Discussion:
[Libstoragemgmt-devel] [PATCH 1/4] Tweak test sizes
Tony Asleson
2014-08-01 01:48:21 UTC
Permalink
Signed-off-by: Tony Asleson <***@redhat.com>
---
test/plugin_test.py | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/test/plugin_test.py b/test/plugin_test.py
index d60b965..658c618 100755
--- a/test/plugin_test.py
+++ b/test/plugin_test.py
@@ -33,8 +33,8 @@ results = {}
stats = {}


-MIN_POOL_SIZE = 2048
-MIN_OBJECT_SIZE = 128
+MIN_POOL_SIZE = 4096
+MIN_OBJECT_SIZE = 512


def mb_in_bytes(mib):
@@ -257,11 +257,19 @@ class TestPlugin(unittest.TestCase):
# TODO Store what exists, so that we don't remove it

def _get_pool_by_usage(self, system_id, element_type):
+ largest_free = 0
+ rc = None
+
for p in self.pool_by_sys_id[system_id]:
+ # If the pool matches our criteria and min size we will consider
+ # it, but we will select the one with the most free space for
+ # testing.
if p.element_type & element_type and \
p.free_space > mb_in_bytes(MIN_POOL_SIZE):
- return p
- return None
+ if p.free_space > largest_free:
+ largest_free = p.free_space
+ rc = p
+ return rc

def tearDown(self):
# TODO Walk the array looking for stuff we have created and remove it
--
1.8.2.1
Tony Asleson
2014-08-01 01:48:22 UTC
Permalink
Added to aide in debugging providers. For smis.py, if you add
debug_path to the query string anytime an invoke ends in error
we will dump the xml request/reply to a file in the directory
specified by 'debug_path'.

Note: renamed a variable as to not conflict with the os import.

Signed-off-by: Tony Asleson <***@redhat.com>
---
plugin/smispy/smis.py | 44 +++++++++++++++++++++++++++++++++++++-------
1 file changed, 37 insertions(+), 7 deletions(-)

diff --git a/plugin/smispy/smis.py b/plugin/smispy/smis.py
index a3b6ca6..88ae335 100644
--- a/plugin/smispy/smis.py
+++ b/plugin/smispy/smis.py
@@ -21,6 +21,8 @@ from string import split
import time
import traceback
import copy
+import os
+import datetime

import pywbem
from pywbem import CIMError
@@ -536,6 +538,7 @@ class Smis(IStorageAreaNetwork):
self.cim_root_profile_dict = dict()
self.fallback_mode = True # Means we cannot use profile register
self.all_vendor_namespaces = []
+ self.debug_path = None

def _get_cim_instance_by_id(self, class_type, requested_id,
property_list=None, raise_error=True):
@@ -622,6 +625,29 @@ class Smis(IStorageAreaNetwork):
ErrorNumber.NO_SUPPORT,
'SMI-S error code indicates operation not supported')
else:
+ # When debugging issues with providers it's helpful to have the
+ # xml request/reply to give to provider developers.
+ try:
+ if self.debug_path is not None:
+ if not os.path.exists(self.debug_path):
+ os.makedirs(self.debug_path)
+
+ if os.path.isdir(self.debug_path):
+ debug_fn = "%s_%s" % \
+ (msg, datetime.datetime.now().isoformat())
+ debug_full = os.path.join(self.debug_path, debug_fn)
+
+ # Dump the request & reply to a file
+ with open(debug_full, 'w') as d:
+ d.write("REQ:\n%s\n\nREPLY:\n%s\n" %
+ (self._c.last_request, self._c.last_reply))
+
+ except Exception:
+ tb = traceback.format_exc()
+ raise LsmError(ErrorNumber.PLUGIN_ERROR,
+ 'Error: ' + msg + " rc= " + str(rc) +
+ ' Debug data exception: ' + str(tb))
+
raise LsmError(ErrorNumber.PLUGIN_ERROR,
'Error: ' + msg + " rc= " + str(rc))

@@ -680,6 +706,10 @@ class Smis(IStorageAreaNetwork):

self.tmo = timeout

+ if 'debug_path' in u['parameters']:
+ self.debug_path = u['parameters']['debug_path']
+ self._c.debug = True
+
if 'force_fallback_mode' in u['parameters'] and \
u['parameters']['force_fallback_mode'] == 'yes':
return
@@ -1769,17 +1799,17 @@ class Smis(IStorageAreaNetwork):
status = System.STATUS_UNKNOWN

