Skip to content

Commit fe0e66f

Browse files
authored
Cloud testing (#290)
### Summary Adjusting dbt tests to run against other environments (with the goal of us being able to run tests against Dremio DC). ### Description This PR makes the testing framework more flexible, mainly by removing some hard coded values.
1 parent 744005d commit fe0e66f

File tree

8 files changed

+52
-41
lines changed

8 files changed

+52
-41
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
tests/functional/adapter/unit_testing/test_unit_testing.py::TestDremioUnitTestingTypes::test_unit_test_data_type
2+
tests/functional/adapter/dremio_specific/test_persist_docs.py::TestPersistDocs::test_view_model_delete_wikis_and_tags
3+
tests/functional/adapter/dremio_specific/test_persist_docs.py::TestPersistDocs::test_view_model_update_wikis_and_tags
4+
tests/functional/adapter/dremio_specific/test_persist_docs.py::TestPersistDocs::test_view_model_wikis_and_tags_remain_when_no_changes
5+
tests/functional/adapter/grants/test_incremental_grants.py::TestIncrementalGrantsDremio::test_incremental_grants
6+
tests/functional/adapter/grants/test_model_grants.py::TestTableGrantsDremio::test_view_table_grants
7+
tests/functional/adapter/grants/test_model_grants.py::TestViewGrantsDremio::test_view_table_grants
8+
tests/functional/adapter/grants/test_seed_grants.py::TestSeedGrantsDremio::test_seed_grants
9+
tests/functional/adapter/materialization/test_base_mat.py::TestSimpleMaterializationsDremio::test_base
10+
tests/functional/adapter/utils/test_array_append.py::TestArrayAppend::test_expected_actual
11+
tests/functional/adapter/utils/test_array_concat.py::TestArrayConcat::test_expected_actual
12+
tests/functional/adapter/utils/test_null_compare.py::TestMixedNullCompare::test_build_assert_equal
13+
tests/functional/adapter/utils/test_null_compare.py::TestNullCompare::test_build_assert_equal
14+
tests/simple_copy/test_simple_copy.py::TestSimpleCopyBaseDremio::test_simple_copy_with_materialized_views
15+
tests/functional/adapter/grants/test_snapshot_grants.py::TestSnapshotGrantsDremio::test_snapshot_grants
16+
tests/component/test_profile_template.py::TestProfileTemplate::test_software_pat_options
17+
tests/component/test_profile_template.py::TestProfileTemplate::test_software_username_password_options
18+
tests/functional/adapter/basic/test_docs_generate.py::TestBaseDocsGenerateDremio::test_run_and_generate
19+
tests/functional/adapter/dremio_specific/test_exact_search.py::TestExactSearchEnabled::test_exact_match_succeeds
20+
tests/functional/adapter/dremio_specific/test_exact_search.py::TestExactSearchEnabled::test_ilike_match_succeeds
21+
tests/hooks/test_model_hooks.py::TestPrePostModelHooksInConfigDremio::test_pre_and_post_model_hooks_model
22+
tests/hooks/test_model_hooks.py::TestPrePostModelHooksInConfigWithCountDremio::test_pre_and_post_model_hooks_model_and_project
23+
tests/hooks/test_model_hooks.py::TestPrePostModelHooksInConfigKwargsDremio::test_pre_and_post_model_hooks_model
24+
tests/hooks/test_model_hooks.py::TestPrePostModelHooksUnderscoresDremio::test_pre_and_post_run_hooks

.github/scripts/profiles.yml

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,3 @@
1-
test_cloud_options:
2-
outputs:
3-
dev:
4-
dremio_space: '@user'
5-
dremio_space_folder: no_schema
6-
object_storage_path: no_schema
7-
object_storage_source: $scratch
8-
pat: dremio123
9-
port: 9047
10-
software_host: localhost
11-
threads: 1
12-
type: dremio
13-
use_ssl: false
14-
user: dremio
15-
target: dev
161
test_sw_pat_options:
172
outputs:
183
dev:

tests/component/test_profile_template.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
from dbt.config.profile import read_profile
1919
from dbt.adapters.dremio.credentials import DremioCredentials
20+
from tests.utils.util import SOURCE
2021

2122
# Tests require manual setup before executing.
2223
#
@@ -55,18 +56,17 @@ class TestProfileTemplate:
5556
_PAT_AUTH_PROFILE_OPTIONS_WITH_DEFAULTS = {"pat": None}
5657
_COMMON_PROFILE_OPTIONS_WITH_DEFAULTS = {
5758
"user": None,
58-
"object_storage_source": "$scratch",
59-
"object_storage_path": "no_schema",
60-
"dremio_space": "@user",
61-
"dremio_space_folder": "no_schema",
6259
"threads": 1,
6360
}
6461
_DREMIO_CLOUD_PROFILE_SPECIFIC_OPTIONS_WITH_DEFAULTS = {
65-
"cloud_host": "api.dremio.cloud",
66-
"cloud_project_id": None,
67-
"use_ssl": True,
62+
"dremio_space": SOURCE,
63+
"dremio_space_folder": "space",
64+
"object_storage_source": SOURCE,
65+
"object_storage_path": "object_storage",
66+
"use_ssl": False,
6867
}
6968
_DREMIO_SW_PROFILE_SPECIFIC_OPTIONS_WITH_DEFAULTS = {
69+
"object_storage_source": "$scratch",
7070
"software_host": None,
7171
"port": 9047,
7272
"use_ssl": False,

tests/functional/adapter/dbt_clone/test_dbt_clone.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,21 @@
2121

2222

2323
# Need to change the target_database to be the object_storage_source
24-
snapshot_sql = """
25-
{% snapshot my_cool_snapshot %}
24+
snapshot_sql = f"""
25+
{{% snapshot my_cool_snapshot %}}
2626
27-
{{
27+
{{{{
2828
config(
29-
target_database="dbt_test_source",
29+
target_database="{SOURCE}",
3030
target_schema=schema,
3131
unique_key='id',
3232
strategy='check',
3333
check_cols=['id'],
3434
)
35-
}}
36-
select * from {{ ref('view_model') }}
35+
}}}}
36+
select * from {{{{ ref('view_model') }}}}
3737
38-
{% endsnapshot %}
38+
{{% endsnapshot %}}
3939
"""
4040

4141
# Append _seeds to schemas of both targets

tests/functional/adapter/dremio_specific/test_persist_docs.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
from build.lib.dbt.adapters.dremio.api.rest.client import DremioRestClient
2727

28-
from tests.utils.util import BUCKET
28+
from tests.utils.util import BUCKET, SOURCE
2929

3030
# Excluded seed
3131
_PROPERTIES__SCHEMA_YML = """
@@ -256,9 +256,8 @@ def _create_path_list(self, database, schema):
256256
def _get_relation_id(self, project, client, identifier):
257257
client.start()
258258

259-
# Replacing dbt_test to dbt_test_source if it is table
260259
if identifier == "table_model":
261-
database = "dbt_test_source"
260+
database = SOURCE
262261
else:
263262
database = project.database
264263
schema = project.test_schema

tests/functional/adapter/dremio_specific/test_schema_parsing.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
read_file,
2020
write_file,
2121
)
22+
from tests.utils.util import BUCKET
23+
2224
test_schema_parsing = """
2325
{{
2426
config(
@@ -45,7 +47,7 @@ def update_config_file(self, updates, *paths):
4547

4648
def test_schema_with_dots(self, project):
4749
self.update_config_file(
48-
{"root_path": 'dbtdremios3."test.schema"'},
50+
{"root_path": f'{BUCKET}."test.schema"'},
4951
project.profiles_dir,
5052
"profiles.yml",
5153
)

tests/functional/adapter/materialization/test_base_mat.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
)
3232
from tests.utils.util import BUCKET
3333

34-
# Unable to insert variable into docstring, so "dbt_test_source" is hardcoded
3534
schema_base_yml = """
3635
version: 2
3736
sources:

tests/utils/util.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,17 @@
1616
from typing import List
1717
from contextlib import contextmanager
1818
from dbt.tests.util import AnyInteger
19+
import os
1920

2021
from dbt.adapters.events.logging import AdapterLogger
2122

2223
logger = AdapterLogger("dremio")
2324

2425
# Ensure we do not include dashes in our source
2526
# https://github.com/dremio/dbt-dremio/issues/68
26-
BUCKET = "dbtdremios3"
27-
SOURCE = "dbt_test_source"
27+
# Use environment variable if present, otherwise use default value
28+
BUCKET = os.environ.get("DBT_DREMIO_S3_BUCKET", "dbtdremios3")
29+
SOURCE = os.environ.get("DBT_DREMIO_S3_SOURCE", "dbt_test_source")
2830

2931

3032
class TestProcessingException(Exception):
@@ -55,15 +57,15 @@ def relation_from_name(adapter, name: str, materialization=""):
5557
relation_parts.insert(0, credentials.datalake)
5658
if credentials.root_path not in [None, "no_schema"]:
5759
relation_parts.insert(1, credentials.root_path)
58-
60+
5961

6062
relation_type = "table" if materialization != "view" and "view" not in name else "view"
6163

6264
schema = ".".join(relation_parts[1:-1])
6365

6466
kwargs = {
6567
"database": relation_parts[0],
66-
"schema": None if schema == "" else schema,
68+
"schema": None if schema == "" else schema,
6769
"identifier": relation_parts[-1],
6870
"type": relation_type,
6971
}
@@ -83,7 +85,7 @@ def get_connection(adapter, name="_test"):
8385
yield conn
8486

8587
# Overwrite the default implementation to use this adapter's
86-
# relation_from_name function.
88+
# relation_from_name function.
8789
def get_relation_columns(adapter, name):
8890
relation = relation_from_name(adapter, name)
8991
with get_connection(adapter):
@@ -92,7 +94,7 @@ def get_relation_columns(adapter, name):
9294

9395

9496
# Overwrite the default implementation to use this adapter's
95-
# relation_from_name function.
97+
# relation_from_name function.
9698
def check_relation_types(adapter, relation_to_type):
9799
# Ensure that models with different materialiations have the
98100
# corrent table/view.
@@ -128,7 +130,7 @@ def check_relation_types(adapter, relation_to_type):
128130

129131

130132
# Overwrite the default implementation to use this adapter's
131-
# relation_from_name function.
133+
# relation_from_name function.
132134
def check_relations_equal(adapter, relation_names: List, compare_snapshot_cols=False):
133135
# Replaces assertTablesEqual. assertManyTablesEqual can be replaced
134136
# by doing a separate call for each set of tables/relations.

0 commit comments

Comments
 (0)