blob: 649ac6ac90a405a643c641381638cc986be857a2 [file] [log] [blame]
Oleksii Zhurba3f438942017-11-13 20:00:06 -06001/**
2 *
Oleksii Zhurba713a5d22018-10-11 14:23:04 +03003 * Launch CVP HA testing for the cloud (virtualized control plane only)
Oleksii Zhurba3f438942017-11-13 20:00:06 -06004 *
5 * Expected parameters:
Oleksii Zhurba3f438942017-11-13 20:00:06 -06006 *
Oleksii Zhurba8fa12d12017-12-07 13:45:53 -06007 * 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 * MANUAL_CONFIRMATION Ask for confirmation before doing something destructive (reboot/shutdown node)
15 * RETRY_CHECK_STATUS Number of retries to check node status
16 * SKIP_LIST_PATH Path to tempest skip list file in TOOLS_REPO
17 * TARGET_NODES Nodes to test
18 * TEMPEST_REPO Tempest repo to clone and use
19 * TEMPEST_TARGET_NODE Node, where tests will be executed
20 * TEMPEST_TEST_PATTERN Tests to run during HA scenarios
Oleksii Zhurba3f438942017-11-13 20:00:06 -060021 *
22 */
23
24common = new com.mirantis.mk.Common()
25salt = new com.mirantis.mk.Salt()
26validate = new com.mirantis.mcp.Validate()
27
28def saltMaster
29def artifacts_dir = 'validation_artifacts/'
30def remote_artifacts_dir = '/root/qa_results/'
Oleksii Zhurba713a5d22018-10-11 14:23:04 +030031def container_name = "${env.JOB_NAME}"
Oleksii Zhurba1c55a012018-04-30 16:18:59 -050032def current_target_node = null
33def first_node = null
Oleksii Zhurba3f438942017-11-13 20:00:06 -060034def tempest_result = ''
Jakub Josefa63f9862018-01-11 17:58:38 +010035timeout(time: 12, unit: 'HOURS') {
36 node() {
37 def num_retries = Integer.parseInt(RETRY_CHECK_STATUS)
38 try {
39 stage('Initialization') {
Jakub Josefa63f9862018-01-11 17:58:38 +010040 sh "rm -rf ${artifacts_dir}"
Oleksii Zhurba713a5d22018-10-11 14:23:04 +030041 saltMaster = salt.connection(SALT_MASTER_URL, SALT_MASTER_CREDENTIALS)
Oleksii Zhurba49275882018-03-21 15:41:57 -050042 salt.cmdRun(saltMaster, TEMPEST_TARGET_NODE, "rm -rf ${remote_artifacts_dir}")
Jakub Josefa63f9862018-01-11 17:58:38 +010043 salt.cmdRun(saltMaster, TEMPEST_TARGET_NODE, "mkdir -p ${remote_artifacts_dir}")
Oleksii Zhurba713a5d22018-10-11 14:23:04 +030044 keystone_creds = validate._get_keystone_creds_v3(saltMaster)
45 if (!keystone_creds) {
46 keystone_creds = validate._get_keystone_creds_v2(saltMaster)
47 }
48 validate.runContainer(saltMaster, TARGET_NODE, TEST_IMAGE, container_name, keystone_creds)
Jakub Josefa63f9862018-01-11 17:58:38 +010049 validate.configureContainer(saltMaster, TEMPEST_TARGET_NODE, PROXY, TOOLS_REPO, TEMPEST_REPO)
Oleksii Zhurba3f438942017-11-13 20:00:06 -060050 }
Oleksii Zhurba3f438942017-11-13 20:00:06 -060051
Jakub Josefa63f9862018-01-11 17:58:38 +010052 stage('Initial env check') {
53 sh "mkdir -p ${artifacts_dir}"
54 tempest_result = validate.runCVPtempest(saltMaster, TEMPEST_TARGET_NODE, TEMPEST_TEST_PATTERN, SKIP_LIST_PATH, remote_artifacts_dir, "docker_tempest_initial")
55 validate.openstack_cleanup(saltMaster, TEMPEST_TARGET_NODE)
56 if (tempest_result != "finished") {
57 currentBuild.result = "FAILURE"
58 throw new Exception("Tempest tests failed")
Oleksii Zhurba3f438942017-11-13 20:00:06 -060059 }
60 }
Oleksii Zhurba3f438942017-11-13 20:00:06 -060061
Jakub Josefa63f9862018-01-11 17:58:38 +010062 stage('Soft Shutdown') {
63 if (MANUAL_CONFIRMATION.toBoolean() == true) {
64 stage('Ask for manual confirmation') {
65 input message: "Are you sure you want to shutdown current vip node?"
66 }
67 }
68 current_target_node = validate.get_vip_node(saltMaster, TARGET_NODES)
Oleksii Zhurba1c55a012018-04-30 16:18:59 -050069 if (current_target_node == null) {
70 throw new Exception("Cannot current vip node in ${TARGET_NODES} nodes")
71 }
Jakub Josefa63f9862018-01-11 17:58:38 +010072 common.warningMsg("Shutdown current vip node ${current_target_node}")
73 validate.shutdown_vm_node(saltMaster, current_target_node, 'soft_shutdown')
Oleksii Zhurbab2eb1f92018-01-18 12:53:13 -060074 sleep 15
Jakub Josefa63f9862018-01-11 17:58:38 +010075 }
76 stage('Check during shutdown') {
77 tempest_result = validate.runCVPtempest(saltMaster, TEMPEST_TARGET_NODE, TEMPEST_TEST_PATTERN, SKIP_LIST_PATH, remote_artifacts_dir, "docker_tempest_during_shutdown")
78 validate.openstack_cleanup(saltMaster, TEMPEST_TARGET_NODE)
79 if (tempest_result != "finished") {
80 currentBuild.result = "FAILURE"
81 throw new Exception("Tempest tests failed")
Oleksii Zhurba3f438942017-11-13 20:00:06 -060082 }
83 }
Jakub Josefa63f9862018-01-11 17:58:38 +010084 stage('Power on') {
85 common.infoMsg('Powering on node')
86 kvm = validate.locate_node_on_kvm(saltMaster, current_target_node)
87 salt.cmdRun(saltMaster, kvm, "virsh start ${current_target_node}")
88 common.infoMsg("Checking that node is UP")
89 status = salt.minionsReachable(saltMaster, 'I@salt:master', current_target_node, null, 10, num_retries)
90 if (status == null) {
91 throw new Exception("Node ${current_target_node} cannot start")
Oleksii Zhurba3f438942017-11-13 20:00:06 -060092 }
Oleksii Zhurbab2eb1f92018-01-18 12:53:13 -060093 first_node = current_target_node
Oleksii Zhurba1c55a012018-04-30 16:18:59 -050094 current_target_node = null
Oleksii Zhurbab2eb1f92018-01-18 12:53:13 -060095 sleep 30
Oleksii Zhurba3f438942017-11-13 20:00:06 -060096 }
Jakub Josefa63f9862018-01-11 17:58:38 +010097 stage('Check after shutdown') {
98 tempest_result = validate.runCVPtempest(saltMaster, TEMPEST_TARGET_NODE, TEMPEST_TEST_PATTERN, SKIP_LIST_PATH, remote_artifacts_dir, "docker_tempest_after_shutdown")
99 validate.openstack_cleanup(saltMaster, TEMPEST_TARGET_NODE)
100 if (tempest_result != "finished") {
101 currentBuild.result = "FAILURE"
102 throw new Exception("Tempest tests failed")
103 }
104 sleep 15
Oleksii Zhurba3f438942017-11-13 20:00:06 -0600105 }
Oleksii Zhurba3f438942017-11-13 20:00:06 -0600106
Jakub Josefa63f9862018-01-11 17:58:38 +0100107 stage('Hard Shutdown') {
108 if (MANUAL_CONFIRMATION.toBoolean() == true) {
109 stage('Ask for manual confirmation') {
110 input message: "Are you sure you want to hard shutdown current vip node?"
111 }
112 }
Oleksii Zhurbab2eb1f92018-01-18 12:53:13 -0600113 salt.cmdRun(saltMaster, first_node, "service keepalived stop")
Jakub Josefa63f9862018-01-11 17:58:38 +0100114 current_target_node = validate.get_vip_node(saltMaster, TARGET_NODES)
115 common.warningMsg("Shutdown current vip node ${current_target_node}")
116 validate.shutdown_vm_node(saltMaster, current_target_node, 'hard_shutdown')
Oleksii Zhurba1c55a012018-04-30 16:18:59 -0500117 //TODO:if previous command fails, keeaplived will not be started on first_node
Oleksii Zhurbab2eb1f92018-01-18 12:53:13 -0600118 sleep 10
119 salt.cmdRun(saltMaster, first_node, "service keepalived start")
Jakub Josefa63f9862018-01-11 17:58:38 +0100120 }
121 stage('Check during hard shutdown') {
122 tempest_result = validate.runCVPtempest(saltMaster, TEMPEST_TARGET_NODE, TEMPEST_TEST_PATTERN, SKIP_LIST_PATH, remote_artifacts_dir, "docker_tempest_during_hard_shutdown")
123 validate.openstack_cleanup(saltMaster, TEMPEST_TARGET_NODE)
124 if (tempest_result != "finished") {
125 currentBuild.result = "FAILURE"
126 throw new Exception("Tempest tests failed")
127 }
128 }
129 stage('Power on') {
130 common.infoMsg('Powering on node')
131 kvm = validate.locate_node_on_kvm(saltMaster, current_target_node)
132 salt.cmdRun(saltMaster, kvm, "virsh start ${current_target_node}")
133 common.infoMsg("Checking that node is UP")
134 status = salt.minionsReachable(saltMaster, 'I@salt:master', current_target_node, null, 10, num_retries)
135 if (status == null) {
Oleksii Zhurbab2eb1f92018-01-18 12:53:13 -0600136 throw new Exception("Node ${current_target_node} cannot start")
Jakub Josefa63f9862018-01-11 17:58:38 +0100137 }
Oleksii Zhurba1c55a012018-04-30 16:18:59 -0500138 current_target_node = null
Oleksii Zhurbab2eb1f92018-01-18 12:53:13 -0600139 sleep 30
Jakub Josefa63f9862018-01-11 17:58:38 +0100140 }
141 stage('Check after hard shutdown') {
142 tempest_result = validate.runCVPtempest(saltMaster, TEMPEST_TARGET_NODE, TEMPEST_TEST_PATTERN, SKIP_LIST_PATH, remote_artifacts_dir, "docker_tempest_after_hard_shutdown")
143 validate.openstack_cleanup(saltMaster, TEMPEST_TARGET_NODE)
144 if (tempest_result != "finished") {
145 currentBuild.result = "FAILURE"
146 throw new Exception("Tempest tests failed")
147 }
Oleksii Zhurbab2eb1f92018-01-18 12:53:13 -0600148 sleep 5
Jakub Josefa63f9862018-01-11 17:58:38 +0100149 }
150
151 stage('Reboot') {
152 if (MANUAL_CONFIRMATION.toBoolean() == true) {
153 stage('Ask for manual confirmation') {
154 input message: "Are you sure you want to reboot current vip node?"
155 }
156 }
157 current_target_node = validate.get_vip_node(saltMaster, TARGET_NODES)
158 common.warningMsg("Rebooting current vip node ${current_target_node}")
159 validate.shutdown_vm_node(saltMaster, current_target_node, 'reboot')
160 sleep 5
161 }
162 stage('Check during reboot') {
163 tempest_result = validate.runCVPtempest(saltMaster, TEMPEST_TARGET_NODE, TEMPEST_TEST_PATTERN, SKIP_LIST_PATH, remote_artifacts_dir, "docker_tempest_during_reboot")
164 validate.openstack_cleanup(saltMaster, TEMPEST_TARGET_NODE)
165 if (tempest_result != "finished") {
166 currentBuild.result = "FAILURE"
167 throw new Exception("Tempest tests failed")
168 }
Oleksii Zhurbab2eb1f92018-01-18 12:53:13 -0600169 sleep 30
Jakub Josefa63f9862018-01-11 17:58:38 +0100170 }
171 stage('Check after reboot') {
172 common.warningMsg("Checking that node is UP")
173 status = salt.minionsReachable(saltMaster, 'I@salt:master', current_target_node, null, 10, num_retries)
174 if (status == null) {
175 throw new Exception("Node ${current_target_node} cannot start")
176 }
Oleksii Zhurba1c55a012018-04-30 16:18:59 -0500177 current_target_node = null
Jakub Josefa63f9862018-01-11 17:58:38 +0100178 tempest_result = validate.runCVPtempest(saltMaster, TEMPEST_TARGET_NODE, TEMPEST_TEST_PATTERN, SKIP_LIST_PATH, remote_artifacts_dir, "docker_tempest_after")
179 validate.openstack_cleanup(saltMaster, TEMPEST_TARGET_NODE)
180 if (tempest_result != "finished") {
181 currentBuild.result = "FAILURE"
182 throw new Exception("Tempest tests failed")
183 }
184 }
185
186 stage('Collect results') {
187 validate.addFiles(saltMaster, TEMPEST_TARGET_NODE, remote_artifacts_dir, artifacts_dir)
188 archiveArtifacts artifacts: "${artifacts_dir}/*"
189 if (DEBUG_MODE == 'false') {
190 validate.runCleanup(saltMaster, TEMPEST_TARGET_NODE)
191 salt.cmdRun(saltMaster, TEMPEST_TARGET_NODE, "rm -rf ${remote_artifacts_dir}")
192 }
193 }
194 } finally {
Oleksii Zhurba3f438942017-11-13 20:00:06 -0600195 if (DEBUG_MODE == 'false') {
Oleksii Zhurba3f438942017-11-13 20:00:06 -0600196 salt.cmdRun(saltMaster, TEMPEST_TARGET_NODE, "rm -rf ${remote_artifacts_dir}")
Jakub Josefa63f9862018-01-11 17:58:38 +0100197 validate.runCleanup(saltMaster, TEMPEST_TARGET_NODE)
Oleksii Zhurba1c55a012018-04-30 16:18:59 -0500198 if (current_target_node != null) {
Oleksii Zhurbab2eb1f92018-01-18 12:53:13 -0600199 common.warningMsg("Powering on node ${current_target_node}")
200 kvm = validate.locate_node_on_kvm(saltMaster, current_target_node)
201 salt.cmdRun(saltMaster, kvm, "virsh start ${current_target_node}")
202 }
Oleksii Zhurba3f438942017-11-13 20:00:06 -0600203 }
204 }
Oleksii Zhurba3f438942017-11-13 20:00:06 -0600205 }
206}