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 |
Dmitrii Kabanov | 6b9343e | 2017-08-30 15:30:21 -0700 | [diff] [blame] | 15 | * RUN_SPT_TESTS If not false, run SPT tests |
| 16 | * SPT_SSH_USER The name of the user which should be used for ssh to nodes |
| 17 | * SPT_FLOATING_NETWORK The name of the external(floating) network |
| 18 | * SPT_IMAGE The name of the image for SPT tests |
| 19 | * SPT_USER The name of the user for SPT image |
| 20 | * SPT_FLAVOR The name of the flavor for SPT image |
| 21 | * SPT_AVAILABILITY_ZONE The name of availability zone |
Dmitrii Kabanov | a67e5a5 | 2017-08-14 16:31:11 -0700 | [diff] [blame] | 22 | * TEST_K8S_API_SERVER Kubernetes API address |
| 23 | * TEST_K8S_CONFORMANCE_IMAGE Path to docker image with conformance e2e tests |
Petr Lomakin | e700ffd | 2017-08-01 10:53:15 -0700 | [diff] [blame] | 24 | * |
| 25 | */ |
| 26 | |
| 27 | common = new com.mirantis.mk.Common() |
| 28 | salt = new com.mirantis.mk.Salt() |
Dmitrii Kabanov | a67e5a5 | 2017-08-14 16:31:11 -0700 | [diff] [blame] | 29 | test = new com.mirantis.mk.Test() |
Petr Lomakin | e700ffd | 2017-08-01 10:53:15 -0700 | [diff] [blame] | 30 | validate = new com.mirantis.mcp.Validate() |
| 31 | |
| 32 | def saltMaster |
| 33 | def artifacts_dir = 'validation_artifacts/' |
| 34 | |
| 35 | node() { |
| 36 | try{ |
| 37 | stage('Initialization') { |
| 38 | saltMaster = salt.connection(SALT_MASTER_URL, SALT_MASTER_CREDENTIALS) |
| 39 | } |
| 40 | |
| 41 | stage('Configure') { |
| 42 | validate.installDocker(saltMaster, TARGET_NODE) |
| 43 | sh "mkdir -p ${artifacts_dir}" |
Dmitrii Kabanov | 6b9343e | 2017-08-30 15:30:21 -0700 | [diff] [blame] | 44 | def spt_variables = "-e spt_ssh_user=${SPT_SSH_USER} " + |
| 45 | "-e spt_floating_network=${SPT_FLOATING_NETWORK} " + |
| 46 | "-e spt_image=${SPT_IMAGE} -e spt_user=${SPT_USER} " + |
| 47 | "-e spt_flavor=${SPT_FLAVOR} -e spt_availability_zone=${SPT_AVAILABILITY_ZONE} " |
| 48 | validate.runContainerConfiguration(saltMaster, TEST_IMAGE, TARGET_NODE, artifacts_dir, spt_variables) |
Petr Lomakin | e700ffd | 2017-08-01 10:53:15 -0700 | [diff] [blame] | 49 | } |
| 50 | |
| 51 | stage('Run Tempest tests') { |
| 52 | if (RUN_TEMPEST_TESTS.toBoolean() == true) { |
| 53 | validate.runTempestTests(saltMaster, TARGET_NODE, artifacts_dir, TEMPEST_TEST_SET) |
| 54 | } else { |
| 55 | common.infoMsg("Skipping Tempest tests") |
| 56 | } |
| 57 | } |
| 58 | |
| 59 | stage('Run Rally tests') { |
| 60 | if (RUN_RALLY_TESTS.toBoolean() == true) { |
| 61 | validate.runRallyTests(saltMaster, TARGET_NODE, artifacts_dir) |
| 62 | } else { |
| 63 | common.infoMsg("Skipping Rally tests") |
| 64 | } |
| 65 | } |
Dmitrii Kabanov | a67e5a5 | 2017-08-14 16:31:11 -0700 | [diff] [blame] | 66 | |
Dmitrii Kabanov | 6b9343e | 2017-08-30 15:30:21 -0700 | [diff] [blame] | 67 | stage('Run SPT tests') { |
| 68 | if (RUN_SPT_TESTS.toBoolean() == true) { |
| 69 | validate.runSptTests(saltMaster, TARGET_NODE, artifacts_dir) |
| 70 | } else { |
| 71 | common.infoMsg("Skipping SPT tests") |
| 72 | } |
| 73 | } |
| 74 | |
Dmitrii Kabanov | a67e5a5 | 2017-08-14 16:31:11 -0700 | [diff] [blame] | 75 | stage('Run k8s bootstrap tests') { |
| 76 | if (RUN_K8S_TESTS.toBoolean() == true) { |
| 77 | def image = 'tomkukral/k8s-scripts' |
| 78 | def output_file = image.replaceAll('/', '-') + '.output' |
| 79 | |
| 80 | // run image |
| 81 | test.runConformanceTests(saltMaster, TEST_K8S_API_SERVER, image) |
| 82 | |
| 83 | // collect output |
| 84 | def file_content = salt.getFileContent(saltMaster, 'ctl01*', '/tmp/' + output_file) |
| 85 | writeFile file: "${artifacts_dir}${output_file}", text: file_content |
| 86 | } else { |
| 87 | common.infoMsg("Skipping k8s bootstrap tests") |
| 88 | } |
| 89 | } |
| 90 | |
| 91 | stage('Run k8s conformance e2e tests') { |
| 92 | if (RUN_K8S_TESTS.toBoolean() == true) { |
| 93 | def image = TEST_K8S_CONFORMANCE_IMAGE |
| 94 | def output_file = image.replaceAll('/', '-') + '.output' |
| 95 | |
| 96 | // run image |
| 97 | test.runConformanceTests(saltMaster, TEST_K8S_API_SERVER, image) |
| 98 | |
| 99 | // collect output |
| 100 | def file_content = salt.getFileContent(saltMaster, 'ctl01*', '/tmp/' + output_file) |
| 101 | writeFile file: "${artifacts_dir}${output_file}", text: file_content |
| 102 | } else { |
| 103 | common.infoMsg("Skipping k8s conformance e2e tests") |
| 104 | } |
| 105 | } |
| 106 | |
Petr Lomakin | e700ffd | 2017-08-01 10:53:15 -0700 | [diff] [blame] | 107 | stage('Collect results') { |
| 108 | archiveArtifacts artifacts: "${artifacts_dir}/*" |
| 109 | } |
| 110 | } catch (Throwable e) { |
| 111 | // If there was an error or exception thrown, the build failed |
| 112 | currentBuild.result = "FAILURE" |
Jakub Josef | d2efd7d | 2017-08-22 17:49:57 +0200 | [diff] [blame] | 113 | currentBuild.description = currentBuild.description ? e.message + " " + currentBuild.description : e.message |
Petr Lomakin | e700ffd | 2017-08-01 10:53:15 -0700 | [diff] [blame] | 114 | throw e |
| 115 | } finally { |
| 116 | validate.runCleanup(saltMaster, TARGET_NODE, artifacts_dir) |
| 117 | } |
| 118 | } |