From 696c9fbedd0ad1ddf18623cfe29db51428f56e29 Mon Sep 17 00:00:00 2001 From: Ben Clifford Date: Tue, 26 Mar 2024 08:29:00 +0000 Subject: [PATCH] Tighten database access in htex/monitoring test to avoid issue #3287 A more principled fix of #3287 looks to be much more deeply invasive, and involves a big rework of how ZMQ is used. --- .../test_htex_init_blocks_vs_monitoring.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/parsl/tests/test_monitoring/test_htex_init_blocks_vs_monitoring.py b/parsl/tests/test_monitoring/test_htex_init_blocks_vs_monitoring.py index 91b1f5b3fc..d1800e11d7 100644 --- a/parsl/tests/test_monitoring/test_htex_init_blocks_vs_monitoring.py +++ b/parsl/tests/test_monitoring/test_htex_init_blocks_vs_monitoring.py @@ -59,24 +59,27 @@ def test_row_counts(tmpd_cwd, strategy): from sqlalchemy import text db_url = f"sqlite:///{tmpd_cwd}/monitoring.db" - parsl.load(fresh_config(tmpd_cwd, strategy, db_url)) + with parsl.load(fresh_config(tmpd_cwd, strategy, db_url)): + dfk = parsl.dfk() + run_id = dfk.run_id - this_app().result() + this_app().result() - parsl.dfk().cleanup() parsl.clear() engine = sqlalchemy.create_engine(db_url) with engine.begin() as connection: - result = connection.execute(text("SELECT COUNT(DISTINCT block_id) FROM block")) + binds = {"run_id": run_id} + + result = connection.execute(text("SELECT COUNT(DISTINCT block_id) FROM block WHERE run_id = :run_id"), binds) (c, ) = result.first() assert c == 1, "We should see a single block in this database" - result = connection.execute(text("SELECT COUNT(*) FROM block WHERE block_id = 0 AND status = 'PENDING'")) + result = connection.execute(text("SELECT COUNT(*) FROM block WHERE block_id = 0 AND status = 'PENDING' AND run_id = :run_id"), binds) (c, ) = result.first() assert c == 1, "There should be a single pending status" - result = connection.execute(text("SELECT COUNT(*) FROM block WHERE block_id = 0 AND status = 'CANCELLED'")) + result = connection.execute(text("SELECT COUNT(*) FROM block WHERE block_id = 0 AND status = 'CANCELLED' AND run_id = :run_id"), binds) (c, ) = result.first() assert c == 1, "There should be a single cancelled status"