[Checkins] SVN: gocept.zeoraid/trunk/src/gocept/zeoraid/tests/
added tests for storeBlob
Thomas Lotze
tl at gocept.com
Tue Jan 29 07:03:33 EST 2008
Log message for revision 83290:
added tests for storeBlob
Changed:
U gocept.zeoraid/trunk/src/gocept/zeoraid/tests/failingstorage.py
U gocept.zeoraid/trunk/src/gocept/zeoraid/tests/test_basics.py
-=-
Modified: gocept.zeoraid/trunk/src/gocept/zeoraid/tests/failingstorage.py
===================================================================
--- gocept.zeoraid/trunk/src/gocept/zeoraid/tests/failingstorage.py 2008-01-29 09:51:09 UTC (rev 83289)
+++ gocept.zeoraid/trunk/src/gocept/zeoraid/tests/failingstorage.py 2008-01-29 12:03:33 UTC (rev 83290)
@@ -61,7 +61,7 @@
# Create a set of stub methods that have to be made to fail but are set as
# non-data descriptors on the proxy object.
__stub_methods__ = ['history', 'loadSerial', 'close', 'getSize',
- 'pack', 'tpc_abort', 'tpc_finish']
+ 'pack', 'tpc_abort', 'tpc_finish', 'storeBlob']
for name in __stub_methods__:
method = zope.proxy.non_overridable(failing_method(name))
locals()[name] = method
Modified: gocept.zeoraid/trunk/src/gocept/zeoraid/tests/test_basics.py
===================================================================
--- gocept.zeoraid/trunk/src/gocept/zeoraid/tests/test_basics.py 2008-01-29 09:51:09 UTC (rev 83289)
+++ gocept.zeoraid/trunk/src/gocept/zeoraid/tests/test_basics.py 2008-01-29 12:03:33 UTC (rev 83290)
@@ -649,7 +649,103 @@
self.assertEquals('I am a happy blob.',
open(stored_file_name, 'r').read())
+ def test_storeBlob_degrading1(self):
+ oid = self._storage.new_oid()
+ handle, blob_file_name = tempfile.mkstemp()
+ open(blob_file_name, 'w').write('I am a happy blob.')
+ t = transaction.Transaction()
+ self._storage.tpc_begin(t)
+ self._disable_storage(0)
+ self._storage.storeBlob(
+ oid, ZODB.utils.z64, 'foo', blob_file_name, '', t)
+ self._storage.tpc_vote(t)
+ self._storage.tpc_finish(t)
+ stored_file_name = self._storage.loadBlob(
+ oid, self._storage.lastTransaction())
+ self.assertEquals('I am a happy blob.',
+ open(stored_file_name, 'r').read())
+ def test_storeBlob_degrading1_both(self):
+ oid = self._storage.new_oid()
+ handle, blob_file_name = tempfile.mkstemp()
+ open(blob_file_name, 'w').write('I am a happy blob.')
+ t = transaction.Transaction()
+ self._storage.tpc_begin(t)
+ self._disable_storage(0)
+ self._disable_storage(0)
+ self.assertRaises(gocept.zeoraid.interfaces.RAIDError,
+ self._storage.storeBlob,
+ oid, ZODB.utils.z64, 'foo', blob_file_name, '', t)
+
+ def test_storeBlob_degrading2(self):
+ oid = self._storage.new_oid()
+ handle, blob_file_name = tempfile.mkstemp()
+ open(blob_file_name, 'w').write('I am a happy blob.')
+ t = transaction.Transaction()
+ self._storage.tpc_begin(t)
+ self._backend(0).fail('storeBlob')
+ # The server doesn't call its storage's storeBlob right away but only
+ # when tpc_vote ist called.
+ self._storage.storeBlob(
+ oid, ZODB.utils.z64, 'foo', blob_file_name, '', t)
+ self.assertEquals('optimal', self._storage.raid_status())
+ self._storage.tpc_vote(t)
+ self.assertEquals('degraded', self._storage.raid_status())
+ self._storage.tpc_finish(t)
+ stored_file_name = self._storage.loadBlob(
+ oid, self._storage.lastTransaction())
+ self.assertEquals('I am a happy blob.',
+ open(stored_file_name, 'r').read())
+
+ def test_storeBlob_degrading2_both(self):
+ oid = self._storage.new_oid()
+ handle, blob_file_name = tempfile.mkstemp()
+ open(blob_file_name, 'w').write('I am a happy blob.')
+ t = transaction.Transaction()
+ self._storage.tpc_begin(t)
+ self._backend(0).fail('storeBlob')
+ self._backend(1).fail('storeBlob')
+ # The server doesn't call its storage's storeBlob right away but only
+ # when tpc_vote ist called.
+ self._storage.storeBlob(
+ oid, ZODB.utils.z64, 'foo', blob_file_name, '', t)
+ self.assertRaises(gocept.zeoraid.interfaces.RAIDError,
+ self._storage.tpc_vote, t)
+
+ def test_storeBlob_degrading3(self):
+ oid = self._storage.new_oid()
+ handle, blob_file_name = tempfile.mkstemp()
+ open(blob_file_name, 'w').write('I am a happy blob.')
+ t = transaction.Transaction()
+ self._storage.tpc_begin(t)
+ def fail(*args, **kw):
+ raise Exception()
+ self._backend(0).storeBlob = fail
+ self._storage.storeBlob(
+ oid, ZODB.utils.z64, 'foo', blob_file_name, '', t)
+ self.assertEquals('degraded', self._storage.raid_status())
+ self._storage.tpc_vote(t)
+ self._storage.tpc_finish(t)
+ stored_file_name = self._storage.loadBlob(
+ oid, self._storage.lastTransaction())
+ self.assertEquals('I am a happy blob.',
+ open(stored_file_name, 'r').read())
+
+ def test_storeBlob_degrading3_both(self):
+ oid = self._storage.new_oid()
+ handle, blob_file_name = tempfile.mkstemp()
+ open(blob_file_name, 'w').write('I am a happy blob.')
+ t = transaction.Transaction()
+ self._storage.tpc_begin(t)
+ def fail(*args, **kw):
+ raise Exception()
+ self._backend(0).storeBlob = fail
+ self._backend(1).storeBlob = fail
+ self.assertRaises(gocept.zeoraid.interfaces.RAIDError,
+ self._storage.storeBlob,
+ oid, ZODB.utils.z64, 'foo', blob_file_name, '', t)
+
+
class ZEOReplicationStorageTests(ZEOStorageBackendTests,
ReplicationStorageTests,
ThreadTests.ThreadTests):
More information about the Checkins
mailing list