diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ed9bdfaf..0640faeb 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -75,10 +75,6 @@ jobs: cat "${DIRACX_DEMO_DIR}/.failed" exit 1 fi - - name: Setup tmate session - uses: mxschmitt/action-tmate@v3 - with: - limit-access-to-actor: true - name: Run pytest run: | pytest . --demo-dir ../diracx-charts/ --cov-report=xml:coverage.xml --junitxml=report.xml diff --git a/tests/db/opensearch/conftest.py b/tests/db/opensearch/conftest.py index 1b66753d..b0c28e91 100644 --- a/tests/db/opensearch/conftest.py +++ b/tests/db/opensearch/conftest.py @@ -2,7 +2,7 @@ import secrets import socket -from subprocess import PIPE, Popen +from subprocess import PIPE, Popen, check_output import pytest @@ -46,6 +46,20 @@ def index_name(self, doc_id: int) -> str: def opensearch_conn_kwargs(demo_kubectl, demo_kubectl_env): """Fixture which forwards a port from the diracx-demo and returns the connection kwargs.""" require_port_availability(OPENSEARCH_PORT) + + # Ensure the pod is running + cmd = [ + demo_kubectl, + "get", + "pod/opensearch-cluster-master-0", + "-o", + "jsonpath={.status.phase}", + ] + pod_status = check_output(cmd, text=True, env=demo_kubectl_env) + if pod_status != "Running": + raise RuntimeError(f"OpenSearch pod is not running: {pod_status=}") + + # Forward the actual port and wait until it has been forwarded before yielding cmd = [ demo_kubectl, "port-forward", diff --git a/tests/db/opensearch/test_connection.py b/tests/db/opensearch/test_connection.py index 48431a6c..3dcf6bb2 100644 --- a/tests/db/opensearch/test_connection.py +++ b/tests/db/opensearch/test_connection.py @@ -78,3 +78,17 @@ async def test_connection_error_bad_password(opensearch_conn_kwargs): } ) await _ensure_db_unavailable(db) + + +async def test_sanity_checks(opensearch_conn_kwargs): + """Check that the sanity checks are working as expected.""" + db = DummyOSDB(opensearch_conn_kwargs) + # Check that the client is not available before entering the context manager + with pytest.raises(RuntimeError): + db.client.ping() + + # It shouldn't be possible to enter the context manager twice + async with db.client_context(): + assert db.client.ping() + with pytest.raises(AssertionError): + await db.__aenter__()