Skip to content

Commit

Permalink
DEBUGGING
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisburr committed Sep 21, 2023
1 parent 2529429 commit 8e90740
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 5 deletions.
4 changes: 0 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 15 additions & 1 deletion tests/db/opensearch/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import secrets
import socket
from subprocess import PIPE, Popen
from subprocess import PIPE, Popen, check_output

import pytest

Expand Down Expand Up @@ -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",
Expand Down
14 changes: 14 additions & 0 deletions tests/db/opensearch/test_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__()

0 comments on commit 8e90740

Please sign in to comment.