blob: 120bb9d3c9c57c8d7619a1d18a82e0c12ca6ffeb [file] [log] [blame]
Oleksii Zhurbad0525492017-12-12 16:07:46 -06001/**
2 *
Oleksii Zhurba713a5d22018-10-11 14:23:04 +03003 * Launch CVP Tempest verification of the cloud
Oleksii Zhurbad0525492017-12-12 16:07:46 -06004 *
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 Zhurba713a5d22018-10-11 14:23:04 +030017 * TEMPEST_TEST_PATTERN Tests to run
Oleksii Zhurbad0525492017-12-12 16:07:46 -060018 * TEMPEST_ENDPOINT_TYPE Type of OS endpoint to use during test run
19 *
20 */
21
22common = new com.mirantis.mk.Common()
23salt = new com.mirantis.mk.Salt()
24validate = new com.mirantis.mcp.Validate()
25
26def saltMaster
27def artifacts_dir = 'validation_artifacts/'
28def remote_artifacts_dir = '/root/qa_results/'
Oleksii Zhurba713a5d22018-10-11 14:23:04 +030029def container_name = "${env.JOB_NAME}"
Oleksii Zhurbad0525492017-12-12 16:07:46 -060030
31node() {
32 try{
33 stage('Initialization') {
Oleksii Zhurbad0525492017-12-12 16:07:46 -060034 sh "rm -rf ${artifacts_dir}"
Oleksii Zhurba713a5d22018-10-11 14:23:04 +030035 saltMaster = salt.connection(SALT_MASTER_URL, SALT_MASTER_CREDENTIALS)
Oleksii Zhurba49275882018-03-21 15:41:57 -050036 salt.cmdRun(saltMaster, TARGET_NODE, "rm -rf ${remote_artifacts_dir}")
Oleksii Zhurbad0525492017-12-12 16:07:46 -060037 salt.cmdRun(saltMaster, TARGET_NODE, "mkdir -p ${remote_artifacts_dir}")
Oleksii Zhurba713a5d22018-10-11 14:23:04 +030038 keystone_creds = validate._get_keystone_creds_v3(saltMaster)
39 if (!keystone_creds) {
40 keystone_creds = validate._get_keystone_creds_v2(saltMaster)
41 }
42 validate.runContainer(saltMaster, TARGET_NODE, TEST_IMAGE, container_name, keystone_creds)
Dmitry Tsapikov38f36512018-07-24 15:18:36 +000043 validate.configureContainer(saltMaster, TARGET_NODE, PROXY, TOOLS_REPO, TEMPEST_REPO, TEMPEST_ENDPOINT_TYPE)
Oleksii Zhurbad0525492017-12-12 16:07:46 -060044 }
45
46 stage('Run Tempest tests') {
47 sh "mkdir -p ${artifacts_dir}"
48 validate.runCVPtempest(saltMaster, TARGET_NODE, TEMPEST_TEST_PATTERN, SKIP_LIST_PATH, remote_artifacts_dir)
49 }
50
51 stage('Collect results') {
52 validate.addFiles(saltMaster, TARGET_NODE, remote_artifacts_dir, artifacts_dir)
53 archiveArtifacts artifacts: "${artifacts_dir}/*"
54 junit "${artifacts_dir}/*.xml"
55 }
56 } catch (Throwable e) {
57 // If there was an error or exception thrown, the build failed
58 currentBuild.result = "FAILURE"
59 throw e
60 } finally {
61 if (DEBUG_MODE == 'false') {
62 if (TOOLS_REPO != "") {
63 validate.openstack_cleanup(saltMaster, TARGET_NODE)
64 }
65 validate.runCleanup(saltMaster, TARGET_NODE)
66 salt.cmdRun(saltMaster, TARGET_NODE, "rm -rf ${remote_artifacts_dir}")
67 }
68 }
69}