blob: d0422fdca9baba6044b6e1513cd8a9895221e910 [file] [log] [blame]
Dennis Dmitrievfde667f2018-07-23 16:26:50 +03001/**
2 *
3 * Deploy the product cluster using Jenkins master on CICD cluster
4 *
5 * Expected parameters:
6
7 * ENV_NAME Fuel-devops environment name
8 * PASSED_STEPS Steps passed to install components using Jenkins on CICD cluster: "salt,core,cicd,openstack:3200,stacklight:2400",
9 where 3200 and 2400 might be timeouts (not used in the testing pipeline)
10 * RUN_TEST_OPTS Pytest option -k or -m, with expression to select necessary tests. Additional pytest options are allowed.
11 * PARENT_NODE_NAME Name of the jenkins slave to create the environment
12 * PARENT_WORKSPACE Path to the workspace of the parent job to use tcp-qa repo
13 * TCP_QA_REFS Reference to the tcp-qa change on review.gerrithub.io, like refs/changes/46/418546/41
14 * SHUTDOWN_ENV_ON_TEARDOWN optional, shutdown fuel-devops environment at the end of the job
15 * LAB_CONFIG_NAME Not used (backward compatibility, for manual deployment steps only)
16 * REPOSITORY_SUITE Not used (backward compatibility, for manual deployment steps only)
17 * MCP_IMAGE_PATH1604 Not used (backward compatibility, for manual deployment steps only)
18 * IMAGE_PATH_CFG01_DAY01 Not used (backward compatibility, for manual deployment steps only)
19 */
20
21@Library('tcp-qa')_
22
23common = new com.mirantis.mk.Common()
24shared = new com.mirantis.system_qa.SharedPipeline()
25
26if (! env.PARENT_NODE_NAME) {
27 error "'PARENT_NODE_NAME' must be set from the parent deployment job!"
28}
29
30node ("${PARENT_NODE_NAME}") {
31 if (! fileExists("${PARENT_WORKSPACE}")) {
32 error "'PARENT_WORKSPACE' contains path to non-existing directory ${PARENT_WORKSPACE} on the node '${PARENT_NODE_NAME}'."
33 }
34 dir("${PARENT_WORKSPACE}") {
35 try {
36
37 stage("Run tests") {
38 def steps = shared.get_steps_list(PASSED_STEPS)
39 def sources = """\
40 export ENV_NAME=${ENV_NAME}
41 . ./tcp_tests/utils/env_salt"""
42 if (steps.contains('k8s')) {
43 sources += """
44 . ./tcp_tests/utils/env_k8s\n"""
45 }
46 if (steps.contains('openstack')) {
47 sources += """
48 # TODO: . ./tcp_tests/utils/env_keystonercv3\n"""
49 }
50 def installed = steps.collect {"""\
51 export ${it}_installed=true"""}.join("\n")
52
53 shared.run_cmd(sources + installed + """
54 export MANAGER=devops # use 'hardware' fixture to manage fuel-devops environment
55 export salt_master_host=\$SALT_MASTER_IP # skip salt_deployed fixture
56 export salt_master_port=6969
57 export SALT_USER=\$SALTAPI_USER
58 export SALT_PASSWORD=\$SALTAPI_PASS
59
60 py.test --junit-xml=nosetests.xml ${RUN_TEST_OPTS}
61
62 dos.py suspend ${ENV_NAME}
63 dos.py snapshot ${ENV_NAME} test_completed
64 """)
65 }
66
67 } catch (e) {
68 common.printMsg("Job failed", "red")
69 throw e
70 } finally {
71 // TODO(ddmitriev): analyze the "def currentResult = currentBuild.result ?: 'SUCCESS'"
72 // and report appropriate data to TestRail
73 if ("${env.SHUTDOWN_ENV_ON_TEARDOWN}" == "true") {
74 shared.run_cmd("""\
75 dos.py destroy ${ENV_NAME}
76 """)
77 }
78 }
79 }
80}