Merge "Fix adding description in manageArtifacts"
diff --git a/src/com/mirantis/mk/Common.groovy b/src/com/mirantis/mk/Common.groovy
index 17ab32c..a85196c 100644
--- a/src/com/mirantis/mk/Common.groovy
+++ b/src/com/mirantis/mk/Common.groovy
@@ -1208,6 +1208,24 @@
     return v1 >= v2
 }
 
+/**
+ * Sort array of versions. Returns sorted array (ascending)
+ * @param ArrayList versions
+ */
+def sortVersions (ArrayList versions) {
+    for (int i = 0; i < versions.size(); i++) {
+        for (int j = 0; j < versions.size() - i - 1; j++) {
+            if (isVerGreaterOrEqual(versions[j], versions[j + 1])) {
+                def temp = versions[j]
+                versions[j] = versions[j + 1]
+                versions[j + 1] = temp
+            }
+        }
+    }
+
+    return versions
+}
+
 def readYaml2(LinkedHashMap kwargs) {
     /**
      *  readYaml wrapper to workaround case when initial file contains
diff --git a/src/com/mirantis/mk/KaasUtils.groovy b/src/com/mirantis/mk/KaasUtils.groovy
index 2526a9c..72d42a2 100644
--- a/src/com/mirantis/mk/KaasUtils.groovy
+++ b/src/com/mirantis/mk/KaasUtils.groovy
@@ -100,6 +100,13 @@
     def auditd = env.AUDITD_ENABLE ? env.AUDITD_ENABLE.toBoolean() : false
     def customSlackChannel = env.SLACK_CHANNEL_NOTIFY ? env.SLACK_CHANNEL_NOTIFY : ''
     def runNTPUpdateTest = env.RUN_NTP_UPDATE_TEST ? env.RUN_NTP_UPDATE_TEST.toBoolean() : false
+    def runMCCMariaBackupRestoreTest = env.RUN_MCC_MARIA_BACKUP_RESTORE_TEST ? env.RUN_MCC_MARIA_BACKUP_RESTORE_TEST.toBoolean() : false
+    def runRuntimeMigrateExtendedTestMgmt = env.RUN_MGMT_RUNTIME_MIGRATE_EXTENDED_TEST ? env.RUN_MGMT_RUNTIME_MIGRATE_EXTENDED_TEST.toBoolean() : false
+    def runRuntimeMigrateQuickTestMgmt = env.RUN_MGMT_RUNTIME_MIGRATE_QUICK_TEST ? env.RUN_MGMT_RUNTIME_MIGRATE_QUICK_TEST.toBoolean() : false
+    def runRuntimeMigrateAndRollbackTestMgmt = env.RUN_MGMT_RUNTIME_MIGRATE_AND_ROLLBACK_TEST ? env.RUN_MGMT_RUNTIME_MIGRATE_AND_ROLLBACK_TEST.toBoolean() : false
+    def runRuntimeMigrateExtendedTestChild = env.RUN_CHILD_RUNTIME_MIGRATE_EXTENDED_TEST ? env.RUN_CHILD_RUNTIME_MIGRATE_EXTENDED_TEST.toBoolean() : false
+    def runRuntimeMigrateQuickTestChild = env.RUN_CHILD_RUNTIME_MIGRATE_QUICK_TEST ? env.RUN_CHILD_RUNTIME_MIGRATE_QUICK_TEST.toBoolean() : false
+    def runRuntimeMigrateAndRollbackTestChild = env.RUN_CHILD_RUNTIME_MIGRATE_AND_ROLLBACK_TEST ? env.RUN_CHILD_RUNTIME_MIGRATE_AND_ROLLBACK_TEST.toBoolean() : false
     // multiregion configuration from env variable: comma-separated string in form $mgmt_provider,$regional_provider
     def multiregionalMappings = env.MULTIREGION_SETUP ? multiregionWorkflowParser(env.MULTIREGION_SETUP) : [
         enabled: false,
@@ -121,7 +128,7 @@
     def equinixOnAwsDemo = env.EQUINIX_ON_AWS_DEMO ? env.EQUINIX_ON_AWS_DEMO.toBoolean() : false
     def azureOnAwsDemo = env.AZURE_ON_AWS_DEMO ? env.AZURE_ON_AWS_DEMO.toBoolean() : false
     def azureOnDemandDemo = env.ALLOW_AZURE_ON_DEMAND ? env.ALLOW_AZURE_ON_DEMAND.toBoolean() : false
-    def enableVsphereDemo = true
+    def enableVsphereDemo = env.ALLOW_VSPHERE_ON_DEMAND ? env.ALLOW_VSPHERE_ON_DEMAND.toBoolean() : false
     def enableOSDemo = true
     def enableBMDemo = true
     def enablebmCoreDemo = env.ALLOW_BM_CORE_ON_DEMAND ? env.ALLOW_BM_CORE_ON_DEMAND.toBoolean() : false
@@ -141,6 +148,9 @@
     def enableBv2Smoke = true
     def runCacheWarmup = env.CACHE_WARMUP_ENABLED ? env.CACHE_WARMUP_ENABLED.toBoolean() : false
     def cveScan = false
+    // Sync to public CDN is triggered automatically for corresponding scenarios
+    // This trigger is used only for on-demand cases
+    def publicCISync = 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.*/) {
@@ -400,6 +410,11 @@
         common.errorMsg('CVE Scan job enabled')
     }
 
