diff --git a/src/karapace/api/container.py b/src/karapace/api/container.py index 7408856ff..2c1903a63 100644 --- a/src/karapace/api/container.py +++ b/src/karapace/api/container.py @@ -6,7 +6,7 @@ from dependency_injector import containers, providers from karapace.core.container import KarapaceContainer from karapace.api.controller import KarapaceSchemaRegistryController -from karapace.api.registry import KarapaceSchemaRegistry +from karapace.core.schema_registry import KarapaceSchemaRegistry from karapace.api.telemetry.container import TelemetryContainer diff --git a/src/karapace/api/controller.py b/src/karapace/api/controller.py index 308a01516..fe7a9e904 100644 --- a/src/karapace/api/controller.py +++ b/src/karapace/api/controller.py @@ -44,7 +44,7 @@ from karapace.core.statsd import StatsClient from karapace.core.typing import JsonData, JsonObject, SchemaId, Subject, Version from karapace.core.utils import JSONDecodeError -from karapace.api.registry import KarapaceSchemaRegistry +from karapace.core.schema_registry import KarapaceSchemaRegistry from karapace.api.routers.errors import no_primary_url_error, SchemaErrorCodes, SchemaErrorMessages from karapace.api.routers.requests import ( CompatibilityCheckResponse, diff --git a/src/karapace/api/factory.py b/src/karapace/api/factory.py index 69726dfe3..9b25fcc32 100644 --- a/src/karapace/api/factory.py +++ b/src/karapace/api/factory.py @@ -7,7 +7,7 @@ from contextlib import asynccontextmanager from dependency_injector.wiring import inject, Provide from fastapi import Depends, FastAPI -from karapace.core import version as karapace_version +from karapace import version as karapace_version from karapace.core.auth import AuthenticatorAndAuthorizer from karapace.core.config import Config from karapace.core.forward_client import ForwardClient @@ -16,7 +16,7 @@ from karapace.api.container import SchemaRegistryContainer from karapace.api.http_handlers import setup_exception_handlers from karapace.api.middlewares import setup_middlewares -from karapace.api.registry import KarapaceSchemaRegistry +from karapace.core.schema_registry import KarapaceSchemaRegistry from karapace.api.routers.setup import setup_routers from karapace.api.telemetry.setup import setup_metering, setup_tracing from typing import AsyncContextManager diff --git a/src/karapace/api/routers/config.py b/src/karapace/api/routers/config.py index 9b5e89f4e..37422e7b1 100644 --- a/src/karapace/api/routers/config.py +++ b/src/karapace/api/routers/config.py @@ -10,7 +10,7 @@ from karapace.core.typing import Subject from karapace.api.container import SchemaRegistryContainer from karapace.api.controller import KarapaceSchemaRegistryController -from karapace.api.registry import KarapaceSchemaRegistry +from karapace.core.schema_registry import KarapaceSchemaRegistry from karapace.api.routers.errors import no_primary_url_error, unauthorized from karapace.api.routers.raw_path_router import RawPathRoute from karapace.api.routers.requests import CompatibilityLevelResponse, CompatibilityRequest, CompatibilityResponse diff --git a/src/karapace/api/routers/health.py b/src/karapace/api/routers/health.py index bf4852323..33f8aee23 100644 --- a/src/karapace/api/routers/health.py +++ b/src/karapace/api/routers/health.py @@ -9,7 +9,7 @@ from opentelemetry.trace.status import StatusCode from pydantic import BaseModel from karapace.api.container import SchemaRegistryContainer -from karapace.api.registry import KarapaceSchemaRegistry +from karapace.core.schema_registry import KarapaceSchemaRegistry from karapace.api.telemetry.tracer import Tracer diff --git a/src/karapace/api/routers/master_availability.py b/src/karapace/api/routers/master_availability.py index 7cc2f2039..533a44f9e 100644 --- a/src/karapace/api/routers/master_availability.py +++ b/src/karapace/api/routers/master_availability.py @@ -9,7 +9,7 @@ from karapace.core.forward_client import ForwardClient from pydantic import BaseModel from karapace.api.container import SchemaRegistryContainer -from karapace.api.registry import KarapaceSchemaRegistry +from karapace.core.schema_registry import KarapaceSchemaRegistry from typing import Final import logging diff --git a/src/karapace/api/routers/subjects.py b/src/karapace/api/routers/subjects.py index e038bd55a..14d1c6f5a 100644 --- a/src/karapace/api/routers/subjects.py +++ b/src/karapace/api/routers/subjects.py @@ -10,7 +10,7 @@ from karapace.core.typing import Subject from karapace.api.container import SchemaRegistryContainer from karapace.api.controller import KarapaceSchemaRegistryController -from karapace.api.registry import KarapaceSchemaRegistry +from karapace.core.schema_registry import KarapaceSchemaRegistry from karapace.api.routers.errors import no_primary_url_error, unauthorized from karapace.api.routers.raw_path_router import RawPathRoute from karapace.api.routers.requests import SchemaIdResponse, SchemaRequest, SchemaResponse, SubjectSchemaVersionResponse diff --git a/src/karapace/core/karapace_all.py b/src/karapace/core/karapace_all.py index 66a80b90f..1083b45eb 100644 --- a/src/karapace/core/karapace_all.py +++ b/src/karapace/core/karapace_all.py @@ -6,7 +6,7 @@ from __future__ import annotations from dependency_injector.wiring import inject, Provide -from karapace.core import version as karapace_version +from karapace import version as karapace_version from karapace.core.config import Config from karapace.core.container import KarapaceContainer from karapace.core.instrumentation.prometheus import PrometheusInstrumentation diff --git a/src/karapace/api/messaging.py b/src/karapace/core/messaging.py similarity index 100% rename from src/karapace/api/messaging.py rename to src/karapace/core/messaging.py diff --git a/src/karapace/api/reader.py b/src/karapace/core/schema_reader.py similarity index 100% rename from src/karapace/api/reader.py rename to src/karapace/core/schema_reader.py diff --git a/src/karapace/api/registry.py b/src/karapace/core/schema_registry.py similarity index 99% rename from src/karapace/api/registry.py rename to src/karapace/core/schema_registry.py index f68ae9e7f..fc925b811 100644 --- a/src/karapace/api/registry.py +++ b/src/karapace/core/schema_registry.py @@ -38,8 +38,8 @@ ) from karapace.core.schema_references import LatestVersionReference, Reference from karapace.core.typing import JsonObject, Mode, PrimaryInfo, SchemaId, Subject, Version -from karapace.api.messaging import KarapaceProducer -from karapace.api.reader import KafkaSchemaReader +from karapace.core.messaging import KarapaceProducer +from karapace.core.schema_reader import KafkaSchemaReader from karapace.api.telemetry.tracer import Tracer import asyncio diff --git a/tests/e2e/schema_registry/test_jsonschema.py b/tests/e2e/schema_registry/test_jsonschema.py index 44f385203..8ef3cdfc4 100644 --- a/tests/e2e/schema_registry/test_jsonschema.py +++ b/tests/e2e/schema_registry/test_jsonschema.py @@ -7,7 +7,7 @@ from karapace.core.client import Client from karapace.core.compatibility import CompatibilityModes from karapace.core.typing import SchemaMetadata, SchemaRuleSet -from karapace.api.reader import SchemaType +from karapace.core.schema_reader import SchemaType from tests.schemas.json_schemas import ( A_DINT_B_DINT_OBJECT_SCHEMA, A_DINT_B_INT_OBJECT_SCHEMA, diff --git a/tests/integration/test_schema_reader.py b/tests/integration/test_schema_reader.py index fd3f1557b..97d12f6ed 100644 --- a/tests/integration/test_schema_reader.py +++ b/tests/integration/test_schema_reader.py @@ -15,7 +15,7 @@ from karapace.core.offset_watcher import OffsetWatcher from karapace.core.typing import PrimaryInfo from karapace.core.utils import json_encode -from karapace.api.reader import KafkaSchemaReader +from karapace.core.schema_reader import KafkaSchemaReader from tests.base_testcase import BaseTestCase from tests.integration.test_master_coordinator import AlwaysAvailableSchemaReaderStoppper from tests.integration.utils.kafka_server import KafkaServers diff --git a/tests/unit/schema_registry/__init__.py b/tests/unit/api/__init__.py similarity index 100% rename from tests/unit/schema_registry/__init__.py rename to tests/unit/api/__init__.py diff --git a/tests/unit/schema_registry/telemetry/__init__.py b/tests/unit/api/telemetry/__init__.py similarity index 100% rename from tests/unit/schema_registry/telemetry/__init__.py rename to tests/unit/api/telemetry/__init__.py diff --git a/tests/unit/schema_registry/telemetry/test_meter.py b/tests/unit/api/telemetry/test_meter.py similarity index 100% rename from tests/unit/schema_registry/telemetry/test_meter.py rename to tests/unit/api/telemetry/test_meter.py diff --git a/tests/unit/schema_registry/telemetry/test_metrics.py b/tests/unit/api/telemetry/test_metrics.py similarity index 100% rename from tests/unit/schema_registry/telemetry/test_metrics.py rename to tests/unit/api/telemetry/test_metrics.py diff --git a/tests/unit/schema_registry/telemetry/test_middleware.py b/tests/unit/api/telemetry/test_middleware.py similarity index 100% rename from tests/unit/schema_registry/telemetry/test_middleware.py rename to tests/unit/api/telemetry/test_middleware.py diff --git a/tests/unit/schema_registry/telemetry/test_setup.py b/tests/unit/api/telemetry/test_setup.py similarity index 100% rename from tests/unit/schema_registry/telemetry/test_setup.py rename to tests/unit/api/telemetry/test_setup.py diff --git a/tests/unit/schema_registry/telemetry/test_tracer.py b/tests/unit/api/telemetry/test_tracer.py similarity index 100% rename from tests/unit/schema_registry/telemetry/test_tracer.py rename to tests/unit/api/telemetry/test_tracer.py diff --git a/tests/unit/schema_registry/test_controller.py b/tests/unit/api/test_controller.py similarity index 98% rename from tests/unit/schema_registry/test_controller.py rename to tests/unit/api/test_controller.py index 1ce06aea3..343c2629e 100644 --- a/tests/unit/schema_registry/test_controller.py +++ b/tests/unit/api/test_controller.py @@ -7,7 +7,7 @@ from karapace.core.rapu import HTTPResponse from karapace.core.schema_models import SchemaType, ValidatedTypedSchema from karapace.api.container import SchemaRegistryContainer -from karapace.api.reader import KafkaSchemaReader +from karapace.core.schema_reader import KafkaSchemaReader from unittest.mock import Mock, patch, PropertyMock import asyncio diff --git a/tests/unit/schema_registry/test_forwarding.py b/tests/unit/api/test_forwarding.py similarity index 97% rename from tests/unit/schema_registry/test_forwarding.py rename to tests/unit/api/test_forwarding.py index 0b1b294b1..450111cb4 100644 --- a/tests/unit/schema_registry/test_forwarding.py +++ b/tests/unit/api/test_forwarding.py @@ -10,7 +10,7 @@ from karapace.core.forward_client import ForwardClient from karapace.core.typing import PrimaryInfo from karapace.api.controller import KarapaceSchemaRegistryController -from karapace.api.registry import KarapaceSchemaRegistry +from karapace.core.schema_registry import KarapaceSchemaRegistry from karapace.api.routers.config import config_put from unittest.mock import AsyncMock, Mock diff --git a/tests/unit/test_in_memory_database.py b/tests/unit/test_in_memory_database.py index 3292b8fca..65976dbb7 100644 --- a/tests/unit/test_in_memory_database.py +++ b/tests/unit/test_in_memory_database.py @@ -20,7 +20,7 @@ from karapace.core.schema_type import SchemaType from karapace.core.typing import SchemaId, Version from pathlib import Path -from karapace.api.reader import KafkaSchemaReader +from karapace.core.schema_reader import KafkaSchemaReader from typing import Final import pytest diff --git a/tests/unit/schema_registry/test_reader.py b/tests/unit/test_schema_reader.py similarity index 97% rename from tests/unit/schema_registry/test_reader.py rename to tests/unit/test_schema_reader.py index 21e0bf241..e52fe4309 100644 --- a/tests/unit/schema_registry/test_reader.py +++ b/tests/unit/test_schema_reader.py @@ -19,7 +19,7 @@ from karapace.core.schema_type import SchemaType from karapace.core.typing import SchemaId, Version from pytest import MonkeyPatch -from karapace.api.reader import ( +from karapace.core.schema_reader import ( KafkaSchemaReader, MAX_MESSAGES_TO_CONSUME_AFTER_STARTUP, MAX_MESSAGES_TO_CONSUME_ON_STARTUP, @@ -316,10 +316,10 @@ def test_handle_msg_delete_subject_logs(caplog: LogCaptureFixture, karapace_cont database=database_mock, ) - with caplog.at_level(logging.WARNING, logger="karapace.api.reader"): + with caplog.at_level(logging.WARNING, logger="karapace.core.schema_reader"): schema_reader._handle_msg_schema_hard_delete(key={"subject": "test-subject", "version": 2}) for log in caplog.records: - assert log.name == "karapace.api.reader" + assert log.name == "karapace.core.schema_reader" assert log.levelname == "WARNING" assert log.message == "Hard delete: version: Version(2) for subject: 'test-subject' did not exist, should have" @@ -594,14 +594,14 @@ def test_message_error_handling( consumer_messages = ([message],) schema_reader = schema_reader_with_consumer_messages_factory(consumer_messages) - with caplog.at_level(logging.WARNING, logger="karapace.api.reader"): + with caplog.at_level(logging.WARNING, logger="karapace.core.schema_reader"): with pytest.raises(test_case.expected_error): schema_reader.handle_messages() assert schema_reader.offset == 1 assert not schema_reader.ready() for log in caplog.records: - assert log.name == "karapace.api.reader" + assert log.name == "karapace.core.schema_reader" assert log.levelname == "WARNING" assert log.message == test_case.expected_log_message @@ -632,7 +632,7 @@ def test_message_error_handling_with_invalid_reference_schema_protobuf( ) message_using_ref = message_factory(key=key_using_ref, value=value_using_ref) - with caplog.at_level(logging.WARN, logger="karapace.api.reader"): + with caplog.at_level(logging.WARN, logger="karapace.core.schema_reader"): # When handling the corrupted schema schema_reader = schema_reader_with_consumer_messages_factory(([message_ref],)) @@ -658,8 +658,8 @@ def test_message_error_handling_with_invalid_reference_schema_protobuf( assert len(warn_records) == 2 # Check that different warnings are logged for each schema - assert warn_records[0].name == "karapace.api.reader" + assert warn_records[0].name == "karapace.core.schema_reader" assert warn_records[0].message == "Schema is not valid ProtoBuf definition" - assert warn_records[1].name == "karapace.api.reader" + assert warn_records[1].name == "karapace.core.schema_reader" assert warn_records[1].message == "Invalid Protobuf references"