blob: 0b6da19075ab5dc1cf602dd51d089f713c67217b [file] [log] [blame]
Ales Komarek1ebb7a82017-08-04 14:58:51 +02001/**
2 *
3 * Service test pipeline
4 *
5 * Expected parameters:
6 * SALT_MASTER_URL URL of Salt master
7 * SALT_MASTER_CREDENTIALS Credentials to the Salt API
8 * Test settings:
9 * TEST_SERVICE Comma separated list of services to test
10 * TEST_K8S_API_SERVER Kubernetes API address
11 * TEST_K8S_CONFORMANCE_IMAGE Path to docker image with conformance e2e tests
12 * TEST_DOCKER_INSTALL Install docker on the target if true
13 * TEST_TEMPEST_IMAGE Tempest image link
14 * TEST_TEMPEST_PATTERN If not false, run tests matched to pattern only
15 * TEST_TEMPEST_TARGET Salt target for tempest node
16 *
17 */
18
19common = new com.mirantis.mk.Common()
20git = new com.mirantis.mk.Git()
21salt = new com.mirantis.mk.Salt()
22test = new com.mirantis.mk.Test()
chnyda625f4b42017-10-11 14:10:31 +020023def python = new com.mirantis.mk.Python()
Ales Komarek1ebb7a82017-08-04 14:58:51 +020024
chnyda625f4b42017-10-11 14:10:31 +020025def pepperEnv = "pepperEnv"
Ales Komarek1ebb7a82017-08-04 14:58:51 +020026
27node("python") {
28 try {
29
chnyda625f4b42017-10-11 14:10:31 +020030 stage('Setup virtualenv for Pepper') {
Dmitrii Kabanovf31c8962017-10-12 21:00:30 -070031 python.setupPepperVirtualenv(pepperEnv, SALT_MASTER_URL, SALT_MASTER_CREDENTIALS)
Ales Komarek1ebb7a82017-08-04 14:58:51 +020032 }
33
34 //
35 // Test
36 //
37 def artifacts_dir = '_artifacts/'
38
39 if (common.checkContains('TEST_SERVICE', 'k8s')) {
40 stage('Run k8s bootstrap tests') {
41 def image = 'tomkukral/k8s-scripts'
42 def output_file = image.replaceAll('/', '-') + '.output'
43
44 // run image
chnyda625f4b42017-10-11 14:10:31 +020045 test.runConformanceTests(pepperEnv, 'ctl01*', TEST_K8S_API_SERVER, image)
Ales Komarek1ebb7a82017-08-04 14:58:51 +020046
47 // collect output
48 sh "mkdir -p ${artifacts_dir}"
chnyda625f4b42017-10-11 14:10:31 +020049 file_content = salt.getFileContent(pepperEnv, 'ctl01*', '/tmp/' + output_file)
Ales Komarek1ebb7a82017-08-04 14:58:51 +020050 writeFile file: "${artifacts_dir}${output_file}", text: file_content
51 sh "cat ${artifacts_dir}${output_file}"
52
53 // collect artifacts
54 archiveArtifacts artifacts: "${artifacts_dir}${output_file}"
55 }
56
57 stage('Run k8s conformance e2e tests') {
58 def image = K8S_CONFORMANCE_IMAGE
59 def output_file = image.replaceAll('/', '-') + '.output'
60
61 // run image
chnyda625f4b42017-10-11 14:10:31 +020062 test.runConformanceTests(pepperEnv, 'ctl01*', TEST_K8S_API_SERVER, image)
Ales Komarek1ebb7a82017-08-04 14:58:51 +020063
64 // collect output
65 sh "mkdir -p ${artifacts_dir}"
chnyda625f4b42017-10-11 14:10:31 +020066 file_content = salt.getFileContent(pepperEnv, 'ctl01*', '/tmp/' + output_file)
Ales Komarek1ebb7a82017-08-04 14:58:51 +020067 writeFile file: "${artifacts_dir}${output_file}", text: file_content
68 sh "cat ${artifacts_dir}${output_file}"
69
70 // collect artifacts
71 archiveArtifacts artifacts: "${artifacts_dir}${output_file}"
72 }
73 }
74
75 if (common.checkContains('TEST_SERVICE', 'openstack')) {
Tomáš Kukrále7859292017-08-11 13:52:06 +020076 if (common.checkContains('TEST_DOCKER_INSTALL', 'true')) {
chnyda625f4b42017-10-11 14:10:31 +020077 test.install_docker(pepperEnv, TEST_TEMPEST_TARGET)
Tomáš Kukrále7859292017-08-11 13:52:06 +020078 }
Ales Komarek1ebb7a82017-08-04 14:58:51 +020079
Tomáš Kukrále7859292017-08-11 13:52:06 +020080 stage('Run OpenStack tests') {
chnyda625f4b42017-10-11 14:10:31 +020081 test.runTempestTests(pepperEnv, TEST_TEMPEST_IMAGE, TEST_TEMPEST_TARGET, TEST_TEMPEST_PATTERN)
Tomáš Kukrále7859292017-08-11 13:52:06 +020082 }
Tomáš Kukrál503d4912017-08-11 13:01:12 +020083
chnyda625f4b42017-10-11 14:10:31 +020084 writeFile(file: 'report.xml', text: salt.getFileContent(pepperEnv, TEST_TEMPEST_TARGET, '/root/report.xml'))
Tomáš Kukrál8689fb32017-08-11 14:13:45 +020085 junit(keepLongStdio: true, testResults: 'report.xml', healthScaleFactor: Double.parseDouble(TEST_JUNIT_RATIO))
Jakub Josefa1ddadf2017-08-18 14:11:29 +020086 def testResults = test.collectJUnitResults(currentBuild.rawBuild.getAction(hudson.tasks.test.AbstractTestResultAction.class))
Jakub Josef17f170c2017-08-18 11:23:24 +020087 if(testResults){
88 currentBuild.desc = String.format("result: %s", testResults["failed"] / testResults["total"])
Jakub Josefb08a94b2017-08-16 13:54:28 +020089 }
Jakub Josefb08a94b2017-08-16 13:54:28 +020090 }
Ales Komarek1ebb7a82017-08-04 14:58:51 +020091 } catch (Throwable e) {
92 currentBuild.result = 'FAILURE'
93 throw e
94 }
95}