blob: 4e0dab350beca81ce994f9e62a9e77e308c48fc6 [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 Dmitriev6f8b0d02018-07-30 21:27:08 +03007throttle(['fuel_devops_environment']) {
8 node ("${NODE_NAME}") {
9 try {
Dennis Dmitrievfde667f2018-07-23 16:26:50 +030010
Dennis Dmitriev6f8b0d02018-07-30 21:27:08 +030011 stage("Clean the environment and clone tcp-qa") {
12 shared.prepare_working_dir()
13 }
Dennis Dmitrievfde667f2018-07-23 16:26:50 +030014
Dennis Dmitriev6f8b0d02018-07-30 21:27:08 +030015 stage("Create environment, generate model, bootstrap the salt-cluster") {
16 // steps: "hardware,create_model,salt"
17 shared.swarm_bootstrap_salt_cluster_devops()
18 }
Dennis Dmitrievfde667f2018-07-23 16:26:50 +030019
Dennis Dmitriev6f8b0d02018-07-30 21:27:08 +030020 stage("Install core infrastructure and deploy CICD nodes") {
21 // steps: env.DRIVETRAIN_STACK_INSTALL
22 shared.swarm_deploy_cicd(env.DRIVETRAIN_STACK_INSTALL)
23 }
Dennis Dmitrievfde667f2018-07-23 16:26:50 +030024
Dennis Dmitriev6f8b0d02018-07-30 21:27:08 +030025 stage("Install core infrastructure and deploy CICD nodes") {
26 // steps: env.PLATFORM_STACK_INSTALL
27 shared.swarm_deploy_platform(env.PLATFORM_STACK_INSTALL)
28 }
Dennis Dmitrievfde667f2018-07-23 16:26:50 +030029
Dennis Dmitriev6f8b0d02018-07-30 21:27:08 +030030 stage("Run tests") {
31 shared.swarm_run_pytest(steps)
32 }
Dennis Dmitrievfde667f2018-07-23 16:26:50 +030033
Dennis Dmitriev6f8b0d02018-07-30 21:27:08 +030034 } catch (e) {
35 common.printMsg("Job failed", "red")
Dennis Dmitrievfde667f2018-07-23 16:26:50 +030036 shared.run_cmd("""\
Dennis Dmitriev6f8b0d02018-07-30 21:27:08 +030037 dos.py suspend ${ENV_NAME} || true
38 dos.py snapshot ${ENV_NAME} test_failed || true
Dennis Dmitrievfde667f2018-07-23 16:26:50 +030039 """)
Dennis Dmitriev6f8b0d02018-07-30 21:27:08 +030040 throw e
41 } finally {
42 // TODO(ddmitriev): analyze the "def currentResult = currentBuild.result ?: 'SUCCESS'"
43 // and report appropriate data to TestRail
44 if ("${env.SHUTDOWN_ENV_ON_TEARDOWN}" == "false") {
45 shared.run_cmd("""\
46 dos.py resume ${ENV_NAME} || true
47 sleep 20 # Wait for I/O on the host calms down
48 dos.py time-sync ${ENV_NAME} || true
49 """)
50 } else {
51 shared.run_cmd("""\
52 dos.py destroy ${ENV_NAME} || true
53 """)
54 }
55 shared.report_deploy_result(steps)
56 shared.report_test_result()
Dennis Dmitrievfde667f2018-07-23 16:26:50 +030057 }
Dennis Dmitrievfde667f2018-07-23 16:26:50 +030058 }
Dennis Dmitriev6f8b0d02018-07-30 21:27:08 +030059}