From d3108a62a61fd01140193c36f57980be97defa95 Mon Sep 17 00:00:00 2001 From: vamahaja Date: Tue, 14 Jan 2020 15:51:54 +0530 Subject: Refactor heketi device test cases List of changes - 1. Remove test file 'test_device_info.py' as it contains only one test case which can be part of test file 'test_heketi_device_operations.py' 2. Change test case name 'test_device_enable_disable' to 'test_heketi_device_enable_disable' 3. Change test case name 'test_device_remove_operation' to 'test_heketi_device_remove' 4. Change test case name 'test_heketi_with_device_removal_insuff_space' to 'test_heketi_device_removal_with_insuff_space' 5. Chnage test case name 'test_heketi_device_delete_operation' to 'test_heketi_device_delete' 6. Move test case 'test_heketi_devices_info_verification' to 'test_heketi_device_operations.py' and rename as 'test_heketi_device_info' Change-Id: I8ddc9beb7bc697214242212e50c9727ce644f2c1 Signed-off-by: vamahaja --- tests/functional/heketi/test_device_info.py | 71 --------------------- .../heketi/test_heketi_device_operations.py | 74 ++++++++++++++++++++-- 2 files changed, 70 insertions(+), 75 deletions(-) delete mode 100644 tests/functional/heketi/test_device_info.py (limited to 'tests/functional') diff --git a/tests/functional/heketi/test_device_info.py b/tests/functional/heketi/test_device_info.py deleted file mode 100644 index 96199f74..00000000 --- a/tests/functional/heketi/test_device_info.py +++ /dev/null @@ -1,71 +0,0 @@ -from openshiftstoragelibs.baseclass import BaseClass -from openshiftstoragelibs import heketi_ops - - -class TestHeketiDeviceInfo(BaseClass): - - def test_heketi_devices_info_verification(self): - """Validate whether device related information is displayed""" - - # Get devices from topology info - devices_from_topology = {} - topology_info = heketi_ops.heketi_topology_info( - self.heketi_client_node, self.heketi_server_url, json=True) - self.assertTrue(topology_info) - self.assertIn('clusters', list(topology_info.keys())) - self.assertGreater(len(topology_info['clusters']), 0) - for cluster in topology_info['clusters']: - self.assertIn('nodes', list(cluster.keys())) - self.assertGreater(len(cluster['nodes']), 0) - for node in cluster['nodes']: - self.assertIn('devices', list(node.keys())) - self.assertGreater(len(node['devices']), 0) - for device in node['devices']: - # Expected keys are state, storage, id, name and bricks. - self.assertIn('id', list(device.keys())) - devices_from_topology[device['id']] = device - - # Get devices info and make sure data are consistent and complete - for device_id, device_from_t_info in devices_from_topology.items(): - device_info = heketi_ops.heketi_device_info( - self.heketi_client_node, self.heketi_server_url, - device_id, json=True) - self.assertTrue(device_info) - - # Verify 'id', 'name', 'state' and 'storage' data - for key in ('id', 'name', 'state', 'storage', 'bricks'): - self.assertIn(key, list(device_from_t_info.keys())) - self.assertIn(key, list(device_info.keys())) - self.assertEqual(device_info['id'], device_from_t_info['id']) - self.assertEqual(device_info['name'], device_from_t_info['name']) - self.assertEqual(device_info['state'], device_from_t_info['state']) - device_info_storage = device_info['storage'] - device_from_t_info_storage = device_from_t_info['storage'] - device_info_storage_keys = list(device_info_storage.keys()) - device_from_t_info_storage_keys = list( - device_from_t_info_storage.keys()) - for key in ('total', 'used', 'free'): - self.assertIn(key, device_info_storage_keys) - self.assertIn(key, device_from_t_info_storage_keys) - self.assertEqual( - device_info_storage[key], device_from_t_info_storage[key]) - self.assertIsInstance(device_info_storage[key], int) - self.assertGreater(device_info_storage[key], -1) - - # Verify 'bricks' data - self.assertEqual( - len(device_info['bricks']), len(device_from_t_info['bricks'])) - brick_match_count = 0 - for brick in device_info['bricks']: - for brick_from_t in device_from_t_info['bricks']: - if brick_from_t['id'] != brick['id']: - continue - brick_match_count += 1 - brick_from_t_keys = list(brick_from_t.keys()) - brick_keys = list(brick.keys()) - for key in ('device', 'volume', 'size', 'path', 'id', - 'node'): - self.assertIn(key, brick_from_t_keys) - self.assertIn(key, brick_keys) - self.assertEqual(brick[key], brick_from_t[key]) - self.assertEqual(brick_match_count, len(device_info['bricks'])) diff --git a/tests/functional/heketi/test_heketi_device_operations.py b/tests/functional/heketi/test_heketi_device_operations.py index cae880c8..fb9be309 100644 --- a/tests/functional/heketi/test_heketi_device_operations.py +++ b/tests/functional/heketi/test_heketi_device_operations.py @@ -95,7 +95,7 @@ class TestHeketiDeviceOperations(BaseClass): return online_hosts - def test_device_enable_disable(self): + def test_heketi_device_enable_disable(self): """Validate device enable and disable functionality""" # Disable all but one device on the first online node @@ -175,7 +175,7 @@ class TestHeketiDeviceOperations(BaseClass): vol_info['id'], online_device_id)) @ddt.data(True, False) - def test_device_remove_operation(self, delete_device): + def test_heketi_device_remove(self, delete_device): """Validate remove/delete device using heketi-cli""" gluster_server_0 = list(g.config["gluster_servers"].values())[0] @@ -326,7 +326,7 @@ class TestHeketiDeviceOperations(BaseClass): "Some of the '%s' volume bricks is present of the removed " "'%s' device." % (vol_info['id'], lowest_device_id)) - def test_heketi_with_device_removal_insuff_space(self): + def test_heketi_device_removal_with_insuff_space(self): """Validate heketi with device removal insufficient space""" # Disable 4+ nodes and 3+ devices on the first 3 nodes @@ -414,7 +414,7 @@ class TestHeketiDeviceOperations(BaseClass): heketi_device_disable, heketi_node, heketi_url, device_id) raise - def test_heketi_device_delete_operation(self): + def test_heketi_device_delete(self): """Test Heketi device delete operation""" # Get list of additional devices for one of the Gluster nodes @@ -472,3 +472,69 @@ class TestHeketiDeviceOperations(BaseClass): msg = ("Device %s should not be shown in node info of the node %s" "after the device deletion" % (device_id, node_id)) self.assertNotIn(device_id, node_info_after_deletion, msg) + + def test_heketi_device_info(self): + """Validate whether device related information is displayed""" + + # Get devices from topology info + devices_from_topology = {} + topology_info = heketi_topology_info( + self.heketi_client_node, self.heketi_server_url, json=True) + self.assertTrue(topology_info) + self.assertIn('clusters', list(topology_info.keys())) + self.assertGreater(len(topology_info['clusters']), 0) + for cluster in topology_info['clusters']: + self.assertIn('nodes', list(cluster.keys())) + self.assertGreater(len(cluster['nodes']), 0) + for node in cluster['nodes']: + self.assertIn('devices', list(node.keys())) + self.assertGreater(len(node['devices']), 0) + for device in node['devices']: + # Expected keys are state, storage, id, name and bricks. + self.assertIn('id', list(device.keys())) + devices_from_topology[device['id']] = device + + # Get devices info and make sure data are consistent and complete + for device_id, device_from_t_info in devices_from_topology.items(): + device_info = heketi_device_info( + self.heketi_client_node, self.heketi_server_url, + device_id, json=True) + self.assertTrue(device_info) + + # Verify 'id', 'name', 'state' and 'storage' data + for key in ('id', 'name', 'state', 'storage', 'bricks'): + self.assertIn(key, list(device_from_t_info.keys())) + self.assertIn(key, list(device_info.keys())) + self.assertEqual(device_info['id'], device_from_t_info['id']) + self.assertEqual(device_info['name'], device_from_t_info['name']) + self.assertEqual(device_info['state'], device_from_t_info['state']) + device_info_storage = device_info['storage'] + device_from_t_info_storage = device_from_t_info['storage'] + device_info_storage_keys = list(device_info_storage.keys()) + device_from_t_info_storage_keys = list( + device_from_t_info_storage.keys()) + for key in ('total', 'used', 'free'): + self.assertIn(key, device_info_storage_keys) + self.assertIn(key, device_from_t_info_storage_keys) + self.assertEqual( + device_info_storage[key], device_from_t_info_storage[key]) + self.assertIsInstance(device_info_storage[key], int) + self.assertGreater(device_info_storage[key], -1) + + # Verify 'bricks' data + self.assertEqual( + len(device_info['bricks']), len(device_from_t_info['bricks'])) + brick_match_count = 0 + for brick in device_info['bricks']: + for brick_from_t in device_from_t_info['bricks']: + if brick_from_t['id'] != brick['id']: + continue + brick_match_count += 1 + brick_from_t_keys = list(brick_from_t.keys()) + brick_keys = list(brick.keys()) + for key in ('device', 'volume', 'size', 'path', 'id', + 'node'): + self.assertIn(key, brick_from_t_keys) + self.assertIn(key, brick_keys) + self.assertEqual(brick[key], brick_from_t[key]) + self.assertEqual(brick_match_count, len(device_info['bricks'])) -- cgit