From 11d5db009af59820e9f6e9e92bb7b25099e17574 Mon Sep 17 00:00:00 2001 From: Adrien Mannocci Date: Mon, 27 Jun 2022 15:26:13 +0200 Subject: [PATCH 1/2] Add initial support of smoketests in CI Signed-off-by: Adrien Mannocci --- .ci/jobs/apm-server-smoketests-mbp.yml | 45 +++++++++++++++++ .ci/smoke-tests.groovy | 70 ++++++++++++++++++++++++++ 2 files changed, 115 insertions(+) create mode 100644 .ci/jobs/apm-server-smoketests-mbp.yml create mode 100644 .ci/smoke-tests.groovy diff --git a/.ci/jobs/apm-server-smoketests-mbp.yml b/.ci/jobs/apm-server-smoketests-mbp.yml new file mode 100644 index 00000000000..3e4860f58bc --- /dev/null +++ b/.ci/jobs/apm-server-smoketests-mbp.yml @@ -0,0 +1,45 @@ +--- +- job: + name: apm-server/smoke-tests + display-name: APM Server Smoke Tests + description: APM Server Smoke Tests + project-type: multibranch + concurrent: true + script-path: .ci/smoke-tests.groovy + scm: + - github: + branch-discovery: no-pr + discover-pr-forks-strategy: merge-current + discover-pr-forks-trust: permission + discover-pr-origin: merge-current + discover-tags: false + head-filter-regex: '(main|7\.17|8\.\d+|PR-.*)' + notification-context: 'apm-server-smoketests' + repo: apm-server + repo-owner: elastic + credentials-id: 2a9602aa-ab9f-4e52-baf3-b71ca88469c7-UserAndToken + ssh-checkout: + credentials: f6c7695a-671e-4f4f-a331-acdce44ff9ba + build-strategies: + - regular-branches: true + - change-request: + ignore-target-only-changes: true + clean: + after: true + before: true + prune: true + shallow-clone: true + depth: 3 + do-not-fetch-tags: true + submodule: + disable: false + recursive: true + parent-credentials: true + timeout: 100 + reference-repo: /var/lib/jenkins/.git-references/apm-server.git + timeout: '15' + use-author: true + wipe-workspace: true + property-strategies: + all-branches: + - suppress-scm-triggering: true diff --git a/.ci/smoke-tests.groovy b/.ci/smoke-tests.groovy new file mode 100644 index 00000000000..6ab3f714392 --- /dev/null +++ b/.ci/smoke-tests.groovy @@ -0,0 +1,70 @@ +#!/usr/bin/env groovy +@Library('apm@current') _ + +pipeline { + agent { label 'linux && immutable' } + environment { + REPO = 'apm-server' + BASE_DIR = "src/github.com/elastic/${env.REPO}" + AWS_ACCOUNT_SECRET = 'secret/observability-team/ci/elastic-observability-aws-account-auth' + EC_KEY_SECRET = 'secret/observability-team/ci/elastic-cloud/observability-pro' + TERRAFORM_VERSION = '1.2.3' + + CREATED_DATE = "${new Date().getTime()}" + } + + options { + timeout(time: 3, unit: 'HOURS') + buildDiscarder(logRotator(numToKeepStr: '100', artifactNumToKeepStr: '30', daysToKeepStr: '30')) + timestamps() + ansiColor('xterm') + disableResume() + durabilityHint('PERFORMANCE_OPTIMIZED') + rateLimitBuilds(throttle: [count: 60, durationName: 'hour', userBoost: true]) + } + parameters { + string(name: 'SMOKETEST_VERSIONS', defaultValue: 'latest', description: 'Run smoke tests using following APM versions') + } + stages { + stage('Checkout') { + options { skipDefaultCheckout() } + steps { + deleteDir() + gitCheckout(basedir: "${BASE_DIR}", shallow: false) + } + } + + stage('Smoke Tests') { + options { skipDefaultCheckout() } + environment { + SSH_KEY = "./id_rsa_terraform" + TF_VAR_private_key = "./id_rsa_terraform" + TF_VAR_public_key = "./id_rsa_terraform.pub" + // cloud tags + TF_VAR_BUILD_ID = "${env.BUILD_ID}" + TF_VAR_ENVIRONMENT= 'ci' + TF_VAR_BRANCH = "${env.BRANCH_NAME.toLowerCase().replaceAll('[^a-z0-9-]', '-')}" + TF_VAR_REPO = "${REPO}" + } + steps { + dir ("${BASE_DIR}") { + withGoEnv() { + withTestClusterEnv { + sh(label: 'Run smoke tests', script: 'make smoketest') + } + } + } + } + } + } +} + +def withTestClusterEnv(Closure body) { + withAWSEnv(secret: "${AWS_ACCOUNT_SECRET}", version: "2.7.6") { + withTerraformEnv(version: "${TERRAFORM_VERSION}") { + withSecretVault(secret: "${EC_KEY_SECRET}", data: ['apiKey': 'EC_API_KEY'] ) { + body() + } + } + } +} From d9849e82bc330d0a53821afcd924c3bc153c1241 Mon Sep 17 00:00:00 2001 From: Adrien Mannocci Date: Mon, 27 Jun 2022 16:23:08 +0200 Subject: [PATCH 2/2] Update .ci/jobs/apm-server-smoketests-mbp.yml Co-authored-by: Victor Martinez --- .ci/jobs/apm-server-smoketests-mbp.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.ci/jobs/apm-server-smoketests-mbp.yml b/.ci/jobs/apm-server-smoketests-mbp.yml index 3e4860f58bc..4df24ec3906 100644 --- a/.ci/jobs/apm-server-smoketests-mbp.yml +++ b/.ci/jobs/apm-server-smoketests-mbp.yml @@ -1,6 +1,6 @@ --- - job: - name: apm-server/smoke-tests + name: apm-server/smoke-tests-mbp display-name: APM Server Smoke Tests description: APM Server Smoke Tests project-type: multibranch