Tomáš Kukrál | e8ebe79 | 2017-01-09 10:24:00 +0100 | [diff] [blame] | 1 | /** |
Tomáš Kukrál | 71dae69 | 2017-05-22 16:27:20 +0200 | [diff] [blame] | 2 | * DO NOT USE THIS OUTDATED PIPELINE - add your steps to lab-pipeline |
Tomáš Kukrál | e8ebe79 | 2017-01-09 10:24:00 +0100 | [diff] [blame] | 3 | * |
| 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 Leontovich | 3754a90 | 2017-01-20 18:48:55 +0200 | [diff] [blame] | 21 | * CONFORMANCE_IMAGE Path to docker image with conformance e2e tests |
| 22 | * K8S_API_SERVER Kubernetes API address |
Tomáš Kukrál | 9f3f887 | 2017-01-25 10:30:27 +0100 | [diff] [blame] | 23 | * RUN_TESTS Run test (0/1) |
| 24 | * HEAT_STACK_DELETE Delete Heat stack when finished (0/1) |
Tomáš Kukrál | e8ebe79 | 2017-01-09 10:24:00 +0100 | [diff] [blame] | 25 | */ |
| 26 | |
Tomáš Kukrál | fe063c6 | 2017-02-21 09:37:27 +0100 | [diff] [blame] | 27 | git = new com.mirantis.mk.Git() |
| 28 | openstack = new com.mirantis.mk.Openstack() |
| 29 | salt = new com.mirantis.mk.Salt() |
| 30 | orchestrate = new com.mirantis.mk.Orchestrate() |
Tatyana Leontovich | ebee21c | 2017-02-28 15:06:17 +0200 | [diff] [blame] | 31 | test = new com.mirantis.mk.Test() |
chnyda | 625f4b4 | 2017-10-11 14:10:31 +0200 | [diff] [blame] | 32 | def python = new com.mirantis.mk.Python() |
| 33 | |
Tatyana Leontovich | 776aad8 | 2017-03-06 12:42:48 +0200 | [diff] [blame] | 34 | artifacts_dir = "_artifacts" |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 35 | timeout(time: 12, unit: 'HOURS') { |
| 36 | node { |
Tomáš Kukrál | e8ebe79 | 2017-01-09 10:24:00 +0100 | [diff] [blame] | 37 | |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 38 | // connection objects |
| 39 | def openstackCloud |
Tomáš Kukrál | e8ebe79 | 2017-01-09 10:24:00 +0100 | [diff] [blame] | 40 | |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 41 | // value defaults |
| 42 | def openstackVersion = OPENSTACK_API_CLIENT ? OPENSTACK_API_CLIENT : 'liberty' |
Jakub Josef | 88aaf83 | 2018-01-18 16:18:28 +0100 | [diff] [blame] | 43 | def workspace = common.getWorkspace() |
| 44 | def openstackEnv = "${workspace}/venv" |
| 45 | def pepperEnv = "${workspace}/pepperEnv" |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 46 | if (HEAT_STACK_NAME == "") { |
| 47 | HEAT_STACK_NAME = BUILD_TAG |
Tomáš Kukrál | 023a40b | 2017-02-20 00:17:00 +0100 | [diff] [blame] | 48 | } |
| 49 | |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 50 | stage ('Download Heat templates') { |
| 51 | git.checkoutGitRepository('template', HEAT_TEMPLATE_URL, HEAT_TEMPLATE_BRANCH, HEAT_TEMPLATE_CREDENTIALS) |
Tatyana Leontovich | ebee21c | 2017-02-28 15:06:17 +0200 | [diff] [blame] | 52 | } |
| 53 | |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 54 | stage('Install OpenStack env') { |
| 55 | openstack.setupOpenstackVirtualenv(openstackEnv, openstackVersion) |
Tomáš Kukrál | 9f3f887 | 2017-01-25 10:30:27 +0100 | [diff] [blame] | 56 | } |
Tatyana Leontovich | 776aad8 | 2017-03-06 12:42:48 +0200 | [diff] [blame] | 57 | |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 58 | stage('Connect to OpenStack cloud') { |
Jakub Josef | 88aaf83 | 2018-01-18 16:18:28 +0100 | [diff] [blame] | 59 | openstackCloud = openstack.createOpenstackEnv(openstackEnv, OPENSTACK_API_URL, OPENSTACK_API_CREDENTIALS, OPENSTACK_API_PROJECT, |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 60 | "", OPENSTACK_API_PROJECT_DOMAIN_ID, OPENSTACK_API_USER_DOMAIN_ID, OPENSTACK_API_VERSION) |
| 61 | openstack.getKeystoneToken(openstackCloud, openstackEnv) |
| 62 | } |
| 63 | |
| 64 | stage('Launch new Heat stack') { |
| 65 | envParams = [ |
| 66 | 'instance_zone': HEAT_STACK_ZONE, |
| 67 | 'public_net': HEAT_STACK_PUBLIC_NET |
| 68 | ] |
| 69 | 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) |
| 74 | saltMasterUrl = "http://${saltMasterHost}:8088" |
| 75 | python.setupPepperVirtualenv(pepperEnv, saltMasterUrl, SALT_MASTER_CREDENTIALS) |
| 76 | } |
| 77 | |
| 78 | stage("Install core infra") { |
| 79 | orchestrate.installFoundationInfra(pepperEnv) |
| 80 | orchestrate.validateFoundationInfra(pepperEnv) |
| 81 | } |
| 82 | |
| 83 | stage("Install Kubernetes infra") { |
| 84 | orchestrate.installOpenstackMcpInfra(pepperEnv) |
| 85 | } |
| 86 | |
| 87 | stage("Install Kubernetes control") { |
| 88 | orchestrate.installOpenstackMcpControl(pepperEnv) |
| 89 | } |
| 90 | |
| 91 | if (RUN_TESTS == "1") { |
| 92 | sleep(30) |
| 93 | stage('Run k8s bootstrap tests') { |
| 94 | test.runConformanceTests(pepperEnv, 'ctl01*', K8S_API_SERVER, 'tomkukral/k8s-scripts') |
Tomáš Kukrál | 3c9954c | 2017-03-10 20:29:06 +0100 | [diff] [blame] | 95 | } |
Tatyana Leontovich | 776aad8 | 2017-03-06 12:42:48 +0200 | [diff] [blame] | 96 | |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 97 | stage("Run k8s conformance e2e tests") { |
| 98 | test.runConformanceTests(pepperEnv, 'ctl01*', K8S_API_SERVER, CONFORMANCE_IMAGE) |
| 99 | } |
Tatyana Leontovich | 3754a90 | 2017-01-20 18:48:55 +0200 | [diff] [blame] | 100 | |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 101 | stage("Copy k8s e2e test output to config node ") { |
| 102 | test.copyTestsOutput(pepperEnv,CONFORMANCE_IMAGE) |
| 103 | } |
Tomáš Kukrál | e8ebe79 | 2017-01-09 10:24:00 +0100 | [diff] [blame] | 104 | |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 105 | stage("Copy k8s e2e test output to host ") { |
| 106 | sh ''' |
| 107 | mkdir ${env.WORKSPACE}/${artifacts_dir} |
| 108 | ''' |
| 109 | try { |
| 110 | test.catTestsOutput(pepperEnv,CONFORMANCE_IMAGE) >> ${env.WORKSPACE}/${artifacts_dir}/$CONFORMANCE_IMAGE |
| 111 | } 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}" |
| 117 | } |
| 118 | |
| 119 | } |
| 120 | } |
| 121 | |
| 122 | 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 | } |
| 126 | } |
| 127 | |
| 128 | } |
Tomáš Kukrál | e8ebe79 | 2017-01-09 10:24:00 +0100 | [diff] [blame] | 129 | } |