Skip to content

Commit

Permalink
fix instance url handling in ci
Browse files Browse the repository at this point in the history
  • Loading branch information
olaughter committed Feb 22, 2024
1 parent 232b7db commit 45c1689
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
10 changes: 6 additions & 4 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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?"
)

Expand Down Expand Up @@ -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
)


Expand Down
11 changes: 8 additions & 3 deletions tests/test_integration.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from unittest.mock import patch
from pathlib import Path
from tempfile import TemporaryDirectory
import json
Expand All @@ -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,
Expand Down Expand Up @@ -54,15 +56,17 @@ 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):
"""
Run repeated integration tests
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()
Expand All @@ -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}"
Expand Down

0 comments on commit 45c1689

Please sign in to comment.