replayer_storage_and_client = (<swh.storage.in_memory.InMemoryStorage object at 0x7f56f323b278>, <swh.journal.client.JournalClient object at 0x7f56f19c93c8>)
caplog = <_pytest.logging.LogCaptureFixture object at 0x7f56f325da20>
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
E assert 58 == 53
.tox/py3/lib/python3.7/site-packages/swh/storage/tests/test_replay.py:118: AssertionError
TEST RESULT
TEST RESULT
- Run At
- Jul 6 2022, 4:23 PM