diff options
author | Jim Cheung <jim.cheung@phazr.io> | 2017-03-01 19:19:22 -0800 |
---|---|---|
committer | Jim Cheung <jim.cheung@phazr.io> | 2017-03-01 19:19:22 -0800 |
commit | 69cb73f9d1a1066325b5c7ed9b2c9a2b16d0343b (patch) | |
tree | 3d51fca740bb351611b9f5c13b05cd63687ddf5b /test | |
parent | 37d43c7c73fcdfdcd303246f0e098c5ae0e717f7 (diff) | |
download | pyeclib-69cb73f9d1a1066325b5c7ed9b2c9a2b16d0343b.tar.gz |
Add Phazr.IO libphazr backend support
Currently, there are several implementations of erasure codes that are
available within OpenStack Swift. Most, if not all, of which are based
on the Reed Solomon coding algorithm.
Phazr.IO’s Erasure Coding technology uses a patented algorithm which are
significantly more efficient and improves the speed of coding, decoding
and reconstruction. In addition, Phazr.IO Erasure Code use a non-systematic
algorithm which provides data protection at rest and in transport without
the need to use encryption.
Please contact support@phazr.io for more info on our technology.
Change-Id: I9377fa32426a190efd0a7f0675ecf13d7e90367d
Diffstat (limited to 'test')
-rw-r--r-- | test/test_pyeclib_api.py | 28 | ||||
-rw-r--r-- | test/test_pyeclib_c.py | 31 |
2 files changed, 55 insertions, 4 deletions
diff --git a/test/test_pyeclib_api.py b/test/test_pyeclib_api.py index b3026a0..9585035 100644 --- a/test/test_pyeclib_api.py +++ b/test/test_pyeclib_api.py @@ -134,7 +134,7 @@ class TestPyECLibDriver(unittest.TestCase): "Invalid Argument: m is required") with self.assertRaises(ECDriverError) as err_context: - # m is smaller than 1 + # k is smaller than 1 ECDriver(ec_type=ec_type, k=-100, m=1) self.assertEqual(str(err_context.exception), "Invalid number of data fragments (k)") @@ -151,10 +151,15 @@ class TestPyECLibDriver(unittest.TestCase): for _type in ALL_EC_TYPES: try: if _type is 'shss': + _k = 10 + _m = 4 + elif _type is 'libphazr': + _k = 4 _m = 4 else: + _k = 10 _m = 5 - ECDriver(k=10, m=_m, ec_type=_type, validate=True) + ECDriver(k=_k, m=_m, ec_type=_type, validate=True) available_ec_types.append(_type) except Exception: # ignore any errors, assume backend not available @@ -171,10 +176,12 @@ class TestPyECLibDriver(unittest.TestCase): try: if _type is 'shss': _instance = ECDriver(k=10, m=4, ec_type=_type) + elif _type is 'libphazr': + _instance = ECDriver(k=4, m=4, ec_type=_type) else: _instance = ECDriver(k=10, m=5, ec_type=_type) except ECDriverError: - self.fail("%p: %s algorithm not supported" % _instance, _type) + self.fail("%s algorithm not supported" % _type) self.assertRaises(ECBackendNotSupported, ECDriver, k=10, m=5, ec_type="invalid_algo") @@ -244,6 +251,11 @@ class TestPyECLibDriver(unittest.TestCase): chksum_type=csum)) pyeclib_drivers.append(ECDriver(k=11, m=7, ec_type=_type6, chksum_type=csum)) + + _type7 = 'libphazr' + if _type7 in VALID_EC_TYPES: + pyeclib_drivers.append(ECDriver(k=4, m=4, ec_type=_type7, + chksum_type=csum)) return pyeclib_drivers def test_small_encode(self): @@ -740,7 +752,15 @@ class TestBackendsEnabled(unittest.TestCase): def dummy(self, ec_type=ec_type): if ec_type not in VALID_EC_TYPES: raise unittest.SkipTest - k, m = 10, 4 if ec_type == 'shss' else 5 + if ec_type == 'shss': + k = 10 + m = 4 + elif ec_type == 'libphazr': + k = 4 + m = 4 + else: + k = 10 + m = 5 ECDriver(k=k, m=m, ec_type=ec_type) dummy.__name__ = 'test_%s_available' % ec_type cls_dict[dummy.__name__] = dummy diff --git a/test/test_pyeclib_c.py b/test/test_pyeclib_c.py index 0395e21..f505a54 100644 --- a/test/test_pyeclib_c.py +++ b/test/test_pyeclib_c.py @@ -78,6 +78,7 @@ class TestPyECLib(unittest.TestCase): (PyECLib_EC_Types.shss, 10, 4), (PyECLib_EC_Types.shss, 20, 4), (PyECLib_EC_Types.shss, 11, 7)] + self.libphazr = [(PyECLib_EC_Types.libphazr, 4, 4)] # Input temp files for testing self.sizes = ["101-K", "202-K", "303-K"] @@ -357,6 +358,36 @@ class TestPyECLib(unittest.TestCase): print("Reconstruct (%s): %s" % (size_str, self.get_throughput(avg_time, size_str))) + @require_backend("libphazr") + def test_libphazr(self): + for (ec_type, k, m) in self.libphazr: + print(("\nRunning tests for %s k=%d, m=%d" % (ec_type, k, m))) + + success = self._test_get_required_fragments(k, m, ec_type) + self.assertTrue(success) + + for size_str in self.sizes: + avg_time = self.time_encode(k, m, ec_type.value, 0, + size_str, + self.iterations) + print("Encode (%s): %s" % + (size_str, self.get_throughput(avg_time, size_str))) + + for size_str in self.sizes: + success, avg_time = self.time_decode(k, m, ec_type.value, 0, + size_str, + self.iterations) + self.assertTrue(success) + print("Decode (%s): %s" % + (size_str, self.get_throughput(avg_time, size_str))) + + for size_str in self.sizes: + success, avg_time = self.time_reconstruct( + k, m, ec_type.value, 0, size_str, self.iterations) + self.assertTrue(success) + print("Reconstruct (%s): %s" % + (size_str, self.get_throughput(avg_time, size_str))) + def _test_get_required_fragments(self, num_data, num_parity, ec_type): """ :return boolean, True if all tests passed |