blob: c73325cc37b52eed21cf57e9ccb1b706457ed4bc [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
Sergey Galkin59511372018-02-13 13:59:41 +040032 * REPORT_DIR Path for reports outside docker image
Dmitrii Kabanova67e5a52017-08-14 16:31:11 -070033 * TEST_K8S_API_SERVER Kubernetes API address
34 * TEST_K8S_CONFORMANCE_IMAGE Path to docker image with conformance e2e tests
Tetiana Korchakefa4f782017-08-25 10:22:29 -070035 * TEST_K8S_NODE Kubernetes node to run tests from
36 * GENERATE_REPORT If not false, run report generation command
37 * ACCUMULATE_RESULTS If true, results from the previous build will be used
Petr Lomakine700ffd2017-08-01 10:53:15 -070038 *
39 */
40
41common = new com.mirantis.mk.Common()
Dmitrii Kabanova67e5a52017-08-14 16:31:11 -070042test = new com.mirantis.mk.Test()
Petr Lomakine700ffd2017-08-01 10:53:15 -070043validate = new com.mirantis.mcp.Validate()
chnyda625f4b42017-10-11 14:10:31 +020044def python = new com.mirantis.mk.Python()
Petr Lomakine700ffd2017-08-01 10:53:15 -070045
chnyda625f4b42017-10-11 14:10:31 +020046def pepperEnv = "pepperEnv"
Petr Lomakine700ffd2017-08-01 10:53:15 -070047def artifacts_dir = 'validation_artifacts/'
Jakub Josefa63f9862018-01-11 17:58:38 +010048timeout(time: 12, unit: 'HOURS') {
49 node() {
50 try{
51 stage('Setup virtualenv for Pepper') {
52 python.setupPepperVirtualenv(pepperEnv, SALT_MASTER_URL, SALT_MASTER_CREDENTIALS)
Tetiana Korchakefa4f782017-08-25 10:22:29 -070053 }
Petr Lomakine700ffd2017-08-01 10:53:15 -070054
Jakub Josefa63f9862018-01-11 17:58:38 +010055 stage('Configure') {
56 validate.installDocker(pepperEnv, TARGET_NODE)
57 if (ACCUMULATE_RESULTS.toBoolean() == false) {
58 sh "rm -r ${artifacts_dir}"
59 }
60 sh "mkdir -p ${artifacts_dir}"
Petr Lomakine700ffd2017-08-01 10:53:15 -070061 }
Petr Lomakine700ffd2017-08-01 10:53:15 -070062
Jakub Josefa63f9862018-01-11 17:58:38 +010063 stage('Run Tempest tests') {
64 if (RUN_TEMPEST_TESTS.toBoolean() == true) {
65 validate.runTempestTests(pepperEnv, TARGET_NODE, TEST_IMAGE, artifacts_dir, TEMPEST_CONFIG_REPO, TEMPEST_CONFIG_BRANCH, TEMPEST_REPO, TEMPEST_VERSION, TEMPEST_TEST_SET)
66 } else {
67 common.infoMsg("Skipping Tempest tests")
68 }
Petr Lomakine700ffd2017-08-01 10:53:15 -070069 }
Dmitrii Kabanova67e5a52017-08-14 16:31:11 -070070
Jakub Josefa63f9862018-01-11 17:58:38 +010071 stage('Run Rally tests') {
72 if (RUN_RALLY_TESTS.toBoolean() == true) {
Sergey Galkin59511372018-02-13 13:59:41 +040073 def report_dir = '/root/qa_results'
74 try {
75 if(REPORT_DIR != ""){
76 report_dir = REPORT_DIR
77 }
78 } catch (MissingPropertyException e) {
Denis Egorenkofca089f2019-03-13 15:37:09 +040079 common.warningMsg(e)
Sergey Galkin59511372018-02-13 13:59:41 +040080 }
Jakub Josefa63f9862018-01-11 17:58:38 +010081 def rally_variables = ["floating_network=${FLOATING_NETWORK}",
82 "rally_image=${RALLY_IMAGE}",
83 "rally_flavor=${RALLY_FLAVOR}",
84 "availability_zone=${AVAILABILITY_ZONE}"]
Sergey Galkin59511372018-02-13 13:59:41 +040085 validate.runRallyTests(pepperEnv, TARGET_NODE, TEST_IMAGE, artifacts_dir, RALLY_CONFIG_REPO, RALLY_CONFIG_BRANCH, RALLY_SCENARIOS, RALLY_TASK_ARGS_FILE, rally_variables, report_dir)
Jakub Josefa63f9862018-01-11 17:58:38 +010086 } else {
87 common.infoMsg("Skipping Rally tests")
88 }
Dmitrii Kabanov6b9343e2017-08-30 15:30:21 -070089 }
Dmitrii Kabanov6b9343e2017-08-30 15:30:21 -070090
Jakub Josefa63f9862018-01-11 17:58:38 +010091 stage('Run SPT tests') {
92 if (RUN_SPT_TESTS.toBoolean() == true) {
93 def spt_variables = ["spt_ssh_user=${SPT_SSH_USER}",
94 "spt_floating_network=${FLOATING_NETWORK}",
95 "spt_image=${SPT_IMAGE}",
96 "spt_user=${SPT_IMAGE_USER}",
97 "spt_flavor=${SPT_FLAVOR}",
98 "spt_availability_zone=${AVAILABILITY_ZONE}"]
99 validate.runSptTests(pepperEnv, TARGET_NODE, TEST_IMAGE, artifacts_dir, spt_variables)
100 } else {
101 common.infoMsg("Skipping SPT tests")
102 }
Dmitrii Kabanova67e5a52017-08-14 16:31:11 -0700103 }
Dmitrii Kabanova67e5a52017-08-14 16:31:11 -0700104
Jakub Josefa63f9862018-01-11 17:58:38 +0100105 stage('Run k8s bootstrap tests') {
106 if (RUN_K8S_TESTS.toBoolean() == true) {
107 def image = 'tomkukral/k8s-scripts'
108 def output_file = 'k8s-bootstrap-tests.txt'
109 def outfile = "/tmp/" + image.replaceAll('/', '-') + '.output'
110 test.runConformanceTests(pepperEnv, TEST_K8S_NODE, TEST_K8S_API_SERVER, image)
Dmitrii Kabanova67e5a52017-08-14 16:31:11 -0700111
Jakub Josefa63f9862018-01-11 17:58:38 +0100112 def file_content = validate.getFileContent(pepperEnv, TEST_K8S_NODE, outfile)
113 writeFile file: "${artifacts_dir}${output_file}", text: file_content
114 } else {
115 common.infoMsg("Skipping k8s bootstrap tests")
116 }
Dmitrii Kabanova67e5a52017-08-14 16:31:11 -0700117 }
Jakub Josefa63f9862018-01-11 17:58:38 +0100118
119 stage('Run k8s conformance e2e tests') {
120 if (RUN_K8S_TESTS.toBoolean() == true) {
121 def image = TEST_K8S_CONFORMANCE_IMAGE
122 def output_file = 'report-k8s-e2e-tests.txt'
123 def outfile = "/tmp/" + image.replaceAll('/', '-') + '.output'
124 test.runConformanceTests(pepperEnv, TEST_K8S_NODE, TEST_K8S_API_SERVER, image)
125
126 def file_content = validate.getFileContent(pepperEnv, TEST_K8S_NODE, outfile)
127 writeFile file: "${artifacts_dir}${output_file}", text: file_content
128 } else {
129 common.infoMsg("Skipping k8s conformance e2e tests")
130 }
Tetiana Korchakefa4f782017-08-25 10:22:29 -0700131 }
Jakub Josefa63f9862018-01-11 17:58:38 +0100132 stage('Generate report') {
133 if (GENERATE_REPORT.toBoolean() == true) {
134 common.infoMsg("Generating html test report ...")
135 validate.generateTestReport(pepperEnv, TARGET_NODE, TEST_IMAGE, artifacts_dir)
136 } else {
137 common.infoMsg("Skipping report generation")
138 }
139 }
140 stage('Collect results') {
141 archiveArtifacts artifacts: "${artifacts_dir}/*"
142 }
143 } catch (Throwable e) {
144 // If there was an error or exception thrown, the build failed
145 currentBuild.result = "FAILURE"
146 currentBuild.description = currentBuild.description ? e.message + " " + currentBuild.description : e.message
147 throw e
Tetiana Korchakefa4f782017-08-25 10:22:29 -0700148 }
Petr Lomakine700ffd2017-08-01 10:53:15 -0700149 }
150}