blob: dbde547100a07ee5bc75e692002921b33983da5e [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 Zhurba1c55a012018-04-30 16:18:59 -050031def current_target_node = null
32def first_node = null
Oleksii Zhurba3f438942017-11-13 20:00:06 -060033def tempest_result = ''
Jakub Josefa63f9862018-01-11 17:58:38 +010034timeout(time: 12, unit: 'HOURS') {
35 node() {
36 def num_retries = Integer.parseInt(RETRY_CHECK_STATUS)
37 try {
38 stage('Initialization') {
Jakub Josefa63f9862018-01-11 17:58:38 +010039 sh "rm -rf ${artifacts_dir}"
Oleksii Zhurba713a5d22018-10-11 14:23:04 +030040 saltMaster = salt.connection(SALT_MASTER_URL, SALT_MASTER_CREDENTIALS)
Oleksii Zhurba07d8a402019-05-14 18:25:20 -050041 os_version=salt.getPillar(saltMaster, 'I@salt:master', '_param:openstack_version')['return'][0].values()[0]
42 if (!os_version) {
43 throw new Exception("Openstack is not found on this env. Exiting")
44 }
Oleksii Zhurba49275882018-03-21 15:41:57 -050045 salt.cmdRun(saltMaster, TEMPEST_TARGET_NODE, "rm -rf ${remote_artifacts_dir}")
Jakub Josefa63f9862018-01-11 17:58:38 +010046 salt.cmdRun(saltMaster, TEMPEST_TARGET_NODE, "mkdir -p ${remote_artifacts_dir}")
Oleksii Zhurba713a5d22018-10-11 14:23:04 +030047 keystone_creds = validate._get_keystone_creds_v3(saltMaster)
48 if (!keystone_creds) {
49 keystone_creds = validate._get_keystone_creds_v2(saltMaster)
50 }
Oleksii Zhurbade663852018-10-23 10:36:36 -050051 validate.runContainer(saltMaster, TEMPEST_TARGET_NODE, TEST_IMAGE, 'cvp', keystone_creds)
Jakub Josefa63f9862018-01-11 17:58:38 +010052 validate.configureContainer(saltMaster, TEMPEST_TARGET_NODE, PROXY, TOOLS_REPO, TEMPEST_REPO)
Oleksii Zhurba3f438942017-11-13 20:00:06 -060053 }
Oleksii Zhurba3f438942017-11-13 20:00:06 -060054
Jakub Josefa63f9862018-01-11 17:58:38 +010055 stage('Initial env check') {
56 sh "mkdir -p ${artifacts_dir}"
57 tempest_result = validate.runCVPtempest(saltMaster, TEMPEST_TARGET_NODE, TEMPEST_TEST_PATTERN, SKIP_LIST_PATH, remote_artifacts_dir, "docker_tempest_initial")
58 validate.openstack_cleanup(saltMaster, TEMPEST_TARGET_NODE)
59 if (tempest_result != "finished") {
60 currentBuild.result = "FAILURE"
61 throw new Exception("Tempest tests failed")
Oleksii Zhurba3f438942017-11-13 20:00:06 -060062 }
63 }
Oleksii Zhurba3f438942017-11-13 20:00:06 -060064
Jakub Josefa63f9862018-01-11 17:58:38 +010065 stage('Soft Shutdown') {
66 if (MANUAL_CONFIRMATION.toBoolean() == true) {
67 stage('Ask for manual confirmation') {
68 input message: "Are you sure you want to shutdown current vip node?"
69 }
70 }
71 current_target_node = validate.get_vip_node(saltMaster, TARGET_NODES)
Oleksii Zhurba1c55a012018-04-30 16:18:59 -050072 if (current_target_node == null) {
73 throw new Exception("Cannot current vip node in ${TARGET_NODES} nodes")
74 }
Jakub Josefa63f9862018-01-11 17:58:38 +010075 common.warningMsg("Shutdown current vip node ${current_target_node}")
76 validate.shutdown_vm_node(saltMaster, current_target_node, 'soft_shutdown')
Oleksii Zhurbab2eb1f92018-01-18 12:53:13 -060077 sleep 15
Jakub Josefa63f9862018-01-11 17:58:38 +010078 }
79 stage('Check during shutdown') {
80 tempest_result = validate.runCVPtempest(saltMaster, TEMPEST_TARGET_NODE, TEMPEST_TEST_PATTERN, SKIP_LIST_PATH, remote_artifacts_dir, "docker_tempest_during_shutdown")
81 validate.openstack_cleanup(saltMaster, TEMPEST_TARGET_NODE)
82 if (tempest_result != "finished") {
83 currentBuild.result = "FAILURE"
84 throw new Exception("Tempest tests failed")
Oleksii Zhurba3f438942017-11-13 20:00:06 -060085 }
86 }
Jakub Josefa63f9862018-01-11 17:58:38 +010087 stage('Power on') {
88 common.infoMsg('Powering on node')
89 kvm = validate.locate_node_on_kvm(saltMaster, current_target_node)
90 salt.cmdRun(saltMaster, kvm, "virsh start ${current_target_node}")
91 common.infoMsg("Checking that node is UP")
92 status = salt.minionsReachable(saltMaster, 'I@salt:master', current_target_node, null, 10, num_retries)
93 if (status == null) {
94 throw new Exception("Node ${current_target_node} cannot start")
Oleksii Zhurba3f438942017-11-13 20:00:06 -060095 }
Oleksii Zhurbab2eb1f92018-01-18 12:53:13 -060096 first_node = current_target_node
Oleksii Zhurba1c55a012018-04-30 16:18:59 -050097 current_target_node = null
Oleksii Zhurbab2eb1f92018-01-18 12:53:13 -060098 sleep 30
Oleksii Zhurba3f438942017-11-13 20:00:06 -060099 }
Jakub Josefa63f9862018-01-11 17:58:38 +0100100 stage('Check after shutdown') {
101 tempest_result = validate.runCVPtempest(saltMaster, TEMPEST_TARGET_NODE, TEMPEST_TEST_PATTERN, SKIP_LIST_PATH, remote_artifacts_dir, "docker_tempest_after_shutdown")
102 validate.openstack_cleanup(saltMaster, TEMPEST_TARGET_NODE)
103 if (tempest_result != "finished") {
104 currentBuild.result = "FAILURE"
105 throw new Exception("Tempest tests failed")
106 }
107 sleep 15
Oleksii Zhurba3f438942017-11-13 20:00:06 -0600108 }
Oleksii Zhurba3f438942017-11-13 20:00:06 -0600109
Jakub Josefa63f9862018-01-11 17:58:38 +0100110 stage('Hard Shutdown') {
111 if (MANUAL_CONFIRMATION.toBoolean() == true) {
112 stage('Ask for manual confirmation') {
113 input message: "Are you sure you want to hard shutdown current vip node?"
114 }
115 }
Oleksii Zhurbab2eb1f92018-01-18 12:53:13 -0600116 salt.cmdRun(saltMaster, first_node, "service keepalived stop")
Jakub Josefa63f9862018-01-11 17:58:38 +0100117 current_target_node = validate.get_vip_node(saltMaster, TARGET_NODES)
118 common.warningMsg("Shutdown current vip node ${current_target_node}")
119 validate.shutdown_vm_node(saltMaster, current_target_node, 'hard_shutdown')
Oleksii Zhurba1c55a012018-04-30 16:18:59 -0500120 //TODO:if previous command fails, keeaplived will not be started on first_node
Oleksii Zhurbab2eb1f92018-01-18 12:53:13 -0600121 sleep 10
122 salt.cmdRun(saltMaster, first_node, "service keepalived start")
Jakub Josefa63f9862018-01-11 17:58:38 +0100123 }
124 stage('Check during hard shutdown') {
125 tempest_result = validate.runCVPtempest(saltMaster, TEMPEST_TARGET_NODE, TEMPEST_TEST_PATTERN, SKIP_LIST_PATH, remote_artifacts_dir, "docker_tempest_during_hard_shutdown")
126 validate.openstack_cleanup(saltMaster, TEMPEST_TARGET_NODE)
127 if (tempest_result != "finished") {
128 currentBuild.result = "FAILURE"
129 throw new Exception("Tempest tests failed")
130 }
131 }
132 stage('Power on') {
133 common.infoMsg('Powering on node')
134 kvm = validate.locate_node_on_kvm(saltMaster, current_target_node)
135 salt.cmdRun(saltMaster, kvm, "virsh start ${current_target_node}")
136 common.infoMsg("Checking that node is UP")
137 status = salt.minionsReachable(saltMaster, 'I@salt:master', current_target_node, null, 10, num_retries)
138 if (status == null) {
Oleksii Zhurbab2eb1f92018-01-18 12:53:13 -0600139 throw new Exception("Node ${current_target_node} cannot start")
Jakub Josefa63f9862018-01-11 17:58:38 +0100140 }
Oleksii Zhurba1c55a012018-04-30 16:18:59 -0500141 current_target_node = null
Oleksii Zhurbab2eb1f92018-01-18 12:53:13 -0600142 sleep 30
Jakub Josefa63f9862018-01-11 17:58:38 +0100143 }
144 stage('Check after hard shutdown') {
145 tempest_result = validate.runCVPtempest(saltMaster, TEMPEST_TARGET_NODE, TEMPEST_TEST_PATTERN, SKIP_LIST_PATH, remote_artifacts_dir, "docker_tempest_after_hard_shutdown")
146 validate.openstack_cleanup(saltMaster, TEMPEST_TARGET_NODE)
147 if (tempest_result != "finished") {
148 currentBuild.result = "FAILURE"
149 throw new Exception("Tempest tests failed")
150 }
Oleksii Zhurbab2eb1f92018-01-18 12:53:13 -0600151 sleep 5
Jakub Josefa63f9862018-01-11 17:58:38 +0100152 }
153
154 stage('Reboot') {
155 if (MANUAL_CONFIRMATION.toBoolean() == true) {
156 stage('Ask for manual confirmation') {
157 input message: "Are you sure you want to reboot current vip node?"
158 }
159 }
160 current_target_node = validate.get_vip_node(saltMaster, TARGET_NODES)
161 common.warningMsg("Rebooting current vip node ${current_target_node}")
162 validate.shutdown_vm_node(saltMaster, current_target_node, 'reboot')
163 sleep 5
164 }
165 stage('Check during reboot') {
166 tempest_result = validate.runCVPtempest(saltMaster, TEMPEST_TARGET_NODE, TEMPEST_TEST_PATTERN, SKIP_LIST_PATH, remote_artifacts_dir, "docker_tempest_during_reboot")
167 validate.openstack_cleanup(saltMaster, TEMPEST_TARGET_NODE)
168 if (tempest_result != "finished") {
169 currentBuild.result = "FAILURE"
170 throw new Exception("Tempest tests failed")
171 }
Oleksii Zhurbab2eb1f92018-01-18 12:53:13 -0600172 sleep 30
Jakub Josefa63f9862018-01-11 17:58:38 +0100173 }
174 stage('Check after reboot') {
175 common.warningMsg("Checking that node is UP")
176 status = salt.minionsReachable(saltMaster, 'I@salt:master', current_target_node, null, 10, num_retries)
177 if (status == null) {
178 throw new Exception("Node ${current_target_node} cannot start")
179 }
Oleksii Zhurba1c55a012018-04-30 16:18:59 -0500180 current_target_node = null
Jakub Josefa63f9862018-01-11 17:58:38 +0100181 tempest_result = validate.runCVPtempest(saltMaster, TEMPEST_TARGET_NODE, TEMPEST_TEST_PATTERN, SKIP_LIST_PATH, remote_artifacts_dir, "docker_tempest_after")
182 validate.openstack_cleanup(saltMaster, TEMPEST_TARGET_NODE)
183 if (tempest_result != "finished") {
184 currentBuild.result = "FAILURE"
185 throw new Exception("Tempest tests failed")
186 }
187 }
188
189 stage('Collect results') {
190 validate.addFiles(saltMaster, TEMPEST_TARGET_NODE, remote_artifacts_dir, artifacts_dir)
191 archiveArtifacts artifacts: "${artifacts_dir}/*"
192 if (DEBUG_MODE == 'false') {
193 validate.runCleanup(saltMaster, TEMPEST_TARGET_NODE)
194 salt.cmdRun(saltMaster, TEMPEST_TARGET_NODE, "rm -rf ${remote_artifacts_dir}")
195 }
196 }
197 } finally {
Oleksii Zhurba3f438942017-11-13 20:00:06 -0600198 if (DEBUG_MODE == 'false') {
Oleksii Zhurba3f438942017-11-13 20:00:06 -0600199 salt.cmdRun(saltMaster, TEMPEST_TARGET_NODE, "rm -rf ${remote_artifacts_dir}")
Jakub Josefa63f9862018-01-11 17:58:38 +0100200 validate.runCleanup(saltMaster, TEMPEST_TARGET_NODE)
Oleksii Zhurba1c55a012018-04-30 16:18:59 -0500201 if (current_target_node != null) {
Oleksii Zhurbab2eb1f92018-01-18 12:53:13 -0600202 common.warningMsg("Powering on node ${current_target_node}")
203 kvm = validate.locate_node_on_kvm(saltMaster, current_target_node)
204 salt.cmdRun(saltMaster, kvm, "virsh start ${current_target_node}")
205 }
Oleksii Zhurba3f438942017-11-13 20:00:06 -0600206 }
207 }
Oleksii Zhurba3f438942017-11-13 20:00:06 -0600208 }
209}