Update Shaker pipeline
- do not null-delimeter cmds (already in the library method)
- mark build as failed if docker exits with non-zero status
Change-Id: Ia1ebcd7951e42581033fbad2ed25382ab3092d2d
Related-PROD: PROD-24883 (PROD:24883)
diff --git a/cvp-shaker.groovy b/cvp-shaker.groovy
index f845bc8..08f9315 100644
--- a/cvp-shaker.groovy
+++ b/cvp-shaker.groovy
@@ -1,15 +1,15 @@
-/**
+/*
*
* Launch CVP Shaker network tests
*
* Expected parameters:
-
+ *
* SALT_MASTER_URL URL of Salt master
* SALT_MASTER_CREDENTIALS Credentials that are used in this Jenkins for accessing Salt master (usually "salt")
* IMAGE Docker image link to use for running container with Shaker.
* SHAKER_PARAMS Yaml context which contains parameters for running Shaker
*
- */
+*/
/*
SHAKER_PARAMS yaml example:
@@ -74,97 +74,94 @@
def SHAKER_PARAMS = readYaml(text: env.getProperty('SHAKER_PARAMS')) ?: [:]
def artifacts_dir = 'validation_artifacts'
def configRun = [:]
+def workdir = '/opt/shaker/'
+def container_artifacts = '/artifacts'
+def html_file = "${container_artifacts}/shaker-report.html"
+def cmd_shaker_args = "--debug --cleanup-on-error --report ${html_file}"
node (SLAVE_NODE) {
- try{
- stage('Initialization') {
- def workdir = '/opt/shaker/'
- def container_artifacts = '/artifacts'
- def html_file = "${container_artifacts}/shaker-report.html"
- def log_file = "${container_artifacts}/shaker.log"
- def cmd_shaker_args = "--debug --cleanup-on-error " +
- "--log-file ${log_file} --report ${html_file}"
+ stage('Initialization') {
- sh "mkdir -p ${artifacts_dir}"
-
- // Get Openstack credentials
- def saltMaster = salt.connection(SALT_MASTER_URL, SALT_MASTER_CREDENTIALS)
+ // prepare artifacts directory
+ sh "rm -rf ${artifacts_dir} || true"
+ sh "mkdir -p ${artifacts_dir}"
+ // Get Openstack credentials
+ def saltMaster = salt.connection(SALT_MASTER_URL, SALT_MASTER_CREDENTIALS)
+ try {
keystone_creds = validate._get_keystone_creds_v3(saltMaster)
if (!keystone_creds) {
keystone_creds = validate._get_keystone_creds_v2(saltMaster)
}
-
- // Get shaker env variables
- def general_params = [
- SHAKER_SERVER_ENDPOINT: (SHAKER_PARAMS.get('SHAKER_SERVER_ENDPOINT')),
- SHAKER_SCENARIOS: (SHAKER_PARAMS.get('SHAKER_SCENARIOS')) ?: 'scenarios/essential',
- SKIP_LIST: (SHAKER_PARAMS.get('SKIP_LIST')),
- MATRIX: (SHAKER_PARAMS.get('MATRIX'))
- ]
- if (! general_params['SHAKER_SERVER_ENDPOINT']) {
- throw new Exception("SHAKER_SERVER_ENDPOINT address was not set in the SHAKER_PARAMS")
- }
- def builder_vars = SHAKER_PARAMS.get("image_builder") ?: [
- "SHAKER_FLAVOR_DISK=4",
- "SHAKER_FLAVOR_RAM=512",
- "SHAKER_FLAVOR_VCPUS=1"
- ]
- def shaker_vars = SHAKER_PARAMS.get("shaker") ?: []
- def env_vars_list = general_params.collect{ "${it.key}=${it.value}" }
- env_vars_list = env_vars_list + keystone_creds + builder_vars + shaker_vars
-
- // Get shaker scenarios cmd
- def scen_cmd = validate.bundle_up_scenarios(
- workdir +
- general_params['SHAKER_SCENARIOS'].replaceAll("^/+", ""),
- general_params['SKIP_LIST']
- )
-
- // Override scenarios params:
- if (general_params['MATRIX']) {
- cmd_shaker_args += " --matrix '${general_params.MATRIX}'"
- }
-
- // Define docker commands
- def commands = [
- '001_build_image': "shaker-image-builder --debug",
- '002_run_shaker': scen_cmd + "-print0" +
- "|paste -zsd ',' - " +
- "|xargs --null " +
- "shaker ${cmd_shaker_args} --scenario "
- ]
- def commands_list = commands.collectEntries{ [ (it.key) : { sh("${it.value}") } ] }
-
- configRun = [
- 'image': IMAGE,
- 'baseRepoPreConfig': false,
- 'dockerMaxCpus': 2,
- // suppress sudo resolve warnings
- // which break image build
- 'dockerHostname': 'localhost',
- 'dockerExtraOpts': [
- "--network=host",
- "--privileged",
- "-v ${env.WORKSPACE}/${artifacts_dir}/:${container_artifacts}"
- ],
- 'envOpts' : env_vars_list,
- 'runCommands' : commands_list
- ]
+ } catch (Throwable e) {
+ error("This test requires Openstack keystone credentials to start (${e.toString()})")
}
- stage('Run Shaker tests') {
- salt_testing.setupDockerAndTest(configRun)
+ // Get shaker env variables
+ def general_params = [
+ SHAKER_SERVER_ENDPOINT: (SHAKER_PARAMS.get('SHAKER_SERVER_ENDPOINT')),
+ SHAKER_SCENARIOS: (SHAKER_PARAMS.get('SHAKER_SCENARIOS')) ?: 'scenarios/essential',
+ SKIP_LIST: (SHAKER_PARAMS.get('SKIP_LIST')),
+ MATRIX: (SHAKER_PARAMS.get('MATRIX'))
+ ]
+ if (! general_params['SHAKER_SERVER_ENDPOINT']) {
+ throw new Exception("SHAKER_SERVER_ENDPOINT address was not set in the SHAKER_PARAMS")
+ }
+ def builder_vars = SHAKER_PARAMS.get("image_builder") ?: [
+ "SHAKER_FLAVOR_DISK=4",
+ "SHAKER_FLAVOR_RAM=512",
+ "SHAKER_FLAVOR_VCPUS=1"
+ ]
+ def shaker_vars = SHAKER_PARAMS.get("shaker") ?: []
+ def env_vars_list = general_params.collect{ "${it.key}=${it.value}" }
+ env_vars_list = env_vars_list + keystone_creds + builder_vars + shaker_vars
+
+ // Get shaker scenarios cmd
+ def scen_cmd = validate.bundle_up_scenarios(
+ workdir +
+ general_params['SHAKER_SCENARIOS'].replaceAll("^/+", ""),
+ general_params['SKIP_LIST']
+ )
+
+ // Override scenarios params:
+ if (general_params['MATRIX']) {
+ cmd_shaker_args += " --matrix '${general_params.MATRIX}'"
}
- stage('Collect results') {
- archiveArtifacts artifacts: "${artifacts_dir}/*"
- }
+ // Define docker commands
+ def commands = [
+ '001_build_image': "shaker-image-builder --debug",
+ '002_run_shaker': scen_cmd +
+ "|paste -sd ',' - " +
+ "|xargs shaker ${cmd_shaker_args} --scenario"
+ ]
+ def commands_list = commands.collectEntries{ [ (it.key) : { sh("${it.value}") } ] }
- } catch (Throwable e) {
- // If there was an error or exception thrown, the build failed
- currentBuild.result = "FAILURE"
- throw e
- } finally {
- sh "rm -rf ${artifacts_dir}"
+ configRun = [
+ 'image': IMAGE,
+ 'baseRepoPreConfig': false,
+ 'dockerMaxCpus': 2,
+ // suppress sudo resolve warnings
+ // which break image build
+ 'dockerHostname': 'localhost',
+ 'dockerExtraOpts': [
+ "--network=host",
+ "--privileged",
+ "-v ${env.WORKSPACE}/${artifacts_dir}/:${container_artifacts}"
+ ],
+ 'envOpts' : env_vars_list,
+ 'runCommands' : commands_list
+ ]
}
+
+ stage('Run Shaker tests') {
+ if (! salt_testing.setupDockerAndTest(configRun)) {
+ common.warningMsg('Docker contrainer failed to run Shaker')
+ currentBuild.result = 'FAILURE'
+ }
+ }
+
+ stage('Collect results') {
+ archiveArtifacts artifacts: "${artifacts_dir}/*"
+ }
+
}