From 364f393a8fa347486f6a37da61624b8ae614d98b Mon Sep 17 00:00:00 2001 From: Aaron Steers Date: Wed, 14 Feb 2024 10:39:19 -0800 Subject: [PATCH 1/6] declare pytest 'slow' marker --- airbyte-lib/pyproject.toml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/airbyte-lib/pyproject.toml b/airbyte-lib/pyproject.toml index 203c446552ee..7630e713bd8e 100644 --- a/airbyte-lib/pyproject.toml +++ b/airbyte-lib/pyproject.toml @@ -56,7 +56,9 @@ requires = ["poetry-core"] build-backend = "poetry.core.masonry.api" [tool.pytest.ini_options] -# addopts = "--mypy" # FIXME: This sometimes blocks test discovery and execution +markers = [ + "slow: marks tests as slow (deselect with '-m \"not slow\"')", +] [tool.ruff.pylint] max-args = 8 # Relaxed from default of 5 From 5c125b9d51598e83af080b701c94a82b77b740f4 Mon Sep 17 00:00:00 2001 From: Aaron Steers Date: Wed, 14 Feb 2024 10:48:21 -0800 Subject: [PATCH 2/6] mark snowflake tests with 'slow' and 'requires_creds' --- airbyte-lib/tests/integration_tests/test_snowflake_cache.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/airbyte-lib/tests/integration_tests/test_snowflake_cache.py b/airbyte-lib/tests/integration_tests/test_snowflake_cache.py index be8aacd8decc..4ac08f4bebe3 100644 --- a/airbyte-lib/tests/integration_tests/test_snowflake_cache.py +++ b/airbyte-lib/tests/integration_tests/test_snowflake_cache.py @@ -98,6 +98,8 @@ def snowflake_cache(snowflake_config) -> Generator[caches.SnowflakeCache, None, # Uncomment this line if you want to see performance trace logs. # You can render perf traces using the viztracer CLI or the VS Code VizTracer Extension. #@viztracer.trace_and_save(output_dir=".pytest_cache/snowflake_trace/") +@pytest.mark.requires_creds +@pytest.mark.slow def test_faker_read_to_snowflake( source_faker_seed_a: ab.Source, snowflake_cache: ab.SnowflakeCache, @@ -109,6 +111,8 @@ def test_faker_read_to_snowflake( assert len(list(result.cache.streams["users"])) == FAKER_SCALE_A +@pytest.mark.requires_creds +@pytest.mark.slow def test_replace_strategy( source_faker_seed_a: ab.Source, snowflake_cache: ab.SnowflakeCache, @@ -121,6 +125,8 @@ def test_replace_strategy( assert len(list(result.cache.streams["users"])) == FAKER_SCALE_A +@pytest.mark.requires_creds +@pytest.mark.slow def test_merge_strategy( source_faker_seed_a: ab.Source, source_faker_seed_b: ab.Source, From e8ee418377389cfc3c5ce42702a8a1c384f8e4e4 Mon Sep 17 00:00:00 2001 From: Aaron Steers Date: Wed, 14 Feb 2024 10:48:30 -0800 Subject: [PATCH 3/6] add 'require_creds' mark in pytest --- airbyte-lib/pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/airbyte-lib/pyproject.toml b/airbyte-lib/pyproject.toml index 7630e713bd8e..d1bdb3049c0c 100644 --- a/airbyte-lib/pyproject.toml +++ b/airbyte-lib/pyproject.toml @@ -58,6 +58,7 @@ build-backend = "poetry.core.masonry.api" [tool.pytest.ini_options] markers = [ "slow: marks tests as slow (deselect with '-m \"not slow\"')", + "requires_creds: marks a test as requiring credentials (skip when secrets unavailable)" ] [tool.ruff.pylint] From 2c982b86a0876c44cc61a4aeaf893fab52100d0a Mon Sep 17 00:00:00 2001 From: Aaron Steers Date: Wed, 14 Feb 2024 11:09:13 -0800 Subject: [PATCH 4/6] run slow tests last --- airbyte-lib/tests/conftest.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/airbyte-lib/tests/conftest.py b/airbyte-lib/tests/conftest.py index 64a3b83431b7..0824d77f3eb8 100644 --- a/airbyte-lib/tests/conftest.py +++ b/airbyte-lib/tests/conftest.py @@ -44,7 +44,9 @@ def pytest_collection_modifyitems(items: list[Item]) -> None: 'integration' tests because 'u' comes after 'i' alphabetically. """ def test_priority(item: Item) -> int: - if 'lint_tests' in str(item.fspath): + if item.get_closest_marker(name="slow"): + return 9 # slow tests have the lowest priority + elif 'lint_tests' in str(item.fspath): return 1 # lint tests have high priority elif 'unit_tests' in str(item.fspath): return 2 # unit tests have highest priority From 5c40cab06ab117978297324e4691962cba712d16 Mon Sep 17 00:00:00 2001 From: Aaron Steers Date: Wed, 14 Feb 2024 11:13:48 -0800 Subject: [PATCH 5/6] mark more slow tests --- .../tests/integration_tests/test_source_faker_integration.py | 3 +++ .../tests/integration_tests/test_source_test_fixture.py | 1 + 2 files changed, 4 insertions(+) diff --git a/airbyte-lib/tests/integration_tests/test_source_faker_integration.py b/airbyte-lib/tests/integration_tests/test_source_faker_integration.py index 22e16b6ef0af..244c52f0e901 100644 --- a/airbyte-lib/tests/integration_tests/test_source_faker_integration.py +++ b/airbyte-lib/tests/integration_tests/test_source_faker_integration.py @@ -141,6 +141,7 @@ def test_faker_pks( assert read_result.cache._get_primary_keys("purchases") == ["id"] +@pytest.mark.slow def test_replace_strategy( source_faker_seed_a: ab.Source, all_cache_types: ab.DuckDBCache, @@ -155,6 +156,7 @@ def test_replace_strategy( assert len(list(result.cache.streams["purchases"])) == FAKER_SCALE_A +@pytest.mark.slow def test_append_strategy( source_faker_seed_a: ab.Source, all_cache_types: ab.DuckDBCache, @@ -167,6 +169,7 @@ def test_append_strategy( assert len(list(result.cache.streams["purchases"])) == FAKER_SCALE_A * iteration +@pytest.mark.slow @pytest.mark.parametrize("strategy", ["merge", "auto"]) def test_merge_strategy( strategy: str, diff --git a/airbyte-lib/tests/integration_tests/test_source_test_fixture.py b/airbyte-lib/tests/integration_tests/test_source_test_fixture.py index 6fc9d04bc047..db04a2d0750a 100644 --- a/airbyte-lib/tests/integration_tests/test_source_test_fixture.py +++ b/airbyte-lib/tests/integration_tests/test_source_test_fixture.py @@ -688,6 +688,7 @@ def test_sync_to_postgres(new_pg_cache_config: PostgresCacheConfig, expected_tes check_dtype=False, ) +@pytest.mark.slow def test_sync_to_snowflake(snowflake_config: SnowflakeCacheConfig, expected_test_stream_data: dict[str, list[dict[str, str | int]]]): source = ab.get_source("source-test", config={"apiKey": "test"}) source.select_all_streams() From 710af18af3fcd334380d4bc21279288bfb0e65a5 Mon Sep 17 00:00:00 2001 From: "Aaron (\"AJ\") Steers" Date: Wed, 14 Feb 2024 11:24:55 -0800 Subject: [PATCH 6/6] apply suggestion --- airbyte-lib/tests/integration_tests/test_source_test_fixture.py | 1 + 1 file changed, 1 insertion(+) diff --git a/airbyte-lib/tests/integration_tests/test_source_test_fixture.py b/airbyte-lib/tests/integration_tests/test_source_test_fixture.py index db04a2d0750a..dadc7b12da72 100644 --- a/airbyte-lib/tests/integration_tests/test_source_test_fixture.py +++ b/airbyte-lib/tests/integration_tests/test_source_test_fixture.py @@ -689,6 +689,7 @@ def test_sync_to_postgres(new_pg_cache_config: PostgresCacheConfig, expected_tes ) @pytest.mark.slow +@pytest.mark.requires_creds def test_sync_to_snowflake(snowflake_config: SnowflakeCacheConfig, expected_test_stream_data: dict[str, list[dict[str, str | int]]]): source = ab.get_source("source-test", config={"apiKey": "test"}) source.select_all_streams()