summaryrefslogtreecommitdiffstats
path: root/tests/functional/heketi/test_check_brick_paths.py
diff options
context:
space:
mode:
authorValerii Ponomarov <vponomar@redhat.com>2019-03-06 16:15:25 +0530
committerValerii Ponomarov <vponomar@redhat.com>2019-03-06 16:28:52 +0530
commit3de9a4ea9623cd3a928ce30cbae3364beeac5edb (patch)
tree1746204da26e4648d20b656b2421ef42c78044a4 /tests/functional/heketi/test_check_brick_paths.py
parent3d4ab96edfa54ec7f2dd9682d1ee3e3077dfa79c (diff)
Reorder test files removing redundant dirs
Move all the files of 'tests/functional/common/' dir to the 'tests/functional/', because 'common' is the only dir there, which doesn't really makes sense. Do the same about 'tests/functional/common/heketi/heketi_tests' and 'tests/functional/common/heketi/'. Change-Id: I1fa55e2e7bf09e9b9115629b06e1fd160e291a36
Diffstat (limited to 'tests/functional/heketi/test_check_brick_paths.py')
-rw-r--r--tests/functional/heketi/test_check_brick_paths.py53
1 files changed, 53 insertions, 0 deletions
diff --git a/tests/functional/heketi/test_check_brick_paths.py b/tests/functional/heketi/test_check_brick_paths.py
new file mode 100644
index 00000000..1b5aa32d
--- /dev/null
+++ b/tests/functional/heketi/test_check_brick_paths.py
@@ -0,0 +1,53 @@
+from glusto.core import Glusto as g
+
+from cnslibs.common.baseclass import BaseClass
+from cnslibs.common.heketi_ops import (heketi_volume_create,
+ heketi_volume_delete)
+from cnslibs.common import openshift_ops
+
+
+class TestHeketiVolume(BaseClass):
+ """Check volume bricks presence in fstab files on Gluster PODs."""
+
+ def _find_bricks(self, brick_paths, present):
+ """Make sure that vol brick paths either exist or not in fstab file."""
+ oc_node = self.ocp_master_node[0]
+ cmd = (
+ 'bash -c "'
+ 'if [ -d "%s" ]; then echo present; else echo absent; fi"')
+ g_hosts = list(g.config.get("gluster_servers", {}).keys())
+ results = []
+ assertion_method = self.assertIn if present else self.assertNotIn
+ for brick_path in brick_paths:
+ for g_host in g_hosts:
+ out = openshift_ops.cmd_run_on_gluster_pod_or_node(
+ oc_node, cmd % brick_path, gluster_node=g_host)
+ results.append(out)
+ assertion_method('present', results)
+
+ def test_validate_brick_paths_on_gluster_pods_or_nodes(self):
+ """Validate brick paths after creation and deletion of a volume."""
+
+ # Create heketi volume
+ vol = heketi_volume_create(
+ self.heketi_client_node, self.heketi_server_url, size=1, json=True)
+ self.assertTrue(vol, "Failed to create 1Gb heketi volume")
+ vol_id = vol["bricks"][0]["volume"]
+ self.addCleanup(
+ heketi_volume_delete,
+ self.heketi_client_node, self.heketi_server_url, vol_id,
+ raise_on_error=False)
+
+ # Gather brick paths
+ brick_paths = [p['path'] for p in vol["bricks"]]
+
+ # Make sure that volume's brick paths exist in the fstab files
+ self._find_bricks(brick_paths, present=True)
+
+ # Delete heketi volume
+ out = heketi_volume_delete(
+ self.heketi_client_node, self.heketi_server_url, vol_id)
+ self.assertTrue(out, "Failed to delete heketi volume %s" % vol_id)
+
+ # Make sure that volume's brick paths are absent in the fstab file
+ self._find_bricks(brick_paths, present=False)