diff --git a/newsfragments/3812.minor b/newsfragments/3812.minor new file mode 100644 index 000000000..e69de29bb diff --git a/src/allmydata/immutable/downloader/share.py b/src/allmydata/immutable/downloader/share.py index 41e11426f..016f1c34d 100644 --- a/src/allmydata/immutable/downloader/share.py +++ b/src/allmydata/immutable/downloader/share.py @@ -475,7 +475,7 @@ class Share(object): # there was corruption somewhere in the given range reason = "corruption in share[%d-%d): %s" % (start, start+offset, str(f.value)) - self._rref.callRemote( + return self._rref.callRemote( "advise_corrupt_share", reason.encode("utf-8") ).addErrback(log.err, "Error from remote call to advise_corrupt_share") diff --git a/src/allmydata/immutable/layout.py b/src/allmydata/immutable/layout.py index 6c7362b8a..79c886237 100644 --- a/src/allmydata/immutable/layout.py +++ b/src/allmydata/immutable/layout.py @@ -254,7 +254,7 @@ class WriteBucketProxy(object): return d def abort(self): - self._rref.callRemote("abort").addErrback(log.err, "Error from remote call to abort an immutable write bucket") + return self._rref.callRemote("abort").addErrback(log.err, "Error from remote call to abort an immutable write bucket") def get_servername(self): return self._server.get_name() diff --git a/src/allmydata/storage_client.py b/src/allmydata/storage_client.py index ac6c107d5..526e4e70d 100644 --- a/src/allmydata/storage_client.py +++ b/src/allmydata/storage_client.py @@ -1017,7 +1017,7 @@ class _StorageServer(object): shnum, reason, ): - self._rref.callRemote( + return self._rref.callRemote( "advise_corrupt_share", share_type, storage_index, diff --git a/src/allmydata/test/test_istorageserver.py b/src/allmydata/test/test_istorageserver.py index 40dcdc8bb..bd056ae13 100644 --- a/src/allmydata/test/test_istorageserver.py +++ b/src/allmydata/test/test_istorageserver.py @@ -20,7 +20,7 @@ if PY2: from random import Random -from twisted.internet.defer import inlineCallbacks +from twisted.internet.defer import inlineCallbacks, returnValue from foolscap.api import Referenceable, RemoteException @@ -405,12 +405,8 @@ class IStorageServerImmutableAPIsTestsMixin(object): ) @inlineCallbacks - def test_bucket_advise_corrupt_share(self): - """ - Calling ``advise_corrupt_share()`` on a bucket returned by - ``IStorageServer.get_buckets()`` does not result in error (other - behavior is opaque at this level of abstraction). - """ + def create_share(self): + """Create a share, return the storage index.""" storage_index = new_storage_index() (_, allocated) = yield self.storage_server.allocate_buckets( storage_index, @@ -423,10 +419,31 @@ class IStorageServerImmutableAPIsTestsMixin(object): yield allocated[0].callRemote("write", 0, b"0123456789") yield allocated[0].callRemote("close") + returnValue(storage_index) + @inlineCallbacks + def test_bucket_advise_corrupt_share(self): + """ + Calling ``advise_corrupt_share()`` on a bucket returned by + ``IStorageServer.get_buckets()`` does not result in error (other + behavior is opaque at this level of abstraction). + """ + storage_index = yield self.create_share() buckets = yield self.storage_server.get_buckets(storage_index) yield buckets[0].callRemote("advise_corrupt_share", b"OH NO") + @inlineCallbacks + def test_advise_corrupt_share(self): + """ + Calling ``advise_corrupt_share()`` on an immutable share does not + result in error (other behavior is opaque at this level of + abstraction). + """ + storage_index = yield self.create_share() + yield self.storage_server.advise_corrupt_share( + b"immutable", storage_index, 0, b"ono" + ) + class IStorageServerMutableAPIsTestsMixin(object): """ @@ -780,6 +797,29 @@ class IStorageServerMutableAPIsTestsMixin(object): {0: [b"abcdefg"], 1: [b"0123456"], 2: [b"9876543"]}, ) + @inlineCallbacks + def test_advise_corrupt_share(self): + """ + Calling ``advise_corrupt_share()`` on a mutable share does not + result in error (other behavior is opaque at this level of + abstraction). + """ + secrets = self.new_secrets() + storage_index = new_storage_index() + (written, _) = yield self.staraw( + storage_index, + secrets, + tw_vectors={ + 0: ([], [(0, b"abcdefg")], 7), + }, + r_vector=[], + ) + self.assertEqual(written, True) + + yield self.storage_server.advise_corrupt_share( + b"mutable", storage_index, 0, b"ono" + ) + class _FoolscapMixin(SystemTestMixin): """Run tests on Foolscap version of ``IStorageServer."""