Merge "Remove unneeded git rev parse"
diff --git a/src/com/mirantis/mk/Git.groovy b/src/com/mirantis/mk/Git.groovy
index 334bf01..1e24aeb 100644
--- a/src/com/mirantis/mk/Git.groovy
+++ b/src/com/mirantis/mk/Git.groovy
@@ -510,31 +510,39 @@
  *   - changeAuthorEmail  Author's email of the change
  *   - changeAuthorName   Author's name of the change
  *   - forceUpdate        Whether to update change if no diff between local state and remote
- */  
+ *   - gerritPatch        Maps with patch information (result of gerrit.findGerritChange)
+ *   - amend              Do amend current patch
+ */
 def updateChangeRequest(Map params) {
     def gerrit = new com.mirantis.mk.Gerrit()
     def common = new com.mirantis.mk.Common()
 
     def commitMessage
-    def auth = params['gerritAuth']
     def creds = params['credentialsId']
     def repo = params['repo']
     def comment = params['comment']
     def change_id_seed = params.get('change_id_seed', JOB_NAME)
     def branch = params['branch']
     def topic = params['topic']
-    def project = params['project']
-    def status = params.get('status', 'open')
     def changeAuthorEmail = params['changeAuthorEmail']
     def changeAuthorName = params['changeAuthorName']
     def forceUpdate = params.get('forceUpdate', true)
-
-    def changeParams = ['owner': auth['USER'], 'status': status, 'project': project, 'branch': branch, 'topic': topic]
-    def gerritChange = gerrit.findGerritChange(creds, auth, changeParams, '--current-patch-set')
+    def amend = params.get('amend', false)
+    def jsonChange = params.get('gerritPatch', [:])
     def changeId = params.get('changeId', '')
     def commit
-    if (gerritChange) {
-        def jsonChange = readJSON text: gerritChange
+
+    if (!jsonChange) {
+        def auth = params['gerritAuth']
+        def status = params.get('status', 'open')
+        def project = params['project']
+        def changeParams = ['owner': auth['USER'], 'status': status, 'project': project, 'branch': branch, 'topic': topic]
+        def gerritChange = gerrit.findGerritChange(creds, auth, changeParams, '--current-patch-set')
+        if (gerritChange) {
+            jsonChange = readJSON text: gerritChange
+        }
+    }
+    if (jsonChange) {
         changeId = jsonChange['id']
         if(!forceUpdate){
             def ref = jsonChange['currentPatchSet']['ref']
@@ -551,9 +559,53 @@
         }
     }
     commitMessage = genCommitMessage(repo, comment, changeId, change_id_seed)
-    commitGitChanges(repo, commitMessage, changeAuthorEmail, changeAuthorName, false, false)
+    commitGitChanges(repo, commitMessage, changeAuthorEmail, changeAuthorName, false, amend)
     dir(repo){
         commit = getGitCommit()
     }
     pushForReview(repo, creds, commit, branch, topic)
 }
+
+/**
+ * Create new working branch for repo from patch if it exists
+ *
+ * @param params   Map of parameters to customize commit
+ *   - gerritAuth         A map containing information about Gerrit. Should include HOST, PORT and USER
+ *   - credentialsId      Jenkins credentials id for gerrit
+ *   - repo               Local directory with repository
+ *   - branch             Name of the branch for uploading
+ *   - topic              Topic of the change
+ *   - project            Gerrit project to search in for gerrit change request
+ *   - status             Change request's status to search for
+ */
+def createGitBranchFromRef(Map params) {
+    def gerrit = new com.mirantis.mk.Gerrit()
+    def common = new com.mirantis.mk.Common()
+
+    def auth = params['gerritAuth']
+    def creds = params['credentialsId']
+    def repo = params['repo']
+    def branch = params['branch']
+    def topic = params['topic']
+    def project = params['project']
+    def status = params.get('status', 'open')
+    def localBranch = "branch_${topic}"
+    def jsonChange = [:]
+
+    def changeParams = ['owner': auth['USER'], 'status': status, 'project': project, 'branch': branch, 'topic': topic]
+    def gerritChange = gerrit.findGerritChange(creds, auth, changeParams, '--current-patch-set')
+    if (gerritChange) {
+        jsonChange = readJSON text: gerritChange
+        def ref = jsonChange['currentPatchSet']['ref']
+        changeId = jsonChange['id']
+        dir(repo){
+            sshagent (credentials: [creds]){
+                common.shCmdStatus("git fetch origin ${ref} && git checkout -b ${localBranch} FETCH_HEAD")
+            }
+        }
+    }
+    else {
+        createGitBranch(repo, localBranch)
+    }
+    return jsonChange
+}
diff --git a/src/com/mirantis/mk/KaasUtils.groovy b/src/com/mirantis/mk/KaasUtils.groovy
index 4ade7d8..ea2ea18 100644
--- a/src/com/mirantis/mk/KaasUtils.groovy
+++ b/src/com/mirantis/mk/KaasUtils.groovy
@@ -60,12 +60,14 @@
     def runBYOMatrix = env.RUN_BYO_MATRIX ? env.RUN_BYO_MATRIX.toBoolean() : false
     def defaultBYOOs = env.DEFAULT_BYO_OS ? env.DEFAULT_BYO_OS.toString() : 'ubuntu'
     def upgradeMgmt = env.UPGRADE_MGMT_CLUSTER ? env.UPGRADE_MGMT_CLUSTER.toBoolean() : false
+    def autoUpgradeMgmt = env.AUTO_UPGRADE_MCC ? env.AUTO_UPGRADE_MCC.toBoolean() : false
     def enableLMALogging = env.ENABLE_LMA_LOGGING ? env.ENABLE_LMA_LOGGING.toBoolean(): false
     def runUie2e = env.RUN_UI_E2E ? env.RUN_UI_E2E.toBoolean() : false
+    def runUie2eNew = env.RUN_UI_E2E_NEW ? env.RUN_UI_E2E_NEW.toBoolean() : false
     def runMgmtConformance = env.RUN_MGMT_CFM ? env.RUN_MGMT_CFM.toBoolean() : false
     def runLMATest = env.RUN_LMA_TEST ? env.RUN_LMA_TEST.toBoolean() : false
     def runMgmtUserControllerTest = env.RUN_MGMT_USER_CONTROLLER_TEST ? env.RUN_MGMT_USER_CONTROLLER_TEST.toBoolean() : false
-    def runProxyChildTest = env.RUN_PROXY_CHILD_TEST ? env.RUN_PROXY_CHILD_TEST : false
+    def runProxyChildTest = env.RUN_PROXY_CHILD_TEST ? env.RUN_PROXY_CHILD_TEST.toBoolean() : false
     def runChildConformance = env.RUN_CHILD_CFM ? env.RUN_CHILD_CFM.toBoolean() : false
     def fetchServiceBinaries = env.FETCH_BINARIES_FROM_UPSTREAM ? env.FETCH_BINARIES_FROM_UPSTREAM.toBoolean() : false
     def equinixMetalV2ChildDiffMetro = env.EQUINIXMETALV2_CHILD_DIFF_METRO ? env.EQUINIXMETALV2_CHILD_DIFF_METRO.toBoolean() : false
@@ -96,6 +98,7 @@
     def enableBMDemo = true
     def enableArtifactsBuild = true
     def openstackIMC = env.OPENSTACK_CLOUD_LOCATION ? env.OPENSTACK_CLOUD_LOCATION : 'us'
+    def enableVsphereUbuntu = env.VSPHERE_DEPLOY_UBUNTU ? env.VSPHERE_DEPLOY_UBUNTU.toBoolean() : false
 
     def commitMsg = env.GERRIT_CHANGE_COMMIT_MESSAGE ? new String(env.GERRIT_CHANGE_COMMIT_MESSAGE.decodeBase64()) : ''
     if (commitMsg ==~ /(?s).*\[mgmt-proxy\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mgmt-proxy.*/) {
@@ -150,12 +153,18 @@
     if (commitMsg ==~ /(?s).*\[mgmt-upgrade\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mgmt-upgrade.*/) {
         upgradeMgmt = true
     }
+    if (commitMsg ==~ /(?s).*\[auto-upgrade\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*auto-upgrade.*/) {
+        autoUpgradeMgmt = true
+    }
     if (commitMsg ==~ /(?s).*\[lma-logging\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*lma-logging.*/) {
         enableLMALogging = true
     }
     if (commitMsg ==~ /(?s).*\[ui-e2e\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*ui-e2e.*/) {
         runUie2e = true
     }
+    if (commitMsg ==~ /(?s).*\[ui-e2e-new\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*ui-e2e-new.*/) {
+        runUie2eNew = true
+    }
     if (commitMsg ==~ /(?s).*\[mgmt-cfm\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mgmt-cfm.*/) {
         runMgmtConformance = true
     }
@@ -238,6 +247,10 @@
         enableVsphereDemo = false
         common.errorMsg('vSphere demo deployment will be aborted, VF -1 will be set')
     }
+    if (commitMsg ==~ /(?s).*\[vsphere-ubuntu\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*vsphere-ubuntu\.*/) {
+        enableVsphereUbuntu = true
+        common.warningMsg('Ubuntu will be used to deploy vsphere machines')
+    }
 
     if (commitMsg ==~ /(?s).*\[disable-artifacts-build\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*disable-artifacts-build\.*/) {
         enableArtifactsBuild = false
@@ -306,14 +319,11 @@
 
     if (commitMsg ==~ /(?s).*\[eu-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*eu-demo.*/) {
         openstackIMC = 'eu'
-        // use internal-eu because on internal-ci with eu cloud image pull takes much time
-        def cdnRegion = (proxyConfig['mgmtOffline'] == true) ? 'public-ci' : 'internal-eu'
-        common.infoMsg("eu-demo was triggered, force switching CDN region to ${cdnRegion}")
-        cdnConfig['mgmt']['openstack'] = cdnRegion
     }
     if (commitMsg ==~ /(?s).*\[mos-tf-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mos-tf-demo.*/) {
         openstackIMC = 'eu2'
-        MosTfDeploy = true
+    }
+    if (openstackIMC == 'eu' || openstackIMC == 'eu2') {
         // use internal-eu because on internal-ci with eu cloud image pull takes much time
         def cdnRegion = (proxyConfig['mgmtOffline'] == true) ? 'public-ci' : 'internal-eu'
         common.infoMsg("eu2-demo was triggered, force switching CDN region to ${cdnRegion}")
@@ -331,7 +341,6 @@
         Child cluster deployment scheduled: ${deployChild}
         Custom child cluster release: ${customChildRelease}
         Child cluster release upgrade scheduled: ${upgradeChild}
-        Mos-Tf deploy: ${mosTfDeploy}
         MOS child deploy scheduled: ${mosDeployChild}
         MOS child upgrade scheduled: ${mosUpgradeChild}
         Child conformance testing scheduled: ${runChildConformance}
@@ -340,11 +349,13 @@
         BYO test matrix whole suite scheduled: ${runBYOMatrix}
         Default BYO OS: ${defaultBYOOs}
         Mgmt cluster release upgrade scheduled: ${upgradeMgmt}
+        Mgmt cluster release auto upgrade scheduled: ${autoUpgradeMgmt}
         Mgmt LMA logging enabled: ${enableLMALogging}
         Mgmt conformance testing scheduled: ${runMgmtConformance}
         LMA testing scheduled: ${runLMATest}
         Mgmt user controller testing scheduled: ${runMgmtUserControllerTest}
         Mgmt UI e2e testing scheduled: ${runUie2e}
+        Mgmt UI e2e playwrite testing scheduled: ${runUie2eNew}
         Maintenance test: ${runMaintenanceTest}
         Child proxy test: ${runProxyChildTest}
         AWS provider deployment scheduled: ${awsOnDemandDemo}
@@ -357,6 +368,7 @@
         VSPHERE provider deployment scheduled: ${enableVsphereDemo}
         OS provider deployment scheduled: ${enableOSDemo}
         BM provider deployment scheduled: ${enableBMDemo}
+        Ubuntu on vSphere scheduled: ${enableVsphereUbuntu}
         Artifacts build scheduled: ${enableArtifactsBuild}
         Multiregional configuration: ${multiregionalMappings}
         Service binaries fetching scheduled: ${fetchServiceBinaries}
@@ -370,7 +382,6 @@
         deployChildEnabled                   : deployChild,
         childDeployCustomRelease             : customChildRelease,
         upgradeChildEnabled                  : upgradeChild,
-        mosTfDeployEnabled                   : mosTfDeploy,
         mosDeployChildEnabled                : mosDeployChild,
         mosUpgradeChildEnabled               : mosUpgradeChild,
         runChildConformanceEnabled           : runChildConformance,
@@ -379,8 +390,10 @@
         runBYOMatrixEnabled                  : runBYOMatrix,
         defaultBYOOs                         : defaultBYOOs,
         upgradeMgmtEnabled                   : upgradeMgmt,
+        autoUpgradeMgmtEnabled               : autoUpgradeMgmt,
         enableLMALoggingEnabled              : enableLMALogging,
         runUie2eEnabled                      : runUie2e,
+        runUie2eNewEnabled                   : runUie2eNew,
         runMgmtConformanceEnabled            : runMgmtConformance,
         runMaintenanceTestEnable             : runMaintenanceTest,
         runLMATestEnabled                    : runLMATest,
@@ -398,6 +411,7 @@
         vsphereOnDemandDemoEnabled           : enableVsphereDemo, // TODO: remove after MCC 2.7 is out
         bmDemoEnabled                        : enableBMDemo,
         osDemoEnabled                        : enableOSDemo,
+        vsphereUbuntuEnabled                 : enableVsphereUbuntu,
         artifactsBuildEnabled                : enableArtifactsBuild,
         multiregionalConfiguration           : multiregionalMappings,
         demoWeight                           : demoWeight]
@@ -655,8 +669,8 @@
         booleanParam(name: 'OFFLINE_CHILD_CLUSTER', value: triggers.proxyConfig['childOffline']),
         booleanParam(name: 'PROXY_CHILD_CLUSTER', value: triggers.proxyConfig['childProxy']),
         booleanParam(name: 'SEED_MACOS', value: triggers.useMacOsSeedNode),
-        booleanParam(name: 'MOS_TF_DEPLOY', value: triggers.mosTfDeployEnabled),
         booleanParam(name: 'UPGRADE_MGMT_CLUSTER', value: triggers.upgradeMgmtEnabled),
+        booleanParam(name: 'AUTO_UPGRADE_MCC', value: triggers.autoUpgradeMgmtEnabled),
         booleanParam(name: 'ENABLE_LMA_LOGGING', value: triggers.enableLMALoggingEnabled),
         booleanParam(name: 'RUN_UI_E2E', value: triggers.runUie2eEnabled),
         booleanParam(name: 'RUN_MGMT_CFM', value: triggers.runMgmtConformanceEnabled),
diff --git a/src/com/mirantis/mk/Orchestrate.groovy b/src/com/mirantis/mk/Orchestrate.groovy
index 3e119f3..5773e55 100644
--- a/src/com/mirantis/mk/Orchestrate.groovy
+++ b/src/com/mirantis/mk/Orchestrate.groovy
@@ -752,7 +752,7 @@
     salt.enforceStateWithTest([saltId: master, target: "I@docker:swarm:role:master and I@jenkins:client ${dockerClientExclude} ${extra_tgt}", state: 'docker.client', retries: 2])
 
     // API timeout in minutes
-    def wait_timeout = 10
+    def wait_timeout = 30
 
     // Gerrit
     def gerrit_master_url = salt.getPillar(master, gerrit_compound, '_param:gerrit_master_url')