Petr Lomakin | e700ffd | 2017-08-01 10:53:15 -0700 | [diff] [blame] | 1 | /** |
| 2 | * |
Oleg Basov | 3d93f55 | 2019-03-27 01:01:20 +0100 | [diff] [blame^] | 3 | * Launch validation of the cloud with Rally |
Petr Lomakin | e700ffd | 2017-08-01 10:53:15 -0700 | [diff] [blame] | 4 | * |
| 5 | * Expected parameters: |
Oleg Basov | d4fa386 | 2019-03-05 21:49:12 +0100 | [diff] [blame] | 6 | * |
| 7 | * ACCUMULATE_RESULTS If true, results from the previous build will be used |
| 8 | * JOB_TIMEOUT Job timeout in hours |
Oleg Basov | d4fa386 | 2019-03-05 21:49:12 +0100 | [diff] [blame] | 9 | * TEST_IMAGE Docker image link |
| 10 | * TARGET_NODE Salt target for tempest node |
Petr Lomakin | e700ffd | 2017-08-01 10:53:15 -0700 | [diff] [blame] | 11 | * SALT_MASTER_URL URL of Salt master |
| 12 | * SALT_MASTER_CREDENTIALS Credentials to the Salt API |
| 13 | * |
Oleg Basov | d4fa386 | 2019-03-05 21:49:12 +0100 | [diff] [blame] | 14 | * Additional validate job YAML params: |
| 15 | * |
| 16 | * Rally |
| 17 | * |
Dmitrii Kabanov | 9f3b7ed | 2017-09-29 10:47:36 -0700 | [diff] [blame] | 18 | * AVAILABILITY_ZONE The name of availability zone |
| 19 | * FLOATING_NETWORK The name of the external(floating) network |
Oleg Basov | d4fa386 | 2019-03-05 21:49:12 +0100 | [diff] [blame] | 20 | * K8S_RALLY Use Kubernetes Rally plugin for testing K8S cluster |
| 21 | * STACKLIGHT_RALLY Use Stacklight Rally plugin for testing Stacklight |
Dmitrii Kabanov | 9f3b7ed | 2017-09-29 10:47:36 -0700 | [diff] [blame] | 22 | * RALLY_IMAGE The name of the image for Rally tests |
| 23 | * RALLY_FLAVOR The name of the flavor for Rally image |
Oleg Basov | 41c4fe7 | 2018-06-10 01:16:58 +0200 | [diff] [blame] | 24 | * RALLY_PLUGINS_REPO Git repository with Rally plugins |
| 25 | * RALLY_PLUGINS_BRANCH Git branch which will be used during the checkout |
Dmitrii Kabanov | b2f60ee | 2017-11-10 00:31:50 -0800 | [diff] [blame] | 26 | * RALLY_CONFIG_REPO Git repository with files for Rally |
| 27 | * RALLY_CONFIG_BRANCH Git branch which will be used during the checkout |
Sergey Galkin | 8991e82 | 2017-11-29 19:10:46 +0400 | [diff] [blame] | 28 | * RALLY_SCENARIOS Path to file or directory with rally scenarios |
Oleg Basov | bf86032 | 2018-09-04 20:54:36 +0200 | [diff] [blame] | 29 | * RALLY_SL_SCENARIOS Path to file or directory with stacklight rally scenarios |
Sergey Galkin | 8991e82 | 2017-11-29 19:10:46 +0400 | [diff] [blame] | 30 | * RALLY_TASK_ARGS_FILE Path to file with rally tests arguments |
Oleg Basov | d4fa386 | 2019-03-05 21:49:12 +0100 | [diff] [blame] | 31 | * RALLY_DB_CONN_STRING Rally-compliant DB connection string for long-term storing |
| 32 | results to external DB |
| 33 | * RALLY_TAGS List of tags for marking Rally tasks. Can be used when |
| 34 | generating Rally trends based on particular group of tasks |
| 35 | * RALLY_TRENDS If enabled, generate Rally trends report. Requires external DB |
| 36 | connection string to be set. If RALLY_TAGS was set, trends will |
| 37 | be generated based on finished tasks with these tags, otherwise |
| 38 | on all the finished tasks available in DB |
mkraynov | da6b698 | 2018-08-06 17:48:24 +0400 | [diff] [blame] | 39 | * SKIP_LIST List of the Rally scenarios which should be skipped |
Oleg Basov | d4fa386 | 2019-03-05 21:49:12 +0100 | [diff] [blame] | 40 | * REPORT_DIR Path for reports outside docker image |
| 41 | * |
Petr Lomakin | e700ffd | 2017-08-01 10:53:15 -0700 | [diff] [blame] | 42 | */ |
| 43 | |
| 44 | common = new com.mirantis.mk.Common() |
Dmitrii Kabanov | a67e5a5 | 2017-08-14 16:31:11 -0700 | [diff] [blame] | 45 | test = new com.mirantis.mk.Test() |
Petr Lomakin | e700ffd | 2017-08-01 10:53:15 -0700 | [diff] [blame] | 46 | validate = new com.mirantis.mcp.Validate() |
chnyda | 625f4b4 | 2017-10-11 14:10:31 +0200 | [diff] [blame] | 47 | def python = new com.mirantis.mk.Python() |
Petr Lomakin | e700ffd | 2017-08-01 10:53:15 -0700 | [diff] [blame] | 48 | |
chnyda | 625f4b4 | 2017-10-11 14:10:31 +0200 | [diff] [blame] | 49 | def pepperEnv = "pepperEnv" |
Petr Lomakin | e700ffd | 2017-08-01 10:53:15 -0700 | [diff] [blame] | 50 | def artifacts_dir = 'validation_artifacts/' |
Oleg Basov | d4fa386 | 2019-03-05 21:49:12 +0100 | [diff] [blame] | 51 | def VALIDATE_PARAMS = readYaml(text: env.getProperty('VALIDATE_PARAMS')) ?: [:] |
| 52 | if (! VALIDATE_PARAMS) { |
| 53 | throw new Exception("VALIDATE_PARAMS yaml is empty.") |
| 54 | } |
| 55 | |
Dmitry Tsapikov | 38f3651 | 2018-07-24 15:18:36 +0000 | [diff] [blame] | 56 | if (env.JOB_TIMEOUT == ''){ |
Sergey Galkin | 3199a2e | 2018-05-28 18:55:58 +0400 | [diff] [blame] | 57 | job_timeout = 12 |
| 58 | } else { |
| 59 | job_timeout = env.JOB_TIMEOUT.toInteger() |
| 60 | } |
| 61 | timeout(time: job_timeout, unit: 'HOURS') { |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 62 | node() { |
Oleg Basov | 3d93f55 | 2019-03-27 01:01:20 +0100 | [diff] [blame^] | 63 | try { |
| 64 | |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 65 | stage('Setup virtualenv for Pepper') { |
| 66 | python.setupPepperVirtualenv(pepperEnv, SALT_MASTER_URL, SALT_MASTER_CREDENTIALS) |
Tetiana Korchak | efa4f78 | 2017-08-25 10:22:29 -0700 | [diff] [blame] | 67 | } |
Petr Lomakin | e700ffd | 2017-08-01 10:53:15 -0700 | [diff] [blame] | 68 | |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 69 | stage('Configure') { |
Oleg Basov | 3d93f55 | 2019-03-27 01:01:20 +0100 | [diff] [blame^] | 70 | test.install_docker(pepperEnv, TARGET_NODE) |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 71 | if (ACCUMULATE_RESULTS.toBoolean() == false) { |
| 72 | sh "rm -r ${artifacts_dir}" |
| 73 | } |
| 74 | sh "mkdir -p ${artifacts_dir}" |
Petr Lomakin | e700ffd | 2017-08-01 10:53:15 -0700 | [diff] [blame] | 75 | } |
Petr Lomakin | e700ffd | 2017-08-01 10:53:15 -0700 | [diff] [blame] | 76 | |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 77 | stage('Run Rally tests') { |
Dmitrii Kabanov | 6b9343e | 2017-08-30 15:30:21 -0700 | [diff] [blame] | 78 | |
Oleg Basov | 3d93f55 | 2019-03-27 01:01:20 +0100 | [diff] [blame^] | 79 | def rally = VALIDATE_PARAMS.get('rally') ?: [] |
| 80 | def tags = rally.get('RALLY_TAGS') ?: [] |
| 81 | def report_dir = rally.REPORT_DIR ?: '/root/qa_results' |
| 82 | def platform = ["type":"unknown", "stacklight_enabled":false] |
| 83 | def rally_variables = [] |
| 84 | if (rally.K8S_RALLY.toBoolean() == false) { |
| 85 | platform['type'] = 'openstack' |
| 86 | rally_variables = ["floating_network=${rally.FLOATING_NETWORK}", |
| 87 | "rally_image=${rally.RALLY_IMAGE}", |
| 88 | "rally_flavor=${rally.RALLY_FLAVOR}", |
| 89 | "availability_zone=${rally.AVAILABILITY_ZONE}"] |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 90 | } else { |
Oleg Basov | 3d93f55 | 2019-03-27 01:01:20 +0100 | [diff] [blame^] | 91 | platform['type'] = 'k8s' |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 92 | } |
Oleg Basov | 3d93f55 | 2019-03-27 01:01:20 +0100 | [diff] [blame^] | 93 | if (rally.STACKLIGHT_RALLY.toBoolean() == true) { |
| 94 | platform['stacklight_enabled'] = true |
| 95 | } |
| 96 | validate.runRallyTests( |
| 97 | pepperEnv, TARGET_NODE, TEST_IMAGE, |
| 98 | platform, artifacts_dir, rally.RALLY_CONFIG_REPO, |
| 99 | rally.RALLY_CONFIG_BRANCH, rally.RALLY_PLUGINS_REPO, |
| 100 | rally.RALLY_PLUGINS_BRANCH, rally.RALLY_SCENARIOS, |
| 101 | rally.RALLY_SL_SCENARIOS, rally.RALLY_TASK_ARGS_FILE, |
| 102 | rally.RALLY_DB_CONN_STRING, tags, |
| 103 | rally.RALLY_TRENDS, rally_variables, |
| 104 | report_dir, rally.SKIP_LIST |
| 105 | ) |
Dmitrii Kabanov | a67e5a5 | 2017-08-14 16:31:11 -0700 | [diff] [blame] | 106 | } |
Dmitrii Kabanov | a67e5a5 | 2017-08-14 16:31:11 -0700 | [diff] [blame] | 107 | |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 108 | stage('Collect results') { |
| 109 | archiveArtifacts artifacts: "${artifacts_dir}/*" |
| 110 | } |
Oleg Basov | 3d93f55 | 2019-03-27 01:01:20 +0100 | [diff] [blame^] | 111 | |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 112 | } catch (Throwable e) { |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 113 | currentBuild.result = "FAILURE" |
| 114 | currentBuild.description = currentBuild.description ? e.message + " " + currentBuild.description : e.message |
| 115 | throw e |
Tetiana Korchak | efa4f78 | 2017-08-25 10:22:29 -0700 | [diff] [blame] | 116 | } |
Petr Lomakin | e700ffd | 2017-08-01 10:53:15 -0700 | [diff] [blame] | 117 | } |
| 118 | } |