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 | /** |
| 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)[ |
| 20 | * deployChildEnabled: (bool) True if need to deploy child cluster during demo-run |
| 21 | * runUie2eEnabled: (bool) True if need to run ui-e2e cluster during demo-run |
| 22 | * ] |
| 23 | */ |
| 24 | def checkDeploymentTestSuite() { |
vnaumov | bdb9022 | 2020-05-04 18:25:50 +0200 | [diff] [blame^] | 25 | def common = new com.mirantis.mk.Common() |
| 26 | |
vnaumov | 33747e1 | 2020-05-04 17:35:20 +0200 | [diff] [blame] | 27 | // Available triggers and its sane defaults |
| 28 | def deployChild = (env.DEPLOY_CHILD_CLUSTER != null ) ? env.DEPLOY_CHILD_CLUSTER.toBoolean() : false |
| 29 | def upgradeChild = (env.UPGRADE_CHILD_CLUSTER != null ) ? env.UPGRADE_CHILD_CLUSTER.toBoolean() : false |
| 30 | def upgradeMgmt = (env.UPGRADE_MGMT_CLUSTER != null ) ? env.UPGRADE_MGMT_CLUSTER.toBoolean() : false |
| 31 | def runUie2e = (env.RUN_UI_E2E != null ) ? env.RUN_UI_E2E.toBoolean() : false |
| 32 | def runMgmtConformance = (env.RUN_MGMT_CFM != null ) ? env.RUN_MGMT_CFM.toBoolean() : false |
| 33 | def runChildConformance = (env.RUN_CHILD_CFM != null ) ? env.RUN_CHILD_CFM.toBoolean() : false |
| 34 | def fetchServiceBinaries = (env.FETCH_BINARIES_FROM_UPSTREAM != null) ? env.FETCH_BINARIES_FROM_UPSTREAM.toBoolean() : false |
| 35 | def awsOnDemandDemo = (env.RUN_AWS_ON_DEMAND_DEMO != null) ? env.RUN_AWS_ON_DEMAND_DEMO.toBoolean() : false |
| 36 | |
| 37 | def commitMsg = (env.GERRIT_CHANGE_COMMIT_MESSAGE != null) ? new String(env.GERRIT_CHANGE_COMMIT_MESSAGE.decodeBase64()) : '' |
| 38 | if (commitMsg ==~ /(?s).*\[child-deploy\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-deploy.*/ || upgradeChild || runChildConformance) { |
| 39 | deployChild = true |
| 40 | } |
| 41 | if (commitMsg ==~ /(?s).*\[child-upgrade\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-upgrade.*/) { |
| 42 | deployChild = true |
| 43 | upgradeChild = true |
| 44 | } |
| 45 | if (commitMsg ==~ /(?s).*\[mgmt-upgrade\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mgmt-upgrade.*/) { |
| 46 | upgradeMgmt = true |
| 47 | } |
| 48 | if (commitMsg ==~ /(?s).*\[ui-e2e\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*ui-e2e.*/) { |
| 49 | runUie2e = true |
| 50 | } |
| 51 | if (commitMsg ==~ /(?s).*\[mgmt-cfm\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mgmt-cfm.*/) { |
| 52 | runMgmtConformance = true |
| 53 | } |
| 54 | if (commitMsg ==~ /(?s).*\[child-cfm\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-cfm.*/) { |
| 55 | runChildConformance = true |
| 56 | deployChild = true |
| 57 | } |
| 58 | if (commitMsg ==~ /(?s).*\[fetch.*binaries\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*fetch.*binaries.*/) { |
| 59 | fetchServiceBinaries = true |
| 60 | } |
| 61 | if (commitMsg ==~ /(?s).*\[aws-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*aws-demo.*/) { |
| 62 | awsOnDemandDemo = true |
| 63 | common.warningMsg('Forced running additional kaas deployment with AWS provider, triggered on patchset using custom keyword: \'aws-demo\' ') |
| 64 | } |
| 65 | |
| 66 | // TODO (vnaumov) remove below condition after moving all releases to UCP |
| 67 | def ucpChildMatches = (commitMsg =~ /(\[child-ucp\s*ucp-.*?\])/) |
| 68 | if (ucpChildMatches.size() > 0) { |
| 69 | deployChild = true |
| 70 | common.warningMsg('Forced UCP based child deployment triggered on patchset using custom keyword: \'[child-ucp ucp-5-1-0-3-3-0-example]\' ') |
| 71 | |
| 72 | // TODO(vnaumov) delete after ucp upgrades support |
| 73 | common.errorMsg('Child upgrade test will be skipped, UCP upgrades temporally disabled') |
| 74 | upgradeChild = false |
| 75 | } |
| 76 | |
| 77 | common.infoMsg(""" |
| 78 | Child cluster deployment scheduled: ${deployChild} |
| 79 | Child cluster release upgrade scheduled: ${upgradeChild} |
| 80 | Child conformance testing scheduled: ${runChildConformance} |
| 81 | Mgmt cluster release upgrade scheduled: ${upgradeMgmt} |
| 82 | Mgmt conformance testing scheduled: ${runMgmtConformance} |
| 83 | Mgmt UI e2e testing scheduled: ${runUie2e} |
| 84 | AWS provider additional deployment scheduled: ${awsOnDemandDemo} |
| 85 | Service binaries fetching scheduled: ${fetchServiceBinaries} |
| 86 | Triggers: https://gerrit.mcp.mirantis.com/plugins/gitiles/kaas/core/+/refs/heads/master/.git-message-template#50""") |
| 87 | return [ |
| 88 | deployChildEnabled: deployChild, |
| 89 | upgradeChildEnabled: upgradeChild, |
| 90 | runChildConformanceEnabled: runChildConformance, |
| 91 | upgradeMgmtEnabled: upgradeMgmt, |
| 92 | runUie2eEnabled: runUie2e, |
| 93 | runMgmtConformanceEnabled: runMgmtConformance, |
| 94 | fetchServiceBinariesEnabled: fetchServiceBinaries, |
| 95 | awsOnDemandDemoEnabled: awsOnDemandDemo] |
| 96 | } |
| 97 | |
| 98 | /** |
| 99 | * Determine if custom si tests/pipelines refspec forwarded from gerrit change request |
| 100 | |
| 101 | * Keyword list: https://gerrit.mcp.mirantis.com/plugins/gitiles/kaas/core/+/refs/heads/master/.git-message-template#59 |
| 102 | * Used for components team to test component changes w/ custom SI refspecs using kaas/core deployment jobs |
| 103 | * Example scheme: |
| 104 | * New CR pushed in kubernetes/lcm-ansible -> parsing it's commit body and get custom test refspecs -> trigger deployment jobs from kaas/core |
| 105 | * manage refspecs through Jenkins Job Parameters |
| 106 | * |
| 107 | * @return (map)[ |
| 108 | * siTests: (string) final refspec for si-tests |
| 109 | * siPipelines: (string) final refspec for si-pipelines |
| 110 | * ] |
| 111 | */ |
| 112 | def checkCustomSIRefspec() { |
vnaumov | bdb9022 | 2020-05-04 18:25:50 +0200 | [diff] [blame^] | 113 | def common = new com.mirantis.mk.Common() |
| 114 | |
vnaumov | 33747e1 | 2020-05-04 17:35:20 +0200 | [diff] [blame] | 115 | // Available triggers and its sane defaults |
| 116 | def siTestsRefspec = (env.SI_TESTS_REFSPEC != null ) ? env.SI_TESTS_REFSPEC : 'master' |
| 117 | def siPipelinesRefspec = (env.SI_PIPELINES_REFSPEC != null ) ? env.SI_PIPELINES_REFSPEC : 'master' |
| 118 | def commitMsg = (env.GERRIT_CHANGE_COMMIT_MESSAGE != null) ? new String(env.GERRIT_CHANGE_COMMIT_MESSAGE.decodeBase64()) : '' |
| 119 | |
| 120 | def siTestMatches = (commitMsg =~ /(\[si-tests-ref\s*refs\/changes\/.*?\])/) |
| 121 | def siPipelinesMatches = (commitMsg =~ /(\[si-pipelines-ref\s*refs\/changes\/.*?\])/) |
| 122 | |
| 123 | if (siTestMatches.size() > 0) { |
| 124 | siTestsRefspec = siTestMatches[0][0].split('si-tests-ref')[1].replaceAll('[\\[\\]]', '').trim() |
| 125 | } |
| 126 | if (siPipelinesMatches.size() > 0) { |
| 127 | siPipelinesRefspec = siPipelinesMatches[0][0].split('si-pipelines-ref')[1].replaceAll('[\\[\\]]', '').trim() |
| 128 | } |
| 129 | |
| 130 | common.infoMsg(""" |
| 131 | kaas/si-pipelines will be fetched from: ${siPipelinesRefspec} |
| 132 | kaas/si-tests will be fetched from: ${siTestsRefspec} |
| 133 | Keywords: https://gerrit.mcp.mirantis.com/plugins/gitiles/kaas/core/+/refs/heads/master/.git-message-template#59""") |
| 134 | return [siTests: siTestsRefspec, siPipelines: siPipelinesRefspec] |
| 135 | } |