summaryrefslogtreecommitdiffstats
path: root/glustolibs-gluster/glustolibs/gluster/dht_test_utils.py
diff options
context:
space:
mode:
authorkshithijiyer <kshithij.ki@gmail.com>2020-04-01 10:44:54 +0530
committerkshithijiyer <kshithij.ki@gmail.com>2020-04-01 12:17:18 +0530
commitdd2382c613db6f3dd72a25c74d5f765006aea31f (patch)
treefcbdca0fc93539b7eee159bfa3c381167cd0eb1c /glustolibs-gluster/glustolibs/gluster/dht_test_utils.py
parentd4349ba649c967ed6c16c1efdd9caa56433142f1 (diff)
[Libfix] Remove rpyc_get_connection() dependency from code
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: The solution here is to modify the code to not use `g.rpyc_get_connection()`. The following changes are done to accomplish it: 1)Remove code which uses g.rpyc_get_connection() and use generic logic in functions: a. do_bricks_exist_in_shd_volfile() b. get_disk_usage() c. mount_volume() d. list_files() f. append_string_to_file() 2)Create files which can be uploaded and executed on clients/servers to avoid rpc calls in functions: a. calculate_hash() b. validate_files_in_dir() 3)Modify setup.py to push the below files to `/usr/share/glustolibs/scripts/`: a.compute_hash.py b.walk_dir.py Change-Id: I00a81a88382bf3f8b366753eebdb2999260788ca Signed-off-by: kshithijiyer <kshithij.ki@gmail.com>
Diffstat (limited to 'glustolibs-gluster/glustolibs/gluster/dht_test_utils.py')
-rw-r--r--glustolibs-gluster/glustolibs/gluster/dht_test_utils.py27
1 files changed, 20 insertions, 7 deletions
diff --git a/glustolibs-gluster/glustolibs/gluster/dht_test_utils.py b/glustolibs-gluster/glustolibs/gluster/dht_test_utils.py
index 8cef3015b..55dcce5c7 100644
--- a/glustolibs-gluster/glustolibs/gluster/dht_test_utils.py
+++ b/glustolibs-gluster/glustolibs/gluster/dht_test_utils.py
@@ -22,7 +22,7 @@ import os
from glusto.core import Glusto as g
from glustolibs.gluster.glusterfile import (GlusterFile, calculate_hash,
- get_pathinfo)
+ get_pathinfo, file_exists)
from glustolibs.gluster.glusterdir import GlusterDir
from glustolibs.gluster.layout import Layout
import glustolibs.gluster.constants as k
@@ -30,6 +30,7 @@ import glustolibs.gluster.exceptions as gex
from glustolibs.gluster.brickdir import BrickDir
from glustolibs.gluster.volume_libs import get_subvols, get_volume_type
from glustolibs.gluster.gluster_init import get_gluster_version
+from glustolibs.misc.misc_libs import upload_scripts
def run_layout_tests(mnode, fqpath, layout, test_type):
@@ -120,11 +121,25 @@ def validate_files_in_dir(mnode, rootdir,
"""
layout_cache = {}
- conn = g.rpyc_get_connection(mnode)
- if conn is None:
- g.log.info("Not able to establish connection to node %s" % mnode)
+ script_path = ("/usr/share/glustolibs/scripts/walk_dir.py")
+ if not file_exists(mnode, script_path):
+ if upload_scripts(mnode, script_path,
+ "/usr/share/glustolibs/scripts/"):
+ g.log.info("Successfully uploaded script "
+ "walk_dir.py!")
+ else:
+ g.log.error("Faild to upload walk_dir.py!")
+ return False
+ else:
+ g.log.info("compute_hash.py already present!")
+
+ cmd = ("/usr/bin/env python {0} {1}".format(script_path, rootdir))
+ ret, out, _ = g.run(mnode, cmd)
+ if ret:
+ g.log.error('Unable to run the script on node {0}'
+ .format(mnode))
return False
- for walkies in conn.modules.os.walk(rootdir):
+ for walkies in eval(out):
g.log.info("TESTING DIRECTORY %s..." % walkies[0])
# check directories
@@ -161,8 +176,6 @@ def validate_files_in_dir(mnode, rootdir,
if test_type & k.TEST_FILE_EXISTS_ON_HASHED_BRICKS:
run_hashed_bricks_test(gfile)
-
- g.rpyc_close_connection(mnode)
return True