From d0aee85958ff13d15eaf75468fe9af0698b06f2e Mon Sep 17 00:00:00 2001 From: kshithijiyer Date: Tue, 17 Dec 2019 11:49:26 +0530 Subject: [TC] Snapshot + glusterd: Status of snapshot after glusterd restart Checking the status of snapshot informations before and after restarting glusterd. Test case: 1. Create volume 2. Create two snapshots with description 3. Check snapshot status informations with snapname, volume name and without snap name/volname. 4. Restart glusterd on all nodes 5. Follow step3 again and validate snapshot History of the patch: The testcase was failing in CentOS-ci due to bug [1], However this bug was defered for fix. Post updating the code with the workaround mentioned below, it was observed that glusterd restart was failing due to bug [2]. And now as the both the bugs are fixed this patch is safe to merge. Workaround: Now the only possible workaround for this is to modify the function get_snap_info_by_volname() to not use --xml option and directly run the command which will dump the output as string which can be directly used in the testcase. This modification in the library function will not impact any other testcase. Links: [1] https://bugzilla.redhat.com/show_bug.cgi?id=1590797 [2] https://bugzilla.redhat.com/show_bug.cgi?id=1782200 Change-Id: I26ac0aaa5f6c8849fd9de41f506d6d13fc55e166 Co-authored-by: srivickynesh Signed-off-by: srivickynesh Signed-off-by: kshithijiyer --- glustolibs-gluster/glustolibs/gluster/snap_ops.py | 63 ++++------------------- 1 file changed, 11 insertions(+), 52 deletions(-) (limited to 'glustolibs-gluster/glustolibs/gluster') diff --git a/glustolibs-gluster/glustolibs/gluster/snap_ops.py b/glustolibs-gluster/glustolibs/gluster/snap_ops.py index 01a7df390..114366320 100644 --- a/glustolibs-gluster/glustolibs/gluster/snap_ops.py +++ b/glustolibs-gluster/glustolibs/gluster/snap_ops.py @@ -304,7 +304,7 @@ def get_snap_status_by_snapname(mnode, snapname): return None -def get_snap_status_by_volname(mnode, volname): +def snap_status_by_volname(mnode, volname): """Parse the output of 'gluster snapshot status' command for the given volume. @@ -313,59 +313,18 @@ def get_snap_status_by_volname(mnode, volname): volname (str): snapshot name Returns: - NoneType: None if command execution fails, parse errors. - list: list of dicts on success. - - Examples: - >>> get_snap_status_by_volname('abc.lab.eng.xyz.com', - 'testvol') - [{'volCount': '1', 'volume': {'brick': [{'path': '10.70.47.11: - testvol_brick0', 'pid': '26747', 'lvUsage': '3.52', 'volumeGroup': - 'RHS_vg0', 'lvSize': '9.95g'}, {'path': '10.70.47.16:/testvol_brick1', - 'pid': '25497', 'lvUsage': '3.52', 'volumeGroup': 'RHS_vg0', - 'lvSize': '9.95g'}], 'brickCount': '2'}, 'name': 'snap2', 'uuid': - '56a39a92-c339-47cc-a8b2-9e54bb2a6324'}, {'volCount': '1', 'volume': - {'brick': [{'path': '10.70.47.11:testvol_next_brick0', 'pid': '26719', - 'lvUsage': '4.93', 'volumeGroup': 'RHS_vg1', 'lvSize': '9.95g'}], - 'brickCount': '1'}, 'name': 'next_snap1', - 'uuid': 'dcf0cd31-c0db-47ad-92ec-f72af2d7b385'}] - """ - - cmd = "gluster snapshot status volume %s --xml" % volname - ret, out, _ = g.run(mnode, cmd) - if ret != 0: - g.log.error("Failed to execute 'snapshot status' on node %s. " - "Hence failed to get the snapshot status.", mnode) - return None - - try: - root = etree.XML(out) - except etree.ParseError: - g.log.error("Failed to parse the gluster snapshot " - "status xml output.") - return None + tuple: Tuple containing three elements (ret, out, err). + The first element 'ret' is of type 'int' and is the return value + of command execution. - snap_status_list = [] - for snap in root.findall("snapStatus/snapshots/snapshot"): - snap_status = {} - for element in snap.getchildren(): - if element.tag == "volume": - status = {} - status["brick"] = [] - for elmt in element.getchildren(): - if elmt.tag == "brick": - brick_info = {} - for el in elmt.getchildren(): - brick_info[el.tag] = el.text - status["brick"].append(brick_info) - else: - status[elmt.tag] = elmt.text + The second element 'out' is of type 'str' and is the stdout value + of the command execution. - snap_status[element.tag] = status - else: - snap_status[element.tag] = element.text - snap_status_list.append(snap_status) - return snap_status_list + The third element 'err' is of type 'str' and is the stderr value + of the command execution. + """ + cmd = "gluster snapshot status volume %s" % volname + return g.run(mnode, cmd) def snap_info(mnode, snapname="", volname=""): -- cgit