14f8ab
From ed6cd2b7674896c810fdd059e35a0d319aacb068 Mon Sep 17 00:00:00 2001
14f8ab
From: Shwetha K Acharya <sacharya@redhat.com>
14f8ab
Date: Tue, 2 Jul 2019 15:00:25 +0530
14f8ab
Subject: [PATCH 257/261] geo-rep: Test case for upgrading config file
14f8ab
14f8ab
Added test case for the patch
14f8ab
https://review.gluster.org/#/c/glusterfs/+/22894/4
14f8ab
14f8ab
Also updated if else structure in gsyncdconfig.py to avoid
14f8ab
repeated occurance of values in new configfile.
14f8ab
14f8ab
>fixes: bz#1707731
14f8ab
>Change-Id: If97e1d37ac52dbd17d47be6cb659fc5a3ccab6d7
14f8ab
>Signed-off-by: Shwetha K Acharya <sacharya@redhat.com>
14f8ab
14f8ab
backport of https://review.gluster.org/#/c/glusterfs/+/22982/
14f8ab
14f8ab
Bug: 1708064
14f8ab
Change-Id: If97e1d37ac52dbd17d47be6cb659fc5a3ccab6d7
14f8ab
Signed-off-by: Shwetha K Acharya <sacharya@redhat.com>
14f8ab
Reviewed-on: https://code.engineering.redhat.com/gerrit/176603
14f8ab
Tested-by: RHGS Build Bot <nigelb@redhat.com>
14f8ab
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
14f8ab
---
14f8ab
 geo-replication/syncdaemon/gsyncdconfig.py | 11 +++++------
14f8ab
 tests/00-geo-rep/georep-basic-dr-rsync.t   | 13 +++++++++++++
14f8ab
 2 files changed, 18 insertions(+), 6 deletions(-)
14f8ab
14f8ab
diff --git a/geo-replication/syncdaemon/gsyncdconfig.py b/geo-replication/syncdaemon/gsyncdconfig.py
14f8ab
index 7edc582..1fc451f 100644
14f8ab
--- a/geo-replication/syncdaemon/gsyncdconfig.py
14f8ab
+++ b/geo-replication/syncdaemon/gsyncdconfig.py
14f8ab
@@ -353,15 +353,14 @@ def config_upgrade(config_file, ret):
14f8ab
                 new_value = "tarssh"
14f8ab
             else:
14f8ab
                 new_value = "rsync"
14f8ab
-                config.set('vars', new_key, new_value)
14f8ab
-
14f8ab
-        if key == "timeout":
14f8ab
+            config.set('vars', new_key, new_value)
14f8ab
+        elif key == "timeout":
14f8ab
             new_key = "slave-timeout"
14f8ab
             config.set('vars', new_key, value)
14f8ab
-
14f8ab
         #for changes like: ignore_deletes to ignore-deletes
14f8ab
-        new_key = key.replace("_", "-")
14f8ab
-        config.set('vars', new_key, value)
14f8ab
+        else:
14f8ab
+            new_key = key.replace("_", "-")
14f8ab
+            config.set('vars', new_key, value)
14f8ab
 
14f8ab
     with open(config_file, 'w') as configfile:
14f8ab
         config.write(configfile)
14f8ab
diff --git a/tests/00-geo-rep/georep-basic-dr-rsync.t b/tests/00-geo-rep/georep-basic-dr-rsync.t
14f8ab
index 428e9ed..b432635 100644
14f8ab
--- a/tests/00-geo-rep/georep-basic-dr-rsync.t
14f8ab
+++ b/tests/00-geo-rep/georep-basic-dr-rsync.t
14f8ab
@@ -212,6 +212,19 @@ EXPECT_WITHIN $GEO_REP_TIMEOUT 0 verify_rename_with_existing_destination ${slave
14f8ab
 #Verify arequal for whole volume
14f8ab
 EXPECT_WITHIN $GEO_REP_TIMEOUT "x0" arequal_checksum ${master_mnt} ${slave_mnt}
14f8ab
 
14f8ab
+#Test config upgrade BUG: 1707731
14f8ab
+config_file=$GLUSTERD_WORKDIR/geo-replication/${GMV0}_${SH0}_${GSV0}/gsyncd.conf
14f8ab
+cat >> $config_file<
14f8ab
+[peers ${GMV0} ${GSV0}]
14f8ab
+use_tarssh = true
14f8ab
+timeout = 1
14f8ab
+EOL
14f8ab
+TEST $GEOREP_CLI $master $slave stop
14f8ab
+TEST $GEOREP_CLI $master $slave start
14f8ab
+#verify that the config file is updated
14f8ab
+EXPECT "1" echo $(grep -Fc "vars" $config_file)
14f8ab
+EXPECT "1" echo $(grep -Fc "sync-method = tarssh" $config_file)
14f8ab
+EXPECT "1" echo $(grep -Fc "slave-timeout = 1" $config_file)
14f8ab
 #Stop Geo-rep
14f8ab
 TEST $GEOREP_CLI $master $slave stop
14f8ab
 
14f8ab
-- 
14f8ab
1.8.3.1
14f8ab