Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tighten database access in htex/monitoring test to avoid issue #3287 #3293

Merged
merged 1 commit into from
Mar 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Loading