mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-02-08 12:20:19 +00:00
Merge pull request #1139 from tahoe-lafs/3812-test-advise-corrupt-share
Tests for IStorageServer.advise_corrupt_share Fixes ticket:3812
This commit is contained in:
commit
4c7e50360c
0
newsfragments/3812.minor
Normal file
0
newsfragments/3812.minor
Normal file
@ -475,7 +475,7 @@ class Share(object):
|
|||||||
# there was corruption somewhere in the given range
|
# there was corruption somewhere in the given range
|
||||||
reason = "corruption in share[%d-%d): %s" % (start, start+offset,
|
reason = "corruption in share[%d-%d): %s" % (start, start+offset,
|
||||||
str(f.value))
|
str(f.value))
|
||||||
self._rref.callRemote(
|
return self._rref.callRemote(
|
||||||
"advise_corrupt_share", reason.encode("utf-8")
|
"advise_corrupt_share", reason.encode("utf-8")
|
||||||
).addErrback(log.err, "Error from remote call to advise_corrupt_share")
|
).addErrback(log.err, "Error from remote call to advise_corrupt_share")
|
||||||
|
|
||||||
|
@ -254,7 +254,7 @@ class WriteBucketProxy(object):
|
|||||||
return d
|
return d
|
||||||
|
|
||||||
def abort(self):
|
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):
|
def get_servername(self):
|
||||||
return self._server.get_name()
|
return self._server.get_name()
|
||||||
|
@ -1017,7 +1017,7 @@ class _StorageServer(object):
|
|||||||
shnum,
|
shnum,
|
||||||
reason,
|
reason,
|
||||||
):
|
):
|
||||||
self._rref.callRemote(
|
return self._rref.callRemote(
|
||||||
"advise_corrupt_share",
|
"advise_corrupt_share",
|
||||||
share_type,
|
share_type,
|
||||||
storage_index,
|
storage_index,
|
||||||
|
@ -20,7 +20,7 @@ if PY2:
|
|||||||
|
|
||||||
from random import Random
|
from random import Random
|
||||||
|
|
||||||
from twisted.internet.defer import inlineCallbacks
|
from twisted.internet.defer import inlineCallbacks, returnValue
|
||||||
|
|
||||||
from foolscap.api import Referenceable, RemoteException
|
from foolscap.api import Referenceable, RemoteException
|
||||||
|
|
||||||
@ -405,12 +405,8 @@ class IStorageServerImmutableAPIsTestsMixin(object):
|
|||||||
)
|
)
|
||||||
|
|
||||||
@inlineCallbacks
|
@inlineCallbacks
|
||||||
def test_bucket_advise_corrupt_share(self):
|
def create_share(self):
|
||||||
"""
|
"""Create a share, return the storage index."""
|
||||||
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 = new_storage_index()
|
storage_index = new_storage_index()
|
||||||
(_, allocated) = yield self.storage_server.allocate_buckets(
|
(_, allocated) = yield self.storage_server.allocate_buckets(
|
||||||
storage_index,
|
storage_index,
|
||||||
@ -423,10 +419,31 @@ class IStorageServerImmutableAPIsTestsMixin(object):
|
|||||||
|
|
||||||
yield allocated[0].callRemote("write", 0, b"0123456789")
|
yield allocated[0].callRemote("write", 0, b"0123456789")
|
||||||
yield allocated[0].callRemote("close")
|
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)
|
buckets = yield self.storage_server.get_buckets(storage_index)
|
||||||
yield buckets[0].callRemote("advise_corrupt_share", b"OH NO")
|
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):
|
class IStorageServerMutableAPIsTestsMixin(object):
|
||||||
"""
|
"""
|
||||||
@ -780,6 +797,29 @@ class IStorageServerMutableAPIsTestsMixin(object):
|
|||||||
{0: [b"abcdefg"], 1: [b"0123456"], 2: [b"9876543"]},
|
{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):
|
class _FoolscapMixin(SystemTestMixin):
|
||||||
"""Run tests on Foolscap version of ``IStorageServer."""
|
"""Run tests on Foolscap version of ``IStorageServer."""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user