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 |
Oleg Basov | 41c4fe7 | 2018-06-10 01:16:58 +0200 | [diff] [blame] | 18 | * K8S_RALLY If not false, run Kubernetes Rally tests |
Oleg Basov | bf86032 | 2018-09-04 20:54:36 +0200 | [diff] [blame^] | 19 | * STACKLIGHT_RALLY If not false, run additional Stacklight tests |
Oleg Basov | 41c4fe7 | 2018-06-10 01:16:58 +0200 | [diff] [blame] | 20 | * RUN_K8S_TESTS If not false, run Kubernetes e2e/conformance tests |
Dmitrii Kabanov | 6b9343e | 2017-08-30 15:30:21 -0700 | [diff] [blame] | 21 | * RUN_SPT_TESTS If not false, run SPT tests |
| 22 | * 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] | 23 | * SPT_IMAGE The name of the image for SPT tests |
Dmitrii Kabanov | 9f3b7ed | 2017-09-29 10:47:36 -0700 | [diff] [blame] | 24 | * SPT_IMAGE_USER The name of the user for SPT image |
Dmitrii Kabanov | 6b9343e | 2017-08-30 15:30:21 -0700 | [diff] [blame] | 25 | * SPT_FLAVOR The name of the flavor for SPT image |
Dmitrii Kabanov | 9f3b7ed | 2017-09-29 10:47:36 -0700 | [diff] [blame] | 26 | * AVAILABILITY_ZONE The name of availability zone |
| 27 | * FLOATING_NETWORK The name of the external(floating) network |
| 28 | * RALLY_IMAGE The name of the image for Rally tests |
| 29 | * RALLY_FLAVOR The name of the flavor for Rally image |
Oleg Basov | 41c4fe7 | 2018-06-10 01:16:58 +0200 | [diff] [blame] | 30 | * RALLY_PLUGINS_REPO Git repository with Rally plugins |
| 31 | * RALLY_PLUGINS_BRANCH Git branch which will be used during the checkout |
Dmitrii Kabanov | b2f60ee | 2017-11-10 00:31:50 -0800 | [diff] [blame] | 32 | * RALLY_CONFIG_REPO Git repository with files for Rally |
| 33 | * RALLY_CONFIG_BRANCH Git branch which will be used during the checkout |
Sergey Galkin | 8991e82 | 2017-11-29 19:10:46 +0400 | [diff] [blame] | 34 | * RALLY_SCENARIOS Path to file or directory with rally scenarios |
Oleg Basov | bf86032 | 2018-09-04 20:54:36 +0200 | [diff] [blame^] | 35 | * RALLY_SL_SCENARIOS Path to file or directory with stacklight rally scenarios |
Sergey Galkin | 8991e82 | 2017-11-29 19:10:46 +0400 | [diff] [blame] | 36 | * RALLY_TASK_ARGS_FILE Path to file with rally tests arguments |
Sergey Galkin | 5951137 | 2018-02-13 13:59:41 +0400 | [diff] [blame] | 37 | * REPORT_DIR Path for reports outside docker image |
Dmitrii Kabanov | a67e5a5 | 2017-08-14 16:31:11 -0700 | [diff] [blame] | 38 | * TEST_K8S_API_SERVER Kubernetes API address |
| 39 | * TEST_K8S_CONFORMANCE_IMAGE Path to docker image with conformance e2e tests |
Tetiana Korchak | efa4f78 | 2017-08-25 10:22:29 -0700 | [diff] [blame] | 40 | * TEST_K8S_NODE Kubernetes node to run tests from |
| 41 | * GENERATE_REPORT If not false, run report generation command |
| 42 | * ACCUMULATE_RESULTS If true, results from the previous build will be used |
Sergey Galkin | 3199a2e | 2018-05-28 18:55:58 +0400 | [diff] [blame] | 43 | * JOB_TIMEOUT Job timeout in hours |
mkraynov | da6b698 | 2018-08-06 17:48:24 +0400 | [diff] [blame] | 44 | * SKIP_LIST List of the Rally scenarios which should be skipped |
Oleg Basov | 41c4fe7 | 2018-06-10 01:16:58 +0200 | [diff] [blame] | 45 | * |
Petr Lomakin | e700ffd | 2017-08-01 10:53:15 -0700 | [diff] [blame] | 46 | */ |
| 47 | |
| 48 | common = new com.mirantis.mk.Common() |
Dmitrii Kabanov | a67e5a5 | 2017-08-14 16:31:11 -0700 | [diff] [blame] | 49 | test = new com.mirantis.mk.Test() |
Petr Lomakin | e700ffd | 2017-08-01 10:53:15 -0700 | [diff] [blame] | 50 | validate = new com.mirantis.mcp.Validate() |
chnyda | 625f4b4 | 2017-10-11 14:10:31 +0200 | [diff] [blame] | 51 | def python = new com.mirantis.mk.Python() |
Petr Lomakin | e700ffd | 2017-08-01 10:53:15 -0700 | [diff] [blame] | 52 | |
chnyda | 625f4b4 | 2017-10-11 14:10:31 +0200 | [diff] [blame] | 53 | def pepperEnv = "pepperEnv" |
Petr Lomakin | e700ffd | 2017-08-01 10:53:15 -0700 | [diff] [blame] | 54 | def artifacts_dir = 'validation_artifacts/' |
Dmitry Tsapikov | 38f3651 | 2018-07-24 15:18:36 +0000 | [diff] [blame] | 55 | if (env.JOB_TIMEOUT == ''){ |
Sergey Galkin | 3199a2e | 2018-05-28 18:55:58 +0400 | [diff] [blame] | 56 | job_timeout = 12 |
| 57 | } else { |
| 58 | job_timeout = env.JOB_TIMEOUT.toInteger() |
| 59 | } |
| 60 | timeout(time: job_timeout, unit: 'HOURS') { |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 61 | node() { |
| 62 | try{ |
| 63 | stage('Setup virtualenv for Pepper') { |
| 64 | python.setupPepperVirtualenv(pepperEnv, SALT_MASTER_URL, SALT_MASTER_CREDENTIALS) |
Tetiana Korchak | efa4f78 | 2017-08-25 10:22:29 -0700 | [diff] [blame] | 65 | } |
Petr Lomakin | e700ffd | 2017-08-01 10:53:15 -0700 | [diff] [blame] | 66 | |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 67 | stage('Configure') { |
| 68 | validate.installDocker(pepperEnv, TARGET_NODE) |
| 69 | if (ACCUMULATE_RESULTS.toBoolean() == false) { |
| 70 | sh "rm -r ${artifacts_dir}" |
| 71 | } |
| 72 | sh "mkdir -p ${artifacts_dir}" |
Petr Lomakin | e700ffd | 2017-08-01 10:53:15 -0700 | [diff] [blame] | 73 | } |
Petr Lomakin | e700ffd | 2017-08-01 10:53:15 -0700 | [diff] [blame] | 74 | |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 75 | stage('Run Tempest tests') { |
| 76 | if (RUN_TEMPEST_TESTS.toBoolean() == true) { |
| 77 | validate.runTempestTests(pepperEnv, TARGET_NODE, TEST_IMAGE, artifacts_dir, TEMPEST_CONFIG_REPO, TEMPEST_CONFIG_BRANCH, TEMPEST_REPO, TEMPEST_VERSION, TEMPEST_TEST_SET) |
| 78 | } else { |
| 79 | common.infoMsg("Skipping Tempest tests") |
| 80 | } |
Petr Lomakin | e700ffd | 2017-08-01 10:53:15 -0700 | [diff] [blame] | 81 | } |
Dmitrii Kabanov | a67e5a5 | 2017-08-14 16:31:11 -0700 | [diff] [blame] | 82 | |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 83 | stage('Run Rally tests') { |
| 84 | if (RUN_RALLY_TESTS.toBoolean() == true) { |
Alexander Evseev | b6c6699 | 2018-05-21 17:52:21 +0300 | [diff] [blame] | 85 | def report_dir = env.REPORT_DIR ?: '/root/qa_results' |
Oleg Basov | bf86032 | 2018-09-04 20:54:36 +0200 | [diff] [blame^] | 86 | def platform = ["type":"unknown", "stacklight_enabled":false] |
| 87 | def rally_variables = [] |
Oleg Basov | 41c4fe7 | 2018-06-10 01:16:58 +0200 | [diff] [blame] | 88 | if (K8S_RALLY.toBoolean() == false) { |
Oleg Basov | bf86032 | 2018-09-04 20:54:36 +0200 | [diff] [blame^] | 89 | platform['type'] = 'openstack' |
Oleg Basov | 41c4fe7 | 2018-06-10 01:16:58 +0200 | [diff] [blame] | 90 | rally_variables = ["floating_network=${FLOATING_NETWORK}", |
| 91 | "rally_image=${RALLY_IMAGE}", |
| 92 | "rally_flavor=${RALLY_FLAVOR}", |
| 93 | "availability_zone=${AVAILABILITY_ZONE}"] |
| 94 | } else { |
Oleg Basov | bf86032 | 2018-09-04 20:54:36 +0200 | [diff] [blame^] | 95 | platform['type'] = 'k8s' |
Oleg Basov | 41c4fe7 | 2018-06-10 01:16:58 +0200 | [diff] [blame] | 96 | } |
Oleg Basov | bf86032 | 2018-09-04 20:54:36 +0200 | [diff] [blame^] | 97 | if (STACKLIGHT_RALLY.toBoolean() == true) { |
| 98 | platform['stacklight_enabled'] = true |
| 99 | } |
| 100 | validate.runRallyTests(pepperEnv, TARGET_NODE, TEST_IMAGE, platform, artifacts_dir, RALLY_CONFIG_REPO, RALLY_CONFIG_BRANCH, RALLY_PLUGINS_REPO, RALLY_PLUGINS_BRANCH, RALLY_SCENARIOS, RALLY_SL_SCENARIOS, RALLY_TASK_ARGS_FILE, rally_variables, report_dir, SKIP_LIST) |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 101 | } else { |
| 102 | common.infoMsg("Skipping Rally tests") |
| 103 | } |
Dmitrii Kabanov | 6b9343e | 2017-08-30 15:30:21 -0700 | [diff] [blame] | 104 | } |
Dmitrii Kabanov | 6b9343e | 2017-08-30 15:30:21 -0700 | [diff] [blame] | 105 | |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 106 | stage('Run SPT tests') { |
| 107 | if (RUN_SPT_TESTS.toBoolean() == true) { |
| 108 | def spt_variables = ["spt_ssh_user=${SPT_SSH_USER}", |
| 109 | "spt_floating_network=${FLOATING_NETWORK}", |
| 110 | "spt_image=${SPT_IMAGE}", |
| 111 | "spt_user=${SPT_IMAGE_USER}", |
| 112 | "spt_flavor=${SPT_FLAVOR}", |
| 113 | "spt_availability_zone=${AVAILABILITY_ZONE}"] |
| 114 | validate.runSptTests(pepperEnv, TARGET_NODE, TEST_IMAGE, artifacts_dir, spt_variables) |
| 115 | } else { |
| 116 | common.infoMsg("Skipping SPT tests") |
| 117 | } |
Dmitrii Kabanov | a67e5a5 | 2017-08-14 16:31:11 -0700 | [diff] [blame] | 118 | } |
Dmitrii Kabanov | a67e5a5 | 2017-08-14 16:31:11 -0700 | [diff] [blame] | 119 | |
Oleg Basov | 41c4fe7 | 2018-06-10 01:16:58 +0200 | [diff] [blame] | 120 | stage('Run K8S bootstrap tests') { |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 121 | if (RUN_K8S_TESTS.toBoolean() == true) { |
| 122 | def image = 'tomkukral/k8s-scripts' |
| 123 | def output_file = 'k8s-bootstrap-tests.txt' |
| 124 | def outfile = "/tmp/" + image.replaceAll('/', '-') + '.output' |
| 125 | test.runConformanceTests(pepperEnv, TEST_K8S_NODE, TEST_K8S_API_SERVER, image) |
Dmitrii Kabanov | a67e5a5 | 2017-08-14 16:31:11 -0700 | [diff] [blame] | 126 | |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 127 | def file_content = validate.getFileContent(pepperEnv, TEST_K8S_NODE, outfile) |
| 128 | writeFile file: "${artifacts_dir}${output_file}", text: file_content |
| 129 | } else { |
| 130 | common.infoMsg("Skipping k8s bootstrap tests") |
| 131 | } |
Dmitrii Kabanov | a67e5a5 | 2017-08-14 16:31:11 -0700 | [diff] [blame] | 132 | } |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 133 | |
Oleg Basov | 41c4fe7 | 2018-06-10 01:16:58 +0200 | [diff] [blame] | 134 | stage('Run K8S conformance e2e tests') { |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 135 | if (RUN_K8S_TESTS.toBoolean() == true) { |
| 136 | def image = TEST_K8S_CONFORMANCE_IMAGE |
| 137 | def output_file = 'report-k8s-e2e-tests.txt' |
| 138 | def outfile = "/tmp/" + image.replaceAll('/', '-') + '.output' |
| 139 | test.runConformanceTests(pepperEnv, TEST_K8S_NODE, TEST_K8S_API_SERVER, image) |
| 140 | |
| 141 | def file_content = validate.getFileContent(pepperEnv, TEST_K8S_NODE, outfile) |
| 142 | writeFile file: "${artifacts_dir}${output_file}", text: file_content |
| 143 | } else { |
| 144 | common.infoMsg("Skipping k8s conformance e2e tests") |
| 145 | } |
Tetiana Korchak | efa4f78 | 2017-08-25 10:22:29 -0700 | [diff] [blame] | 146 | } |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 147 | stage('Generate report') { |
| 148 | if (GENERATE_REPORT.toBoolean() == true) { |
| 149 | common.infoMsg("Generating html test report ...") |
| 150 | validate.generateTestReport(pepperEnv, TARGET_NODE, TEST_IMAGE, artifacts_dir) |
| 151 | } else { |
| 152 | common.infoMsg("Skipping report generation") |
| 153 | } |
| 154 | } |
| 155 | stage('Collect results') { |
| 156 | archiveArtifacts artifacts: "${artifacts_dir}/*" |
| 157 | } |
| 158 | } catch (Throwable e) { |
| 159 | // If there was an error or exception thrown, the build failed |
| 160 | currentBuild.result = "FAILURE" |
| 161 | currentBuild.description = currentBuild.description ? e.message + " " + currentBuild.description : e.message |
| 162 | throw e |
Tetiana Korchak | efa4f78 | 2017-08-25 10:22:29 -0700 | [diff] [blame] | 163 | } |
Petr Lomakin | e700ffd | 2017-08-01 10:53:15 -0700 | [diff] [blame] | 164 | } |
| 165 | } |