Merge "Add possibility to perform conformance runs before and after k8s update"
diff --git a/cloud-update.groovy b/cloud-update.groovy
index 9fdeaad..56f9351 100644
--- a/cloud-update.groovy
+++ b/cloud-update.groovy
@@ -846,7 +846,7 @@
 timeout(time: 12, unit: 'HOURS') {
     node() {
         try {
-            if(RUN_CVP_TESTS.toBoolean() == True){
+            if(RUN_CVP_TESTS.toBoolean() == true){
                 stage('Run CVP tests before upgrade.') {
                     build job: "cvp-sanity"
                     build job: "cvp-func"
@@ -1581,7 +1581,7 @@
                 // verification is already present in restore pipelines
             }
 
-            if(RUN_CVP_TESTS.toBoolean() == True){
+            if(RUN_CVP_TESTS.toBoolean() == true){
                 stage('Run CVP tests after upgrade.') {
                     build job: "cvp-sanity"
                     build job: "cvp-func"
diff --git a/cvp-ha.groovy b/cvp-ha.groovy
index 414ab46..b33cda6 100644
--- a/cvp-ha.groovy
+++ b/cvp-ha.groovy
@@ -44,7 +44,7 @@
                 if (!keystone_creds) {
                     keystone_creds = validate._get_keystone_creds_v2(saltMaster)
                 }
-                validate.runContainer(saltMaster, TARGET_NODE, TEST_IMAGE, 'cvp', keystone_creds)
+                validate.runContainer(saltMaster, TEMPEST_TARGET_NODE, TEST_IMAGE, 'cvp', keystone_creds)
                 validate.configureContainer(saltMaster, TEMPEST_TARGET_NODE, PROXY, TOOLS_REPO, TEMPEST_REPO)
             }
 
diff --git a/opencontrail40-upgrade.groovy b/opencontrail40-upgrade.groovy
index 52a0d23..7b5036f 100644
--- a/opencontrail40-upgrade.groovy
+++ b/opencontrail40-upgrade.groovy
@@ -26,9 +26,9 @@
 def command = 'cmd.shell'
 
 def controlPkgs = 'contrail-config,contrail-config-openstack,contrail-control,contrail-dns,contrail-lib,contrail-nodemgr,contrail-utils,contrail-web-controller,contrail-web-core,neutron-plugin-contrail,python-contrail,contrail-database'
-def thirdPartyControlPkgsToRemove = 'redis-server,ifmap-server,supervisor'
+def thirdPartyControlPkgsToRemove = 'zookeeper,libzookeeper-java,kafka,cassandra,redis-server,ifmap-server,supervisor'
 def analyticsPkgs = 'contrail-analytics,contrail-lib,contrail-nodemgr,contrail-utils,python-contrail,contrail-database'
-def thirdPartyAnalyticsPkgsToRemove = 'redis-server,supervisor'
+def thirdPartyAnalyticsPkgsToRemove = 'zookeeper,libzookeeper-java,kafka,cassandra,python-cassandra,cassandra-cpp-driver,redis-server,supervisor'
 //def cmpPkgs = ['contrail-lib', 'contrail-nodemgr', 'contrail-utils', 'contrail-vrouter-agent', 'contrail-vrouter-utils', 'python-contrail', 'python-contrail-vrouter-api', 'python-opencontrail-vrouter-netns', 'contrail-vrouter-dkms']
 def CMP_PKGS = 'contrail-lib contrail-nodemgr contrail-utils contrail-vrouter-agent contrail-vrouter-utils python-contrail python-contrail-vrouter-api python-opencontrail-vrouter-netns contrail-vrouter-dkms'
 def KERNEL_MODULE_RELOAD = 'service supervisor-vrouter stop; rmmod vrouter; sync && echo 3 > /proc/sys/vm/drop_caches && echo 1 > /proc/sys/vm/compact_memory; service contrail-vrouter-agent start; service contrail-vrouter-nodemgr start'
@@ -164,20 +164,44 @@
                     common.errorMsg("Opencontrail Controller failed to be upgraded.")
                     throw er
                 }
+            }
 
+            stage('Opencontrail controllers backup and cleanup') {
+                try {
+                    salt.runSaltProcessStep(pepperEnv, 'I@opencontrail:control', 'archive.tar', ['zcvf', '/root/contrail-database.tgz', '/var/lib/cassandra'])
+                    salt.runSaltProcessStep(pepperEnv, 'I@opencontrail:control', 'archive.tar', ['zcvf', '/root/contrail-zookeeper.tgz', '/var/lib/zoopeeker'])
+                    salt.runSaltProcessStep(pepperEnv, 'I@opencontrail:collector', 'archive.tar', ['zcvf', '/root/contrail-analytics-database.tgz', '/var/lib/cassandra'])
+                    salt.runSaltProcessStep(pepperEnv, 'I@opencontrail:collector', 'archive.tar', ['zcvf', '/root/contrail-analytics-zookeeper.tgz', '/var/lib/zookeeper'])
+
+                    for (service in (controlServices + thirdPartyServicesToDisable)) {
+                        salt.runSaltProcessStep(pepperEnv, 'I@opencontrail:control', 'service.disable', [service])
+                    }
+                    for (service in (analyticsServices + thirdPartyServicesToDisable)) {
+                        salt.runSaltProcessStep(pepperEnv, 'I@opencontrail:collector', 'service.disable', [service])
+                    }
+
+                    def tmpCfgBackupDir = '/tmp/cfg_backup'
+                    def thirdPartyCfgFilesToBackup = ['/var/lib/zookeeper/myid', '/etc/zookeeper/conf/', '/usr/share/kafka/config/']
+
+                    salt.runSaltProcessStep(pepperEnv, 'I@opencontrail:control or I@opencontrail:collector', 'file.makedirs', [tmpCfgBackupDir])
+
+                    for (cfgFilePath in thirdPartyCfgFilesToBackup) {
+                        salt.runSaltProcessStep(pepperEnv, 'I@opencontrail:control or I@opencontrail:collector', 'file.makedirs', [tmpCfgBackupDir + cfgFilePath])
+                        salt.runSaltProcessStep(pepperEnv, 'I@opencontrail:control or I@opencontrail:collector', 'file.copy', [cfgFilePath, tmpCfgBackupDir + cfgFilePath, 'recurse=True'])
+                    }
+
+                    salt.runSaltProcessStep(pepperEnv, 'I@opencontrail:control', 'pkg.remove', [controlPkgs + ',' + thirdPartyControlPkgsToRemove])
+                    salt.runSaltProcessStep(pepperEnv, 'I@opencontrail:collector', 'pkg.remove', [analyticsPkgs + ',' + thirdPartyAnalyticsPkgsToRemove])
+
+                    for (cfgFilePath in thirdPartyCfgFilesToBackup) {
+                        salt.runSaltProcessStep(pepperEnv, 'I@opencontrail:control or I@opencontrail:collector', 'file.makedirs', [cfgFilePath])
+                        salt.runSaltProcessStep(pepperEnv, 'I@opencontrail:control or I@opencontrail:collector', 'file.copy', [tmpCfgBackupDir + cfgFilePath, cfgFilePath, 'recurse=True'])
+                    }
+                } catch (Exception er) {
+                    common.errorMsg("Opencontrail Controllers backup and cleanup stage has failed.")
+                    throw er
+                }
             }
-            salt.runSaltProcessStep(pepperEnv, 'I@opencontrail:control', 'archive.tar', ['zcvf', '/root/contrail-database.tgz', '/var/lib/cassandra'])
-            salt.runSaltProcessStep(pepperEnv, 'I@opencontrail:control', 'archive.tar', ['zcvf', '/root/contrail-zookeeper.tgz', '/var/lib/zoopeeker'])
-            salt.runSaltProcessStep(pepperEnv, 'I@opencontrail:collector', 'archive.tar', ['zcvf', '/root/contrail-analytics-database.tgz', '/var/lib/cassandra'])
-            salt.runSaltProcessStep(pepperEnv, 'I@opencontrail:collector', 'archive.tar', ['zcvf', '/root/contrail-analytics-zookeeper.tgz', '/var/lib/zookeeper'])
-            for (service in (controlServices + thirdPartyServicesToDisable)) {
-                salt.runSaltProcessStep(pepperEnv, 'I@opencontrail:control', 'service.disable', [service])
-            }
-            for (service in (analyticsServices + thirdPartyServicesToDisable)) {
-                salt.runSaltProcessStep(pepperEnv, 'I@opencontrail:collector', 'service.disable', [service])
-            }
-            salt.runSaltProcessStep(pepperEnv, 'I@opencontrail:control', 'pkg.remove', [controlPkgs + ',' + thirdPartyControlPkgsToRemove])
-            salt.runSaltProcessStep(pepperEnv, 'I@opencontrail:collector', 'pkg.remove', [analyticsPkgs + ',' + thirdPartyAnalyticsPkgsToRemove])
         }