blob: 000c34c34a71c24ddcb1576dc43e12550d6f4c41 [file] [log] [blame]
Petr Lomakine700ffd2017-08-01 10:53:15 -07001/**
2 *
3 * Launch validation of the cloud
4 *
5 * Expected parameters:
Oleg Basovd4fa3862019-03-05 21:49:12 +01006 *
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 Lomakine700ffd2017-08-01 10:53:15 -070014 * SALT_MASTER_URL URL of Salt master
15 * SALT_MASTER_CREDENTIALS Credentials to the Salt API
16 *
Oleg Basovd4fa3862019-03-05 21:49:12 +010017 * Additional validate job YAML params:
18 *
19 * Rally
20 *
Dmitrii Kabanov9f3b7ed2017-09-29 10:47:36 -070021 * AVAILABILITY_ZONE The name of availability zone
22 * FLOATING_NETWORK The name of the external(floating) network
Oleg Basovd4fa3862019-03-05 21:49:12 +010023 * K8S_RALLY Use Kubernetes Rally plugin for testing K8S cluster
24 * STACKLIGHT_RALLY Use Stacklight Rally plugin for testing Stacklight
Dmitrii Kabanov9f3b7ed2017-09-29 10:47:36 -070025 * RALLY_IMAGE The name of the image for Rally tests
26 * RALLY_FLAVOR The name of the flavor for Rally image
Oleg Basov41c4fe72018-06-10 01:16:58 +020027 * RALLY_PLUGINS_REPO Git repository with Rally plugins
28 * RALLY_PLUGINS_BRANCH Git branch which will be used during the checkout
Dmitrii Kabanovb2f60ee2017-11-10 00:31:50 -080029 * RALLY_CONFIG_REPO Git repository with files for Rally
30 * RALLY_CONFIG_BRANCH Git branch which will be used during the checkout
Sergey Galkin8991e822017-11-29 19:10:46 +040031 * RALLY_SCENARIOS Path to file or directory with rally scenarios
Oleg Basovbf860322018-09-04 20:54:36 +020032 * RALLY_SL_SCENARIOS Path to file or directory with stacklight rally scenarios
Sergey Galkin8991e822017-11-29 19:10:46 +040033 * RALLY_TASK_ARGS_FILE Path to file with rally tests arguments
Oleg Basovd4fa3862019-03-05 21:49:12 +010034 * 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
mkraynovda6b6982018-08-06 17:48:24 +040042 * SKIP_LIST List of the Rally scenarios which should be skipped
Oleg Basovd4fa3862019-03-05 21:49:12 +010043 * 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 Basov41c4fe72018-06-10 01:16:58 +020063 *
Petr Lomakine700ffd2017-08-01 10:53:15 -070064 */
65
66common = new com.mirantis.mk.Common()
Dmitrii Kabanova67e5a52017-08-14 16:31:11 -070067test = new com.mirantis.mk.Test()
Petr Lomakine700ffd2017-08-01 10:53:15 -070068validate = new com.mirantis.mcp.Validate()
chnyda625f4b42017-10-11 14:10:31 +020069def python = new com.mirantis.mk.Python()
Petr Lomakine700ffd2017-08-01 10:53:15 -070070
chnyda625f4b42017-10-11 14:10:31 +020071def pepperEnv = "pepperEnv"
Petr Lomakine700ffd2017-08-01 10:53:15 -070072def artifacts_dir = 'validation_artifacts/'
Oleg Basovd4fa3862019-03-05 21:49:12 +010073def VALIDATE_PARAMS = readYaml(text: env.getProperty('VALIDATE_PARAMS')) ?: [:]
74if (! VALIDATE_PARAMS) {
75 throw new Exception("VALIDATE_PARAMS yaml is empty.")
76}
77
Dmitry Tsapikov38f36512018-07-24 15:18:36 +000078if (env.JOB_TIMEOUT == ''){
Sergey Galkin3199a2e2018-05-28 18:55:58 +040079 job_timeout = 12
80} else {
81 job_timeout = env.JOB_TIMEOUT.toInteger()
82}
83timeout(time: job_timeout, unit: 'HOURS') {
Jakub Josefa63f9862018-01-11 17:58:38 +010084 node() {
85 try{
86 stage('Setup virtualenv for Pepper') {
87 python.setupPepperVirtualenv(pepperEnv, SALT_MASTER_URL, SALT_MASTER_CREDENTIALS)
Tetiana Korchakefa4f782017-08-25 10:22:29 -070088 }
Petr Lomakine700ffd2017-08-01 10:53:15 -070089
Jakub Josefa63f9862018-01-11 17:58:38 +010090 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 Lomakine700ffd2017-08-01 10:53:15 -070096 }
Petr Lomakine700ffd2017-08-01 10:53:15 -070097
Jakub Josefa63f9862018-01-11 17:58:38 +010098 stage('Run Tempest tests') {
99 if (RUN_TEMPEST_TESTS.toBoolean() == true) {
Oleg Basovd4fa3862019-03-05 21:49:12 +0100100 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 Josefa63f9862018-01-11 17:58:38 +0100111 } else {
112 common.infoMsg("Skipping Tempest tests")
113 }
Petr Lomakine700ffd2017-08-01 10:53:15 -0700114 }
Dmitrii Kabanova67e5a52017-08-14 16:31:11 -0700115
Jakub Josefa63f9862018-01-11 17:58:38 +0100116 stage('Run Rally tests') {
117 if (RUN_RALLY_TESTS.toBoolean() == true) {
Oleg Basovd4fa3862019-03-05 21:49:12 +0100118 def rally = VALIDATE_PARAMS.get('rally') ?: []
119 def tags = rally.get('RALLY_TAGS') ?: []
120 def report_dir = rally.REPORT_DIR ?: '/root/qa_results'
Oleg Basovbf860322018-09-04 20:54:36 +0200121 def platform = ["type":"unknown", "stacklight_enabled":false]
122 def rally_variables = []
Oleg Basovd4fa3862019-03-05 21:49:12 +0100123 if (rally.K8S_RALLY.toBoolean() == false) {
Oleg Basovbf860322018-09-04 20:54:36 +0200124 platform['type'] = 'openstack'
Oleg Basovd4fa3862019-03-05 21:49:12 +0100125 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 Basov41c4fe72018-06-10 01:16:58 +0200129 } else {
Oleg Basovbf860322018-09-04 20:54:36 +0200130 platform['type'] = 'k8s'
Oleg Basov41c4fe72018-06-10 01:16:58 +0200131 }
Oleg Basovd4fa3862019-03-05 21:49:12 +0100132 if (rally.STACKLIGHT_RALLY.toBoolean() == true) {
Oleg Basovbf860322018-09-04 20:54:36 +0200133 platform['stacklight_enabled'] = true
134 }
Oleg Basovd4fa3862019-03-05 21:49:12 +0100135 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 Josefa63f9862018-01-11 17:58:38 +0100145 } else {
146 common.infoMsg("Skipping Rally tests")
147 }
Dmitrii Kabanov6b9343e2017-08-30 15:30:21 -0700148 }
Dmitrii Kabanov6b9343e2017-08-30 15:30:21 -0700149
Jakub Josefa63f9862018-01-11 17:58:38 +0100150 stage('Run SPT tests') {
151 if (RUN_SPT_TESTS.toBoolean() == true) {
Oleg Basovd4fa3862019-03-05 21:49:12 +0100152 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 Josefa63f9862018-01-11 17:58:38 +0100159 validate.runSptTests(pepperEnv, TARGET_NODE, TEST_IMAGE, artifacts_dir, spt_variables)
Oleg Basovd4fa3862019-03-05 21:49:12 +0100160
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 Josefa63f9862018-01-11 17:58:38 +0100165 } else {
166 common.infoMsg("Skipping SPT tests")
167 }
Dmitrii Kabanova67e5a52017-08-14 16:31:11 -0700168 }
Dmitrii Kabanova67e5a52017-08-14 16:31:11 -0700169
Jakub Josefa63f9862018-01-11 17:58:38 +0100170 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 Korchakefa4f782017-08-25 10:22:29 -0700178 }
Petr Lomakine700ffd2017-08-01 10:53:15 -0700179 }
180}