diff --git a/Makefile b/Makefile index 4eaf2a1..e6ded80 100644 --- a/Makefile +++ b/Makefile @@ -11,6 +11,7 @@ build: vespa_setup: vespa_confirm_cli_installed vespa_dev_start vespa_healthy vespa_deploy_schema test: + docker-compose -f docker-compose.dev.yml build docker-compose -f docker-compose.dev.yml run --rm navigator-search-indexer python -m pytest -vvv dev_install: diff --git a/tests/conftest.py b/tests/conftest.py index 4cb5a24..98204bb 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -22,12 +22,15 @@ FIXTURE_DIR = Path(__file__).parent / "fixtures" +VESPA_TEST_ENDPOINT = os.getenv("VESPA_INSTANCE_URL", "http://localhost:8080") def pytest_configure(config): - if "vespa-app.cloud" in VESPA_INSTANCE_URL: + cloud_url_substring = "vespa-app.cloud" + if cloud_url_substring in VESPA_INSTANCE_URL or cloud_url_substring in VESPA_TEST_ENDPOINT: pytest.exit( - f"Vespa instance url looks like a cloud url: {VESPA_INSTANCE_URL} " + f"Vespa instance url looks like a cloud url: " + "{VESPA_INSTANCE_URL} | {VESPA_TEST_ENDPOINT} " "Has something been misconfigured?" ) @@ -103,8 +106,7 @@ def embeddings_dir_as_path( @pytest.fixture def test_vespa(): yield Vespa( - url="http://localhost", - port=8080 + url=VESPA_TEST_ENDPOINT ) diff --git a/tests/test_integration.py b/tests/test_integration.py index c18a28e..013fcfa 100644 --- a/tests/test_integration.py +++ b/tests/test_integration.py @@ -1,3 +1,4 @@ +from unittest.mock import patch from pathlib import Path from tempfile import TemporaryDirectory import json @@ -9,7 +10,8 @@ from vespa.application import Vespa from cli.index_data import run_as_cli -from conftest import FIXTURE_DIR +from conftest import FIXTURE_DIR, VESPA_TEST_ENDPOINT +from src import config from src.index.vespa_ import ( SEARCH_WEIGHTS_SCHEMA, FAMILY_DOCUMENT_SCHEMA, @@ -54,7 +56,8 @@ def prepare_temp_dir(doc_id: str, incremental_update_dir: str, limit): return doc_id - +@patch.object(config, "VESPA_INSTANCE_URL", new=VESPA_TEST_ENDPOINT) +@patch.object(config, "DEVELOPMENT_MODE", new="true") @pytest.mark.usefixtures("cleanup_test_vespa_before", "cleanup_test_vespa_after") def test_integration(test_vespa): """ @@ -62,7 +65,8 @@ def test_integration(test_vespa): First run: on the fixture dir Second run: on a single fixture shortened to test incremental runs with shorter docs - Third run: on the single, original document pre shortening + Third run: on the same fixture, shortened but less + Fourth Run: on the same fixture but at its original state pre shortening """ runner = CliRunner() @@ -80,6 +84,7 @@ def test_integration(test_vespa): "vespa", ], ) + assert result.exit_code == 0, ( f"Exception: {result.exception if result.exception else None}\n" f"Stdout: {result.stdout}"