Petr Lomakin | e700ffd | 2017-08-01 10:53:15 -0700 | [diff] [blame] | 1 | /** |
| 2 | * |
| 3 | * Launch validation of the cloud |
| 4 | * |
| 5 | * Expected parameters: |
Oleg Basov | d4fa386 | 2019-03-05 21:49:12 +0100 | [diff] [blame^] | 6 | * |
| 7 | * ACCUMULATE_RESULTS If true, results from the previous build will be used |
| 8 | * JOB_TIMEOUT Job timeout in hours |
| 9 | * RUN_RALLY_TESTS If not false, run Rally tests |
| 10 | * RUN_SPT_TESTS If not false, run SPT tests |
| 11 | * RUN_TEMPEST_TESTS If not false, run Tempest tests |
| 12 | * TEST_IMAGE Docker image link |
| 13 | * TARGET_NODE Salt target for tempest node |
Petr Lomakin | e700ffd | 2017-08-01 10:53:15 -0700 | [diff] [blame] | 14 | * SALT_MASTER_URL URL of Salt master |
| 15 | * SALT_MASTER_CREDENTIALS Credentials to the Salt API |
| 16 | * |
Oleg Basov | d4fa386 | 2019-03-05 21:49:12 +0100 | [diff] [blame^] | 17 | * Additional validate job YAML params: |
| 18 | * |
| 19 | * Rally |
| 20 | * |
Dmitrii Kabanov | 9f3b7ed | 2017-09-29 10:47:36 -0700 | [diff] [blame] | 21 | * AVAILABILITY_ZONE The name of availability zone |
| 22 | * FLOATING_NETWORK The name of the external(floating) network |
Oleg Basov | d4fa386 | 2019-03-05 21:49:12 +0100 | [diff] [blame^] | 23 | * K8S_RALLY Use Kubernetes Rally plugin for testing K8S cluster |
| 24 | * STACKLIGHT_RALLY Use Stacklight Rally plugin for testing Stacklight |
Dmitrii Kabanov | 9f3b7ed | 2017-09-29 10:47:36 -0700 | [diff] [blame] | 25 | * RALLY_IMAGE The name of the image for Rally tests |
| 26 | * RALLY_FLAVOR The name of the flavor for Rally image |
Oleg Basov | 41c4fe7 | 2018-06-10 01:16:58 +0200 | [diff] [blame] | 27 | * RALLY_PLUGINS_REPO Git repository with Rally plugins |
| 28 | * RALLY_PLUGINS_BRANCH Git branch which will be used during the checkout |
Dmitrii Kabanov | b2f60ee | 2017-11-10 00:31:50 -0800 | [diff] [blame] | 29 | * RALLY_CONFIG_REPO Git repository with files for Rally |
| 30 | * RALLY_CONFIG_BRANCH Git branch which will be used during the checkout |
Sergey Galkin | 8991e82 | 2017-11-29 19:10:46 +0400 | [diff] [blame] | 31 | * RALLY_SCENARIOS Path to file or directory with rally scenarios |
Oleg Basov | bf86032 | 2018-09-04 20:54:36 +0200 | [diff] [blame] | 32 | * RALLY_SL_SCENARIOS Path to file or directory with stacklight rally scenarios |
Sergey Galkin | 8991e82 | 2017-11-29 19:10:46 +0400 | [diff] [blame] | 33 | * RALLY_TASK_ARGS_FILE Path to file with rally tests arguments |
Oleg Basov | d4fa386 | 2019-03-05 21:49:12 +0100 | [diff] [blame^] | 34 | * RALLY_DB_CONN_STRING Rally-compliant DB connection string for long-term storing |
| 35 | results to external DB |
| 36 | * RALLY_TAGS List of tags for marking Rally tasks. Can be used when |
| 37 | generating Rally trends based on particular group of tasks |
| 38 | * RALLY_TRENDS If enabled, generate Rally trends report. Requires external DB |
| 39 | connection string to be set. If RALLY_TAGS was set, trends will |
| 40 | be generated based on finished tasks with these tags, otherwise |
| 41 | on all the finished tasks available in DB |
mkraynov | da6b698 | 2018-08-06 17:48:24 +0400 | [diff] [blame] | 42 | * SKIP_LIST List of the Rally scenarios which should be skipped |
Oleg Basov | d4fa386 | 2019-03-05 21:49:12 +0100 | [diff] [blame^] | 43 | * REPORT_DIR Path for reports outside docker image |
| 44 | * |
| 45 | * Tempest |
| 46 | * |
| 47 | * TEMPEST_TEST_SET If not false, run tests matched to pattern only |
| 48 | * TEMPEST_CONFIG_REPO Git repository with configuration files for Tempest |
| 49 | * TEMPEST_CONFIG_BRANCH Git branch which will be used during the checkout |
| 50 | * TEMPEST_REPO Git repository with Tempest |
| 51 | * TEMPEST_VERSION Version of Tempest (tag, branch or commit) |
| 52 | * GENERATE_REPORT If not false, run report generation command |
| 53 | * |
| 54 | * SPT |
| 55 | * |
| 56 | * AVAILABILITY_ZONE The name of availability zone |
| 57 | * FLOATING_NETWORK The name of the external(floating) network |
| 58 | * SPT_SSH_USER The name of the user which should be used for ssh to nodes |
| 59 | * SPT_IMAGE The name of the image for SPT tests |
| 60 | * SPT_IMAGE_USER The name of the user for SPT image |
| 61 | * SPT_FLAVOR The name of the flavor for SPT image |
| 62 | * GENERATE_REPORT If not false, run report generation command |
Oleg Basov | 41c4fe7 | 2018-06-10 01:16:58 +0200 | [diff] [blame] | 63 | * |
Petr Lomakin | e700ffd | 2017-08-01 10:53:15 -0700 | [diff] [blame] | 64 | */ |
| 65 | |
| 66 | common = new com.mirantis.mk.Common() |
Dmitrii Kabanov | a67e5a5 | 2017-08-14 16:31:11 -0700 | [diff] [blame] | 67 | test = new com.mirantis.mk.Test() |
Petr Lomakin | e700ffd | 2017-08-01 10:53:15 -0700 | [diff] [blame] | 68 | validate = new com.mirantis.mcp.Validate() |
chnyda | 625f4b4 | 2017-10-11 14:10:31 +0200 | [diff] [blame] | 69 | def python = new com.mirantis.mk.Python() |
Petr Lomakin | e700ffd | 2017-08-01 10:53:15 -0700 | [diff] [blame] | 70 | |
chnyda | 625f4b4 | 2017-10-11 14:10:31 +0200 | [diff] [blame] | 71 | def pepperEnv = "pepperEnv" |
Petr Lomakin | e700ffd | 2017-08-01 10:53:15 -0700 | [diff] [blame] | 72 | def artifacts_dir = 'validation_artifacts/' |
Oleg Basov | d4fa386 | 2019-03-05 21:49:12 +0100 | [diff] [blame^] | 73 | def VALIDATE_PARAMS = readYaml(text: env.getProperty('VALIDATE_PARAMS')) ?: [:] |
| 74 | if (! VALIDATE_PARAMS) { |
| 75 | throw new Exception("VALIDATE_PARAMS yaml is empty.") |
| 76 | } |
| 77 | |
Dmitry Tsapikov | 38f3651 | 2018-07-24 15:18:36 +0000 | [diff] [blame] | 78 | if (env.JOB_TIMEOUT == ''){ |
Sergey Galkin | 3199a2e | 2018-05-28 18:55:58 +0400 | [diff] [blame] | 79 | job_timeout = 12 |
| 80 | } else { |
| 81 | job_timeout = env.JOB_TIMEOUT.toInteger() |
| 82 | } |
| 83 | timeout(time: job_timeout, unit: 'HOURS') { |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 84 | node() { |
| 85 | try{ |
| 86 | stage('Setup virtualenv for Pepper') { |
| 87 | python.setupPepperVirtualenv(pepperEnv, SALT_MASTER_URL, SALT_MASTER_CREDENTIALS) |
Tetiana Korchak | efa4f78 | 2017-08-25 10:22:29 -0700 | [diff] [blame] | 88 | } |
Petr Lomakin | e700ffd | 2017-08-01 10:53:15 -0700 | [diff] [blame] | 89 | |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 90 | stage('Configure') { |
| 91 | validate.installDocker(pepperEnv, TARGET_NODE) |
| 92 | if (ACCUMULATE_RESULTS.toBoolean() == false) { |
| 93 | sh "rm -r ${artifacts_dir}" |
| 94 | } |
| 95 | sh "mkdir -p ${artifacts_dir}" |
Petr Lomakin | e700ffd | 2017-08-01 10:53:15 -0700 | [diff] [blame] | 96 | } |
Petr Lomakin | e700ffd | 2017-08-01 10:53:15 -0700 | [diff] [blame] | 97 | |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 98 | stage('Run Tempest tests') { |
| 99 | if (RUN_TEMPEST_TESTS.toBoolean() == true) { |
Oleg Basov | d4fa386 | 2019-03-05 21:49:12 +0100 | [diff] [blame^] | 100 | def tempest = VALIDATE_PARAMS.get('tempest') ?: [] |
| 101 | validate.runTempestTests( |
| 102 | pepperEnv, TARGET_NODE, TEST_IMAGE, |
| 103 | artifacts_dir, tempest.TEMPEST_CONFIG_REPO, |
| 104 | tempest.TEMPEST_CONFIG_BRANCH, tempest.TEMPEST_REPO, |
| 105 | tempest.TEMPEST_VERSION, tempest.TEMPEST_TEST_SET |
| 106 | ) |
| 107 | if (tempest.GENERATE_REPORT.toBoolean() == true) { |
| 108 | common.infoMsg("Generating html test report ...") |
| 109 | validate.generateTestReport(pepperEnv, TARGET_NODE, TEST_IMAGE, artifacts_dir) |
| 110 | } |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 111 | } else { |
| 112 | common.infoMsg("Skipping Tempest tests") |
| 113 | } |
Petr Lomakin | e700ffd | 2017-08-01 10:53:15 -0700 | [diff] [blame] | 114 | } |
Dmitrii Kabanov | a67e5a5 | 2017-08-14 16:31:11 -0700 | [diff] [blame] | 115 | |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 116 | stage('Run Rally tests') { |
| 117 | if (RUN_RALLY_TESTS.toBoolean() == true) { |
Oleg Basov | d4fa386 | 2019-03-05 21:49:12 +0100 | [diff] [blame^] | 118 | def rally = VALIDATE_PARAMS.get('rally') ?: [] |
| 119 | def tags = rally.get('RALLY_TAGS') ?: [] |
| 120 | def report_dir = rally.REPORT_DIR ?: '/root/qa_results' |
Oleg Basov | bf86032 | 2018-09-04 20:54:36 +0200 | [diff] [blame] | 121 | def platform = ["type":"unknown", "stacklight_enabled":false] |
| 122 | def rally_variables = [] |
Oleg Basov | d4fa386 | 2019-03-05 21:49:12 +0100 | [diff] [blame^] | 123 | if (rally.K8S_RALLY.toBoolean() == false) { |
Oleg Basov | bf86032 | 2018-09-04 20:54:36 +0200 | [diff] [blame] | 124 | platform['type'] = 'openstack' |
Oleg Basov | d4fa386 | 2019-03-05 21:49:12 +0100 | [diff] [blame^] | 125 | rally_variables = ["floating_network=${rally.FLOATING_NETWORK}", |
| 126 | "rally_image=${rally.RALLY_IMAGE}", |
| 127 | "rally_flavor=${rally.RALLY_FLAVOR}", |
| 128 | "availability_zone=${rally.AVAILABILITY_ZONE}"] |
Oleg Basov | 41c4fe7 | 2018-06-10 01:16:58 +0200 | [diff] [blame] | 129 | } else { |
Oleg Basov | bf86032 | 2018-09-04 20:54:36 +0200 | [diff] [blame] | 130 | platform['type'] = 'k8s' |
Oleg Basov | 41c4fe7 | 2018-06-10 01:16:58 +0200 | [diff] [blame] | 131 | } |
Oleg Basov | d4fa386 | 2019-03-05 21:49:12 +0100 | [diff] [blame^] | 132 | if (rally.STACKLIGHT_RALLY.toBoolean() == true) { |
Oleg Basov | bf86032 | 2018-09-04 20:54:36 +0200 | [diff] [blame] | 133 | platform['stacklight_enabled'] = true |
| 134 | } |
Oleg Basov | d4fa386 | 2019-03-05 21:49:12 +0100 | [diff] [blame^] | 135 | validate.runRallyTests( |
| 136 | pepperEnv, TARGET_NODE, TEST_IMAGE, |
| 137 | platform, artifacts_dir, rally.RALLY_CONFIG_REPO, |
| 138 | rally.RALLY_CONFIG_BRANCH, rally.RALLY_PLUGINS_REPO, |
| 139 | rally.RALLY_PLUGINS_BRANCH, rally.RALLY_SCENARIOS, |
| 140 | rally.RALLY_SL_SCENARIOS, rally.RALLY_TASK_ARGS_FILE, |
| 141 | rally.RALLY_DB_CONN_STRING, tags, |
| 142 | rally.RALLY_TRENDS, rally_variables, |
| 143 | report_dir, rally.SKIP_LIST |
| 144 | ) |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 145 | } else { |
| 146 | common.infoMsg("Skipping Rally tests") |
| 147 | } |
Dmitrii Kabanov | 6b9343e | 2017-08-30 15:30:21 -0700 | [diff] [blame] | 148 | } |
Dmitrii Kabanov | 6b9343e | 2017-08-30 15:30:21 -0700 | [diff] [blame] | 149 | |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 150 | stage('Run SPT tests') { |
| 151 | if (RUN_SPT_TESTS.toBoolean() == true) { |
Oleg Basov | d4fa386 | 2019-03-05 21:49:12 +0100 | [diff] [blame^] | 152 | def spt = VALIDATE_PARAMS.get('spt') ?: [] |
| 153 | def spt_variables = ["spt_ssh_user=${spt.SPT_SSH_USER}", |
| 154 | "spt_floating_network=${spt.FLOATING_NETWORK}", |
| 155 | "spt_image=${spt.SPT_IMAGE}", |
| 156 | "spt_user=${spt.SPT_IMAGE_USER}", |
| 157 | "spt_flavor=${spt.SPT_FLAVOR}", |
| 158 | "spt_availability_zone=${spt.AVAILABILITY_ZONE}"] |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 159 | validate.runSptTests(pepperEnv, TARGET_NODE, TEST_IMAGE, artifacts_dir, spt_variables) |
Oleg Basov | d4fa386 | 2019-03-05 21:49:12 +0100 | [diff] [blame^] | 160 | |
| 161 | if (spt.GENERATE_REPORT.toBoolean() == true) { |
| 162 | common.infoMsg("Generating html test report ...") |
| 163 | validate.generateTestReport(pepperEnv, TARGET_NODE, TEST_IMAGE, artifacts_dir) |
| 164 | } |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 165 | } else { |
| 166 | common.infoMsg("Skipping SPT tests") |
| 167 | } |
Dmitrii Kabanov | a67e5a5 | 2017-08-14 16:31:11 -0700 | [diff] [blame] | 168 | } |
Dmitrii Kabanov | a67e5a5 | 2017-08-14 16:31:11 -0700 | [diff] [blame] | 169 | |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 170 | stage('Collect results') { |
| 171 | archiveArtifacts artifacts: "${artifacts_dir}/*" |
| 172 | } |
| 173 | } catch (Throwable e) { |
| 174 | // If there was an error or exception thrown, the build failed |
| 175 | currentBuild.result = "FAILURE" |
| 176 | currentBuild.description = currentBuild.description ? e.message + " " + currentBuild.description : e.message |
| 177 | throw e |
Tetiana Korchak | efa4f78 | 2017-08-25 10:22:29 -0700 | [diff] [blame] | 178 | } |
Petr Lomakin | e700ffd | 2017-08-01 10:53:15 -0700 | [diff] [blame] | 179 | } |
| 180 | } |