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