summaryrefslogtreecommitdiffstats
path: root/tests/functional/heketi/test_server_state_examine_gluster.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/functional/heketi/test_server_state_examine_gluster.py')
-rw-r--r--tests/functional/heketi/test_server_state_examine_gluster.py90
1 files changed, 90 insertions, 0 deletions
diff --git a/tests/functional/heketi/test_server_state_examine_gluster.py b/tests/functional/heketi/test_server_state_examine_gluster.py
index bb2b3d41..bbba966b 100644
--- a/tests/functional/heketi/test_server_state_examine_gluster.py
+++ b/tests/functional/heketi/test_server_state_examine_gluster.py
@@ -1,4 +1,7 @@
+import re
+
import ddt
+from glustolibs.gluster import volume_ops
import pytest
from openshiftstoragelibs.baseclass import BaseClass
@@ -7,6 +10,10 @@ from openshiftstoragelibs import heketi_ops
from openshiftstoragelibs import heketi_version
from openshiftstoragelibs import node_ops
from openshiftstoragelibs import openshift_ops
+from openshiftstoragelibs import podcmd
+
+G_BRICK_REGEX = r'^.*:.*\/(brick_.*)\/.*$'
+H_BRICK_REGEX = r'^.*\/(brick_.*)$'
@ddt.ddt
@@ -180,3 +187,86 @@ class TestHeketiServerStateExamineGluster(BaseClass):
self.assertEqual(
examine_msg, msg, "Failed to generate error report for node {} in"
" gluster examine output".format(g_node))
+
+ @pytest.mark.tier0
+ @podcmd.GlustoPod()
+ def test_compare_brick_mount_status(self):
+ """Compare the brick mount status from all nodes"""
+ h_node_ip_list, h_mount_point, dev_paths = [], [], []
+ g_nodes, brick_list = [], []
+ cmd = "df -h {} | awk '{{print $6}}' | tail -1"
+ h_node, h_url = self.heketi_client_node, self.heketi_server_url
+
+ # Create a volume and fetch the gluster volume info
+ vol = heketi_ops.heketi_volume_create(h_node, h_url, 1, json=True)
+ self.addCleanup(
+ heketi_ops.heketi_volume_delete, h_node, h_url, vol['id'])
+ vol_name = vol['name']
+ g_vol_info = volume_ops.get_volume_info(
+ 'auto_get_gluster_endpoint', vol_name)
+ self.assertTrue(
+ g_vol_info, "Failed to get the volume info of {}".format(vol_name))
+
+ # Fetch bricks details from gluster vol info
+ for brick_detail in g_vol_info[vol_name]['bricks']['brick']:
+ brick = re.findall(G_BRICK_REGEX, brick_detail['name'])
+ self.assertTrue(
+ brick, "Failed to get brick for volume {}".format(vol_name))
+ brick_list.append(brick[0])
+
+ # Extract node data from examine glusterfs
+ h_examine_gluster = heketi_ops.heketi_examine_gluster(h_node, h_url)
+ h_node_details = h_examine_gluster.get("clusters")[0].get('NodesData')
+ self.assertTrue(
+ h_node_details,
+ "Failed to get the node details {}".format(h_node_details))
+ h_brick_details = (h_node_details[0]['VolumeInfo']['Volumes']
+ ['VolumeList'][0]['Bricks']['BrickList'])
+
+ # Fetch brick ip from examine glusterfs
+ for i in range(len(h_brick_details)):
+ node_bricks = h_brick_details[i]['Name']
+ self.assertTrue(
+ node_bricks,
+ "Failed to get the node bricks data {}".format(node_bricks))
+ h_node_ip_list.append(node_bricks.split(":")[0])
+
+ # Extract mount point and mount status
+ for h_node_detail in h_node_details:
+ for node_detail in h_node_detail['BricksMountStatus']['Statuses']:
+ # Fetch brick from heketi examine
+ brick = re.findall(H_BRICK_REGEX, node_detail['MountPoint'])
+ self.assertTrue(
+ brick,
+ "Failed to get the brick details from "
+ "{}".format(node_detail))
+
+ # Check if the mount point is of new volume
+ if brick[0] in brick_list:
+ dev_paths.append(node_detail['Device'])
+ h_mount_point.append(node_detail['MountPoint'])
+ h_mount_status = node_detail['Mounted']
+
+ # verify if the Mount status is True
+ self.assertTrue(
+ h_mount_status,
+ "Expecting mount status to be true but found"
+ " {}".format(h_mount_status))
+
+ h_nodes_ids = heketi_ops.heketi_node_list(h_node, h_url)
+ for node in h_nodes_ids:
+ g_node = heketi_ops.heketi_node_info(
+ h_node, h_url, node, json=True)
+ g_nodes.append(g_node['hostnames']['manage'][0])
+
+ # Validate mount point from heketi and gluster side
+ for dev_path in dev_paths:
+ # Fetch the mount path with respect to dev path
+ for g_node in g_nodes:
+ g_mount_point = openshift_ops.cmd_run_on_gluster_pod_or_node(
+ self.node, cmd.format(dev_path, g_node))
+ if g_mount_point:
+ self.assertIn(
+ g_mount_point, h_mount_point,
+ "Failed to match mount point {} from gluster side and"
+ " {}".format(g_mount_point, h_mount_point))