From 0a7a8723ceffd60e39c878d628501103e98fd5eb Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Mon, 28 Sep 2020 10:01:59 +0100 Subject: [PATCH 1/4] [CI] cherry-pick #20891 (#21314) Co-authored-by: Ivan Fernandez Calvo --- Jenkinsfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index e7f91ef95e5..a70d6f77bd0 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -21,6 +21,7 @@ pipeline { JOB_GCS_CREDENTIALS = 'beats-ci-gcs-plugin' OSS_MODULE_PATTERN = '^[a-z0-9]+beat\\/module\\/([^\\/]+)\\/.*' PIPELINE_LOG_LEVEL = 'INFO' + PYTEST_ADDOPTS = "${params.PYTEST_ADDOPTS}" RUNBLD_DISABLE_NOTIFICATIONS = 'true' TERRAFORM_VERSION = "0.12.24" XPACK_MODULE_PATTERN = '^x-pack\\/[a-z0-9]+beat\\/module\\/([^\\/]+)\\/.*' @@ -44,6 +45,7 @@ pipeline { string(name: 'awsRegion', defaultValue: 'eu-central-1', description: 'Default AWS region to use for testing.') booleanParam(name: 'runAllStages', defaultValue: false, description: 'Allow to run all stages.') booleanParam(name: 'macosTest', defaultValue: false, description: 'Allow macOS stages.') + string(name: 'PYTEST_ADDOPTS', defaultValue: '', description: 'Additional options to pass to pytest. Use PYTEST_ADDOPTS="-k pattern" to only run tests matching the specified pattern. For retries you can use `--reruns 3 --reruns-delay 15`') } stages { stage('Checkout') { From 5b5c4cfef566073376852b91a2d8ac4c4cc960b5 Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Mon, 28 Sep 2020 11:23:49 +0100 Subject: [PATCH 2/4] [CI] refactor runbld post build action (#21256) --- Jenkinsfile | 51 ++++----------------------------------------------- 1 file changed, 4 insertions(+), 47 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index a70d6f77bd0..9121d0d48cf 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -12,7 +12,8 @@ pipeline { agent { label 'ubuntu-18 && immutable' } environment { AWS_ACCOUNT_SECRET = 'secret/observability-team/ci/elastic-observability-aws-account-auth' - BASE_DIR = 'src/github.com/elastic/beats' + REPO = 'beats' + BASE_DIR = "src/github.com/elastic/${env.REPO}" DOCKERELASTIC_SECRET = 'secret/observability-team/ci/docker-registry/prod' DOCKER_COMPOSE_VERSION = "1.21.0" DOCKER_REGISTRY = 'docker.elastic.co' @@ -122,7 +123,7 @@ pipeline { } post { always { - runbld() + runbld(stashedTestReports: stashedTestReports, project: env.REPO) } cleanup { notifyBuildResult(prComment: true) @@ -348,7 +349,7 @@ def archiveTestOutput(Map args = [:]) { } cmd(label: 'Prepare test output', script: 'python .ci/scripts/pre_archive_test.py') dir('build') { - junitAndStore(allowEmptyResults: true, keepLongStdio: true, testResults: args.testResults, id: args.id) + junitAndStore(allowEmptyResults: true, keepLongStdio: true, testResults: args.testResults, stashedTestReports: stashedTestReports, id: args.id) archiveArtifacts(allowEmptyArchive: true, artifacts: args.artifacts) } catchError(buildResult: 'SUCCESS', message: 'Failed to archive the build test results', stageResult: 'SUCCESS') { @@ -362,50 +363,6 @@ def archiveTestOutput(Map args = [:]) { } } -/** -* This method wraps the junit built-in step to archive the test reports that gonna be populated later on -* with the runbld post build step. -*/ -def junitAndStore(Map args = [:]) { - junit(args) - // args.id could be null in some cases, so let's use the currentmilliseconds - def stageName = args.id ? args.id?.replaceAll("[\\W]|_",'-') : "uncategorized-${new java.util.Date().getTime()}" - stash(includes: args.testResults, allowEmpty: true, name: stageName, useDefaultExcludes: true) - stashedTestReports[stageName] = stageName -} - -/** -* This method populates the test output using the runbld approach. For such it requires the -* global variable stashedTestReports. -* TODO: should be moved to the shared library -*/ -def runbld() { - catchError(buildResult: 'SUCCESS', message: 'runbld post build action failed.') { - if (stashedTestReports) { - def jobName = isPR() ? 'elastic+beats+pull-request' : 'elastic+beats' - deleteDir() - unstashV2(name: 'source', bucket: "${JOB_GCS_BUCKET}", credentialsId: "${JOB_GCS_CREDENTIALS}") - dir("${env.BASE_DIR}") { - // Unstash the test reports - stashedTestReports.each { k, v -> - dir(k) { - unstash(v) - } - } - } - sh(label: 'Process JUnit reports with runbld', - script: """\ - ## for debugging purposes - find . -name "TEST-*.xml" - cat >./runbld-script < Date: Mon, 28 Sep 2020 11:24:05 +0100 Subject: [PATCH 3/4] [CI] Enable macOS builds for branches/tags (#21323) --- auditbeat/Jenkinsfile.yml | 4 +++- filebeat/Jenkinsfile.yml | 4 +++- generator/Jenkinsfile.yml | 8 ++++++-- heartbeat/Jenkinsfile.yml | 4 +++- metricbeat/Jenkinsfile.yml | 4 +++- packetbeat/Jenkinsfile.yml | 4 +++- x-pack/auditbeat/Jenkinsfile.yml | 4 +++- x-pack/elastic-agent/Jenkinsfile.yml | 4 +++- x-pack/filebeat/Jenkinsfile.yml | 4 +++- x-pack/functionbeat/Jenkinsfile.yml | 4 +++- x-pack/metricbeat/Jenkinsfile.yml | 4 +++- 11 files changed, 36 insertions(+), 12 deletions(-) diff --git a/auditbeat/Jenkinsfile.yml b/auditbeat/Jenkinsfile.yml index 873e2c319f3..84bef6a6ceb 100644 --- a/auditbeat/Jenkinsfile.yml +++ b/auditbeat/Jenkinsfile.yml @@ -21,13 +21,15 @@ stages: mage: "mage build unitTest" platforms: ## override default label in this specific stage. - "macosx" - when: ## Aggregate when with the top-level one. + when: ## Override the top-level when. comments: - "/test auditbeat for macos" labels: - "macOS" parameters: - "macosTest" + branches: true ## for all the branches + tags: true ## for all the tags windows: mage: "mage build unitTest" platforms: ## override default labels in this specific stage. diff --git a/filebeat/Jenkinsfile.yml b/filebeat/Jenkinsfile.yml index 45b032accfb..d0f36b24536 100644 --- a/filebeat/Jenkinsfile.yml +++ b/filebeat/Jenkinsfile.yml @@ -20,13 +20,15 @@ stages: mage: "mage build unitTest" platforms: ## override default label in this specific stage. - "macosx" - when: ## Aggregate when with the top-level one. + when: ## Override the top-level when. comments: - "/test filebeat for macos" labels: - "macOS" parameters: - "macosTest" + branches: true ## for all the branches + tags: true ## for all the tags windows: mage: "mage build unitTest" platforms: ## override default labels in this specific stage. diff --git a/generator/Jenkinsfile.yml b/generator/Jenkinsfile.yml index 071d24858bb..b20081956ee 100644 --- a/generator/Jenkinsfile.yml +++ b/generator/Jenkinsfile.yml @@ -23,21 +23,25 @@ stages: make: "make -C generator/_templates/metricbeat test" platforms: ## override default label in this specific stage. - "macosx" - when: ## Aggregate when with the top-level one. + when: ## Override the top-level when. comments: - "/test generator for macos" labels: - "macOS" parameters: - "macosTest" + branches: true ## for all the branches + tags: true ## for all the tags macos-beat: make: "make -C generator/_templates/beat test" platforms: ## override default label in this specific stage. - "macosx" - when: ## Aggregate when with the top-level one. + when: ## Override the top-level when. comments: - "/test generator for macos" labels: - "macOS" parameters: - "macosTest" + branches: true ## for all the branches + tags: true ## for all the tags diff --git a/heartbeat/Jenkinsfile.yml b/heartbeat/Jenkinsfile.yml index b8668715c3c..71369fd5814 100644 --- a/heartbeat/Jenkinsfile.yml +++ b/heartbeat/Jenkinsfile.yml @@ -19,13 +19,15 @@ stages: mage: "mage build unitTest" platforms: ## override default label in this specific stage. - "macosx" - when: ## Aggregate when with the top-level one. + when: ## Override the top-level when. comments: - "/test heartbeat for macos" labels: - "macOS" parameters: - "macosTest" + branches: true ## for all the branches + tags: true ## for all the tags windows: mage: "mage build unitTest" platforms: ## override default labels in this specific stage. diff --git a/metricbeat/Jenkinsfile.yml b/metricbeat/Jenkinsfile.yml index 1219a27af77..09f1a49b9e2 100644 --- a/metricbeat/Jenkinsfile.yml +++ b/metricbeat/Jenkinsfile.yml @@ -27,13 +27,15 @@ stages: mage: "mage build unitTest" platforms: ## override default label in this specific stage. - "macosx" - when: ## Aggregate when with the top-level one. + when: ## Override the top-level when. comments: - "/test metricbeat for macos" labels: - "macOS" parameters: - "macosTest" + branches: true ## for all the branches + tags: true ## for all the tags windows: mage: "mage build unitTest" platforms: ## override default labels in this specific stage. diff --git a/packetbeat/Jenkinsfile.yml b/packetbeat/Jenkinsfile.yml index 416e69a203b..580826bf2fa 100644 --- a/packetbeat/Jenkinsfile.yml +++ b/packetbeat/Jenkinsfile.yml @@ -19,13 +19,15 @@ stages: mage: "mage build unitTest" platforms: ## override default label in this specific stage. - "macosx" - when: ## Aggregate when with the top-level one. + when: ## Override the top-level when. comments: - "/test packetbeat for macos" labels: - "macOS" parameters: - "macosTest" + branches: true ## for all the branches + tags: true ## for all the tags windows: mage: "mage build unitTest" platforms: ## override default labels in this specific stage. diff --git a/x-pack/auditbeat/Jenkinsfile.yml b/x-pack/auditbeat/Jenkinsfile.yml index 86f0832d3f2..fd73c10a1c5 100644 --- a/x-pack/auditbeat/Jenkinsfile.yml +++ b/x-pack/auditbeat/Jenkinsfile.yml @@ -20,13 +20,15 @@ stages: mage: "mage build unitTest" platforms: ## override default label in this specific stage. - "macosx" - when: ## Aggregate when with the top-level one. + when: ## Override the top-level when. comments: - "/test auditbeat for macos" labels: - "macOS" parameters: - "macosTest" + branches: true ## for all the branches + tags: true ## for all the tags windows: mage: "mage build unitTest" platforms: ## override default labels in this specific stage. diff --git a/x-pack/elastic-agent/Jenkinsfile.yml b/x-pack/elastic-agent/Jenkinsfile.yml index 8f99e11da3c..f5074df5965 100644 --- a/x-pack/elastic-agent/Jenkinsfile.yml +++ b/x-pack/elastic-agent/Jenkinsfile.yml @@ -19,13 +19,15 @@ stages: mage: "mage build unitTest" platforms: ## override default label in this specific stage. - "macosx" - when: ## Aggregate when with the top-level one. + when: ## Override the top-level when. comments: - "/test x-pack/elastic-agent for macos" labels: - "macOS" parameters: - "macosTest" + branches: true ## for all the branches + tags: true ## for all the tags windows: mage: "mage build unitTest" platforms: ## override default labels in this specific stage. diff --git a/x-pack/filebeat/Jenkinsfile.yml b/x-pack/filebeat/Jenkinsfile.yml index d3d5e6d862e..437f4c074db 100644 --- a/x-pack/filebeat/Jenkinsfile.yml +++ b/x-pack/filebeat/Jenkinsfile.yml @@ -20,13 +20,15 @@ stages: mage: "mage build unitTest" platforms: ## override default label in this specific stage. - "macosx" - when: ## Aggregate when with the top-level one. + when: ## Override the top-level when. comments: - "/test x-pack/filebeat for macos" labels: - "macOS" parameters: - "macosTest" + branches: true ## for all the branches + tags: true ## for all the tags windows: mage: "mage build unitTest" platforms: ## override default labels in this specific stage. diff --git a/x-pack/functionbeat/Jenkinsfile.yml b/x-pack/functionbeat/Jenkinsfile.yml index f3428ae7cc8..20a8527eae3 100644 --- a/x-pack/functionbeat/Jenkinsfile.yml +++ b/x-pack/functionbeat/Jenkinsfile.yml @@ -19,13 +19,15 @@ stages: mage: "mage build unitTest" platforms: ## override default label in this specific stage. - "macosx" - when: ## Aggregate when with the top-level one. + when: ## Override the top-level when. comments: - "/test x-pack/functionbeat for macos" labels: - "macOS" parameters: - "macosTest" + branches: true ## for all the branches + tags: true ## for all the tags windows: mage: "mage build unitTest" platforms: ## override default labels in this specific stage. diff --git a/x-pack/metricbeat/Jenkinsfile.yml b/x-pack/metricbeat/Jenkinsfile.yml index 2448d43d85b..00fa2c1265e 100644 --- a/x-pack/metricbeat/Jenkinsfile.yml +++ b/x-pack/metricbeat/Jenkinsfile.yml @@ -22,13 +22,15 @@ stages: mage: "mage build unitTest" platforms: ## override default label in this specific stage. - "macosx" - when: ## Aggregate when with the top-level one. + when: ## Override the top-level when. comments: - "/test x-pack/metricbeat for macos" labels: - "macOS" parameters: - "macosTest" + branches: true ## for all the branches + tags: true ## for all the tags windows: mage: "mage build unitTest" platforms: ## override default labels in this specific stage. From a75582f3d7233c8fb9828e25fd39cf9ad35cf903 Mon Sep 17 00:00:00 2001 From: Jaime Soriano Pastor Date: Mon, 28 Sep 2020 13:34:12 +0200 Subject: [PATCH 4/4] Skip flaky test TestClientPublishEventKerberosAware (#21296) --- libbeat/outputs/elasticsearch/client_integration_test.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libbeat/outputs/elasticsearch/client_integration_test.go b/libbeat/outputs/elasticsearch/client_integration_test.go index e243cb7d1e4..67ccc34b8f7 100644 --- a/libbeat/outputs/elasticsearch/client_integration_test.go +++ b/libbeat/outputs/elasticsearch/client_integration_test.go @@ -55,6 +55,8 @@ func TestClientPublishEvent(t *testing.T) { } func TestClientPublishEventKerberosAware(t *testing.T) { + t.Skip("Flaky test: https://github.com/elastic/beats/issues/21295") + err := setupRoleMapping(t, eslegtest.GetEsKerberosHost()) if err != nil { t.Fatal(err)