blob: cc587748a60049736e474c6caaef8a725eb2c58a [file] [log] [blame]
vnaumov33747e12020-05-04 17:35:20 +02001package com.mirantis.mk
vnaumov33747e12020-05-04 17:35:20 +02002
3/**
4 *
5 * KaaS Component Testing Utilities
6 *
7 */
8
9
10/**
azvyagintseva12230a2020-06-05 13:24:06 +030011 * Determine scope of test suite against per-commit KaaS deployment based on keywords
12 * Keyword list: https://gerrit.mcp.mirantis.com/plugins/gitiles/kaas/core/+/refs/heads/master/.git-message-template#50
13 *
14 * Used for components team to combine test-suites and forward desired parameters to kaas/core deployment jobs
15 * Example scheme:
16 * New CR pushed in kubernetes/lcm-ansible -> parsing it's commit body and combine test-suite -> trigger deployment jobs from kaas/core
17 * manage test-suite through Jenkins Job Parameters
18 *
19 * @return (map)[* deployChildEnabled: (bool) True if need to deploy child cluster during demo-run
20 * runUie2eEnabled: (bool) True if need to run ui-e2e cluster during demo-run
21 * ]
22 */
vnaumov33747e12020-05-04 17:35:20 +020023def checkDeploymentTestSuite() {
vnaumovbdb90222020-05-04 18:25:50 +020024 def common = new com.mirantis.mk.Common()
25
vnaumov33747e12020-05-04 17:35:20 +020026 // Available triggers and its sane defaults
azvyagintseva12230a2020-06-05 13:24:06 +030027 def deployChild = (env.DEPLOY_CHILD_CLUSTER != null) ? env.DEPLOY_CHILD_CLUSTER.toBoolean() : false
28 def upgradeChild = (env.UPGRADE_CHILD_CLUSTER != null) ? env.UPGRADE_CHILD_CLUSTER.toBoolean() : false
29 def upgradeMgmt = (env.UPGRADE_MGMT_CLUSTER != null) ? env.UPGRADE_MGMT_CLUSTER.toBoolean() : false
30 def runUie2e = (env.RUN_UI_E2E != null) ? env.RUN_UI_E2E.toBoolean() : false
31 def runMgmtConformance = (env.RUN_MGMT_CFM != null) ? env.RUN_MGMT_CFM.toBoolean() : false
32 def runChildConformance = (env.RUN_CHILD_CFM != null) ? env.RUN_CHILD_CFM.toBoolean() : false
vnaumov33747e12020-05-04 17:35:20 +020033 def fetchServiceBinaries = (env.FETCH_BINARIES_FROM_UPSTREAM != null) ? env.FETCH_BINARIES_FROM_UPSTREAM.toBoolean() : false
34 def awsOnDemandDemo = (env.RUN_AWS_ON_DEMAND_DEMO != null) ? env.RUN_AWS_ON_DEMAND_DEMO.toBoolean() : false
35
36 def commitMsg = (env.GERRIT_CHANGE_COMMIT_MESSAGE != null) ? new String(env.GERRIT_CHANGE_COMMIT_MESSAGE.decodeBase64()) : ''
37 if (commitMsg ==~ /(?s).*\[child-deploy\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-deploy.*/ || upgradeChild || runChildConformance) {
38 deployChild = true
39 }
40 if (commitMsg ==~ /(?s).*\[child-upgrade\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-upgrade.*/) {
41 deployChild = true
42 upgradeChild = true
43 }
44 if (commitMsg ==~ /(?s).*\[mgmt-upgrade\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mgmt-upgrade.*/) {
45 upgradeMgmt = true
46 }
47 if (commitMsg ==~ /(?s).*\[ui-e2e\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*ui-e2e.*/) {
48 runUie2e = true
49 }
50 if (commitMsg ==~ /(?s).*\[mgmt-cfm\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mgmt-cfm.*/) {
51 runMgmtConformance = true
52 }
53 if (commitMsg ==~ /(?s).*\[child-cfm\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-cfm.*/) {
54 runChildConformance = true
55 deployChild = true
56 }
57 if (commitMsg ==~ /(?s).*\[fetch.*binaries\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*fetch.*binaries.*/) {
58 fetchServiceBinaries = true
59 }
60 if (commitMsg ==~ /(?s).*\[aws-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*aws-demo.*/) {
61 awsOnDemandDemo = true
62 common.warningMsg('Forced running additional kaas deployment with AWS provider, triggered on patchset using custom keyword: \'aws-demo\' ')
63 }
64
65 // TODO (vnaumov) remove below condition after moving all releases to UCP
66 def ucpChildMatches = (commitMsg =~ /(\[child-ucp\s*ucp-.*?\])/)
67 if (ucpChildMatches.size() > 0) {
68 deployChild = true
69 common.warningMsg('Forced UCP based child deployment triggered on patchset using custom keyword: \'[child-ucp ucp-5-1-0-3-3-0-example]\' ')
70
71 // TODO(vnaumov) delete after ucp upgrades support
72 common.errorMsg('Child upgrade test will be skipped, UCP upgrades temporally disabled')
73 upgradeChild = false
74 }
75
76 common.infoMsg("""
77 Child cluster deployment scheduled: ${deployChild}
78 Child cluster release upgrade scheduled: ${upgradeChild}
79 Child conformance testing scheduled: ${runChildConformance}
80 Mgmt cluster release upgrade scheduled: ${upgradeMgmt}
81 Mgmt conformance testing scheduled: ${runMgmtConformance}
82 Mgmt UI e2e testing scheduled: ${runUie2e}
83 AWS provider additional deployment scheduled: ${awsOnDemandDemo}
84 Service binaries fetching scheduled: ${fetchServiceBinaries}
85 Triggers: https://gerrit.mcp.mirantis.com/plugins/gitiles/kaas/core/+/refs/heads/master/.git-message-template#50""")
86 return [
azvyagintseva12230a2020-06-05 13:24:06 +030087 deployChildEnabled : deployChild,
88 upgradeChildEnabled : upgradeChild,
89 runChildConformanceEnabled : runChildConformance,
90 upgradeMgmtEnabled : upgradeMgmt,
91 runUie2eEnabled : runUie2e,
92 runMgmtConformanceEnabled : runMgmtConformance,
vnaumov33747e12020-05-04 17:35:20 +020093 fetchServiceBinariesEnabled: fetchServiceBinaries,
azvyagintseva12230a2020-06-05 13:24:06 +030094 awsOnDemandDemoEnabled : awsOnDemandDemo]
vnaumov33747e12020-05-04 17:35:20 +020095}
96
97/**
98 * Determine if custom si tests/pipelines refspec forwarded from gerrit change request
99
100 * Keyword list: https://gerrit.mcp.mirantis.com/plugins/gitiles/kaas/core/+/refs/heads/master/.git-message-template#59
101 * Used for components team to test component changes w/ custom SI refspecs using kaas/core deployment jobs
102 * Example scheme:
103 * New CR pushed in kubernetes/lcm-ansible -> parsing it's commit body and get custom test refspecs -> trigger deployment jobs from kaas/core
104 * manage refspecs through Jenkins Job Parameters
105 *
azvyagintseva12230a2020-06-05 13:24:06 +0300106 * @return (map)[* siTests: (string) final refspec for si-tests
vnaumov33747e12020-05-04 17:35:20 +0200107 * siPipelines: (string) final refspec for si-pipelines
108 * ]
109 */
110def checkCustomSIRefspec() {
vnaumovbdb90222020-05-04 18:25:50 +0200111 def common = new com.mirantis.mk.Common()
112
vnaumov33747e12020-05-04 17:35:20 +0200113 // Available triggers and its sane defaults
azvyagintseva12230a2020-06-05 13:24:06 +0300114 def siTestsRefspec = (env.SI_TESTS_REFSPEC != null) ? env.SI_TESTS_REFSPEC : 'master'
115 def siPipelinesRefspec = (env.SI_PIPELINES_REFSPEC != null) ? env.SI_PIPELINES_REFSPEC : 'master'
116 def siTestsDockerImage = (env.SI_TESTS_DOCKER_IMAGE != null) ? env.SI_TESTS_DOCKER_IMAGE : 'docker-dev-kaas-local.docker.mirantis.net/mirantis/kaas/si-test:master'
vnaumov33747e12020-05-04 17:35:20 +0200117 def commitMsg = (env.GERRIT_CHANGE_COMMIT_MESSAGE != null) ? new String(env.GERRIT_CHANGE_COMMIT_MESSAGE.decodeBase64()) : ''
118
119 def siTestMatches = (commitMsg =~ /(\[si-tests-ref\s*refs\/changes\/.*?\])/)
120 def siPipelinesMatches = (commitMsg =~ /(\[si-pipelines-ref\s*refs\/changes\/.*?\])/)
121
122 if (siTestMatches.size() > 0) {
123 siTestsRefspec = siTestMatches[0][0].split('si-tests-ref')[1].replaceAll('[\\[\\]]', '').trim()
azvyagintseva12230a2020-06-05 13:24:06 +0300124 siTestsDockerImage = "docker-dev-local.docker.mirantis.net/review/" +
125 "kaas-si-test-${siTestsRefspec.split('/')[-2]}:${siTestsRefspec.split('/')[-1]}"
vnaumov33747e12020-05-04 17:35:20 +0200126 }
127 if (siPipelinesMatches.size() > 0) {
128 siPipelinesRefspec = siPipelinesMatches[0][0].split('si-pipelines-ref')[1].replaceAll('[\\[\\]]', '').trim()
129 }
130
131 common.infoMsg("""
132 kaas/si-pipelines will be fetched from: ${siPipelinesRefspec}
133 kaas/si-tests will be fetched from: ${siTestsRefspec}
azvyagintseva12230a2020-06-05 13:24:06 +0300134 kaas/si-tests as dockerImage will be fetched from: ${siTestsDockerImage}
vnaumov33747e12020-05-04 17:35:20 +0200135 Keywords: https://gerrit.mcp.mirantis.com/plugins/gitiles/kaas/core/+/refs/heads/master/.git-message-template#59""")
azvyagintseva12230a2020-06-05 13:24:06 +0300136 return [siTests: siTestsRefspec, siPipelines: siPipelinesRefspec, siTestsDockerImage: siTestsDockerImage]
vnaumov33747e12020-05-04 17:35:20 +0200137}