blob: 9e13f7c224db6a7a804ef3ad172cd47dcbed6c1e [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
Tetiana Korchakefa4f782017-08-25 10:22:29 -070024 * TEST_K8S_NODE Kubernetes node to run tests from
25 * GENERATE_REPORT If not false, run report generation command
26 * ACCUMULATE_RESULTS If true, results from the previous build will be used
Petr Lomakine700ffd2017-08-01 10:53:15 -070027 *
28 */
29
30common = new com.mirantis.mk.Common()
31salt = new com.mirantis.mk.Salt()
Dmitrii Kabanova67e5a52017-08-14 16:31:11 -070032test = new com.mirantis.mk.Test()
Petr Lomakine700ffd2017-08-01 10:53:15 -070033validate = new com.mirantis.mcp.Validate()
chnyda625f4b42017-10-11 14:10:31 +020034def python = new com.mirantis.mk.Python()
Petr Lomakine700ffd2017-08-01 10:53:15 -070035
chnyda625f4b42017-10-11 14:10:31 +020036def pepperEnv = "pepperEnv"
Petr Lomakine700ffd2017-08-01 10:53:15 -070037def artifacts_dir = 'validation_artifacts/'
38
39node() {
40 try{
chnyda625f4b42017-10-11 14:10:31 +020041 stage('Setup virtualenv for Pepper') {
42 python.setupPepperVirtualenv(venvPepper, SALT_MASTER_URL, SALT_MASTER_CREDENTIALS)
Petr Lomakine700ffd2017-08-01 10:53:15 -070043 }
44
45 stage('Configure') {
chnyda625f4b42017-10-11 14:10:31 +020046 validate.installDocker(pepperEnv, TARGET_NODE)
Tetiana Korchakefa4f782017-08-25 10:22:29 -070047 if (ACCUMULATE_RESULTS.toBoolean() == false) {
48 sh "rm -r ${artifacts_dir}"
49 }
Petr Lomakine700ffd2017-08-01 10:53:15 -070050 sh "mkdir -p ${artifacts_dir}"
Dmitrii Kabanov6b9343e2017-08-30 15:30:21 -070051 def spt_variables = "-e spt_ssh_user=${SPT_SSH_USER} " +
52 "-e spt_floating_network=${SPT_FLOATING_NETWORK} " +
53 "-e spt_image=${SPT_IMAGE} -e spt_user=${SPT_USER} " +
54 "-e spt_flavor=${SPT_FLAVOR} -e spt_availability_zone=${SPT_AVAILABILITY_ZONE} "
chnyda625f4b42017-10-11 14:10:31 +020055 validate.runContainerConfiguration(pepperEnv, TEST_IMAGE, TARGET_NODE, artifacts_dir, spt_variables)
Petr Lomakine700ffd2017-08-01 10:53:15 -070056 }
57
58 stage('Run Tempest tests') {
59 if (RUN_TEMPEST_TESTS.toBoolean() == true) {
chnyda625f4b42017-10-11 14:10:31 +020060 validate.runTempestTests(pepperEnv, TARGET_NODE, artifacts_dir, TEMPEST_TEST_SET)
Petr Lomakine700ffd2017-08-01 10:53:15 -070061 } else {
62 common.infoMsg("Skipping Tempest tests")
63 }
64 }
65
66 stage('Run Rally tests') {
67 if (RUN_RALLY_TESTS.toBoolean() == true) {
chnyda625f4b42017-10-11 14:10:31 +020068 validate.runRallyTests(pepperEnv, TARGET_NODE, artifacts_dir)
Petr Lomakine700ffd2017-08-01 10:53:15 -070069 } else {
70 common.infoMsg("Skipping Rally tests")
71 }
72 }
Dmitrii Kabanova67e5a52017-08-14 16:31:11 -070073
Dmitrii Kabanov6b9343e2017-08-30 15:30:21 -070074 stage('Run SPT tests') {
75 if (RUN_SPT_TESTS.toBoolean() == true) {
chnyda625f4b42017-10-11 14:10:31 +020076 validate.runSptTests(pepperEnv, TARGET_NODE, artifacts_dir)
Dmitrii Kabanov6b9343e2017-08-30 15:30:21 -070077 } else {
78 common.infoMsg("Skipping SPT tests")
79 }
80 }
81
Dmitrii Kabanova67e5a52017-08-14 16:31:11 -070082 stage('Run k8s bootstrap tests') {
83 if (RUN_K8S_TESTS.toBoolean() == true) {
84 def image = 'tomkukral/k8s-scripts'
Tetiana Korchakefa4f782017-08-25 10:22:29 -070085 def output_file = 'k8s-bootstrap-tests.txt'
86 def containerName = 'conformance_tests'
87 def outfile = "/tmp/" + image.replaceAll('/', '-') + '.output'
chnyda625f4b42017-10-11 14:10:31 +020088 test.runConformanceTests(pepperEnv, TEST_K8S_NODE, TEST_K8S_API_SERVER, image)
Dmitrii Kabanova67e5a52017-08-14 16:31:11 -070089
chnyda625f4b42017-10-11 14:10:31 +020090 def file_content = validate.getFileContent(pepperEnv, TEST_K8S_NODE, outfile)
Dmitrii Kabanova67e5a52017-08-14 16:31:11 -070091 writeFile file: "${artifacts_dir}${output_file}", text: file_content
92 } else {
93 common.infoMsg("Skipping k8s bootstrap tests")
94 }
95 }
96
97 stage('Run k8s conformance e2e tests') {
98 if (RUN_K8S_TESTS.toBoolean() == true) {
99 def image = TEST_K8S_CONFORMANCE_IMAGE
Tetiana Korchakefa4f782017-08-25 10:22:29 -0700100 def output_file = 'report-k8s-e2e-tests.txt'
101 def containerName = 'conformance_tests'
102 def outfile = "/tmp/" + image.replaceAll('/', '-') + '.output'
chnyda625f4b42017-10-11 14:10:31 +0200103 test.runConformanceTests(pepperEnv, TEST_K8S_NODE, TEST_K8S_API_SERVER, image)
Dmitrii Kabanova67e5a52017-08-14 16:31:11 -0700104
chnyda625f4b42017-10-11 14:10:31 +0200105 def file_content = validate.getFileContent(pepperEnv, TEST_K8S_NODE, outfile)
Dmitrii Kabanova67e5a52017-08-14 16:31:11 -0700106 writeFile file: "${artifacts_dir}${output_file}", text: file_content
107 } else {
108 common.infoMsg("Skipping k8s conformance e2e tests")
109 }
110 }
Tetiana Korchakefa4f782017-08-25 10:22:29 -0700111 stage('Generate report') {
112 if (GENERATE_REPORT.toBoolean() == true) {
113 print("Generating html test report ...")
chnyda625f4b42017-10-11 14:10:31 +0200114 validate.generateTestReport(pepperEnv, TARGET_NODE, artifacts_dir)
Tetiana Korchakefa4f782017-08-25 10:22:29 -0700115 } else {
116 common.infoMsg("Skipping report generation")
117 }
118 }
Petr Lomakine700ffd2017-08-01 10:53:15 -0700119 stage('Collect results') {
120 archiveArtifacts artifacts: "${artifacts_dir}/*"
121 }
122 } catch (Throwable e) {
123 // If there was an error or exception thrown, the build failed
124 currentBuild.result = "FAILURE"
Jakub Josefd2efd7d2017-08-22 17:49:57 +0200125 currentBuild.description = currentBuild.description ? e.message + " " + currentBuild.description : e.message
Petr Lomakine700ffd2017-08-01 10:53:15 -0700126 throw e
127 } finally {
chnyda625f4b42017-10-11 14:10:31 +0200128 validate.runCleanup(pepperEnv, TARGET_NODE, artifacts_dir)
Petr Lomakine700ffd2017-08-01 10:53:15 -0700129 }
130}