From 4287e8fefe812d1535cecb1fe44ed91588260ddd Mon Sep 17 00:00:00 2001 From: Kelvin Sundli Date: Mon, 20 Apr 2026 23:20:40 -0700 Subject: [PATCH 1/5] test(hosted_extractors): skip flaky jobs tests until 2026-05-04 The jobs integration tests leak state between runs, causing 'external_id ... exists' setup errors across the full matrix. Module-level time-bound skip until the tests are fixed. --- .../test_api/test_hosted_extractors/test_jobs.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/tests_integration/test_api/test_hosted_extractors/test_jobs.py b/tests/tests_integration/test_api/test_hosted_extractors/test_jobs.py index 9729e0ef51..5b37746906 100644 --- a/tests/tests_integration/test_api/test_hosted_extractors/test_jobs.py +++ b/tests/tests_integration/test_api/test_hosted_extractors/test_jobs.py @@ -1,6 +1,7 @@ from __future__ import annotations from collections.abc import Iterator +from datetime import date import pytest @@ -19,6 +20,11 @@ from cognite.client.exceptions import CogniteAPIError from cognite.client.utils._text import random_string +pytestmark = pytest.mark.skipif( + date.today() < date(2026, 5, 4), + reason="Hosted extractor jobs tests are flaky; skip until tests are fixed", +) + @pytest.fixture def one_job(cognite_client: CogniteClient, one_event_hub_source: Source, one_destination: Destination) -> Iterator[Job]: From 27623bd8456b7a6169f3731dfb2b69c030dee203 Mon Sep 17 00:00:00 2001 From: Kelvin Sundli Date: Mon, 20 Apr 2026 23:32:49 -0700 Subject: [PATCH 2/5] test(hosted_extractors): move skip to conftest so it covers all 4 files The previous commit skipped only test_jobs.py, but all four files in the directory fail setup due to the shared session-scoped cleanup fixture in conftest.py. Move the skip to a pytest_collection_modifyitems hook in that conftest so it applies to every test in the directory, and revert the file-level pytestmark in test_jobs.py. --- .../test_api/test_hosted_extractors/conftest.py | 13 +++++++++++++ .../test_api/test_hosted_extractors/test_jobs.py | 6 ------ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/tests/tests_integration/test_api/test_hosted_extractors/conftest.py b/tests/tests_integration/test_api/test_hosted_extractors/conftest.py index 22f0b46811..e5874bb561 100644 --- a/tests/tests_integration/test_api/test_hosted_extractors/conftest.py +++ b/tests/tests_integration/test_api/test_hosted_extractors/conftest.py @@ -2,6 +2,7 @@ import time from collections.abc import Iterator +from datetime import date import pytest @@ -21,6 +22,18 @@ UPDATE_SOURCE_PREFIX = "to-update-" TEST_SOURCE_PREFIXES = (HUB_SOURCE_PREFIX, MQTT_SOURCE_PREFIX, UPDATE_SOURCE_PREFIX) +_SKIP_UNTIL = date(2026, 5, 4) + + +def pytest_collection_modifyitems(items: list[pytest.Item]) -> None: + if date.today() >= _SKIP_UNTIL: + return + skip_marker = pytest.mark.skip( + reason=f"Hosted extractor integration tests are flaky; skip until {_SKIP_UNTIL.isoformat()}" + ) + for item in items: + item.add_marker(skip_marker) + @pytest.fixture(scope="session", autouse=True) def cleanup_stale_test_sources(cognite_client: CogniteClient) -> None: diff --git a/tests/tests_integration/test_api/test_hosted_extractors/test_jobs.py b/tests/tests_integration/test_api/test_hosted_extractors/test_jobs.py index 5b37746906..9729e0ef51 100644 --- a/tests/tests_integration/test_api/test_hosted_extractors/test_jobs.py +++ b/tests/tests_integration/test_api/test_hosted_extractors/test_jobs.py @@ -1,7 +1,6 @@ from __future__ import annotations from collections.abc import Iterator -from datetime import date import pytest @@ -20,11 +19,6 @@ from cognite.client.exceptions import CogniteAPIError from cognite.client.utils._text import random_string -pytestmark = pytest.mark.skipif( - date.today() < date(2026, 5, 4), - reason="Hosted extractor jobs tests are flaky; skip until tests are fixed", -) - @pytest.fixture def one_job(cognite_client: CogniteClient, one_event_hub_source: Source, one_destination: Destination) -> Iterator[Job]: From f34ef434e2ce7201166d63e989532bcd47e728a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anders=20=C3=98en=20Fylling?= <7851860+andersfylling@users.noreply.github.com> Date: Tue, 21 Apr 2026 14:29:44 +0200 Subject: [PATCH 3/5] adjust flow --- .../test_api/test_hosted_extractors/conftest.py | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/tests/tests_integration/test_api/test_hosted_extractors/conftest.py b/tests/tests_integration/test_api/test_hosted_extractors/conftest.py index e5874bb561..ebce829a8b 100644 --- a/tests/tests_integration/test_api/test_hosted_extractors/conftest.py +++ b/tests/tests_integration/test_api/test_hosted_extractors/conftest.py @@ -24,15 +24,10 @@ _SKIP_UNTIL = date(2026, 5, 4) - -def pytest_collection_modifyitems(items: list[pytest.Item]) -> None: - if date.today() >= _SKIP_UNTIL: - return - skip_marker = pytest.mark.skip( - reason=f"Hosted extractor integration tests are flaky; skip until {_SKIP_UNTIL.isoformat()}" - ) - for item in items: - item.add_marker(skip_marker) +pytestmark = pytest.mark.skipif( + date.today() < SKIP_UNTIL, + reason=f"Hosted extractor integration tests are flaky; skip until {SKIP_UNTIL.isoformat()}" +) @pytest.fixture(scope="session", autouse=True) From f6451e26667c310b990f38927ff7048809ada5f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5kon=20V=2E=20Treider?= Date: Tue, 21 Apr 2026 20:53:21 +0200 Subject: [PATCH 4/5] Revert all changes since branching from master --- .../test_api/test_hosted_extractors/conftest.py | 8 -------- 1 file changed, 8 deletions(-) diff --git a/tests/tests_integration/test_api/test_hosted_extractors/conftest.py b/tests/tests_integration/test_api/test_hosted_extractors/conftest.py index ebce829a8b..22f0b46811 100644 --- a/tests/tests_integration/test_api/test_hosted_extractors/conftest.py +++ b/tests/tests_integration/test_api/test_hosted_extractors/conftest.py @@ -2,7 +2,6 @@ import time from collections.abc import Iterator -from datetime import date import pytest @@ -22,13 +21,6 @@ UPDATE_SOURCE_PREFIX = "to-update-" TEST_SOURCE_PREFIXES = (HUB_SOURCE_PREFIX, MQTT_SOURCE_PREFIX, UPDATE_SOURCE_PREFIX) -_SKIP_UNTIL = date(2026, 5, 4) - -pytestmark = pytest.mark.skipif( - date.today() < SKIP_UNTIL, - reason=f"Hosted extractor integration tests are flaky; skip until {SKIP_UNTIL.isoformat()}" -) - @pytest.fixture(scope="session", autouse=True) def cleanup_stale_test_sources(cognite_client: CogniteClient) -> None: From f65158757b10eb8c5b9cb08df6ee92e685a2d6ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5kon=20V=2E=20Treider?= Date: Tue, 21 Apr 2026 20:53:57 +0200 Subject: [PATCH 5/5] use force=True delete to also remove those with jobs --- .../test_api/test_hosted_extractors/conftest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/tests_integration/test_api/test_hosted_extractors/conftest.py b/tests/tests_integration/test_api/test_hosted_extractors/conftest.py index 22f0b46811..acd6f22b64 100644 --- a/tests/tests_integration/test_api/test_hosted_extractors/conftest.py +++ b/tests/tests_integration/test_api/test_hosted_extractors/conftest.py @@ -35,7 +35,7 @@ def cleanup_stale_test_sources(cognite_client: CogniteClient) -> None: and now_ms - s.created_time >= 3 * 60 * 60 * 1000 # type: ignore [attr-defined] ] if stale: - cognite_client.hosted_extractors.sources.delete(stale, ignore_unknown_ids=True) + cognite_client.hosted_extractors.sources.delete(stale, force=True, ignore_unknown_ids=True) @pytest.fixture