blob: a1d84c1460491da3190dea6d836ba7d26b1e79f1 [file] [log] [blame]
Tomáš Kukrálb9957b32017-02-28 14:49:00 +01001/**
2 *
3 * Launch heat stack with basic k8s
4 * Flow parameters:
Jakub Josef3c7915f2017-05-24 11:23:57 +02005 * STACK_NAME Heat stack name
6 * STACK_TYPE Orchestration engine: heat, ''
7 * STACK_INSTALL What should be installed (k8s, openstack, ...)
8 * STACK_TEST What should be tested (k8s, openstack, ...)
9 *
10 * STACK_TEMPLATE_URL URL to git repo with stack templates
11 * STACK_TEMPLATE_BRANCH Stack templates repo branch
12 * STACK_TEMPLATE_CREDENTIALS Credentials to the stack templates repo
13 * STACK_TEMPLATE Heat stack HOT template
14 * STACK_DELETE Delete stack when finished (bool)
15 * STACK_REUSE Reuse stack (don't create one)
16 * STACK_CLEANUP_JOB Name of job for deleting Heat stack
Tomáš Kukrálb9957b32017-02-28 14:49:00 +010017 *
18 * Expected parameters:
Tomáš Kukrálb9957b32017-02-28 14:49:00 +010019 * required for STACK_TYPE=heat
Matthew Mosesohn59fc6482017-06-01 18:53:10 +030020 * HEAT_STACK_ENVIRONMENT Heat stack environmental parameters
21 * HEAT_STACK_ZONE Heat stack availability zone
22 * HEAT_STACK_PUBLIC_NET Heat stack floating IP pool
23 * OPENSTACK_API_URL OpenStack API address
24 * OPENSTACK_API_CREDENTIALS Credentials to the OpenStack API
25 * OPENSTACK_API_PROJECT OpenStack project to connect to
26 * OPENSTACK_API_PROJECT_DOMAIN Domain for OpenStack project
27 * OPENSTACK_API_PROJECT_ID ID for OpenStack project
28 * OPENSTACK_API_USER_DOMAIN Domain for OpenStack user
29 * OPENSTACK_API_CLIENT Versions of OpenStack python clients
30 * OPENSTACK_API_VERSION Version of the OpenStack API (2/3)
Tomáš Kukrálb9957b32017-02-28 14:49:00 +010031 *
32 * SALT_MASTER_CREDENTIALS Credentials to the Salt API
33 *
34 * required for STACK_TYPE=NONE or empty string
35 * SALT_MASTER_URL URL of Salt-API
36
37 * K8S_API_SERVER Kubernetes API address
38 * K8S_CONFORMANCE_IMAGE Path to docker image with conformance e2e tests
39 *
Victor Ryzhenkin5f3b7e62017-03-09 16:02:58 +040040 * TEMPEST_IMAGE_LINK Tempest image link
41 *
Matthew Mosesohna85f24e2017-04-28 13:45:19 +030042 * optional parameters for overwriting soft params
43 * KUBERNETES_HYPERKUBE_IMAGE Docker repository and tag for hyperkube image
Matthew Mosesohnd00a8f52017-05-22 17:07:19 +030044 * CALICO_CNI_IMAGE Docker repository and tag for calico CNI image
45 * CALICO_NODE_IMAGE Docker repository and tag for calico node image
46 * CALICOCTL_IMAGE Docker repository and tag for calicoctl image
Matthew Mosesohn21a0e8e2017-06-06 16:35:08 +030047 * MTU MTU for Calico
Matthew Mosesohn3f2e10a2017-05-24 17:25:37 +030048 * NETCHECKER_AGENT_IMAGE Docker repository and tag for netchecker agent image
Matthew Mosesohn21a0e8e2017-06-06 16:35:08 +030049 * NETCHECKER_SERVER_IMAGE Docker repository and tag for netchecker server image
Matthew Mosesohna85f24e2017-04-28 13:45:19 +030050 *
Tomáš Kukrálb9957b32017-02-28 14:49:00 +010051 */
52
Tomáš Kukrál1f8b5012017-04-28 21:07:10 +020053common = new com.mirantis.mk.Common()
Tomáš Kukrálb9957b32017-02-28 14:49:00 +010054git = new com.mirantis.mk.Git()
55openstack = new com.mirantis.mk.Openstack()
Tomáš Kukrál1f8b5012017-04-28 21:07:10 +020056orchestrate = new com.mirantis.mk.Orchestrate()
Tomáš Kukrálb9957b32017-02-28 14:49:00 +010057salt = new com.mirantis.mk.Salt()
Ondrej Smola8f35e482017-03-30 14:04:36 +020058test = new com.mirantis.mk.Test()
Tomáš Kukrál1f8b5012017-04-28 21:07:10 +020059
Tomáš Kukrálab2f3702017-05-11 09:17:43 +020060_MAX_PERMITTED_STACKS = 2
Tomáš Kukrále80680a2017-03-02 16:34:35 +010061
Tomáš Kukrál9e0fb732017-03-02 10:12:05 +010062timestamps {
63 node {
Jakub Josef96ec3aa2017-05-29 17:53:56 +020064 // try to get STACK_INSTALL or fallback to INSTALL if exists
65 try {
66 def temporary = STACK_INSTALL
67 } catch (MissingPropertyException e) {
68 try {
69 STACK_INSTALL = INSTALL
70 env['STACK_INSTALL'] = INSTALL
71 } catch (MissingPropertyException e2) {
72 common.errorMsg("Property STACK_INSTALL or INSTALL not found!")
73 }
74 }
Tomáš Kukrála18de112017-03-02 13:57:47 +010075 try {
76 //
77 // Prepare machines
78 //
Tomáš Kukrála18de112017-03-02 13:57:47 +010079 stage ('Create infrastructure') {
Tomáš Kukrál6d627d62017-03-23 17:39:07 +010080
Tomáš Kukrála18de112017-03-02 13:57:47 +010081 if (STACK_TYPE == 'heat') {
82 // value defaults
83 def openstackCloud
84 def openstackVersion = OPENSTACK_API_CLIENT ? OPENSTACK_API_CLIENT : 'liberty'
85 def openstackEnv = "${env.WORKSPACE}/venv"
Tomáš Kukrálb9957b32017-02-28 14:49:00 +010086
Jakub Josef3c7915f2017-05-24 11:23:57 +020087 if (STACK_REUSE.toBoolean() == true && STACK_NAME == '') {
Filip Pytloun794ad952017-03-03 10:39:26 +010088 error("If you want to reuse existing stack you need to provide it's name")
89 }
90
Jakub Josef3c7915f2017-05-24 11:23:57 +020091 if (STACK_REUSE.toBoolean() == false) {
Filip Pytloun794ad952017-03-03 10:39:26 +010092 // Don't allow to set custom heat stack name
93 wrap([$class: 'BuildUser']) {
Tomáš Kukrál24d7fe62017-03-03 10:57:11 +010094 if (env.BUILD_USER_ID) {
Jakub Josef3c7915f2017-05-24 11:23:57 +020095 STACK_NAME = "${env.BUILD_USER_ID}-${JOB_NAME}-${BUILD_NUMBER}"
Tomáš Kukrál24d7fe62017-03-03 10:57:11 +010096 } else {
Jakub Josef3c7915f2017-05-24 11:23:57 +020097 STACK_NAME = "jenkins-${JOB_NAME}-${BUILD_NUMBER}"
Tomáš Kukrál24d7fe62017-03-03 10:57:11 +010098 }
Jakub Josef3c7915f2017-05-24 11:23:57 +020099 currentBuild.description = STACK_NAME
Filip Pytloun794ad952017-03-03 10:39:26 +0100100 }
Tomáš Kukrál9e0fb732017-03-02 10:12:05 +0100101 }
Tomáš Kukrála18de112017-03-02 13:57:47 +0100102
Tomáš Kukrálcbabec42017-03-02 16:24:04 +0100103 // set description
Jakub Josef3c7915f2017-05-24 11:23:57 +0200104 currentBuild.description = "${STACK_NAME}"
Tomáš Kukrálcbabec42017-03-02 16:24:04 +0100105
Tomáš Kukrála18de112017-03-02 13:57:47 +0100106 // get templates
Jakub Josef3c7915f2017-05-24 11:23:57 +0200107 git.checkoutGitRepository('template', STACK_TEMPLATE_URL, STACK_TEMPLATE_BRANCH, STACK_TEMPLATE_CREDENTIALS)
Tomáš Kukrála18de112017-03-02 13:57:47 +0100108
109 // create openstack env
110 openstack.setupOpenstackVirtualenv(openstackEnv, openstackVersion)
Matthew Mosesohnbd7976b2017-05-29 19:35:44 +0300111 openstackCloud = openstack.createOpenstackEnv(
112 OPENSTACK_API_URL, OPENSTACK_API_CREDENTIALS,
Matthew Mosesohn59fc6482017-06-01 18:53:10 +0300113 OPENSTACK_API_PROJECT, OPENSTACK_API_PROJECT_DOMAIN,
114 OPENSTACK_API_PROJECT_ID, OPENSTACK_API_USER_DOMAIN,
Matthew Mosesohnbd7976b2017-05-29 19:35:44 +0300115 OPENSTACK_API_VERSION)
Tomáš Kukrála18de112017-03-02 13:57:47 +0100116 openstack.getKeystoneToken(openstackCloud, openstackEnv)
Jakub Josef458913d2017-05-10 15:37:56 +0200117 //
118 // Verify possibility of create stack for given user and stack type
119 //
120 wrap([$class: 'BuildUser']) {
chnydaf23f46b2017-06-05 14:54:27 +0200121 if (env.BUILD_USER_ID && !env.BUILD_USER_ID.equals("jenkins") && !env.BUILD_USER_ID.equals("mceloud") && !STACK_REUSE.toBoolean()) {
Jakub Josef78c3f8b2017-05-10 15:45:29 +0200122 def existingStacks = openstack.getStacksForNameContains(openstackCloud, "${env.BUILD_USER_ID}-${JOB_NAME}", openstackEnv)
123 if(existingStacks.size() >= _MAX_PERMITTED_STACKS){
Jakub Josef3c7915f2017-05-24 11:23:57 +0200124 STACK_DELETE = "false"
Jakub Josef78c3f8b2017-05-10 15:45:29 +0200125 throw new Exception("You cannot create new stack, you already have ${_MAX_PERMITTED_STACKS} stacks of this type (${JOB_NAME}). \nStack names: ${existingStacks}")
126 }
Jakub Josef458913d2017-05-10 15:37:56 +0200127 }
128 }
Tomáš Kukrála18de112017-03-02 13:57:47 +0100129 // launch stack
Jakub Josef3c7915f2017-05-24 11:23:57 +0200130 if (STACK_REUSE.toBoolean() == false) {
Tomáš Kukrála18de112017-03-02 13:57:47 +0100131 stage('Launch new Heat stack') {
132 // create stack
133 envParams = [
134 'instance_zone': HEAT_STACK_ZONE,
135 'public_net': HEAT_STACK_PUBLIC_NET
136 ]
Jakub Josef3c7915f2017-05-24 11:23:57 +0200137 openstack.createHeatStack(openstackCloud, STACK_NAME, STACK_TEMPLATE, envParams, HEAT_STACK_ENVIRONMENT, openstackEnv)
Tomáš Kukrála18de112017-03-02 13:57:47 +0100138 }
139 }
140
141 // get SALT_MASTER_URL
Jakub Josef3c7915f2017-05-24 11:23:57 +0200142 saltMasterHost = openstack.getHeatStackOutputParam(openstackCloud, STACK_NAME, 'salt_master_ip', openstackEnv)
143 currentBuild.description = "${STACK_NAME}: ${saltMasterHost}"
Tomáš Kukrál615aa9c2017-03-04 15:29:08 +0100144
Ales Komarek47a29f12017-04-26 12:05:47 +0200145 SALT_MASTER_URL = "http://${saltMasterHost}:6969"
Tomáš Kukrál9e0fb732017-03-02 10:12:05 +0100146 }
Tomáš Kukrál9e0fb732017-03-02 10:12:05 +0100147 }
Tomáš Kukrál9e0fb732017-03-02 10:12:05 +0100148
Tomáš Kukrála18de112017-03-02 13:57:47 +0100149 //
150 // Connect to Salt master
151 //
Tomáš Kukrál9e0fb732017-03-02 10:12:05 +0100152
Tomáš Kukrála18de112017-03-02 13:57:47 +0100153 def saltMaster
154 stage('Connect to Salt API') {
155 saltMaster = salt.connection(SALT_MASTER_URL, SALT_MASTER_CREDENTIALS)
156 }
Tomáš Kukrál9e0fb732017-03-02 10:12:05 +0100157
Tomáš Kukrála18de112017-03-02 13:57:47 +0100158 //
159 // Install
160 //
Tomáš Kukrál9e0fb732017-03-02 10:12:05 +0100161
Jakub Josef3c7915f2017-05-24 11:23:57 +0200162 if (common.checkContains('STACK_INSTALL', 'core')) {
Tomáš Kukrála18de112017-03-02 13:57:47 +0100163 stage('Install core infrastructure') {
Ales Komarek47a29f12017-04-26 12:05:47 +0200164 orchestrate.installFoundationInfra(saltMaster)
Tomáš Kukrálc265e352017-03-02 11:45:11 +0100165
Jakub Josef3c7915f2017-05-24 11:23:57 +0200166 if (common.checkContains('STACK_INSTALL', 'kvm')) {
Ales Komarek47a29f12017-04-26 12:05:47 +0200167 orchestrate.installInfraKvm(saltMaster)
168 orchestrate.installFoundationInfra(saltMaster)
Tomáš Kukrála18de112017-03-02 13:57:47 +0100169 }
170
Ales Komarek47a29f12017-04-26 12:05:47 +0200171 orchestrate.validateFoundationInfra(saltMaster)
Tomáš Kukrála18de112017-03-02 13:57:47 +0100172 }
173 }
174
175 // install k8s
Jakub Josef3c7915f2017-05-24 11:23:57 +0200176 if (common.checkContains('STACK_INSTALL', 'k8s')) {
vrovachev48ea8622017-06-28 10:28:56 +0400177
178 stage('Overwrite Kubernetes parameters') {
179
180 // Overwrite Kubernetes vars if specified
181 if (env.getEnvironment().containsKey('KUBERNETES_HYPERKUBE_IMAGE')) {
182 salt.runSaltProcessStep(saltMaster, 'I@salt:master', 'reclass.cluster_meta_set', ['kubernetes_hyperkube_image', KUBERNETES_HYPERKUBE_IMAGE])
183 }
184 if (env.getEnvironment().containsKey('MTU')) {
185 salt.runSaltProcessStep(saltMaster, 'I@salt:master', 'reclass.cluster_meta_set', ['kubernetes_mtu', MTU])
186 }
187
188 // Overwrite Calico vars if specified
189 if (env.getEnvironment().containsKey('CALICO_CNI_IMAGE')) {
190 salt.runSaltProcessStep(saltMaster, 'I@salt:master', 'reclass.cluster_meta_set', ['kubernetes_calico_cni_image', CALICO_CNI_IMAGE])
191 }
192 if (env.getEnvironment().containsKey('CALICO_NODE_IMAGE')) {
193 salt.runSaltProcessStep(saltMaster, 'I@salt:master', 'reclass.cluster_meta_set', ['kubernetes_calico_image', CALICO_NODE_IMAGE])
194 }
195 if (env.getEnvironment().containsKey('CALICOCTL_IMAGE')) {
196 salt.runSaltProcessStep(saltMaster, 'I@salt:master', 'reclass.cluster_meta_set', ['kubernetes_calicoctl_image', CALICOCTL_IMAGE])
197 }
198 if (env.getEnvironment().containsKey('CALICO_POLICY_IMAGE')) {
199 salt.runSaltProcessStep(saltMaster, 'I@salt:master', 'reclass.cluster_meta_set', ['kubernetes_calico_policy_image', CALICO_POLICY_IMAGE])
200 }
201
202 // Overwrite Virtlet image if specified
203 if (env.getEnvironment().containsKey('VIRTLET_IMAGE')) {
204 salt.runSaltProcessStep(saltMaster, 'I@salt:master', 'reclass.cluster_meta_set', ['kubernetes_virtlet_image', VIRTLET_IMAGE])
205 }
206
207 // Overwrite netchecker vars if specified
208 if (env.getEnvironment().containsKey('NETCHECKER_AGENT_IMAGE')) {
209 salt.runSaltProcessStep(saltMaster, 'I@salt:master', 'reclass.cluster_meta_set', ['kubernetes_netchecker_agent_image', NETCHECKER_AGENT_IMAGE])
210 }
211 if (env.getEnvironment().containsKey('NETCHECKER_SERVER_IMAGE')) {
212 salt.runSaltProcessStep(saltMaster, 'I@salt:master', 'reclass.cluster_meta_set', ['kubernetes_netchecker_server_image', NETCHECKER_SERVER_IMAGE])
213 }
214
215 // Overwrite docker version if specified
216 if (env.getEnvironment().containsKey('DOCKER_ENGINE')) {
217 salt.runSaltProcessStep(saltMaster, 'I@salt:master', 'reclass.cluster_meta_set', ['kubernetes_docker_package', DOCKER_ENGINE])
218 }
219
220 // Overwrite addons vars if specified
221 if (env.getEnvironment().containsKey('HELM_ENABLED')) {
222 salt.runSaltProcessStep(saltMaster, 'I@salt:master', 'reclass.cluster_meta_set', ['kubernetes_helm_enabled', HELM_ENABLED])
223 }
224 if (env.getEnvironment().containsKey('NETCHECKER_ENABLED')) {
225 salt.runSaltProcessStep(saltMaster, 'I@salt:master', 'reclass.cluster_meta_set', ['kubernetes_netchecker_enabled', NETCHECKER_ENABLED])
226 }
227 if (env.getEnvironment().containsKey('CALICO_POLICY_ENABLED')) {
228 salt.runSaltProcessStep(saltMaster, 'I@salt:master', 'reclass.cluster_meta_set', ['kubernetes_calico_policy_enabled', CALICO_POLICY_ENABLED])
229 }
230 if (env.getEnvironment().containsKey('VIRTLET_ENABLED')) {
231 salt.runSaltProcessStep(saltMaster, 'I@salt:master', 'reclass.cluster_meta_set', ['kubernetes_virtlet_enabled', VIRTLET_ENABLED])
232 }
233 if (env.getEnvironment().containsKey('KUBE_NET_MANAGER_ENABLED')) {
234 salt.runSaltProcessStep(saltMaster, 'I@salt:master', 'reclass.cluster_meta_set', ['kubernetes_kube_network_manager_enabled', KUBE_NET_MANAGER_ENABLED])
235 }
236 }
237
238 // If k8s install with contrail network manager then contrail need to be install first
239 if (common.checkContains('STACK_INSTALL', 'contrail')) {
240 stage('Install Contrail for Kubernetes') {
241 orchestrate.installContrailNetwork(saltMaster)
242 orchestrate.installContrailCompute(saltMaster)
243 orchestrate.installKubernetesContrailCompute(saltMaster)
244 }
245 }
246
Tomáš Kukrála18de112017-03-02 13:57:47 +0100247 stage('Install Kubernetes infra') {
Ales Komarek47a29f12017-04-26 12:05:47 +0200248 orchestrate.installKubernetesInfra(saltMaster)
Tomáš Kukrálc265e352017-03-02 11:45:11 +0100249 }
250
Tomáš Kukrála18de112017-03-02 13:57:47 +0100251 stage('Install Kubernetes control') {
Ales Komarek47a29f12017-04-26 12:05:47 +0200252 orchestrate.installKubernetesControl(saltMaster)
Tomáš Kukrálc265e352017-03-02 11:45:11 +0100253 }
Tomáš Kukrál9e0fb732017-03-02 10:12:05 +0100254 }
255
Tomáš Kukrála18de112017-03-02 13:57:47 +0100256 // install openstack
Jakub Josef3c7915f2017-05-24 11:23:57 +0200257 if (common.checkContains('STACK_INSTALL', 'openstack')) {
Tomáš Kukrála18de112017-03-02 13:57:47 +0100258 // install Infra and control, tests, ...
Tomáš Kukrál9e0fb732017-03-02 10:12:05 +0100259
Tomáš Kukrála18de112017-03-02 13:57:47 +0100260 stage('Install OpenStack infra') {
Ales Komarek47a29f12017-04-26 12:05:47 +0200261 orchestrate.installOpenstackInfra(saltMaster)
Tomáš Kukrálc265e352017-03-02 11:45:11 +0100262 }
263
Tomáš Kukrála18de112017-03-02 13:57:47 +0100264 stage('Install OpenStack control') {
Ales Komarek47a29f12017-04-26 12:05:47 +0200265 orchestrate.installOpenstackControl(saltMaster)
Tomáš Kukrála18de112017-03-02 13:57:47 +0100266 }
267
268 stage('Install OpenStack network') {
Tomáš Kukrála18de112017-03-02 13:57:47 +0100269
Jakub Josef3c7915f2017-05-24 11:23:57 +0200270 if (common.checkContains('STACK_INSTALL', 'contrail')) {
Ales Komarek47a29f12017-04-26 12:05:47 +0200271 orchestrate.installContrailNetwork(saltMaster)
Jakub Josef3c7915f2017-05-24 11:23:57 +0200272 } else if (common.checkContains('STACK_INSTALL', 'ovs')) {
Ales Komarek47a29f12017-04-26 12:05:47 +0200273 orchestrate.installOpenstackNetwork(saltMaster)
Tomáš Kukrála18de112017-03-02 13:57:47 +0100274 }
275
Tomáš Kukrálfbb98322017-05-02 10:38:05 +0200276 salt.runSaltProcessStep(saltMaster, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; neutron net-list'])
277 salt.runSaltProcessStep(saltMaster, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; nova net-list'])
Tomáš Kukrála18de112017-03-02 13:57:47 +0100278 }
279
280 stage('Install OpenStack compute') {
Ales Komarek47a29f12017-04-26 12:05:47 +0200281 orchestrate.installOpenstackCompute(saltMaster)
Tomáš Kukrála18de112017-03-02 13:57:47 +0100282
Jakub Josef3c7915f2017-05-24 11:23:57 +0200283 if (common.checkContains('STACK_INSTALL', 'contrail')) {
Ales Komarek47a29f12017-04-26 12:05:47 +0200284 orchestrate.installContrailCompute(saltMaster)
Tomáš Kukráld5a40af2017-03-07 15:34:58 +0100285 }
Tomáš Kukrála18de112017-03-02 13:57:47 +0100286 }
Tomáš Kukrál2b4c1282017-03-03 17:25:26 +0100287
Tomáš Kukrál00ed1302017-03-03 17:38:40 +0100288 }
Tomáš Kukrál2b4c1282017-03-03 17:25:26 +0100289
Tomáš Kukrál00ed1302017-03-03 17:38:40 +0100290
Martin Polreichbb6f5752017-06-30 12:37:41 +0200291 if (common.checkContains('STACK_INSTALL', 'sl-legacy')) {
292 stage('Install StackLight v1') {
293 orchestrate.installStacklightv1Control(saltMaster)
294 orchestrate.installStacklightv1Client(saltMaster)
295 }
296 }
297
Jakub Josef3c7915f2017-05-24 11:23:57 +0200298 if (common.checkContains('STACK_INSTALL', 'stacklight')) {
Tomáš Kukrál2b4c1282017-03-03 17:25:26 +0100299 stage('Install StackLight') {
Martin Polreichbb6f5752017-06-30 12:37:41 +0200300 orchestrate.installDockerSwarm(saltMaster)
301 orchestrate.installStacklight(saltMaster)
Tomáš Kukrál2b4c1282017-03-03 17:25:26 +0100302 }
Tomáš Kukrál9e0fb732017-03-02 10:12:05 +0100303 }
304
Tomáš Kukrála18de112017-03-02 13:57:47 +0100305 //
306 // Test
307 //
Tomáš Kukrál695d6462017-04-21 16:31:52 +0200308 def artifacts_dir = '_artifacts/'
Tomáš Kukrála18de112017-03-02 13:57:47 +0100309
Jakub Josef3c7915f2017-05-24 11:23:57 +0200310 if (common.checkContains('STACK_TEST', 'k8s')) {
Tomáš Kukrála18de112017-03-02 13:57:47 +0100311 stage('Run k8s bootstrap tests') {
Tomáš Kukrál695d6462017-04-21 16:31:52 +0200312 def image = 'tomkukral/k8s-scripts'
Tomáš Kukrál44ca7fe2017-04-21 16:44:19 +0200313 def output_file = image.replaceAll('/', '-') + '.output'
Tomáš Kukrál695d6462017-04-21 16:31:52 +0200314
Tomáš Kukrálb22826d2017-04-21 16:38:00 +0200315 // run image
316 test.runConformanceTests(saltMaster, K8S_API_SERVER, image)
Tomáš Kukrálf56beed2017-04-21 16:21:06 +0200317
318 // collect output
Tomáš Kukrálf56beed2017-04-21 16:21:06 +0200319 sh "mkdir -p ${artifacts_dir}"
Tomáš Kukrálb22826d2017-04-21 16:38:00 +0200320 file_content = salt.getFileContent(saltMaster, 'ctl01*', '/tmp/' + output_file)
Tomáš Kukrálf56beed2017-04-21 16:21:06 +0200321 writeFile file: "${artifacts_dir}${output_file}", text: file_content
Tomáš Kukrálf56beed2017-04-21 16:21:06 +0200322 sh "cat ${artifacts_dir}${output_file}"
323
324 // collect artifacts
325 archiveArtifacts artifacts: "${artifacts_dir}${output_file}"
Tomáš Kukrála18de112017-03-02 13:57:47 +0100326 }
327
Tomáš Kukrálb22826d2017-04-21 16:38:00 +0200328 stage('Run k8s conformance e2e tests') {
329 //test.runConformanceTests(saltMaster, K8S_API_SERVER, K8S_CONFORMANCE_IMAGE)
330
331 def image = K8S_CONFORMANCE_IMAGE
Tomáš Kukrál44ca7fe2017-04-21 16:44:19 +0200332 def output_file = image.replaceAll('/', '-') + '.output'
Tomáš Kukrálb22826d2017-04-21 16:38:00 +0200333
334 // run image
335 test.runConformanceTests(saltMaster, K8S_API_SERVER, image)
336
337 // collect output
338 sh "mkdir -p ${artifacts_dir}"
339 file_content = salt.getFileContent(saltMaster, 'ctl01*', '/tmp/' + output_file)
340 writeFile file: "${artifacts_dir}${output_file}", text: file_content
341 sh "cat ${artifacts_dir}${output_file}"
342
343 // collect artifacts
344 archiveArtifacts artifacts: "${artifacts_dir}${output_file}"
345 }
Tomáš Kukrál9e0fb732017-03-02 10:12:05 +0100346 }
Tomáš Kukrálb9957b32017-02-28 14:49:00 +0100347
Jakub Josef3c7915f2017-05-24 11:23:57 +0200348 if (common.checkContains('STACK_TEST', 'openstack')) {
Victor Ryzhenkin5f3b7e62017-03-09 16:02:58 +0400349 stage('Run OpenStack tests') {
350 test.runTempestTests(saltMaster, TEMPEST_IMAGE_LINK)
351 }
352
353 stage('Copy Tempest results to config node') {
354 test.copyTempestResults(saltMaster)
355 }
356 }
357
Tomáš Kukrál420d7ff2017-03-21 11:38:33 +0100358 stage('Finalize') {
Jakub Josef3c7915f2017-05-24 11:23:57 +0200359 if (STACK_INSTALL != '') {
Tomáš Kukrál38ab6bb2017-04-21 21:29:31 +0200360 try {
361 salt.runSaltProcessStep(saltMaster, '*', 'state.apply', [], null, true)
362 } catch (Exception e) {
363 common.warningMsg('State apply failed but we should continue to run')
Jakub Josefa6904f12017-05-22 16:37:27 +0200364 throw e
Tomáš Kukrál38ab6bb2017-04-21 21:29:31 +0200365 }
Tomáš Kukrál420d7ff2017-03-21 11:38:33 +0100366 }
367 }
Tomáš Kukrála18de112017-03-02 13:57:47 +0100368 } catch (Throwable e) {
369 currentBuild.result = 'FAILURE'
370 throw e
Tomáš Kukrál65fb5fd2017-03-02 14:56:49 +0100371 } finally {
Tomáš Kukrálb9957b32017-02-28 14:49:00 +0100372
Tomáš Kukrál96b12d52017-03-07 22:43:37 +0100373
Tomáš Kukrála18de112017-03-02 13:57:47 +0100374 //
375 // Clean
376 //
377
Tomáš Kukrálc9a630a2017-03-07 17:28:53 +0100378 if (STACK_TYPE == 'heat') {
Tomáš Kukrál4507c6a2017-03-23 19:00:39 +0100379 // send notification
Jakub Josef3c7915f2017-05-24 11:23:57 +0200380 common.sendNotification(currentBuild.result, STACK_NAME, ["slack"])
Tomáš Kukrál4507c6a2017-03-23 19:00:39 +0100381
Jakub Josef3c7915f2017-05-24 11:23:57 +0200382 if (STACK_DELETE.toBoolean() == true) {
Tomáš Kukrálc9a630a2017-03-07 17:28:53 +0100383 common.errorMsg('Heat job cleanup triggered')
384 stage('Trigger cleanup job') {
Tomáš Kukrálea079922017-06-22 09:12:15 +0200385 build(job: STACK_CLEANUP_JOB, parameters: [
386 [$class: 'StringParameterValue', name: 'STACK_NAME', value: STACK_NAME],
387 [$class: 'StringParameterValue', name: 'STACK_TYPE', value: STACK_TYPE],
388 [$class: 'StringParameterValue', name: 'OPENSTACK_API_URL', value: OPENSTACK_API_URL],
389 [$class: 'StringParameterValue', name: 'OPENSTACK_API_CREDENTIALS', value: OPENSTACK_API_CREDENTIALS],
390 [$class: 'StringParameterValue', name: 'OPENSTACK_API_PROJECT', value: OPENSTACK_API_PROJECT],
391 [$class: 'StringParameterValue', name: 'OPENSTACK_API_PROJECT_DOMAIN', value: OPENSTACK_API_PROJECT_DOMAIN],
392 [$class: 'StringParameterValue', name: 'OPENSTACK_API_PROJECT_ID', value: OPENSTACK_API_PROJECT_ID],
393 [$class: 'StringParameterValue', name: 'OPENSTACK_API_USER_DOMAIN', value: OPENSTACK_API_USER_DOMAIN],
394 [$class: 'StringParameterValue', name: 'OPENSTACK_API_CLIENT', value: OPENSTACK_API_CLIENT],
395 [$class: 'StringParameterValue', name: 'OPENSTACK_API_VERSION', value: OPENSTACK_API_VERSION]
396 ])
Tomáš Kukrálc9a630a2017-03-07 17:28:53 +0100397 }
398 } else {
Tomáš Kukrálbcc53ea2017-03-08 08:15:57 +0100399 if (currentBuild.result == 'FAILURE') {
400 common.errorMsg("Deploy job FAILED and was not deleted. Please fix the problem and delete stack on you own.")
Tomáš Kukrálc9a630a2017-03-07 17:28:53 +0100401
Tomáš Kukrálbcc53ea2017-03-08 08:15:57 +0100402 if (SALT_MASTER_URL) {
403 common.errorMsg("Salt master URL: ${SALT_MASTER_URL}")
404 }
Tomáš Kukrálb908dac2017-03-07 18:58:35 +0100405 }
406
Tomáš Kukrála18de112017-03-02 13:57:47 +0100407 }
Tomáš Kukrál9e0fb732017-03-02 10:12:05 +0100408 }
Tomáš Kukrálb9957b32017-02-28 14:49:00 +0100409 }
410 }
411}