blob: 4bb50188db535c96e29a3b3e803be9c6f94dda2f [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/'
31def current_target_node = ''
Oleksii Zhurbab2eb1f92018-01-18 12:53:13 -060032def first_node = ''
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}"
42 salt.cmdRun(saltMaster, TEMPEST_TARGET_NODE, "mkdir -p ${remote_artifacts_dir}")
43 validate.configureContainer(saltMaster, TEMPEST_TARGET_NODE, PROXY, TOOLS_REPO, TEMPEST_REPO)
Oleksii Zhurba3f438942017-11-13 20:00:06 -060044 }
Oleksii Zhurba3f438942017-11-13 20:00:06 -060045
Jakub Josefa63f9862018-01-11 17:58:38 +010046 stage('Initial env check') {
47 sh "mkdir -p ${artifacts_dir}"
48 tempest_result = validate.runCVPtempest(saltMaster, TEMPEST_TARGET_NODE, TEMPEST_TEST_PATTERN, SKIP_LIST_PATH, remote_artifacts_dir, "docker_tempest_initial")
49 validate.openstack_cleanup(saltMaster, TEMPEST_TARGET_NODE)
50 if (tempest_result != "finished") {
51 currentBuild.result = "FAILURE"
52 throw new Exception("Tempest tests failed")
Oleksii Zhurba3f438942017-11-13 20:00:06 -060053 }
54 }
Oleksii Zhurba3f438942017-11-13 20:00:06 -060055
Jakub Josefa63f9862018-01-11 17:58:38 +010056 stage('Soft Shutdown') {
57 if (MANUAL_CONFIRMATION.toBoolean() == true) {
58 stage('Ask for manual confirmation') {
59 input message: "Are you sure you want to shutdown current vip node?"
60 }
61 }
62 current_target_node = validate.get_vip_node(saltMaster, TARGET_NODES)
63 common.warningMsg("Shutdown current vip node ${current_target_node}")
64 validate.shutdown_vm_node(saltMaster, current_target_node, 'soft_shutdown')
Oleksii Zhurbab2eb1f92018-01-18 12:53:13 -060065 sleep 15
Jakub Josefa63f9862018-01-11 17:58:38 +010066 }
67 stage('Check during shutdown') {
68 tempest_result = validate.runCVPtempest(saltMaster, TEMPEST_TARGET_NODE, TEMPEST_TEST_PATTERN, SKIP_LIST_PATH, remote_artifacts_dir, "docker_tempest_during_shutdown")
69 validate.openstack_cleanup(saltMaster, TEMPEST_TARGET_NODE)
70 if (tempest_result != "finished") {
71 currentBuild.result = "FAILURE"
72 throw new Exception("Tempest tests failed")
Oleksii Zhurba3f438942017-11-13 20:00:06 -060073 }
74 }
Jakub Josefa63f9862018-01-11 17:58:38 +010075 stage('Power on') {
76 common.infoMsg('Powering on node')
77 kvm = validate.locate_node_on_kvm(saltMaster, current_target_node)
78 salt.cmdRun(saltMaster, kvm, "virsh start ${current_target_node}")
79 common.infoMsg("Checking that node is UP")
80 status = salt.minionsReachable(saltMaster, 'I@salt:master', current_target_node, null, 10, num_retries)
81 if (status == null) {
82 throw new Exception("Node ${current_target_node} cannot start")
Oleksii Zhurba3f438942017-11-13 20:00:06 -060083 }
Oleksii Zhurbab2eb1f92018-01-18 12:53:13 -060084 first_node = current_target_node
85 current_target_node = ''
86 sleep 30
Oleksii Zhurba3f438942017-11-13 20:00:06 -060087 }
Jakub Josefa63f9862018-01-11 17:58:38 +010088 stage('Check after shutdown') {
89 tempest_result = validate.runCVPtempest(saltMaster, TEMPEST_TARGET_NODE, TEMPEST_TEST_PATTERN, SKIP_LIST_PATH, remote_artifacts_dir, "docker_tempest_after_shutdown")
90 validate.openstack_cleanup(saltMaster, TEMPEST_TARGET_NODE)
91 if (tempest_result != "finished") {
92 currentBuild.result = "FAILURE"
93 throw new Exception("Tempest tests failed")
94 }
95 sleep 15
Oleksii Zhurba3f438942017-11-13 20:00:06 -060096 }
Oleksii Zhurba3f438942017-11-13 20:00:06 -060097
Jakub Josefa63f9862018-01-11 17:58:38 +010098 stage('Hard Shutdown') {
99 if (MANUAL_CONFIRMATION.toBoolean() == true) {
100 stage('Ask for manual confirmation') {
101 input message: "Are you sure you want to hard shutdown current vip node?"
102 }
103 }
Oleksii Zhurbab2eb1f92018-01-18 12:53:13 -0600104 salt.cmdRun(saltMaster, first_node, "service keepalived stop")
Jakub Josefa63f9862018-01-11 17:58:38 +0100105 current_target_node = validate.get_vip_node(saltMaster, TARGET_NODES)
106 common.warningMsg("Shutdown current vip node ${current_target_node}")
107 validate.shutdown_vm_node(saltMaster, current_target_node, 'hard_shutdown')
Oleksii Zhurbab2eb1f92018-01-18 12:53:13 -0600108 sleep 10
109 salt.cmdRun(saltMaster, first_node, "service keepalived start")
Jakub Josefa63f9862018-01-11 17:58:38 +0100110 }
111 stage('Check during hard shutdown') {
112 tempest_result = validate.runCVPtempest(saltMaster, TEMPEST_TARGET_NODE, TEMPEST_TEST_PATTERN, SKIP_LIST_PATH, remote_artifacts_dir, "docker_tempest_during_hard_shutdown")
113 validate.openstack_cleanup(saltMaster, TEMPEST_TARGET_NODE)
114 if (tempest_result != "finished") {
115 currentBuild.result = "FAILURE"
116 throw new Exception("Tempest tests failed")
117 }
118 }
119 stage('Power on') {
120 common.infoMsg('Powering on node')
121 kvm = validate.locate_node_on_kvm(saltMaster, current_target_node)
122 salt.cmdRun(saltMaster, kvm, "virsh start ${current_target_node}")
123 common.infoMsg("Checking that node is UP")
124 status = salt.minionsReachable(saltMaster, 'I@salt:master', current_target_node, null, 10, num_retries)
125 if (status == null) {
Oleksii Zhurbab2eb1f92018-01-18 12:53:13 -0600126 throw new Exception("Node ${current_target_node} cannot start")
Jakub Josefa63f9862018-01-11 17:58:38 +0100127 }
Oleksii Zhurbab2eb1f92018-01-18 12:53:13 -0600128 current_target_node = ''
129 sleep 30
Jakub Josefa63f9862018-01-11 17:58:38 +0100130 }
131 stage('Check after hard shutdown') {
132 tempest_result = validate.runCVPtempest(saltMaster, TEMPEST_TARGET_NODE, TEMPEST_TEST_PATTERN, SKIP_LIST_PATH, remote_artifacts_dir, "docker_tempest_after_hard_shutdown")
133 validate.openstack_cleanup(saltMaster, TEMPEST_TARGET_NODE)
134 if (tempest_result != "finished") {
135 currentBuild.result = "FAILURE"
136 throw new Exception("Tempest tests failed")
137 }
Oleksii Zhurbab2eb1f92018-01-18 12:53:13 -0600138 sleep 5
Jakub Josefa63f9862018-01-11 17:58:38 +0100139 }
140
141 stage('Reboot') {
142 if (MANUAL_CONFIRMATION.toBoolean() == true) {
143 stage('Ask for manual confirmation') {
144 input message: "Are you sure you want to reboot current vip node?"
145 }
146 }
147 current_target_node = validate.get_vip_node(saltMaster, TARGET_NODES)
148 common.warningMsg("Rebooting current vip node ${current_target_node}")
149 validate.shutdown_vm_node(saltMaster, current_target_node, 'reboot')
150 sleep 5
151 }
152 stage('Check during reboot') {
153 tempest_result = validate.runCVPtempest(saltMaster, TEMPEST_TARGET_NODE, TEMPEST_TEST_PATTERN, SKIP_LIST_PATH, remote_artifacts_dir, "docker_tempest_during_reboot")
154 validate.openstack_cleanup(saltMaster, TEMPEST_TARGET_NODE)
155 if (tempest_result != "finished") {
156 currentBuild.result = "FAILURE"
157 throw new Exception("Tempest tests failed")
158 }
Oleksii Zhurbab2eb1f92018-01-18 12:53:13 -0600159 sleep 30
Jakub Josefa63f9862018-01-11 17:58:38 +0100160 }
161 stage('Check after reboot') {
162 common.warningMsg("Checking that node is UP")
163 status = salt.minionsReachable(saltMaster, 'I@salt:master', current_target_node, null, 10, num_retries)
164 if (status == null) {
165 throw new Exception("Node ${current_target_node} cannot start")
166 }
167 tempest_result = validate.runCVPtempest(saltMaster, TEMPEST_TARGET_NODE, TEMPEST_TEST_PATTERN, SKIP_LIST_PATH, remote_artifacts_dir, "docker_tempest_after")
168 validate.openstack_cleanup(saltMaster, TEMPEST_TARGET_NODE)
169 if (tempest_result != "finished") {
170 currentBuild.result = "FAILURE"
171 throw new Exception("Tempest tests failed")
172 }
173 }
174
175 stage('Collect results') {
176 validate.addFiles(saltMaster, TEMPEST_TARGET_NODE, remote_artifacts_dir, artifacts_dir)
177 archiveArtifacts artifacts: "${artifacts_dir}/*"
178 if (DEBUG_MODE == 'false') {
179 validate.runCleanup(saltMaster, TEMPEST_TARGET_NODE)
180 salt.cmdRun(saltMaster, TEMPEST_TARGET_NODE, "rm -rf ${remote_artifacts_dir}")
181 }
182 }
183 } finally {
Oleksii Zhurba3f438942017-11-13 20:00:06 -0600184 if (DEBUG_MODE == 'false') {
Oleksii Zhurba3f438942017-11-13 20:00:06 -0600185 salt.cmdRun(saltMaster, TEMPEST_TARGET_NODE, "rm -rf ${remote_artifacts_dir}")
Jakub Josefa63f9862018-01-11 17:58:38 +0100186 validate.runCleanup(saltMaster, TEMPEST_TARGET_NODE)
Oleksii Zhurbab2eb1f92018-01-18 12:53:13 -0600187 if (current_target_node != '') {
188 common.warningMsg("Powering on node ${current_target_node}")
189 kvm = validate.locate_node_on_kvm(saltMaster, current_target_node)
190 salt.cmdRun(saltMaster, kvm, "virsh start ${current_target_node}")
191 }
Oleksii Zhurba3f438942017-11-13 20:00:06 -0600192 }
193 }
Oleksii Zhurba3f438942017-11-13 20:00:06 -0600194 }
195}