blob: e933984426a1403f5cd6ac44edcf39859e9d0618 [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 Zhurba22581002019-03-08 16:54:00 -060040 if (!TEMPEST_TARGET_NODE) {
41 // This pillar will return us cid01
42 TEMPEST_TARGET_NODE = "I@gerrit:client"
43 }
Oleksii Zhurba713a5d22018-10-11 14:23:04 +030044 saltMaster = salt.connection(SALT_MASTER_URL, SALT_MASTER_CREDENTIALS)
Oleksii Zhurba07d8a402019-05-14 18:25:20 -050045 os_version=salt.getPillar(saltMaster, 'I@salt:master', '_param:openstack_version')['return'][0].values()[0]
46 if (!os_version) {
47 throw new Exception("Openstack is not found on this env. Exiting")
48 }
Oleksii Zhurba49275882018-03-21 15:41:57 -050049 salt.cmdRun(saltMaster, TEMPEST_TARGET_NODE, "rm -rf ${remote_artifacts_dir}")
Jakub Josefa63f9862018-01-11 17:58:38 +010050 salt.cmdRun(saltMaster, TEMPEST_TARGET_NODE, "mkdir -p ${remote_artifacts_dir}")
Oleksii Zhurba713a5d22018-10-11 14:23:04 +030051 keystone_creds = validate._get_keystone_creds_v3(saltMaster)
52 if (!keystone_creds) {
53 keystone_creds = validate._get_keystone_creds_v2(saltMaster)
54 }
Oleksii Zhurbade663852018-10-23 10:36:36 -050055 validate.runContainer(saltMaster, TEMPEST_TARGET_NODE, TEST_IMAGE, 'cvp', keystone_creds)
Jakub Josefa63f9862018-01-11 17:58:38 +010056 validate.configureContainer(saltMaster, TEMPEST_TARGET_NODE, PROXY, TOOLS_REPO, TEMPEST_REPO)
Oleksii Zhurba3f438942017-11-13 20:00:06 -060057 }
Oleksii Zhurba3f438942017-11-13 20:00:06 -060058
Jakub Josefa63f9862018-01-11 17:58:38 +010059 stage('Initial env check') {
60 sh "mkdir -p ${artifacts_dir}"
61 tempest_result = validate.runCVPtempest(saltMaster, TEMPEST_TARGET_NODE, TEMPEST_TEST_PATTERN, SKIP_LIST_PATH, remote_artifacts_dir, "docker_tempest_initial")
62 validate.openstack_cleanup(saltMaster, TEMPEST_TARGET_NODE)
63 if (tempest_result != "finished") {
64 currentBuild.result = "FAILURE"
65 throw new Exception("Tempest tests failed")
Oleksii Zhurba3f438942017-11-13 20:00:06 -060066 }
67 }
Oleksii Zhurba3f438942017-11-13 20:00:06 -060068
Jakub Josefa63f9862018-01-11 17:58:38 +010069 stage('Soft Shutdown') {
70 if (MANUAL_CONFIRMATION.toBoolean() == true) {
71 stage('Ask for manual confirmation') {
72 input message: "Are you sure you want to shutdown current vip node?"
73 }
74 }
75 current_target_node = validate.get_vip_node(saltMaster, TARGET_NODES)
Oleksii Zhurba1c55a012018-04-30 16:18:59 -050076 if (current_target_node == null) {
77 throw new Exception("Cannot current vip node in ${TARGET_NODES} nodes")
78 }
Jakub Josefa63f9862018-01-11 17:58:38 +010079 common.warningMsg("Shutdown current vip node ${current_target_node}")
80 validate.shutdown_vm_node(saltMaster, current_target_node, 'soft_shutdown')
Oleksii Zhurbab2eb1f92018-01-18 12:53:13 -060081 sleep 15
Jakub Josefa63f9862018-01-11 17:58:38 +010082 }
83 stage('Check during shutdown') {
84 tempest_result = validate.runCVPtempest(saltMaster, TEMPEST_TARGET_NODE, TEMPEST_TEST_PATTERN, SKIP_LIST_PATH, remote_artifacts_dir, "docker_tempest_during_shutdown")
85 validate.openstack_cleanup(saltMaster, TEMPEST_TARGET_NODE)
86 if (tempest_result != "finished") {
87 currentBuild.result = "FAILURE"
88 throw new Exception("Tempest tests failed")
Oleksii Zhurba3f438942017-11-13 20:00:06 -060089 }
90 }
Jakub Josefa63f9862018-01-11 17:58:38 +010091 stage('Power on') {
92 common.infoMsg('Powering on node')
93 kvm = validate.locate_node_on_kvm(saltMaster, current_target_node)
94 salt.cmdRun(saltMaster, kvm, "virsh start ${current_target_node}")
95 common.infoMsg("Checking that node is UP")
96 status = salt.minionsReachable(saltMaster, 'I@salt:master', current_target_node, null, 10, num_retries)
97 if (status == null) {
98 throw new Exception("Node ${current_target_node} cannot start")
Oleksii Zhurba3f438942017-11-13 20:00:06 -060099 }
Oleksii Zhurbab2eb1f92018-01-18 12:53:13 -0600100 first_node = current_target_node
Oleksii Zhurba1c55a012018-04-30 16:18:59 -0500101 current_target_node = null
Oleksii Zhurbab2eb1f92018-01-18 12:53:13 -0600102 sleep 30
Oleksii Zhurba3f438942017-11-13 20:00:06 -0600103 }
Jakub Josefa63f9862018-01-11 17:58:38 +0100104 stage('Check after shutdown') {
105 tempest_result = validate.runCVPtempest(saltMaster, TEMPEST_TARGET_NODE, TEMPEST_TEST_PATTERN, SKIP_LIST_PATH, remote_artifacts_dir, "docker_tempest_after_shutdown")
106 validate.openstack_cleanup(saltMaster, TEMPEST_TARGET_NODE)
107 if (tempest_result != "finished") {
108 currentBuild.result = "FAILURE"
109 throw new Exception("Tempest tests failed")
110 }
111 sleep 15
Oleksii Zhurba3f438942017-11-13 20:00:06 -0600112 }
Oleksii Zhurba3f438942017-11-13 20:00:06 -0600113
Jakub Josefa63f9862018-01-11 17:58:38 +0100114 stage('Hard Shutdown') {
115 if (MANUAL_CONFIRMATION.toBoolean() == true) {
116 stage('Ask for manual confirmation') {
117 input message: "Are you sure you want to hard shutdown current vip node?"
118 }
119 }
Oleksii Zhurbab2eb1f92018-01-18 12:53:13 -0600120 salt.cmdRun(saltMaster, first_node, "service keepalived stop")
Jakub Josefa63f9862018-01-11 17:58:38 +0100121 current_target_node = validate.get_vip_node(saltMaster, TARGET_NODES)
122 common.warningMsg("Shutdown current vip node ${current_target_node}")
123 validate.shutdown_vm_node(saltMaster, current_target_node, 'hard_shutdown')
Oleksii Zhurba1c55a012018-04-30 16:18:59 -0500124 //TODO:if previous command fails, keeaplived will not be started on first_node
Oleksii Zhurbab2eb1f92018-01-18 12:53:13 -0600125 sleep 10
126 salt.cmdRun(saltMaster, first_node, "service keepalived start")
Jakub Josefa63f9862018-01-11 17:58:38 +0100127 }
128 stage('Check during hard shutdown') {
129 tempest_result = validate.runCVPtempest(saltMaster, TEMPEST_TARGET_NODE, TEMPEST_TEST_PATTERN, SKIP_LIST_PATH, remote_artifacts_dir, "docker_tempest_during_hard_shutdown")
130 validate.openstack_cleanup(saltMaster, TEMPEST_TARGET_NODE)
131 if (tempest_result != "finished") {
132 currentBuild.result = "FAILURE"
133 throw new Exception("Tempest tests failed")
134 }
135 }
136 stage('Power on') {
137 common.infoMsg('Powering on node')
138 kvm = validate.locate_node_on_kvm(saltMaster, current_target_node)
139 salt.cmdRun(saltMaster, kvm, "virsh start ${current_target_node}")
140 common.infoMsg("Checking that node is UP")
141 status = salt.minionsReachable(saltMaster, 'I@salt:master', current_target_node, null, 10, num_retries)
142 if (status == null) {
Oleksii Zhurbab2eb1f92018-01-18 12:53:13 -0600143 throw new Exception("Node ${current_target_node} cannot start")
Jakub Josefa63f9862018-01-11 17:58:38 +0100144 }
Oleksii Zhurba1c55a012018-04-30 16:18:59 -0500145 current_target_node = null
Oleksii Zhurbab2eb1f92018-01-18 12:53:13 -0600146 sleep 30
Jakub Josefa63f9862018-01-11 17:58:38 +0100147 }
148 stage('Check after hard shutdown') {
149 tempest_result = validate.runCVPtempest(saltMaster, TEMPEST_TARGET_NODE, TEMPEST_TEST_PATTERN, SKIP_LIST_PATH, remote_artifacts_dir, "docker_tempest_after_hard_shutdown")
150 validate.openstack_cleanup(saltMaster, TEMPEST_TARGET_NODE)
151 if (tempest_result != "finished") {
152 currentBuild.result = "FAILURE"
153 throw new Exception("Tempest tests failed")
154 }
Oleksii Zhurbab2eb1f92018-01-18 12:53:13 -0600155 sleep 5
Jakub Josefa63f9862018-01-11 17:58:38 +0100156 }
157
158 stage('Reboot') {
159 if (MANUAL_CONFIRMATION.toBoolean() == true) {
160 stage('Ask for manual confirmation') {
161 input message: "Are you sure you want to reboot current vip node?"
162 }
163 }
164 current_target_node = validate.get_vip_node(saltMaster, TARGET_NODES)
165 common.warningMsg("Rebooting current vip node ${current_target_node}")
166 validate.shutdown_vm_node(saltMaster, current_target_node, 'reboot')
167 sleep 5
168 }
169 stage('Check during reboot') {
170 tempest_result = validate.runCVPtempest(saltMaster, TEMPEST_TARGET_NODE, TEMPEST_TEST_PATTERN, SKIP_LIST_PATH, remote_artifacts_dir, "docker_tempest_during_reboot")
171 validate.openstack_cleanup(saltMaster, TEMPEST_TARGET_NODE)
172 if (tempest_result != "finished") {
173 currentBuild.result = "FAILURE"
174 throw new Exception("Tempest tests failed")
175 }
Oleksii Zhurbab2eb1f92018-01-18 12:53:13 -0600176 sleep 30
Jakub Josefa63f9862018-01-11 17:58:38 +0100177 }
178 stage('Check after reboot') {
179 common.warningMsg("Checking that node is UP")
180 status = salt.minionsReachable(saltMaster, 'I@salt:master', current_target_node, null, 10, num_retries)
181 if (status == null) {
182 throw new Exception("Node ${current_target_node} cannot start")
183 }
Oleksii Zhurba1c55a012018-04-30 16:18:59 -0500184 current_target_node = null
Jakub Josefa63f9862018-01-11 17:58:38 +0100185 tempest_result = validate.runCVPtempest(saltMaster, TEMPEST_TARGET_NODE, TEMPEST_TEST_PATTERN, SKIP_LIST_PATH, remote_artifacts_dir, "docker_tempest_after")
186 validate.openstack_cleanup(saltMaster, TEMPEST_TARGET_NODE)
187 if (tempest_result != "finished") {
188 currentBuild.result = "FAILURE"
189 throw new Exception("Tempest tests failed")
190 }
191 }
192
193 stage('Collect results') {
194 validate.addFiles(saltMaster, TEMPEST_TARGET_NODE, remote_artifacts_dir, artifacts_dir)
195 archiveArtifacts artifacts: "${artifacts_dir}/*"
196 if (DEBUG_MODE == 'false') {
197 validate.runCleanup(saltMaster, TEMPEST_TARGET_NODE)
198 salt.cmdRun(saltMaster, TEMPEST_TARGET_NODE, "rm -rf ${remote_artifacts_dir}")
199 }
200 }
201 } finally {
Oleksii Zhurba3f438942017-11-13 20:00:06 -0600202 if (DEBUG_MODE == 'false') {
Oleksii Zhurba3f438942017-11-13 20:00:06 -0600203 salt.cmdRun(saltMaster, TEMPEST_TARGET_NODE, "rm -rf ${remote_artifacts_dir}")
Jakub Josefa63f9862018-01-11 17:58:38 +0100204 validate.runCleanup(saltMaster, TEMPEST_TARGET_NODE)
Oleksii Zhurba1c55a012018-04-30 16:18:59 -0500205 if (current_target_node != null) {
Oleksii Zhurbab2eb1f92018-01-18 12:53:13 -0600206 common.warningMsg("Powering on node ${current_target_node}")
207 kvm = validate.locate_node_on_kvm(saltMaster, current_target_node)
208 salt.cmdRun(saltMaster, kvm, "virsh start ${current_target_node}")
209 }
Oleksii Zhurba3f438942017-11-13 20:00:06 -0600210 }
211 }
Oleksii Zhurba3f438942017-11-13 20:00:06 -0600212 }
213}