cli_runner = <click.testing.CliRunner object at 0x7fc16ef5d470>
swh_config = '/tmp/pytest-of-jenkins/pytest-0/test_cli_journal_client_index_3/indexer.yml'
kafka_prefix = 'igudfarcaw', kafka_server = '127.0.0.1:43361'
consumer = <cimpl.Consumer object at 0x7fc16efa0a48>
idx_storage = <swh.indexer.storage.IndexerStorage object at 0x7fc16ed444e0>
storage = <swh.storage.postgresql.storage.Storage object at 0x7fc173a76668>
mocker = <pytest_mock.plugin.MockerFixture object at 0x7fc16ed67470>
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=28319 options=''"}, ...}
indexer_name = '*'
@pytest.mark.parametrize("indexer_name", ["extrinsic_metadata", "*"])
def test_cli_journal_client_index__origin_extrinsic_metadata(
cli_runner,
swh_config,
kafka_prefix: str,
kafka_server,
consumer: Consumer,
idx_storage,
storage,
mocker,
swh_indexer_config,
indexer_name: str,
):
"""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
)
origin = Origin("http://example.org/repo.git")
storage.origin_add([origin])
raw_extrinsic_metadata = attr.evolve(REMD, target=origin.swhid())
raw_extrinsic_metadata = attr.evolve(
raw_extrinsic_metadata, id=raw_extrinsic_metadata.compute_hash()
)
journal_writer.write_additions("raw_extrinsic_metadata", [raw_extrinsic_metadata])
result = cli_runner.invoke(
indexer_cli_group,
[
"-C",
swh_config,
"journal-client",
indexer_name,
"--broker",
kafka_server,
"--prefix",
kafka_prefix,
"--group-id",
"test-consumer",
"--stop-after-objects",
1,
],
catch_exceptions=False,
)
# Check the output
expected_output = "Done.\n"
assert result.exit_code == 0, result.output
assert result.output == expected_output
results = idx_storage.origin_extrinsic_metadata_get([origin.url])
expected_results = [
OriginExtrinsicMetadataRow(
id=origin.url,
from_remd_id=raw_extrinsic_metadata.id,
tool={"id": 1, **swh_indexer_config["tools"]},
mappings=["github"],
metadata={
"@context": "https://doi.org/10.5063/schema/codemeta-2.0",
"type": "https://forgefed.org/ns#Repository",
"name": "test software",
},
)
]
> assert sorted(results, key=lambda r: r.id) == expected_results
E AssertionError: assert [OriginExtrin...s=['github'])] == [OriginExtrin...s=['github'])]
E At index 0 diff: OriginExtrinsicMetadataRow(indexer_configuration_id=None, tool={'id': 1, 'name': 'file', 'version': '1:5.30-1+deb9u1', 'configuration': {'type': 'library', 'debian-package': 'python3-magic'}}, id='http://example.org/repo.git', metadata={'id': 'http://example.org/', 'name': 'test software', 'type': 'https://forgefed.org/ns#Repository', '@context': 'https://doi.org/10.5063/schema/codemeta-2.0'}, from_remd_id=b'\x85<\x89uL\xc9\xe36\x8f\xd0\xe6p\x08h\x82\xe6\xf7\xf0\x92\x92', mappings=['github']) != OriginExtrinsicMetadataRow(indexer_configuration_id=None, ...
E
E ...Full output truncated (6 lines hidden), use '-vv' to show
.tox/py3/lib/python3.7/site-packages/swh/indexer/tests/test_cli.py:758: AssertionError
TEST RESULT
TEST RESULT
- Run At
- Sep 15 2022, 2:11 PM