blob: e88d4826fe0976a2c5030a82d7d5a73fbef4d1ef [file] [log] [blame]
Tomáš Kukrále8ebe792017-01-09 10:24:00 +01001/**
Tomáš Kukrál71dae692017-05-22 16:27:20 +02002 * DO NOT USE THIS OUTDATED PIPELINE - add your steps to lab-pipeline
Tomáš Kukrále8ebe792017-01-09 10:24:00 +01003 *
4 * Launch heat stack with basic k8s
5 *
6 * Expected parameters:
7 * HEAT_TEMPLATE_URL URL to git repo with Heat templates
8 * HEAT_TEMPLATE_CREDENTIALS Credentials to the Heat templates repo
9 * HEAT_TEMPLATE_BRANCH Heat templates repo branch
10 * OPENSTACK_API_URL OpenStack API address
11 * OPENSTACK_API_CREDENTIALS Credentials to the OpenStack API
12 * OPENSTACK_API_PROJECT OpenStack project to connect to
13 * OPENSTACK_API_CLIENT Versions of OpenStack python clients
14 * OPENSTACK_API_VERSION Version of the OpenStack API (2/3)
15 * SALT_MASTER_CREDENTIALS Credentials to the Salt API
16 * HEAT_STACK_NAME Heat stack name
17 * HEAT_STACK_TEMPLATE Heat stack HOT template
18 * HEAT_STACK_ENVIRONMENT Heat stack environmental parameters
19 * HEAT_STACK_ZONE Heat stack availability zone
20 * HEAT_STACK_PUBLIC_NET Heat stack floating IP pool
Tatyana Leontovich3754a902017-01-20 18:48:55 +020021 * CONFORMANCE_IMAGE Path to docker image with conformance e2e tests
22 * K8S_API_SERVER Kubernetes API address
Tomáš Kukrál9f3f8872017-01-25 10:30:27 +010023 * RUN_TESTS Run test (0/1)
24 * HEAT_STACK_DELETE Delete Heat stack when finished (0/1)
Tomáš Kukrále8ebe792017-01-09 10:24:00 +010025 */
26
Tomáš Kukrálfe063c62017-02-21 09:37:27 +010027git = new com.mirantis.mk.Git()
28openstack = new com.mirantis.mk.Openstack()
29salt = new com.mirantis.mk.Salt()
30orchestrate = new com.mirantis.mk.Orchestrate()
Tatyana Leontovichebee21c2017-02-28 15:06:17 +020031test = new com.mirantis.mk.Test()
chnyda625f4b42017-10-11 14:10:31 +020032def python = new com.mirantis.mk.Python()
33
34def pepperEnv = "pepperEnv"
Tatyana Leontovich776aad82017-03-06 12:42:48 +020035artifacts_dir = "_artifacts"
Tomáš Kukrále8ebe792017-01-09 10:24:00 +010036
37node {
38
39 // connection objects
40 def openstackCloud
Tomáš Kukrále8ebe792017-01-09 10:24:00 +010041
42 // value defaults
Tomáš Kukrálfe063c62017-02-21 09:37:27 +010043 def openstackVersion = OPENSTACK_API_CLIENT ? OPENSTACK_API_CLIENT : 'liberty'
Tomáš Kukrále8ebe792017-01-09 10:24:00 +010044 def openstackEnv = "${env.WORKSPACE}/venv"
45
Tomáš Kukrál00c7bf42017-01-13 13:27:23 +010046 if (HEAT_STACK_NAME == "") {
Tomáš Kukrálfe063c62017-02-21 09:37:27 +010047 HEAT_STACK_NAME = BUILD_TAG
Tomáš Kukrál00c7bf42017-01-13 13:27:23 +010048 }
49
Tomáš Kukrále8ebe792017-01-09 10:24:00 +010050 stage ('Download Heat templates') {
51 git.checkoutGitRepository('template', HEAT_TEMPLATE_URL, HEAT_TEMPLATE_BRANCH, HEAT_TEMPLATE_CREDENTIALS)
52 }
53
54 stage('Install OpenStack env') {
55 openstack.setupOpenstackVirtualenv(openstackEnv, openstackVersion)
56 }
57
58 stage('Connect to OpenStack cloud') {
kairat_kushaev23ba7d72017-05-18 16:13:56 +040059 openstackCloud = openstack.createOpenstackEnv(OPENSTACK_API_URL, OPENSTACK_API_CREDENTIALS, OPENSTACK_API_PROJECT,
Matthew Mosesohnbd7976b2017-05-29 19:35:44 +030060 "", OPENSTACK_API_PROJECT_DOMAIN_ID, OPENSTACK_API_USER_DOMAIN_ID, OPENSTACK_API_VERSION)
Tomáš Kukrále8ebe792017-01-09 10:24:00 +010061 openstack.getKeystoneToken(openstackCloud, openstackEnv)
62 }
63
64 stage('Launch new Heat stack') {
Tomáš Kukrál843b1c12017-02-23 11:37:05 +010065 envParams = [
66 'instance_zone': HEAT_STACK_ZONE,
67 'public_net': HEAT_STACK_PUBLIC_NET
68 ]
Tomáš Kukrále8ebe792017-01-09 10:24:00 +010069 openstack.createHeatStack(openstackCloud, HEAT_STACK_NAME, HEAT_STACK_TEMPLATE, envParams, HEAT_STACK_ENVIRONMENT, openstackEnv)
70 }
71
72 stage("Connect to Salt master") {
73 saltMasterHost = openstack.getHeatStackOutputParam(openstackCloud, HEAT_STACK_NAME, 'salt_master_ip', openstackEnv)
Tomáš Kukrál658944b2017-02-21 18:05:05 +010074 saltMasterUrl = "http://${saltMasterHost}:8088"
Dmitrii Kabanovf31c8962017-10-12 21:00:30 -070075 python.setupPepperVirtualenv(pepperEnv, saltMasterUrl, SALT_MASTER_CREDENTIALS)
Tomáš Kukrále8ebe792017-01-09 10:24:00 +010076 }
77
78 stage("Install core infra") {
chnyda625f4b42017-10-11 14:10:31 +020079 orchestrate.installFoundationInfra(pepperEnv)
80 orchestrate.validateFoundationInfra(pepperEnv)
Tomáš Kukrále8ebe792017-01-09 10:24:00 +010081 }
82
83 stage("Install Kubernetes infra") {
chnyda625f4b42017-10-11 14:10:31 +020084 orchestrate.installOpenstackMcpInfra(pepperEnv)
Tomáš Kukrále8ebe792017-01-09 10:24:00 +010085 }
86
87 stage("Install Kubernetes control") {
chnyda625f4b42017-10-11 14:10:31 +020088 orchestrate.installOpenstackMcpControl(pepperEnv)
Tomáš Kukrále8ebe792017-01-09 10:24:00 +010089 }
90
Tomáš Kukrál75d4bb12017-01-25 10:40:28 +010091 if (RUN_TESTS == "1") {
Bartosz Kupidurae88158a2017-03-28 11:55:59 +020092 sleep(30)
Tomáš Kukrál023a40b2017-02-20 00:17:00 +010093 stage('Run k8s bootstrap tests') {
chnyda625f4b42017-10-11 14:10:31 +020094 test.runConformanceTests(pepperEnv, 'ctl01*', K8S_API_SERVER, 'tomkukral/k8s-scripts')
Tomáš Kukrál023a40b2017-02-20 00:17:00 +010095 }
96
Tomáš Kukrál9f3f8872017-01-25 10:30:27 +010097 stage("Run k8s conformance e2e tests") {
chnyda625f4b42017-10-11 14:10:31 +020098 test.runConformanceTests(pepperEnv, 'ctl01*', K8S_API_SERVER, CONFORMANCE_IMAGE)
Tatyana Leontovichebee21c2017-02-28 15:06:17 +020099 }
100
101 stage("Copy k8s e2e test output to config node ") {
chnyda625f4b42017-10-11 14:10:31 +0200102 test.copyTestsOutput(pepperEnv,CONFORMANCE_IMAGE)
Tomáš Kukrál9f3f8872017-01-25 10:30:27 +0100103 }
Tatyana Leontovich776aad82017-03-06 12:42:48 +0200104
105 stage("Copy k8s e2e test output to host ") {
106 sh '''
107 mkdir ${env.WORKSPACE}/${artifacts_dir}
108 '''
109 try {
chnyda625f4b42017-10-11 14:10:31 +0200110 test.catTestsOutput(pepperEnv,CONFORMANCE_IMAGE) >> ${env.WORKSPACE}/${artifacts_dir}/$CONFORMANCE_IMAGE
Tatyana Leontovich776aad82017-03-06 12:42:48 +0200111 } catch (InterruptedException x) {
112 echo "The job was aborted"
113 } finally {
114 archiveArtifacts allowEmptyArchive: true, artifacts: '_artifacts/*', excludes: null
115 junit keepLongStdio: true, testResults: '_artifacts/**.xml'
116 sh "sudo chown -R jenkins:jenkins ${env.WORKSPACE}"
Tomáš Kukrál3c9954c2017-03-10 20:29:06 +0100117 }
Tatyana Leontovich776aad82017-03-06 12:42:48 +0200118
119 }
Tatyana Leontovich3754a902017-01-20 18:48:55 +0200120 }
121
Tomáš Kukrál7568ca72017-01-16 09:40:35 +0100122 if (HEAT_STACK_DELETE == "1") {
123 stage('Trigger cleanup job') {
124 build job: 'mk-k8s-cleanup', parameters: [[$class: 'StringParameterValue', name: 'HEAT_STACK_NAME', value: HEAT_STACK_NAME]]
125 }
Tomáš Kukrálaba0a7d2017-01-13 14:05:12 +0100126 }
Tomáš Kukrále8ebe792017-01-09 10:24:00 +0100127
128}