blob: 7566b347174cf9b9128e8cc9d48021970a4d0a3f [file] [log] [blame]
Dennis Dmitrievfde667f2018-07-23 16:26:50 +03001@Library('tcp-qa')_
2
3def common = new com.mirantis.mk.Common()
4def shared = new com.mirantis.system_qa.SharedPipeline()
5def steps = "hardware,create_model,salt," + env.DRIVETRAIN_STACK_INSTALL + "," + env.PLATFORM_STACK_INSTALL
6
Dennis Dmitriev201a35e2018-08-06 01:37:05 +03007currentBuild.description = "${NODE_NAME}:${ENV_NAME}"
8
Dennis Dmitriev6f8b0d02018-07-30 21:27:08 +03009throttle(['fuel_devops_environment']) {
10 node ("${NODE_NAME}") {
11 try {
Dennis Dmitrievfde667f2018-07-23 16:26:50 +030012
Dennis Dmitriev6f8b0d02018-07-30 21:27:08 +030013 stage("Clean the environment and clone tcp-qa") {
14 shared.prepare_working_dir()
15 }
Dennis Dmitrievfde667f2018-07-23 16:26:50 +030016
Dennis Dmitriev6f8b0d02018-07-30 21:27:08 +030017 stage("Create environment, generate model, bootstrap the salt-cluster") {
18 // steps: "hardware,create_model,salt"
19 shared.swarm_bootstrap_salt_cluster_devops()
20 }
Dennis Dmitrievfde667f2018-07-23 16:26:50 +030021
Dennis Dmitriev6f8b0d02018-07-30 21:27:08 +030022 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 Dmitrievfde667f2018-07-23 16:26:50 +030026
Dennis Dmitriev6f8b0d02018-07-30 21:27:08 +030027 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 Dmitrievfde667f2018-07-23 16:26:50 +030031
Dennis Dmitriev6f8b0d02018-07-30 21:27:08 +030032 stage("Run tests") {
33 shared.swarm_run_pytest(steps)
34 }
Dennis Dmitrievfde667f2018-07-23 16:26:50 +030035
Dennis Dmitriev6f8b0d02018-07-30 21:27:08 +030036 } catch (e) {
37 common.printMsg("Job failed", "red")
Dennis Dmitrievfde667f2018-07-23 16:26:50 +030038 shared.run_cmd("""\
Dennis Dmitriev6f8b0d02018-07-30 21:27:08 +030039 dos.py suspend ${ENV_NAME} || true
40 dos.py snapshot ${ENV_NAME} test_failed || true
Dennis Dmitrievfde667f2018-07-23 16:26:50 +030041 """)
Dennis Dmitriev6f8b0d02018-07-30 21:27:08 +030042 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 Dmitrievfde667f2018-07-23 16:26:50 +030059 }
Dennis Dmitrievfde667f2018-07-23 16:26:50 +030060 }
Dennis Dmitriev6f8b0d02018-07-30 21:27:08 +030061}