Changeset View
Changeset View
Standalone View
Standalone View
swh/journal/tests/conftest.py
# Copyright (C) 2019 The Software Heritage developers | # Copyright (C) 2019 The Software Heritage developers | ||||
# See the AUTHORS file at the top-level directory of this distribution | # See the AUTHORS file at the top-level directory of this distribution | ||||
# License: GNU General Public License version 3, or any later version | # License: GNU General Public License version 3, or any later version | ||||
# See top-level LICENSE file for more information | # See top-level LICENSE file for more information | ||||
import os | import os | ||||
import pytest | import pytest | ||||
import logging | import logging | ||||
import random | import random | ||||
import string | import string | ||||
from confluent_kafka import Consumer | from confluent_kafka import Consumer | ||||
from subprocess import Popen | from subprocess import Popen | ||||
from typing import Tuple, Dict | from typing import Any, Dict, List, Optional, Tuple | ||||
from pathlib import Path | from pathlib import Path | ||||
from pytest_kafka import ( | from pytest_kafka import ( | ||||
make_zookeeper_process, make_kafka_server | make_zookeeper_process, make_kafka_server | ||||
) | ) | ||||
from swh.model.hashutil import hash_to_bytes | from swh.model.hashutil import hash_to_bytes | ||||
▲ Show 20 Lines • Show All 126 Lines • ▼ Show 20 Lines | |||||
# From type to tuple (id, <objects instances to test>) | # From type to tuple (id, <objects instances to test>) | ||||
OBJECT_TYPE_KEYS = { | OBJECT_TYPE_KEYS = { | ||||
'content': ('sha1', CONTENTS), | 'content': ('sha1', CONTENTS), | ||||
'revision': ('id', REVISIONS), | 'revision': ('id', REVISIONS), | ||||
'release': ('id', RELEASES), | 'release': ('id', RELEASES), | ||||
'origin': (None, ORIGINS), | 'origin': (None, ORIGINS), | ||||
'origin_visit': (None, ORIGIN_VISITS), | 'origin_visit': (None, ORIGIN_VISITS), | ||||
} | } # type: Dict[str, Tuple[Optional[str], List[Dict[str, Any]]]] | ||||
KAFKA_ROOT = os.environ.get('SWH_KAFKA_ROOT') | KAFKA_ROOT = os.environ.get('SWH_KAFKA_ROOT') | ||||
KAFKA_ROOT = KAFKA_ROOT if KAFKA_ROOT else os.path.dirname(__file__) + '/kafka' | KAFKA_ROOT = KAFKA_ROOT if KAFKA_ROOT else os.path.dirname(__file__) + '/kafka' | ||||
if not os.path.exists(KAFKA_ROOT): | if not os.path.exists(KAFKA_ROOT): | ||||
msg = ('Development error: %s must exist and target an ' | msg = ('Development error: %s must exist and target an ' | ||||
'existing kafka installation' % KAFKA_ROOT) | 'existing kafka installation' % KAFKA_ROOT) | ||||
raise ValueError(msg) | raise ValueError(msg) | ||||
▲ Show 20 Lines • Show All 70 Lines • Show Last 20 Lines |