kafka_prefix = 'fhclylhzzs', kafka_consumer_group = 'test-consumer-fhclylhzzs'
kafka_server = '127.0.0.1:48647'
def test_storage_play_anonymized(
kafka_prefix: str, kafka_consumer_group: str, kafka_server: str
):
"""Optimal replayer scenario.
This:
- writes objects to the topic
- replayer consumes objects from the topic and replay them
"""
writer_config = {
"cls": "kafka",
"brokers": [kafka_server],
"client_id": "kafka_writer",
"prefix": kafka_prefix,
"anonymize": True,
}
src_config = {"cls": "memory", "journal_writer": writer_config}
storage = get_storage(**src_config)
# Fill the src storage
nb_sent = 0
for obj_type, objs in TEST_OBJECTS.items():
if obj_type == "origin_visit":
# these have non-consistent API and are unrelated with what we
# want to test here
continue
method = getattr(storage, obj_type + "_add")
method(objs)
nb_sent += len(objs)
# Fill a destination storage from Kafka **using anonymized topics**
dst_storage = get_storage(cls="memory")
replayer = JournalClient(
brokers=kafka_server,
group_id=kafka_consumer_group,
prefix=kafka_prefix,
stop_after_objects=nb_sent,
privileged=False,
)
worker_fn = functools.partial(process_replay_objects, storage=dst_storage)
nb_inserted = replayer.process(worker_fn)
assert nb_sent == nb_inserted
> check_replayed(storage, dst_storage, expected_anonymized=True)
.tox/py3/lib/python3.7/site-packages/swh/storage/tests/test_replay.py:309:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.tox/py3/lib/python3.7/site-packages/swh/storage/tests/test_replay.py:356: in check_replayed
for id, obj in sorted(getattr(src, f"_{attr}").items())
.tox/py3/lib/python3.7/site-packages/swh/storage/tests/test_replay.py:356: in <listcomp>
for id, obj in sorted(getattr(src, f"_{attr}").items())
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
obj = [OriginVisitStatus(origin='https://overtherainbow.org/fox/den', visit=1, date=datetime.datetime(2014, 11, 27, 17, 20, 39, tzinfo=datetime.timezone.utc), status='ongoing', snapshot=None, metadata={'baz': 'qux'})]
def maybe_anonymize(obj):
if expected_anonymized:
> return obj.anonymize() or obj
E AttributeError: 'list' object has no attribute 'anonymize'
.tox/py3/lib/python3.7/site-packages/swh/storage/tests/test_replay.py:337: AttributeError
TEST RESULT
TEST RESULT
- Run At
- Jun 12 2020, 3:31 PM