-
Notifications
You must be signed in to change notification settings - Fork 35
ci: add smoke tests integration #310
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
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
90e6c51
ci: add smoke tests integration
kruskall e0ce062
Merge branch 'main' into ci/smoke-tests
kruskall 77be13a
ci: avoid empty/unset env for the very first build
kruskall 172525d
ci: rework approach to .go-version file
kruskall 91ded2b
ci: move .ci/jobs definition to a different PR
kruskall 31c2c1d
Merge branch 'main' into ci/smoke-tests
kruskall 57b60ff
ci: remove GO_VERSION from smoke-tests job
kruskall 7ec9c43
ci: run on main and manually when using the Jenkins UI
v1v 07a3aef
build: add smoketest/run dependency on build task
kruskall ad2e04f
Update .ci/smoke-tests.groovy
v1v 4fd3c09
Update .ci/smoke-tests.groovy
v1v 6dea451
revert jenkins shared library
v1v 62b58f2
Merge branch 'main' into ci/smoke-tests
kruskall c3c560d
Merge branch 'main' into ci/smoke-tests
kruskall File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
#!/usr/bin/env groovy | ||
@Library('apm@current') _ | ||
|
||
pipeline { | ||
agent none | ||
environment { | ||
REPO = 'apm-aws-lambda' | ||
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()}" | ||
SLACK_CHANNEL = "#apm-serverless" | ||
SMOKETEST_VERSIONS = "${params.SMOKETEST_VERSIONS}" | ||
} | ||
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('Filter build') { | ||
options { skipDefaultCheckout() } | ||
agent { label 'linux && immutable' } | ||
when { | ||
beforeAgent true | ||
anyOf { | ||
branch 'main' | ||
expression { | ||
if(!isUserTrigger()){ | ||
currentBuild.result = 'NOT_BUILT' | ||
currentBuild.description = "The build has been skipped" | ||
currentBuild.displayName = "#${BUILD_NUMBER}-(Skipped)" | ||
echo("Support builds for the `main` branch or manually triggered") | ||
return false | ||
} | ||
return true | ||
} | ||
} | ||
} | ||
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}" | ||
v1v marked this conversation as resolved.
Show resolved
Hide resolved
|
||
HOME = "${env.WORKSPACE}" | ||
} | ||
steps { | ||
dir ("${BASE_DIR}") { | ||
withTestClusterEnv { | ||
withGoEnv() { | ||
script { | ||
def smokeTests = sh(returnStdout: true, script: 'make smoketest/discover').trim().split('\r?\n') | ||
def smokeTestJobs = [:] | ||
for (smokeTest in smokeTests) { | ||
smokeTestJobs["Run smoke tests in ${smokeTest}"] = runSmokeTest(smokeTest) | ||
} | ||
parallel smokeTestJobs | ||
} | ||
} | ||
} | ||
} | ||
} | ||
post { | ||
always { | ||
dir("${BASE_DIR}") { | ||
withTestClusterEnv { | ||
withGoEnv() { | ||
sh(label: 'Teardown smoke tests infra', script: 'make smoketest/all/cleanup') | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
post { | ||
cleanup { | ||
notifyBuildResult(slackComment: true) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
def runSmokeTest(String testDir) { | ||
return { | ||
stage("Run smoke tests in ${testDir}") { | ||
sh(label: 'Run smoke tests', script: "make smoketest/run TEST_DIR=${testDir}") | ||
} | ||
} | ||
} | ||
|
||
def withTestClusterEnv(Closure body) { | ||
withAWSEnv(secret: "${AWS_ACCOUNT_SECRET}", version: "2.7.6") { | ||
withTerraformEnv(version: "${TERRAFORM_VERSION}", forceInstallation: true) { | ||
withSecretVault(secret: "${EC_KEY_SECRET}", data: ['apiKey': 'EC_API_KEY'] ) { | ||
body() | ||
} | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.