diff options
author | kshithijiyer <kshithij.ki@gmail.com> | 2020-04-16 16:44:01 +0530 |
---|---|---|
committer | kshithijiyer <kshithij.ki@gmail.com> | 2020-04-16 16:55:06 +0530 |
commit | fb77a9055e12b753d202d55d4e44776735588160 (patch) | |
tree | d73ba860185fdc83de5cae97d620e94447cc2d3b /tests/functional/arbiter | |
parent | 5b93ecfcb7b9dc591da9cbbe39efd1ec1b1c38ac (diff) |
[Testfix] Fix rpyc_get_connection() issue in test_metadata_self_heal
Problem:
`g.rpyc_get_connection()` has a limitaion where it can't
convert python2 calls to python3 calls. Due to this a large
number of testcases fail when executed from a python2 machine
on a python3 only setup or visa versa with the below stack trace:
```
E ========= Remote Traceback (1) =========
E Traceback (most recent call last):
E File "/root/tmp.tL8Eqx7d8l/rpyc/core/protocol.py", line 323, in _dispatch_request
E res = self._HANDLERS[handler](self, *args)
E File "/root/tmp.tL8Eqx7d8l/rpyc/core/protocol.py", line 591, in _handle_inspect
E if hasattr(self._local_objects[id_pack], '____conn__'):
E File "/root/tmp.tL8Eqx7d8l/rpyc/lib/colls.py", line 110, in __getitem__
E return self._dict[key][0]
E KeyError: (b'rpyc.core.service.SlaveService', 94282642994712, 140067150858560)
```
Solution:
Write generic code which can run from python2 to
python3 and visa-versa
Change-Id: I7783485a784ef4b57f626f77e6012d918fee6032
Signed-off-by: kshithijiyer <kshithij.ki@gmail.com>
Diffstat (limited to 'tests/functional/arbiter')
-rwxr-xr-x | tests/functional/arbiter/test_metadata_self_heal.py | 31 |
1 files changed, 15 insertions, 16 deletions
diff --git a/tests/functional/arbiter/test_metadata_self_heal.py b/tests/functional/arbiter/test_metadata_self_heal.py index 81a098fff..4af3f8747 100755 --- a/tests/functional/arbiter/test_metadata_self_heal.py +++ b/tests/functional/arbiter/test_metadata_self_heal.py @@ -356,11 +356,6 @@ class TestMetadataSelfHeal(GlusterBaseClass): ret, out, err = g.run(node, command) file_list = out.split() - g.log.info('Checking for user and group on %s...', node) - conn = g.rpyc_get_connection(node) - if conn is None: - raise Exception("Unable to get connection on node %s" % node) - for file_name in file_list: file_to_check = '%s/%s/%s' % (nodes_to_check[node], test_meta_data_self_heal_folder, @@ -368,26 +363,30 @@ class TestMetadataSelfHeal(GlusterBaseClass): g.log.info('Checking for permissions, user and group for %s', file_name) + # Check for permissions - permissions = oct( - conn.modules.os.stat(file_to_check).st_mode)[-3:] - self.assertEqual(permissions, '444', + cmd = ("stat -c '%a %n' {} | awk '{{print $1}}'" + .format(file_to_check)) + ret, permissions, _ = g.run(node, cmd) + self.assertEqual(permissions.split('\n')[0], '444', 'Permissions %s is not equal to 444' % permissions) g.log.info("Permissions are '444' for %s", file_name) # Check for user - uid = conn.modules.os.stat(file_to_check).st_uid - username = conn.modules.pwd.getpwuid(uid).pw_name - self.assertEqual(username, 'qa', 'User %s is not equal qa' + cmd = ("ls -ld {} | awk '{{print $3}}'" + .format(file_to_check)) + ret, username, _ = g.run(node, cmd) + self.assertEqual(username.split('\n')[0], + 'qa', 'User %s is not equal qa' % username) g.log.info("User is 'qa' for %s", file_name) # Check for group - gid = conn.modules.os.stat(file_to_check).st_gid - groupname = conn.modules.grp.getgrgid(gid).gr_name - self.assertEqual(groupname, 'qa', 'Group %s is not equal qa' + cmd = ("ls -ld {} | awk '{{print $4}}'" + .format(file_to_check)) + ret, groupname, _ = g.run(node, cmd) + self.assertEqual(groupname.split('\n')[0], + 'qa', 'Group %s is not equal qa' % groupname) g.log.info("Group is 'qa' for %s", file_name) - - g.rpyc_close_connection(host=node) |