Ales Komarek | 1ebb7a8 | 2017-08-04 14:58:51 +0200 | [diff] [blame] | 1 | /** |
| 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 | |
| 19 | common = new com.mirantis.mk.Common() |
| 20 | git = new com.mirantis.mk.Git() |
| 21 | salt = new com.mirantis.mk.Salt() |
| 22 | test = new com.mirantis.mk.Test() |
| 23 | |
| 24 | // Define global variables |
| 25 | def saltMaster |
| 26 | |
| 27 | node("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ál | 503d491 | 2017-08-11 13:01:12 +0200 | [diff] [blame^] | 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 | // } |
Ales Komarek | 1ebb7a8 | 2017-08-04 14:58:51 +0200 | [diff] [blame] | 86 | |
Tomáš Kukrál | 503d491 | 2017-08-11 13:01:12 +0200 | [diff] [blame^] | 87 | //stage('Copy Tempest results to config node') { |
| 88 | // test.copyTempestResults(saltMaster, TEST_TEMPEST_TARGET) |
| 89 | // |
| 90 | |
| 91 | def rally_file = salt.getFileContent(saltMaster, TEST_TEMPEST_TARGET, '/root/report.xml') |
| 92 | print(rally_file) |
| 93 | |
| 94 | |
Ales Komarek | 1ebb7a8 | 2017-08-04 14:58:51 +0200 | [diff] [blame] | 95 | } |
| 96 | |
| 97 | } catch (Throwable e) { |
| 98 | currentBuild.result = 'FAILURE' |
| 99 | throw e |
| 100 | } |
| 101 | } |