SNOW-2381033: Deflake hybrid tests by using separate tables.#3830
Conversation
Signed-off-by: sfc-gh-mvashishtha <mahesh.vashishtha@snowflake.com>
sfc-gh-joshi
left a comment
There was a problem hiding this comment.
I do remember the initialization fixture taking a while, and I see you made the fixture generate fewer rows. As long as it's still above whatever switching thresholds we're testing it should be OK.
The "one table per test approach" is fine, but I think we ideally would find a way to initialize the table once during setup instead of re-creating it every time the fixture is initialized (maybe a single CTAS if not exists?), since none of the tests mutate it. I thought that's how module-scoped fixtures work, but I guess that's not the case.
Signed-off-by: sfc-gh-mvashishtha <mahesh.vashishtha@snowflake.com>
I agree.
They do work that way, but in this case each pytest process replaces/creates and inserts into the same table in the same namespace. We could alternatively create a (snowflake-session-scoped) temporary table once per pytest session, though that has the disadvantage that test cases could mutate the table. I've now updated this PR so it does that (except I had to use |
|
@sfc-gh-joshi never mind; the problem with the pytest-module-level fixture is that we could get the race condition again if different test files use the fixture. the |
no; each module gets its own session so we should be ok. un-revert. |
| """ | ||
| CREATE OR REPLACE TABLE revenue_transactions ( | ||
| f""" | ||
| CREATE OR REPLACE TEMP TABLE {module_scoped_test_table_name} ( |
There was a problem hiding this comment.
TEMP is not necessary now that we're using a different table name in each pytest module, but that's ok.
Prior to this commit, a few test cases depended on the module-scoped fixture
init_transaction_tables, which wouldThe table was shared by different pytest processes, so there was a race condition where a test case might use a REVENUE_TRANSACTIONS table with 0 rows, or with double the number of rows.
In this commit, use a smaller, separate table for each test module. This change doesn't slow down
pytest -n12 tests/integ/modin/hybrid/test_switch_operations.pyon my laptop.pytest -n12 tests/integ/modin/hybrid/test_switch_operations.pyreliably failed on my machine prior to this commit, but now it passes.