blob: 781f5b46460db821b0f9c0d02a217e2cd2e02150 [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 = ''
33node() {
34 def num_retries = Integer.parseInt(RETRY_CHECK_STATUS)
35 try {
36 stage('Initialization') {
37 saltMaster = salt.connection(SALT_MASTER_URL, SALT_MASTER_CREDENTIALS)
38 validate.runBasicContainer(saltMaster, TEMPEST_TARGET_NODE, TEST_IMAGE)
39 sh "rm -rf ${artifacts_dir}"
40 salt.cmdRun(saltMaster, TEMPEST_TARGET_NODE, "mkdir -p ${remote_artifacts_dir}")
41 validate.configureContainer(saltMaster, TEMPEST_TARGET_NODE, PROXY, TOOLS_REPO, TEMPEST_REPO)
42 }
43
44 stage('Initial env check') {
45 sh "mkdir -p ${artifacts_dir}"
46 tempest_result = validate.runCVPtempest(saltMaster, TEMPEST_TARGET_NODE, TEMPEST_TEST_PATTERN, SKIP_LIST_PATH, remote_artifacts_dir, "docker_tempest_initial")
47 validate.openstack_cleanup(saltMaster, TEMPEST_TARGET_NODE)
48 if (tempest_result != "finished") {
49 currentBuild.result = "FAILURE"
50 throw new Exception("Tempest tests failed")
51 }
52 }
53
54 stage('Soft Shutdown') {
55 if (MANUAL_CONFIRMATION.toBoolean() == true) {
56 stage('Ask for manual confirmation') {
57 input message: "Are you sure you want to shutdown current vip node?"
58 }
59 }
60 current_target_node = validate.get_vip_node(saltMaster, TARGET_NODES)
61 common.warningMsg("Shutdown current vip node ${current_target_node}")
62 validate.shutdown_vm_node(saltMaster, current_target_node, 'soft_shutdown')
63 }
64 stage('Check during shutdown') {
65 tempest_result = validate.runCVPtempest(saltMaster, TEMPEST_TARGET_NODE, TEMPEST_TEST_PATTERN, SKIP_LIST_PATH, remote_artifacts_dir, "docker_tempest_during_shutdown")
66 validate.openstack_cleanup(saltMaster, TEMPEST_TARGET_NODE)
67 if (tempest_result != "finished") {
68 currentBuild.result = "FAILURE"
69 throw new Exception("Tempest tests failed")
70 }
71 }
72 stage('Power on') {
73 common.infoMsg('Powering on node')
74 kvm = validate.locate_node_on_kvm(saltMaster, current_target_node)
75 salt.cmdRun(saltMaster, kvm, "virsh start ${current_target_node}")
76 common.infoMsg("Checking that node is UP")
77 status = salt.minionsReachable(saltMaster, 'I@salt:master', current_target_node, null, 10, num_retries)
78 if (status == null) {
79 throw new Exception("Node ${current_target_node} cannot start")
80 }
81 }
82 stage('Check after shutdown') {
83 tempest_result = validate.runCVPtempest(saltMaster, TEMPEST_TARGET_NODE, TEMPEST_TEST_PATTERN, SKIP_LIST_PATH, remote_artifacts_dir, "docker_tempest_after_shutdown")
84 validate.openstack_cleanup(saltMaster, TEMPEST_TARGET_NODE)
85 if (tempest_result != "finished") {
86 currentBuild.result = "FAILURE"
87 throw new Exception("Tempest tests failed")
88 }
89 sleep 15
90 }
91
92 stage('Hard Shutdown') {
93 if (MANUAL_CONFIRMATION.toBoolean() == true) {
94 stage('Ask for manual confirmation') {
95 input message: "Are you sure you want to hard shutdown current vip node?"
96 }
97 }
98 salt.cmdRun(saltMaster, current_target_node, "service keepalived stop")
99 current_target_node = validate.get_vip_node(saltMaster, TARGET_NODES)
100 common.warningMsg("Shutdown current vip node ${current_target_node}")
101 validate.shutdown_vm_node(saltMaster, current_target_node, 'hard_shutdown')
102 }
103 stage('Check during hard shutdown') {
104 tempest_result = validate.runCVPtempest(saltMaster, TEMPEST_TARGET_NODE, TEMPEST_TEST_PATTERN, SKIP_LIST_PATH, remote_artifacts_dir, "docker_tempest_during_hard_shutdown")
105 validate.openstack_cleanup(saltMaster, TEMPEST_TARGET_NODE)
106 if (tempest_result != "finished") {
107 currentBuild.result = "FAILURE"
108 throw new Exception("Tempest tests failed")
109 }
110 }
111 stage('Power on') {
112 common.infoMsg('Powering on node')
113 kvm = validate.locate_node_on_kvm(saltMaster, current_target_node)
114 salt.cmdRun(saltMaster, kvm, "virsh start ${current_target_node}")
115 common.infoMsg("Checking that node is UP")
116 status = salt.minionsReachable(saltMaster, 'I@salt:master', current_target_node, null, 10, num_retries)
117 if (status == null) {
118 throw new Exception("Command execution failed")
119 }
120 salt.cmdRun(saltMaster, TARGET_NODES, "service keepalived start")
121 }
122 stage('Check after hard shutdown') {
123 tempest_result = validate.runCVPtempest(saltMaster, TEMPEST_TARGET_NODE, TEMPEST_TEST_PATTERN, SKIP_LIST_PATH, remote_artifacts_dir, "docker_tempest_after_hard_shutdown")
124 validate.openstack_cleanup(saltMaster, TEMPEST_TARGET_NODE)
125 if (tempest_result != "finished") {
126 currentBuild.result = "FAILURE"
127 throw new Exception("Tempest tests failed")
128 }
129 sleep 15
130 }
131
132 stage('Reboot') {
133 if (MANUAL_CONFIRMATION.toBoolean() == true) {
134 stage('Ask for manual confirmation') {
135 input message: "Are you sure you want to reboot current vip node?"
136 }
137 }
138 current_target_node = validate.get_vip_node(saltMaster, TARGET_NODES)
139 common.warningMsg("Rebooting current vip node ${current_target_node}")
140 validate.shutdown_vm_node(saltMaster, current_target_node, 'reboot')
141 sleep 5
142 }
143 stage('Check during reboot') {
144 tempest_result = validate.runCVPtempest(saltMaster, TEMPEST_TARGET_NODE, TEMPEST_TEST_PATTERN, SKIP_LIST_PATH, remote_artifacts_dir, "docker_tempest_during_reboot")
145 validate.openstack_cleanup(saltMaster, TEMPEST_TARGET_NODE)
146 if (tempest_result != "finished") {
147 currentBuild.result = "FAILURE"
148 throw new Exception("Tempest tests failed")
149 }
150 }
151 stage('Check after reboot') {
152 common.warningMsg("Checking that node is UP")
153 status = salt.minionsReachable(saltMaster, 'I@salt:master', current_target_node, null, 10, num_retries)
154 if (status == null) {
155 throw new Exception("Node ${current_target_node} cannot start")
156 }
157 tempest_result = validate.runCVPtempest(saltMaster, TEMPEST_TARGET_NODE, TEMPEST_TEST_PATTERN, SKIP_LIST_PATH, remote_artifacts_dir, "docker_tempest_after")
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 }
163 }
164
165 stage('Collect results') {
Oleksii Zhurba8fa12d12017-12-07 13:45:53 -0600166 validate.addFiles(saltMaster, TEMPEST_TARGET_NODE, remote_artifacts_dir, artifacts_dir)
Oleksii Zhurba3f438942017-11-13 20:00:06 -0600167 archiveArtifacts artifacts: "${artifacts_dir}/*"
168 if (DEBUG_MODE == 'false') {
169 validate.runCleanup(saltMaster, TEMPEST_TARGET_NODE)
170 salt.cmdRun(saltMaster, TEMPEST_TARGET_NODE, "rm -rf ${remote_artifacts_dir}")
171 }
172 }
173 } finally {
174 if (DEBUG_MODE == 'false') {
175 salt.cmdRun(saltMaster, TEMPEST_TARGET_NODE, "rm -rf ${remote_artifacts_dir}")
176 validate.runCleanup(saltMaster, TEMPEST_TARGET_NODE)
177 }
178 }
179}