Skip to content

Commit

Permalink
Writer uses utils storage as everyone else
Browse files Browse the repository at this point in the history
  • Loading branch information
jotare committed Dec 27, 2024
1 parent 732c22f commit 6423748
Showing 1 changed file with 2 additions and 56 deletions.
58 changes: 2 additions & 56 deletions nucliadb/tests/ndbfixtures/writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import pytest
from fastapi import FastAPI
from httpx import AsyncClient
from pytest_lazy_fixtures import lazy_fixture
from redis import asyncio as aioredis

from nucliadb.standalone.settings import Settings
Expand All @@ -32,16 +31,9 @@
from nucliadb.writer.settings import settings
from nucliadb_models.resource import NucliaDBRoles
from nucliadb_utils.settings import (
FileBackendConfig,
nucliadb_settings,
storage_settings,
)
from nucliadb_utils.tests.fixtures import get_testing_storage_backend
from nucliadb_utils.utilities import (
Utility,
clean_utility,
set_utility,
)
from nucliadb_utils.storages.storage import Storage
from tests.utils.dirty_index import mark_dirty

from .utils import create_api_client_factory
Expand Down Expand Up @@ -90,7 +82,7 @@ async def nucliadb_writer_manager(
async def writer_api_server(
disabled_back_pressure,
redis,
storage_writer,
storage: Storage,
ingest_grpc_server, # component fixture, shouldn't be used in other modes
ingest_consumers,
ingest_processed_consumer,
Expand All @@ -116,52 +108,6 @@ def disabled_back_pressure():
yield mocked


@pytest.fixture(scope="function")
def gcs_storage_writer(gcs):
with (
patch.object(storage_settings, "file_backend", FileBackendConfig.GCS),
patch.object(storage_settings, "gcs_endpoint_url", gcs),
patch.object(storage_settings, "gcs_bucket", "test_{kbid}"),
):
yield


@pytest.fixture(scope="function")
def s3_storage_writer(s3):
with (
patch.object(storage_settings, "file_backend", FileBackendConfig.S3),
patch.object(storage_settings, "s3_endpoint", s3),
patch.object(storage_settings, "s3_client_id", ""),
patch.object(storage_settings, "s3_client_secret", ""),
patch.object(storage_settings, "s3_bucket", "test-{kbid}"),
):
yield


def lazy_storage_writer_fixture():
backend = get_testing_storage_backend()
if backend == "gcs":
return [lazy_fixture.lf("gcs_storage_writer")]
elif backend == "s3":
return [lazy_fixture.lf("s3_storage_writer")]
else:
print(f"Unknown storage backend {backend}, using gcs")
return [lazy_fixture.lf("gcs_storage_writer")]


@pytest.fixture(scope="function", params=lazy_storage_writer_fixture())
async def storage_writer(request):
"""
Generic storage fixture that allows us to run the same tests for different storage backends.
"""
storage_driver = request.param
set_utility(Utility.STORAGE, storage_driver)

yield storage_driver

clean_utility(Utility.STORAGE)


@pytest.fixture(scope="function")
async def tus_manager(redis):
with (
Expand Down

0 comments on commit 6423748

Please sign in to comment.