Skip to content

Commit

Permalink
Migrate writer tests and remove old grpc_servicer fixture
Browse files Browse the repository at this point in the history
  • Loading branch information
jotare committed Dec 26, 2024
1 parent 0665aa3 commit 732c22f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 28 deletions.
25 changes: 0 additions & 25 deletions nucliadb/tests/ingest/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
8 changes: 5 additions & 3 deletions nucliadb/tests/ndbfixtures/writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 732c22f

Please sign in to comment.