blob: 3b4d49e4a5431c1c157a042041a6fd51e9f963b4 [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
34 cp \$(pwd)/${ENV_NAME}_salt_deployed.ini \$(pwd)/${ENV_NAME}_sl_deployed.ini
35 #dos.py suspend ${ENV_NAME}
36 #dos.py snapshot ${ENV_NAME} k8s_deployed
37 #dos.py snapshot ${ENV_NAME} sl_deployed
38 #dos.py resume ${ENV_NAME}
39 #dos.py time-sync ${ENV_NAME}
40
41 # Initialize variables used in tcp-qa tests
42 export CURRENT_SNAPSHOT=sl_deployed # provide the snapshot name required by the test
43 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
53 export COMMON_SERVICES_INSTALLED=true # skip common_services_deployed fixture
54 export K8S_INSTALLED=true # skip k8s_deployed fixture
55 export sl_installed=true # skip sl_deployed fixture
56
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}