blob: cb9265c1c10f836f7f54529c4c335e4fa02af190 [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')) {
80 if (common.checkContains('TEST_DOCKER_INSTALL', 'true')) {
81 test.install_docker(saltMaster, TEST_TEMPEST_TARGET)
82 }
83 stage('Run OpenStack tests') {
84 test.runTempestTests(saltMaster, TEST_TEMPEST_IMAGE, TEST_TEMPEST_TARGET, TEST_TEMPEST_PATTERN)
85 }
86
87 stage('Copy Tempest results to config node') {
88 test.copyTempestResults(saltMaster, TEST_TEMPEST_TARGET)
89 }
90 }
91
92 } catch (Throwable e) {
93 currentBuild.result = 'FAILURE'
94 throw e
95 }
96}