blob: 99a49d3f5f0787c23346923dda49b0dd77ccfb62 [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}"
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)
Oleksii Zhurba1c55a012018-04-30 16:18:59 -050063 if (current_target_node == null) {
64 throw new Exception("Cannot current vip node in ${TARGET_NODES} nodes")
65 }
Jakub Josefa63f9862018-01-11 17:58:38 +010066 common.warningMsg("Shutdown current vip node ${current_target_node}")
67 validate.shutdown_vm_node(saltMaster, current_target_node, 'soft_shutdown')
Oleksii Zhurbab2eb1f92018-01-18 12:53:13 -060068 sleep 15
Jakub Josefa63f9862018-01-11 17:58:38 +010069 }
70 stage('Check during shutdown') {
71 tempest_result = validate.runCVPtempest(saltMaster, TEMPEST_TARGET_NODE, TEMPEST_TEST_PATTERN, SKIP_LIST_PATH, remote_artifacts_dir, "docker_tempest_during_shutdown")
72 validate.openstack_cleanup(saltMaster, TEMPEST_TARGET_NODE)
73 if (tempest_result != "finished") {
74 currentBuild.result = "FAILURE"
75 throw new Exception("Tempest tests failed")
Oleksii Zhurba3f438942017-11-13 20:00:06 -060076 }
77 }
Jakub Josefa63f9862018-01-11 17:58:38 +010078 stage('Power on') {
79 common.infoMsg('Powering on node')
80 kvm = validate.locate_node_on_kvm(saltMaster, current_target_node)
81 salt.cmdRun(saltMaster, kvm, "virsh start ${current_target_node}")
82 common.infoMsg("Checking that node is UP")
83 status = salt.minionsReachable(saltMaster, 'I@salt:master', current_target_node, null, 10, num_retries)
84 if (status == null) {
85 throw new Exception("Node ${current_target_node} cannot start")
Oleksii Zhurba3f438942017-11-13 20:00:06 -060086 }
Oleksii Zhurbab2eb1f92018-01-18 12:53:13 -060087 first_node = current_target_node
Oleksii Zhurba1c55a012018-04-30 16:18:59 -050088 current_target_node = null
Oleksii Zhurbab2eb1f92018-01-18 12:53:13 -060089 sleep 30
Oleksii Zhurba3f438942017-11-13 20:00:06 -060090 }
Jakub Josefa63f9862018-01-11 17:58:38 +010091 stage('Check after shutdown') {
92 tempest_result = validate.runCVPtempest(saltMaster, TEMPEST_TARGET_NODE, TEMPEST_TEST_PATTERN, SKIP_LIST_PATH, remote_artifacts_dir, "docker_tempest_after_shutdown")
93 validate.openstack_cleanup(saltMaster, TEMPEST_TARGET_NODE)
94 if (tempest_result != "finished") {
95 currentBuild.result = "FAILURE"
96 throw new Exception("Tempest tests failed")
97 }
98 sleep 15
Oleksii Zhurba3f438942017-11-13 20:00:06 -060099 }
Oleksii Zhurba3f438942017-11-13 20:00:06 -0600100
Jakub Josefa63f9862018-01-11 17:58:38 +0100101 stage('Hard Shutdown') {
102 if (MANUAL_CONFIRMATION.toBoolean() == true) {
103 stage('Ask for manual confirmation') {
104 input message: "Are you sure you want to hard shutdown current vip node?"
105 }
106 }
Oleksii Zhurbab2eb1f92018-01-18 12:53:13 -0600107 salt.cmdRun(saltMaster, first_node, "service keepalived stop")
Jakub Josefa63f9862018-01-11 17:58:38 +0100108 current_target_node = validate.get_vip_node(saltMaster, TARGET_NODES)
109 common.warningMsg("Shutdown current vip node ${current_target_node}")
110 validate.shutdown_vm_node(saltMaster, current_target_node, 'hard_shutdown')
Oleksii Zhurba1c55a012018-04-30 16:18:59 -0500111 //TODO:if previous command fails, keeaplived will not be started on first_node
Oleksii Zhurbab2eb1f92018-01-18 12:53:13 -0600112 sleep 10
113 salt.cmdRun(saltMaster, first_node, "service keepalived start")
Jakub Josefa63f9862018-01-11 17:58:38 +0100114 }
115 stage('Check during hard shutdown') {
116 tempest_result = validate.runCVPtempest(saltMaster, TEMPEST_TARGET_NODE, TEMPEST_TEST_PATTERN, SKIP_LIST_PATH, remote_artifacts_dir, "docker_tempest_during_hard_shutdown")
117 validate.openstack_cleanup(saltMaster, TEMPEST_TARGET_NODE)
118 if (tempest_result != "finished") {
119 currentBuild.result = "FAILURE"
120 throw new Exception("Tempest tests failed")
121 }
122 }
123 stage('Power on') {
124 common.infoMsg('Powering on node')
125 kvm = validate.locate_node_on_kvm(saltMaster, current_target_node)
126 salt.cmdRun(saltMaster, kvm, "virsh start ${current_target_node}")
127 common.infoMsg("Checking that node is UP")
128 status = salt.minionsReachable(saltMaster, 'I@salt:master', current_target_node, null, 10, num_retries)
129 if (status == null) {
Oleksii Zhurbab2eb1f92018-01-18 12:53:13 -0600130 throw new Exception("Node ${current_target_node} cannot start")
Jakub Josefa63f9862018-01-11 17:58:38 +0100131 }
Oleksii Zhurba1c55a012018-04-30 16:18:59 -0500132 current_target_node = null
Oleksii Zhurbab2eb1f92018-01-18 12:53:13 -0600133 sleep 30
Jakub Josefa63f9862018-01-11 17:58:38 +0100134 }
135 stage('Check after hard shutdown') {
136 tempest_result = validate.runCVPtempest(saltMaster, TEMPEST_TARGET_NODE, TEMPEST_TEST_PATTERN, SKIP_LIST_PATH, remote_artifacts_dir, "docker_tempest_after_hard_shutdown")
137 validate.openstack_cleanup(saltMaster, TEMPEST_TARGET_NODE)
138 if (tempest_result != "finished") {
139 currentBuild.result = "FAILURE"
140 throw new Exception("Tempest tests failed")
141 }
Oleksii Zhurbab2eb1f92018-01-18 12:53:13 -0600142 sleep 5
Jakub Josefa63f9862018-01-11 17:58:38 +0100143 }
144
145 stage('Reboot') {
146 if (MANUAL_CONFIRMATION.toBoolean() == true) {
147 stage('Ask for manual confirmation') {
148 input message: "Are you sure you want to reboot current vip node?"
149 }
150 }
151 current_target_node = validate.get_vip_node(saltMaster, TARGET_NODES)
152 common.warningMsg("Rebooting current vip node ${current_target_node}")
153 validate.shutdown_vm_node(saltMaster, current_target_node, 'reboot')
154 sleep 5
155 }
156 stage('Check during reboot') {
157 tempest_result = validate.runCVPtempest(saltMaster, TEMPEST_TARGET_NODE, TEMPEST_TEST_PATTERN, SKIP_LIST_PATH, remote_artifacts_dir, "docker_tempest_during_reboot")
158 validate.openstack_cleanup(saltMaster, TEMPEST_TARGET_NODE)
159 if (tempest_result != "finished") {
160 currentBuild.result = "FAILURE"
161 throw new Exception("Tempest tests failed")
162 }
Oleksii Zhurbab2eb1f92018-01-18 12:53:13 -0600163 sleep 30
Jakub Josefa63f9862018-01-11 17:58:38 +0100164 }
165 stage('Check after reboot') {
166 common.warningMsg("Checking that node is UP")
167 status = salt.minionsReachable(saltMaster, 'I@salt:master', current_target_node, null, 10, num_retries)
168 if (status == null) {
169 throw new Exception("Node ${current_target_node} cannot start")
170 }
Oleksii Zhurba1c55a012018-04-30 16:18:59 -0500171 current_target_node = null
Jakub Josefa63f9862018-01-11 17:58:38 +0100172 tempest_result = validate.runCVPtempest(saltMaster, TEMPEST_TARGET_NODE, TEMPEST_TEST_PATTERN, SKIP_LIST_PATH, remote_artifacts_dir, "docker_tempest_after")
173 validate.openstack_cleanup(saltMaster, TEMPEST_TARGET_NODE)
174 if (tempest_result != "finished") {
175 currentBuild.result = "FAILURE"
176 throw new Exception("Tempest tests failed")
177 }
178 }
179
180 stage('Collect results') {
181 validate.addFiles(saltMaster, TEMPEST_TARGET_NODE, remote_artifacts_dir, artifacts_dir)
182 archiveArtifacts artifacts: "${artifacts_dir}/*"
183 if (DEBUG_MODE == 'false') {
184 validate.runCleanup(saltMaster, TEMPEST_TARGET_NODE)
185 salt.cmdRun(saltMaster, TEMPEST_TARGET_NODE, "rm -rf ${remote_artifacts_dir}")
186 }
187 }
188 } finally {
Oleksii Zhurba3f438942017-11-13 20:00:06 -0600189 if (DEBUG_MODE == 'false') {
Oleksii Zhurba3f438942017-11-13 20:00:06 -0600190 salt.cmdRun(saltMaster, TEMPEST_TARGET_NODE, "rm -rf ${remote_artifacts_dir}")
Jakub Josefa63f9862018-01-11 17:58:38 +0100191 validate.runCleanup(saltMaster, TEMPEST_TARGET_NODE)
Oleksii Zhurba1c55a012018-04-30 16:18:59 -0500192 if (current_target_node != null) {
Oleksii Zhurbab2eb1f92018-01-18 12:53:13 -0600193 common.warningMsg("Powering on node ${current_target_node}")
194 kvm = validate.locate_node_on_kvm(saltMaster, current_target_node)
195 salt.cmdRun(saltMaster, kvm, "virsh start ${current_target_node}")
196 }
Oleksii Zhurba3f438942017-11-13 20:00:06 -0600197 }
198 }
Oleksii Zhurba3f438942017-11-13 20:00:06 -0600199 }
200}