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