blob: ceca57ff2cee12174f803b639b07ad9dbc3ea681 [file] [log] [blame]
Petr Lomakine700ffd2017-08-01 10:53:15 -07001/**
2 *
Oleg Basov3d93f552019-03-27 01:01:20 +01003 * Launch validation of the cloud with Rally
Petr Lomakine700ffd2017-08-01 10:53:15 -07004 *
5 * Expected parameters:
Oleg Basovd4fa3862019-03-05 21:49:12 +01006 *
7 * ACCUMULATE_RESULTS If true, results from the previous build will be used
8 * JOB_TIMEOUT Job timeout in hours
Oleg Basovd4fa3862019-03-05 21:49:12 +01009 * TEST_IMAGE Docker image link
10 * TARGET_NODE Salt target for tempest node
Petr Lomakine700ffd2017-08-01 10:53:15 -070011 * SALT_MASTER_URL URL of Salt master
12 * SALT_MASTER_CREDENTIALS Credentials to the Salt API
13 *
Oleg Basovd4fa3862019-03-05 21:49:12 +010014 * Additional validate job YAML params:
15 *
16 * Rally
17 *
Dmitrii Kabanov9f3b7ed2017-09-29 10:47:36 -070018 * AVAILABILITY_ZONE The name of availability zone
19 * FLOATING_NETWORK The name of the external(floating) network
Oleg Basovd4fa3862019-03-05 21:49:12 +010020 * K8S_RALLY Use Kubernetes Rally plugin for testing K8S cluster
21 * STACKLIGHT_RALLY Use Stacklight Rally plugin for testing Stacklight
Dmitrii Kabanov9f3b7ed2017-09-29 10:47:36 -070022 * RALLY_IMAGE The name of the image for Rally tests
23 * RALLY_FLAVOR The name of the flavor for Rally image
Oleg Basov41c4fe72018-06-10 01:16:58 +020024 * RALLY_PLUGINS_REPO Git repository with Rally plugins
25 * RALLY_PLUGINS_BRANCH Git branch which will be used during the checkout
Dmitrii Kabanovb2f60ee2017-11-10 00:31:50 -080026 * RALLY_CONFIG_REPO Git repository with files for Rally
27 * RALLY_CONFIG_BRANCH Git branch which will be used during the checkout
Sergey Galkin8991e822017-11-29 19:10:46 +040028 * RALLY_SCENARIOS Path to file or directory with rally scenarios
Oleg Basovbf860322018-09-04 20:54:36 +020029 * RALLY_SL_SCENARIOS Path to file or directory with stacklight rally scenarios
Sergey Galkin8991e822017-11-29 19:10:46 +040030 * RALLY_TASK_ARGS_FILE Path to file with rally tests arguments
Oleg Basovd4fa3862019-03-05 21:49:12 +010031 * 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
mkraynovda6b6982018-08-06 17:48:24 +040039 * SKIP_LIST List of the Rally scenarios which should be skipped
Oleg Basovd4fa3862019-03-05 21:49:12 +010040 * REPORT_DIR Path for reports outside docker image
41 *
Petr Lomakine700ffd2017-08-01 10:53:15 -070042 */
43
44common = new com.mirantis.mk.Common()
Dmitrii Kabanova67e5a52017-08-14 16:31:11 -070045test = new com.mirantis.mk.Test()
Petr Lomakine700ffd2017-08-01 10:53:15 -070046validate = new com.mirantis.mcp.Validate()
chnyda625f4b42017-10-11 14:10:31 +020047def python = new com.mirantis.mk.Python()
Petr Lomakine700ffd2017-08-01 10:53:15 -070048
chnyda625f4b42017-10-11 14:10:31 +020049def pepperEnv = "pepperEnv"
Petr Lomakine700ffd2017-08-01 10:53:15 -070050def artifacts_dir = 'validation_artifacts/'
Oleg Basovd4fa3862019-03-05 21:49:12 +010051def VALIDATE_PARAMS = readYaml(text: env.getProperty('VALIDATE_PARAMS')) ?: [:]
52if (! VALIDATE_PARAMS) {
53 throw new Exception("VALIDATE_PARAMS yaml is empty.")
54}
55
Dmitry Tsapikov38f36512018-07-24 15:18:36 +000056if (env.JOB_TIMEOUT == ''){
Sergey Galkin3199a2e2018-05-28 18:55:58 +040057 job_timeout = 12
58} else {
59 job_timeout = env.JOB_TIMEOUT.toInteger()
60}
61timeout(time: job_timeout, unit: 'HOURS') {
Jakub Josefa63f9862018-01-11 17:58:38 +010062 node() {
Oleg Basov3d93f552019-03-27 01:01:20 +010063 try {
64
Jakub Josefa63f9862018-01-11 17:58:38 +010065 stage('Setup virtualenv for Pepper') {
66 python.setupPepperVirtualenv(pepperEnv, SALT_MASTER_URL, SALT_MASTER_CREDENTIALS)
Tetiana Korchakefa4f782017-08-25 10:22:29 -070067 }
Petr Lomakine700ffd2017-08-01 10:53:15 -070068
Jakub Josefa63f9862018-01-11 17:58:38 +010069 stage('Configure') {
Oleg Basov3d93f552019-03-27 01:01:20 +010070 test.install_docker(pepperEnv, TARGET_NODE)
Jakub Josefa63f9862018-01-11 17:58:38 +010071 if (ACCUMULATE_RESULTS.toBoolean() == false) {
72 sh "rm -r ${artifacts_dir}"
73 }
74 sh "mkdir -p ${artifacts_dir}"
Petr Lomakine700ffd2017-08-01 10:53:15 -070075 }
Petr Lomakine700ffd2017-08-01 10:53:15 -070076
Jakub Josefa63f9862018-01-11 17:58:38 +010077 stage('Run Rally tests') {
Dmitrii Kabanov6b9343e2017-08-30 15:30:21 -070078
Oleg Basov3d93f552019-03-27 01:01:20 +010079 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 Josefa63f9862018-01-11 17:58:38 +010090 } else {
Oleg Basov3d93f552019-03-27 01:01:20 +010091 platform['type'] = 'k8s'
Jakub Josefa63f9862018-01-11 17:58:38 +010092 }
Oleg Basov3d93f552019-03-27 01:01:20 +010093 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 Kabanova67e5a52017-08-14 16:31:11 -0700106 }
Dmitrii Kabanova67e5a52017-08-14 16:31:11 -0700107
Jakub Josefa63f9862018-01-11 17:58:38 +0100108 stage('Collect results') {
109 archiveArtifacts artifacts: "${artifacts_dir}/*"
110 }
Oleg Basov3d93f552019-03-27 01:01:20 +0100111
Jakub Josefa63f9862018-01-11 17:58:38 +0100112 } catch (Throwable e) {
Jakub Josefa63f9862018-01-11 17:58:38 +0100113 currentBuild.result = "FAILURE"
114 currentBuild.description = currentBuild.description ? e.message + " " + currentBuild.description : e.message
115 throw e
Tetiana Korchakefa4f782017-08-25 10:22:29 -0700116 }
Petr Lomakine700ffd2017-08-01 10:53:15 -0700117 }
118}