From f98c2a267770533f911aed7149ff8b3f6d7ac607 Mon Sep 17 00:00:00 2001 From: Brian Seeders Date: Mon, 3 May 2021 15:53:21 -0400 Subject: [PATCH] [CI] Create a ciGroup just for tests that use Docker (#98535) (#99090) # Conflicts: # test/scripts/jenkins_xpack_build_kibana.sh --- .ci/es-snapshots/Jenkinsfile_verify_es | 1 + .ci/jobs.yml | 1 + test/scripts/jenkins_xpack_build_kibana.sh | 15 ++++++++- vars/kibanaPipeline.groovy | 31 +++++++++++++++++-- vars/tasks.groovy | 18 ++++++++++- vars/workers.groovy | 2 ++ .../test/fleet_api_integration/apis/index.js | 2 +- .../apps/endpoint/index.ts | 2 +- .../apis/index.ts | 2 +- 9 files changed, 66 insertions(+), 8 deletions(-) diff --git a/.ci/es-snapshots/Jenkinsfile_verify_es b/.ci/es-snapshots/Jenkinsfile_verify_es index b22406e389276..6f46650a2c635 100644 --- a/.ci/es-snapshots/Jenkinsfile_verify_es +++ b/.ci/es-snapshots/Jenkinsfile_verify_es @@ -44,6 +44,7 @@ kibanaPipeline(timeoutMinutes: 210) { task { kibanaPipeline.buildXpack(10) tasks.xpackCiGroups() + tasks.xpackCiGroupDocker() } } } diff --git a/.ci/jobs.yml b/.ci/jobs.yml index e3770b857382d..481029f8f76aa 100644 --- a/.ci/jobs.yml +++ b/.ci/jobs.yml @@ -33,6 +33,7 @@ JOB: - x-pack-ciGroup11 - x-pack-ciGroup12 - x-pack-ciGroup13 + - x-pack-ciGroupDocker - x-pack-accessibility - x-pack-visualRegression diff --git a/test/scripts/jenkins_xpack_build_kibana.sh b/test/scripts/jenkins_xpack_build_kibana.sh index abe0990b9044c..f0b1614374d38 100755 --- a/test/scripts/jenkins_xpack_build_kibana.sh +++ b/test/scripts/jenkins_xpack_build_kibana.sh @@ -25,7 +25,8 @@ node scripts/functional_tests --assert-none-excluded \ --include-tag ciGroup10 \ --include-tag ciGroup11 \ --include-tag ciGroup12 \ - --include-tag ciGroup13 + --include-tag ciGroup13 \ + --include-tag ciGroupDocker echo " -> building and extracting default Kibana distributable for use in functional tests" cd "$KIBANA_DIR" @@ -40,6 +41,18 @@ linuxBuild="$(find "$KIBANA_DIR/target" -name 'kibana-*-linux-x86_64.tar.gz')" installDir="$KIBANA_DIR/install/kibana" mkdir -p "$installDir" tar -xzf "$linuxBuild" -C "$installDir" --strip=1 +cp "$linuxBuild" "$WORKSPACE/kibana-default.tar.gz" mkdir -p "$WORKSPACE/kibana-build-xpack" cp -pR install/kibana/. $WORKSPACE/kibana-build-xpack/ + +echo " -> Archive built plugins" +shopt -s globstar +tar -zcf \ + "$WORKSPACE/kibana-default-plugins.tar.gz" \ + x-pack/plugins/**/target/public \ + x-pack/test/**/target/public \ + examples/**/target/public \ + x-pack/examples/**/target/public \ + test/**/target/public +shopt -u globstar diff --git a/vars/kibanaPipeline.groovy b/vars/kibanaPipeline.groovy index a9ea8651d31df..65e2945ea4464 100644 --- a/vars/kibanaPipeline.groovy +++ b/vars/kibanaPipeline.groovy @@ -130,7 +130,7 @@ def functionalTestProcess(String name, String script) { def ossCiGroupProcess(ciGroup, withDelay = false) { return functionalTestProcess("ciGroup" + ciGroup) { - if (withDelay) { + if (withDelay && !(ciGroup instanceof String) && !(ciGroup instanceof GString)) { sleep((ciGroup-1)*30) // smooth out CPU spikes from ES startup } @@ -147,7 +147,7 @@ def ossCiGroupProcess(ciGroup, withDelay = false) { def xpackCiGroupProcess(ciGroup, withDelay = false) { return functionalTestProcess("xpack-ciGroup" + ciGroup) { - if (withDelay) { + if (withDelay && !(ciGroup instanceof String) && !(ciGroup instanceof GString)) { sleep((ciGroup-1)*30) // smooth out CPU spikes from ES startup } withEnv([ @@ -294,11 +294,36 @@ def buildOss(maxWorkers = '') { } } -def buildXpack(maxWorkers = '') { +def getBuildArtifactBucket() { + def dir = env.ghprbPullId ? "pr-${env.ghprbPullId}" : buildState.get('checkoutInfo').branch.replace("/", "__") + return "gs://ci-artifacts.kibana.dev/default-build/${dir}/${buildState.get('checkoutInfo').commit}" +} + +def buildXpack(maxWorkers = '', uploadArtifacts = false) { notifyOnError { withEnv(["KBN_OPTIMIZER_MAX_WORKERS=${maxWorkers}"]) { runbld("./test/scripts/jenkins_xpack_build_kibana.sh", "Build X-Pack Kibana") } + + if (uploadArtifacts) { + withGcpServiceAccount.fromVaultSecret('secret/kibana-issues/dev/ci-artifacts-key', 'value') { + bash(""" + cd "${env.WORKSPACE}" + gsutil -q -m cp 'kibana-default.tar.gz' '${getBuildArtifactBucket()}/' + gsutil -q -m cp 'kibana-default-plugins.tar.gz' '${getBuildArtifactBucket()}/' + """, "Upload Default Build artifacts to GCS") + } + } + } +} + +def downloadDefaultBuildArtifacts() { + withGcpServiceAccount.fromVaultSecret('secret/kibana-issues/dev/ci-artifacts-key', 'value') { + bash(""" + cd "${env.WORKSPACE}" + gsutil -q -m cp '${getBuildArtifactBucket()}/kibana-default.tar.gz' ./ + gsutil -q -m cp '${getBuildArtifactBucket()}/kibana-default-plugins.tar.gz' ./ + """, "Download Default Build artifacts from GCS") } } diff --git a/vars/tasks.groovy b/vars/tasks.groovy index 7ed6de8094067..1d33fd1249681 100644 --- a/vars/tasks.groovy +++ b/vars/tasks.groovy @@ -49,6 +49,21 @@ def xpackCiGroups() { tasks(ciGroups.collect { kibanaPipeline.xpackCiGroupProcess(it, true) }) } +def xpackCiGroupDocker() { + task { + workers.ci(name: 'xpack-cigroups-docker', size: 'm', ramDisk: true) { + kibanaPipeline.downloadDefaultBuildArtifacts() + kibanaPipeline.bash(""" + cd '${env.WORKSPACE}' + mkdir -p kibana-build-xpack + tar -xzf kibana-default.tar.gz -C kibana-build-xpack --strip=1 + tar -xzf kibana-default-plugins.tar.gz -C kibana + """, "Extract Default Build artifacts") + kibanaPipeline.xpackCiGroupProcess('Docker', true)() + } + } +} + def functionalOss(Map params = [:]) { def config = params ?: [ serverIntegration: true, @@ -100,10 +115,11 @@ def functionalXpack(Map params = [:]) { ] task { - kibanaPipeline.buildXpack(10) + kibanaPipeline.buildXpack(10, true) if (config.ciGroups) { xpackCiGroups() + xpackCiGroupDocker() } if (config.firefox) { diff --git a/vars/workers.groovy b/vars/workers.groovy index 83d439934cbfa..acd3fa51a3fe7 100644 --- a/vars/workers.groovy +++ b/vars/workers.groovy @@ -9,6 +9,8 @@ def label(size) { return 'docker && linux && immutable' case 's-highmem': return 'docker && tests-s' + case 'm': + return 'docker && linux && immutable && gobld/machineType:n2-standard-8' case 'm-highmem': return 'docker && linux && immutable && gobld/machineType:n1-highmem-8' case 'l': diff --git a/x-pack/test/fleet_api_integration/apis/index.js b/x-pack/test/fleet_api_integration/apis/index.js index 4d2bf1d74a495..503926960a2b7 100644 --- a/x-pack/test/fleet_api_integration/apis/index.js +++ b/x-pack/test/fleet_api_integration/apis/index.js @@ -7,7 +7,7 @@ export default function ({ loadTestFile }) { describe('Fleet Endpoints', function () { - this.tags('ciGroup10'); + this.tags('ciGroupDocker'); // EPM loadTestFile(require.resolve('./epm/index')); diff --git a/x-pack/test/security_solution_endpoint/apps/endpoint/index.ts b/x-pack/test/security_solution_endpoint/apps/endpoint/index.ts index f28545f83a890..8639db45a23ee 100644 --- a/x-pack/test/security_solution_endpoint/apps/endpoint/index.ts +++ b/x-pack/test/security_solution_endpoint/apps/endpoint/index.ts @@ -16,7 +16,7 @@ export default function (providerContext: FtrProviderContext) { const { loadTestFile, getService } = providerContext; describe('endpoint', function () { - this.tags('ciGroup7'); + this.tags('ciGroupDocker'); const ingestManager = getService('ingestManager'); const log = getService('log'); diff --git a/x-pack/test/security_solution_endpoint_api_int/apis/index.ts b/x-pack/test/security_solution_endpoint_api_int/apis/index.ts index 9cf8a5e6e4c6d..d5f84e43f0807 100644 --- a/x-pack/test/security_solution_endpoint_api_int/apis/index.ts +++ b/x-pack/test/security_solution_endpoint_api_int/apis/index.ts @@ -15,7 +15,7 @@ export default function endpointAPIIntegrationTests(providerContext: FtrProvider describe('Endpoint plugin', function () { const ingestManager = getService('ingestManager'); - this.tags('ciGroup7'); + this.tags('ciGroupDocker'); const log = getService('log'); if (!isRegistryEnabled()) {