Skip to content
This repository was archived by the owner on May 17, 2024. It is now read-only.

Commit cc12659

Browse files
committed
Split tests into FULL_TESTS and regular
1 parent abf3d51 commit cc12659

File tree

6 files changed

+59
-5
lines changed

6 files changed

+59
-5
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ jobs:
4646
env:
4747
DATADIFF_SNOWFLAKE_URI: '${{ secrets.DATADIFF_SNOWFLAKE_URI }}'
4848
DATADIFF_PRESTO_URI: '${{ secrets.DATADIFF_PRESTO_URI }}'
49+
DATADIFF_TRINO_URI: '${{ secrets.DATADIFF_TRINO_URI }}'
4950
DATADIFF_CLICKHOUSE_URI: 'clickhouse://clickhouse:Password1@localhost:9000/clickhouse'
5051
DATADIFF_VERTICA_URI: 'vertica://vertica:Password1@localhost:5433/vertica'
5152
run: |

.github/workflows/ci_full.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
paths:
6+
- '**.py'
7+
- '.github/workflows/**'
8+
- '!dev/**'
9+
pull_request:
10+
branches: [ master ]
11+
12+
workflow_dispatch:
13+
14+
jobs:
15+
unit_tests:
16+
strategy:
17+
fail-fast: false
18+
matrix:
19+
os: [ubuntu-latest]
20+
python-version:
21+
- "3.10"
22+
23+
name: Check Python ${{ matrix.python-version }} on ${{ matrix.os }}
24+
runs-on: ${{ matrix.os }}
25+
steps:
26+
- uses: actions/checkout@v3
27+
28+
- name: Setup Python ${{ matrix.python-version }}
29+
uses: actions/setup-python@v3
30+
with:
31+
python-version: ${{ matrix.python-version }}
32+
33+
- name: Build the stack
34+
run: docker-compose up -d mysql postgres presto trino clickhouse vertica
35+
36+
- name: Install Poetry
37+
run: pip install poetry
38+
39+
- name: Install package
40+
run: "poetry install"
41+
42+
- name: Run unit tests
43+
env:
44+
DATADIFF_SNOWFLAKE_URI: '${{ secrets.DATADIFF_SNOWFLAKE_URI }}'
45+
DATADIFF_PRESTO_URI: '${{ secrets.DATADIFF_PRESTO_URI }}'
46+
DATADIFF_CLICKHOUSE_URI: 'clickhouse://clickhouse:Password1@localhost:9000/clickhouse'
47+
DATADIFF_VERTICA_URI: 'vertica://vertica:Password1@localhost:5433/vertica'
48+
run: |
49+
chmod +x tests/waiting_for_stack_up.sh
50+
./tests/waiting_for_stack_up.sh && FULL_TESTS=1 poetry run unittest-parallel -j 16

data_diff/databases/clickhouse.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ class Dialect(BaseDialect):
5555
"DateTime64": Timestamp,
5656
}
5757

58-
5958
def normalize_number(self, value: str, coltype: FractionalType) -> str:
6059
# If a decimal value has trailing zeros in a fractional part, when casting to string they are dropped.
6160
# For example:

data_diff/databases/oracle.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,7 @@ def parse_type(
127127
precision = int(m.group(1))
128128
return t_cls(precision=precision, rounds=self.ROUNDS_ON_PREC_LOSS)
129129

130-
return super().parse_type(
131-
table_path, col_name, type_repr, datetime_precision, numeric_precision, numeric_scale
132-
)
130+
return super().parse_type(table_path, col_name, type_repr, datetime_precision, numeric_precision, numeric_scale)
133131

134132

135133
class Oracle(ThreadedDatabase):

tests/common.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
N_SAMPLES = int(os.environ.get("N_SAMPLES", DEFAULT_N_SAMPLES))
3737
BENCHMARK = os.environ.get("BENCHMARK", False)
3838
N_THREADS = int(os.environ.get("N_THREADS", 1))
39+
FULL_TESTS = bool(os.environ.get("FULL_TESTS", False)) # Should we run the full db<->db test suite?
3940

4041

4142
def get_git_revision_short_hash() -> str:
@@ -94,6 +95,8 @@ def _print_used_dbs():
9495
logging.info(f"Testing databases: {', '.join(used)}")
9596
if unused:
9697
logging.info(f"Connection not configured; skipping tests for: {', '.join(unused)}")
98+
if FULL_TESTS:
99+
logging.info("Full tests enabled (every db<->db). May take very long when many dbs are involved.")
97100

98101

99102
_print_used_dbs()

tests/test_database_types.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
N_THREADS,
2626
BENCHMARK,
2727
GIT_REVISION,
28+
FULL_TESTS,
2829
get_conn,
2930
random_table_suffix,
3031
)
@@ -418,6 +419,7 @@ def __iter__(self):
418419
"uuid": UUID_Faker(N_SAMPLES),
419420
}
420421

422+
421423
def _get_test_db_pairs(full):
422424
if full:
423425
for source_db in DATABASE_TYPES:
@@ -430,14 +432,15 @@ def _get_test_db_pairs(full):
430432
yield db_cls, db.Snowflake
431433
yield db.Snowflake, db_cls
432434

435+
433436
def get_test_db_pairs(full=True):
434437
active_pairs = {(db1, db2) for db1, db2 in _get_test_db_pairs(full) if db1 in CONN_STRINGS and db2 in CONN_STRINGS}
435438
for db1, db2 in active_pairs:
436439
yield db1, DATABASE_TYPES[db1], db2, DATABASE_TYPES[db2]
437440

438441

439442
type_pairs = []
440-
for source_db, source_type_categories, target_db, target_type_categories in get_test_db_pairs():
443+
for source_db, source_type_categories, target_db, target_type_categories in get_test_db_pairs(FULL_TESTS):
441444
for type_category, source_types in source_type_categories.items(): # int, datetime, ..
442445
for source_type in source_types:
443446
for target_type in target_type_categories[type_category]:

0 commit comments

Comments
 (0)