Oleksii Zhurba | d052549 | 2017-12-12 16:07:46 -0600 | [diff] [blame] | 1 | /** |
| 2 | * |
| 3 | * Launch validation of the cloud |
| 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 |
| 17 | * TEMPEST_TEST_PATTERN Tests to run during HA scenarios |
| 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') { |
| 33 | saltMaster = salt.connection(SALT_MASTER_URL, SALT_MASTER_CREDENTIALS) |
| 34 | validate.runBasicContainer(saltMaster, TARGET_NODE, TEST_IMAGE) |
| 35 | sh "rm -rf ${artifacts_dir}" |
| 36 | salt.cmdRun(saltMaster, TARGET_NODE, "mkdir -p ${remote_artifacts_dir}") |
| 37 | validate.configureContainer(saltMaster, TARGET_NODE, PROXY, TOOLS_REPO, TEMPEST_REPO, TEMPEST_ENDPOINT_TYPE) |
| 38 | } |
| 39 | |
| 40 | stage('Run Tempest tests') { |
| 41 | sh "mkdir -p ${artifacts_dir}" |
| 42 | validate.runCVPtempest(saltMaster, TARGET_NODE, TEMPEST_TEST_PATTERN, SKIP_LIST_PATH, remote_artifacts_dir) |
| 43 | } |
| 44 | |
| 45 | stage('Collect results') { |
| 46 | validate.addFiles(saltMaster, TARGET_NODE, remote_artifacts_dir, artifacts_dir) |
| 47 | archiveArtifacts artifacts: "${artifacts_dir}/*" |
| 48 | junit "${artifacts_dir}/*.xml" |
| 49 | } |
| 50 | } catch (Throwable e) { |
| 51 | // If there was an error or exception thrown, the build failed |
| 52 | currentBuild.result = "FAILURE" |
| 53 | throw e |
| 54 | } finally { |
| 55 | if (DEBUG_MODE == 'false') { |
| 56 | if (TOOLS_REPO != "") { |
| 57 | validate.openstack_cleanup(saltMaster, TARGET_NODE) |
| 58 | } |
| 59 | validate.runCleanup(saltMaster, TARGET_NODE) |
| 60 | salt.cmdRun(saltMaster, TARGET_NODE, "rm -rf ${remote_artifacts_dir}") |
| 61 | } |
| 62 | } |
| 63 | } |