· 6 years ago · Mar 25, 2020, 06:58 PM
1/**
2*
3* Workflow for KaaS bootstrap on VMs and run test suites against deployments
4
5* KAAS_PIPELINE_REFSPEC Refspec for kaas related pipelines, for testing additional pipeline changes, generally using GERRIT_REFSPEC
6* GERRIT_REFSPEC Parameter also used for fetching groovy pipeline from kaas repo [KAAS_PIPELINE_REFSPEC]
7
8* # Variables used to render KaaS bootstrap templates
9* KAAS_EXTERNAL_NETWORK_ID ID of 'public' network, example for EU cloud: bf6b85a1-39db-4582-b0d1-f4291dddb9cf
10* ENV_NAME Used to provide naming for ceed resources
11* CLUSTER_NAME Used to provide common naming for mgmt cluster/machine resources
12* CDN_REGION Preferrable CDN region
13* CUSTOM_LCM_SPEC TODO
14* KAAS_MANAGEMENT_CLUSTER_FLAVOR Flavor name, which will be used for kaas mgmt machines
15* SKIP_BOOTSTRAP_TEMPLATES_CHECK Skip bootstrap templates preflight checks, useful in case of KAAS_CUSTOM_DEPLOYMENT_BOOTSTRAP_TEMPLATES_TARBALL
16*
17* # Variables used to specify tests
18* DEPLOY_CHILD_CLUSTER Deploy child cluster according to specified release version
19* UPGRADE_CHILD_CLUSTER Upgrade child cluster according to specified release version
20* UPGRADE_MGMT_CLUSTER Upgrade mgmt cluster release
21* KAAS_CHILD_CLUSTER_NAME Desired name for child cluster [DEPLOY_CHILD_CLUSTER=true]
22* KAAS_CHILD_CLUSTER_NAMESPACE Desired namespace for child cluster [DEPLOY_CHILD_CLUSTER=true]
23* KAAS_CHILD_CLUSTER_RELEASE_NAME Desired release name for child deployment
24* KAAS_CHILD_CLUSTER_DNS Desired dns for child cluster
25* KAAS_CHILD_CLUSTER_SLAVE_NODES_COUNT Amount of child worker nodes
26*
27* RUN_UI_E2E Run UI e2e tests against mgmt cluster
28* RUN_MGMT_CFM Run SI conformance tests against mgmt cluster
29*
30* # Remote access parameters
31* OPENSTACK_API_CREDENTIALS Jenkins credential ID with OpenStack OS_USERNAME and OS_PASSWORD, example: system-integration-team-ci
32* CLOUD_KEY_NAME OpenStack keypair name to create the 'seed' node in the OpenStack, example: kaas-vm-seed-node
33* SEED_PRIVATE_KEY_CREDENTIAL_ID Jenkins credential ID with username and private key to access the 'seed' node created with CLOUD_KEY_NAME
34*
35* # Variables used to render clouds.yaml for OpenStack
36* OS_AUTH_URL OpenStack auth URL, example for EU cloud: https://ic-eu.ssl.mirantis.net:5000/v3
37* OS_IDENTITY_API_VERSION OpenStack auth API version, example: 3
38* OS_INTERFACE OpenStack endpoints interface, example: public
39* OS_PROJECT_ID OpenStack project ID, used for bootstrap.sh, example for 'systest-team': 7fd2d1904af849ccb2d72fcfb8469c97
40* OS_PROJECT_NAME OpenStack project name, used for si-tests, example: systest-team
41* OS_REGION_NAME OpenStack region name, example: RegionOne
42* OS_USER_DOMAIN_NAME OpenStack domain name, example: default
43* OPENSTACK_ENVIRONMENT OpenStack environment key name for ceed stack cleanup
44*
45* Optional parameters:
46* TOTAL_TIMEOUT Total workflow timeout
47* SI_TESTS_REFSPEC Refspec of patchset in gerrit.mcp.mirantis.com for the kaas/si-tests repository
48* REPORT_TO_TESTRAIL Report test results to TestRail
49* SLACK_CHANNEL_NOTIFY If not empty, send build results in slack channel
50*/
51
52// Changes in below scenario may affect predefined job var-set, described in kaasLibrary.grooby
53scenario_yaml = '''\
54workflow:
55- job: kaas-testing-core-release-artifact
56 parameters:
57 KAAS_RELEASES_REFSPEC:
58 type: StringParameterValue
59 use_variable: GERRIT_REFSPEC
60 KAAS_PIPELINE_REFSPEC:
61 type: StringParameterValue
62 use_variable: KAAS_PIPELINE_REFSPEC
63 artifacts:
64 KAAS_RELEASE_FILE: release_version.txt
65 KAAS_RELEASE_REPO_URL: release_repo_url.txt
66 KAAS_CUSTOM_DEPLOYMENT_RELEASE_REPO_URL: release_custom_repo_url.txt.txt
67
68- job: kaas-testing-core-bootstrap-template-artifact
69 parameters:
70 KAAS_RELEASES_REFSPEC:
71 type: StringParameterValue
72 use_variable: GERRIT_REFSPEC
73 KAAS_PIPELINE_REFSPEC:
74 type: StringParameterValue
75 use_variable: KAAS_PIPELINE_REFSPEC
76 OS_MANAGEMENT_CLUSTER_FLAVOR:
77 type: StringParameterValue
78 use_variable: KAAS_MANAGEMENT_CLUSTER_FLAVOR
79 OS_MANAGEMENT_CLUSTER_NAME:
80 type: StringParameterValue
81 use_variable: CLUSTER_NAME
82 OS_MANAGEMENT_MACHINE_NAME_PREFIX:
83 type: StringParameterValue
84 use_variable: CLUSTER_NAME
85 KAAS_RELEASE_REPO_URL:
86 type: StringParameterValue
87 get_variable_from_url: KAAS_RELEASE_REPO_URL
88 artifacts:
89 KAAS_CUSTOM_DEPLOYMENT_BOOTSTRAP_TEMPLATES_TARBALL: release_custom_bootstrap_templates_url.txt
90
91- job: si-test-create-vm-kaas-management
92 ignore_failed: false
93 parameters:
94 ENV_NAME:
95 type: StringParameterValue
96 use_variable: ENV_NAME
97 CLUSTER_NAME:
98 type: StringParameterValue
99 use_variable: CLUSTER_NAME
100 CDN_REGION:
101 type: StringParameterValue
102 use_variable: CDN_REGION
103 # KaaS Core release customization
104 KAAS_RELEASE_REPO_URL:
105 type: StringParameterValue
106 get_variable_from_url: KAAS_RELEASE_REPO_URL
107 KAAS_RELEASE_FILE:
108 type: StringParameterValue
109 get_variable_from_url: KAAS_RELEASE_FILE
110 KAAS_CUSTOM_DEPLOYMENT_RELEASE_REPO_URL:
111 type: StringParameterValue
112 get_variable_from_url: KAAS_CUSTOM_DEPLOYMENT_RELEASE_REPO_URL
113 KAAS_CUSTOM_DEPLOYMENT_BOOTSTRAP_TEMPLATES_TARBALL:
114 type: StringParameterValue
115 get_variable_from_url: KAAS_CUSTOM_DEPLOYMENT_BOOTSTRAP_TEMPLATES_TARBALL
116 SKIP_BOOTSTRAP_TEMPLATES_CHECK:
117 type: BooleanParameterValue
118 use_variable: SKIP_BOOTSTRAP_TEMPLATES_CHECK
119 KAAS_RELEASES_REFSPEC:
120 type: StringParameterValue
121 use_variable: ""
122 # Creds
123 OPENSTACK_API_CREDENTIALS:
124 type: StringParameterValue
125 use_variable: OPENSTACK_API_CREDENTIALS
126 OS_AUTH_URL:
127 type: StringParameterValue
128 use_variable: OS_AUTH_URL
129 OS_IDENTITY_API_VERSION:
130 type: StringParameterValue
131 use_variable: OS_IDENTITY_API_VERSION
132 OS_INTERFACE:
133 type: StringParameterValue
134 use_variable: OS_INTERFACE
135 OS_PROJECT_ID:
136 type: StringParameterValue
137 use_variable: OS_PROJECT_ID
138 OS_PROJECT_NAME:
139 type: StringParameterValue
140 use_variable: OS_PROJECT_NAME
141 OS_REGION_NAME:
142 type: StringParameterValue
143 use_variable: OS_REGION_NAME
144 OS_USER_DOMAIN_NAME:
145 type: StringParameterValue
146 use_variable: OS_USER_DOMAIN_NAME
147 KAAS_EXTERNAL_NETWORK_ID:
148 type: StringParameterValue
149 use_variable: KAAS_EXTERNAL_NETWORK_ID
150 CLOUD_KEY_NAME:
151 type: StringParameterValue
152 use_variable: CLOUD_KEY_NAME
153 SEED_PRIVATE_KEY_CREDENTIAL_ID:
154 type: StringParameterValue
155 use_variable: SEED_PRIVATE_KEY_CREDENTIAL_ID
156 SI_TESTS_REFSPEC:
157 type: StringParameterValue
158 use_variable: SI_TESTS_REFSPEC
159 REPORT_TO_TESTRAIL:
160 type: BooleanParameterValue
161 use_variable: REPORT_TO_TESTRAIL
162 artifacts:
163 KUBECONFIG_ARTIFACT: artifacts/management_kubeconfig
164 DEPLOYED_KAAS_VERSION: artifacts/management_version
165 MGMT_K8S_VERSION: artifacts/management_k8s_version
166 KAAS_MGMT_CLUSTER_PRIVATE_KEY_FILE: artifacts/management_id_rsa
167 SHARED_PUBLIC_KEY: artifacts/management_id_rsa_pub
168'''
169
170
171common = new com.mirantis.mk.Common()
172def workflow = new com.mirantis.mk.Workflow()
173def total_timeout = env.TOTAL_TIMEOUT ?: 14400
174
175// sane defaults for job running process in scenario
176continueIfFailure = 'true'
177breakIfFailure = 'false'
178
179node('python') {
180 // Import external kaas groovy library
181 stage('Getting kaas-libraries') {
182 checkout scm
183 baseKaas = load 'hack/backend/kaasLibrary.groovy'
184 }
185 // Determine if custom trigger keywords forwarded from gerrit
186 def triggers = baseKaas.checkCustomGerritTriggers()
187 deployChild = triggers.deployChildEnabled
188 upgradeChild = triggers.upgradeChildEnabled
189 upgradeMgmt = triggers.upgradeMgmtEnabled
190 runUie2e = triggers.runUie2eEnabled
191 runMgmtConformance = triggers.runMgmtConformanceEnabled
192
193 stage('Generating workflow scenario') {
194 if (upgradeMgmt) {
195 scenario_yaml += baseKaas.siMgmtUpdate(breakIfFailure)
196 }
197
198 if (runMgmtConformance) {
199 scenario_yaml += baseKaas.siMgmtRunCfm(continueIfFailure)
200 }
201
202 if (deployChild) {
203 scenario_yaml += baseKaas.siChildOsCreate(breakIfFailure)
204 scenario_yaml += baseKaas.siChildCollectLogs(continueIfFailure)
205 if (upgradeChild) {
206 scenario_yaml += baseKaas.siChildUpdate(breakIfFailure)
207 scenario_yaml += baseKaas.siChildCollectLogs(continueIfFailure)
208 }
209 scenario_yaml += baseKaas.siChildDelete(breakIfFailure)
210 }
211
212 if (runUie2e) {
213 scenario_yaml += baseKaas.siMgmtRunUiE2eOs(breakIfFailure)
214 }
215 }
216
217 stage('Generating final steps in scenario') {
218 scenario_yaml += '\nfinally:'
219
220 if (deployChild) {
221 scenario_yaml += baseKaas.siChildCollectLogs(continueIfFailure)
222 }
223 scenario_yaml += baseKaas.siMgmtDelete(continueIfFailure)
224 scenario_yaml += baseKaas.siMgmtSeedDelete(breakIfFailure)
225
226 scenario = readYaml text: scenario_yaml
227 common.infoMsg('Scenario generated successfully')
228 writeYaml file: 'generated_scenario.yaml', data: scenario
229 archiveArtifacts(
230 artifacts: 'generated_scenario.yaml',
231 )
232 }
233
234 timeout(time: total_timeout.toInteger(), unit: 'SECONDS') {
235 workflow.runScenario(scenario)
236 } // timeout
237}