if 'OperationalStatus' in cim_sys:
- for os in cim_sys['OperationalStatus']:
- if os == Smis.SystemOperationalStatus.OK:
+ for op_st in cim_sys['OperationalStatus']:
+ if op_st == Smis.SystemOperationalStatus.OK:
status |= System.STATUS_OK
- elif os == Smis.SystemOperationalStatus.DEGRADED:
+ elif op_st == Smis.SystemOperationalStatus.DEGRADED:
status |= System.STATUS_DEGRADED
- elif (os == Smis.SystemOperationalStatus.ERROR or
- os == Smis.SystemOperationalStatus.STRESSED or
- os ==
+ elif (op_st == Smis.SystemOperationalStatus.ERROR or
+ op_st == Smis.SystemOperationalStatus.STRESSED or
+ op_st ==
Smis.SystemOperationalStatus.NON_RECOVERABLE_ERROR):
status |= System.STATUS_ERROR
- elif os == Smis.SystemOperationalStatus.PREDICTIVE_FAILURE:
+ elif op_st == Smis.SystemOperationalStatus.PREDICTIVE_FAILURE:
status |= System.STATUS_PREDICTIVE_FAILURE

return System(cim_sys['Name'], cim_sys['ElementName'], status, '')
--
1.8.2.1
Tony Asleson
2014-08-01 01:48:24 UTC
Permalink
Signed-off-by: Tony Asleson <***@redhat.com>
---
test/plugin_test.py | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/test/plugin_test.py b/test/plugin_test.py
index da5bb9d..ff4aafc 100755
--- a/test/plugin_test.py
+++ b/test/plugin_test.py
@@ -74,6 +74,13 @@ def rs(component, l=4):
random.choice(string.ascii_uppercase) for x in range(l))


+def r_fcpn():
+ """
+ Generate a random 16 character hex number
+ """
+ return '%016X' % random.randrange(2 ** 64)
+
+
class Duration(object):
def __init__(self):
self.start = 0
@@ -649,8 +656,8 @@ class TestPlugin(unittest.TestCase):

elif init_type == lsm.AccessGroup.INIT_TYPE_WWPN:
ag_created = self.c.access_group_create(
- rs('access_group'),
- '500A0986994B8DC5',
+ rs('ag'),
+ r_fcpn(),
lsm.AccessGroup.INIT_TYPE_WWPN, s)

self.assertTrue(ag_created is not None)
@@ -718,7 +725,7 @@ class TestPlugin(unittest.TestCase):
t = lsm.AccessGroup.INIT_TYPE_ISCSI_IQN
else:
# We will try FC PN
- t_id = '500A0986994B8DC5'
+ t_id = r_fcpn()
t = lsm.AccessGroup.INIT_TYPE_WWPN

self.c.access_group_initiator_add(ag, t_id, t)
--
1.8.2.1
Tony Asleson
2014-08-01 01:48:23 UTC
Permalink
Signed-off-by: Tony Asleson <***@redhat.com>
---
test/plugin_test.py | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/test/plugin_test.py b/test/plugin_test.py
index 658c618..da5bb9d 100755
--- a/test/plugin_test.py
+++ b/test/plugin_test.py
@@ -66,7 +66,7 @@ def update_stats(method_name, duration, number_results):
stats[method_name]["number_items"] += number_results


-def rs(component, l=8):
+def rs(component, l=4):
"""
Generate a random string
"""
@@ -329,7 +329,7 @@ class TestPlugin(unittest.TestCase):
if p:
vol_size = self._object_size(p)

- vol = self.c.volume_create(p, rs('volume'), vol_size,
+ vol = self.c.volume_create(p, rs('v'), vol_size,
lsm.Volume.PROVISION_DEFAULT)[1]

self.assertTrue(self._volume_exists(vol.id))
@@ -436,7 +436,7 @@ class TestPlugin(unittest.TestCase):
if supported(cap, [capability]):
volume_clone = self.c.volume_replicate(
None, replication_type, vol,
- rs('volume_clone'))[1]
+ rs('v_c_'))[1]

self.assertTrue(volume_clone is not None)
self.assertTrue(self._volume_exists(volume_clone.id))
@@ -541,7 +541,7 @@ class TestPlugin(unittest.TestCase):
if supported(cap, [lsm.Capabilities.FS_CREATE,
lsm.Capabilities.FS_CLONE]):
fs = self._fs_create(s.id)[0]
- fs_clone = self.c.fs_clone(fs, rs('fs_clone'))[1]
+ fs_clone = self.c.fs_clone(fs, rs('fs_c'))[1]

if supported(cap, [lsm.Capabilities.FS_DELETE]):
self._fs_delete(fs_clone)
@@ -556,7 +556,7 @@ class TestPlugin(unittest.TestCase):

fs = self._fs_create(s.id)[0]

- ss = self.c.fs_snapshot_create(fs, rs('fs_snapshot'))[1]
+ ss = self.c.fs_snapshot_create(fs, rs('ss'))[1]
self.assertTrue(self._fs_snapshot_exists(fs, ss.id))

# Delete snapshot
@@ -643,7 +643,7 @@ class TestPlugin(unittest.TestCase):

if init_type == lsm.AccessGroup.INIT_TYPE_ISCSI_IQN:
ag_created = self.c.access_group_create(
- rs('access_group'),
+ rs('ag'),
'iqn.1994-05.com.domain:01.89bd01',
lsm.AccessGroup.INIT_TYPE_ISCSI_IQN, s)
--
1.8.2.1
Continue reading on narkive:
Loading...