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