blob: 8381d6e5fac9feaf712f332642bdc7db160e8080 [file] [log] [blame]
Petr Lomakine700ffd2017-08-01 10:53:15 -07001/**
2 *
3 * Launch validation of the cloud
4 *
5 * Expected parameters:
6 * SALT_MASTER_URL URL of Salt master
7 * SALT_MASTER_CREDENTIALS Credentials to the Salt API
8 *
9 * TEST_IMAGE Docker image link
10 * TARGET_NODE Salt target for tempest node
11 * TEMPEST_TEST_SET If not false, run tests matched to pattern only
12 * RUN_TEMPEST_TESTS If not false, run Tempest tests
13 * RUN_RALLY_TESTS If not false, run Rally tests
Dmitrii Kabanova67e5a52017-08-14 16:31:11 -070014 * RUN_K8S_TESTS If not false, run Kubernetes tests
15 * TEST_K8S_API_SERVER Kubernetes API address
16 * TEST_K8S_CONFORMANCE_IMAGE Path to docker image with conformance e2e tests
Petr Lomakine700ffd2017-08-01 10:53:15 -070017 *
18 */
19
20common = new com.mirantis.mk.Common()
21salt = new com.mirantis.mk.Salt()
Dmitrii Kabanova67e5a52017-08-14 16:31:11 -070022test = new com.mirantis.mk.Test()
Petr Lomakine700ffd2017-08-01 10:53:15 -070023validate = new com.mirantis.mcp.Validate()
24
25def saltMaster
26def artifacts_dir = 'validation_artifacts/'
27
28node() {
29 try{
30 stage('Initialization') {
31 saltMaster = salt.connection(SALT_MASTER_URL, SALT_MASTER_CREDENTIALS)
32 }
33
34 stage('Configure') {
35 validate.installDocker(saltMaster, TARGET_NODE)
36 sh "mkdir -p ${artifacts_dir}"
37 validate.runContainerConfiguration(saltMaster, TEST_IMAGE, TARGET_NODE, artifacts_dir)
38 }
39
40 stage('Run Tempest tests') {
41 if (RUN_TEMPEST_TESTS.toBoolean() == true) {
42 validate.runTempestTests(saltMaster, TARGET_NODE, artifacts_dir, TEMPEST_TEST_SET)
43 } else {
44 common.infoMsg("Skipping Tempest tests")
45 }
46 }
47
48 stage('Run Rally tests') {
49 if (RUN_RALLY_TESTS.toBoolean() == true) {
50 validate.runRallyTests(saltMaster, TARGET_NODE, artifacts_dir)
51 } else {
52 common.infoMsg("Skipping Rally tests")
53 }
54 }
Dmitrii Kabanova67e5a52017-08-14 16:31:11 -070055
56 stage('Run k8s bootstrap tests') {
57 if (RUN_K8S_TESTS.toBoolean() == true) {
58 def image = 'tomkukral/k8s-scripts'
59 def output_file = image.replaceAll('/', '-') + '.output'
60
61 // run image
62 test.runConformanceTests(saltMaster, TEST_K8S_API_SERVER, image)
63
64 // collect output
65 def file_content = salt.getFileContent(saltMaster, 'ctl01*', '/tmp/' + output_file)
66 writeFile file: "${artifacts_dir}${output_file}", text: file_content
67 } else {
68 common.infoMsg("Skipping k8s bootstrap tests")
69 }
70 }
71
72 stage('Run k8s conformance e2e tests') {
73 if (RUN_K8S_TESTS.toBoolean() == true) {
74 def image = TEST_K8S_CONFORMANCE_IMAGE
75 def output_file = image.replaceAll('/', '-') + '.output'
76
77 // run image
78 test.runConformanceTests(saltMaster, TEST_K8S_API_SERVER, image)
79
80 // collect output
81 def file_content = salt.getFileContent(saltMaster, 'ctl01*', '/tmp/' + output_file)
82 writeFile file: "${artifacts_dir}${output_file}", text: file_content
83 } else {
84 common.infoMsg("Skipping k8s conformance e2e tests")
85 }
86 }
87
Petr Lomakine700ffd2017-08-01 10:53:15 -070088 stage('Collect results') {
89 archiveArtifacts artifacts: "${artifacts_dir}/*"
90 }
91 } catch (Throwable e) {
92 // If there was an error or exception thrown, the build failed
93 currentBuild.result = "FAILURE"
94 throw e
95 } finally {
96 validate.runCleanup(saltMaster, TARGET_NODE, artifacts_dir)
97 }
98}