replayer_storage_and_client = (<swh.storage.in_memory.InMemoryStorage object at 0x7f89a88c6a58>, <swh.journal.client.JournalClient object at 0x7f8b5c65cbe0>)
caplog = <_pytest.logging.LogCaptureFixture object at 0x7f89a886b438>
def test_storage_replayer(replayer_storage_and_client, caplog):
"""Optimal replayer scenario.
This:
- writes objects to a source storage
- replayer consumes objects from the topic and replays them
- a destination storage is filled from this
In the end, both storages should have the same content.
"""
src, replayer = replayer_storage_and_client
# Fill Kafka using a source storage
nb_sent = 0
for object_type, objects in TEST_OBJECTS.items():
method = getattr(src, object_type + "_add")
method(objects)
if object_type == "origin_visit":
nb_sent += len(objects) # origin-visit-add adds origin-visit-status as well
nb_sent += len(objects)
caplog.set_level(logging.ERROR, "swh.journal.replay")
# Fill the destination storage from Kafka
dst = get_storage(cls="memory")
worker_fn = functools.partial(process_replay_objects, storage=dst)
nb_inserted = replayer.process(worker_fn)
assert nb_sent == nb_inserted
> _check_replayed(src, dst)
.tox/py3/lib/python3.7/site-packages/swh/storage/tests/test_replay.py:85:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
src = <swh.storage.in_memory.InMemoryStorage object at 0x7f89a88c6a58>
dst = <swh.storage.in_memory.InMemoryStorage object at 0x7f89aa209a20>
exclude = None
def _check_replayed(
src: InMemoryStorage, dst: InMemoryStorage, exclude: Optional[Container] = None
):
"""Simple utility function to compare the content of 2 in_memory storages
"""
expected_persons = set(src._persons.values())
got_persons = set(dst._persons.values())
assert got_persons == expected_persons
for attr in (
"contents",
"skipped_contents",
"directories",
"revisions",
"releases",
"snapshots",
"origins",
"origin_visits",
"origin_visit_statuses",
):
if exclude and attr in exclude:
continue
> expected_objects = sorted(getattr(src, f"_{attr}").items())
E AttributeError: 'InMemoryStorage' object has no attribute '_contents'
.tox/py3/lib/python3.7/site-packages/swh/storage/tests/test_replay.py:206: AttributeError
TEST RESULT
TEST RESULT
- Run At
- Aug 12 2020, 7:43 PM