Skip to content

Commit 2343309

Browse files
authored
Chore: Test retry flakiness and migrate pytest config to pyproject.toml (#4496)
1 parent d08ece1 commit 2343309

5 files changed

Lines changed: 63 additions & 63 deletions

File tree

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ clickhouse-cloud-test: guard-CLICKHOUSE_CLOUD_HOST guard-CLICKHOUSE_CLOUD_USERNA
170170
pytest -n 1 -m "clickhouse_cloud" --retries 3 --junitxml=test-results/junit-clickhouse-cloud.xml
171171

172172
athena-test: guard-AWS_ACCESS_KEY_ID guard-AWS_SECRET_ACCESS_KEY guard-ATHENA_S3_WAREHOUSE_LOCATION engine-athena-install
173-
pytest -n auto -m "athena" --retries 3 --retry-delay 10 --junitxml=test-results/junit-athena.xml
173+
pytest -n auto -m "athena" --retries 3 --junitxml=test-results/junit-athena.xml
174174

175175
vscode_settings:
176176
mkdir -p .vscode

pyproject.toml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,53 @@ module = [
215215
]
216216
ignore_missing_imports = true
217217

218+
[tool.pytest.ini_options]
219+
markers = [
220+
# Test Type Markers
221+
# Tests are ordered from fastest to slowest
222+
"fast: fast tests (automatically applied if no type markers)",
223+
"slow: slow tests that typically involve interacting with a local DB (like DuckDB)",
224+
"docker: test that involves interacting with a Docker container",
225+
"remote: test that involves interacting with a remote DB",
226+
"cicdonly: test that only runs on CI/CD",
227+
"isolated: tests that need to run sequentially usually because they use fork",
228+
229+
# Test Domain Markers
230+
# default: core functionality
231+
"cli: test for CLI",
232+
"dbt: test for dbt adapter",
233+
"github: test for Github CI/CD bot",
234+
"jupyter: tests for Jupyter integration",
235+
"web: tests for web UI",
236+
237+
# Engine Adapters
238+
"engine: test all engine adapters",
239+
"athena: test for Athena",
240+
"bigquery: test for BigQuery",
241+
"clickhouse: test for Clickhouse (standalone mode / cluster mode)",
242+
"clickhouse_cloud: test for Clickhouse (cloud mode)",
243+
"databricks: test for Databricks",
244+
"duckdb: test for DuckDB",
245+
"motherduck: test for MotherDuck",
246+
"mssql: test for MSSQL",
247+
"mysql: test for MySQL",
248+
"postgres: test for Postgres",
249+
"redshift: test for Redshift",
250+
"snowflake: test for Snowflake",
251+
"spark: test for Spark",
252+
"trino: test for Trino (all connectors)",
253+
"risingwave: test for Risingwave"
254+
]
255+
addopts = "-n 0 --dist=loadgroup"
256+
asyncio_default_fixture_loop_scope = "session"
257+
log_cli = false # Set this to true to enable logging during tests
258+
log_cli_format = "%(asctime)s.%(msecs)03d %(filename)s:%(lineno)d %(levelname)s %(message)s"
259+
log_cli_level = "INFO"
260+
filterwarnings = [
261+
"ignore:The localize method is no longer necessary, as this time zone supports the fold attribute"
262+
]
263+
retry_delay = 10
264+
218265
[tool.ruff.lint]
219266
select = [
220267
"F401",

pytest.ini

Lines changed: 0 additions & 45 deletions
This file was deleted.

tests/core/engine_adapter/integration/conftest.py

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -106,25 +106,23 @@ def _create(
106106
is_remote=is_remote,
107107
)
108108

109-
skip = False
110109
try:
111110
ctx.init()
112-
except Exception:
113-
# We need to catch this exception because if there is an error during setup, pytest-retry aborts immediately
114-
# instead of retrying
111+
except:
112+
# pytest-retry doesnt work if there are errors in fixture setup (ref: https://github.com/str0zzapreti/pytest-retry/issues/33 )
113+
# what we can do is log the exception and return a partially-initialized context to the test, which should
114+
# throw an exception when it tries to access something that didnt init properly and thus trigger pytest-retry to retry
115115
logger.exception("Context init failed")
116-
skip = True
117-
118-
if not skip:
119-
with ctx.engine_adapter.session({}):
120-
yield ctx
121-
122-
try:
123-
ctx.cleanup()
124-
except Exception:
125-
# We need to catch this exception because if there is an error during teardown, pytest-retry aborts immediately
126-
# instead of retrying
127-
logger.exception("Context cleanup failed")
116+
117+
with ctx.engine_adapter.session({}):
118+
yield ctx
119+
120+
try:
121+
ctx.cleanup()
122+
except:
123+
# We need to catch this exception because if there is an error during teardown, pytest-retry aborts immediately
124+
# instead of retrying
125+
logger.exception("Context cleanup failed")
128126

129127
return _create
130128

tests/core/engine_adapter/integration/docker/compose.trino.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ services:
2828

2929
# Trino Stack
3030
trino:
31-
image: 'trinodb/trino:465'
31+
image: 'trinodb/trino:475'
3232
ports:
3333
- '8080:8080'
3434
volumes:

0 commit comments

Comments
 (0)