blob: 0ff946dfb9d0dfaa4cd098e731b1b6cff6a6a93d [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
Dmitrii Kabanov6b9343e2017-08-30 15:30:21 -070017 * SPT_IMAGE The name of the image for SPT tests
Dmitrii Kabanov9f3b7ed2017-09-29 10:47:36 -070018 * SPT_IMAGE_USER The name of the user for SPT image
Dmitrii Kabanov6b9343e2017-08-30 15:30:21 -070019 * SPT_FLAVOR The name of the flavor for SPT image
Dmitrii Kabanov9f3b7ed2017-09-29 10:47:36 -070020 * AVAILABILITY_ZONE The name of availability zone
21 * FLOATING_NETWORK The name of the external(floating) network
22 * RALLY_IMAGE The name of the image for Rally tests
23 * RALLY_FLAVOR The name of the flavor for Rally image
Dmitrii Kabanova67e5a52017-08-14 16:31:11 -070024 * TEST_K8S_API_SERVER Kubernetes API address
25 * TEST_K8S_CONFORMANCE_IMAGE Path to docker image with conformance e2e tests
Tetiana Korchakefa4f782017-08-25 10:22:29 -070026 * TEST_K8S_NODE Kubernetes node to run tests from
27 * GENERATE_REPORT If not false, run report generation command
28 * ACCUMULATE_RESULTS If true, results from the previous build will be used
Petr Lomakine700ffd2017-08-01 10:53:15 -070029 *
30 */
31
32common = new com.mirantis.mk.Common()
Dmitrii Kabanova67e5a52017-08-14 16:31:11 -070033test = new com.mirantis.mk.Test()
Petr Lomakine700ffd2017-08-01 10:53:15 -070034validate = new com.mirantis.mcp.Validate()
chnyda625f4b42017-10-11 14:10:31 +020035def python = new com.mirantis.mk.Python()
Petr Lomakine700ffd2017-08-01 10:53:15 -070036
chnyda625f4b42017-10-11 14:10:31 +020037def pepperEnv = "pepperEnv"
Petr Lomakine700ffd2017-08-01 10:53:15 -070038def artifacts_dir = 'validation_artifacts/'
39
40node() {
41 try{
chnyda625f4b42017-10-11 14:10:31 +020042 stage('Setup virtualenv for Pepper') {
Dmitrii Kabanovf31c8962017-10-12 21:00:30 -070043 python.setupPepperVirtualenv(pepperEnv, SALT_MASTER_URL, SALT_MASTER_CREDENTIALS)
Petr Lomakine700ffd2017-08-01 10:53:15 -070044 }
45
46 stage('Configure') {
chnyda625f4b42017-10-11 14:10:31 +020047 validate.installDocker(pepperEnv, TARGET_NODE)
Tetiana Korchakefa4f782017-08-25 10:22:29 -070048 if (ACCUMULATE_RESULTS.toBoolean() == false) {
49 sh "rm -r ${artifacts_dir}"
50 }
Petr Lomakine700ffd2017-08-01 10:53:15 -070051 sh "mkdir -p ${artifacts_dir}"
Petr Lomakine700ffd2017-08-01 10:53:15 -070052 }
53
54 stage('Run Tempest tests') {
55 if (RUN_TEMPEST_TESTS.toBoolean() == true) {
Dmitrii Kabanovb20f1fc2017-10-20 10:40:40 -070056 validate.runTempestTests(pepperEnv, TARGET_NODE, TEST_IMAGE, artifacts_dir, TEMPEST_TEST_SET)
Petr Lomakine700ffd2017-08-01 10:53:15 -070057 } else {
58 common.infoMsg("Skipping Tempest tests")
59 }
60 }
61
62 stage('Run Rally tests') {
63 if (RUN_RALLY_TESTS.toBoolean() == true) {
Dmitrii Kabanovb20f1fc2017-10-20 10:40:40 -070064 def rally_variables = ["floating_network=${FLOATING_NETWORK}",
65 "rally_image=${RALLY_IMAGE}",
66 "rally_flavor=${RALLY_FLAVOR}",
67 "availability_zone=${AVAILABILITY_ZONE}"]
68 validate.runRallyTests(pepperEnv, TARGET_NODE, TEST_IMAGE, artifacts_dir, rally_variables)
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) {
Dmitrii Kabanovb20f1fc2017-10-20 10:40:40 -070076 def spt_variables = ["spt_ssh_user=${SPT_SSH_USER}",
77 "spt_floating_network=${FLOATING_NETWORK}",
78 "spt_image=${SPT_IMAGE}",
79 "spt_user=${SPT_IMAGE_USER}",
80 "spt_flavor=${SPT_FLAVOR}",
81 "spt_availability_zone=${AVAILABILITY_ZONE}"]
82 validate.runSptTests(pepperEnv, TARGET_NODE, TEST_IMAGE, artifacts_dir, spt_variables)
Dmitrii Kabanov6b9343e2017-08-30 15:30:21 -070083 } else {
84 common.infoMsg("Skipping SPT tests")
85 }
86 }
87
Dmitrii Kabanova67e5a52017-08-14 16:31:11 -070088 stage('Run k8s bootstrap tests') {
89 if (RUN_K8S_TESTS.toBoolean() == true) {
90 def image = 'tomkukral/k8s-scripts'
Tetiana Korchakefa4f782017-08-25 10:22:29 -070091 def output_file = 'k8s-bootstrap-tests.txt'
Tetiana Korchakefa4f782017-08-25 10:22:29 -070092 def outfile = "/tmp/" + image.replaceAll('/', '-') + '.output'
chnyda625f4b42017-10-11 14:10:31 +020093 test.runConformanceTests(pepperEnv, TEST_K8S_NODE, TEST_K8S_API_SERVER, image)
Dmitrii Kabanova67e5a52017-08-14 16:31:11 -070094
chnyda625f4b42017-10-11 14:10:31 +020095 def file_content = validate.getFileContent(pepperEnv, TEST_K8S_NODE, outfile)
Dmitrii Kabanova67e5a52017-08-14 16:31:11 -070096 writeFile file: "${artifacts_dir}${output_file}", text: file_content
97 } else {
98 common.infoMsg("Skipping k8s bootstrap tests")
99 }
100 }
101
102 stage('Run k8s conformance e2e tests') {
103 if (RUN_K8S_TESTS.toBoolean() == true) {
104 def image = TEST_K8S_CONFORMANCE_IMAGE
Tetiana Korchakefa4f782017-08-25 10:22:29 -0700105 def output_file = 'report-k8s-e2e-tests.txt'
Tetiana Korchakefa4f782017-08-25 10:22:29 -0700106 def outfile = "/tmp/" + image.replaceAll('/', '-') + '.output'
chnyda625f4b42017-10-11 14:10:31 +0200107 test.runConformanceTests(pepperEnv, TEST_K8S_NODE, TEST_K8S_API_SERVER, image)
Dmitrii Kabanova67e5a52017-08-14 16:31:11 -0700108
chnyda625f4b42017-10-11 14:10:31 +0200109 def file_content = validate.getFileContent(pepperEnv, TEST_K8S_NODE, outfile)
Dmitrii Kabanova67e5a52017-08-14 16:31:11 -0700110 writeFile file: "${artifacts_dir}${output_file}", text: file_content
111 } else {
112 common.infoMsg("Skipping k8s conformance e2e tests")
113 }
114 }
Tetiana Korchakefa4f782017-08-25 10:22:29 -0700115 stage('Generate report') {
116 if (GENERATE_REPORT.toBoolean() == true) {
Dmitrii Kabanovb20f1fc2017-10-20 10:40:40 -0700117 common.infoMsg("Generating html test report ...")
118 validate.generateTestReport(pepperEnv, TARGET_NODE, TEST_IMAGE, artifacts_dir)
Tetiana Korchakefa4f782017-08-25 10:22:29 -0700119 } else {
120 common.infoMsg("Skipping report generation")
121 }
122 }
Petr Lomakine700ffd2017-08-01 10:53:15 -0700123 stage('Collect results') {
124 archiveArtifacts artifacts: "${artifacts_dir}/*"
125 }
126 } catch (Throwable e) {
127 // If there was an error or exception thrown, the build failed
128 currentBuild.result = "FAILURE"
Jakub Josefd2efd7d2017-08-22 17:49:57 +0200129 currentBuild.description = currentBuild.description ? e.message + " " + currentBuild.description : e.message
Petr Lomakine700ffd2017-08-01 10:53:15 -0700130 throw e
Petr Lomakine700ffd2017-08-01 10:53:15 -0700131 }
132}