test(falkordb): skip when the port answers but is not FalkorDB
The integration test guarded only on ping(), so a plain Redis (or an SSH-forwarded one) on 6379 passed the liveness check and then FAILED both tests on 'unknown command GRAPH.QUERY'. Add a read-only GRAPH.LIST probe that identifies the service and skips with a distinct message when the graph module is absent, so the test still runs (and can fail) against a real FalkorDB but no longer breaks on a wrong service.
This commit is contained in:
1 parent
3af5021e79
commit
8d611dc4d0
1 file changed
+19
-5
@@ -5,8 +5,10 @@ Runs for real against `falkordb/falkordb:latest`:
|
||||
docker run -d -p 6379:6379 falkordb/falkordb:latest
|
||||
uv run pytest tests/test_falkordb_integration.py -q
|
||||
|
||||
The test auto-skips when the `falkordb` SDK is not installed or no FalkorDB is
|
||||
reachable, so it is a no-op in the default CI (which runs no external services).
|
||||
The test auto-skips when the `falkordb` SDK is not installed, no server is
|
||||
reachable, or the server that answers is not FalkorDB, so it is a no-op in the
|
||||
default CI (which runs no external services) and on a dev box that already has
|
||||
a plain Redis on 6379.
|
||||
Host/port are overridable via FALKORDB_HOST / FALKORDB_PORT.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
@@ -26,13 +28,25 @@ GRAPH_NAME = "graphify_test"
|
||||
|
||||
|
||||
def _connect():
|
||||
"""Return a connected FalkorDB client, or skip if none is reachable."""
|
||||
"""Return a connected FalkorDB client, or skip if none is reachable.
|
||||
|
||||
``ping()`` only proves *something* answers on the port. A plain Redis -- or
|
||||
an SSH tunnel forwarding one -- replies to PING but has no graph module, so
|
||||
the guard passed and the tests FAILED on `unknown command 'GRAPH.QUERY'`
|
||||
instead of skipping. ``GRAPH.LIST`` identifies the service rather than mere
|
||||
liveness: it is read-only, creates no keys, and anything that is not
|
||||
FalkorDB/RedisGraph rejects it as an unknown command.
|
||||
"""
|
||||
try:
|
||||
db = falkordb.FalkorDB(host=HOST, port=PORT)
|
||||
db.connection.ping()
|
||||
return db
|
||||
except Exception as e: # pragma: no cover - depends on local environment
|
||||
pytest.skip(f"no FalkorDB reachable at {HOST}:{PORT} ({e})")
|
||||
pytest.skip(f"no server reachable at {HOST}:{PORT} ({e})")
|
||||
try:
|
||||
db.connection.execute_command("GRAPH.LIST")
|
||||
except Exception as e: # pragma: no cover - depends on local environment
|
||||
pytest.skip(f"server at {HOST}:{PORT} is not FalkorDB, no graph module ({e})")
|
||||
return db
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
|
||||
Reference in new issue
Block a user