Repository navigation
Fix flaky test_mongo.py::test_simple_ssl file errors in dictionary test infrastructure - #102734
Conversation
…oundError Two filesystem bugs in BaseLayoutTester caused intermittent failures in test_dictionaries_all_layouts_separate_sources/test_mongo.py::test_simple_ssl: 1. cleanup() used os.makedirs() without exist_ok=True. When shutil.rmtree(ignore_errors=True) silently failed to remove the directory (e.g. Docker containers still holding file handles from the previous secure_connection=False parametrization), makedirs() crashed with FileExistsError. 2. create_dictionaries() assumed the dictionary config directory already existed, but complex_tester and ranged_tester don't call cleanup() (which creates the directory). Since pytest doesn't guarantee fixture resolution order among independent sibling fixtures, if ranged_tester or complex_tester resolved before simple_tester, generate_config() crashed with FileNotFoundError. Fix: add exist_ok=True to os.makedirs() in cleanup(), and ensure the directory exists at the start of create_dictionaries().
Pre-PR Validation Gate (session: cron:clickhouse-ci-task-worker:20260415-061500)a) Deterministic repro? Yes — the b) Root cause explained? Yes. Two independent bugs: (1) c) Fix matches root cause? Yes. d) Test intent preserved? Yes. The fix only changes test infrastructure (directory creation logic), not the actual test assertions or what is being tested (MongoDB SSL dictionary functionality). No assertions are weakened. e) Demonstrated in both directions? Old code crashes with |
|
cc @vdimir — could you review this? It fixes two filesystem bugs in the dictionary integration test infrastructure (missing |
|
Workflow [PR], commit [035a13b] Summary: ✅ AI ReviewSummaryThis PR makes a focused, low-risk test-infrastructure fix in ClickHouse Rules
Final VerdictStatus: ✅ Approve |
5915bfe
Two filesystem bugs in
BaseLayoutTester(intest_dictionaries_all_layouts_separate_sources/common.py) caused intermittentFileExistsErrorandFileNotFoundErrorcrashes intest_mongo.py::test_simple_sslacross all 4 layout variants (flat, hashed, cache, direct).Root cause
Bug 1 —
FileExistsErrorincleanup()(8 failures in 30 days):cleanup()callsshutil.rmtree(path, ignore_errors=True)thenos.makedirs(path). Whenrmtreesilently fails to remove the directory (e.g., Docker containers from the previoussecure_connection=Falseparametrization still holding file handles),makedirs()crashes because the directory already exists.Bug 2 —
FileNotFoundErrorincreate_dictionaries()(4 failures in 30 days):complex_testerandranged_testerfixtures callcreate_dictionaries()which writes config files to a directory that onlysimple_tester.cleanup()creates. Since these three fixtures are independent (no dependency between them), pytest doesn't guarantee resolution order. Ifranged_testerresolves beforesimple_tester,generate_config()→open(path, "w")crashes because the directory doesn't exist yet.Fix
cleanup(): Addexist_ok=Truetoos.makedirs()— resilient to failedrmtreecreate_dictionaries(): Addos.makedirs(dir, exist_ok=True)at the start — ensures the directory exists regardless of fixture resolution orderCIDB evidence (30-day window)
17 distinct PR/master entries total for
test_simple_ssl, with 5 master failures. The file errors account for 8 of 22 non-infrastructure failures (the remaining are sanitizer findings and MongoDB connection issues — separate root causes not addressed here).Verification
All 4 variants pass locally with the fix:
test_simple_ssl[cache-True]test_simple_ssl[direct-True]test_simple_ssl[flat-True]test_simple_ssl[hashed-True]Changelog category (leave one):