blob: f7cdd64fba7689e047875611f186f9d6f3836d66 [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()
23
24// Define global variables
25def saltMaster
26
27node("python") {
28 try {
29
30 //
31 // Prepare connection
32 //
33 stage ('Connect to salt master') {
34 // Connect to Salt master
35 saltMaster = salt.connection(SALT_MASTER_URL, SALT_MASTER_CREDENTIALS)
36 }
37
38 //
39 // Test
40 //
41 def artifacts_dir = '_artifacts/'
42
43 if (common.checkContains('TEST_SERVICE', 'k8s')) {
44 stage('Run k8s bootstrap tests') {
45 def image = 'tomkukral/k8s-scripts'
46 def output_file = image.replaceAll('/', '-') + '.output'
47
48 // run image
49 test.runConformanceTests(saltMaster, TEST_K8S_API_SERVER, image)
50
51 // collect output
52 sh "mkdir -p ${artifacts_dir}"
53 file_content = salt.getFileContent(saltMaster, 'ctl01*', '/tmp/' + output_file)
54 writeFile file: "${artifacts_dir}${output_file}", text: file_content
55 sh "cat ${artifacts_dir}${output_file}"
56
57 // collect artifacts
58 archiveArtifacts artifacts: "${artifacts_dir}${output_file}"
59 }
60
61 stage('Run k8s conformance e2e tests') {
62 def image = K8S_CONFORMANCE_IMAGE
63 def output_file = image.replaceAll('/', '-') + '.output'
64
65 // run image
66 test.runConformanceTests(saltMaster, TEST_K8S_API_SERVER, image)
67
68 // collect output
69 sh "mkdir -p ${artifacts_dir}"
70 file_content = salt.getFileContent(saltMaster, 'ctl01*', '/tmp/' + output_file)
71 writeFile file: "${artifacts_dir}${output_file}", text: file_content
72 sh "cat ${artifacts_dir}${output_file}"
73
74 // collect artifacts
75 archiveArtifacts artifacts: "${artifacts_dir}${output_file}"
76 }
77 }
78
79 if (common.checkContains('TEST_SERVICE', 'openstack')) {
Tomáš Kukrále7859292017-08-11 13:52:06 +020080 if (common.checkContains('TEST_DOCKER_INSTALL', 'true')) {
81 test.install_docker(saltMaster, TEST_TEMPEST_TARGET)
82 }
Ales Komarek1ebb7a82017-08-04 14:58:51 +020083
Tomáš Kukrále7859292017-08-11 13:52:06 +020084 stage('Run OpenStack tests') {
85 test.runTempestTests(saltMaster, TEST_TEMPEST_IMAGE, TEST_TEMPEST_TARGET, TEST_TEMPEST_PATTERN)
86 }
Tomáš Kukrál503d4912017-08-11 13:01:12 +020087
Tomáš Kukrál457b7c62017-08-11 14:02:40 +020088 writeFile(file: 'report.xml', text: salt.getFileContent(saltMaster, TEST_TEMPEST_TARGET, '/root/report.xml'))
Tomáš Kukrál8689fb32017-08-11 14:13:45 +020089 junit(keepLongStdio: true, testResults: 'report.xml', healthScaleFactor: Double.parseDouble(TEST_JUNIT_RATIO))
Jakub Josefa1ddadf2017-08-18 14:11:29 +020090 def testResults = test.collectJUnitResults(currentBuild.rawBuild.getAction(hudson.tasks.test.AbstractTestResultAction.class))
Jakub Josef17f170c2017-08-18 11:23:24 +020091 if(testResults){
92 currentBuild.desc = String.format("result: %s", testResults["failed"] / testResults["total"])
Jakub Josefb08a94b2017-08-16 13:54:28 +020093 }
Jakub Josefb08a94b2017-08-16 13:54:28 +020094 }
Ales Komarek1ebb7a82017-08-04 14:58:51 +020095 } catch (Throwable e) {
96 currentBuild.result = 'FAILURE'
97 throw e
98 }
99}