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