Oleksii Zhurba | 3f43894 | 2017-11-13 20:00:06 -0600 | [diff] [blame] | 1 | /** |
| 2 | * |
| 3 | * Launch validation of the cloud |
| 4 | * |
| 5 | * Expected parameters: |
| 6 | * SALT_MASTER_URL URL of Salt master |
| 7 | * SALT_MASTER_CREDENTIALS Credentials to the Salt API |
| 8 | * |
| 9 | * TEST_IMAGE Docker image link |
| 10 | * TARGET_NODE Salt target for tempest node |
| 11 | * TEMPEST_TEST_SET If not false, run tests matched to pattern only |
| 12 | * RUN_TEMPEST_TESTS If not false, run Tempest tests |
| 13 | * RUN_RALLY_TESTS If not false, run Rally tests |
| 14 | * |
| 15 | */ |
| 16 | |
| 17 | common = new com.mirantis.mk.Common() |
| 18 | salt = new com.mirantis.mk.Salt() |
| 19 | validate = new com.mirantis.mcp.Validate() |
| 20 | |
| 21 | def saltMaster |
| 22 | def artifacts_dir = 'validation_artifacts/' |
| 23 | def remote_artifacts_dir = '/root/qa_results/' |
| 24 | def current_target_node = '' |
| 25 | def tempest_result = '' |
| 26 | node() { |
| 27 | def num_retries = Integer.parseInt(RETRY_CHECK_STATUS) |
| 28 | try { |
| 29 | stage('Initialization') { |
| 30 | saltMaster = salt.connection(SALT_MASTER_URL, SALT_MASTER_CREDENTIALS) |
| 31 | validate.runBasicContainer(saltMaster, TEMPEST_TARGET_NODE, TEST_IMAGE) |
| 32 | sh "rm -rf ${artifacts_dir}" |
| 33 | salt.cmdRun(saltMaster, TEMPEST_TARGET_NODE, "mkdir -p ${remote_artifacts_dir}") |
| 34 | validate.configureContainer(saltMaster, TEMPEST_TARGET_NODE, PROXY, TOOLS_REPO, TEMPEST_REPO) |
| 35 | } |
| 36 | |
| 37 | stage('Initial env check') { |
| 38 | sh "mkdir -p ${artifacts_dir}" |
| 39 | tempest_result = validate.runCVPtempest(saltMaster, TEMPEST_TARGET_NODE, TEMPEST_TEST_PATTERN, SKIP_LIST_PATH, remote_artifacts_dir, "docker_tempest_initial") |
| 40 | validate.openstack_cleanup(saltMaster, TEMPEST_TARGET_NODE) |
| 41 | if (tempest_result != "finished") { |
| 42 | currentBuild.result = "FAILURE" |
| 43 | throw new Exception("Tempest tests failed") |
| 44 | } |
| 45 | } |
| 46 | |
| 47 | stage('Soft Shutdown') { |
| 48 | if (MANUAL_CONFIRMATION.toBoolean() == true) { |
| 49 | stage('Ask for manual confirmation') { |
| 50 | input message: "Are you sure you want to shutdown current vip node?" |
| 51 | } |
| 52 | } |
| 53 | current_target_node = validate.get_vip_node(saltMaster, TARGET_NODES) |
| 54 | common.warningMsg("Shutdown current vip node ${current_target_node}") |
| 55 | validate.shutdown_vm_node(saltMaster, current_target_node, 'soft_shutdown') |
| 56 | } |
| 57 | stage('Check during shutdown') { |
| 58 | tempest_result = validate.runCVPtempest(saltMaster, TEMPEST_TARGET_NODE, TEMPEST_TEST_PATTERN, SKIP_LIST_PATH, remote_artifacts_dir, "docker_tempest_during_shutdown") |
| 59 | validate.openstack_cleanup(saltMaster, TEMPEST_TARGET_NODE) |
| 60 | if (tempest_result != "finished") { |
| 61 | currentBuild.result = "FAILURE" |
| 62 | throw new Exception("Tempest tests failed") |
| 63 | } |
| 64 | } |
| 65 | stage('Power on') { |
| 66 | common.infoMsg('Powering on node') |
| 67 | kvm = validate.locate_node_on_kvm(saltMaster, current_target_node) |
| 68 | salt.cmdRun(saltMaster, kvm, "virsh start ${current_target_node}") |
| 69 | common.infoMsg("Checking that node is UP") |
| 70 | status = salt.minionsReachable(saltMaster, 'I@salt:master', current_target_node, null, 10, num_retries) |
| 71 | if (status == null) { |
| 72 | throw new Exception("Node ${current_target_node} cannot start") |
| 73 | } |
| 74 | } |
| 75 | stage('Check after shutdown') { |
| 76 | tempest_result = validate.runCVPtempest(saltMaster, TEMPEST_TARGET_NODE, TEMPEST_TEST_PATTERN, SKIP_LIST_PATH, remote_artifacts_dir, "docker_tempest_after_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") |
| 81 | } |
| 82 | sleep 15 |
| 83 | } |
| 84 | |
| 85 | stage('Hard Shutdown') { |
| 86 | if (MANUAL_CONFIRMATION.toBoolean() == true) { |
| 87 | stage('Ask for manual confirmation') { |
| 88 | input message: "Are you sure you want to hard shutdown current vip node?" |
| 89 | } |
| 90 | } |
| 91 | salt.cmdRun(saltMaster, current_target_node, "service keepalived stop") |
| 92 | current_target_node = validate.get_vip_node(saltMaster, TARGET_NODES) |
| 93 | common.warningMsg("Shutdown current vip node ${current_target_node}") |
| 94 | validate.shutdown_vm_node(saltMaster, current_target_node, 'hard_shutdown') |
| 95 | } |
| 96 | stage('Check during hard shutdown') { |
| 97 | tempest_result = validate.runCVPtempest(saltMaster, TEMPEST_TARGET_NODE, TEMPEST_TEST_PATTERN, SKIP_LIST_PATH, remote_artifacts_dir, "docker_tempest_during_hard_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 | } |
| 104 | stage('Power on') { |
| 105 | common.infoMsg('Powering on node') |
| 106 | kvm = validate.locate_node_on_kvm(saltMaster, current_target_node) |
| 107 | salt.cmdRun(saltMaster, kvm, "virsh start ${current_target_node}") |
| 108 | common.infoMsg("Checking that node is UP") |
| 109 | status = salt.minionsReachable(saltMaster, 'I@salt:master', current_target_node, null, 10, num_retries) |
| 110 | if (status == null) { |
| 111 | throw new Exception("Command execution failed") |
| 112 | } |
| 113 | salt.cmdRun(saltMaster, TARGET_NODES, "service keepalived start") |
| 114 | } |
| 115 | stage('Check after hard shutdown') { |
| 116 | tempest_result = validate.runCVPtempest(saltMaster, TEMPEST_TARGET_NODE, TEMPEST_TEST_PATTERN, SKIP_LIST_PATH, remote_artifacts_dir, "docker_tempest_after_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 | sleep 15 |
| 123 | } |
| 124 | |
| 125 | stage('Reboot') { |
| 126 | if (MANUAL_CONFIRMATION.toBoolean() == true) { |
| 127 | stage('Ask for manual confirmation') { |
| 128 | input message: "Are you sure you want to reboot current vip node?" |
| 129 | } |
| 130 | } |
| 131 | current_target_node = validate.get_vip_node(saltMaster, TARGET_NODES) |
| 132 | common.warningMsg("Rebooting current vip node ${current_target_node}") |
| 133 | validate.shutdown_vm_node(saltMaster, current_target_node, 'reboot') |
| 134 | sleep 5 |
| 135 | } |
| 136 | stage('Check during reboot') { |
| 137 | tempest_result = validate.runCVPtempest(saltMaster, TEMPEST_TARGET_NODE, TEMPEST_TEST_PATTERN, SKIP_LIST_PATH, remote_artifacts_dir, "docker_tempest_during_reboot") |
| 138 | validate.openstack_cleanup(saltMaster, TEMPEST_TARGET_NODE) |
| 139 | if (tempest_result != "finished") { |
| 140 | currentBuild.result = "FAILURE" |
| 141 | throw new Exception("Tempest tests failed") |
| 142 | } |
| 143 | } |
| 144 | stage('Check after reboot') { |
| 145 | common.warningMsg("Checking that node is UP") |
| 146 | status = salt.minionsReachable(saltMaster, 'I@salt:master', current_target_node, null, 10, num_retries) |
| 147 | if (status == null) { |
| 148 | throw new Exception("Node ${current_target_node} cannot start") |
| 149 | } |
| 150 | tempest_result = validate.runCVPtempest(saltMaster, TEMPEST_TARGET_NODE, TEMPEST_TEST_PATTERN, SKIP_LIST_PATH, remote_artifacts_dir, "docker_tempest_after") |
| 151 | validate.openstack_cleanup(saltMaster, TEMPEST_TARGET_NODE) |
| 152 | if (tempest_result != "finished") { |
| 153 | currentBuild.result = "FAILURE" |
| 154 | throw new Exception("Tempest tests failed") |
| 155 | } |
| 156 | } |
| 157 | |
| 158 | stage('Collect results') { |
| 159 | val.addFiles(saltMaster, TEMPEST_TARGET_NODE, remote_artifacts_dir, artifacts_dir) |
| 160 | archiveArtifacts artifacts: "${artifacts_dir}/*" |
| 161 | if (DEBUG_MODE == 'false') { |
| 162 | validate.runCleanup(saltMaster, TEMPEST_TARGET_NODE) |
| 163 | salt.cmdRun(saltMaster, TEMPEST_TARGET_NODE, "rm -rf ${remote_artifacts_dir}") |
| 164 | } |
| 165 | } |
| 166 | } finally { |
| 167 | if (DEBUG_MODE == 'false') { |
| 168 | salt.cmdRun(saltMaster, TEMPEST_TARGET_NODE, "rm -rf ${remote_artifacts_dir}") |
| 169 | validate.runCleanup(saltMaster, TEMPEST_TARGET_NODE) |
| 170 | } |
| 171 | } |
| 172 | } |