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