Tomáš Kukrál | b9957b3 | 2017-02-28 14:49:00 +0100 | [diff] [blame] | 1 | /** |
| 2 | * |
| 3 | * Launch heat stack with basic k8s |
| 4 | * Flow parameters: |
| 5 | * STACK_TYPE Orchestration engine: heat, '' |
| 6 | * INSTALL What should be installed (k8s, openstack, ...) |
Tomáš Kukrál | 55357d0 | 2017-02-28 22:56:45 +0100 | [diff] [blame] | 7 | * TEST What should be tested (k8s, openstack, ...) |
Tomáš Kukrál | b9957b3 | 2017-02-28 14:49:00 +0100 | [diff] [blame] | 8 | * |
| 9 | * Expected parameters: |
| 10 | * |
| 11 | * required for STACK_TYPE=heat |
| 12 | * HEAT_TEMPLATE_URL URL to git repo with Heat templates |
| 13 | * HEAT_TEMPLATE_CREDENTIALS Credentials to the Heat templates repo |
| 14 | * HEAT_TEMPLATE_BRANCH Heat templates repo branch |
| 15 | * HEAT_STACK_TEMPLATE Heat stack HOT template |
| 16 | * HEAT_STACK_ENVIRONMENT Heat stack environmental parameters |
| 17 | * HEAT_STACK_ZONE Heat stack availability zone |
| 18 | * HEAT_STACK_PUBLIC_NET Heat stack floating IP pool |
| 19 | * HEAT_STACK_DELETE Delete Heat stack when finished (bool) |
| 20 | * HEAT_STACK_CLEANUP_JOB Name of job for deleting Heat stack |
| 21 | * HEAT_STACK_REUSE Reuse Heat stack (don't create one) |
| 22 | * OPENSTACK_API_URL OpenStack API address |
| 23 | * OPENSTACK_API_CREDENTIALS Credentials to the OpenStack API |
| 24 | * OPENSTACK_API_PROJECT OpenStack project to connect to |
| 25 | * OPENSTACK_API_CLIENT Versions of OpenStack python clients |
| 26 | * OPENSTACK_API_VERSION Version of the OpenStack API (2/3) |
| 27 | * |
| 28 | * SALT_MASTER_CREDENTIALS Credentials to the Salt API |
| 29 | * |
| 30 | * required for STACK_TYPE=NONE or empty string |
| 31 | * SALT_MASTER_URL URL of Salt-API |
| 32 | |
| 33 | * K8S_API_SERVER Kubernetes API address |
| 34 | * K8S_CONFORMANCE_IMAGE Path to docker image with conformance e2e tests |
| 35 | * |
Victor Ryzhenkin | 5f3b7e6 | 2017-03-09 16:02:58 +0400 | [diff] [blame] | 36 | * TEMPEST_IMAGE_LINK Tempest image link |
| 37 | * |
Matthew Mosesohn | a85f24e | 2017-04-28 13:45:19 +0300 | [diff] [blame] | 38 | * optional parameters for overwriting soft params |
| 39 | * KUBERNETES_HYPERKUBE_IMAGE Docker repository and tag for hyperkube image |
| 40 | * |
Tomáš Kukrál | b9957b3 | 2017-02-28 14:49:00 +0100 | [diff] [blame] | 41 | */ |
| 42 | |
Tomáš Kukrál | 1f8b501 | 2017-04-28 21:07:10 +0200 | [diff] [blame] | 43 | common = new com.mirantis.mk.Common() |
Tomáš Kukrál | b9957b3 | 2017-02-28 14:49:00 +0100 | [diff] [blame] | 44 | git = new com.mirantis.mk.Git() |
| 45 | openstack = new com.mirantis.mk.Openstack() |
Tomáš Kukrál | 1f8b501 | 2017-04-28 21:07:10 +0200 | [diff] [blame] | 46 | orchestrate = new com.mirantis.mk.Orchestrate() |
Tomáš Kukrál | b9957b3 | 2017-02-28 14:49:00 +0100 | [diff] [blame] | 47 | salt = new com.mirantis.mk.Salt() |
Ondrej Smola | 8f35e48 | 2017-03-30 14:04:36 +0200 | [diff] [blame] | 48 | test = new com.mirantis.mk.Test() |
Tomáš Kukrál | 1f8b501 | 2017-04-28 21:07:10 +0200 | [diff] [blame] | 49 | |
Tomáš Kukrál | ab2f370 | 2017-05-11 09:17:43 +0200 | [diff] [blame^] | 50 | _MAX_PERMITTED_STACKS = 2 |
Matthew Mosesohn | a85f24e | 2017-04-28 13:45:19 +0300 | [diff] [blame] | 51 | overwriteFile = "/srv/salt/reclass/classes/cluster/overwrite.yml" |
Tomáš Kukrál | e80680a | 2017-03-02 16:34:35 +0100 | [diff] [blame] | 52 | |
Tomáš Kukrál | 9e0fb73 | 2017-03-02 10:12:05 +0100 | [diff] [blame] | 53 | timestamps { |
| 54 | node { |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 55 | try { |
| 56 | // |
| 57 | // Prepare machines |
| 58 | // |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 59 | stage ('Create infrastructure') { |
Tomáš Kukrál | 6d627d6 | 2017-03-23 17:39:07 +0100 | [diff] [blame] | 60 | |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 61 | if (STACK_TYPE == 'heat') { |
| 62 | // value defaults |
| 63 | def openstackCloud |
| 64 | def openstackVersion = OPENSTACK_API_CLIENT ? OPENSTACK_API_CLIENT : 'liberty' |
| 65 | def openstackEnv = "${env.WORKSPACE}/venv" |
Tomáš Kukrál | b9957b3 | 2017-02-28 14:49:00 +0100 | [diff] [blame] | 66 | |
Filip Pytloun | 794ad95 | 2017-03-03 10:39:26 +0100 | [diff] [blame] | 67 | if (HEAT_STACK_REUSE.toBoolean() == true && HEAT_STACK_NAME == '') { |
| 68 | error("If you want to reuse existing stack you need to provide it's name") |
| 69 | } |
| 70 | |
| 71 | if (HEAT_STACK_REUSE.toBoolean() == false) { |
| 72 | // Don't allow to set custom heat stack name |
| 73 | wrap([$class: 'BuildUser']) { |
Tomáš Kukrál | 24d7fe6 | 2017-03-03 10:57:11 +0100 | [diff] [blame] | 74 | if (env.BUILD_USER_ID) { |
| 75 | HEAT_STACK_NAME = "${env.BUILD_USER_ID}-${JOB_NAME}-${BUILD_NUMBER}" |
| 76 | } else { |
| 77 | HEAT_STACK_NAME = "jenkins-${JOB_NAME}-${BUILD_NUMBER}" |
| 78 | } |
Filip Pytloun | 794ad95 | 2017-03-03 10:39:26 +0100 | [diff] [blame] | 79 | currentBuild.description = HEAT_STACK_NAME |
| 80 | } |
Tomáš Kukrál | 9e0fb73 | 2017-03-02 10:12:05 +0100 | [diff] [blame] | 81 | } |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 82 | |
Tomáš Kukrál | cbabec4 | 2017-03-02 16:24:04 +0100 | [diff] [blame] | 83 | // set description |
Tomáš Kukrál | aeb5c92 | 2017-03-02 17:00:48 +0100 | [diff] [blame] | 84 | currentBuild.description = "${HEAT_STACK_NAME}" |
Tomáš Kukrál | cbabec4 | 2017-03-02 16:24:04 +0100 | [diff] [blame] | 85 | |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 86 | // get templates |
| 87 | git.checkoutGitRepository('template', HEAT_TEMPLATE_URL, HEAT_TEMPLATE_BRANCH, HEAT_TEMPLATE_CREDENTIALS) |
| 88 | |
| 89 | // create openstack env |
| 90 | openstack.setupOpenstackVirtualenv(openstackEnv, openstackVersion) |
| 91 | openstackCloud = openstack.createOpenstackEnv(OPENSTACK_API_URL, OPENSTACK_API_CREDENTIALS, OPENSTACK_API_PROJECT) |
| 92 | openstack.getKeystoneToken(openstackCloud, openstackEnv) |
Jakub Josef | 458913d | 2017-05-10 15:37:56 +0200 | [diff] [blame] | 93 | // |
| 94 | // Verify possibility of create stack for given user and stack type |
| 95 | // |
| 96 | wrap([$class: 'BuildUser']) { |
Tomáš Kukrál | ab2f370 | 2017-05-11 09:17:43 +0200 | [diff] [blame^] | 97 | if (env.BUILD_USER_ID && !env.BUILD_USER_ID.equals("jenkins") && !HEAT_STACK_REUSE.toBoolean()) { |
Jakub Josef | 78c3f8b | 2017-05-10 15:45:29 +0200 | [diff] [blame] | 98 | def existingStacks = openstack.getStacksForNameContains(openstackCloud, "${env.BUILD_USER_ID}-${JOB_NAME}", openstackEnv) |
| 99 | if(existingStacks.size() >= _MAX_PERMITTED_STACKS){ |
Jakub Josef | 124403a | 2017-05-10 15:58:06 +0200 | [diff] [blame] | 100 | HEAT_STACK_DELETE = "false" |
Jakub Josef | 78c3f8b | 2017-05-10 15:45:29 +0200 | [diff] [blame] | 101 | throw new Exception("You cannot create new stack, you already have ${_MAX_PERMITTED_STACKS} stacks of this type (${JOB_NAME}). \nStack names: ${existingStacks}") |
| 102 | } |
Jakub Josef | 458913d | 2017-05-10 15:37:56 +0200 | [diff] [blame] | 103 | } |
| 104 | } |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 105 | // launch stack |
Filip Pytloun | 794ad95 | 2017-03-03 10:39:26 +0100 | [diff] [blame] | 106 | if (HEAT_STACK_REUSE.toBoolean() == false) { |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 107 | stage('Launch new Heat stack') { |
| 108 | // create stack |
| 109 | envParams = [ |
| 110 | 'instance_zone': HEAT_STACK_ZONE, |
| 111 | 'public_net': HEAT_STACK_PUBLIC_NET |
| 112 | ] |
| 113 | openstack.createHeatStack(openstackCloud, HEAT_STACK_NAME, HEAT_STACK_TEMPLATE, envParams, HEAT_STACK_ENVIRONMENT, openstackEnv) |
| 114 | } |
| 115 | } |
| 116 | |
| 117 | // get SALT_MASTER_URL |
| 118 | saltMasterHost = openstack.getHeatStackOutputParam(openstackCloud, HEAT_STACK_NAME, 'salt_master_ip', openstackEnv) |
Tomáš Kukrál | aeb5c92 | 2017-03-02 17:00:48 +0100 | [diff] [blame] | 119 | currentBuild.description = "${HEAT_STACK_NAME}: ${saltMasterHost}" |
Tomáš Kukrál | 615aa9c | 2017-03-04 15:29:08 +0100 | [diff] [blame] | 120 | |
Ales Komarek | 47a29f1 | 2017-04-26 12:05:47 +0200 | [diff] [blame] | 121 | SALT_MASTER_URL = "http://${saltMasterHost}:6969" |
Tomáš Kukrál | 9e0fb73 | 2017-03-02 10:12:05 +0100 | [diff] [blame] | 122 | } |
Tomáš Kukrál | 9e0fb73 | 2017-03-02 10:12:05 +0100 | [diff] [blame] | 123 | } |
Tomáš Kukrál | 9e0fb73 | 2017-03-02 10:12:05 +0100 | [diff] [blame] | 124 | |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 125 | // |
| 126 | // Connect to Salt master |
| 127 | // |
Tomáš Kukrál | 9e0fb73 | 2017-03-02 10:12:05 +0100 | [diff] [blame] | 128 | |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 129 | def saltMaster |
| 130 | stage('Connect to Salt API') { |
| 131 | saltMaster = salt.connection(SALT_MASTER_URL, SALT_MASTER_CREDENTIALS) |
| 132 | } |
Tomáš Kukrál | 9e0fb73 | 2017-03-02 10:12:05 +0100 | [diff] [blame] | 133 | |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 134 | // |
| 135 | // Install |
| 136 | // |
Tomáš Kukrál | 9e0fb73 | 2017-03-02 10:12:05 +0100 | [diff] [blame] | 137 | |
Tomáš Kukrál | 6d627d6 | 2017-03-23 17:39:07 +0100 | [diff] [blame] | 138 | if (common.checkContains('INSTALL', 'core')) { |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 139 | stage('Install core infrastructure') { |
Ales Komarek | 47a29f1 | 2017-04-26 12:05:47 +0200 | [diff] [blame] | 140 | orchestrate.installFoundationInfra(saltMaster) |
Tomáš Kukrál | c265e35 | 2017-03-02 11:45:11 +0100 | [diff] [blame] | 141 | |
Tomáš Kukrál | 6d627d6 | 2017-03-23 17:39:07 +0100 | [diff] [blame] | 142 | if (common.checkContains('INSTALL', 'kvm')) { |
Ales Komarek | 47a29f1 | 2017-04-26 12:05:47 +0200 | [diff] [blame] | 143 | orchestrate.installInfraKvm(saltMaster) |
| 144 | orchestrate.installFoundationInfra(saltMaster) |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 145 | } |
| 146 | |
Ales Komarek | 47a29f1 | 2017-04-26 12:05:47 +0200 | [diff] [blame] | 147 | orchestrate.validateFoundationInfra(saltMaster) |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 148 | } |
| 149 | } |
| 150 | |
| 151 | // install k8s |
Tomáš Kukrál | 6d627d6 | 2017-03-23 17:39:07 +0100 | [diff] [blame] | 152 | if (common.checkContains('INSTALL', 'k8s')) { |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 153 | stage('Install Kubernetes infra') { |
Ales Komarek | 47a29f1 | 2017-04-26 12:05:47 +0200 | [diff] [blame] | 154 | orchestrate.installKubernetesInfra(saltMaster) |
Tomáš Kukrál | c265e35 | 2017-03-02 11:45:11 +0100 | [diff] [blame] | 155 | } |
| 156 | |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 157 | stage('Install Kubernetes control') { |
Tomáš Kukrál | 06c27a9 | 2017-03-01 16:21:46 +0100 | [diff] [blame] | 158 | |
Ales Komarek | 47a29f1 | 2017-04-26 12:05:47 +0200 | [diff] [blame] | 159 | // Overwrite Kubernetes vars if specified |
| 160 | if (env.getEnvironment().containsKey("KUBERNETES_HYPERKUBE_IMAGE")) { |
Tomáš Kukrál | fbb9832 | 2017-05-02 10:38:05 +0200 | [diff] [blame] | 161 | salt.runSaltProcessStep(saltMaster, 'I@salt:master', 'file.append', overwriteFile, " kubernetes_hyperkube_image: ${KUBERNETES_HYPERKUBE_IMAGE}") |
Ales Komarek | 47a29f1 | 2017-04-26 12:05:47 +0200 | [diff] [blame] | 162 | } |
Tomáš Kukrál | c265e35 | 2017-03-02 11:45:11 +0100 | [diff] [blame] | 163 | |
Ales Komarek | 47a29f1 | 2017-04-26 12:05:47 +0200 | [diff] [blame] | 164 | orchestrate.installKubernetesControl(saltMaster) |
Tomáš Kukrál | c265e35 | 2017-03-02 11:45:11 +0100 | [diff] [blame] | 165 | } |
Tomáš Kukrál | 9e0fb73 | 2017-03-02 10:12:05 +0100 | [diff] [blame] | 166 | } |
| 167 | |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 168 | // install openstack |
Tomáš Kukrál | 6d627d6 | 2017-03-23 17:39:07 +0100 | [diff] [blame] | 169 | if (common.checkContains('INSTALL', 'openstack')) { |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 170 | // install Infra and control, tests, ... |
Tomáš Kukrál | 9e0fb73 | 2017-03-02 10:12:05 +0100 | [diff] [blame] | 171 | |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 172 | stage('Install OpenStack infra') { |
Ales Komarek | 47a29f1 | 2017-04-26 12:05:47 +0200 | [diff] [blame] | 173 | orchestrate.installOpenstackInfra(saltMaster) |
Tomáš Kukrál | c265e35 | 2017-03-02 11:45:11 +0100 | [diff] [blame] | 174 | } |
| 175 | |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 176 | stage('Install OpenStack control') { |
Ales Komarek | 47a29f1 | 2017-04-26 12:05:47 +0200 | [diff] [blame] | 177 | orchestrate.installOpenstackControl(saltMaster) |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 178 | } |
| 179 | |
| 180 | stage('Install OpenStack network') { |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 181 | |
Tomáš Kukrál | 6d627d6 | 2017-03-23 17:39:07 +0100 | [diff] [blame] | 182 | if (common.checkContains('INSTALL', 'contrail')) { |
Ales Komarek | 47a29f1 | 2017-04-26 12:05:47 +0200 | [diff] [blame] | 183 | orchestrate.installContrailNetwork(saltMaster) |
Tomáš Kukrál | 6d627d6 | 2017-03-23 17:39:07 +0100 | [diff] [blame] | 184 | } else if (common.checkContains('INSTALL', 'ovs')) { |
Ales Komarek | 47a29f1 | 2017-04-26 12:05:47 +0200 | [diff] [blame] | 185 | orchestrate.installOpenstackNetwork(saltMaster) |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 186 | } |
| 187 | |
Tomáš Kukrál | fbb9832 | 2017-05-02 10:38:05 +0200 | [diff] [blame] | 188 | salt.runSaltProcessStep(saltMaster, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; neutron net-list']) |
| 189 | salt.runSaltProcessStep(saltMaster, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; nova net-list']) |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 190 | } |
| 191 | |
| 192 | stage('Install OpenStack compute') { |
Ales Komarek | 47a29f1 | 2017-04-26 12:05:47 +0200 | [diff] [blame] | 193 | orchestrate.installOpenstackCompute(saltMaster) |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 194 | |
Tomáš Kukrál | 6d627d6 | 2017-03-23 17:39:07 +0100 | [diff] [blame] | 195 | if (common.checkContains('INSTALL', 'contrail')) { |
Ales Komarek | 47a29f1 | 2017-04-26 12:05:47 +0200 | [diff] [blame] | 196 | orchestrate.installContrailCompute(saltMaster) |
Tomáš Kukrál | d5a40af | 2017-03-07 15:34:58 +0100 | [diff] [blame] | 197 | } |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 198 | } |
Tomáš Kukrál | 2b4c128 | 2017-03-03 17:25:26 +0100 | [diff] [blame] | 199 | |
Tomáš Kukrál | 00ed130 | 2017-03-03 17:38:40 +0100 | [diff] [blame] | 200 | } |
Tomáš Kukrál | 2b4c128 | 2017-03-03 17:25:26 +0100 | [diff] [blame] | 201 | |
Tomáš Kukrál | 00ed130 | 2017-03-03 17:38:40 +0100 | [diff] [blame] | 202 | |
Tomáš Kukrál | 6d627d6 | 2017-03-23 17:39:07 +0100 | [diff] [blame] | 203 | if (common.checkContains('INSTALL', 'stacklight')) { |
Tomáš Kukrál | 2b4c128 | 2017-03-03 17:25:26 +0100 | [diff] [blame] | 204 | stage('Install StackLight') { |
Ales Komarek | 47a29f1 | 2017-04-26 12:05:47 +0200 | [diff] [blame] | 205 | orchestrate.installStacklightControl(saltMaster) |
| 206 | orchestrate.installStacklightClient(saltMaster) |
Tomáš Kukrál | 2b4c128 | 2017-03-03 17:25:26 +0100 | [diff] [blame] | 207 | } |
Tomáš Kukrál | 9e0fb73 | 2017-03-02 10:12:05 +0100 | [diff] [blame] | 208 | } |
| 209 | |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 210 | // |
| 211 | // Test |
| 212 | // |
Tomáš Kukrál | 695d646 | 2017-04-21 16:31:52 +0200 | [diff] [blame] | 213 | def artifacts_dir = '_artifacts/' |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 214 | |
Tomáš Kukrál | 6d627d6 | 2017-03-23 17:39:07 +0100 | [diff] [blame] | 215 | if (common.checkContains('TEST', 'k8s')) { |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 216 | stage('Run k8s bootstrap tests') { |
Tomáš Kukrál | 695d646 | 2017-04-21 16:31:52 +0200 | [diff] [blame] | 217 | def image = 'tomkukral/k8s-scripts' |
Tomáš Kukrál | 44ca7fe | 2017-04-21 16:44:19 +0200 | [diff] [blame] | 218 | def output_file = image.replaceAll('/', '-') + '.output' |
Tomáš Kukrál | 695d646 | 2017-04-21 16:31:52 +0200 | [diff] [blame] | 219 | |
Tomáš Kukrál | b22826d | 2017-04-21 16:38:00 +0200 | [diff] [blame] | 220 | // run image |
| 221 | test.runConformanceTests(saltMaster, K8S_API_SERVER, image) |
Tomáš Kukrál | f56beed | 2017-04-21 16:21:06 +0200 | [diff] [blame] | 222 | |
| 223 | // collect output |
Tomáš Kukrál | f56beed | 2017-04-21 16:21:06 +0200 | [diff] [blame] | 224 | sh "mkdir -p ${artifacts_dir}" |
Tomáš Kukrál | b22826d | 2017-04-21 16:38:00 +0200 | [diff] [blame] | 225 | file_content = salt.getFileContent(saltMaster, 'ctl01*', '/tmp/' + output_file) |
Tomáš Kukrál | f56beed | 2017-04-21 16:21:06 +0200 | [diff] [blame] | 226 | writeFile file: "${artifacts_dir}${output_file}", text: file_content |
Tomáš Kukrál | f56beed | 2017-04-21 16:21:06 +0200 | [diff] [blame] | 227 | sh "cat ${artifacts_dir}${output_file}" |
| 228 | |
| 229 | // collect artifacts |
| 230 | archiveArtifacts artifacts: "${artifacts_dir}${output_file}" |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 231 | } |
| 232 | |
Tomáš Kukrál | b22826d | 2017-04-21 16:38:00 +0200 | [diff] [blame] | 233 | stage('Run k8s conformance e2e tests') { |
| 234 | //test.runConformanceTests(saltMaster, K8S_API_SERVER, K8S_CONFORMANCE_IMAGE) |
| 235 | |
| 236 | def image = K8S_CONFORMANCE_IMAGE |
Tomáš Kukrál | 44ca7fe | 2017-04-21 16:44:19 +0200 | [diff] [blame] | 237 | def output_file = image.replaceAll('/', '-') + '.output' |
Tomáš Kukrál | b22826d | 2017-04-21 16:38:00 +0200 | [diff] [blame] | 238 | |
| 239 | // run image |
| 240 | test.runConformanceTests(saltMaster, K8S_API_SERVER, image) |
| 241 | |
| 242 | // collect output |
| 243 | sh "mkdir -p ${artifacts_dir}" |
| 244 | file_content = salt.getFileContent(saltMaster, 'ctl01*', '/tmp/' + output_file) |
| 245 | writeFile file: "${artifacts_dir}${output_file}", text: file_content |
| 246 | sh "cat ${artifacts_dir}${output_file}" |
| 247 | |
| 248 | // collect artifacts |
| 249 | archiveArtifacts artifacts: "${artifacts_dir}${output_file}" |
| 250 | } |
Tomáš Kukrál | 9e0fb73 | 2017-03-02 10:12:05 +0100 | [diff] [blame] | 251 | } |
Tomáš Kukrál | b9957b3 | 2017-02-28 14:49:00 +0100 | [diff] [blame] | 252 | |
Tomáš Kukrál | 6d627d6 | 2017-03-23 17:39:07 +0100 | [diff] [blame] | 253 | if (common.checkContains('TEST', 'openstack')) { |
Victor Ryzhenkin | 5f3b7e6 | 2017-03-09 16:02:58 +0400 | [diff] [blame] | 254 | stage('Run OpenStack tests') { |
| 255 | test.runTempestTests(saltMaster, TEMPEST_IMAGE_LINK) |
| 256 | } |
| 257 | |
| 258 | stage('Copy Tempest results to config node') { |
| 259 | test.copyTempestResults(saltMaster) |
| 260 | } |
| 261 | } |
| 262 | |
Tomáš Kukrál | 420d7ff | 2017-03-21 11:38:33 +0100 | [diff] [blame] | 263 | stage('Finalize') { |
Tomáš Kukrál | 38ab6bb | 2017-04-21 21:29:31 +0200 | [diff] [blame] | 264 | if (INSTALL != '') { |
| 265 | try { |
| 266 | salt.runSaltProcessStep(saltMaster, '*', 'state.apply', [], null, true) |
| 267 | } catch (Exception e) { |
| 268 | common.warningMsg('State apply failed but we should continue to run') |
| 269 | } |
Tomáš Kukrál | 420d7ff | 2017-03-21 11:38:33 +0100 | [diff] [blame] | 270 | } |
| 271 | } |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 272 | } catch (Throwable e) { |
| 273 | currentBuild.result = 'FAILURE' |
| 274 | throw e |
Tomáš Kukrál | 65fb5fd | 2017-03-02 14:56:49 +0100 | [diff] [blame] | 275 | } finally { |
Tomáš Kukrál | b9957b3 | 2017-02-28 14:49:00 +0100 | [diff] [blame] | 276 | |
Tomáš Kukrál | 96b12d5 | 2017-03-07 22:43:37 +0100 | [diff] [blame] | 277 | |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 278 | // |
| 279 | // Clean |
| 280 | // |
| 281 | |
Tomáš Kukrál | c9a630a | 2017-03-07 17:28:53 +0100 | [diff] [blame] | 282 | if (STACK_TYPE == 'heat') { |
Tomáš Kukrál | 4507c6a | 2017-03-23 19:00:39 +0100 | [diff] [blame] | 283 | // send notification |
| 284 | common.sendNotification(currentBuild.result, HEAT_STACK_NAME, ["slack"]) |
| 285 | |
Tomáš Kukrál | c9a630a | 2017-03-07 17:28:53 +0100 | [diff] [blame] | 286 | if (HEAT_STACK_DELETE.toBoolean() == true) { |
| 287 | common.errorMsg('Heat job cleanup triggered') |
| 288 | stage('Trigger cleanup job') { |
| 289 | build job: 'deploy-heat-cleanup', parameters: [[$class: 'StringParameterValue', name: 'HEAT_STACK_NAME', value: HEAT_STACK_NAME]] |
| 290 | } |
| 291 | } else { |
Tomáš Kukrál | bcc53ea | 2017-03-08 08:15:57 +0100 | [diff] [blame] | 292 | if (currentBuild.result == 'FAILURE') { |
| 293 | common.errorMsg("Deploy job FAILED and was not deleted. Please fix the problem and delete stack on you own.") |
Tomáš Kukrál | c9a630a | 2017-03-07 17:28:53 +0100 | [diff] [blame] | 294 | |
Tomáš Kukrál | bcc53ea | 2017-03-08 08:15:57 +0100 | [diff] [blame] | 295 | if (SALT_MASTER_URL) { |
| 296 | common.errorMsg("Salt master URL: ${SALT_MASTER_URL}") |
| 297 | } |
Tomáš Kukrál | b908dac | 2017-03-07 18:58:35 +0100 | [diff] [blame] | 298 | } |
| 299 | |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 300 | } |
Tomáš Kukrál | 9e0fb73 | 2017-03-02 10:12:05 +0100 | [diff] [blame] | 301 | } |
Tomáš Kukrál | b9957b3 | 2017-02-28 14:49:00 +0100 | [diff] [blame] | 302 | } |
| 303 | } |
| 304 | } |