-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
chore: simplify triggering the E2E tests for Beats #21790
Changes from 6 commits
54cdb84
995df39
1bd97e6
76f7b71
9808a18
ace848e
3afdcf3
92ca4ed
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,13 @@ | |
|
||
@Library('apm@current') _ | ||
|
||
import groovy.transform.Field | ||
|
||
/** | ||
This is required to store the test suites we will use to trigger the E2E tests. | ||
*/ | ||
@Field def e2eTestSuites = [] | ||
|
||
pipeline { | ||
agent none | ||
environment { | ||
|
@@ -121,7 +128,7 @@ pipeline { | |
release() | ||
pushCIDockerImages() | ||
} | ||
runE2ETestForPackages() | ||
prepareE2ETestForPackage("${BEATS_FOLDER}") | ||
} | ||
} | ||
stage('Package Mac OS'){ | ||
|
@@ -152,6 +159,13 @@ pipeline { | |
} | ||
} | ||
} | ||
stage('Run E2E Tests for Packages'){ | ||
agent { label 'ubuntu && immutable' } | ||
options { skipDefaultCheckout() } | ||
steps { | ||
runE2ETests() | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
@@ -208,14 +222,15 @@ def tagAndPush(name){ | |
def commitName = "${DOCKER_REGISTRY}/observability-ci/${name}${variant}:${env.GIT_BASE_COMMIT}" | ||
|
||
def iterations = 0 | ||
retryWithSleep(retries: 3, seconds: 5, backoff: true) | ||
retryWithSleep(retries: 3, seconds: 5, backoff: true) { | ||
iterations++ | ||
def status = sh(label:'Change tag and push', script: """ | ||
docker tag ${oldName} ${newName} | ||
docker push ${newName} | ||
docker tag ${oldName} ${commitName} | ||
docker push ${commitName} | ||
""", returnStatus: true) | ||
} | ||
|
||
if ( status > 0 && iterations < 3) { | ||
error('tag and push failed, retry') | ||
|
@@ -225,22 +240,18 @@ def tagAndPush(name){ | |
} | ||
} | ||
|
||
def runE2ETestForPackages(){ | ||
def suite = '' | ||
|
||
catchError(buildResult: 'UNSTABLE', message: 'Unable to run e2e tests', stageResult: 'FAILURE') { | ||
if ("${env.BEATS_FOLDER}" == "filebeat" || "${env.BEATS_FOLDER}" == "x-pack/filebeat") { | ||
suite = 'helm,fleet' | ||
} else if ("${env.BEATS_FOLDER}" == "metricbeat" || "${env.BEATS_FOLDER}" == "x-pack/metricbeat") { | ||
suite = '' | ||
} else if ("${env.BEATS_FOLDER}" == "x-pack/elastic-agent") { | ||
suite = 'fleet' | ||
} else { | ||
echo("Skipping E2E tests for ${env.BEATS_FOLDER}.") | ||
return | ||
} | ||
|
||
triggerE2ETests(suite) | ||
def prepareE2ETestForPackage(String beat){ | ||
if ("${beat}" == "filebeat" || "${beat}" == "x-pack/filebeat") { | ||
e2eTestSuites.push('fleet') | ||
e2eTestSuites.push('helm') | ||
} else if ("${beat}" == "metricbeat" || "${beat}" == "x-pack/metricbeat") { | ||
e2eTestSuites.push('ALL') | ||
echo("${beat} adds all test suites to the E2E tests job.") | ||
} else if ("${beat}" == "x-pack/elastic-agent") { | ||
e2eTestSuites.push('fleet') | ||
} else { | ||
echo("${beat} does not add any test suite to the E2E tests job.") | ||
return | ||
} | ||
} | ||
|
||
|
@@ -257,8 +268,29 @@ def release(){ | |
} | ||
} | ||
|
||
def runE2ETests(){ | ||
if (e2eTestSuites.size()) { | ||
echo("Not triggering E2E tests for PR-${env.CHANGE_ID} because the changes does not affect the E2E.") | ||
return | ||
} | ||
|
||
def suites = '' // empty value represents all suites in the E2E tests | ||
|
||
catchError(buildResult: 'UNSTABLE', message: 'Unable to run e2e tests', stageResult: 'FAILURE') { | ||
def suitesSet = e2eTestSuites.toSet() | ||
|
||
if (!suitesSet.contains('ALL')) { | ||
suitesSet.each { suite -> | ||
suites += "${suite}," | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Verified that last comma does not cause any new suite with empty value. See https://beats-ci.elastic.co/job/e2e-tests/job/e2e-testing-mbp/job/master/512/parameters/ |
||
}; | ||
} | ||
|
||
triggerE2ETests(suites) | ||
} | ||
} | ||
|
||
def triggerE2ETests(String suite) { | ||
echo("Triggering E2E tests for ${env.BEATS_FOLDER}. Test suite: ${suite}.") | ||
echo("Triggering E2E tests for PR-${env.CHANGE_ID}. Test suites: ${suite}.") | ||
|
||
def branchName = isPR() ? "${env.CHANGE_TARGET}" : "${env.JOB_BASE_NAME}" | ||
def e2eTestsPipeline = "e2e-tests/e2e-testing-mbp/${branchName}" | ||
|
@@ -285,7 +317,7 @@ def triggerE2ETests(String suite) { | |
wait: false | ||
) | ||
|
||
def notifyContext = "${env.GITHUB_CHECK_E2E_TESTS_NAME} for ${env.BEATS_FOLDER}" | ||
def notifyContext = "${env.GITHUB_CHECK_E2E_TESTS_NAME}" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Only one GH check per PR |
||
githubNotify(context: "${notifyContext}", description: "${notifyContext} ...", status: 'PENDING', targetUrl: "${env.JENKINS_URL}search/?q=${e2eTestsPipeline.replaceAll('/','+')}") | ||
} | ||
|
||
|
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.
toSet()
is allowed by Jenkins sandbox: