swh_storage_backend_config = {'check_config': {'check_write': True}, 'cls': 'postgresql', 'db': "dbname=storage user=postgres host=127.0.0.1 port=2...riter': {'brokers': ['127.0.0.1:60025'], 'client_id': 'kafka_writer-1', 'cls': 'kafka', 'prefix': 'hznxvpkbzv-1'}, ...}
kafka_prefix = 'hznxvpkbzv', kafka_consumer_group = 'test-consumer-hznxvpkbzv'
kafka_server = '127.0.0.1:60025'
caplog = <_pytest.logging.LogCaptureFixture object at 0x7f7c4c2d5ac8>
@patch("swh.storage.backfill.RANGE_GENERATORS", RANGE_GENERATORS)
def test_backfiller(
swh_storage_backend_config,
kafka_prefix: str,
kafka_consumer_group: str,
kafka_server: str,
caplog,
):
prefix1 = f"{kafka_prefix}-1"
prefix2 = f"{kafka_prefix}-2"
journal1 = {
"cls": "kafka",
"brokers": [kafka_server],
"client_id": "kafka_writer-1",
"prefix": prefix1,
}
swh_storage_backend_config["journal_writer"] = journal1
storage = get_storage(**swh_storage_backend_config)
# fill the storage and the journal (under prefix1)
for object_type, objects in TEST_OBJECTS.items():
method = getattr(storage, object_type + "_add")
method(objects)
# now apply the backfiller on the storage to fill the journal under prefix2
backfiller_config = {
"journal_writer": {
"brokers": [kafka_server],
"client_id": "kafka_writer-2",
"prefix": prefix2,
},
"storage": swh_storage_backend_config,
}
# Backfilling
backfiller = JournalBackfiller(backfiller_config)
for object_type in TEST_OBJECTS:
> backfiller.run(object_type, None, None)
.tox/py3/lib/python3.7/site-packages/swh/storage/tests/test_backfill.py:261:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.tox/py3/lib/python3.7/site-packages/swh/storage/backfill.py:649: in run
writer.write_additions(object_type, objects)
.tox/py3/lib/python3.7/site-packages/swh/storage/writer.py:67: in write_additions
self.journal.write_additions(object_type, values)
.tox/py3/lib/python3.7/site-packages/swh/journal/writer/kafka.py:270: in write_additions
for object_ in objects:
.tox/py3/lib/python3.7/site-packages/swh/storage/backfill.py:542: in fetch
record = converter(db, record)
.tox/py3/lib/python3.7/site-packages/swh/storage/backfill.py:228: in raw_extrinsic_metadata_converter
return db_to_raw_extrinsic_metadata(metadata)
.tox/py3/lib/python3.7/site-packages/swh/storage/postgresql/converters.py:326: in db_to_raw_extrinsic_metadata
directory=map_optional(CoreSWHID.from_string, row["directory"]),
<attrs generated init swh.model.model.RawExtrinsicMetadata>:18: in __init__
__attr_validator_target(self, __attr_target, self.target)
.tox/py3/lib/python3.7/site-packages/attrs_strict/_type_validation.py:105: in _validator
_validate_elements(attribute, field, attribute.type)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
attribute = Attribute(name='target', default=NOTHING, validator=<function type_validator.<locals>._validator at 0x7f7c538318c8>, r...xy({}), type=<class 'swh.model.swhids.ExtendedSWHID'>, converter=None, kw_only=False, inherited=False, on_setattr=None)
value = 'swh:1:ori:88c3a1fcecd78d2daef7e33634cc493db9fb84ca'
expected_type = <class 'swh.model.swhids.ExtendedSWHID'>
def _validate_elements(attribute, value, expected_type):
if expected_type is None:
return
base_type = _get_base_type(expected_type)
if base_type == typing.Any:
return
if isinstance(base_type, (str, ForwardRef)):
# These base_types happen when you have string annotations and cannot
# be used in isinstance.
raise _StringAnnotationError()
elif base_type == Literal or base_type == type(Literal): # type: ignore
_handle_literal(attribute, value, expected_type)
elif base_type == typing.Union: # type: ignore
_handle_union(attribute, value, expected_type)
elif not isinstance(value, base_type):
> raise AttributeTypeError(value, attribute)
E attrs_strict._error.AttributeTypeError: target must be <class 'swh.model.swhids.ExtendedSWHID'> (got swh:1:ori:88c3a1fcecd78d2daef7e33634cc493db9fb84ca that is a <class 'str'>)
.tox/py3/lib/python3.7/site-packages/attrs_strict/_type_validation.py:131: AttributeTypeError
TEST RESULT
TEST RESULT
- Run At
- Oct 7 2021, 11:27 AM