-
Notifications
You must be signed in to change notification settings - Fork 154
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* use dynamic schema in test_grant_access_to.py * use dynamic schema in test_grant_access_to.py * experiment with query job cancel on timeout * modify unit tests * remove test grants change * starting functional test * update functional test and experiment with polling logic * experiment with async wait_for * modifying connections.py for asyncio logic * swap back to new_event_loop * close loop, now seeing asyncio timeoutError * improve order and update functional test * update unit test * add changie * add max_result back to result call in async path * rescope the dbt_profile_target to being a class fixture * raise DbtRuntimeError instead database * remove exception type check in job timeout --------- Co-authored-by: Matthew McKnight <matthew.mcknight@dbtlabs.com> Co-authored-by: Matthew McKnight <91097623+McKnight-42@users.noreply.github.com>
- Loading branch information
1 parent
0a9ab72
commit 2eb407d
Showing
5 changed files
with
114 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
kind: Fixes | ||
body: Time out queries if user supplies `job_execution_timeout` | ||
time: 2023-08-29T16:21:11.69291-07:00 | ||
custom: | ||
Author: colin-rogers-dbt McKnight-42 | ||
Issue: "231" |
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,62 @@ | ||
import pytest | ||
|
||
from dbt.tests.util import run_dbt | ||
|
||
_REASONABLE_TIMEOUT = 300 | ||
_SHORT_TIMEOUT = 1 | ||
|
||
_LONG_RUNNING_MODEL_SQL = """ | ||
{{ config(materialized='table') }} | ||
with array_1 as ( | ||
select generated_ids from UNNEST(GENERATE_ARRAY(1, 200000)) AS generated_ids | ||
), | ||
array_2 as ( | ||
select generated_ids from UNNEST(GENERATE_ARRAY(2, 200000)) AS generated_ids | ||
) | ||
SELECT array_1.generated_ids | ||
FROM array_1 | ||
LEFT JOIN array_1 as jnd on 1=1 | ||
LEFT JOIN array_2 as jnd2 on 1=1 | ||
LEFT JOIN array_1 as jnd3 on jnd3.generated_ids >= jnd2.generated_ids | ||
""" | ||
|
||
_SHORT_RUNNING_QUERY = """ | ||
SELECT 1 as id | ||
""" | ||
|
||
|
||
class TestSuccessfulJobRun: | ||
@pytest.fixture(scope="class") | ||
def models(self): | ||
return { | ||
"model.sql": _SHORT_RUNNING_QUERY, | ||
} | ||
|
||
@pytest.fixture(scope="class") | ||
def profiles_config_update(self, dbt_profile_target): | ||
outputs = {"default": dbt_profile_target} | ||
outputs["default"]["job_execution_timeout_seconds"] = _REASONABLE_TIMEOUT | ||
return {"test": {"outputs": outputs, "target": "default"}} | ||
|
||
def test_bigquery_job_run_succeeds_within_timeout(self, project): | ||
result = run_dbt() | ||
assert len(result) == 1 | ||
|
||
|
||
class TestJobTimeout: | ||
@pytest.fixture(scope="class") | ||
def models(self): | ||
return { | ||
"model.sql": _LONG_RUNNING_MODEL_SQL, | ||
} | ||
|
||
@pytest.fixture(scope="class") | ||
def profiles_config_update(self, dbt_profile_target): | ||
outputs = {"default": dbt_profile_target} | ||
outputs["default"]["job_execution_timeout_seconds"] = _SHORT_TIMEOUT | ||
return {"test": {"outputs": outputs, "target": "default"}} | ||
|
||
def test_job_timeout(self, project): | ||
result = run_dbt(["run"], expect_pass=False) # project setup will fail | ||
assert f"Query exceeded configured timeout of {_SHORT_TIMEOUT}s" in result[0].message |
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