From 732c22f6c11b77020a45c07a60428c066dac58c6 Mon Sep 17 00:00:00 2001 From: Joan Antoni RE Date: Thu, 26 Dec 2024 12:49:46 +0100 Subject: [PATCH] Migrate writer tests and remove old grpc_servicer fixture --- nucliadb/tests/ingest/fixtures.py | 25 ------------------------- nucliadb/tests/ndbfixtures/writer.py | 8 +++++--- 2 files changed, 5 insertions(+), 28 deletions(-) diff --git a/nucliadb/tests/ingest/fixtures.py b/nucliadb/tests/ingest/fixtures.py index 2ff66391ae..e4f784fdb1 100644 --- a/nucliadb/tests/ingest/fixtures.py +++ b/nucliadb/tests/ingest/fixtures.py @@ -46,7 +46,6 @@ from nucliadb.tests.vectors import V1, V2, V3 from nucliadb_protos import resources_pb2 as rpb from nucliadb_protos import utils_pb2 as upb -from nucliadb_protos import writer_pb2_grpc from nucliadb_protos.knowledgebox_pb2 import SemanticModelMetadata from nucliadb_protos.writer_pb2 import BrokerMessage from nucliadb_utils import const @@ -127,30 +126,6 @@ async def ingest_processed_consumer( clear_global_cache() -# DEPRECATED: only used by writer ndbfixtures -@pytest.fixture(scope="function") -async def grpc_servicer( - maindb_driver: Driver, ingest_consumers, ingest_processed_consumer, learning_config -): - servicer = WriterServicer() - await servicer.initialize() - - server = aio.server() - port = server.add_insecure_port("[::]:0") - writer_pb2_grpc.add_WriterServicer_to_server(servicer, server) - await server.start() - _channel = aio.insecure_channel(f"127.0.0.1:{port}") - yield IngestFixture( - channel=_channel, - serv=server, - servicer=servicer, - host=f"127.0.0.1:{port}", - ) - await servicer.finalize() - await _channel.close(grace=None) - await server.stop(None) - - @pytest.fixture(scope="function") async def pubsub(nats_server: str) -> AsyncIterator[PubSubDriver]: pubsub = get_utility(Utility.PUBSUB) diff --git a/nucliadb/tests/ndbfixtures/writer.py b/nucliadb/tests/ndbfixtures/writer.py index 5301556d82..82b7583012 100644 --- a/nucliadb/tests/ndbfixtures/writer.py +++ b/nucliadb/tests/ndbfixtures/writer.py @@ -42,7 +42,6 @@ clean_utility, set_utility, ) -from tests.ingest.fixtures import IngestFixture from tests.utils.dirty_index import mark_dirty from .utils import create_api_client_factory @@ -92,13 +91,16 @@ async def writer_api_server( disabled_back_pressure, redis, storage_writer, - grpc_servicer: IngestFixture, + ingest_grpc_server, # component fixture, shouldn't be used in other modes + ingest_consumers, + ingest_processed_consumer, + learning_config, transaction_utility, dummy_processing, tus_manager, dummy_nidx_utility, ) -> AsyncIterator[FastAPI]: - with patch.object(nucliadb_settings, "nucliadb_ingest", grpc_servicer.host): + with patch.object(nucliadb_settings, "nucliadb_ingest", ingest_grpc_server.address): application = create_application() async with application.router.lifespan_context(application): yield application