-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
connectors-ci: implement per step time out (#28771)
* connectors-ci: implement per step time out * set default timeout to 5hours * DEMO - to revert * Revert "DEMO - to revert" This reverts commit 2f4fd39.
- Loading branch information
1 parent
9f6963c
commit 9cee15b
Showing
4 changed files
with
95 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# | ||
# Copyright (c) 2023 Airbyte, Inc., all rights reserved. | ||
# | ||
import dagger | ||
import pytest | ||
import requests | ||
|
||
|
||
@pytest.fixture(scope="session") | ||
def anyio_backend(): | ||
return "asyncio" | ||
|
||
|
||
@pytest.fixture(scope="session") | ||
async def dagger_client(): | ||
async with dagger.Connection() as client: | ||
yield client | ||
|
||
|
||
@pytest.fixture(scope="session") | ||
def oss_registry(): | ||
response = requests.get("https://connectors.airbyte.com/files/registries/v0/oss_registry.json") | ||
response.raise_for_status() | ||
return response.json() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# | ||
# Copyright (c) 2023 Airbyte, Inc., all rights reserved. | ||
# | ||
from datetime import timedelta | ||
|
||
import anyio | ||
import pytest | ||
from pipelines import bases | ||
|
||
pytestmark = [ | ||
pytest.mark.anyio, | ||
] | ||
|
||
|
||
class TestStep: | ||
class DummyStep(bases.Step): | ||
title = "Dummy step" | ||
max_retries = 3 | ||
max_duration = timedelta(seconds=2) | ||
|
||
async def _run(self, run_duration: timedelta) -> bases.StepResult: | ||
await anyio.sleep(run_duration.total_seconds()) | ||
return bases.StepResult(self, bases.StepStatus.SUCCESS) | ||
|
||
@pytest.fixture | ||
def test_context(self, mocker): | ||
return mocker.Mock(secrets_to_mask=[]) | ||
|
||
async def test_run_with_timeout(self, test_context): | ||
step = self.DummyStep(test_context) | ||
step_result = await step.run(run_duration=step.max_duration - timedelta(seconds=1)) | ||
assert step_result.status == bases.StepStatus.SUCCESS | ||
assert step.retry_count == 0 | ||
|
||
step_result = await step.run(run_duration=step.max_duration + timedelta(seconds=1)) | ||
timed_out_step_result = step._get_timed_out_step_result() | ||
assert step_result.status == timed_out_step_result.status | ||
assert step_result.stdout == timed_out_step_result.stdout | ||
assert step_result.stderr == timed_out_step_result.stderr | ||
assert step_result.output_artifact == timed_out_step_result.output_artifact | ||
assert step.retry_count == step.max_retries + 1 |