-
Notifications
You must be signed in to change notification settings - Fork 24
Add a Service Book class with a shared testProject method, for scripted pipelines #23
Conversation
…y loaded as a library
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This all looks great! Please add docs and tests where possible.
import groovy.json.JsonSlurperClassic; | ||
|
||
|
||
HttpResponse doGetHttpRequest(String requestUrl){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the idea of seeing if we can use the HTTP Request plugin, though that could be a future enhancement.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Futured, for now, but will file an Issue for us to get that evaluated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} | ||
|
||
|
||
return this; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this needed? It looks superfluous.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you don't return "this", you can't use the module as a top namespace object in other modules, but maybe there are better ways to do it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm.. it was working fine when I had a dummy method in https://github.com/davehunt/fxtest-jenkins-pipeline/blob/servicebook/src/org/mozilla/fxtest/ServiceBook.groovy without return this;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe that's what "package" is for :)
} | ||
} | ||
stage('Ship it!') { | ||
if (failures == 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be checking the size of the failures array.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed, I hope!
} | ||
|
||
def testProject(String name) { | ||
node { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We might not want to put the node
here. We're using node
within the stages, and this is only needed for the exit codes on lins 158-160, so we could simple wrap those in a node. I think that would be a more efficient use of our executors.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks; fixed!
) | ||
} | ||
echo "checked out" | ||
node { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that this will run on any executor. If we have a specific agent or label that we wanted to run on, we should do that. I suspect we want a specific docker image.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't yet know much about these actual tests, and/or where/how they best should run, besides that they should run in Docker, on the slave/execution node (at least in the qa-preprod* new setup).
Can we defer that for now, or should we hold off on merging this in until we have it clarified and codified, here?
Latest run is https://qa-preprod-master.fxtest.jenkins.stage.mozaws.net/job/kinto.stage.stephend/19/console. I'll work as I have time, now, on version history and code examples, in the README. Dave and I will likely pair on the tests next week. |
145f174
to
bd3891c
Compare
|
||
|
||
def validURL(url) { | ||
allowedOrgs = ['Kinto', 'mozilla', 'mozilla-services', 'tarekziade', 'rpappalax'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This restriction is good to be aware of. I was thinking folks could make sure tests were somewhat viable before pushing them to a mozilla* org (i.e. that tests could be triggered from any org), but this is much safer route. I suppose we can still follow that workflow in PreProdJenkins and do soak testing there (without hooking into pipeline).
If you don't need the org for tarekziade or me, I'd go ahead and remove them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, Richard. Actually, yes: now that we're getting really close to using this in a production/production-like environment and workflow, it's probably a good time to reel the validation back a bit; I'll make that change now.
// script.doGetHttpRequest = { String url -> [resp] } | ||
// def tests = script.getProjectTests('foo') | ||
// assert tests != null | ||
// } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @tarekziade, we're trying to mock out the getProjectTests
but hit various issues with our attempts. Do you have any suggestions for how to test this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll give it a shot
README.md
Outdated
tests, and ```exit 1``` in the event of failed builds. | ||
|
||
## Examples | ||
```@Library('fxtest@1.7') _ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be ```groovy
and I don't think we need to include the tag in the example.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
README.md
Outdated
@@ -133,6 +133,19 @@ submitToTreeherder( | |||
) | |||
``` | |||
|
|||
## testProject |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The other entries are pipeline steps, whereas this is a ServiceBook class. It feels like there should be some separation in the documentation. Perhaps a heading for pipeline steps, and a heading for ServiceBook with the testProject
method documentated? We're probably close to wanting to break the documentation out to a readthedocs or similar too, as it's getting quite lenghty.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Took a stab at this, but currently the "Shared Libraries..." heading and "Pipeline Steps" and "ServiceBook Class" are all the same heading weight of "#" - let me know if that's a deal-breaker, and I'll rework the subheadings' weights to match!
README.md
Outdated
|
||
def sb = new org.mozilla.fxtest.ServiceBook() | ||
sb.testProject('kinto') | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to close the code sample with ```
, otherwise the next heading is considered code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed; thanks (and, oops!)
README.md
Outdated
@@ -158,6 +171,8 @@ writeCapabilities( | |||
|
|||
## Version History | |||
|
|||
### 1.7 (2017-09-04) | |||
* Introduced `testProject` method, which queries Service Book for project repos. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would reword as something like: Introduces ServiceBook
class, with testProject
method to execute tests for all pipelines associated with the specified project name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks - fixed.
README.md
Outdated
|
||
## Examples | ||
```groovy | ||
def sb = new org.mozilla.fxtest.ServiceBook() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I didn't mean to remove the library import, just the version tag as that will become dated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
r+ with comments addressed. For the headings, I think I'd prefer Pipeline Steps and ServiceBook to be under the top heading, but that would require pushing everything else down a level, which might not look great. This is why I think it's worth moving to readthedocs, as these can then be separate pages then. Would you mind filing a separate issue for that?
README.md
Outdated
@@ -155,9 +156,23 @@ writeCapabilities( | |||
path: 'fx51win10.json' | |||
) | |||
``` | |||
# ServiceBook Class |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd drop 'Class'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
Filed #29 to track moving the README to Read the Docs. |
@davehunt @tarekziade @rpappalax - thoughts and feedback much-desired and appreciated!
I anticipate a fair amount of cleanup needed/desired here, but this is, IMHO, very much a working prototype.
It can be seen working (i.e. getting to the same "tox" error) on https://qa-preprod-master.fxtest.jenkins.stage.mozaws.net/job/kinto.stage.stephend/15/console as in https://qa-preprod-master.fxtest.jenkins.stage.mozaws.net/job/kinto.stage/3/console
Full output (patch): https://gist.github.com/stephendonner/9a3904b1294c12b9ecc67ea42c5ced71 vs. (existing): https://gist.github.com/stephendonner/146f85214800dd25527974ac52929f5a
Since it's a shared library, we'll also need corresponding changes to call testProject() from a project's Jenkinsfile, which I've done (also rough) in mozilla-services/kinto-integration-tests#35