From c7cabff5bfe0254f26ad25f1138b5b55acb90bd5 Mon Sep 17 00:00:00 2001 From: Stu Kilgore Date: Tue, 8 Nov 2022 07:43:40 -0600 Subject: [PATCH 1/2] Convert threading tests to pytest --- .../031_thread_count_tests/models/.gitkeep | 0 .../models/do_nothing_1.sql | 1 - .../models/do_nothing_10.sql | 1 - .../models/do_nothing_11.sql | 1 - .../models/do_nothing_12.sql | 1 - .../models/do_nothing_13.sql | 1 - .../models/do_nothing_14.sql | 1 - .../models/do_nothing_15.sql | 1 - .../models/do_nothing_16.sql | 1 - .../models/do_nothing_17.sql | 1 - .../models/do_nothing_18.sql | 1 - .../models/do_nothing_19.sql | 1 - .../models/do_nothing_2.sql | 1 - .../models/do_nothing_20.sql | 1 - .../models/do_nothing_3.sql | 1 - .../models/do_nothing_4.sql | 1 - .../models/do_nothing_5.sql | 1 - .../models/do_nothing_6.sql | 1 - .../models/do_nothing_7.sql | 1 - .../models/do_nothing_8.sql | 1 - .../models/do_nothing_9.sql | 1 - .../test_thread_count.py | 28 ----------- .../functional/threading/test_thread_count.py | 46 +++++++++++++++++++ 23 files changed, 46 insertions(+), 48 deletions(-) delete mode 100644 test/integration/031_thread_count_tests/models/.gitkeep delete mode 100644 test/integration/031_thread_count_tests/models/do_nothing_1.sql delete mode 100644 test/integration/031_thread_count_tests/models/do_nothing_10.sql delete mode 100644 test/integration/031_thread_count_tests/models/do_nothing_11.sql delete mode 100644 test/integration/031_thread_count_tests/models/do_nothing_12.sql delete mode 100644 test/integration/031_thread_count_tests/models/do_nothing_13.sql delete mode 100644 test/integration/031_thread_count_tests/models/do_nothing_14.sql delete mode 100644 test/integration/031_thread_count_tests/models/do_nothing_15.sql delete mode 100644 test/integration/031_thread_count_tests/models/do_nothing_16.sql delete mode 100644 test/integration/031_thread_count_tests/models/do_nothing_17.sql delete mode 100644 test/integration/031_thread_count_tests/models/do_nothing_18.sql delete mode 100644 test/integration/031_thread_count_tests/models/do_nothing_19.sql delete mode 100644 test/integration/031_thread_count_tests/models/do_nothing_2.sql delete mode 100644 test/integration/031_thread_count_tests/models/do_nothing_20.sql delete mode 100644 test/integration/031_thread_count_tests/models/do_nothing_3.sql delete mode 100644 test/integration/031_thread_count_tests/models/do_nothing_4.sql delete mode 100644 test/integration/031_thread_count_tests/models/do_nothing_5.sql delete mode 100644 test/integration/031_thread_count_tests/models/do_nothing_6.sql delete mode 100644 test/integration/031_thread_count_tests/models/do_nothing_7.sql delete mode 100644 test/integration/031_thread_count_tests/models/do_nothing_8.sql delete mode 100644 test/integration/031_thread_count_tests/models/do_nothing_9.sql delete mode 100644 test/integration/031_thread_count_tests/test_thread_count.py create mode 100644 tests/functional/threading/test_thread_count.py diff --git a/test/integration/031_thread_count_tests/models/.gitkeep b/test/integration/031_thread_count_tests/models/.gitkeep deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/integration/031_thread_count_tests/models/do_nothing_1.sql b/test/integration/031_thread_count_tests/models/do_nothing_1.sql deleted file mode 100644 index 341741be33b..00000000000 --- a/test/integration/031_thread_count_tests/models/do_nothing_1.sql +++ /dev/null @@ -1 +0,0 @@ -with x as (select pg_sleep(1)) select 1 \ No newline at end of file diff --git a/test/integration/031_thread_count_tests/models/do_nothing_10.sql b/test/integration/031_thread_count_tests/models/do_nothing_10.sql deleted file mode 100644 index 341741be33b..00000000000 --- a/test/integration/031_thread_count_tests/models/do_nothing_10.sql +++ /dev/null @@ -1 +0,0 @@ -with x as (select pg_sleep(1)) select 1 \ No newline at end of file diff --git a/test/integration/031_thread_count_tests/models/do_nothing_11.sql b/test/integration/031_thread_count_tests/models/do_nothing_11.sql deleted file mode 100644 index 341741be33b..00000000000 --- a/test/integration/031_thread_count_tests/models/do_nothing_11.sql +++ /dev/null @@ -1 +0,0 @@ -with x as (select pg_sleep(1)) select 1 \ No newline at end of file diff --git a/test/integration/031_thread_count_tests/models/do_nothing_12.sql b/test/integration/031_thread_count_tests/models/do_nothing_12.sql deleted file mode 100644 index 341741be33b..00000000000 --- a/test/integration/031_thread_count_tests/models/do_nothing_12.sql +++ /dev/null @@ -1 +0,0 @@ -with x as (select pg_sleep(1)) select 1 \ No newline at end of file diff --git a/test/integration/031_thread_count_tests/models/do_nothing_13.sql b/test/integration/031_thread_count_tests/models/do_nothing_13.sql deleted file mode 100644 index 341741be33b..00000000000 --- a/test/integration/031_thread_count_tests/models/do_nothing_13.sql +++ /dev/null @@ -1 +0,0 @@ -with x as (select pg_sleep(1)) select 1 \ No newline at end of file diff --git a/test/integration/031_thread_count_tests/models/do_nothing_14.sql b/test/integration/031_thread_count_tests/models/do_nothing_14.sql deleted file mode 100644 index 341741be33b..00000000000 --- a/test/integration/031_thread_count_tests/models/do_nothing_14.sql +++ /dev/null @@ -1 +0,0 @@ -with x as (select pg_sleep(1)) select 1 \ No newline at end of file diff --git a/test/integration/031_thread_count_tests/models/do_nothing_15.sql b/test/integration/031_thread_count_tests/models/do_nothing_15.sql deleted file mode 100644 index 341741be33b..00000000000 --- a/test/integration/031_thread_count_tests/models/do_nothing_15.sql +++ /dev/null @@ -1 +0,0 @@ -with x as (select pg_sleep(1)) select 1 \ No newline at end of file diff --git a/test/integration/031_thread_count_tests/models/do_nothing_16.sql b/test/integration/031_thread_count_tests/models/do_nothing_16.sql deleted file mode 100644 index 341741be33b..00000000000 --- a/test/integration/031_thread_count_tests/models/do_nothing_16.sql +++ /dev/null @@ -1 +0,0 @@ -with x as (select pg_sleep(1)) select 1 \ No newline at end of file diff --git a/test/integration/031_thread_count_tests/models/do_nothing_17.sql b/test/integration/031_thread_count_tests/models/do_nothing_17.sql deleted file mode 100644 index 341741be33b..00000000000 --- a/test/integration/031_thread_count_tests/models/do_nothing_17.sql +++ /dev/null @@ -1 +0,0 @@ -with x as (select pg_sleep(1)) select 1 \ No newline at end of file diff --git a/test/integration/031_thread_count_tests/models/do_nothing_18.sql b/test/integration/031_thread_count_tests/models/do_nothing_18.sql deleted file mode 100644 index 341741be33b..00000000000 --- a/test/integration/031_thread_count_tests/models/do_nothing_18.sql +++ /dev/null @@ -1 +0,0 @@ -with x as (select pg_sleep(1)) select 1 \ No newline at end of file diff --git a/test/integration/031_thread_count_tests/models/do_nothing_19.sql b/test/integration/031_thread_count_tests/models/do_nothing_19.sql deleted file mode 100644 index 341741be33b..00000000000 --- a/test/integration/031_thread_count_tests/models/do_nothing_19.sql +++ /dev/null @@ -1 +0,0 @@ -with x as (select pg_sleep(1)) select 1 \ No newline at end of file diff --git a/test/integration/031_thread_count_tests/models/do_nothing_2.sql b/test/integration/031_thread_count_tests/models/do_nothing_2.sql deleted file mode 100644 index 341741be33b..00000000000 --- a/test/integration/031_thread_count_tests/models/do_nothing_2.sql +++ /dev/null @@ -1 +0,0 @@ -with x as (select pg_sleep(1)) select 1 \ No newline at end of file diff --git a/test/integration/031_thread_count_tests/models/do_nothing_20.sql b/test/integration/031_thread_count_tests/models/do_nothing_20.sql deleted file mode 100644 index 341741be33b..00000000000 --- a/test/integration/031_thread_count_tests/models/do_nothing_20.sql +++ /dev/null @@ -1 +0,0 @@ -with x as (select pg_sleep(1)) select 1 \ No newline at end of file diff --git a/test/integration/031_thread_count_tests/models/do_nothing_3.sql b/test/integration/031_thread_count_tests/models/do_nothing_3.sql deleted file mode 100644 index 341741be33b..00000000000 --- a/test/integration/031_thread_count_tests/models/do_nothing_3.sql +++ /dev/null @@ -1 +0,0 @@ -with x as (select pg_sleep(1)) select 1 \ No newline at end of file diff --git a/test/integration/031_thread_count_tests/models/do_nothing_4.sql b/test/integration/031_thread_count_tests/models/do_nothing_4.sql deleted file mode 100644 index 341741be33b..00000000000 --- a/test/integration/031_thread_count_tests/models/do_nothing_4.sql +++ /dev/null @@ -1 +0,0 @@ -with x as (select pg_sleep(1)) select 1 \ No newline at end of file diff --git a/test/integration/031_thread_count_tests/models/do_nothing_5.sql b/test/integration/031_thread_count_tests/models/do_nothing_5.sql deleted file mode 100644 index 341741be33b..00000000000 --- a/test/integration/031_thread_count_tests/models/do_nothing_5.sql +++ /dev/null @@ -1 +0,0 @@ -with x as (select pg_sleep(1)) select 1 \ No newline at end of file diff --git a/test/integration/031_thread_count_tests/models/do_nothing_6.sql b/test/integration/031_thread_count_tests/models/do_nothing_6.sql deleted file mode 100644 index 341741be33b..00000000000 --- a/test/integration/031_thread_count_tests/models/do_nothing_6.sql +++ /dev/null @@ -1 +0,0 @@ -with x as (select pg_sleep(1)) select 1 \ No newline at end of file diff --git a/test/integration/031_thread_count_tests/models/do_nothing_7.sql b/test/integration/031_thread_count_tests/models/do_nothing_7.sql deleted file mode 100644 index 341741be33b..00000000000 --- a/test/integration/031_thread_count_tests/models/do_nothing_7.sql +++ /dev/null @@ -1 +0,0 @@ -with x as (select pg_sleep(1)) select 1 \ No newline at end of file diff --git a/test/integration/031_thread_count_tests/models/do_nothing_8.sql b/test/integration/031_thread_count_tests/models/do_nothing_8.sql deleted file mode 100644 index 341741be33b..00000000000 --- a/test/integration/031_thread_count_tests/models/do_nothing_8.sql +++ /dev/null @@ -1 +0,0 @@ -with x as (select pg_sleep(1)) select 1 \ No newline at end of file diff --git a/test/integration/031_thread_count_tests/models/do_nothing_9.sql b/test/integration/031_thread_count_tests/models/do_nothing_9.sql deleted file mode 100644 index 341741be33b..00000000000 --- a/test/integration/031_thread_count_tests/models/do_nothing_9.sql +++ /dev/null @@ -1 +0,0 @@ -with x as (select pg_sleep(1)) select 1 \ No newline at end of file diff --git a/test/integration/031_thread_count_tests/test_thread_count.py b/test/integration/031_thread_count_tests/test_thread_count.py deleted file mode 100644 index 042e2cd8a94..00000000000 --- a/test/integration/031_thread_count_tests/test_thread_count.py +++ /dev/null @@ -1,28 +0,0 @@ - -from test.integration.base import DBTIntegrationTest, use_profile - - -class TestThreadCount(DBTIntegrationTest): - - @property - def project_config(self): - return {'config-version': 2} - - @property - def profile_config(self): - return { - 'threads': 2, - } - - @property - def schema(self): - return "thread_tests_031" - - @property - def models(self): - return "models" - - @use_profile('postgres') - def test_postgres_threading_8x(self): - results = self.run_dbt(args=['run', '--threads', '16']) - self.assertTrue(len(results), 20) diff --git a/tests/functional/threading/test_thread_count.py b/tests/functional/threading/test_thread_count.py new file mode 100644 index 00000000000..c31f5ed6312 --- /dev/null +++ b/tests/functional/threading/test_thread_count.py @@ -0,0 +1,46 @@ +import pytest +from dbt.tests.util import run_dbt + + +models__do_nothing__sql = """ +with x as (select pg_sleep(1)) select 1 +""" + + +class TestThreadCount: + @pytest.fixture(scope="class") + def models(self): + return { + "do_nothing_1.sql": models__do_nothing__sql, + "do_nothing_2.sql": models__do_nothing__sql, + "do_nothing_3.sql": models__do_nothing__sql, + "do_nothing_4.sql": models__do_nothing__sql, + "do_nothing_5.sql": models__do_nothing__sql, + "do_nothing_6.sql": models__do_nothing__sql, + "do_nothing_7.sql": models__do_nothing__sql, + "do_nothing_8.sql": models__do_nothing__sql, + "do_nothing_9.sql": models__do_nothing__sql, + "do_nothing_10.sql": models__do_nothing__sql, + "do_nothing_11.sql": models__do_nothing__sql, + "do_nothing_12.sql": models__do_nothing__sql, + "do_nothing_13.sql": models__do_nothing__sql, + "do_nothing_14.sql": models__do_nothing__sql, + "do_nothing_15.sql": models__do_nothing__sql, + "do_nothing_16.sql": models__do_nothing__sql, + "do_nothing_17.sql": models__do_nothing__sql, + "do_nothing_18.sql": models__do_nothing__sql, + "do_nothing_19.sql": models__do_nothing__sql, + "do_nothing_20.sql": models__do_nothing__sql, + } + + @pytest.fixture(scope="class") + def project_config_update(self): + return {"config-version": 2} + + @pytest.fixture(scope="class") + def profiles_config_update(self): + return {"threads": 2} + + def test_threading_8x(self, project): + results = run_dbt(args=["run", "--threads", "16"]) + assert len(results), 20 From 57e4e3b7612e7c99688d302dd90d5aab7d9c9533 Mon Sep 17 00:00:00 2001 From: Stu Kilgore Date: Tue, 8 Nov 2022 07:45:53 -0600 Subject: [PATCH 2/2] Add changie entry --- .changes/unreleased/Under the Hood-20221108-074550.yaml | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 .changes/unreleased/Under the Hood-20221108-074550.yaml diff --git a/.changes/unreleased/Under the Hood-20221108-074550.yaml b/.changes/unreleased/Under the Hood-20221108-074550.yaml new file mode 100644 index 00000000000..351887f767a --- /dev/null +++ b/.changes/unreleased/Under the Hood-20221108-074550.yaml @@ -0,0 +1,7 @@ +kind: Under the Hood +body: Convert threading tests to pytest +time: 2022-11-08T07:45:50.589147-06:00 +custom: + Author: stu-k + Issue: "5942" + PR: "6226"