Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions .github/workflows/test_cloud.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,43 +2,43 @@
name: "test_cloud"

on: # yamllint disable-line rule:truthy
pull_request:
branches:
- '*_cloud'
workflow_dispatch:
pull_request:
branches: main
schedule:
- cron: '0 2 * * *' # Nightly run at 2:00 AM UTC
- cron: '0 2 * * *' # Nightly run at 2:00 AM UTC

jobs:
cloud_smt_tests:
name: ClickHouse Cloud SharedMergeTree Tests
runs-on: ubuntu-latest
timeout-minutes: 90

env:
PYTHONPATH: dbt
DBT_CH_TEST_HOST: ${{ secrets.INTEGRATIONS_TEAM_TESTS_CLOUD_HOST_SMT }}
DBT_CH_TEST_PASSWORD: ${{ secrets.INTEGRATIONS_TEAM_TESTS_CLOUD_PASSWORD_SMT }}
DBT_CH_TEST_HOST: ${{ secrets.DBT_TESTS_CLOUD_HOST_SMT }}
DBT_CH_TEST_PASSWORD: ${{ secrets.DBT_TESTS_CLOUD_PASSWORD_SMT }}
DBT_CH_TEST_CLUSTER_MODE: true
DBT_CH_TEST_CLOUD: true

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup Python 3.11
- name: Setup Python 3.12
uses: actions/setup-python@v4
with:
python-version: '3.11'
python-version: '3.12'

- name: Install requirements
run: pip3 install -r dev_requirements.txt

- name: Run HTTP tests
env:
DBT_CH_TEST_PORT: 8443
run: pytest tests
run: pytest tests --timeout=240

- name: Run Native tests
env:
DBT_CH_TEST_PORT: 9440
run: pytest tests
run: pytest tests --timeout=240
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import pytest
from dbt.adapters.clickhouse.query import quote_identifier
from dbt.tests.fixtures.project import TestProjInfo
from dbt.tests.util import check_relation_types, run_dbt

PEOPLE_SEED_CSV = """
Expand Down Expand Up @@ -193,14 +194,14 @@ def test_disabled_catchup(self, project):
"""


def query_table_type(project, schema, table):
def query_table_type(project: TestProjInfo, schema: str, table: str) -> str:
table_type = project.run_sql(
f"""
select engine from system.tables where database = '{schema}' and name = '{table}'
""",
fetch="all",
)
return table_type[0][0] if len(table_type) > 0 else None
return table_type[0][0] if len(table_type) > 0 else ''


class TestUpdateMV:
Expand Down Expand Up @@ -287,7 +288,7 @@ def test_mv_is_dropped_on_full_refresh(self, project):
assert len(results) == 2 # will include also a view for the other test.

# Verify both tables were created correctly
assert query_table_type(project, schema_unquoted, 'hackers_mv') == "MergeTree"
assert query_table_type(project, schema_unquoted, 'hackers_mv').endswith("MergeTree")
assert query_table_type(project, schema_unquoted, 'hackers_mv_mv') == "MaterializedView"

# Step 3: Change model to view materialization and run with full refresh
Expand All @@ -300,7 +301,7 @@ def test_mv_is_dropped_on_full_refresh(self, project):
# Step 4: Assert that target table is now a view and internal MV no longer exists
assert query_table_type(project, schema_unquoted, 'hackers_mv') == "View"
# Verify that the internal materialized view (_mv) no longer exists
assert query_table_type(project, schema_unquoted, 'hackers_mv_mv') is None
assert not query_table_type(project, schema_unquoted, 'hackers_mv_mv')

def test_view_full_refresh_does_not_affect_existing_mv_with_mv_suffix(self, project):
"""
Expand All @@ -321,7 +322,7 @@ def test_view_full_refresh_does_not_affect_existing_mv_with_mv_suffix(self, proj

# Verify both models were created correctly
assert query_table_type(project, schema_unquoted, 'hackers') == "View"
assert query_table_type(project, schema_unquoted, 'hackers_mv') == "MergeTree"
assert query_table_type(project, schema_unquoted, 'hackers_mv').endswith("MergeTree")
assert query_table_type(project, schema_unquoted, 'hackers_mv_mv') == "MaterializedView"

# Verify data is present in both
Expand All @@ -341,7 +342,7 @@ def test_view_full_refresh_does_not_affect_existing_mv_with_mv_suffix(self, proj
assert result[0][0] == 3

# Verify that hackers_mv and hackers_mv_mv are still present and working
assert query_table_type(project, schema_unquoted, 'hackers_mv') == "MergeTree"
assert query_table_type(project, schema_unquoted, 'hackers_mv').endswith("MergeTree")
assert query_table_type(project, schema_unquoted, 'hackers_mv_mv') == "MaterializedView"

result = project.run_sql(f"select count(*) from {schema_unquoted}.hackers_mv", fetch="all")
Expand Down
Loading