blob: f1a4ab1695194d3f8e2b8bd0607fff413b973c46 [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
Dmitrii Kabanovb2f60ee2017-11-10 00:31:50 -080012 * TEMPEST_CONFIG_REPO Git repository with configuration files for Tempest
13 * TEMPEST_CONFIG_BRANCH Git branch which will be used during the checkout
14 * TEMPEST_REPO Git repository with Tempest
15 * TEMPEST_VERSION Version of Tempest (tag, branch or commit)
Petr Lomakine700ffd2017-08-01 10:53:15 -070016 * RUN_TEMPEST_TESTS If not false, run Tempest tests
17 * RUN_RALLY_TESTS If not false, run Rally tests
Dmitrii Kabanova67e5a52017-08-14 16:31:11 -070018 * RUN_K8S_TESTS If not false, run Kubernetes tests
Dmitrii Kabanov6b9343e2017-08-30 15:30:21 -070019 * RUN_SPT_TESTS If not false, run SPT tests
20 * SPT_SSH_USER The name of the user which should be used for ssh to nodes
Dmitrii Kabanov6b9343e2017-08-30 15:30:21 -070021 * SPT_IMAGE The name of the image for SPT tests
Dmitrii Kabanov9f3b7ed2017-09-29 10:47:36 -070022 * SPT_IMAGE_USER The name of the user for SPT image
Dmitrii Kabanov6b9343e2017-08-30 15:30:21 -070023 * SPT_FLAVOR The name of the flavor for SPT image
Dmitrii Kabanov9f3b7ed2017-09-29 10:47:36 -070024 * AVAILABILITY_ZONE The name of availability zone
25 * FLOATING_NETWORK The name of the external(floating) network
26 * RALLY_IMAGE The name of the image for Rally tests
27 * RALLY_FLAVOR The name of the flavor for Rally image
Dmitrii Kabanovb2f60ee2017-11-10 00:31:50 -080028 * RALLY_CONFIG_REPO Git repository with files for Rally
29 * RALLY_CONFIG_BRANCH Git branch which will be used during the checkout
Sergey Galkin8991e822017-11-29 19:10:46 +040030 * RALLY_SCENARIOS Path to file or directory with rally scenarios
31 * RALLY_TASK_ARGS_FILE Path to file with rally tests arguments
Dmitrii Kabanova67e5a52017-08-14 16:31:11 -070032 * TEST_K8S_API_SERVER Kubernetes API address
33 * TEST_K8S_CONFORMANCE_IMAGE Path to docker image with conformance e2e tests
Tetiana Korchakefa4f782017-08-25 10:22:29 -070034 * TEST_K8S_NODE Kubernetes node to run tests from
35 * GENERATE_REPORT If not false, run report generation command
36 * ACCUMULATE_RESULTS If true, results from the previous build will be used
Petr Lomakine700ffd2017-08-01 10:53:15 -070037 *
38 */
39
40common = new com.mirantis.mk.Common()
Dmitrii Kabanova67e5a52017-08-14 16:31:11 -070041test = new com.mirantis.mk.Test()
Petr Lomakine700ffd2017-08-01 10:53:15 -070042validate = new com.mirantis.mcp.Validate()
chnyda625f4b42017-10-11 14:10:31 +020043def python = new com.mirantis.mk.Python()
Petr Lomakine700ffd2017-08-01 10:53:15 -070044
chnyda625f4b42017-10-11 14:10:31 +020045def pepperEnv = "pepperEnv"
Petr Lomakine700ffd2017-08-01 10:53:15 -070046def artifacts_dir = 'validation_artifacts/'
47
48node() {
49 try{
chnyda625f4b42017-10-11 14:10:31 +020050 stage('Setup virtualenv for Pepper') {
Dmitrii Kabanovf31c8962017-10-12 21:00:30 -070051 python.setupPepperVirtualenv(pepperEnv, SALT_MASTER_URL, SALT_MASTER_CREDENTIALS)
Petr Lomakine700ffd2017-08-01 10:53:15 -070052 }
53
54 stage('Configure') {
chnyda625f4b42017-10-11 14:10:31 +020055 validate.installDocker(pepperEnv, TARGET_NODE)
Tetiana Korchakefa4f782017-08-25 10:22:29 -070056 if (ACCUMULATE_RESULTS.toBoolean() == false) {
57 sh "rm -r ${artifacts_dir}"
58 }
Petr Lomakine700ffd2017-08-01 10:53:15 -070059 sh "mkdir -p ${artifacts_dir}"
Petr Lomakine700ffd2017-08-01 10:53:15 -070060 }
61
62 stage('Run Tempest tests') {
63 if (RUN_TEMPEST_TESTS.toBoolean() == true) {
Dmitrii Kabanovb2f60ee2017-11-10 00:31:50 -080064 validate.runTempestTests(pepperEnv, TARGET_NODE, TEST_IMAGE, artifacts_dir, TEMPEST_CONFIG_REPO, TEMPEST_CONFIG_BRANCH, TEMPEST_REPO, TEMPEST_VERSION, TEMPEST_TEST_SET)
Petr Lomakine700ffd2017-08-01 10:53:15 -070065 } else {
66 common.infoMsg("Skipping Tempest tests")
67 }
68 }
69
70 stage('Run Rally tests') {
71 if (RUN_RALLY_TESTS.toBoolean() == true) {
Dmitrii Kabanovb20f1fc2017-10-20 10:40:40 -070072 def rally_variables = ["floating_network=${FLOATING_NETWORK}",
73 "rally_image=${RALLY_IMAGE}",
74 "rally_flavor=${RALLY_FLAVOR}",
75 "availability_zone=${AVAILABILITY_ZONE}"]
Sergey Galkin8991e822017-11-29 19:10:46 +040076 validate.runRallyTests(pepperEnv, TARGET_NODE, TEST_IMAGE, artifacts_dir, RALLY_CONFIG_REPO, RALLY_CONFIG_BRANCH, RALLY_SCENARIOS, RALLY_TASK_ARGS_FILE, rally_variables)
Petr Lomakine700ffd2017-08-01 10:53:15 -070077 } else {
78 common.infoMsg("Skipping Rally tests")
79 }
80 }
Dmitrii Kabanova67e5a52017-08-14 16:31:11 -070081
Dmitrii Kabanov6b9343e2017-08-30 15:30:21 -070082 stage('Run SPT tests') {
83 if (RUN_SPT_TESTS.toBoolean() == true) {
Dmitrii Kabanovb20f1fc2017-10-20 10:40:40 -070084 def spt_variables = ["spt_ssh_user=${SPT_SSH_USER}",
85 "spt_floating_network=${FLOATING_NETWORK}",
86 "spt_image=${SPT_IMAGE}",
87 "spt_user=${SPT_IMAGE_USER}",
88 "spt_flavor=${SPT_FLAVOR}",
89 "spt_availability_zone=${AVAILABILITY_ZONE}"]
90 validate.runSptTests(pepperEnv, TARGET_NODE, TEST_IMAGE, artifacts_dir, spt_variables)
Dmitrii Kabanov6b9343e2017-08-30 15:30:21 -070091 } else {
92 common.infoMsg("Skipping SPT tests")
93 }
94 }
95
Dmitrii Kabanova67e5a52017-08-14 16:31:11 -070096 stage('Run k8s bootstrap tests') {
97 if (RUN_K8S_TESTS.toBoolean() == true) {
98 def image = 'tomkukral/k8s-scripts'
Tetiana Korchakefa4f782017-08-25 10:22:29 -070099 def output_file = 'k8s-bootstrap-tests.txt'
Tetiana Korchakefa4f782017-08-25 10:22:29 -0700100 def outfile = "/tmp/" + image.replaceAll('/', '-') + '.output'
chnyda625f4b42017-10-11 14:10:31 +0200101 test.runConformanceTests(pepperEnv, TEST_K8S_NODE, TEST_K8S_API_SERVER, image)
Dmitrii Kabanova67e5a52017-08-14 16:31:11 -0700102
chnyda625f4b42017-10-11 14:10:31 +0200103 def file_content = validate.getFileContent(pepperEnv, TEST_K8S_NODE, outfile)
Dmitrii Kabanova67e5a52017-08-14 16:31:11 -0700104 writeFile file: "${artifacts_dir}${output_file}", text: file_content
105 } else {
106 common.infoMsg("Skipping k8s bootstrap tests")
107 }
108 }
109
110 stage('Run k8s conformance e2e tests') {
111 if (RUN_K8S_TESTS.toBoolean() == true) {
112 def image = TEST_K8S_CONFORMANCE_IMAGE
Tetiana Korchakefa4f782017-08-25 10:22:29 -0700113 def output_file = 'report-k8s-e2e-tests.txt'
Tetiana Korchakefa4f782017-08-25 10:22:29 -0700114 def outfile = "/tmp/" + image.replaceAll('/', '-') + '.output'
chnyda625f4b42017-10-11 14:10:31 +0200115 test.runConformanceTests(pepperEnv, TEST_K8S_NODE, TEST_K8S_API_SERVER, image)
Dmitrii Kabanova67e5a52017-08-14 16:31:11 -0700116
chnyda625f4b42017-10-11 14:10:31 +0200117 def file_content = validate.getFileContent(pepperEnv, TEST_K8S_NODE, outfile)
Dmitrii Kabanova67e5a52017-08-14 16:31:11 -0700118 writeFile file: "${artifacts_dir}${output_file}", text: file_content
119 } else {
120 common.infoMsg("Skipping k8s conformance e2e tests")
121 }
122 }
Tetiana Korchakefa4f782017-08-25 10:22:29 -0700123 stage('Generate report') {
124 if (GENERATE_REPORT.toBoolean() == true) {
Dmitrii Kabanovb20f1fc2017-10-20 10:40:40 -0700125 common.infoMsg("Generating html test report ...")
126 validate.generateTestReport(pepperEnv, TARGET_NODE, TEST_IMAGE, artifacts_dir)
Tetiana Korchakefa4f782017-08-25 10:22:29 -0700127 } else {
128 common.infoMsg("Skipping report generation")
129 }
130 }
Petr Lomakine700ffd2017-08-01 10:53:15 -0700131 stage('Collect results') {
132 archiveArtifacts artifacts: "${artifacts_dir}/*"
133 }
134 } catch (Throwable e) {
135 // If there was an error or exception thrown, the build failed
136 currentBuild.result = "FAILURE"
Jakub Josefd2efd7d2017-08-22 17:49:57 +0200137 currentBuild.description = currentBuild.description ? e.message + " " + currentBuild.description : e.message
Petr Lomakine700ffd2017-08-01 10:53:15 -0700138 throw e
Petr Lomakine700ffd2017-08-01 10:53:15 -0700139 }
140}