Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run tests for integrations in parallel #421

Merged
merged 34 commits into from
Dec 1, 2020

Conversation

mtojek
Copy link
Contributor

@mtojek mtojek commented Nov 26, 2020

What does this PR do?

This PR modifies the Jenkins pipeline configuration to dynamically create stages and run integration tests in parallel. I'll leverage from this one while working on the #370 , so I won't break the pipeline for other packages (at some point in time Metricbeat will start publishing metrics under a new key).

Still TODOs:

  • Don't spawn the Elastic stack if there is no tests defined
  • Build integrations for UpdatePackageStorage

How to test this PR locally

The CI builder will verify it.

Related issues

@mtojek mtojek self-assigned this Nov 26, 2020
@elasticmachine
Copy link

elasticmachine commented Nov 26, 2020

💚 Build Succeeded

the below badges are clickable and redirect to their specific view in the CI or DOCS
Pipeline View Test View Changes Artifacts preview

Expand to view the summary

Build stats

  • Build Cause: Pull request #421 updated

  • Start Time: 2020-12-01T09:53:28.024+0000

  • Duration: 12 min 59 sec

Test stats 🧪

Test Results
Failed 0
Passed 25
Skipped 0
Total 25

@mtojek
Copy link
Contributor Author

mtojek commented Nov 30, 2020

@kuisathaverat I'm trying to build and test integrations in parallel, but unfortunately the pipeline fails with the following error:

Unhandled arch in NODE_LABELS: master
— Error signal
<1s

For reference:
https://beats-ci.elastic.co/blue/organizations/jenkins/Ingest-manager%2Fintegrations/detail/PR-421/8/pipeline/167

I'm not quite sure if it started failing after the weekend outage. I would appreciate if you can provide me some guidance here.

@mtojek
Copy link
Contributor Author

mtojek commented Nov 30, 2020

I think I went further, just need to select the correct host labels.

.ci/Jenkinsfile Outdated
''')
integrations["${it}"] = {
env.NODE_LABELS = "master linux x86_64"
node {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
node {
node('ubuntu-18 && immutable') {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me try this one...

.ci/Jenkinsfile Outdated
../../build/elastic-package test -v --report-format xUnit --report-output file
''')
integrations["${it}"] = {
env.NODE_LABELS = "master linux x86_64"
Copy link
Contributor

@kuisathaverat kuisathaverat Nov 30, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure what this for

Suggested change
env.NODE_LABELS = "master linux x86_64"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Firstly it complained about arch, then os and then missing Go runtime. I will try your suggestion with node('ubuntu-18 && immutable')

@mtojek
Copy link
Contributor Author

mtojek commented Nov 30, 2020

Ok, it looks like I hit this bug (or feature request): https://issues.jenkins.io/browse/JENKINS-55438

@mtojek
Copy link
Contributor Author

mtojek commented Nov 30, 2020

@mtojek
Copy link
Contributor Author

mtojek commented Nov 30, 2020

jenkins run the tests please

@mtojek
Copy link
Contributor Author

mtojek commented Nov 30, 2020

@mtojek mtojek marked this pull request as ready for review November 30, 2020 20:00
@mtojek
Copy link
Contributor Author

mtojek commented Nov 30, 2020

@ycombinator This PR is finally ready for review. Please take a look at it if you're free.

Copy link
Contributor

@ycombinator ycombinator left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is amazing - comparing the latest CI run for this PR with a master branch CI run, looks like we save almost 3 minutes overall! And that's despite the fact that we now have to start the Elastic Stack on each parallel node (if necessary), which takes about 2m.

It would be nice if someday in the future we could share the Elastic Stack amongst the parallel steps but I don't know enough about Jenkins networking to know if this would be possible or how complex it might be. Anyway, this is something for later. Already with this PR, as we add more integrations packages, we're going to start seeing benefits!

dir("${BASE_DIR}/packages/${it}") {
sh(label: "Check integration: ${it}", script: '../../build/elastic-package check -v')
def r = sh(label: "Find test folders", script: 'find . -d -name test | grep .', returnStatus: true)
if (r == 0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: IDK enough Groovy but if you could invert this condition and return early that would be nice for extra readability but also not absolutely required at this time.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a short code block, let's leave it as is, but thanks for the suggestion!

try {
dir("${BASE_DIR}/packages/${it}") {
sh(label: "Check integration: ${it}", script: '../../build/elastic-package check -v')
def r = sh(label: "Find test folders", script: 'find . -d -name test | grep .', returnStatus: true)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add a comment here explaining why you're doing this? I know you explained this in the PR description but a comment would help anyone in the future looking at this code without having to look up the PR for it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

Copy link
Contributor

@ycombinator ycombinator left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@mtojek mtojek merged commit d2e73ba into elastic:master Dec 1, 2020
eyalkraft pushed a commit to build-security/integrations that referenced this pull request Mar 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[CI] Introduce concurrency in package testing
4 participants