Skip to content

Commit

Permalink
Fix tests against external kafka, sr, and rest
Browse files Browse the repository at this point in the history
Fix pytest options handling for running the tests against external
Kafkas, Schema Registries and REST URIs.
  • Loading branch information
tvainika committed Jul 5, 2022
1 parent 95ce142 commit 03a8c4a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
3 changes: 1 addition & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ def pytest_addoption(parser, pluginmanager) -> None: # pylint: disable=unused-a
# Configuration options for the services started by the test suite
parser.addoption(
KAFKA_VERION_OPT,
default=KAFKA_VERSION,
help=f"Kafka version used by the test suite. (Incompatible with {KAFKA_BOOTSTRAP_SERVERS_OPT})",
)
parser.addoption(
Expand Down Expand Up @@ -105,7 +104,7 @@ def fixture_validate_options(request) -> None:

has_external_registry_or_rest = registry_url or rest_url

if not re.match(VERSION_REGEX, kafka_version):
if kafka_version is not None and not re.match(VERSION_REGEX, kafka_version):
msg = "Provided Kafka version has invalid format {kafka_version} should match {VERSION_REGEX}"
raise ValueError(msg)

Expand Down
9 changes: 6 additions & 3 deletions tests/integration/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
from karapace.config import Config, set_config_defaults, write_config
from karapace.kafka_rest_apis import KafkaRest, KafkaRestAdminClient
from pathlib import Path
from tests.integration.utils.cluster import RegistryDescription, start_schema_registry_cluster
from tests.conftest import KAFKA_VERSION
from tests.integration.utils.cluster import RegistryDescription, RegistryEndpoint, start_schema_registry_cluster
from tests.integration.utils.config import KafkaConfig, KafkaDescription, ZKConfig
from tests.integration.utils.kafka_server import (
configure_and_start_kafka,
Expand Down Expand Up @@ -82,7 +83,7 @@ def fixture_port_range() -> PortRangeInclusive:

@pytest.fixture(scope="session", name="kafka_description")
def fixture_kafka_description(request: SubRequest) -> KafkaDescription:
kafka_version = request.config.getoption("kafka_version")
kafka_version = request.config.getoption("kafka_version") or KAFKA_VERSION
kafka_folder = f"kafka_{KAFKA_SCALA_VERSION}-{kafka_version}"
kafka_tgz = f"{kafka_folder}.tgz"
kafka_url = f"https://archive.apache.org/dist/kafka/{kafka_version}/{kafka_tgz}"
Expand Down Expand Up @@ -386,7 +387,9 @@ async def fixture_registry_cluster(
# won't work and will cause test failures.
registry_url = request.config.getoption("registry_url")
if registry_url:
yield registry_url
registry = urlparse(registry_url)
endpoint = RegistryEndpoint(registry.scheme, registry.hostname, registry.port)
yield RegistryDescription(endpoint, "_schemas")
return

config = {"bootstrap_uri": kafka_servers.bootstrap_servers}
Expand Down

0 comments on commit 03a8c4a

Please sign in to comment.