Skip to content

Commit

Permalink
Add git credential fetch support, minor bug fixes
Browse files Browse the repository at this point in the history
Signed-off-by: Kunal Kotwani <kkotwani@amazon.com>
  • Loading branch information
kotwanikunal committed Apr 29, 2022
1 parent 6c4f856 commit 4cf7d2a
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 39 deletions.
17 changes: 5 additions & 12 deletions jenkins/opensearch/perf-test.jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,6 @@ pipeline {
JOB_NAME = 'perf-test'
}
parameters {
string(
name: 'GITHUB_TOKEN',
description: 'Github token for account access.',
trim: true
)
string(
name: 'BUNDLE_MANIFEST_URL',
description: 'The bundle manifest URL, e.g. https://ci.opensearch.org/ci/dbc/distribution-build-opensearch/1.2.2/98/linux/x64/builds/opensearch/manifest.yml.',
Expand Down Expand Up @@ -57,10 +52,6 @@ pipeline {
currentBuild.result = 'ABORTED'
error("Performance Tests failed to start. Missing parameter: BUNDLE_MANIFEST_URL.")
}
if (GITHUB_TOKEN == '') {
currentBuild.result = 'ABORTED'
error("Performance Tests failed to start. Missing parameter: GITHUB_TOKEN.")
}
if (TEST_ITERATIONS != null && !TEST_ITERATIONS.isInteger()) {
currentBuild.result = 'ABORTED'
error("Performance Tests failed to start. Invalid value for parameter: TEST_ITERATIONS. Value should be an integer.")
Expand Down Expand Up @@ -93,7 +84,7 @@ pipeline {
}
}
when {
expression { return env.HAS_SECURITY }
expression { return env.HAS_SECURITY.toBoolean() }
}
steps {
script {
Expand All @@ -111,7 +102,8 @@ pipeline {
insecure: false,
workload: TEST_WORKLOAD,
testIterations: TEST_ITERATIONS,
warmupIterations: WARMUP_ITERATIONS)
warmupIterations: WARMUP_ITERATIONS,
stackNameSuffix: env.BUILD_NUMBER)

lib.jenkins.Messages.new(this).add(JOB_NAME,
lib.jenkins.Messages.new(this).get([JOB_NAME]) +
Expand Down Expand Up @@ -162,7 +154,8 @@ pipeline {
insecure: true,
workload: TEST_WORKLOAD,
testIterations: TEST_ITERATIONS,
warmupIterations: WARMUP_ITERATIONS)
warmupIterations: WARMUP_ITERATIONS,
stackNameSuffix: env.BUILD_NUMBER)

lib.jenkins.Messages.new(this).add(JOB_NAME,
lib.jenkins.Messages.new(this).get([JOB_NAME]) +
Expand Down
4 changes: 2 additions & 2 deletions tests/jenkins/TestCCRPerfTest.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class TestCCRPerfTest extends BuildPipelineTest {

assertThat(s3DownloadCommands.size(), equalTo(1))
assertThat(s3DownloadCommands, hasItem(
"{file=config.yml, bucket=test_bucket, path=test_config/config.yml, force=true}".toString()
"{file=config.yml, bucket=test_bucket, path=test_config/config-ccr.yml, force=true}".toString()
))
}

Expand Down Expand Up @@ -85,7 +85,7 @@ class TestCCRPerfTest extends BuildPipelineTest {

assertThat(testScriptCommands.size(), equalTo(1))
assertThat(testScriptCommands, hasItem(
"./test.sh perf-test --stack test-single-security-1236-x64 --bundle-manifest tests/jenkins/data/opensearch-1.3.0-bundle.yml --config config.yml --component cross-cluster-replication".toString()
"./test.sh perf-test --stack test-single-security-1236-x64-perf-test --bundle-manifest tests/jenkins/data/opensearch-1.3.0-bundle.yml --config config.yml --component cross-cluster-replication".toString()
))

def resultUploadScriptCommands = getCommandExecutions('s3Upload', 'test-results').findAll {
Expand Down
2 changes: 1 addition & 1 deletion tests/jenkins/TestRunNonSecurityPerfTestScript.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class TestRunNonSecurityPerfTestScript extends BuildPipelineTest {

assertThat(testScriptCommands.size(), equalTo(1))
assertThat(testScriptCommands, hasItem(
"./test.sh perf-test --stack test-single-1236-x64 --bundle-manifest tests/jenkins/data/opensearch-1.3.0-non-security-bundle.yml --config config.yml --without-security --workload nyc_taxis --test-iters 1 --warmup-iters 1 ".toString()
"./test.sh perf-test --stack test-single-1236-x64-perf-test --bundle-manifest tests/jenkins/data/opensearch-1.3.0-non-security-bundle.yml --config config.yml --without-security --workload nyc_taxis --test-iters 1 --warmup-iters 1 ".toString()
))

def resultUploadScriptCommands = getCommandExecutions('s3Upload', 'test-results').findAll {
Expand Down
4 changes: 2 additions & 2 deletions tests/jenkins/TestRunPerfTestScript.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,10 @@ class TestRunPerfTestScript extends BuildPipelineTest {

assertThat(testScriptCommands.size(), equalTo(2))
assertThat(testScriptCommands, hasItem(
"./test.sh perf-test --stack test-single-security-1236-x64 --bundle-manifest tests/jenkins/data/opensearch-1.3.0-bundle.yml --config config.yml --workload nyc_taxis --test-iters 1 --warmup-iters 1 ".toString()
"./test.sh perf-test --stack test-single-security-1236-x64-perf-test --bundle-manifest tests/jenkins/data/opensearch-1.3.0-bundle.yml --config config.yml --workload nyc_taxis --test-iters 1 --warmup-iters 1 ".toString()
))
assertThat(testScriptCommands, hasItem(
"./test.sh perf-test --stack test-single-1236-x64 --bundle-manifest tests/jenkins/data/opensearch-1.3.0-bundle.yml --config config.yml --without-security --workload nyc_taxis --test-iters 1 --warmup-iters 1 ".toString()
"./test.sh perf-test --stack test-single-1236-x64-perf-test --bundle-manifest tests/jenkins/data/opensearch-1.3.0-bundle.yml --config config.yml --without-security --workload nyc_taxis --test-iters 1 --warmup-iters 1 ".toString()
))

def resultUploadScriptCommands = getCommandExecutions('s3Upload', 'test-results').findAll {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,10 @@
pipenv install "boto3~=1.18" "setuptools~=57.4" "retry~=0.9"
)
runPerfTestScript.withAWS({role=opensearch-test, roleAccount=dummy_account, duration=900, roleSessionName=jenkins-session}, groovy.lang.Closure)
runPerfTestScript.s3Download({file=config.yml, bucket=test_bucket, path=test_config/config.yml, force=true})
runPerfTestScript.sh(./test.sh perf-test --stack test-single-security-1236-x64 --bundle-manifest tests/jenkins/data/opensearch-1.3.0-bundle.yml --config config.yml --component cross-cluster-replication)
runPerfTestScript.s3Download({file=config.yml, bucket=test_bucket, path=test_config/config-ccr.yml, force=true})
runPerfTestScript.usernamePassword({credentialsId=bot_token_name, usernameVariable=GITHUB_USER, passwordVariable=GITHUB_TOKEN})
runPerfTestScript.withCredentials([[GITHUB_USER, GITHUB_TOKEN]], groovy.lang.Closure)
runPerfTestScript.sh(./test.sh perf-test --stack test-single-security-1236-x64-perf-test --bundle-manifest tests/jenkins/data/opensearch-1.3.0-bundle.yml --config config.yml --component cross-cluster-replication)
Messages.asBoolean()
Messages.asBoolean()
Messages.get([perf-test])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
perf-test.echo(BUNDLE_MANIFEST: tests/jenkins/data/opensearch-1.3.0-bundle.yml)
perf-test.echo(BUILD_ID: 1236)
perf-test.echo(Architecture: x64)
perf-test.runPerfTestScript({bundleManifest=tests/jenkins/data/opensearch-1.3.0-bundle.yml, buildId=1236, architecture=x64, insecure=false, workload=nyc_taxis, testIterations=1, warmupIterations=1})
perf-test.runPerfTestScript({bundleManifest=tests/jenkins/data/opensearch-1.3.0-bundle.yml, buildId=1236, architecture=x64, insecure=false, workload=nyc_taxis, testIterations=1, warmupIterations=1, stackNameSuffix=null})
runPerfTestScript.legacySCM(groovy.lang.Closure)
runPerfTestScript.library({identifier=jenkins@20211123, retriever=null})
runPerfTestScript.readYaml({file=tests/jenkins/data/opensearch-1.3.0-bundle.yml})
Expand All @@ -51,7 +51,9 @@
)
runPerfTestScript.withAWS({role=opensearch-test, roleAccount=dummy_account, duration=900, roleSessionName=jenkins-session}, groovy.lang.Closure)
runPerfTestScript.s3Download({file=config.yml, bucket=test_bucket, path=test_config/config.yml, force=true})
runPerfTestScript.sh(./test.sh perf-test --stack test-single-security-1236-x64 --bundle-manifest tests/jenkins/data/opensearch-1.3.0-bundle.yml --config config.yml --workload nyc_taxis --test-iters 1 --warmup-iters 1 )
runPerfTestScript.usernamePassword({credentialsId=bot_token_name, usernameVariable=GITHUB_USER, passwordVariable=GITHUB_TOKEN})
runPerfTestScript.withCredentials([[GITHUB_USER, GITHUB_TOKEN]], groovy.lang.Closure)
runPerfTestScript.sh(./test.sh perf-test --stack test-single-security-1236-x64-perf-test --bundle-manifest tests/jenkins/data/opensearch-1.3.0-bundle.yml --config config.yml --workload nyc_taxis --test-iters 1 --warmup-iters 1 )
Messages.asBoolean()
Messages.asBoolean()
Messages.get([perf-test])
Expand Down Expand Up @@ -93,7 +95,7 @@ Performance tests with security for 1236 completed})
perf-test.echo(BUNDLE_MANIFEST: tests/jenkins/data/opensearch-1.3.0-bundle.yml)
perf-test.echo(BUILD_ID: 1236)
perf-test.echo(Architecture: x64)
perf-test.runPerfTestScript({bundleManifest=tests/jenkins/data/opensearch-1.3.0-bundle.yml, buildId=1236, architecture=x64, insecure=true, workload=nyc_taxis, testIterations=1, warmupIterations=1})
perf-test.runPerfTestScript({bundleManifest=tests/jenkins/data/opensearch-1.3.0-bundle.yml, buildId=1236, architecture=x64, insecure=true, workload=nyc_taxis, testIterations=1, warmupIterations=1, stackNameSuffix=null})
runPerfTestScript.legacySCM(groovy.lang.Closure)
runPerfTestScript.library({identifier=jenkins@20211123, retriever=null})
runPerfTestScript.readYaml({file=tests/jenkins/data/opensearch-1.3.0-bundle.yml})
Expand All @@ -112,7 +114,9 @@ Performance tests with security for 1236 completed})
)
runPerfTestScript.withAWS({role=opensearch-test, roleAccount=dummy_account, duration=900, roleSessionName=jenkins-session}, groovy.lang.Closure)
runPerfTestScript.s3Download({file=config.yml, bucket=test_bucket, path=test_config/config.yml, force=true})
runPerfTestScript.sh(./test.sh perf-test --stack test-single-1236-x64 --bundle-manifest tests/jenkins/data/opensearch-1.3.0-bundle.yml --config config.yml --without-security --workload nyc_taxis --test-iters 1 --warmup-iters 1 )
runPerfTestScript.usernamePassword({credentialsId=bot_token_name, usernameVariable=GITHUB_USER, passwordVariable=GITHUB_TOKEN})
runPerfTestScript.withCredentials([[GITHUB_USER, GITHUB_TOKEN]], groovy.lang.Closure)
runPerfTestScript.sh(./test.sh perf-test --stack test-single-1236-x64-perf-test --bundle-manifest tests/jenkins/data/opensearch-1.3.0-bundle.yml --config config.yml --without-security --workload nyc_taxis --test-iters 1 --warmup-iters 1 )
Messages.asBoolean()
Messages.asBoolean()
Messages.get([perf-test])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
perf-test.echo(BUNDLE_MANIFEST: tests/jenkins/data/opensearch-1.3.0-non-security-bundle.yml)
perf-test.echo(BUILD_ID: 1236)
perf-test.echo(Architecture: x64)
perf-test.runPerfTestScript({bundleManifest=tests/jenkins/data/opensearch-1.3.0-non-security-bundle.yml, buildId=1236, architecture=x64, insecure=true, workload=nyc_taxis, testIterations=1, warmupIterations=1})
perf-test.runPerfTestScript({bundleManifest=tests/jenkins/data/opensearch-1.3.0-non-security-bundle.yml, buildId=1236, architecture=x64, insecure=true, workload=nyc_taxis, testIterations=1, warmupIterations=1, stackNameSuffix=null})
runPerfTestScript.legacySCM(groovy.lang.Closure)
runPerfTestScript.library({identifier=jenkins@20211123, retriever=null})
runPerfTestScript.readYaml({file=tests/jenkins/data/opensearch-1.3.0-non-security-bundle.yml})
Expand All @@ -52,7 +52,9 @@
)
runPerfTestScript.withAWS({role=opensearch-test, roleAccount=dummy_account, duration=900, roleSessionName=jenkins-session}, groovy.lang.Closure)
runPerfTestScript.s3Download({file=config.yml, bucket=test_bucket, path=test_config/config.yml, force=true})
runPerfTestScript.sh(./test.sh perf-test --stack test-single-1236-x64 --bundle-manifest tests/jenkins/data/opensearch-1.3.0-non-security-bundle.yml --config config.yml --without-security --workload nyc_taxis --test-iters 1 --warmup-iters 1 )
runPerfTestScript.usernamePassword({credentialsId=bot_token_name, usernameVariable=GITHUB_USER, passwordVariable=GITHUB_TOKEN})
runPerfTestScript.withCredentials([[GITHUB_USER, GITHUB_TOKEN]], groovy.lang.Closure)
runPerfTestScript.sh(./test.sh perf-test --stack test-single-1236-x64-perf-test --bundle-manifest tests/jenkins/data/opensearch-1.3.0-non-security-bundle.yml --config config.yml --without-security --workload nyc_taxis --test-iters 1 --warmup-iters 1 )
Messages.asBoolean()
Messages.asBoolean()
Messages.get([perf-test])
Expand Down
2 changes: 2 additions & 0 deletions tests/jenkins/lib-testers/RunPerfTestScriptLibTest.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ class RunPerfTestScriptLibTester extends LibFunctionTester {
binding.setVariable('BUILD_URL', 'test://artifact.url')
binding.setVariable('BUNDLE_MANIFEST', bundleManifest)
binding.setVariable('BUNDLE_MANIFEST_URL', 'test://artifact.url')
binding.setVariable('GITHUB_BOT_TOKEN_NAME', 'bot_token_name')
binding.setVariable('GITHUB_USER', 'test_user')
binding.setVariable('GITHUB_TOKEN', 'test_token')
binding.setVariable('HAS_SECURITY', security)
binding.setVariable('JOB_NAME', 'perf-test')
Expand Down
32 changes: 18 additions & 14 deletions vars/runPerfTestScript.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,28 @@ void call(Map args = [:]) {

install_dependencies()
install_opensearch_infra_dependencies()
config_name = isNullOrEmpty(args.conig) ? "config.yml" : args.config
config_name = isNullOrEmpty(args.config) ? "config.yml" : args.config
withAWS(role: 'opensearch-test', roleAccount: "${AWS_ACCOUNT_PUBLIC}", duration: 900, roleSessionName: 'jenkins-session') {
s3Download(file: "config.yml", bucket: "${ARTIFACT_BUCKET_NAME}", path: "${PERF_TEST_CONFIG_LOCATION}/${config_name}", force: true)
}

sh([
'./test.sh',
'perf-test',
args.insecure ? "--stack test-single-${args.buildId}-${args.architecture}" :
"--stack test-single-security-${args.buildId}-${args.architecture}",
"--bundle-manifest ${args.bundleManifest}",
"--config config.yml",
args.insecure ? "--without-security" : "",
isNullOrEmpty(args.workload) ? "" : "--workload ${args.workload}",
isNullOrEmpty(args.testIterations) ? "" : "--test-iters ${args.testIterations}",
isNullOrEmpty(args.warmupIterations) ? "" : "--warmup-iters ${args.warmupIterations}",
isNullOrEmpty(args.component) ? "" : "--component ${args.component}"
].join(' '))
String stackNameSuffix = isNullOrEmpty(args.stackNameSuffix) ? 'perf-test' : args.stackNameSuffix

withCredentials([usernamePassword(credentialsId: "${GITHUB_BOT_TOKEN_NAME}", usernameVariable: 'GITHUB_USER', passwordVariable: 'GITHUB_TOKEN')]) {
sh([
'./test.sh',
'perf-test',
args.insecure ? "--stack test-single-${args.buildId}-${args.architecture}-${stackNameSuffix}" :
"--stack test-single-security-${args.buildId}-${args.architecture}-${stackNameSuffix}",
"--bundle-manifest ${args.bundleManifest}",
"--config config.yml",
args.insecure ? "--without-security" : "",
isNullOrEmpty(args.workload) ? "" : "--workload ${args.workload}",
isNullOrEmpty(args.testIterations) ? "" : "--test-iters ${args.testIterations}",
isNullOrEmpty(args.warmupIterations) ? "" : "--warmup-iters ${args.warmupIterations}",
isNullOrEmpty(args.component) ? "" : "--component ${args.component}"
].join(' '))
}
}

boolean isNullOrEmpty(String str) { return (str == null || str.allWhitespace) }
Expand Down

0 comments on commit 4cf7d2a

Please sign in to comment.