summaryrefslogtreecommitdiffstats
path: root/tests/functional/common/heketi/test_check_entries.py
diff options
context:
space:
mode:
authorValerii Ponomarov <vponomar@redhat.com>2018-11-20 20:19:56 +0530
committerValerii Ponomarov <vponomar@redhat.com>2018-11-20 17:10:45 +0000
commit80e6057a8cc3d851b685c3afce1bc7a757b5a12c (patch)
tree010a42e6001c61c1f291b3c6b3bc600e80ff9f53 /tests/functional/common/heketi/test_check_entries.py
parent51cec40d9aae83448e594498adfeae71aa10c860 (diff)
[CNS-778] Refactor and fix 'test_to_check_entry_in_fstab_file' TC
List of changes: - Fixed bug, where test didn't fail in case volume brick was not found in fstab file. It was only logging message related to it. - Fixed bug, where we searched for all the brick paths in one single Gluser POD, such thing should have been failing always. Above mentioned bug has hidden this one. - Fixed bug, where test was failing in case we didn't have passwordless SSH connection between test-runner and heketi-client nodes. - Added Heketi volume cleanup for case our test fails before the step with Heketi volume deletion. - Removed redundant copy operations of fstab files. Instead, used 'cat' shell command for getting inner data of fstab files. Change-Id: I76c6a59ab9f40cc5e94923fcc82e5e15f640714a
Diffstat (limited to 'tests/functional/common/heketi/test_check_entries.py')
-rw-r--r--tests/functional/common/heketi/test_check_entries.py54
1 files changed, 54 insertions, 0 deletions
diff --git a/tests/functional/common/heketi/test_check_entries.py b/tests/functional/common/heketi/test_check_entries.py
new file mode 100644
index 00000000..be7add9e
--- /dev/null
+++ b/tests/functional/common/heketi/test_check_entries.py
@@ -0,0 +1,54 @@
+from glusto.core import Glusto as g
+
+from cnslibs.common.heketi_libs import HeketiClientSetupBaseClass
+from cnslibs.common.heketi_ops import (heketi_volume_create,
+ heketi_volume_delete)
+from cnslibs.common.openshift_ops import get_ocp_gluster_pod_names
+
+
+class TestHeketiVolume(HeketiClientSetupBaseClass):
+ """Check volume bricks presence in fstab files on Gluster PODs."""
+
+ def _find_bricks_in_fstab_files(self, brick_paths, present):
+ """Make sure that vol brick paths either exist or not in fstab file."""
+ oc_node = self.ocp_master_nodes[0]
+ gluster_pods = get_ocp_gluster_pod_names(oc_node)
+ get_fstab_entries_cmd = "oc exec %s -- cat /var/lib/heketi/fstab"
+ fstab_files_data = ''
+ for gluster_pod in gluster_pods:
+ ret, out, err = g.run(oc_node, get_fstab_entries_cmd % gluster_pod)
+ self.assertEqual(
+ ret, 0,
+ "Failed to read fstab file on '%s' gluster POD. "
+ "\nOut: %s \nError: %s" % (gluster_pod, out, err))
+ fstab_files_data += '%s\n' % out
+ assertion_method = self.assertIn if present else self.assertNotIn
+ for brick_path in brick_paths:
+ assertion_method(brick_path, fstab_files_data)
+
+ def test_to_check_entry_in_fstab_file(self):
+ """Test case CNS-778"""
+
+ # 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'].rstrip("/brick") for p in vol["bricks"]]
+
+ # Make sure that volume's brick paths exist in the fstab files
+ self._find_bricks_in_fstab_files(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_in_fstab_files(brick_paths, present=False)