Oleksii Zhurba | 546a560 | 2017-12-12 16:18:05 -0600 | [diff] [blame] | 1 | /** |
| 2 | * |
Oleksii Zhurba | 713a5d2 | 2018-10-11 14:23:04 +0300 | [diff] [blame] | 3 | * Launch CVP Rally performance testing of the cloud |
Oleksii Zhurba | 546a560 | 2017-12-12 16:18:05 -0600 | [diff] [blame] | 4 | * |
| 5 | * Expected parameters: |
| 6 | * SALT_MASTER_URL URL of Salt master |
| 7 | * SALT_MASTER_CREDENTIALS Credentials that are used in this Jenkins for accessing Salt master (usually "salt") |
| 8 | * PROXY Proxy address (if any) for accessing the Internet. It will be used for cloning repos and installing pip dependencies |
| 9 | * TEST_IMAGE Docker image link to use for running container with testing tools. |
| 10 | * TOOLS_REPO URL of repo where testing tools, scenarios, configs are located |
| 11 | * |
| 12 | * TARGET_NODE Node to run container with Rally |
| 13 | * DEBUG_MODE If you need to debug (keep container after test), please enabled this |
| 14 | * RALLY_SCENARIO_FILE Path to Rally scenario file in container |
| 15 | * |
| 16 | */ |
| 17 | |
| 18 | common = new com.mirantis.mk.Common() |
| 19 | salt = new com.mirantis.mk.Salt() |
| 20 | validate = new com.mirantis.mcp.Validate() |
| 21 | |
| 22 | def artifacts_dir = 'validation_artifacts/' |
| 23 | def remote_artifacts_dir = '/root/qa_results/' |
| 24 | def saltMaster |
| 25 | |
| 26 | node() { |
| 27 | try{ |
| 28 | stage('Initialization') { |
Oleksii Zhurba | 546a560 | 2017-12-12 16:18:05 -0600 | [diff] [blame] | 29 | sh "rm -rf ${artifacts_dir}" |
Oleksii Zhurba | 2258100 | 2019-03-08 16:54:00 -0600 | [diff] [blame] | 30 | if (!TARGET_NODE) { |
| 31 | // This pillar will return us cid01 |
| 32 | TARGET_NODE = "I@gerrit:client" |
| 33 | } |
Oleksii Zhurba | 713a5d2 | 2018-10-11 14:23:04 +0300 | [diff] [blame] | 34 | saltMaster = salt.connection(SALT_MASTER_URL, SALT_MASTER_CREDENTIALS) |
Oleksii Zhurba | 07d8a40 | 2019-05-14 18:25:20 -0500 | [diff] [blame] | 35 | os_version=salt.getPillar(saltMaster, 'I@salt:master', '_param:openstack_version')['return'][0].values()[0] |
| 36 | if (!os_version) { |
| 37 | throw new Exception("Openstack is not found on this env. Exiting") |
| 38 | } |
Oleksii Zhurba | d4c0411 | 2019-05-15 12:15:02 -0500 | [diff] [blame] | 39 | container_name = "${env.JOB_NAME}" |
Oleksii Zhurba | 4927588 | 2018-03-21 15:41:57 -0500 | [diff] [blame] | 40 | salt.cmdRun(saltMaster, TARGET_NODE, "rm -rf ${remote_artifacts_dir}") |
Oleksii Zhurba | 546a560 | 2017-12-12 16:18:05 -0600 | [diff] [blame] | 41 | salt.cmdRun(saltMaster, TARGET_NODE, "mkdir -p ${remote_artifacts_dir}") |
Oleksii Zhurba | 713a5d2 | 2018-10-11 14:23:04 +0300 | [diff] [blame] | 42 | keystone_creds = validate._get_keystone_creds_v3(saltMaster) |
| 43 | if (!keystone_creds) { |
| 44 | keystone_creds = validate._get_keystone_creds_v2(saltMaster) |
| 45 | } |
Oleksii Zhurba | d4c0411 | 2019-05-15 12:15:02 -0500 | [diff] [blame] | 46 | validate.runContainer(saltMaster, TARGET_NODE, TEST_IMAGE, container_name, keystone_creds) |
| 47 | validate.configureContainer(saltMaster, TARGET_NODE, PROXY, TOOLS_REPO, "", "internalURL", "", "", [], container_name) |
Oleksii Zhurba | 546a560 | 2017-12-12 16:18:05 -0600 | [diff] [blame] | 48 | } |
| 49 | |
| 50 | stage('Run Rally tests') { |
| 51 | sh "mkdir -p ${artifacts_dir}" |
Oleksii Zhurba | d4c0411 | 2019-05-15 12:15:02 -0500 | [diff] [blame] | 52 | validate.runCVPrally(saltMaster, TARGET_NODE, RALLY_SCENARIO_FILE, remote_artifacts_dir, "docker-rally", container_name) |
Oleksii Zhurba | 546a560 | 2017-12-12 16:18:05 -0600 | [diff] [blame] | 53 | } |
| 54 | |
| 55 | stage('Collect results') { |
| 56 | validate.addFiles(saltMaster, TARGET_NODE, remote_artifacts_dir, artifacts_dir) |
| 57 | archiveArtifacts artifacts: "${artifacts_dir}/*" |
| 58 | junit "${artifacts_dir}/*.xml" |
Oleksii Zhurba | e23f94c | 2018-04-30 16:08:18 -0500 | [diff] [blame] | 59 | perfReport configType: 'PRT', graphType: 'PRT', sourceDataFiles: "${artifacts_dir}/docker-rally.xml" |
Oleksii Zhurba | 546a560 | 2017-12-12 16:18:05 -0600 | [diff] [blame] | 60 | } |
| 61 | } catch (Throwable e) { |
| 62 | // If there was an error or exception thrown, the build failed |
| 63 | currentBuild.result = "FAILURE" |
| 64 | throw e |
| 65 | } finally { |
| 66 | if (DEBUG_MODE == 'false') { |
Oleksii Zhurba | d4c0411 | 2019-05-15 12:15:02 -0500 | [diff] [blame] | 67 | validate.openstack_cleanup(saltMaster, TARGET_NODE, container_name) |
| 68 | validate.runCleanup(saltMaster, TARGET_NODE, container_name) |
Oleksii Zhurba | 546a560 | 2017-12-12 16:18:05 -0600 | [diff] [blame] | 69 | salt.cmdRun(saltMaster, TARGET_NODE, "rm -rf ${remote_artifacts_dir}") |
| 70 | } |
| 71 | } |
| 72 | } |
| 73 | |