blob: 503b375985b7f5a1408ec68575b21998720c1a6f [file] [log] [blame]
Petr Lomakine700ffd2017-08-01 10:53:15 -07001/**
2 *
3 * Launch validation of the cloud
4 *
5 * Expected parameters:
6 * SALT_MASTER_URL URL of Salt master
7 * SALT_MASTER_CREDENTIALS Credentials to the Salt API
8 *
9 * TEST_IMAGE Docker image link
10 * TARGET_NODE Salt target for tempest node
11 * TEMPEST_TEST_SET If not false, run tests matched to pattern only
Dmitrii Kabanovb2f60ee2017-11-10 00:31:50 -080012 * TEMPEST_CONFIG_REPO Git repository with configuration files for Tempest
13 * TEMPEST_CONFIG_BRANCH Git branch which will be used during the checkout
14 * TEMPEST_REPO Git repository with Tempest
15 * TEMPEST_VERSION Version of Tempest (tag, branch or commit)
Petr Lomakine700ffd2017-08-01 10:53:15 -070016 * RUN_TEMPEST_TESTS If not false, run Tempest tests
17 * RUN_RALLY_TESTS If not false, run Rally tests
Oleg Basov41c4fe72018-06-10 01:16:58 +020018 * K8S_RALLY If not false, run Kubernetes Rally tests
19 * RUN_K8S_TESTS If not false, run Kubernetes e2e/conformance tests
Dmitrii Kabanov6b9343e2017-08-30 15:30:21 -070020 * RUN_SPT_TESTS If not false, run SPT tests
21 * SPT_SSH_USER The name of the user which should be used for ssh to nodes
Dmitrii Kabanov6b9343e2017-08-30 15:30:21 -070022 * SPT_IMAGE The name of the image for SPT tests
Dmitrii Kabanov9f3b7ed2017-09-29 10:47:36 -070023 * SPT_IMAGE_USER The name of the user for SPT image
Dmitrii Kabanov6b9343e2017-08-30 15:30:21 -070024 * SPT_FLAVOR The name of the flavor for SPT image
Dmitrii Kabanov9f3b7ed2017-09-29 10:47:36 -070025 * AVAILABILITY_ZONE The name of availability zone
26 * FLOATING_NETWORK The name of the external(floating) network
27 * RALLY_IMAGE The name of the image for Rally tests
28 * RALLY_FLAVOR The name of the flavor for Rally image
Oleg Basov41c4fe72018-06-10 01:16:58 +020029 * RALLY_PLUGINS_REPO Git repository with Rally plugins
30 * RALLY_PLUGINS_BRANCH Git branch which will be used during the checkout
Dmitrii Kabanovb2f60ee2017-11-10 00:31:50 -080031 * RALLY_CONFIG_REPO Git repository with files for Rally
32 * RALLY_CONFIG_BRANCH Git branch which will be used during the checkout
Sergey Galkin8991e822017-11-29 19:10:46 +040033 * RALLY_SCENARIOS Path to file or directory with rally scenarios
34 * RALLY_TASK_ARGS_FILE Path to file with rally tests arguments
Sergey Galkin59511372018-02-13 13:59:41 +040035 * REPORT_DIR Path for reports outside docker image
Dmitrii Kabanova67e5a52017-08-14 16:31:11 -070036 * TEST_K8S_API_SERVER Kubernetes API address
37 * TEST_K8S_CONFORMANCE_IMAGE Path to docker image with conformance e2e tests
Tetiana Korchakefa4f782017-08-25 10:22:29 -070038 * TEST_K8S_NODE Kubernetes node to run tests from
39 * GENERATE_REPORT If not false, run report generation command
40 * ACCUMULATE_RESULTS If true, results from the previous build will be used
Sergey Galkin3199a2e2018-05-28 18:55:58 +040041 * JOB_TIMEOUT Job timeout in hours
Oleg Basov41c4fe72018-06-10 01:16:58 +020042 *
Petr Lomakine700ffd2017-08-01 10:53:15 -070043 */
44
45common = new com.mirantis.mk.Common()
Dmitrii Kabanova67e5a52017-08-14 16:31:11 -070046test = new com.mirantis.mk.Test()
Petr Lomakine700ffd2017-08-01 10:53:15 -070047validate = new com.mirantis.mcp.Validate()
chnyda625f4b42017-10-11 14:10:31 +020048def python = new com.mirantis.mk.Python()
Petr Lomakine700ffd2017-08-01 10:53:15 -070049
chnyda625f4b42017-10-11 14:10:31 +020050def pepperEnv = "pepperEnv"
Petr Lomakine700ffd2017-08-01 10:53:15 -070051def artifacts_dir = 'validation_artifacts/'
dtsapikov164010b2018-07-20 11:30:48 +040052if (!env.JOB_TIMEOUT){
Sergey Galkin3199a2e2018-05-28 18:55:58 +040053 job_timeout = 12
54} else {
55 job_timeout = env.JOB_TIMEOUT.toInteger()
56}
57timeout(time: job_timeout, unit: 'HOURS') {
Jakub Josefa63f9862018-01-11 17:58:38 +010058 node() {
59 try{
60 stage('Setup virtualenv for Pepper') {
61 python.setupPepperVirtualenv(pepperEnv, SALT_MASTER_URL, SALT_MASTER_CREDENTIALS)
Tetiana Korchakefa4f782017-08-25 10:22:29 -070062 }
Petr Lomakine700ffd2017-08-01 10:53:15 -070063
Jakub Josefa63f9862018-01-11 17:58:38 +010064 stage('Configure') {
65 validate.installDocker(pepperEnv, TARGET_NODE)
66 if (ACCUMULATE_RESULTS.toBoolean() == false) {
67 sh "rm -r ${artifacts_dir}"
68 }
69 sh "mkdir -p ${artifacts_dir}"
Petr Lomakine700ffd2017-08-01 10:53:15 -070070 }
Petr Lomakine700ffd2017-08-01 10:53:15 -070071
Jakub Josefa63f9862018-01-11 17:58:38 +010072 stage('Run Tempest tests') {
73 if (RUN_TEMPEST_TESTS.toBoolean() == true) {
74 validate.runTempestTests(pepperEnv, TARGET_NODE, TEST_IMAGE, artifacts_dir, TEMPEST_CONFIG_REPO, TEMPEST_CONFIG_BRANCH, TEMPEST_REPO, TEMPEST_VERSION, TEMPEST_TEST_SET)
75 } else {
76 common.infoMsg("Skipping Tempest tests")
77 }
Petr Lomakine700ffd2017-08-01 10:53:15 -070078 }
Dmitrii Kabanova67e5a52017-08-14 16:31:11 -070079
Jakub Josefa63f9862018-01-11 17:58:38 +010080 stage('Run Rally tests') {
81 if (RUN_RALLY_TESTS.toBoolean() == true) {
Alexander Evseevb6c66992018-05-21 17:52:21 +030082 def report_dir = env.REPORT_DIR ?: '/root/qa_results'
Oleg Basov41c4fe72018-06-10 01:16:58 +020083 def platform
84 def rally_variables
85 if (K8S_RALLY.toBoolean() == false) {
86 platform = 'openstack'
87 rally_variables = ["floating_network=${FLOATING_NETWORK}",
88 "rally_image=${RALLY_IMAGE}",
89 "rally_flavor=${RALLY_FLAVOR}",
90 "availability_zone=${AVAILABILITY_ZONE}"]
91 } else {
92 platform = 'k8s'
93 rally_variables = ["plugins_repo":"${RALLY_PLUGINS_REPO}",
94 "plugins_branch":"${RALLY_PLUGINS_BRANCH}"]
95 }
96 validate.runRallyTests(pepperEnv, TARGET_NODE, TEST_IMAGE, platform, artifacts_dir, RALLY_CONFIG_REPO, RALLY_CONFIG_BRANCH, RALLY_SCENARIOS, RALLY_TASK_ARGS_FILE, rally_variables, report_dir)
Jakub Josefa63f9862018-01-11 17:58:38 +010097 } else {
98 common.infoMsg("Skipping Rally tests")
99 }
Dmitrii Kabanov6b9343e2017-08-30 15:30:21 -0700100 }
Dmitrii Kabanov6b9343e2017-08-30 15:30:21 -0700101
Jakub Josefa63f9862018-01-11 17:58:38 +0100102 stage('Run SPT tests') {
103 if (RUN_SPT_TESTS.toBoolean() == true) {
104 def spt_variables = ["spt_ssh_user=${SPT_SSH_USER}",
105 "spt_floating_network=${FLOATING_NETWORK}",
106 "spt_image=${SPT_IMAGE}",
107 "spt_user=${SPT_IMAGE_USER}",
108 "spt_flavor=${SPT_FLAVOR}",
109 "spt_availability_zone=${AVAILABILITY_ZONE}"]
110 validate.runSptTests(pepperEnv, TARGET_NODE, TEST_IMAGE, artifacts_dir, spt_variables)
111 } else {
112 common.infoMsg("Skipping SPT tests")
113 }
Dmitrii Kabanova67e5a52017-08-14 16:31:11 -0700114 }
Dmitrii Kabanova67e5a52017-08-14 16:31:11 -0700115
Oleg Basov41c4fe72018-06-10 01:16:58 +0200116 stage('Run K8S bootstrap tests') {
Jakub Josefa63f9862018-01-11 17:58:38 +0100117 if (RUN_K8S_TESTS.toBoolean() == true) {
118 def image = 'tomkukral/k8s-scripts'
119 def output_file = 'k8s-bootstrap-tests.txt'
120 def outfile = "/tmp/" + image.replaceAll('/', '-') + '.output'
121 test.runConformanceTests(pepperEnv, TEST_K8S_NODE, TEST_K8S_API_SERVER, image)
Dmitrii Kabanova67e5a52017-08-14 16:31:11 -0700122
Jakub Josefa63f9862018-01-11 17:58:38 +0100123 def file_content = validate.getFileContent(pepperEnv, TEST_K8S_NODE, outfile)
124 writeFile file: "${artifacts_dir}${output_file}", text: file_content
125 } else {
126 common.infoMsg("Skipping k8s bootstrap tests")
127 }
Dmitrii Kabanova67e5a52017-08-14 16:31:11 -0700128 }
Jakub Josefa63f9862018-01-11 17:58:38 +0100129
Oleg Basov41c4fe72018-06-10 01:16:58 +0200130 stage('Run K8S conformance e2e tests') {
Jakub Josefa63f9862018-01-11 17:58:38 +0100131 if (RUN_K8S_TESTS.toBoolean() == true) {
132 def image = TEST_K8S_CONFORMANCE_IMAGE
133 def output_file = 'report-k8s-e2e-tests.txt'
134 def outfile = "/tmp/" + image.replaceAll('/', '-') + '.output'
135 test.runConformanceTests(pepperEnv, TEST_K8S_NODE, TEST_K8S_API_SERVER, image)
136
137 def file_content = validate.getFileContent(pepperEnv, TEST_K8S_NODE, outfile)
138 writeFile file: "${artifacts_dir}${output_file}", text: file_content
139 } else {
140 common.infoMsg("Skipping k8s conformance e2e tests")
141 }
Tetiana Korchakefa4f782017-08-25 10:22:29 -0700142 }
Jakub Josefa63f9862018-01-11 17:58:38 +0100143 stage('Generate report') {
144 if (GENERATE_REPORT.toBoolean() == true) {
145 common.infoMsg("Generating html test report ...")
146 validate.generateTestReport(pepperEnv, TARGET_NODE, TEST_IMAGE, artifacts_dir)
147 } else {
148 common.infoMsg("Skipping report generation")
149 }
150 }
151 stage('Collect results') {
152 archiveArtifacts artifacts: "${artifacts_dir}/*"
153 }
154 } catch (Throwable e) {
155 // If there was an error or exception thrown, the build failed
156 currentBuild.result = "FAILURE"
157 currentBuild.description = currentBuild.description ? e.message + " " + currentBuild.description : e.message
158 throw e
Tetiana Korchakefa4f782017-08-25 10:22:29 -0700159 }
Petr Lomakine700ffd2017-08-01 10:53:15 -0700160 }
161}