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 |
Dmitrii Kabanov | b2f60ee | 2017-11-10 00:31:50 -0800 | [diff] [blame] | 12 | * TEMPEST_CONFIG_REPO Git repository with configuration files for Tempest |
| 13 | * TEMPEST_CONFIG_BRANCH Git branch which will be used during the checkout |
| 14 | * TEMPEST_REPO Git repository with Tempest |
| 15 | * TEMPEST_VERSION Version of Tempest (tag, branch or commit) |
Petr Lomakin | e700ffd | 2017-08-01 10:53:15 -0700 | [diff] [blame] | 16 | * RUN_TEMPEST_TESTS If not false, run Tempest tests |
| 17 | * RUN_RALLY_TESTS If not false, run Rally tests |
Dmitrii Kabanov | a67e5a5 | 2017-08-14 16:31:11 -0700 | [diff] [blame] | 18 | * RUN_K8S_TESTS If not false, run Kubernetes tests |
Dmitrii Kabanov | 6b9343e | 2017-08-30 15:30:21 -0700 | [diff] [blame] | 19 | * RUN_SPT_TESTS If not false, run SPT tests |
| 20 | * SPT_SSH_USER The name of the user which should be used for ssh to nodes |
Dmitrii Kabanov | 6b9343e | 2017-08-30 15:30:21 -0700 | [diff] [blame] | 21 | * SPT_IMAGE The name of the image for SPT tests |
Dmitrii Kabanov | 9f3b7ed | 2017-09-29 10:47:36 -0700 | [diff] [blame] | 22 | * SPT_IMAGE_USER The name of the user for SPT image |
Dmitrii Kabanov | 6b9343e | 2017-08-30 15:30:21 -0700 | [diff] [blame] | 23 | * SPT_FLAVOR The name of the flavor for SPT image |
Dmitrii Kabanov | 9f3b7ed | 2017-09-29 10:47:36 -0700 | [diff] [blame] | 24 | * AVAILABILITY_ZONE The name of availability zone |
| 25 | * FLOATING_NETWORK The name of the external(floating) network |
| 26 | * RALLY_IMAGE The name of the image for Rally tests |
| 27 | * RALLY_FLAVOR The name of the flavor for Rally image |
Dmitrii Kabanov | b2f60ee | 2017-11-10 00:31:50 -0800 | [diff] [blame] | 28 | * RALLY_CONFIG_REPO Git repository with files for Rally |
| 29 | * RALLY_CONFIG_BRANCH Git branch which will be used during the checkout |
Dmitrii Kabanov | a67e5a5 | 2017-08-14 16:31:11 -0700 | [diff] [blame] | 30 | * TEST_K8S_API_SERVER Kubernetes API address |
| 31 | * TEST_K8S_CONFORMANCE_IMAGE Path to docker image with conformance e2e tests |
Tetiana Korchak | efa4f78 | 2017-08-25 10:22:29 -0700 | [diff] [blame] | 32 | * TEST_K8S_NODE Kubernetes node to run tests from |
| 33 | * GENERATE_REPORT If not false, run report generation command |
| 34 | * ACCUMULATE_RESULTS If true, results from the previous build will be used |
Petr Lomakin | e700ffd | 2017-08-01 10:53:15 -0700 | [diff] [blame] | 35 | * |
| 36 | */ |
| 37 | |
| 38 | common = new com.mirantis.mk.Common() |
Dmitrii Kabanov | a67e5a5 | 2017-08-14 16:31:11 -0700 | [diff] [blame] | 39 | test = new com.mirantis.mk.Test() |
Petr Lomakin | e700ffd | 2017-08-01 10:53:15 -0700 | [diff] [blame] | 40 | validate = new com.mirantis.mcp.Validate() |
chnyda | 625f4b4 | 2017-10-11 14:10:31 +0200 | [diff] [blame] | 41 | def python = new com.mirantis.mk.Python() |
Petr Lomakin | e700ffd | 2017-08-01 10:53:15 -0700 | [diff] [blame] | 42 | |
chnyda | 625f4b4 | 2017-10-11 14:10:31 +0200 | [diff] [blame] | 43 | def pepperEnv = "pepperEnv" |
Petr Lomakin | e700ffd | 2017-08-01 10:53:15 -0700 | [diff] [blame] | 44 | def artifacts_dir = 'validation_artifacts/' |
| 45 | |
| 46 | node() { |
| 47 | try{ |
chnyda | 625f4b4 | 2017-10-11 14:10:31 +0200 | [diff] [blame] | 48 | stage('Setup virtualenv for Pepper') { |
Dmitrii Kabanov | f31c896 | 2017-10-12 21:00:30 -0700 | [diff] [blame] | 49 | python.setupPepperVirtualenv(pepperEnv, SALT_MASTER_URL, SALT_MASTER_CREDENTIALS) |
Petr Lomakin | e700ffd | 2017-08-01 10:53:15 -0700 | [diff] [blame] | 50 | } |
| 51 | |
| 52 | stage('Configure') { |
chnyda | 625f4b4 | 2017-10-11 14:10:31 +0200 | [diff] [blame] | 53 | validate.installDocker(pepperEnv, TARGET_NODE) |
Tetiana Korchak | efa4f78 | 2017-08-25 10:22:29 -0700 | [diff] [blame] | 54 | if (ACCUMULATE_RESULTS.toBoolean() == false) { |
| 55 | sh "rm -r ${artifacts_dir}" |
| 56 | } |
Petr Lomakin | e700ffd | 2017-08-01 10:53:15 -0700 | [diff] [blame] | 57 | sh "mkdir -p ${artifacts_dir}" |
Petr Lomakin | e700ffd | 2017-08-01 10:53:15 -0700 | [diff] [blame] | 58 | } |
| 59 | |
| 60 | stage('Run Tempest tests') { |
| 61 | if (RUN_TEMPEST_TESTS.toBoolean() == true) { |
Dmitrii Kabanov | b2f60ee | 2017-11-10 00:31:50 -0800 | [diff] [blame] | 62 | validate.runTempestTests(pepperEnv, TARGET_NODE, TEST_IMAGE, artifacts_dir, TEMPEST_CONFIG_REPO, TEMPEST_CONFIG_BRANCH, TEMPEST_REPO, TEMPEST_VERSION, TEMPEST_TEST_SET) |
Petr Lomakin | e700ffd | 2017-08-01 10:53:15 -0700 | [diff] [blame] | 63 | } else { |
| 64 | common.infoMsg("Skipping Tempest tests") |
| 65 | } |
| 66 | } |
| 67 | |
| 68 | stage('Run Rally tests') { |
| 69 | if (RUN_RALLY_TESTS.toBoolean() == true) { |
Dmitrii Kabanov | b20f1fc | 2017-10-20 10:40:40 -0700 | [diff] [blame] | 70 | def rally_variables = ["floating_network=${FLOATING_NETWORK}", |
| 71 | "rally_image=${RALLY_IMAGE}", |
| 72 | "rally_flavor=${RALLY_FLAVOR}", |
| 73 | "availability_zone=${AVAILABILITY_ZONE}"] |
Dmitrii Kabanov | b2f60ee | 2017-11-10 00:31:50 -0800 | [diff] [blame] | 74 | validate.runRallyTests(pepperEnv, TARGET_NODE, TEST_IMAGE, artifacts_dir, RALLY_CONFIG_REPO, RALLY_CONFIG_BRANCH, rally_variables) |
Petr Lomakin | e700ffd | 2017-08-01 10:53:15 -0700 | [diff] [blame] | 75 | } else { |
| 76 | common.infoMsg("Skipping Rally tests") |
| 77 | } |
| 78 | } |
Dmitrii Kabanov | a67e5a5 | 2017-08-14 16:31:11 -0700 | [diff] [blame] | 79 | |
Dmitrii Kabanov | 6b9343e | 2017-08-30 15:30:21 -0700 | [diff] [blame] | 80 | stage('Run SPT tests') { |
| 81 | if (RUN_SPT_TESTS.toBoolean() == true) { |
Dmitrii Kabanov | b20f1fc | 2017-10-20 10:40:40 -0700 | [diff] [blame] | 82 | def spt_variables = ["spt_ssh_user=${SPT_SSH_USER}", |
| 83 | "spt_floating_network=${FLOATING_NETWORK}", |
| 84 | "spt_image=${SPT_IMAGE}", |
| 85 | "spt_user=${SPT_IMAGE_USER}", |
| 86 | "spt_flavor=${SPT_FLAVOR}", |
| 87 | "spt_availability_zone=${AVAILABILITY_ZONE}"] |
| 88 | validate.runSptTests(pepperEnv, TARGET_NODE, TEST_IMAGE, artifacts_dir, spt_variables) |
Dmitrii Kabanov | 6b9343e | 2017-08-30 15:30:21 -0700 | [diff] [blame] | 89 | } else { |
| 90 | common.infoMsg("Skipping SPT tests") |
| 91 | } |
| 92 | } |
| 93 | |
Dmitrii Kabanov | a67e5a5 | 2017-08-14 16:31:11 -0700 | [diff] [blame] | 94 | stage('Run k8s bootstrap tests') { |
| 95 | if (RUN_K8S_TESTS.toBoolean() == true) { |
| 96 | def image = 'tomkukral/k8s-scripts' |
Tetiana Korchak | efa4f78 | 2017-08-25 10:22:29 -0700 | [diff] [blame] | 97 | def output_file = 'k8s-bootstrap-tests.txt' |
Tetiana Korchak | efa4f78 | 2017-08-25 10:22:29 -0700 | [diff] [blame] | 98 | def outfile = "/tmp/" + image.replaceAll('/', '-') + '.output' |
chnyda | 625f4b4 | 2017-10-11 14:10:31 +0200 | [diff] [blame] | 99 | test.runConformanceTests(pepperEnv, TEST_K8S_NODE, TEST_K8S_API_SERVER, image) |
Dmitrii Kabanov | a67e5a5 | 2017-08-14 16:31:11 -0700 | [diff] [blame] | 100 | |
chnyda | 625f4b4 | 2017-10-11 14:10:31 +0200 | [diff] [blame] | 101 | def file_content = validate.getFileContent(pepperEnv, TEST_K8S_NODE, outfile) |
Dmitrii Kabanov | a67e5a5 | 2017-08-14 16:31:11 -0700 | [diff] [blame] | 102 | writeFile file: "${artifacts_dir}${output_file}", text: file_content |
| 103 | } else { |
| 104 | common.infoMsg("Skipping k8s bootstrap tests") |
| 105 | } |
| 106 | } |
| 107 | |
| 108 | stage('Run k8s conformance e2e tests') { |
| 109 | if (RUN_K8S_TESTS.toBoolean() == true) { |
| 110 | def image = TEST_K8S_CONFORMANCE_IMAGE |
Tetiana Korchak | efa4f78 | 2017-08-25 10:22:29 -0700 | [diff] [blame] | 111 | def output_file = 'report-k8s-e2e-tests.txt' |
Tetiana Korchak | efa4f78 | 2017-08-25 10:22:29 -0700 | [diff] [blame] | 112 | def outfile = "/tmp/" + image.replaceAll('/', '-') + '.output' |
chnyda | 625f4b4 | 2017-10-11 14:10:31 +0200 | [diff] [blame] | 113 | test.runConformanceTests(pepperEnv, TEST_K8S_NODE, TEST_K8S_API_SERVER, image) |
Dmitrii Kabanov | a67e5a5 | 2017-08-14 16:31:11 -0700 | [diff] [blame] | 114 | |
chnyda | 625f4b4 | 2017-10-11 14:10:31 +0200 | [diff] [blame] | 115 | def file_content = validate.getFileContent(pepperEnv, TEST_K8S_NODE, outfile) |
Dmitrii Kabanov | a67e5a5 | 2017-08-14 16:31:11 -0700 | [diff] [blame] | 116 | writeFile file: "${artifacts_dir}${output_file}", text: file_content |
| 117 | } else { |
| 118 | common.infoMsg("Skipping k8s conformance e2e tests") |
| 119 | } |
| 120 | } |
Tetiana Korchak | efa4f78 | 2017-08-25 10:22:29 -0700 | [diff] [blame] | 121 | stage('Generate report') { |
| 122 | if (GENERATE_REPORT.toBoolean() == true) { |
Dmitrii Kabanov | b20f1fc | 2017-10-20 10:40:40 -0700 | [diff] [blame] | 123 | common.infoMsg("Generating html test report ...") |
| 124 | validate.generateTestReport(pepperEnv, TARGET_NODE, TEST_IMAGE, artifacts_dir) |
Tetiana Korchak | efa4f78 | 2017-08-25 10:22:29 -0700 | [diff] [blame] | 125 | } else { |
| 126 | common.infoMsg("Skipping report generation") |
| 127 | } |
| 128 | } |
Petr Lomakin | e700ffd | 2017-08-01 10:53:15 -0700 | [diff] [blame] | 129 | stage('Collect results') { |
| 130 | archiveArtifacts artifacts: "${artifacts_dir}/*" |
| 131 | } |
| 132 | } catch (Throwable e) { |
| 133 | // If there was an error or exception thrown, the build failed |
| 134 | currentBuild.result = "FAILURE" |
Jakub Josef | d2efd7d | 2017-08-22 17:49:57 +0200 | [diff] [blame] | 135 | currentBuild.description = currentBuild.description ? e.message + " " + currentBuild.description : e.message |
Petr Lomakin | e700ffd | 2017-08-01 10:53:15 -0700 | [diff] [blame] | 136 | throw e |
Petr Lomakin | e700ffd | 2017-08-01 10:53:15 -0700 | [diff] [blame] | 137 | } |
| 138 | } |