summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin Greenan <kmg@box.com>2015-03-09 22:25:22 -0700
committerTushar Gohad <tushar.gohad@intel.com>2015-03-10 22:46:26 -0700
commiteb572055f86c0e93f12bab58435885d67265c2a0 (patch)
tree94c5f7d6c446237f3f0fc58b390a89cbc6722fb0
parentd71d280ed70c4ff67db6771f838b9b773d46d13c (diff)
downloadpyeclib-eb572055f86c0e93f12bab58435885d67265c2a0.tar.gz
Example test case thst tests plumbing liberasurecode errors up into pyeclib
-rw-r--r--test/test_pyeclib_api.py17
-rw-r--r--test/test_pyeclib_c.py1
2 files changed, 17 insertions, 1 deletions
diff --git a/test/test_pyeclib_api.py b/test/test_pyeclib_api.py
index 1131423..969fee1 100644
--- a/test/test_pyeclib_api.py
+++ b/test/test_pyeclib_api.py
@@ -30,6 +30,7 @@ import unittest
from pyeclib.ec_iface import ECDriver, VALID_EC_TYPES, ECDriverError, \
PyECLib_EC_Types
from test_pyeclib_c import _available_backends
+import pyeclib_c
if sys.version < '3':
def b2i(b):
@@ -195,6 +196,14 @@ class TestPyECLibDriver(unittest.TestCase):
# pyeclib_driver.verify_stripe_metadata(fragment_metadata_list) == -1)
#
+ def get_available_backend(self, k, m, ec_type, chksum_type = "inline_crc32"):
+ if ec_type[:11] == "flat_xor_hd":
+ return ECDriver(k=k, m=m, ec_type="flat_xor_hd", chksum_type=chksum_type)
+ elif ec_type in self.available_backends:
+ return ECDriver(k=k, m=m, ec_type=ec_type, chksum_type=chksum_type)
+ else:
+ return None
+
def test_get_metadata_formatted(self):
pyeclib_driver = ECDriver(k=12, m=2, ec_type="jerasure_rs_vand", chksum_type="inline_crc32")
@@ -487,6 +496,14 @@ class TestPyECLibDriver(unittest.TestCase):
idxs_to_remove[0]])
#
+ # Test reconstructor with insufficient fragments
+ #
+ try:
+ pyeclib_driver.reconstruct([fragments[0]], [])
+ except pyeclib_c.error as e:
+ self.assertTrue(e.message.find("Insufficient number of fragments") > -1)
+
+ #
# Test decode with integrity checks
#
first_fragment_to_corrupt = random.randint(0, len(fragments))
diff --git a/test/test_pyeclib_c.py b/test/test_pyeclib_c.py
index ddd7e27..c7ebb83 100644
--- a/test/test_pyeclib_c.py
+++ b/test/test_pyeclib_c.py
@@ -385,7 +385,6 @@ class TestPyECLib(unittest.TestCase):
print(("Unexpected required fragments list "
"(exp != req): %s != %s" %
(expected_fragments, required_fragments)))
- #sys.exit(2)
return success