Changeset View
Changeset View
Standalone View
Standalone View
swh/search/tests/test_cli.py
Show All 13 Lines | |||||
from swh.journal.serializers import value_to_kafka | from swh.journal.serializers import value_to_kafka | ||||
from swh.model.hashutil import hash_to_bytes | from swh.model.hashutil import hash_to_bytes | ||||
from swh.search import get_search | from swh.search import get_search | ||||
from swh.search.cli import search_cli_group | from swh.search.cli import search_cli_group | ||||
CLI_CONFIG = """ | CLI_CONFIG = """ | ||||
search: | search: | ||||
cls: elasticsearch | cls: elasticsearch | ||||
args: | |||||
hosts: | hosts: | ||||
- '%(elasticsearch_host)s' | - '%(elasticsearch_host)s' | ||||
index_prefix: test | index_prefix: test | ||||
anlambert: I put that change in a separate commit. | |||||
""" | """ | ||||
JOURNAL_OBJECTS_CONFIG_TEMPLATE = """ | JOURNAL_OBJECTS_CONFIG_TEMPLATE = """ | ||||
journal: | journal: | ||||
brokers: | brokers: | ||||
- {broker} | - {broker} | ||||
prefix: {prefix} | prefix: {prefix} | ||||
group_id: {group_id} | group_id: {group_id} | ||||
▲ Show 20 Lines • Show All 81 Lines • ▼ Show 20 Lines | ): | ||||
producer = Producer( | producer = Producer( | ||||
{ | { | ||||
"bootstrap.servers": kafka_server, | "bootstrap.servers": kafka_server, | ||||
"client.id": "test search origin visit producer", | "client.id": "test search origin visit producer", | ||||
"acks": "all", | "acks": "all", | ||||
} | } | ||||
) | ) | ||||
topic = f"{kafka_prefix}.origin_visit" | topic = f"{kafka_prefix}.origin_visit" | ||||
value = value_to_kafka({"origin": origin_foobar["url"]}) | value = value_to_kafka({"origin": origin_foobar["url"], "type": "git"}) | ||||
producer.produce(topic=topic, key=b"bogus-origin-visit", value=value) | producer.produce(topic=topic, key=b"bogus-origin-visit", value=value) | ||||
journal_objects_config = JOURNAL_OBJECTS_CONFIG_TEMPLATE.format( | journal_objects_config = JOURNAL_OBJECTS_CONFIG_TEMPLATE.format( | ||||
broker=kafka_server, prefix=kafka_prefix, group_id="test-consumer" | broker=kafka_server, prefix=kafka_prefix, group_id="test-consumer" | ||||
) | ) | ||||
result = invoke( | result = invoke( | ||||
False, | False, | ||||
[ | [ | ||||
▲ Show 20 Lines • Show All 280 Lines • Show Last 20 Lines |
I put that change in a separate commit.