Add parameter for upgrade on tag automaticaly

Change-Id: I83ce6de74cb633e8f493fa7edacfa1d1c43feb84
diff --git a/jobs/global.yaml b/jobs/global.yaml
index dcb7ceb..32baf23 100755
--- a/jobs/global.yaml
+++ b/jobs/global.yaml
@@ -1,16 +1,17 @@
-- defaults:

-    name: global

-    job-description: |

-      Do not edit this job through the web ! <br>

-      Please use jenkins-job-builder in git <br>

-      git clone ssh://gerrit.mcp.mirantis.com:29418/mcp/tcp-qa

-

-      <h1><font color='red'>

-      <!--- INSERT ALERT HERE vvvvvvv --->

-

-      <!--- INSERT ALERT HERE ^^^^^^^ --->

-      </font></h1>

-    current-version: 2019.2.21

-    previous-version: 2019.2.20

-    disabled-proposed: false

-    disabled-2019-2-0: true

+- defaults:
+    name: global
+    job-description: |
+      Do not edit this job through the web ! <br>
+      Please use jenkins-job-builder in git <br>
+      git clone ssh://gerrit.mcp.mirantis.com:29418/mcp/tcp-qa
+
+      <h1><font color='red'>
+      <!--- INSERT ALERT HERE vvvvvvv --->
+
+      <!--- INSERT ALERT HERE ^^^^^^^ --->
+      </font></h1>
+    current-version: 2019.2.21
+    previous-version: 2019.2.20
+    disabled-proposed: false
+    disabled-2019-2-0: true
+    upgrade-to-tag: false
diff --git a/jobs/pipelines/deploy-cicd-and-run-tests.groovy b/jobs/pipelines/deploy-cicd-and-run-tests.groovy
index a611a1a..2336aec 100644
--- a/jobs/pipelines/deploy-cicd-and-run-tests.groovy
+++ b/jobs/pipelines/deploy-cicd-and-run-tests.groovy
@@ -217,6 +217,27 @@
         if (env.RUN_UPGRADE_AFTER_JOB == "true" && currentBuild.result == 'SUCCESS') {
             network_backend = env.PLATFORM_STACK_INSTALL.contains("contrail") ? 'contrail' : 'dvr'
             upgrade_job = "mcp-update-${env.TEMPEST_IMAGE_VERSION}-${network_backend}-sl"
+            upgrade_to_tag = ''
+            contrail_upgrade_line = ''
+            if(env.UPGRADE_TO_TAG == "true") {
+                upgrade_to_tag = '--update-to-tag ${env.UPGRADE_VERSION_TAG} '
+            }
+            if(env.PLATFORM_STACK_INSTALL.contains("contrail") {
+                contrail_upgrade_line = "tcp_tests/tests/system/test_upgrade_contrail.py::TestUpdateContrail "
+            }
+            run_test_opts = """--keep-duplicates --maxfail=1 \
+                tcp_tests/tests/system/test_mcp_update.py::TestUpdateMcpCluster::test_update_drivetrain ${upgrade_to_tag} \
+                ${contrail_upgrade_line}\
+                tcp_tests/tests/system/test_mcp_update.py::TestOpenstackUpdate \
+                tcp_tests/tests/system/test_mcp_update.py::TestUpdateMcpCluster::test_update_galera --update-mysql-version 5.7 \
+                tcp_tests/tests/system/test_mcp_update.py::TestUpdateMcpCluster::test_update_rabbit \
+                tcp_tests/tests/system/test_mcp_update.py::TestUpdateMcpCluster::test_update_stacklight \
+                tcp_tests/tests/system/test_mcp_update.py::TestUpdateMcpCluster::test_update_ceph \
+                \
+                tcp_tests/tests/system/test_cvp_pipelines.py::TestCvpPipelines::test_run_cvp_tempest \
+                tcp_tests/tests/system/test_cvp_pipelines.py::TestCvpPipelines::test_run_cvp_func_sanity \
+                tcp_tests/tests/system/test_cvp_pipelines.py::TestCvpPipelines::test_run_cvp_stacklight
+            """
             if (env.IPMI_CREDS) {
                 upgrade_job = "mcp-update-bm-b300-queens-ovs-maas"
             }
@@ -227,6 +248,7 @@
                     string(name: 'PASSED_STEPS', value: steps),
                     string(name: 'TEMPEST_TEST_SUITE_NAME', value: env.TEMPEST_TEST_SUITE_NAME),
                     string(name: 'NODE', value: "openstack_slave_${env.ENV_NAME}")
+                    string(name: 'RUN_TEST_OPTS', value: run_test_opts)
                 ],
                 wait: false,
                 propagate: false
diff --git a/jobs/templates/released-heat-cicd-pike-contrail41-sl.yml b/jobs/templates/released-heat-cicd-pike-contrail41-sl.yml
index 0e00a79..37aadc0 100644
--- a/jobs/templates/released-heat-cicd-pike-contrail41-sl.yml
+++ b/jobs/templates/released-heat-cicd-pike-contrail41-sl.yml
@@ -212,6 +212,15 @@
         name: RUN_UPGRADE_AFTER_JOB
         default: true
         description: "Upgrade and test after deploy?"
+    - bool:
+        name: UPGRADE_TO_TAG
+        default: '{upgrade-to-tag}'
+        description: "Upgrade to new tag"
+    - string:
+        name: UPGRADE_VERSION_TAG
+        default: "{current-version}"
+        description: 'Only works in conjunction with UPGRADE_TO_TAG and must be younger than the deployed version.'
+        trim: 'false'
     pipeline-scm:
       lightweight-checkout: false
       scm:
diff --git a/jobs/templates/released-heat-cicd-pike-dvr-sl.yml b/jobs/templates/released-heat-cicd-pike-dvr-sl.yml
index da9c52a..0ea7e7b 100644
--- a/jobs/templates/released-heat-cicd-pike-dvr-sl.yml
+++ b/jobs/templates/released-heat-cicd-pike-dvr-sl.yml
@@ -212,6 +212,15 @@
         name: RUN_UPGRADE_AFTER_JOB
         default: true
         description: "Upgrade and test after deploy?"
+    - bool:
+        name: UPGRADE_TO_TAG
+        default: '{upgrade-to-tag}'
+        description: "Upgrade to new tag"
+    - string:
+        name: UPGRADE_VERSION_TAG
+        default: "{current-version}"
+        description: 'Only works in conjunction with UPGRADE_TO_TAG and must be younger than the deployed version.'
+        trim: 'false'
     pipeline-scm:
       lightweight-checkout: false
       scm:
diff --git a/jobs/templates/released-heat-cicd-queens-contrail41-sl.yml b/jobs/templates/released-heat-cicd-queens-contrail41-sl.yml
index 89f5d39..91f5f18 100644
--- a/jobs/templates/released-heat-cicd-queens-contrail41-sl.yml
+++ b/jobs/templates/released-heat-cicd-queens-contrail41-sl.yml
@@ -215,6 +215,15 @@
         name: RUN_UPGRADE_AFTER_JOB
         default: true
         description: "Upgrade and test after deploy?"
+    - bool:
+        name: UPGRADE_TO_TAG
+        default: '{upgrade-to-tag}'
+        description: "Upgrade to new tag"
+    - string:
+        name: UPGRADE_VERSION_TAG
+        default: "{current-version}"
+        description: 'Only works in conjunction with UPGRADE_TO_TAG and must be younger than the deployed version.'
+        trim: 'false'
     pipeline-scm:
       lightweight-checkout: false
       scm:
diff --git a/jobs/templates/released-heat-cicd-queens-dvr-sl.yml b/jobs/templates/released-heat-cicd-queens-dvr-sl.yml
index 8d845b6..1740a26 100644
--- a/jobs/templates/released-heat-cicd-queens-dvr-sl.yml
+++ b/jobs/templates/released-heat-cicd-queens-dvr-sl.yml
@@ -212,6 +212,15 @@
         name: RUN_UPGRADE_AFTER_JOB
         default: true
         description: "Upgrade and test after deploy?"
+    - bool:
+        name: UPGRADE_TO_TAG
+        default: '{upgrade-to-tag}'
+        description: "Upgrade to new tag"
+    - string:
+        name: UPGRADE_VERSION_TAG
+        default: "{current-version}"
+        description: 'Only works in conjunction with UPGRADE_TO_TAG and must be younger than the deployed version.'
+        trim: 'false'
     pipeline-scm:
       lightweight-checkout: false
       scm: