Example test case thst tests plumbing liberasurecode errors up into pyeclib

This commit is contained in:
Kevin Greenan 2015-03-09 22:25:22 -07:00 committed by Tushar Gohad
parent d71d280ed7
commit eb572055f8
2 changed files with 17 additions and 1 deletions

View File

@ -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")
@ -486,6 +495,14 @@ class TestPyECLibDriver(unittest.TestCase):
reconstructed_fragments[0] == orig_fragments[
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
#

View File

@ -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