blob: b33cda6eac680d831129d600a2486c3d54d27a0c [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 Zhurba49275882018-03-21 15:41:57 -050041 salt.cmdRun(saltMaster, TEMPEST_TARGET_NODE, "rm -rf ${remote_artifacts_dir}")
Jakub Josefa63f9862018-01-11 17:58:38 +010042 salt.cmdRun(saltMaster, TEMPEST_TARGET_NODE, "mkdir -p ${remote_artifacts_dir}")
Oleksii Zhurba713a5d22018-10-11 14:23:04 +030043 keystone_creds = validate._get_keystone_creds_v3(saltMaster)
44 if (!keystone_creds) {
45 keystone_creds = validate._get_keystone_creds_v2(saltMaster)
46 }
Oleksii Zhurbade663852018-10-23 10:36:36 -050047 validate.runContainer(saltMaster, TEMPEST_TARGET_NODE, TEST_IMAGE, 'cvp', keystone_creds)
Jakub Josefa63f9862018-01-11 17:58:38 +010048 validate.configureContainer(saltMaster, TEMPEST_TARGET_NODE, PROXY, TOOLS_REPO, TEMPEST_REPO)
Oleksii Zhurba3f438942017-11-13 20:00:06 -060049 }
Oleksii Zhurba3f438942017-11-13 20:00:06 -060050
Jakub Josefa63f9862018-01-11 17:58:38 +010051 stage('Initial env check') {
52 sh "mkdir -p ${artifacts_dir}"
53 tempest_result = validate.runCVPtempest(saltMaster, TEMPEST_TARGET_NODE, TEMPEST_TEST_PATTERN, SKIP_LIST_PATH, remote_artifacts_dir, "docker_tempest_initial")
54 validate.openstack_cleanup(saltMaster, TEMPEST_TARGET_NODE)
55 if (tempest_result != "finished") {
56 currentBuild.result = "FAILURE"
57 throw new Exception("Tempest tests failed")
Oleksii Zhurba3f438942017-11-13 20:00:06 -060058 }
59 }
Oleksii Zhurba3f438942017-11-13 20:00:06 -060060
Jakub Josefa63f9862018-01-11 17:58:38 +010061 stage('Soft Shutdown') {
62 if (MANUAL_CONFIRMATION.toBoolean() == true) {
63 stage('Ask for manual confirmation') {
64 input message: "Are you sure you want to shutdown current vip node?"
65 }
66 }
67 current_target_node = validate.get_vip_node(saltMaster, TARGET_NODES)
Oleksii Zhurba1c55a012018-04-30 16:18:59 -050068 if (current_target_node == null) {
69 throw new Exception("Cannot current vip node in ${TARGET_NODES} nodes")
70 }
Jakub Josefa63f9862018-01-11 17:58:38 +010071 common.warningMsg("Shutdown current vip node ${current_target_node}")
72 validate.shutdown_vm_node(saltMaster, current_target_node, 'soft_shutdown')
Oleksii Zhurbab2eb1f92018-01-18 12:53:13 -060073 sleep 15
Jakub Josefa63f9862018-01-11 17:58:38 +010074 }
75 stage('Check during shutdown') {
76 tempest_result = validate.runCVPtempest(saltMaster, TEMPEST_TARGET_NODE, TEMPEST_TEST_PATTERN, SKIP_LIST_PATH, remote_artifacts_dir, "docker_tempest_during_shutdown")
77 validate.openstack_cleanup(saltMaster, TEMPEST_TARGET_NODE)
78 if (tempest_result != "finished") {
79 currentBuild.result = "FAILURE"
80 throw new Exception("Tempest tests failed")
Oleksii Zhurba3f438942017-11-13 20:00:06 -060081 }
82 }
Jakub Josefa63f9862018-01-11 17:58:38 +010083 stage('Power on') {
84 common.infoMsg('Powering on node')
85 kvm = validate.locate_node_on_kvm(saltMaster, current_target_node)
86 salt.cmdRun(saltMaster, kvm, "virsh start ${current_target_node}")
87 common.infoMsg("Checking that node is UP")
88 status = salt.minionsReachable(saltMaster, 'I@salt:master', current_target_node, null, 10, num_retries)
89 if (status == null) {
90 throw new Exception("Node ${current_target_node} cannot start")
Oleksii Zhurba3f438942017-11-13 20:00:06 -060091 }
Oleksii Zhurbab2eb1f92018-01-18 12:53:13 -060092 first_node = current_target_node
Oleksii Zhurba1c55a012018-04-30 16:18:59 -050093 current_target_node = null
Oleksii Zhurbab2eb1f92018-01-18 12:53:13 -060094 sleep 30
Oleksii Zhurba3f438942017-11-13 20:00:06 -060095 }
Jakub Josefa63f9862018-01-11 17:58:38 +010096 stage('Check after shutdown') {
97 tempest_result = validate.runCVPtempest(saltMaster, TEMPEST_TARGET_NODE, TEMPEST_TEST_PATTERN, SKIP_LIST_PATH, remote_artifacts_dir, "docker_tempest_after_shutdown")
98 validate.openstack_cleanup(saltMaster, TEMPEST_TARGET_NODE)
99 if (tempest_result != "finished") {
100 currentBuild.result = "FAILURE"
101 throw new Exception("Tempest tests failed")
102 }
103 sleep 15
Oleksii Zhurba3f438942017-11-13 20:00:06 -0600104 }
Oleksii Zhurba3f438942017-11-13 20:00:06 -0600105
Jakub Josefa63f9862018-01-11 17:58:38 +0100106 stage('Hard Shutdown') {
107 if (MANUAL_CONFIRMATION.toBoolean() == true) {
108 stage('Ask for manual confirmation') {
109 input message: "Are you sure you want to hard shutdown current vip node?"
110 }
111 }
Oleksii Zhurbab2eb1f92018-01-18 12:53:13 -0600112 salt.cmdRun(saltMaster, first_node, "service keepalived stop")
Jakub Josefa63f9862018-01-11 17:58:38 +0100113 current_target_node = validate.get_vip_node(saltMaster, TARGET_NODES)
114 common.warningMsg("Shutdown current vip node ${current_target_node}")
115 validate.shutdown_vm_node(saltMaster, current_target_node, 'hard_shutdown')
Oleksii Zhurba1c55a012018-04-30 16:18:59 -0500116 //TODO:if previous command fails, keeaplived will not be started on first_node
Oleksii Zhurbab2eb1f92018-01-18 12:53:13 -0600117 sleep 10
118 salt.cmdRun(saltMaster, first_node, "service keepalived start")
Jakub Josefa63f9862018-01-11 17:58:38 +0100119 }
120 stage('Check during hard shutdown') {
121 tempest_result = validate.runCVPtempest(saltMaster, TEMPEST_TARGET_NODE, TEMPEST_TEST_PATTERN, SKIP_LIST_PATH, remote_artifacts_dir, "docker_tempest_during_hard_shutdown")
122 validate.openstack_cleanup(saltMaster, TEMPEST_TARGET_NODE)
123 if (tempest_result != "finished") {
124 currentBuild.result = "FAILURE"
125 throw new Exception("Tempest tests failed")
126 }
127 }
128 stage('Power on') {
129 common.infoMsg('Powering on node')
130 kvm = validate.locate_node_on_kvm(saltMaster, current_target_node)
131 salt.cmdRun(saltMaster, kvm, "virsh start ${current_target_node}")
132 common.infoMsg("Checking that node is UP")
133 status = salt.minionsReachable(saltMaster, 'I@salt:master', current_target_node, null, 10, num_retries)
134 if (status == null) {
Oleksii Zhurbab2eb1f92018-01-18 12:53:13 -0600135 throw new Exception("Node ${current_target_node} cannot start")
Jakub Josefa63f9862018-01-11 17:58:38 +0100136 }
Oleksii Zhurba1c55a012018-04-30 16:18:59 -0500137 current_target_node = null
Oleksii Zhurbab2eb1f92018-01-18 12:53:13 -0600138 sleep 30
Jakub Josefa63f9862018-01-11 17:58:38 +0100139 }
140 stage('Check after hard shutdown') {
141 tempest_result = validate.runCVPtempest(saltMaster, TEMPEST_TARGET_NODE, TEMPEST_TEST_PATTERN, SKIP_LIST_PATH, remote_artifacts_dir, "docker_tempest_after_hard_shutdown")
142 validate.openstack_cleanup(saltMaster, TEMPEST_TARGET_NODE)
143 if (tempest_result != "finished") {
144 currentBuild.result = "FAILURE"
145 throw new Exception("Tempest tests failed")
146 }
Oleksii Zhurbab2eb1f92018-01-18 12:53:13 -0600147 sleep 5
Jakub Josefa63f9862018-01-11 17:58:38 +0100148 }
149
150 stage('Reboot') {
151 if (MANUAL_CONFIRMATION.toBoolean() == true) {
152 stage('Ask for manual confirmation') {
153 input message: "Are you sure you want to reboot current vip node?"
154 }
155 }
156 current_target_node = validate.get_vip_node(saltMaster, TARGET_NODES)
157 common.warningMsg("Rebooting current vip node ${current_target_node}")
158 validate.shutdown_vm_node(saltMaster, current_target_node, 'reboot')
159 sleep 5
160 }
161 stage('Check during reboot') {
162 tempest_result = validate.runCVPtempest(saltMaster, TEMPEST_TARGET_NODE, TEMPEST_TEST_PATTERN, SKIP_LIST_PATH, remote_artifacts_dir, "docker_tempest_during_reboot")
163 validate.openstack_cleanup(saltMaster, TEMPEST_TARGET_NODE)
164 if (tempest_result != "finished") {
165 currentBuild.result = "FAILURE"
166 throw new Exception("Tempest tests failed")
167 }
Oleksii Zhurbab2eb1f92018-01-18 12:53:13 -0600168 sleep 30
Jakub Josefa63f9862018-01-11 17:58:38 +0100169 }
170 stage('Check after reboot') {
171 common.warningMsg("Checking that node is UP")
172 status = salt.minionsReachable(saltMaster, 'I@salt:master', current_target_node, null, 10, num_retries)
173 if (status == null) {
174 throw new Exception("Node ${current_target_node} cannot start")
175 }
Oleksii Zhurba1c55a012018-04-30 16:18:59 -0500176 current_target_node = null
Jakub Josefa63f9862018-01-11 17:58:38 +0100177 tempest_result = validate.runCVPtempest(saltMaster, TEMPEST_TARGET_NODE, TEMPEST_TEST_PATTERN, SKIP_LIST_PATH, remote_artifacts_dir, "docker_tempest_after")
178 validate.openstack_cleanup(saltMaster, TEMPEST_TARGET_NODE)
179 if (tempest_result != "finished") {
180 currentBuild.result = "FAILURE"
181 throw new Exception("Tempest tests failed")
182 }
183 }
184
185 stage('Collect results') {
186 validate.addFiles(saltMaster, TEMPEST_TARGET_NODE, remote_artifacts_dir, artifacts_dir)
187 archiveArtifacts artifacts: "${artifacts_dir}/*"
188 if (DEBUG_MODE == 'false') {
189 validate.runCleanup(saltMaster, TEMPEST_TARGET_NODE)
190 salt.cmdRun(saltMaster, TEMPEST_TARGET_NODE, "rm -rf ${remote_artifacts_dir}")
191 }
192 }
193 } finally {
Oleksii Zhurba3f438942017-11-13 20:00:06 -0600194 if (DEBUG_MODE == 'false') {
Oleksii Zhurba3f438942017-11-13 20:00:06 -0600195 salt.cmdRun(saltMaster, TEMPEST_TARGET_NODE, "rm -rf ${remote_artifacts_dir}")
Jakub Josefa63f9862018-01-11 17:58:38 +0100196 validate.runCleanup(saltMaster, TEMPEST_TARGET_NODE)
Oleksii Zhurba1c55a012018-04-30 16:18:59 -0500197 if (current_target_node != null) {
Oleksii Zhurbab2eb1f92018-01-18 12:53:13 -0600198 common.warningMsg("Powering on node ${current_target_node}")
199 kvm = validate.locate_node_on_kvm(saltMaster, current_target_node)
200 salt.cmdRun(saltMaster, kvm, "virsh start ${current_target_node}")
201 }
Oleksii Zhurba3f438942017-11-13 20:00:06 -0600202 }
203 }
Oleksii Zhurba3f438942017-11-13 20:00:06 -0600204 }
205}