blob: baa98539c051d1c9308b03e31ea6d13b6175e799 [file] [log] [blame]
Dennis Dmitrievb3b37492018-07-08 21:23:00 +03001@Library('tcp-qa')_
2
3common = new com.mirantis.mk.Common()
4shared = new com.mirantis.system_qa.SharedPipeline()
5
6
7node ("${NODE_NAME}") {
8 try {
9
10 stage("Clean the environment and clone tcp-qa") {
11 shared.prepare_working_dir()
12 }
13
14 stage("Create environment, generate model, bootstrap the salt-cluster") {
15 shared.swarm_bootstrap_salt_cluster_devops()
16 }
17
18 stage("Install core infrastructure and deploy CICD nodes") {
19 shared.swarm_deploy_cicd(env.DRIVETRAIN_STACK_INSTALL)
20 }
21
22 stage("Install core infrastructure and deploy CICD nodes") {
23 shared.swarm_deploy_platform(env.PLATFORM_STACK_INSTALL)
24 }
25
26 stage("Run tests") {
27 shared.run_cmd("""\
28 export ENV_NAME=${ENV_NAME}
29 . ./tcp_tests/utils/env_salt
30 . ./tcp_tests/utils/env_k8s
31
32 # Prepare snapshots that may be used in tests if MANAGER=devops
33 cp \$(pwd)/${ENV_NAME}_salt_deployed.ini \$(pwd)/${ENV_NAME}_k8s_deployed.ini
Dennis Dmitrievea48cf52018-07-18 18:04:39 +030034 cp \$(pwd)/${ENV_NAME}_salt_deployed.ini \$(pwd)/${ENV_NAME}_stacklight_deployed.ini
Dennis Dmitrievb3b37492018-07-08 21:23:00 +030035 #dos.py suspend ${ENV_NAME}
36 #dos.py snapshot ${ENV_NAME} k8s_deployed
Dennis Dmitrievea48cf52018-07-18 18:04:39 +030037 #dos.py snapshot ${ENV_NAME} stacklight_deployed
Dennis Dmitrievb3b37492018-07-08 21:23:00 +030038 #dos.py resume ${ENV_NAME}
39 #dos.py time-sync ${ENV_NAME}
40
41 # Initialize variables used in tcp-qa tests
Dennis Dmitrievea48cf52018-07-18 18:04:39 +030042 export CURRENT_SNAPSHOT=stacklight_deployed # provide the snapshot name required by the test
Dennis Dmitrievb3b37492018-07-08 21:23:00 +030043 export TESTS_CONFIGS=\$(pwd)/${ENV_NAME}_salt_deployed.ini # some SSH data may be filled separatelly
44
45 #export MANAGER=empty # skip 'hardware' fixture, disable snapshot/revert features
46 export MANAGER=devops # use 'hardware' fixture to manage fuel-devops environment
47 export MAKE_SNAPSHOT_STAGES=false # skip 'hardware' fixture, disable snapshot/revert features
48 # export SSH='{...}' # non-empty SSH required to skip 'underlay' fixture. It is filled from TESTS_CONFIGS now
49 export salt_master_host=\$SALT_MASTER_IP # skip salt_deployed fixture
50 export salt_master_port=6969
51 export SALT_USER=\$SALTAPI_USER
52 export SALT_PASSWORD=\$SALTAPI_PASS
Dennis Dmitrievea48cf52018-07-18 18:04:39 +030053 export CORE_INSTALLED=true # skip core_deployed fixture
Dennis Dmitrievb3b37492018-07-08 21:23:00 +030054 export K8S_INSTALLED=true # skip k8s_deployed fixture
Dennis Dmitrievea48cf52018-07-18 18:04:39 +030055 export sl_installed=true # skip stacklight_deployed fixture
Dennis Dmitrievb3b37492018-07-08 21:23:00 +030056
57 py.test --junit-xml=nosetests.xml ${RUN_TEST_OPTS}
58
59 dos.py suspend ${ENV_NAME}
60 dos.py snapshot ${ENV_NAME} test_completed
61 """)
62 }
63
64 } catch (e) {
65 common.printMsg("Job failed", "red")
66 shared.run_cmd("""\
67 dos.py suspend ${ENV_NAME} || true
68 dos.py snapshot ${ENV_NAME} test_failed || true
69 """)
70 throw e
71 } finally {
72 // TODO(ddmitriev): analyze the "def currentResult = currentBuild.result ?: 'SUCCESS'"
73 // and report appropriate data to TestRail
74 if ("${env.SHUTDOWN_ENV_ON_TEARDOWN}" == "true") {
75 shared.run_cmd("""\
76 dos.py destroy ${ENV_NAME} || true
77 """)
78 } else {
79 shared.run_cmd("""\
80 dos.py resume ${ENV_NAME} || true
81 dos.py time-sync ${ENV_NAME} || true
82 """)
83 }
84 shared.report_deploy_result("hardware,create_model,salt," + env.DRIVETRAIN_STACK_INSTALL + "," + env.PLATFORM_STACK_INSTALL)
85 shared.report_test_result()
86 }
87}