blob: ab5b5d43856f1aab6ffc46eaddf5046132d9cd8d [file] [log] [blame]
Oleksii Zhurba3f438942017-11-13 20:00:06 -06001/**
2 *
Oleksii Zhurba8fa12d12017-12-07 13:45:53 -06003 * Launch HA test for the cloud
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') {
39 saltMaster = salt.connection(SALT_MASTER_URL, SALT_MASTER_CREDENTIALS)
40 validate.runBasicContainer(saltMaster, TEMPEST_TARGET_NODE, TEST_IMAGE)
41 sh "rm -rf ${artifacts_dir}"
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}")
44 validate.configureContainer(saltMaster, TEMPEST_TARGET_NODE, PROXY, TOOLS_REPO, TEMPEST_REPO)
Oleksii Zhurba3f438942017-11-13 20:00:06 -060045 }
Oleksii Zhurba3f438942017-11-13 20:00:06 -060046
Jakub Josefa63f9862018-01-11 17:58:38 +010047 stage('Initial env check') {
48 sh "mkdir -p ${artifacts_dir}"
49 tempest_result = validate.runCVPtempest(saltMaster, TEMPEST_TARGET_NODE, TEMPEST_TEST_PATTERN, SKIP_LIST_PATH, remote_artifacts_dir, "docker_tempest_initial")
50 validate.openstack_cleanup(saltMaster, TEMPEST_TARGET_NODE)
51 if (tempest_result != "finished") {
52 currentBuild.result = "FAILURE"
53 throw new Exception("Tempest tests failed")
Oleksii Zhurba3f438942017-11-13 20:00:06 -060054 }
55 }
Oleksii Zhurba3f438942017-11-13 20:00:06 -060056
Jakub Josefa63f9862018-01-11 17:58:38 +010057 stage('Soft Shutdown') {
58 if (MANUAL_CONFIRMATION.toBoolean() == true) {
59 stage('Ask for manual confirmation') {
60 input message: "Are you sure you want to shutdown current vip node?"
61 }
62 }
63 current_target_node = validate.get_vip_node(saltMaster, TARGET_NODES)
Oleksii Zhurba1c55a012018-04-30 16:18:59 -050064 if (current_target_node == null) {
65 throw new Exception("Cannot current vip node in ${TARGET_NODES} nodes")
66 }
Jakub Josefa63f9862018-01-11 17:58:38 +010067 common.warningMsg("Shutdown current vip node ${current_target_node}")
68 validate.shutdown_vm_node(saltMaster, current_target_node, 'soft_shutdown')
Oleksii Zhurbab2eb1f92018-01-18 12:53:13 -060069 sleep 15
Jakub Josefa63f9862018-01-11 17:58:38 +010070 }
71 stage('Check during shutdown') {
72 tempest_result = validate.runCVPtempest(saltMaster, TEMPEST_TARGET_NODE, TEMPEST_TEST_PATTERN, SKIP_LIST_PATH, remote_artifacts_dir, "docker_tempest_during_shutdown")
73 validate.openstack_cleanup(saltMaster, TEMPEST_TARGET_NODE)
74 if (tempest_result != "finished") {
75 currentBuild.result = "FAILURE"
76 throw new Exception("Tempest tests failed")
Oleksii Zhurba3f438942017-11-13 20:00:06 -060077 }
78 }
Jakub Josefa63f9862018-01-11 17:58:38 +010079 stage('Power on') {
80 common.infoMsg('Powering on node')
81 kvm = validate.locate_node_on_kvm(saltMaster, current_target_node)
82 salt.cmdRun(saltMaster, kvm, "virsh start ${current_target_node}")
83 common.infoMsg("Checking that node is UP")
84 status = salt.minionsReachable(saltMaster, 'I@salt:master', current_target_node, null, 10, num_retries)
85 if (status == null) {
86 throw new Exception("Node ${current_target_node} cannot start")
Oleksii Zhurba3f438942017-11-13 20:00:06 -060087 }
Oleksii Zhurbab2eb1f92018-01-18 12:53:13 -060088 first_node = current_target_node
Oleksii Zhurba1c55a012018-04-30 16:18:59 -050089 current_target_node = null
Oleksii Zhurbab2eb1f92018-01-18 12:53:13 -060090 sleep 30
Oleksii Zhurba3f438942017-11-13 20:00:06 -060091 }
Jakub Josefa63f9862018-01-11 17:58:38 +010092 stage('Check after shutdown') {
93 tempest_result = validate.runCVPtempest(saltMaster, TEMPEST_TARGET_NODE, TEMPEST_TEST_PATTERN, SKIP_LIST_PATH, remote_artifacts_dir, "docker_tempest_after_shutdown")
94 validate.openstack_cleanup(saltMaster, TEMPEST_TARGET_NODE)
95 if (tempest_result != "finished") {
96 currentBuild.result = "FAILURE"
97 throw new Exception("Tempest tests failed")
98 }
99 sleep 15
Oleksii Zhurba3f438942017-11-13 20:00:06 -0600100 }
Oleksii Zhurba3f438942017-11-13 20:00:06 -0600101
Jakub Josefa63f9862018-01-11 17:58:38 +0100102 stage('Hard Shutdown') {
103 if (MANUAL_CONFIRMATION.toBoolean() == true) {
104 stage('Ask for manual confirmation') {
105 input message: "Are you sure you want to hard shutdown current vip node?"
106 }
107 }
Oleksii Zhurbab2eb1f92018-01-18 12:53:13 -0600108 salt.cmdRun(saltMaster, first_node, "service keepalived stop")
Jakub Josefa63f9862018-01-11 17:58:38 +0100109 current_target_node = validate.get_vip_node(saltMaster, TARGET_NODES)
110 common.warningMsg("Shutdown current vip node ${current_target_node}")
111 validate.shutdown_vm_node(saltMaster, current_target_node, 'hard_shutdown')
Oleksii Zhurba1c55a012018-04-30 16:18:59 -0500112 //TODO:if previous command fails, keeaplived will not be started on first_node
Oleksii Zhurbab2eb1f92018-01-18 12:53:13 -0600113 sleep 10
114 salt.cmdRun(saltMaster, first_node, "service keepalived start")
Jakub Josefa63f9862018-01-11 17:58:38 +0100115 }
116 stage('Check during hard shutdown') {
117 tempest_result = validate.runCVPtempest(saltMaster, TEMPEST_TARGET_NODE, TEMPEST_TEST_PATTERN, SKIP_LIST_PATH, remote_artifacts_dir, "docker_tempest_during_hard_shutdown")
118 validate.openstack_cleanup(saltMaster, TEMPEST_TARGET_NODE)
119 if (tempest_result != "finished") {
120 currentBuild.result = "FAILURE"
121 throw new Exception("Tempest tests failed")
122 }
123 }
124 stage('Power on') {
125 common.infoMsg('Powering on node')
126 kvm = validate.locate_node_on_kvm(saltMaster, current_target_node)
127 salt.cmdRun(saltMaster, kvm, "virsh start ${current_target_node}")
128 common.infoMsg("Checking that node is UP")
129 status = salt.minionsReachable(saltMaster, 'I@salt:master', current_target_node, null, 10, num_retries)
130 if (status == null) {
Oleksii Zhurbab2eb1f92018-01-18 12:53:13 -0600131 throw new Exception("Node ${current_target_node} cannot start")
Jakub Josefa63f9862018-01-11 17:58:38 +0100132 }
Oleksii Zhurba1c55a012018-04-30 16:18:59 -0500133 current_target_node = null
Oleksii Zhurbab2eb1f92018-01-18 12:53:13 -0600134 sleep 30
Jakub Josefa63f9862018-01-11 17:58:38 +0100135 }
136 stage('Check after hard shutdown') {
137 tempest_result = validate.runCVPtempest(saltMaster, TEMPEST_TARGET_NODE, TEMPEST_TEST_PATTERN, SKIP_LIST_PATH, remote_artifacts_dir, "docker_tempest_after_hard_shutdown")
138 validate.openstack_cleanup(saltMaster, TEMPEST_TARGET_NODE)
139 if (tempest_result != "finished") {
140 currentBuild.result = "FAILURE"
141 throw new Exception("Tempest tests failed")
142 }
Oleksii Zhurbab2eb1f92018-01-18 12:53:13 -0600143 sleep 5
Jakub Josefa63f9862018-01-11 17:58:38 +0100144 }
145
146 stage('Reboot') {
147 if (MANUAL_CONFIRMATION.toBoolean() == true) {
148 stage('Ask for manual confirmation') {
149 input message: "Are you sure you want to reboot current vip node?"
150 }
151 }
152 current_target_node = validate.get_vip_node(saltMaster, TARGET_NODES)
153 common.warningMsg("Rebooting current vip node ${current_target_node}")
154 validate.shutdown_vm_node(saltMaster, current_target_node, 'reboot')
155 sleep 5
156 }
157 stage('Check during reboot') {
158 tempest_result = validate.runCVPtempest(saltMaster, TEMPEST_TARGET_NODE, TEMPEST_TEST_PATTERN, SKIP_LIST_PATH, remote_artifacts_dir, "docker_tempest_during_reboot")
159 validate.openstack_cleanup(saltMaster, TEMPEST_TARGET_NODE)
160 if (tempest_result != "finished") {
161 currentBuild.result = "FAILURE"
162 throw new Exception("Tempest tests failed")
163 }
Oleksii Zhurbab2eb1f92018-01-18 12:53:13 -0600164 sleep 30
Jakub Josefa63f9862018-01-11 17:58:38 +0100165 }
166 stage('Check after reboot') {
167 common.warningMsg("Checking that node is UP")
168 status = salt.minionsReachable(saltMaster, 'I@salt:master', current_target_node, null, 10, num_retries)
169 if (status == null) {
170 throw new Exception("Node ${current_target_node} cannot start")
171 }
Oleksii Zhurba1c55a012018-04-30 16:18:59 -0500172 current_target_node = null
Jakub Josefa63f9862018-01-11 17:58:38 +0100173 tempest_result = validate.runCVPtempest(saltMaster, TEMPEST_TARGET_NODE, TEMPEST_TEST_PATTERN, SKIP_LIST_PATH, remote_artifacts_dir, "docker_tempest_after")
174 validate.openstack_cleanup(saltMaster, TEMPEST_TARGET_NODE)
175 if (tempest_result != "finished") {
176 currentBuild.result = "FAILURE"
177 throw new Exception("Tempest tests failed")
178 }
179 }
180
181 stage('Collect results') {
182 validate.addFiles(saltMaster, TEMPEST_TARGET_NODE, remote_artifacts_dir, artifacts_dir)
183 archiveArtifacts artifacts: "${artifacts_dir}/*"
184 if (DEBUG_MODE == 'false') {
185 validate.runCleanup(saltMaster, TEMPEST_TARGET_NODE)
186 salt.cmdRun(saltMaster, TEMPEST_TARGET_NODE, "rm -rf ${remote_artifacts_dir}")
187 }
188 }
189 } finally {
Oleksii Zhurba3f438942017-11-13 20:00:06 -0600190 if (DEBUG_MODE == 'false') {
Oleksii Zhurba3f438942017-11-13 20:00:06 -0600191 salt.cmdRun(saltMaster, TEMPEST_TARGET_NODE, "rm -rf ${remote_artifacts_dir}")
Jakub Josefa63f9862018-01-11 17:58:38 +0100192 validate.runCleanup(saltMaster, TEMPEST_TARGET_NODE)
Oleksii Zhurba1c55a012018-04-30 16:18:59 -0500193 if (current_target_node != null) {
Oleksii Zhurbab2eb1f92018-01-18 12:53:13 -0600194 common.warningMsg("Powering on node ${current_target_node}")
195 kvm = validate.locate_node_on_kvm(saltMaster, current_target_node)
196 salt.cmdRun(saltMaster, kvm, "virsh start ${current_target_node}")
197 }
Oleksii Zhurba3f438942017-11-13 20:00:06 -0600198 }
199 }
Oleksii Zhurba3f438942017-11-13 20:00:06 -0600200 }
201}