blob: f9c34e35d39b3ef317a0a154e9ecee9a61be0d13 [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"
Jakub Josefa63f9862018-01-11 17:58:38 +010026timeout(time: 12, unit: 'HOURS') {
27 node("python") {
28 try {
Ales Komarek1ebb7a82017-08-04 14:58:51 +020029
Jakub Josefa63f9862018-01-11 17:58:38 +010030 stage('Setup virtualenv for Pepper') {
31 python.setupPepperVirtualenv(pepperEnv, SALT_MASTER_URL, SALT_MASTER_CREDENTIALS)
32 }
Ales Komarek1ebb7a82017-08-04 14:58:51 +020033
Jakub Josefa63f9862018-01-11 17:58:38 +010034 //
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
45 test.runConformanceTests(pepperEnv, 'ctl01*', TEST_K8S_API_SERVER, image)
46
47 // collect output
48 sh "mkdir -p ${artifacts_dir}"
49 file_content = salt.getFileContent(pepperEnv, 'ctl01*', '/tmp/' + output_file)
50 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
62 test.runConformanceTests(pepperEnv, 'ctl01*', TEST_K8S_API_SERVER, image)
63
64 // collect output
65 sh "mkdir -p ${artifacts_dir}"
66 file_content = salt.getFileContent(pepperEnv, 'ctl01*', '/tmp/' + output_file)
67 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')) {
76 if (common.checkContains('TEST_DOCKER_INSTALL', 'true')) {
77 test.install_docker(pepperEnv, TEST_TEMPEST_TARGET)
78 }
79
80 stage('Run OpenStack tests') {
81 test.runTempestTests(pepperEnv, TEST_TEMPEST_IMAGE, TEST_TEMPEST_TARGET, TEST_TEMPEST_PATTERN)
82 }
83
84 writeFile(file: 'report.xml', text: salt.getFileContent(pepperEnv, TEST_TEMPEST_TARGET, '/root/report.xml'))
85 junit(keepLongStdio: true, testResults: 'report.xml', healthScaleFactor: Double.parseDouble(TEST_JUNIT_RATIO))
86 def testResults = test.collectJUnitResults(currentBuild.rawBuild.getAction(hudson.tasks.test.AbstractTestResultAction.class))
87 if(testResults){
88 currentBuild.desc = String.format("result: %s", testResults["failed"] / testResults["total"])
89 }
90 }
91 } catch (Throwable e) {
92 currentBuild.result = 'FAILURE'
93 throw e
Ales Komarek1ebb7a82017-08-04 14:58:51 +020094 }
Ales Komarek1ebb7a82017-08-04 14:58:51 +020095 }
96}