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