blob: 4952502dbfd688ed656fce2442b01df83aed08d7 [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 = ''
32def tempest_result = ''
Jakub Josefa63f9862018-01-11 17:58:38 +010033timeout(time: 12, unit: 'HOURS') {
34 node() {
35 def num_retries = Integer.parseInt(RETRY_CHECK_STATUS)
36 try {
37 stage('Initialization') {
38 saltMaster = salt.connection(SALT_MASTER_URL, SALT_MASTER_CREDENTIALS)
39 validate.runBasicContainer(saltMaster, TEMPEST_TARGET_NODE, TEST_IMAGE)
40 sh "rm -rf ${artifacts_dir}"
41 salt.cmdRun(saltMaster, TEMPEST_TARGET_NODE, "mkdir -p ${remote_artifacts_dir}")
42 validate.configureContainer(saltMaster, TEMPEST_TARGET_NODE, PROXY, TOOLS_REPO, TEMPEST_REPO)
Oleksii Zhurba3f438942017-11-13 20:00:06 -060043 }
Oleksii Zhurba3f438942017-11-13 20:00:06 -060044
Jakub Josefa63f9862018-01-11 17:58:38 +010045 stage('Initial env check') {
46 sh "mkdir -p ${artifacts_dir}"
47 tempest_result = validate.runCVPtempest(saltMaster, TEMPEST_TARGET_NODE, TEMPEST_TEST_PATTERN, SKIP_LIST_PATH, remote_artifacts_dir, "docker_tempest_initial")
48 validate.openstack_cleanup(saltMaster, TEMPEST_TARGET_NODE)
49 if (tempest_result != "finished") {
50 currentBuild.result = "FAILURE"
51 throw new Exception("Tempest tests failed")
Oleksii Zhurba3f438942017-11-13 20:00:06 -060052 }
53 }
Oleksii Zhurba3f438942017-11-13 20:00:06 -060054
Jakub Josefa63f9862018-01-11 17:58:38 +010055 stage('Soft Shutdown') {
56 if (MANUAL_CONFIRMATION.toBoolean() == true) {
57 stage('Ask for manual confirmation') {
58 input message: "Are you sure you want to shutdown current vip node?"
59 }
60 }
61 current_target_node = validate.get_vip_node(saltMaster, TARGET_NODES)
62 common.warningMsg("Shutdown current vip node ${current_target_node}")
63 validate.shutdown_vm_node(saltMaster, current_target_node, 'soft_shutdown')
64 }
65 stage('Check during shutdown') {
66 tempest_result = validate.runCVPtempest(saltMaster, TEMPEST_TARGET_NODE, TEMPEST_TEST_PATTERN, SKIP_LIST_PATH, remote_artifacts_dir, "docker_tempest_during_shutdown")
67 validate.openstack_cleanup(saltMaster, TEMPEST_TARGET_NODE)
68 if (tempest_result != "finished") {
69 currentBuild.result = "FAILURE"
70 throw new Exception("Tempest tests failed")
Oleksii Zhurba3f438942017-11-13 20:00:06 -060071 }
72 }
Jakub Josefa63f9862018-01-11 17:58:38 +010073 stage('Power on') {
74 common.infoMsg('Powering on node')
75 kvm = validate.locate_node_on_kvm(saltMaster, current_target_node)
76 salt.cmdRun(saltMaster, kvm, "virsh start ${current_target_node}")
77 common.infoMsg("Checking that node is UP")
78 status = salt.minionsReachable(saltMaster, 'I@salt:master', current_target_node, null, 10, num_retries)
79 if (status == null) {
80 throw new Exception("Node ${current_target_node} cannot start")
Oleksii Zhurba3f438942017-11-13 20:00:06 -060081 }
82 }
Jakub Josefa63f9862018-01-11 17:58:38 +010083 stage('Check after shutdown') {
84 tempest_result = validate.runCVPtempest(saltMaster, TEMPEST_TARGET_NODE, TEMPEST_TEST_PATTERN, SKIP_LIST_PATH, remote_artifacts_dir, "docker_tempest_after_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")
89 }
90 sleep 15
Oleksii Zhurba3f438942017-11-13 20:00:06 -060091 }
Oleksii Zhurba3f438942017-11-13 20:00:06 -060092
Jakub Josefa63f9862018-01-11 17:58:38 +010093 stage('Hard Shutdown') {
94 if (MANUAL_CONFIRMATION.toBoolean() == true) {
95 stage('Ask for manual confirmation') {
96 input message: "Are you sure you want to hard shutdown current vip node?"
97 }
98 }
99 salt.cmdRun(saltMaster, current_target_node, "service keepalived stop")
100 current_target_node = validate.get_vip_node(saltMaster, TARGET_NODES)
101 common.warningMsg("Shutdown current vip node ${current_target_node}")
102 validate.shutdown_vm_node(saltMaster, current_target_node, 'hard_shutdown')
103 }
104 stage('Check during hard shutdown') {
105 tempest_result = validate.runCVPtempest(saltMaster, TEMPEST_TARGET_NODE, TEMPEST_TEST_PATTERN, SKIP_LIST_PATH, remote_artifacts_dir, "docker_tempest_during_hard_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 }
112 stage('Power on') {
113 common.infoMsg('Powering on node')
114 kvm = validate.locate_node_on_kvm(saltMaster, current_target_node)
115 salt.cmdRun(saltMaster, kvm, "virsh start ${current_target_node}")
116 common.infoMsg("Checking that node is UP")
117 status = salt.minionsReachable(saltMaster, 'I@salt:master', current_target_node, null, 10, num_retries)
118 if (status == null) {
119 throw new Exception("Command execution failed")
120 }
121 salt.cmdRun(saltMaster, TARGET_NODES, "service keepalived start")
122 }
123 stage('Check after hard shutdown') {
124 tempest_result = validate.runCVPtempest(saltMaster, TEMPEST_TARGET_NODE, TEMPEST_TEST_PATTERN, SKIP_LIST_PATH, remote_artifacts_dir, "docker_tempest_after_hard_shutdown")
125 validate.openstack_cleanup(saltMaster, TEMPEST_TARGET_NODE)
126 if (tempest_result != "finished") {
127 currentBuild.result = "FAILURE"
128 throw new Exception("Tempest tests failed")
129 }
130 sleep 15
131 }
132
133 stage('Reboot') {
134 if (MANUAL_CONFIRMATION.toBoolean() == true) {
135 stage('Ask for manual confirmation') {
136 input message: "Are you sure you want to reboot current vip node?"
137 }
138 }
139 current_target_node = validate.get_vip_node(saltMaster, TARGET_NODES)
140 common.warningMsg("Rebooting current vip node ${current_target_node}")
141 validate.shutdown_vm_node(saltMaster, current_target_node, 'reboot')
142 sleep 5
143 }
144 stage('Check during reboot') {
145 tempest_result = validate.runCVPtempest(saltMaster, TEMPEST_TARGET_NODE, TEMPEST_TEST_PATTERN, SKIP_LIST_PATH, remote_artifacts_dir, "docker_tempest_during_reboot")
146 validate.openstack_cleanup(saltMaster, TEMPEST_TARGET_NODE)
147 if (tempest_result != "finished") {
148 currentBuild.result = "FAILURE"
149 throw new Exception("Tempest tests failed")
150 }
151 }
152 stage('Check after reboot') {
153 common.warningMsg("Checking that node is UP")
154 status = salt.minionsReachable(saltMaster, 'I@salt:master', current_target_node, null, 10, num_retries)
155 if (status == null) {
156 throw new Exception("Node ${current_target_node} cannot start")
157 }
158 tempest_result = validate.runCVPtempest(saltMaster, TEMPEST_TARGET_NODE, TEMPEST_TEST_PATTERN, SKIP_LIST_PATH, remote_artifacts_dir, "docker_tempest_after")
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 }
164 }
165
166 stage('Collect results') {
167 validate.addFiles(saltMaster, TEMPEST_TARGET_NODE, remote_artifacts_dir, artifacts_dir)
168 archiveArtifacts artifacts: "${artifacts_dir}/*"
169 if (DEBUG_MODE == 'false') {
170 validate.runCleanup(saltMaster, TEMPEST_TARGET_NODE)
171 salt.cmdRun(saltMaster, TEMPEST_TARGET_NODE, "rm -rf ${remote_artifacts_dir}")
172 }
173 }
174 } finally {
Oleksii Zhurba3f438942017-11-13 20:00:06 -0600175 if (DEBUG_MODE == 'false') {
Oleksii Zhurba3f438942017-11-13 20:00:06 -0600176 salt.cmdRun(saltMaster, TEMPEST_TARGET_NODE, "rm -rf ${remote_artifacts_dir}")
Jakub Josefa63f9862018-01-11 17:58:38 +0100177 validate.runCleanup(saltMaster, TEMPEST_TARGET_NODE)
Oleksii Zhurba3f438942017-11-13 20:00:06 -0600178 }
179 }
Oleksii Zhurba3f438942017-11-13 20:00:06 -0600180 }
181}