Alexander Kurenyshev | 2bac457 | 2019-03-21 11:13:34 +0300 | [diff] [blame] | 1 | /** |
| 2 | * |
| 3 | * Deploy env with l2gw and bgpvpn enabled from cc context |
| 4 | * using create-mcp-env job and run test on environment and download artifacts |
| 5 | * |
| 6 | * Expected parameters: |
| 7 | * MCP_ENV_PIPELINES_REFSPEC Used by rollout-mcp-env and delete-heat-stack-for-mcp-env |
| 8 | * MCP_ENV_HEAT_TEMPLATES_REFSPEC Used by rollout-mcp-env |
| 9 | * OPENSTACK_API_PROJECT OpenStack project name |
| 10 | * OPENSTACK_HEAT_AZ OpenStack availability zone |
| 11 | * OPENSTACK_ENVIRONMENT OpenStack environment |
| 12 | * HEAT_STACK_CONTEXT Same as in rollout-mcp-env |
| 13 | * STACK_DELETE Remove stack after test |
| 14 | * COOKIECUTTER_TEMPLATE_CONTEXT_FILE Path to file with base context from heat-templates |
| 15 | * COOKIECUTTER_EXTRA_CONTEXT Overrides base kubernetes_testing context |
| 16 | * EXTRA_REPOS Yaml based extra repos metadata to be added during bootstrap phase |
| 17 | * STACK_NAME The name of a stack in openstack (will be generated if empty) |
| 18 | * CLUSTER_MODEL_OVERRIDES List of cluster model yaml files parameters overrides (same as in create-mcp-env) |
| 19 | * SALT_MASTER_URL Full Salt API address. |
| 20 | * CLUSTER_MODEL_OVERRIDES List of cluster model yaml files parameters overrides (same as in create-mcp-env) |
| 21 | */ |
| 22 | |
| 23 | common = new com.mirantis.mk.Common() |
| 24 | |
| 25 | def setBuildParameters(inputParams, allowedParams){ |
| 26 | def result = [] |
| 27 | allowedParams.each { param -> |
| 28 | if (inputParams.containsKey(param.name)) { |
| 29 | def value = inputParams[param.name] |
| 30 | def value_class = 'StringParameterValue' |
| 31 | switch (param.type) { |
| 32 | case 'boolean': |
| 33 | value = value.toBoolean() |
| 34 | value_class = 'BooleanParameterValue' |
| 35 | break |
| 36 | case 'text': |
| 37 | value_class = 'TextParameterValue' |
| 38 | break |
| 39 | } |
| 40 | result.add([ |
| 41 | $class: value_class, |
| 42 | name: param.name, |
| 43 | value: value, |
| 44 | ]) |
| 45 | } |
| 46 | } |
| 47 | return result |
| 48 | } |
| 49 | |
| 50 | node ('python') { |
| 51 | def stack_name |
| 52 | if (common.validInputParam('STACK_NAME')) { |
| 53 | stack_name = STACK_NAME |
| 54 | } else { |
| 55 | stack_name = BUILD_TAG |
| 56 | } |
| 57 | |
| 58 | currentBuild.description = stack_name |
| 59 | |
| 60 | try { |
| 61 | stage ('Deploy cluster') { |
| 62 | deploy_build = build (job: "create-mcp-env", parameters: [ |
| 63 | [$class: 'StringParameterValue', name: 'REFSPEC', value: MCP_ENV_PIPELINES_REFSPEC], |
| 64 | [$class: 'StringParameterValue', name: 'HEAT_TEMPLATES_REFSPEC', value: MCP_ENV_HEAT_TEMPLATES_REFSPEC], |
| 65 | [$class: 'StringParameterValue', name: 'OS_PROJECT_NAME', value: OPENSTACK_API_PROJECT], |
| 66 | [$class: 'StringParameterValue', name: 'OS_AZ', value: OPENSTACK_HEAT_AZ], |
| 67 | [$class: 'StringParameterValue', name: 'OPENSTACK_ENVIRONMENT', value: OPENSTACK_ENVIRONMENT], |
| 68 | [$class: 'StringParameterValue', name: 'STACK_NAME', value: stack_name], |
| 69 | [$class: 'StringParameterValue', name: 'COOKIECUTTER_TEMPLATE_CONTEXT_FILE', value: COOKIECUTTER_TEMPLATE_CONTEXT_FILE], |
| 70 | [$class: 'TextParameterValue', name: 'HEAT_STACK_CONTEXT', value: HEAT_STACK_CONTEXT], |
| 71 | [$class: 'TextParameterValue', name: 'COOKIECUTTER_EXTRA_CONTEXT', value: COOKIECUTTER_EXTRA_CONTEXT], |
| 72 | [$class: 'TextParameterValue', name: 'EXTRA_REPOS', value: EXTRA_REPOS], |
| 73 | [$class: 'TextParameterValue', name: 'CLUSTER_MODEL_OVERRIDES', value: CLUSTER_MODEL_OVERRIDES], |
| 74 | ] |
| 75 | ) |
| 76 | } |
| 77 | |
| 78 | if (Boolean.valueOf(RUN_TESTS)) { |
| 79 | stage ('Run networking tests') { |
| 80 | common.infoMsg('TODO') |
| 81 | } |
| 82 | } |
| 83 | |
| 84 | // get salt master url |
| 85 | saltMasterUrl = "http://${deploy_build.description.tokenize(' ')[1]}:6969" |
| 86 | |
| 87 | } finally { |
| 88 | if (Boolean.valueOf(STACK_DELETE)) { |
| 89 | stage ('Delete stack') { |
| 90 | common.infoMsg("Trying to delete stack ${stack_name}") |
| 91 | build (job: 'delete-heat-stack-for-mcp-env', propagate: true, parameters: [ |
| 92 | [$class: 'StringParameterValue', name: 'REFSPEC', value: MCP_ENV_PIPELINES_REFSPEC], |
| 93 | [$class: 'StringParameterValue', name: 'OS_PROJECT_NAME', value: OPENSTACK_API_PROJECT], |
| 94 | [$class: 'StringParameterValue', name: 'OPENSTACK_ENVIRONMENT', value: OPENSTACK_ENVIRONMENT], |
| 95 | [$class: 'StringParameterValue', name: 'STACK_NAME', value: stack_name], |
| 96 | ] |
| 97 | ) |
| 98 | } |
| 99 | } |
| 100 | } |
| 101 | } |