diff options
author | Jenkins <jenkins@review.openstack.org> | 2016-11-29 19:27:41 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2016-11-29 19:27:41 +0000 |
commit | 465cd5e739023f98609c5c38887d43f68072f3ee (patch) | |
tree | f68d1b4c8c1c549a2d645a29f6a677520facf708 | |
parent | d163972bb04faf192d0ba65451dcc388b5bb19f0 (diff) | |
parent | ea46179001c0375a523b6b2e388a14012f6cb45c (diff) | |
download | pyeclib-465cd5e739023f98609c5c38887d43f68072f3ee.tar.gz |
Merge "Add greedy test for decode/reconstruct result solid"
-rw-r--r-- | test/test_pyeclib_api.py | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/test/test_pyeclib_api.py b/test/test_pyeclib_api.py index 4eb6bcf..5769b07 100644 --- a/test/test_pyeclib_api.py +++ b/test/test_pyeclib_api.py @@ -28,6 +28,7 @@ import tempfile import unittest from distutils.version import StrictVersion +from itertools import combinations from pyeclib.ec_iface import ECBackendNotSupported from pyeclib.ec_iface import ECDriver @@ -510,6 +511,40 @@ class TestPyECLibDriver(unittest.TestCase): last_fragment_size == len( encoded_fragments[0])) + def test_rs_greedy_decode_reconstruct_combination(self): + # the testing spec defined at get_pyeclib_testspec() method + # and if you want to test either other parameters or backends, + # you can add the spec you want to test there. + pyeclib_drivers = self.get_pyeclib_testspec() + orig_data = 'a' * 1024 * 1024 + for pyeclib_driver in pyeclib_drivers: + if 'rs' not in str(pyeclib_driver.ec_type): + continue + encoded = pyeclib_driver.encode(orig_data) + # make all fragment like (index, frag_data) format to feed + # to combinations + frags = [(i, frag) for i, frag in enumerate(encoded)] + + for check_frags in combinations(frags, pyeclib_driver.k): + check_frags_dict = dict(check_frags) + decoded = pyeclib_driver.decode(check_frags_dict.values()) + self.assertEqual( + orig_data, decoded, + "assertion fail in decode %s %s+%s from:%s" % + (pyeclib_driver.ec_type, pyeclib_driver.k, + pyeclib_driver.m, list(check_frags_dict))) + holes = [index for index in range(pyeclib_driver.k) if + index not in check_frags_dict] + for hole in holes: + reconed = pyeclib_driver.reconstruct( + check_frags_dict.values(), [hole])[0] + self.assertEqual( + encoded[hole], reconed, + "assertion fail in reconstruct %s %s+%s target:%s " + "from:%s" % (pyeclib_driver.ec_type, pyeclib_driver.k, + pyeclib_driver.m, hole, + list(check_frags_dict))) + def test_rs(self): pyeclib_drivers = self.get_pyeclib_testspec() |