Petr Lomakin | e700ffd | 2017-08-01 10:53:15 -0700 | [diff] [blame] | 1 | /** |
| 2 | * |
| 3 | * Launch validation of the cloud |
| 4 | * |
| 5 | * Expected parameters: |
| 6 | * SALT_MASTER_URL URL of Salt master |
| 7 | * SALT_MASTER_CREDENTIALS Credentials to the Salt API |
| 8 | * |
| 9 | * TEST_IMAGE Docker image link |
| 10 | * TARGET_NODE Salt target for tempest node |
| 11 | * TEMPEST_TEST_SET If not false, run tests matched to pattern only |
| 12 | * RUN_TEMPEST_TESTS If not false, run Tempest tests |
| 13 | * RUN_RALLY_TESTS If not false, run Rally tests |
Dmitrii Kabanov | a67e5a5 | 2017-08-14 16:31:11 -0700 | [diff] [blame^] | 14 | * RUN_K8S_TESTS If not false, run Kubernetes tests |
| 15 | * TEST_K8S_API_SERVER Kubernetes API address |
| 16 | * TEST_K8S_CONFORMANCE_IMAGE Path to docker image with conformance e2e tests |
Petr Lomakin | e700ffd | 2017-08-01 10:53:15 -0700 | [diff] [blame] | 17 | * |
| 18 | */ |
| 19 | |
| 20 | common = new com.mirantis.mk.Common() |
| 21 | salt = new com.mirantis.mk.Salt() |
Dmitrii Kabanov | a67e5a5 | 2017-08-14 16:31:11 -0700 | [diff] [blame^] | 22 | test = new com.mirantis.mk.Test() |
Petr Lomakin | e700ffd | 2017-08-01 10:53:15 -0700 | [diff] [blame] | 23 | validate = new com.mirantis.mcp.Validate() |
| 24 | |
| 25 | def saltMaster |
| 26 | def artifacts_dir = 'validation_artifacts/' |
| 27 | |
| 28 | node() { |
| 29 | try{ |
| 30 | stage('Initialization') { |
| 31 | saltMaster = salt.connection(SALT_MASTER_URL, SALT_MASTER_CREDENTIALS) |
| 32 | } |
| 33 | |
| 34 | stage('Configure') { |
| 35 | validate.installDocker(saltMaster, TARGET_NODE) |
| 36 | sh "mkdir -p ${artifacts_dir}" |
| 37 | validate.runContainerConfiguration(saltMaster, TEST_IMAGE, TARGET_NODE, artifacts_dir) |
| 38 | } |
| 39 | |
| 40 | stage('Run Tempest tests') { |
| 41 | if (RUN_TEMPEST_TESTS.toBoolean() == true) { |
| 42 | validate.runTempestTests(saltMaster, TARGET_NODE, artifacts_dir, TEMPEST_TEST_SET) |
| 43 | } else { |
| 44 | common.infoMsg("Skipping Tempest tests") |
| 45 | } |
| 46 | } |
| 47 | |
| 48 | stage('Run Rally tests') { |
| 49 | if (RUN_RALLY_TESTS.toBoolean() == true) { |
| 50 | validate.runRallyTests(saltMaster, TARGET_NODE, artifacts_dir) |
| 51 | } else { |
| 52 | common.infoMsg("Skipping Rally tests") |
| 53 | } |
| 54 | } |
Dmitrii Kabanov | a67e5a5 | 2017-08-14 16:31:11 -0700 | [diff] [blame^] | 55 | |
| 56 | stage('Run k8s bootstrap tests') { |
| 57 | if (RUN_K8S_TESTS.toBoolean() == true) { |
| 58 | def image = 'tomkukral/k8s-scripts' |
| 59 | def output_file = image.replaceAll('/', '-') + '.output' |
| 60 | |
| 61 | // run image |
| 62 | test.runConformanceTests(saltMaster, TEST_K8S_API_SERVER, image) |
| 63 | |
| 64 | // collect output |
| 65 | def file_content = salt.getFileContent(saltMaster, 'ctl01*', '/tmp/' + output_file) |
| 66 | writeFile file: "${artifacts_dir}${output_file}", text: file_content |
| 67 | } else { |
| 68 | common.infoMsg("Skipping k8s bootstrap tests") |
| 69 | } |
| 70 | } |
| 71 | |
| 72 | stage('Run k8s conformance e2e tests') { |
| 73 | if (RUN_K8S_TESTS.toBoolean() == true) { |
| 74 | def image = TEST_K8S_CONFORMANCE_IMAGE |
| 75 | def output_file = image.replaceAll('/', '-') + '.output' |
| 76 | |
| 77 | // run image |
| 78 | test.runConformanceTests(saltMaster, TEST_K8S_API_SERVER, image) |
| 79 | |
| 80 | // collect output |
| 81 | def file_content = salt.getFileContent(saltMaster, 'ctl01*', '/tmp/' + output_file) |
| 82 | writeFile file: "${artifacts_dir}${output_file}", text: file_content |
| 83 | } else { |
| 84 | common.infoMsg("Skipping k8s conformance e2e tests") |
| 85 | } |
| 86 | } |
| 87 | |
Petr Lomakin | e700ffd | 2017-08-01 10:53:15 -0700 | [diff] [blame] | 88 | stage('Collect results') { |
| 89 | archiveArtifacts artifacts: "${artifacts_dir}/*" |
| 90 | } |
| 91 | } catch (Throwable e) { |
| 92 | // If there was an error or exception thrown, the build failed |
| 93 | currentBuild.result = "FAILURE" |
| 94 | throw e |
| 95 | } finally { |
| 96 | validate.runCleanup(saltMaster, TARGET_NODE, artifacts_dir) |
| 97 | } |
| 98 | } |