From eea3d6b705aced34c3ac893158781ed7da197622 Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Thu, 18 Feb 2021 16:21:11 +0000 Subject: [PATCH 1/6] [CI] Run e2e for fleet --- x-pack/elastic-agent/Jenkinsfile.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/x-pack/elastic-agent/Jenkinsfile.yml b/x-pack/elastic-agent/Jenkinsfile.yml index 9a30d836391b..60bfcbdf8c29 100644 --- a/x-pack/elastic-agent/Jenkinsfile.yml +++ b/x-pack/elastic-agent/Jenkinsfile.yml @@ -88,4 +88,5 @@ stages: packaging-linux: packaging-linux: "mage package" e2e: - enabled: false + enabled: true + entrypoint: 'fleet-test.sh' From b53ae70fa0177c97b3399c63a78018f2804ed07c Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Mon, 22 Feb 2021 17:00:30 +0000 Subject: [PATCH 2/6] Fail the e2e instead get the status --- Jenkinsfile | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 8e8d67c782b7..324a0c2d7b8b 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -436,14 +436,12 @@ def e2e(Map args = [:]) { "LOG_LEVEL=TRACE"]) { def status = 0 filebeat(output: dockerLogFile){ - status = sh(script: ".ci/scripts/${entrypoint}", - label: "Run functional tests ${entrypoint}", - returnStatus: true) - } - junit(allowEmptyResults: true, keepLongStdio: true, testResults: "outputs/TEST-*.xml") - archiveArtifacts allowEmptyArchive: true, artifacts: "outputs/TEST-*.xml" - if (status != 0) { - error("ERROR: functional tests for ${args?.directory?.trim()} has failed. See the test report and ${dockerLogFile}.") + try { + sh(script: ".ci/scripts/${entrypoint}", label: "Run functional tests ${entrypoint}") + } finally { + junit(allowEmptyResults: true, keepLongStdio: true, testResults: "outputs/TEST-*.xml") + archiveArtifacts allowEmptyArchive: true, artifacts: "outputs/TEST-*.xml" + } } } } From 049a1b9b136f52f73952e62549f513f29886d98b Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Mon, 22 Feb 2021 17:03:04 +0000 Subject: [PATCH 3/6] PUblish packages earlier to be consumed if needed --- Jenkinsfile | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 324a0c2d7b8b..2419d34ca5fb 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -469,19 +469,15 @@ def target(Map args = [:]) { dir(isMage ? directory : '') { cmd(label: "${args.id?.trim() ? args.id : env.STAGE_NAME} - ${command}", script: "${command}") } - // TODO: - // Packaging should happen only after the e2e? + // Publish packages shoud happen always to easily consume those artifacts if the + // e2e were triggered and failed. if (isPackaging) { publishPackages("${directory}") + pushCIDockerImages("${directory}") } if(isE2E) { e2e(args) } - // TODO: - // push docker images should happen only after the e2e? - if (isPackaging) { - pushCIDockerImages("${directory}") - } } } } From 5733224dc5d1d89127d54cbc8ce7f007f364e817 Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Mon, 11 Oct 2021 17:02:11 +0100 Subject: [PATCH 4/6] ci: support e2e stage by running the given job --- Jenkinsfile | 46 ++++++++++++++++++++++++++-- x-pack/elastic-agent/Jenkinsfile.yml | 3 +- 2 files changed, 45 insertions(+), 4 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 834bf2e3ede0..ceb27770c1f4 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -514,15 +514,26 @@ def getBeatsName(baseDir) { return baseDir.replace('x-pack/', '') } + +/** +* This method runs the end 2 end testing +*/ +def e2e(Map args = [:]) { + if (!args.e2e?.get('enabled', false)) { return } + if (args.e2e.get('entrypoint', '')?.trim()) { + e2e_with_entrypoint(args) + } else { + e2e_with_job(args) + } +} + /** * This method runs the end 2 end testing in the same worker where the packages have been * generated, this should help to speed up the things */ -def e2e(Map args = [:]) { - def enabled = args.e2e?.get('enabled', false) +def e2e_with_entrypoint(Map args = [:]) { def entrypoint = args.e2e?.get('entrypoint') def dockerLogFile = "docker_logs_${entrypoint}.log" - if (!enabled) { return } dir("${env.WORKSPACE}/src/github.com/elastic/e2e-testing") { // TBC with the target branch if running on a PR basis. git(branch: 'master', credentialsId: '2a9602aa-ab9f-4e52-baf3-b71ca88469c7-UserAndToken', url: 'https://github.com/elastic/e2e-testing.git') @@ -547,6 +558,35 @@ def e2e(Map args = [:]) { } } +/** +* This method triggers the end 2 end testing job. +*/ +def e2e_with_job(Map args = [:]) { + def jobName = args.e2e?.get('job') + def testSuite = args.e2e?.get('suite', '') + def notifyContext = "e2e-${args.context}" + def e2eTestsPipeline = "${jobName}/${isPR() ? "${env.CHANGE_TARGET}" : "${env.JOB_BASE_NAME}"}" + + def parameters = [ + booleanParam(name: 'forceSkipGitChecks', value: true), + booleanParam(name: 'forceSkipPresubmit', value: true), + booleanParam(name: 'notifyOnGreenBuilds', value: !isPR()), + string(name: 'BEAT_VERSION', value: "${env.VERSION}-SNAPSHOT"), + string(name: 'runTestsSuites', value: testSuite), + string(name: 'GITHUB_CHECK_NAME', value: notifyContext), + string(name: 'GITHUB_CHECK_REPO', value: env.REPO), + string(name: 'GITHUB_CHECK_SHA1', value: env.GIT_BASE_COMMIT), + ] + + build(job: "${e2eTestsPipeline}", + parameters: parameters, + propagate: false, + wait: false + ) + + githubNotify(context: "${notifyContext}", description: "${notifyContext} ...", status: 'PENDING', targetUrl: "${env.JENKINS_URL}search/?q=${e2eTestsPipeline.replaceAll('/','+')}") +} + /** * This method runs the given command supporting two kind of scenarios: * - make -C then the dir(location) is not required, aka by disaling isMage: false diff --git a/x-pack/elastic-agent/Jenkinsfile.yml b/x-pack/elastic-agent/Jenkinsfile.yml index 1baaae785db7..57fd790471e8 100644 --- a/x-pack/elastic-agent/Jenkinsfile.yml +++ b/x-pack/elastic-agent/Jenkinsfile.yml @@ -97,7 +97,8 @@ stages: packaging-linux: "mage package" e2e: enabled: true - entrypoint: 'fleet-test.sh' + job: 'e2e-tests/e2e-testing-mbp' + suite: 'fleet' stage: packaging packaging-arm: packaging-arm: "mage package" From ba377748b70bb7433d8abc3f178e5f017bafd434 Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Wed, 13 Oct 2021 11:53:51 +0100 Subject: [PATCH 5/6] Use testMatrixFile --- Jenkinsfile | 6 +++--- x-pack/elastic-agent/Jenkinsfile.yml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index ceb27770c1f4..de42a0f1ce87 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -563,7 +563,7 @@ def e2e_with_entrypoint(Map args = [:]) { */ def e2e_with_job(Map args = [:]) { def jobName = args.e2e?.get('job') - def testSuite = args.e2e?.get('suite', '') + def testMatrixFile = args.e2e?.get('testMatrixFile', '') def notifyContext = "e2e-${args.context}" def e2eTestsPipeline = "${jobName}/${isPR() ? "${env.CHANGE_TARGET}" : "${env.JOB_BASE_NAME}"}" @@ -572,7 +572,7 @@ def e2e_with_job(Map args = [:]) { booleanParam(name: 'forceSkipPresubmit', value: true), booleanParam(name: 'notifyOnGreenBuilds', value: !isPR()), string(name: 'BEAT_VERSION', value: "${env.VERSION}-SNAPSHOT"), - string(name: 'runTestsSuites', value: testSuite), + string(name: 'testMatrixFile', value: testMatrixFile), string(name: 'GITHUB_CHECK_NAME', value: notifyContext), string(name: 'GITHUB_CHECK_REPO', value: env.REPO), string(name: 'GITHUB_CHECK_SHA1', value: env.GIT_BASE_COMMIT), @@ -619,7 +619,7 @@ def target(Map args = [:]) { cmd(label: "${args.id?.trim() ? args.id : env.STAGE_NAME} - ${command}", script: "${command}") } } - // Publish packages shoud happen always to easily consume those artifacts if the + // Publish packages should happen always to easily consume those artifacts if the // e2e were triggered and failed. if (isPackaging) { publishPackages("${directory}") diff --git a/x-pack/elastic-agent/Jenkinsfile.yml b/x-pack/elastic-agent/Jenkinsfile.yml index 57fd790471e8..0f3fed1b5e88 100644 --- a/x-pack/elastic-agent/Jenkinsfile.yml +++ b/x-pack/elastic-agent/Jenkinsfile.yml @@ -98,7 +98,7 @@ stages: e2e: enabled: true job: 'e2e-tests/e2e-testing-mbp' - suite: 'fleet' + testMatrixFile: '.ci/.e2e-tests-for-elastic-agent.yaml' stage: packaging packaging-arm: packaging-arm: "mage package" From fd2a2feaed4526dafc56c65bd91cdac1c3cddece Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Wed, 13 Oct 2021 11:54:16 +0100 Subject: [PATCH 6/6] Update Jenkinsfile --- Jenkinsfile | 1 - 1 file changed, 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index de42a0f1ce87..861b2b6c541f 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -514,7 +514,6 @@ def getBeatsName(baseDir) { return baseDir.replace('x-pack/', '') } - /** * This method runs the end 2 end testing */