+    if (commitMsg ==~ /(?s).*\[public-ci-sync\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*public-ci-sync\.*/) {
+        publicCISync = true
+        common.errorMsg('Sync to public-ci CDN is enabled')
+    }
+
     def slackChannelMatches = (commitMsg =~ /(\[slack-channel\s*[#@](\S+)])/)
     if (slackChannelMatches.size() > 0) {
         // override chanenel notify when it set explicitly
@@ -453,6 +468,41 @@
         common.warningMsg('After deployment of mgmt job with NTP update will be executed')
     }
 
+    if (commitMsg ==~ /(?s).*\[mcc-maria-backup-restore\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mcc-maria-backup-restore\.*/) {
+        runMCCMariaBackupRestoreTest = true
+        common.warningMsg('MCC Maria Backup/Restore test will be executed as part of mgmt test suite')
+    }
+
+    if (commitMsg ==~ /(?s).*\[runtime-migrate-extended-mgmt\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*runtime-migrate-extended-mgmt\.*/) {
+        runRuntimeMigrateExtendedTestMgmt = true
+        common.warningMsg('Runtime migration with semi-reverts (extended test) scheduled as part of mgmt test suite')
+    }
+
+    if (commitMsg ==~ /(?s).*\[runtime-migrate-quick-mgmt\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*runtime-migrate-quick-mgmt\.*/) {
+        runRuntimeMigrateQuickTestMgmt = true
+        common.warningMsg('Runtime migration of all nodes in one action (quick test) scheduled as part of mgmt test suite')
+    }
+
+    if (commitMsg ==~ /(?s).*\[runtime-migrate-and-rollback-mgmt\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*runtime-migrate-and-rollback-mgmt\.*/) {
+        runRuntimeMigrateAndRollbackTestMgmt = true
+        common.warningMsg('Runtime migration with semi-reverts (extended test) and runtime rollback scheduled as part of mgmt test suite')
+    }
+
+    if (commitMsg ==~ /(?s).*\[runtime-migrate-extended-child\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*runtime-migrate-extended-child\.*/) {
+        runRuntimeMigrateExtendedTestChild = true
+        common.warningMsg('Runtime migration with semi-reverts (extended test) scheduled as part of child test suite')
+    }
+
+    if (commitMsg ==~ /(?s).*\[runtime-migrate-quick-child\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*runtime-migrate-quick-child\.*/) {
+        runRuntimeMigrateQuickTestChild = true
+        common.warningMsg('Runtime migration of all nodes in one action (quick test) scheduled as part of child test suite')
+    }
+
+    if (commitMsg ==~ /(?s).*\[runtime-migrate-and-rollback-child\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*runtime-migrate-and-rollback-child\.*/) {
+        runRuntimeMigrateAndRollbackTestChild = true
+        common.warningMsg('Runtime migration with semi-reverts (extended test) and runtime rollback scheduled as part of child test suite')
+    }
+
     if (commitMsg ==~ /(?s).*\[internal-ntp\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*internal-ntp\.*/ || proxyConfig['mgmtOffline'] || proxyConfig['childOffline']) {
         configureInternalNTP = true
         openstackIMC = 'eu'
@@ -667,6 +717,14 @@
         CVE Scan enabled: ${cveScan}
         Keycloak+LDAP integration enabled: ${coreKeycloakLdap}
         NTP update job scheduled: ${runNTPUpdateTest}
+        MCC MariaDB Backup/Restore test enabled: ${runMCCMariaBackupRestoreTest}
+        Sync to public-ci CDN enabled: ${publicCISync}
+        Mgmt runtime migration (extended) enabled: ${runRuntimeMigrateExtendedTestMgmt}
+        Mgmt runtime migration (quick) enabled: ${runRuntimeMigrateQuickTestMgmt}
+        Mgmt runtime migration (extended) with rollback enabled: ${runRuntimeMigrateAndRollbackTestMgmt}
+        Child runtime migration (extended) enabled: ${runRuntimeMigrateExtendedTestChild}
+        Child runtime migration (quick) enabled: ${runRuntimeMigrateQuickTestChild}
+        Child runtime migration (extended) with rollback enabled: ${runRuntimeMigrateAndRollbackTestChild}
         Triggers: https://gerrit.mcp.mirantis.com/plugins/gitiles/kaas/core/+/refs/heads/master/hack/ci-gerrit-keywords.md""")
     return [
         osCloudLocation                          : openstackIMC,
@@ -747,6 +805,14 @@
         coreKeycloakLdapEnabled                  : coreKeycloakLdap,
         internalNTPServersEnabled                : configureInternalNTP,
         runNTPUpdateTestEnabled                  : runNTPUpdateTest,
+        runMCCMariaBackupRestoreTestEnabled      : runMCCMariaBackupRestoreTest,
+        publicCISyncEnabled                      : publicCISync,
+        runtimeMigrateExtendedMgmtEnabled        : runRuntimeMigrateExtendedTestMgmt,
+        runtimeMigrateQuickMgmtEnabled           : runRuntimeMigrateQuickTestMgmt,
+        runtimeMigrateMgmtAndRollbackEnabled     : runRuntimeMigrateAndRollbackTestMgmt,
+        runtimeMigrateExtendedChildEnabled       : runRuntimeMigrateExtendedTestChild,
+        runtimeMigrateQuickChildEnabled          : runRuntimeMigrateQuickTestChild,
+        runtimeMigrateChildAndRollbackEnabled    : runRuntimeMigrateAndRollbackTestChild,
     ]
 }
 
@@ -1072,7 +1138,14 @@
         booleanParam(name: "AUDITD_ENABLE", value: triggers.auditdEnabled),
         booleanParam(name: 'CORE_KEYCLOAK_LDAP_ENABLED', value: triggers.coreKeycloakLdapEnabled),
         booleanParam(name: 'CORE_KAAS_NTP_ENABLED', value: triggers.internalNTPServersEnabled),
-        booleanParam(name: 'RUN_NTP_UPDATE_TEST', value: triggers.runNTPUpdateTestEnabled)
+        booleanParam(name: 'RUN_NTP_UPDATE_TEST', value: triggers.runNTPUpdateTestEnabled),
+        booleanParam(name: 'RUN_MCC_MARIA_BACKUP_RESTORE_TEST', value: triggers.runMCCMariaBackupRestoreTestEnabled),
+        booleanParam(name: 'RUN_MGMT_RUNTIME_MIGRATE_EXTENDED_TEST', value: triggers.runtimeMigrateExtendedMgmtEnabled),
+        booleanParam(name: 'RUN_MGMT_RUNTIME_MIGRATE_QUICK_TEST', value: triggers.runtimeMigrateQuickMgmtEnabled),
+        booleanParam(name: 'RUN_MGMT_RUNTIME_MIGRATE_AND_ROLLBACK_TEST', value: triggers.runtimeMigrateMgmtAndRollbackEnabled),
+        booleanParam(name: 'RUN_CHILD_RUNTIME_MIGRATE_EXTENDED_TEST', value: triggers.runtimeMigrateExtendedChildEnabled),
+        booleanParam(name: 'RUN_CHILD_RUNTIME_MIGRATE_QUICK_TEST', value: triggers.runtimeMigrateQuickChildEnabled),
+        booleanParam(name: 'RUN_CHILD_RUNTIME_MIGRATE_AND_ROLLBACK_TEST', value: triggers.runtimeMigrateChildAndRollbackEnabled),
     ]
 
     // customize multiregional demo
diff --git a/src/com/mirantis/mk/Workflow.groovy b/src/com/mirantis/mk/Workflow.groovy
index 67d61a8..c6f7e7b 100644
--- a/src/com/mirantis/mk/Workflow.groovy
+++ b/src/com/mirantis/mk/Workflow.groovy
@@ -851,7 +851,8 @@
             jobs.each { stepName, job ->
                 common.infoMsg("${prefixMsg} Running sequence ${stepName}")
                 job()
-                sleep(30)
+                // just in case sleep.
+                sleep(5)
             }
             sequenceSummary['nested_result'] = 'SUCCESS'
         } catch (InterruptedException e) {