vnaumov | 33747e1 | 2020-05-04 17:35:20 +0200 | [diff] [blame^] | 1 | package com.mirantis.mk |
| 2 | common = new com.mirantis.mk.Common() |
| 3 | |
| 4 | /** |
| 5 | * |
| 6 | * KaaS Component Testing Utilities |
| 7 | * |
| 8 | */ |
| 9 | |
| 10 | |
| 11 | /** |
| 12 | * Determine scope of test suite against per-commit KaaS deployment based on keywords |
| 13 | * Keyword list: https://gerrit.mcp.mirantis.com/plugins/gitiles/kaas/core/+/refs/heads/master/.git-message-template#50 |
| 14 | * |
| 15 | * Used for components team to combine test-suites and forward desired parameters to kaas/core deployment jobs |
| 16 | * Example scheme: |
| 17 | * New CR pushed in kubernetes/lcm-ansible -> parsing it's commit body and combine test-suite -> trigger deployment jobs from kaas/core |
| 18 | * manage test-suite through Jenkins Job Parameters |
| 19 | * |
| 20 | * @return (map)[ |
| 21 | * deployChildEnabled: (bool) True if need to deploy child cluster during demo-run |
| 22 | * runUie2eEnabled: (bool) True if need to run ui-e2e cluster during demo-run |
| 23 | * ] |
| 24 | */ |
| 25 | def checkDeploymentTestSuite() { |
| 26 | // Available triggers and its sane defaults |
| 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 |
| 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 [ |
| 87 | deployChildEnabled: deployChild, |
| 88 | upgradeChildEnabled: upgradeChild, |
| 89 | runChildConformanceEnabled: runChildConformance, |
| 90 | upgradeMgmtEnabled: upgradeMgmt, |
| 91 | runUie2eEnabled: runUie2e, |
| 92 | runMgmtConformanceEnabled: runMgmtConformance, |
| 93 | fetchServiceBinariesEnabled: fetchServiceBinaries, |
| 94 | awsOnDemandDemoEnabled: awsOnDemandDemo] |
| 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 | * |
| 106 | * @return (map)[ |
| 107 | * siTests: (string) final refspec for si-tests |
| 108 | * siPipelines: (string) final refspec for si-pipelines |
| 109 | * ] |
| 110 | */ |
| 111 | def checkCustomSIRefspec() { |
| 112 | // Available triggers and its sane defaults |
| 113 | def siTestsRefspec = (env.SI_TESTS_REFSPEC != null ) ? env.SI_TESTS_REFSPEC : 'master' |
| 114 | def siPipelinesRefspec = (env.SI_PIPELINES_REFSPEC != null ) ? env.SI_PIPELINES_REFSPEC : 'master' |
| 115 | def commitMsg = (env.GERRIT_CHANGE_COMMIT_MESSAGE != null) ? new String(env.GERRIT_CHANGE_COMMIT_MESSAGE.decodeBase64()) : '' |
| 116 | |
| 117 | def siTestMatches = (commitMsg =~ /(\[si-tests-ref\s*refs\/changes\/.*?\])/) |
| 118 | def siPipelinesMatches = (commitMsg =~ /(\[si-pipelines-ref\s*refs\/changes\/.*?\])/) |
| 119 | |
| 120 | if (siTestMatches.size() > 0) { |
| 121 | siTestsRefspec = siTestMatches[0][0].split('si-tests-ref')[1].replaceAll('[\\[\\]]', '').trim() |
| 122 | } |
| 123 | if (siPipelinesMatches.size() > 0) { |
| 124 | siPipelinesRefspec = siPipelinesMatches[0][0].split('si-pipelines-ref')[1].replaceAll('[\\[\\]]', '').trim() |
| 125 | } |
| 126 | |
| 127 | common.infoMsg(""" |
| 128 | kaas/si-pipelines will be fetched from: ${siPipelinesRefspec} |
| 129 | kaas/si-tests will be fetched from: ${siTestsRefspec} |
| 130 | Keywords: https://gerrit.mcp.mirantis.com/plugins/gitiles/kaas/core/+/refs/heads/master/.git-message-template#59""") |
| 131 | return [siTests: siTestsRefspec, siPipelines: siPipelinesRefspec] |
| 132 | } |