cli_runner = <click.testing.CliRunner object at 0x7fd933626978>
swh_config = '/tmp/pytest-of-jenkins/pytest-0/test_cli_journal_client_index_4/indexer.yml'
kafka_prefix = 'ijgllxgbgb', kafka_server = '127.0.0.1:46653'
consumer = <cimpl.Consumer object at 0x7fd9336e5188>
idx_storage = <swh.indexer.storage.IndexerStorage object at 0x7fd9336294e0>
obj_storage = <swh.objstorage.backends.pathslicing.PathSlicingObjStorage object at 0x7fd933629ba8>
storage = <swh.storage.postgresql.storage.Storage object at 0x7fd9337892b0>
mocker = <pytest_mock.plugin.MockerFixture object at 0x7fd933789e48>
swh_indexer_config = {'compute_checksums': ['blake2b512'], 'indexer_storage': {'cls': 'local', 'db': "user=postgres password=xxx dbname=tes...cheduler': {'cls': 'local', 'db': "user=postgres password=xxx dbname=tests host=127.0.0.1 port=22683 options=''"}, ...}
def test_cli_journal_client_index__content_mimetype(
cli_runner,
swh_config,
kafka_prefix: str,
kafka_server,
consumer: Consumer,
idx_storage,
obj_storage,
storage,
mocker,
swh_indexer_config,
):
"""Test the 'swh indexer journal-client' cli tool."""
journal_writer = get_journal_writer(
"kafka",
brokers=[kafka_server],
prefix=kafka_prefix,
client_id="test producer",
value_sanitizer=lambda object_type, value: value,
flush_timeout=3, # fail early if something is going wrong
)
fill_obj_storage(obj_storage)
contents = []
expected_results = []
content_ids = []
for content_id, content_d in RAW_CONTENTS.items():
raw_content = content_d[0]
content = Content.from_data(raw_content)
assert content_id == content.sha1
contents.append(content)
content_ids.append(content_id)
if isinstance(content_d[1], tuple):
mimetype = content_d[1][1]
else:
mimetype = content_d[1]
encoding = content_d[2]
content_mimetype_row = ContentMimetypeRow(
id=content.sha1,
tool={"id": 1, **swh_indexer_config["tools"]},
mimetype=mimetype,
encoding=encoding,
)
expected_results.append(content_mimetype_row)
assert len(contents) == len(RAW_CONTENTS)
storage.content_add(contents)
journal_writer.write_additions("content", contents)
result = cli_runner.invoke(
indexer_cli_group,
[
"-C",
swh_config,
"journal-client",
"content-mimetype",
"--broker",
kafka_server,
"--prefix",
kafka_prefix,
"--group-id",
"test-consumer",
"--stop-after-objects",
len(contents),
],
> catch_exceptions=False,
)
.tox/py3/lib/python3.7/site-packages/swh/indexer/tests/test_cli.py:807:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.tox/py3/lib/python3.7/site-packages/click/testing.py:408: in invoke
return_value = cli.main(args=args or (), prog_name=prog_name, **extra)
.tox/py3/lib/python3.7/site-packages/click/core.py:1055: in main
rv = self.invoke(ctx)
.tox/py3/lib/python3.7/site-packages/click/core.py:1657: in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
.tox/py3/lib/python3.7/site-packages/click/core.py:1404: in invoke
return ctx.invoke(self.callback, **ctx.params)
.tox/py3/lib/python3.7/site-packages/click/core.py:760: in invoke
return __callback(*args, **kwargs)
.tox/py3/lib/python3.7/site-packages/click/decorators.py:26: in new_func
return f(get_current_context(), *args, **kwargs)
.tox/py3/lib/python3.7/site-packages/swh/indexer/cli.py:365: in journal_client
client.process(worker_fn)
.tox/py3/lib/python3.7/site-packages/swh/journal/client.py:318: in process
batch_processed, at_eof = self.handle_messages(messages, worker_fn)
.tox/py3/lib/python3.7/site-packages/swh/journal/client.py:356: in handle_messages
worker_fn(dict(objects))
.tox/py3/lib/python3.7/site-packages/swh/indexer/cli.py:362: in worker_fn
fn(objects)
.tox/py3/lib/python3.7/site-packages/swh/indexer/indexer.py:325: in process_journal_objects
content_ids, self.objstorage.get_batch(content_ids)
.tox/py3/lib/python3.7/site-packages/swh/objstorage/objstorage.py:123: in get_batch
yield self.get(obj_id)
.tox/py3/lib/python3.7/site-packages/swh/objstorage/backends/pathslicing.py:252: in get
if obj_id not in self:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <swh.objstorage.backends.pathslicing.PathSlicingObjStorage object at 0x7fd933629ba8>
obj_id = {'blake2s256': b'6\xfae\xce\xd6{\x9d\xf3\x10\xc1?\x94\xd7(\xb9\x9f\x93\xea\x15\x9a\xabq3\xc4\x10\x0bc\xa1\xff\x95>(', 'data': b'def __init__(self):', 'length': 19, 'sha1': b'\x0fu\xaeO}u\xd4.\x12\xc1\xb6W!\xec\xae^v\xfe\xe2#', ...}
def __contains__(self, obj_id):
> hex_obj_id = hashutil.hash_to_hex(obj_id)
E TypeError: unhashable type: 'dict'
.tox/py3/lib/python3.7/site-packages/swh/objstorage/backends/pathslicing.py:194: TypeError
TEST RESULT
TEST RESULT
- Run At
- Jul 21 2022, 7:31 PM