From d6f768b24ee2b3129b17db9ffecfb59a10eba593 Mon Sep 17 00:00:00 2001 From: Rishabh Dave Date: Sat, 7 Sep 2019 22:07:40 +0530 Subject: [PATCH] qa/cephfs: test conf file reading for CephFS shell Adds tests that checks - * reading conf option * reading conf option after setting it twice * reading conf option after setting it after a reset Signed-off-by: Rishabh Dave --- qa/tasks/cephfs/test_cephfs_shell.py | 54 ++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/qa/tasks/cephfs/test_cephfs_shell.py b/qa/tasks/cephfs/test_cephfs_shell.py index 4a7b723c7f1..630fc459619 100644 --- a/qa/tasks/cephfs/test_cephfs_shell.py +++ b/qa/tasks/cephfs/test_cephfs_shell.py @@ -28,6 +28,11 @@ def humansize(nbytes): f = ('%d' % nbytes).rstrip('.') return '%s%s' % (f, suffixes[i]) +def str_to_bool(val): + val = val.strip() + trueval = ['true', 'yes', 'y', '1'] + return True if val == 1 or val.lower() in trueval else False + class TestCephFSShell(CephFSTestCase): CLIENTS_REQUIRED = 1 @@ -692,3 +697,52 @@ class TestMisc(TestCephFSShell): """ o = self.get_cephfs_shell_cmd_output("help all") log.info("output:\n{}".format(o)) + +class TestConfReading(TestCephFSShell): + + def test_reading_conf_opt(self): + """ + Read conf without duplicate sections/options. + """ + debugval = self.fs.mon_manager.raw_cluster_cmd('config', 'get', + 'client','debug_shell') + debugval = str_to_bool(debugval) + self.fs.mon_manager.raw_cluster_cmd('config', 'set', 'client', + 'debug_shell', str(not debugval)) + output = self.get_cephfs_shell_cmd_output('set debug') + new_debug_val = \ + str_to_bool(output[output.find('debug: ') + len('debug: ') : ]) + assert not debugval == new_debug_val + + def test_reading_conf_after_setting_opt_twice(self): + """ + Read conf without duplicate sections/options. + """ + debugval = self.fs.mon_manager.raw_cluster_cmd('config', 'get', + 'client','debug_shell') + debugval = str_to_bool(debugval) + + self.fs.mon_manager.raw_cluster_cmd('config', 'set', 'client', + 'debug_shell', str(not debugval)) + self.fs.mon_manager.raw_cluster_cmd('config', 'set', 'client', + 'debug_shell', str(not debugval)) + output = self.get_cephfs_shell_cmd_output('set debug') + new_debug_val = \ + str_to_bool(output[output.find('debug: ') + len('debug: ') : ]) + assert not debugval == new_debug_val + + def test_reading_conf_after_resetting_opt(self): + debugval = self.fs.mon_manager.raw_cluster_cmd('config', 'get', + 'client','debug_shell') + debugval = str_to_bool(debugval) + + self.fs.mon_manager.raw_cluster_cmd('config', 'set', 'client', + 'debug_shell', str(not debugval)) + self.fs.mon_manager.raw_cluster_cmd('config', 'rm', 'client', + 'debug_shell') + self.fs.mon_manager.raw_cluster_cmd('config', 'set', 'client', + 'debug_shell', str(not debugval)) + output = self.get_cephfs_shell_cmd_output('set debug') + new_debug_val = \ + str_to_bool(output[output.find('debug: ') + len('debug: ') : ]) + assert not debugval == new_debug_val -- 2.39.5