mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-02-01 08:48:01 +00:00
apply the MutableShareFile tests to all known schemas
This commit is contained in:
parent
931ddf85a5
commit
728638fe23
@ -42,9 +42,12 @@ from allmydata.util import fileutil, hashutil, base32
|
||||
from allmydata.storage.server import StorageServer, DEFAULT_RENEWAL_TIME
|
||||
from allmydata.storage.shares import get_share_file
|
||||
from allmydata.storage.mutable import MutableShareFile
|
||||
from allmydata.storage.mutable_schema import (
|
||||
ALL_SCHEMAS as ALL_MUTABLE_SCHEMAS,
|
||||
)
|
||||
from allmydata.storage.immutable import BucketWriter, BucketReader, ShareFile
|
||||
from allmydata.storage.immutable_schema import (
|
||||
ALL_SCHEMAS,
|
||||
ALL_SCHEMAS as ALL_IMMUTABLE_SCHEMAS,
|
||||
)
|
||||
from allmydata.storage.common import storage_index_to_dir, \
|
||||
UnknownMutableContainerVersionError, UnknownImmutableContainerVersionError, \
|
||||
@ -3131,7 +3134,7 @@ class Stats(unittest.TestCase):
|
||||
self.failUnless(output["get"]["99_0_percentile"] is None, output)
|
||||
self.failUnless(output["get"]["99_9_percentile"] is None, output)
|
||||
|
||||
immutable_schemas = strategies.sampled_from(list(ALL_SCHEMAS))
|
||||
immutable_schemas = strategies.sampled_from(list(ALL_IMMUTABLE_SCHEMAS))
|
||||
|
||||
class ShareFileTests(unittest.TestCase):
|
||||
"""Tests for allmydata.storage.immutable.ShareFile."""
|
||||
@ -3270,15 +3273,17 @@ class ShareFileTests(unittest.TestCase):
|
||||
(loaded_lease,) = sf.get_leases()
|
||||
self.assertTrue(loaded_lease.is_cancel_secret(cancel_secret))
|
||||
|
||||
mutable_schemas = strategies.sampled_from(list(ALL_MUTABLE_SCHEMAS))
|
||||
|
||||
class MutableShareFileTests(unittest.TestCase):
|
||||
"""
|
||||
Tests for allmydata.storage.mutable.MutableShareFile.
|
||||
"""
|
||||
def get_sharefile(self):
|
||||
return MutableShareFile(self.mktemp())
|
||||
def get_sharefile(self, **kwargs):
|
||||
return MutableShareFile(self.mktemp(), **kwargs)
|
||||
|
||||
@given(
|
||||
schema=mutable_schemas,
|
||||
nodeid=strategies.just(b"x" * 20),
|
||||
write_enabler=strategies.just(b"y" * 32),
|
||||
datav=strategies.lists(
|
||||
@ -3289,12 +3294,12 @@ class MutableShareFileTests(unittest.TestCase):
|
||||
),
|
||||
new_length=offsets(),
|
||||
)
|
||||
def test_readv_reads_share_data(self, nodeid, write_enabler, datav, new_length):
|
||||
def test_readv_reads_share_data(self, schema, nodeid, write_enabler, datav, new_length):
|
||||
"""
|
||||
``MutableShareFile.readv`` returns bytes from the share data portion
|
||||
of the share file.
|
||||
"""
|
||||
sf = self.get_sharefile()
|
||||
sf = self.get_sharefile(schema=schema)
|
||||
sf.create(my_nodeid=nodeid, write_enabler=write_enabler)
|
||||
sf.writev(datav=datav, new_length=new_length)
|
||||
|
||||
@ -3329,12 +3334,13 @@ class MutableShareFileTests(unittest.TestCase):
|
||||
self.assertEqual(expected_data, read_data)
|
||||
|
||||
@given(
|
||||
schema=mutable_schemas,
|
||||
nodeid=strategies.just(b"x" * 20),
|
||||
write_enabler=strategies.just(b"y" * 32),
|
||||
readv=strategies.lists(strategies.tuples(offsets(), lengths()), min_size=1),
|
||||
random=strategies.randoms(),
|
||||
)
|
||||
def test_readv_rejects_negative_length(self, nodeid, write_enabler, readv, random):
|
||||
def test_readv_rejects_negative_length(self, schema, nodeid, write_enabler, readv, random):
|
||||
"""
|
||||
If a negative length is given to ``MutableShareFile.readv`` in a read
|
||||
vector then ``AssertionError`` is raised.
|
||||
@ -3373,7 +3379,7 @@ class MutableShareFileTests(unittest.TestCase):
|
||||
*broken_readv[readv_index]
|
||||
)
|
||||
|
||||
sf = self.get_sharefile()
|
||||
sf = self.get_sharefile(schema=schema)
|
||||
sf.create(my_nodeid=nodeid, write_enabler=write_enabler)
|
||||
|
||||
# A read with a broken read vector is an error.
|
||||
|
Loading…
x
Reference in New Issue
Block a user