mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2024-12-24 23:26:43 +00:00
Start thinking about immutable tests.
This commit is contained in:
parent
51b1e5624a
commit
855d02bef0
@ -1,38 +1,69 @@
|
|||||||
"""
|
"""
|
||||||
Tests for the ``IStorageServer`` interface.
|
Tests for the ``IStorageServer`` interface.
|
||||||
|
|
||||||
|
Note that for performance, in the future we might want the same node to be
|
||||||
|
reused across tests, so each test should be careful to generate unique storage
|
||||||
|
indexes.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from twisted.trial import unittest
|
from twisted.internet.defer import inlineCallbacks, returnValue
|
||||||
from twisted.internet.defer import inlineCallbacks
|
from twisted.trial.unittest import TestCase
|
||||||
|
|
||||||
from allmydata.interfaces import IStorageServer
|
from allmydata.interfaces import IStorageServer
|
||||||
from .test_system import SystemTestMixin
|
from .test_system import SystemTestMixin
|
||||||
|
|
||||||
|
|
||||||
class IStorageServerTestsMixin:
|
class IStorageServerSharedAPIsTestsMixin(object):
|
||||||
"""
|
"""
|
||||||
Tests for ``IStorageServer``.
|
Tests for ``IStorageServer``'s shared APIs.
|
||||||
|
|
||||||
``self.storage_server`` is expected to provide ``IStorageServer``.
|
``self.storage_server`` is expected to provide ``IStorageServer``.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@inlineCallbacks
|
@inlineCallbacks
|
||||||
def test_version(self):
|
def test_version(self):
|
||||||
|
# TODO get_version() returns a dict-like thing with some of the
|
||||||
|
# expected fields.
|
||||||
yield self.storage_server.get_version()
|
yield self.storage_server.get_version()
|
||||||
|
|
||||||
|
|
||||||
class FoolscapIStorageServerTests(
|
class IStorageServerImmutableAPIsTestsMixin(object):
|
||||||
SystemTestMixin, IStorageServerTestsMixin, unittest.TestCase
|
"""
|
||||||
):
|
Tests for ``IStorageServer``'s immutable APIs.
|
||||||
|
|
||||||
|
``self.storage_server`` is expected to provide ``IStorageServer``.
|
||||||
|
"""
|
||||||
|
|
||||||
|
# TODO === allocate_buckets + RIBucketWriter ===
|
||||||
|
# TODO allocate_buckets on a new storage index
|
||||||
|
# TODO allocate_buckets on existing bucket with same sharenums
|
||||||
|
# TODO allocate_buckets with smaller sharenums
|
||||||
|
# TODO allocate_buckets with larger sharenums
|
||||||
|
# TODO writes to bucket can happen in any order (write then read)
|
||||||
|
# TODO overlapping writes ignore already-written data (write then read)
|
||||||
|
|
||||||
|
|
||||||
|
class _FoolscapMixin(SystemTestMixin):
|
||||||
"""Run tests on Foolscap version of ``IStorageServer."""
|
"""Run tests on Foolscap version of ``IStorageServer."""
|
||||||
|
|
||||||
@inlineCallbacks
|
@inlineCallbacks
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.basedir = "test_istorageserver/{}/{}".format(
|
self.basedir = "test_istorageserver/" + self.id()
|
||||||
self.__class__.__name__, self._testMethodName
|
|
||||||
)
|
|
||||||
yield SystemTestMixin.setUp(self)
|
yield SystemTestMixin.setUp(self)
|
||||||
yield self.set_up_nodes(1)
|
yield self.set_up_nodes(1)
|
||||||
self.storage_server = next(
|
self.storage_server = next(
|
||||||
iter(self.clients[0].storage_broker.get_known_servers())
|
iter(self.clients[0].storage_broker.get_known_servers())
|
||||||
).get_storage_server()
|
).get_storage_server()
|
||||||
self.assertTrue(IStorageServer.providedBy(self.storage_server))
|
self.assertTrue(IStorageServer.providedBy(self.storage_server))
|
||||||
|
|
||||||
|
|
||||||
|
class FoolscapSharedAPIsTests(
|
||||||
|
_FoolscapMixin, IStorageServerSharedAPIsTestsMixin, TestCase
|
||||||
|
):
|
||||||
|
"""Foolscap-specific tests for shared ``IStorageServer`` APIs."""
|
||||||
|
|
||||||
|
|
||||||
|
class FoolscapImmutableAPIsTests(
|
||||||
|
_FoolscapMixin, IStorageServerImmutableAPIsTestsMixin, TestCase
|
||||||
|
):
|
||||||
|
"""Foolscap-specific tests for immutable ``IStorageServer`` APIs."""
|
||||||
|
Loading…
Reference in New Issue
Block a user