Skip to content

Commit 3270f41

Browse files
committed
fix test
Signed-off-by: kerthcet <kerthcet@gmail.com>
1 parent bbe5201 commit 3270f41

3 files changed

Lines changed: 18 additions & 3 deletions

File tree

.env.test

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ ALPHATRION_METADATA_INIT_TABLES=true
33
ALPHATRION_ARTIFACT_REGISTRY_URL=localhost:5001
44
ALPHATRION_ARTIFACT_INSECURE=true
55
ALPHATRION_LOG_LEVEL=INFO
6-
ALPHATRION_AUTO_CLEANUP=true
6+
ALPHATRION_AUTO_CLEANUP=true
7+
ALPHATRION_ENABLE_TRACING=true

alphatrion/storage/runtime.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ def __init__(self, force_init: bool = False):
2222
if self._inited and not force_init:
2323
return
2424

25+
# Reset inited flag when force_init is True
26+
if force_init:
27+
self._inited = False
28+
2529
self._metadb = SQLStore(
2630
os.getenv(envs.METADATA_DB_URL),
2731
init_tables=os.getenv(envs.METADATA_INIT_TABLES, "false").lower() == "true",
@@ -67,7 +71,7 @@ def init(force_init: bool = False):
6771
"""
6872

6973
global __STORAGE_RUNTIME__
70-
if __STORAGE_RUNTIME__ is None:
74+
if force_init or __STORAGE_RUNTIME__ is None:
7175
__STORAGE_RUNTIME__ = StorageRuntime(force_init=force_init)
7276

7377

tests/integration/server/test_graphql_query.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,10 @@ async def create_joke():
396396

397397
@pytest.mark.asyncio
398398
async def test_query_single_run():
399+
# Enable tracing for this test - MUST be set before init()
400+
os.environ["ALPHATRION_ENABLE_TRACING"] = "true"
401+
os.environ["ALPHATRION_CLICKHOUSE_INIT_TABLES"] = "true"
402+
399403
team_id = uuid.uuid4()
400404
user_id = uuid.uuid4()
401405

@@ -413,7 +417,13 @@ async def test_query_single_run():
413417
exp_id = exp.id
414418
await exp.wait()
415419

416-
# Wait a bit for spans to be flushed to ClickHouse
420+
# Force flush spans to ClickHouse
421+
from opentelemetry import trace
422+
tracer_provider = trace.get_tracer_provider()
423+
if hasattr(tracer_provider, 'force_flush'):
424+
tracer_provider.force_flush()
425+
426+
# Wait a bit for spans to be written to ClickHouse
417427
await asyncio.sleep(0.5)
418428

419429
response = schema.execute_sync(

0 commit comments

Comments
 (0)