blob: 5768f595fb654c5afb4e195dd9e13ced3e8a47f2 [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
Dmitrii Kabanov6b9343e2017-08-30 15:30:21 -070015 * RUN_SPT_TESTS If not false, run SPT tests
16 * SPT_SSH_USER The name of the user which should be used for ssh to nodes
17 * SPT_FLOATING_NETWORK The name of the external(floating) network
18 * SPT_IMAGE The name of the image for SPT tests
19 * SPT_USER The name of the user for SPT image
20 * SPT_FLAVOR The name of the flavor for SPT image
21 * SPT_AVAILABILITY_ZONE The name of availability zone
Dmitrii Kabanova67e5a52017-08-14 16:31:11 -070022 * TEST_K8S_API_SERVER Kubernetes API address
23 * TEST_K8S_CONFORMANCE_IMAGE Path to docker image with conformance e2e tests
Petr Lomakine700ffd2017-08-01 10:53:15 -070024 *
25 */
26
27common = new com.mirantis.mk.Common()
28salt = new com.mirantis.mk.Salt()
Dmitrii Kabanova67e5a52017-08-14 16:31:11 -070029test = new com.mirantis.mk.Test()
Petr Lomakine700ffd2017-08-01 10:53:15 -070030validate = new com.mirantis.mcp.Validate()
31
32def saltMaster
33def artifacts_dir = 'validation_artifacts/'
34
35node() {
36 try{
37 stage('Initialization') {
38 saltMaster = salt.connection(SALT_MASTER_URL, SALT_MASTER_CREDENTIALS)
39 }
40
41 stage('Configure') {
42 validate.installDocker(saltMaster, TARGET_NODE)
43 sh "mkdir -p ${artifacts_dir}"
Dmitrii Kabanov6b9343e2017-08-30 15:30:21 -070044 def spt_variables = "-e spt_ssh_user=${SPT_SSH_USER} " +
45 "-e spt_floating_network=${SPT_FLOATING_NETWORK} " +
46 "-e spt_image=${SPT_IMAGE} -e spt_user=${SPT_USER} " +
47 "-e spt_flavor=${SPT_FLAVOR} -e spt_availability_zone=${SPT_AVAILABILITY_ZONE} "
48 validate.runContainerConfiguration(saltMaster, TEST_IMAGE, TARGET_NODE, artifacts_dir, spt_variables)
Petr Lomakine700ffd2017-08-01 10:53:15 -070049 }
50
51 stage('Run Tempest tests') {
52 if (RUN_TEMPEST_TESTS.toBoolean() == true) {
53 validate.runTempestTests(saltMaster, TARGET_NODE, artifacts_dir, TEMPEST_TEST_SET)
54 } else {
55 common.infoMsg("Skipping Tempest tests")
56 }
57 }
58
59 stage('Run Rally tests') {
60 if (RUN_RALLY_TESTS.toBoolean() == true) {
61 validate.runRallyTests(saltMaster, TARGET_NODE, artifacts_dir)
62 } else {
63 common.infoMsg("Skipping Rally tests")
64 }
65 }
Dmitrii Kabanova67e5a52017-08-14 16:31:11 -070066
Dmitrii Kabanov6b9343e2017-08-30 15:30:21 -070067 stage('Run SPT tests') {
68 if (RUN_SPT_TESTS.toBoolean() == true) {
69 validate.runSptTests(saltMaster, TARGET_NODE, artifacts_dir)
70 } else {
71 common.infoMsg("Skipping SPT tests")
72 }
73 }
74
Dmitrii Kabanova67e5a52017-08-14 16:31:11 -070075 stage('Run k8s bootstrap tests') {
76 if (RUN_K8S_TESTS.toBoolean() == true) {
77 def image = 'tomkukral/k8s-scripts'
78 def output_file = image.replaceAll('/', '-') + '.output'
79
80 // run image
81 test.runConformanceTests(saltMaster, TEST_K8S_API_SERVER, image)
82
83 // collect output
84 def file_content = salt.getFileContent(saltMaster, 'ctl01*', '/tmp/' + output_file)
85 writeFile file: "${artifacts_dir}${output_file}", text: file_content
86 } else {
87 common.infoMsg("Skipping k8s bootstrap tests")
88 }
89 }
90
91 stage('Run k8s conformance e2e tests') {
92 if (RUN_K8S_TESTS.toBoolean() == true) {
93 def image = TEST_K8S_CONFORMANCE_IMAGE
94 def output_file = image.replaceAll('/', '-') + '.output'
95
96 // run image
97 test.runConformanceTests(saltMaster, TEST_K8S_API_SERVER, image)
98
99 // collect output
100 def file_content = salt.getFileContent(saltMaster, 'ctl01*', '/tmp/' + output_file)
101 writeFile file: "${artifacts_dir}${output_file}", text: file_content
102 } else {
103 common.infoMsg("Skipping k8s conformance e2e tests")
104 }
105 }
106
Petr Lomakine700ffd2017-08-01 10:53:15 -0700107 stage('Collect results') {
108 archiveArtifacts artifacts: "${artifacts_dir}/*"
109 }
110 } catch (Throwable e) {
111 // If there was an error or exception thrown, the build failed
112 currentBuild.result = "FAILURE"
Jakub Josefd2efd7d2017-08-22 17:49:57 +0200113 currentBuild.description = currentBuild.description ? e.message + " " + currentBuild.description : e.message
Petr Lomakine700ffd2017-08-01 10:53:15 -0700114 throw e
115 } finally {
116 validate.runCleanup(saltMaster, TARGET_NODE, artifacts_dir)
117 }
118}