summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoradityaramteke <adityaramteke05icr@gmail.com>2020-09-09 19:07:37 +0530
committeradityaramteke <adityaramteke05icr@gmail.com>2020-09-18 13:07:51 +0530
commitf2b8196decb9863308d8a87fede1acf68e5009b0 (patch)
tree0a0169ece324ad4b4d3bcac4ddfd511862571a75
parentacfce28d8689eb40e3ba810141147f5402d05182 (diff)
[Test] Add TC to validate lvm script is executable on host
Signed-off-by: Aditya Ramteke <aramteke@redhat.com> Change-Id: Ib9870cba6fc5ce1936a22c9fcbb326a6ab753378
-rw-r--r--tests/functional/heketi/test_heketi_lvm_wrapper.py47
1 files changed, 47 insertions, 0 deletions
diff --git a/tests/functional/heketi/test_heketi_lvm_wrapper.py b/tests/functional/heketi/test_heketi_lvm_wrapper.py
index 40abaf5..7a6fbae 100644
--- a/tests/functional/heketi/test_heketi_lvm_wrapper.py
+++ b/tests/functional/heketi/test_heketi_lvm_wrapper.py
@@ -2,6 +2,7 @@ import ddt
import pytest
+from openshiftstoragelibs import command
from openshiftstoragelibs import baseclass
from openshiftstoragelibs import heketi_version
from openshiftstoragelibs import openshift_ops
@@ -61,3 +62,49 @@ class TestHeketiLvmWrapper(baseclass.BaseClass):
self.assertEqual(env_var_value[0], ENV_VALUE, err_msg)
else:
self.assertIsNotNone(env_var_value[0], err_msg)
+
+ @pytest.mark.tier0
+ def test_lvm_script_executable_on_host(self):
+ """Validate lvm script is executable on host instead
+ of container"""
+
+ # Skip the TC if independent mode deployment
+ if not self.is_containerized_gluster():
+ self.skipTest(
+ "Skipping this test as LVM script is not available in "
+ "independent mode deployment")
+
+ pod_name = self.pod_name[0]['pod_name']
+ gluster_pod_label = "glusterfs=storage-pod"
+
+ # Remove LVM banaries to validate /usr/sbin/exec-on-host script
+ # is execute LVM commands on host instead on pod
+ cmd = "rm /usr/sbin/lvm"
+ ret, _, err = openshift_ops.oc_rsh(self.oc_node, pod_name, cmd)
+ self.addCleanup(
+ openshift_ops.wait_for_pods_be_ready, self.oc_node,
+ len(self.gluster_servers), gluster_pod_label)
+ self.addCleanup(
+ openshift_ops.wait_for_resource_absence, self.oc_node, "pod",
+ pod_name)
+ self.addCleanup(
+ openshift_ops.oc_delete, self.oc_node, "pod", pod_name)
+ err_msg = (
+ "failed to execute command {} on pod {} with error: {}"
+ "".format(cmd, pod_name, err))
+ self.assertFalse(ret, err_msg)
+
+ # Validate LVM command is not executable in pod
+ cmd = "oc rsh {} lvs".format(pod_name)
+ stdout = command.cmd_run(cmd, self.oc_node, raise_on_error=False)
+ self.assertIn(
+ 'exec: \\"lvs\\": executable file not found in $PATH', stdout)
+
+ # Run LVM command with /usr/sbin/exec-on-host
+ cmd = "{} lvs".format(ENV_VALUE)
+ ret, out, err = openshift_ops.oc_rsh(self.oc_node, pod_name, cmd)
+ err_msg = (
+ "failed to execute command {} on pod {} with error: {}"
+ "".format(cmd, pod_name, err))
+ self.assertFalse(ret, err_msg)
+ self.assertIn("VG", out)