summaryrefslogtreecommitdiffstats
path: root/tests/functional/common/heketi/test_heketi_device_operations.py
diff options
context:
space:
mode:
authorValerii Ponomarov <vponomar@redhat.com>2018-12-26 21:49:08 +0530
committerValerii Ponomarov <vponomar@redhat.com>2018-12-27 14:09:38 +0530
commitaea011ba00315fc7771808d4192824d36679ce77 (patch)
treec26bd9c25ed224c493994fb7488dd68f619c3207 /tests/functional/common/heketi/test_heketi_device_operations.py
parent919744fa9eee14bb983cfdc58b9f873afa705c6d (diff)
Refactor and enable 'test_device_remove_basic_validation' tc
It was skipped some time ago due to the bug. Now this bug is fixed. So, we need to unskip it. So, do it, in addition to the required refactor. Change-Id: I7c426e9cd3dc38ed48e5b91870bc10bd63998694
Diffstat (limited to 'tests/functional/common/heketi/test_heketi_device_operations.py')
-rw-r--r--tests/functional/common/heketi/test_heketi_device_operations.py52
1 files changed, 43 insertions, 9 deletions
diff --git a/tests/functional/common/heketi/test_heketi_device_operations.py b/tests/functional/common/heketi/test_heketi_device_operations.py
index 202da90f..718ed80b 100644
--- a/tests/functional/common/heketi/test_heketi_device_operations.py
+++ b/tests/functional/common/heketi/test_heketi_device_operations.py
@@ -1,5 +1,6 @@
import json
+import ddt
from glusto.core import Glusto as g
from cnslibs.common.heketi_libs import HeketiBaseClass
@@ -17,6 +18,7 @@ from cnslibs.common.heketi_ops import (heketi_node_enable,
heketi_topology_info)
+@ddt.ddt
class TestHeketiDeviceOperations(HeketiBaseClass):
"""Test Heketi device enable/disable and remove functionality."""
@@ -168,8 +170,10 @@ class TestHeketiDeviceOperations(HeketiBaseClass):
"None of '%s' volume bricks is present on the '%s' device." % (
vol_info['id'], online_device_id))
- def test_device_remove_operation(self):
- """Test case CNS-766. Test device remove functionality."""
+ @ddt.data(True, False)
+ def test_device_remove_operation(self, delete_device):
+ """Test cases CNS-623,766."""
+
gluster_server_0 = g.config["gluster_servers"].values()[0]
try:
device_name = gluster_server_0["additional_devices"][0]
@@ -206,6 +210,7 @@ class TestHeketiDeviceOperations(HeketiBaseClass):
device["storage"]["total"] < lowest_device_size):
lowest_device_size = device["storage"]["total"]
lowest_device_id = device["id"]
+ lowest_device_name = device["name"]
if lowest_device_id is None:
self.skipTest(
"Didn't find suitable device for disablement on '%s' node." % (
@@ -260,15 +265,41 @@ class TestHeketiDeviceOperations(HeketiBaseClass):
# Need to disable device before removing
heketi_device_disable(
- self.heketi_client_node, self.heketi_server_url, lowest_device_id)
- self.addCleanup(heketi_device_enable, self.heketi_client_node,
- self.heketi_server_url, lowest_device_id)
+ self.heketi_client_node, self.heketi_server_url,
+ lowest_device_id)
+ if not delete_device:
+ self.addCleanup(heketi_device_enable, self.heketi_client_node,
+ self.heketi_server_url, lowest_device_id)
# Remove device from Heketi
- heketi_device_remove(
- self.heketi_client_node, self.heketi_server_url, lowest_device_id)
- self.addCleanup(heketi_device_disable, self.heketi_client_node,
- self.heketi_server_url, lowest_device_id)
+ try:
+ heketi_device_remove(
+ self.heketi_client_node, self.heketi_server_url,
+ lowest_device_id)
+ except Exception:
+ if delete_device:
+ self.addCleanup(heketi_device_enable, self.heketi_client_node,
+ self.heketi_server_url, lowest_device_id)
+ raise
+ if not delete_device:
+ self.addCleanup(heketi_device_disable, self.heketi_client_node,
+ self.heketi_server_url, lowest_device_id)
+
+ if delete_device:
+ try:
+ heketi_device_delete(
+ self.heketi_client_node, self.heketi_server_url,
+ lowest_device_id)
+ except Exception:
+ self.addCleanup(heketi_device_enable, self.heketi_client_node,
+ self.heketi_server_url, lowest_device_id)
+ self.addCleanup(heketi_device_disable, self.heketi_client_node,
+ self.heketi_server_url, lowest_device_id)
+ raise
+ self.addCleanup(
+ heketi_device_add,
+ self.heketi_client_node, self.heketi_server_url,
+ lowest_device_name, node_id)
# Create volume
vol_info = heketi_volume_create(self.heketi_client_node,
@@ -278,6 +309,9 @@ class TestHeketiDeviceOperations(HeketiBaseClass):
"Failed to create heketi volume of size %d" % vol_size))
self.addCleanup(self.delete_volumes, vol_info['id'])
+ if delete_device:
+ return
+
# Check that none of volume's bricks is present on the device
present = self.check_any_of_bricks_present_in_device(
vol_info['bricks'], lowest_device_id)