vnaumov | 33747e1 | 2020-05-04 17:35:20 +0200 | [diff] [blame] | 1 | package com.mirantis.mk |
vnaumov | 33747e1 | 2020-05-04 17:35:20 +0200 | [diff] [blame] | 2 | |
| 3 | /** |
| 4 | * |
| 5 | * KaaS Component Testing Utilities |
| 6 | * |
| 7 | */ |
| 8 | |
| 9 | |
| 10 | /** |
azvyagintsev | a12230a | 2020-06-05 13:24:06 +0300 | [diff] [blame] | 11 | * 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 | */ |
vnaumov | 33747e1 | 2020-05-04 17:35:20 +0200 | [diff] [blame] | 23 | def checkDeploymentTestSuite() { |
vnaumov | bdb9022 | 2020-05-04 18:25:50 +0200 | [diff] [blame] | 24 | def common = new com.mirantis.mk.Common() |
| 25 | |
vnaumov | 33747e1 | 2020-05-04 17:35:20 +0200 | [diff] [blame] | 26 | // Available triggers and its sane defaults |
azvyagintsev | a12230a | 2020-06-05 13:24:06 +0300 | [diff] [blame] | 27 | 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 |
vnaumov | 33747e1 | 2020-05-04 17:35:20 +0200 | [diff] [blame] | 33 | 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 [ |
azvyagintsev | a12230a | 2020-06-05 13:24:06 +0300 | [diff] [blame] | 87 | deployChildEnabled : deployChild, |
| 88 | upgradeChildEnabled : upgradeChild, |
| 89 | runChildConformanceEnabled : runChildConformance, |
| 90 | upgradeMgmtEnabled : upgradeMgmt, |
| 91 | runUie2eEnabled : runUie2e, |
| 92 | runMgmtConformanceEnabled : runMgmtConformance, |
vnaumov | 33747e1 | 2020-05-04 17:35:20 +0200 | [diff] [blame] | 93 | fetchServiceBinariesEnabled: fetchServiceBinaries, |
azvyagintsev | a12230a | 2020-06-05 13:24:06 +0300 | [diff] [blame] | 94 | awsOnDemandDemoEnabled : awsOnDemandDemo] |
vnaumov | 33747e1 | 2020-05-04 17:35:20 +0200 | [diff] [blame] | 95 | } |
| 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 | * |
azvyagintsev | a12230a | 2020-06-05 13:24:06 +0300 | [diff] [blame] | 106 | * @return (map)[* siTests: (string) final refspec for si-tests |
vnaumov | 33747e1 | 2020-05-04 17:35:20 +0200 | [diff] [blame] | 107 | * siPipelines: (string) final refspec for si-pipelines |
| 108 | * ] |
| 109 | */ |
| 110 | def checkCustomSIRefspec() { |
vnaumov | bdb9022 | 2020-05-04 18:25:50 +0200 | [diff] [blame] | 111 | def common = new com.mirantis.mk.Common() |
| 112 | |
vnaumov | 33747e1 | 2020-05-04 17:35:20 +0200 | [diff] [blame] | 113 | // Available triggers and its sane defaults |
azvyagintsev | a12230a | 2020-06-05 13:24:06 +0300 | [diff] [blame] | 114 | 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' |
vnaumov | 33747e1 | 2020-05-04 17:35:20 +0200 | [diff] [blame] | 117 | 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() |
azvyagintsev | a12230a | 2020-06-05 13:24:06 +0300 | [diff] [blame] | 124 | siTestsDockerImage = "docker-dev-local.docker.mirantis.net/review/" + |
| 125 | "kaas-si-test-${siTestsRefspec.split('/')[-2]}:${siTestsRefspec.split('/')[-1]}" |
vnaumov | 33747e1 | 2020-05-04 17:35:20 +0200 | [diff] [blame] | 126 | } |
| 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} |
azvyagintsev | a12230a | 2020-06-05 13:24:06 +0300 | [diff] [blame] | 134 | kaas/si-tests as dockerImage will be fetched from: ${siTestsDockerImage} |
vnaumov | 33747e1 | 2020-05-04 17:35:20 +0200 | [diff] [blame] | 135 | Keywords: https://gerrit.mcp.mirantis.com/plugins/gitiles/kaas/core/+/refs/heads/master/.git-message-template#59""") |
azvyagintsev | a12230a | 2020-06-05 13:24:06 +0300 | [diff] [blame] | 136 | return [siTests: siTestsRefspec, siPipelines: siPipelinesRefspec, siTestsDockerImage: siTestsDockerImage] |
vnaumov | 33747e1 | 2020-05-04 17:35:20 +0200 | [diff] [blame] | 137 | } |