Dennis Dmitriev | fde667f | 2018-07-23 16:26:50 +0300 | [diff] [blame] | 1 | @Library('tcp-qa')_ |
| 2 | |
| 3 | def common = new com.mirantis.mk.Common() |
| 4 | def shared = new com.mirantis.system_qa.SharedPipeline() |
| 5 | def steps = "hardware,create_model,salt," + env.DRIVETRAIN_STACK_INSTALL + "," + env.PLATFORM_STACK_INSTALL |
| 6 | |
Dennis Dmitriev | 201a35e | 2018-08-06 01:37:05 +0300 | [diff] [blame] | 7 | currentBuild.description = "${NODE_NAME}:${ENV_NAME}" |
| 8 | |
Dennis Dmitriev | 6f8b0d0 | 2018-07-30 21:27:08 +0300 | [diff] [blame] | 9 | throttle(['fuel_devops_environment']) { |
| 10 | node ("${NODE_NAME}") { |
| 11 | try { |
Dennis Dmitriev | fde667f | 2018-07-23 16:26:50 +0300 | [diff] [blame] | 12 | |
Dennis Dmitriev | 6f8b0d0 | 2018-07-30 21:27:08 +0300 | [diff] [blame] | 13 | stage("Clean the environment and clone tcp-qa") { |
| 14 | shared.prepare_working_dir() |
| 15 | } |
Dennis Dmitriev | fde667f | 2018-07-23 16:26:50 +0300 | [diff] [blame] | 16 | |
Dennis Dmitriev | 6f8b0d0 | 2018-07-30 21:27:08 +0300 | [diff] [blame] | 17 | stage("Create environment, generate model, bootstrap the salt-cluster") { |
| 18 | // steps: "hardware,create_model,salt" |
| 19 | shared.swarm_bootstrap_salt_cluster_devops() |
| 20 | } |
Dennis Dmitriev | fde667f | 2018-07-23 16:26:50 +0300 | [diff] [blame] | 21 | |
Dennis Dmitriev | 6f8b0d0 | 2018-07-30 21:27:08 +0300 | [diff] [blame] | 22 | stage("Install core infrastructure and deploy CICD nodes") { |
| 23 | // steps: env.DRIVETRAIN_STACK_INSTALL |
| 24 | shared.swarm_deploy_cicd(env.DRIVETRAIN_STACK_INSTALL) |
| 25 | } |
Dennis Dmitriev | fde667f | 2018-07-23 16:26:50 +0300 | [diff] [blame] | 26 | |
Dennis Dmitriev | 6f8b0d0 | 2018-07-30 21:27:08 +0300 | [diff] [blame] | 27 | stage("Install core infrastructure and deploy CICD nodes") { |
| 28 | // steps: env.PLATFORM_STACK_INSTALL |
| 29 | shared.swarm_deploy_platform(env.PLATFORM_STACK_INSTALL) |
| 30 | } |
Dennis Dmitriev | fde667f | 2018-07-23 16:26:50 +0300 | [diff] [blame] | 31 | |
Dennis Dmitriev | 6f8b0d0 | 2018-07-30 21:27:08 +0300 | [diff] [blame] | 32 | stage("Run tests") { |
| 33 | shared.swarm_run_pytest(steps) |
| 34 | } |
Dennis Dmitriev | fde667f | 2018-07-23 16:26:50 +0300 | [diff] [blame] | 35 | |
Dennis Dmitriev | 6f8b0d0 | 2018-07-30 21:27:08 +0300 | [diff] [blame] | 36 | } catch (e) { |
| 37 | common.printMsg("Job failed", "red") |
Dennis Dmitriev | fde667f | 2018-07-23 16:26:50 +0300 | [diff] [blame] | 38 | shared.run_cmd("""\ |
Dennis Dmitriev | 6f8b0d0 | 2018-07-30 21:27:08 +0300 | [diff] [blame] | 39 | dos.py suspend ${ENV_NAME} || true |
| 40 | dos.py snapshot ${ENV_NAME} test_failed || true |
Dennis Dmitriev | fde667f | 2018-07-23 16:26:50 +0300 | [diff] [blame] | 41 | """) |
Dennis Dmitriev | 6f8b0d0 | 2018-07-30 21:27:08 +0300 | [diff] [blame] | 42 | throw e |
| 43 | } finally { |
| 44 | // TODO(ddmitriev): analyze the "def currentResult = currentBuild.result ?: 'SUCCESS'" |
| 45 | // and report appropriate data to TestRail |
| 46 | if ("${env.SHUTDOWN_ENV_ON_TEARDOWN}" == "false") { |
| 47 | shared.run_cmd("""\ |
| 48 | dos.py resume ${ENV_NAME} || true |
| 49 | sleep 20 # Wait for I/O on the host calms down |
| 50 | dos.py time-sync ${ENV_NAME} || true |
| 51 | """) |
| 52 | } else { |
| 53 | shared.run_cmd("""\ |
| 54 | dos.py destroy ${ENV_NAME} || true |
| 55 | """) |
| 56 | } |
| 57 | shared.report_deploy_result(steps) |
| 58 | shared.report_test_result() |
Dennis Dmitriev | fde667f | 2018-07-23 16:26:50 +0300 | [diff] [blame] | 59 | } |
Dennis Dmitriev | fde667f | 2018-07-23 16:26:50 +0300 | [diff] [blame] | 60 | } |
Dennis Dmitriev | 6f8b0d0 | 2018-07-30 21:27:08 +0300 | [diff] [blame] | 61 | } |