Skip to content

Commit 75f2ee3

Browse files
authored
Merge pull request #684 from Altinity/new_tests
New tests for TestFlows that incldue coverage for the new release
2 parents ba961f9 + 98312c0 commit 75f2ee3

File tree

16 files changed

+766
-154
lines changed

16 files changed

+766
-154
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Configuration status="INFO">
3+
<Appenders>
4+
<Console name="console" target="SYSTEM_OUT">
5+
<!-- <JSONLayout compact="true" eventEol="true" properties="true" stacktraceAsString="true" includeTimeMillis="true" />-->
6+
7+
<PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss.SSS} %-5level - %msg%n"/>
8+
</Console>
9+
</Appenders>
10+
<Loggers>
11+
<!-- <Logger name="org.slf4j" level="DEBUG"
12+
additivity="false">
13+
<AppenderRef ref="console"/>
14+
</Logger>-->
15+
<Logger name="com.clickhouse" level="ERROR"
16+
additivity="false">
17+
<AppenderRef ref="console"/>
18+
</Logger>
19+
20+
<Root level="info" additivity="false">
21+
<AppenderRef ref="console" />
22+
</Root>
23+
</Loggers>
24+
</Configuration>
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Configuration status="INFO">
3+
<Appenders>
4+
<Console name="console" target="SYSTEM_OUT">
5+
<!-- <JSONLayout compact="true" eventEol="true" properties="true" stacktraceAsString="true" includeTimeMillis="true" />-->
6+
7+
<PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss.SSS} %-5level - %msg%n"/>
8+
</Console>
9+
</Appenders>
10+
<Loggers>
11+
<!-- <Logger name="org.slf4j" level="DEBUG"
12+
additivity="false">
13+
<AppenderRef ref="console"/>
14+
</Logger>-->
15+
<Logger name="com.clickhouse" level="ERROR"
16+
additivity="false">
17+
<AppenderRef ref="console"/>
18+
</Logger>
19+
20+
<Root level="info" additivity="false">
21+
<AppenderRef ref="console" />
22+
</Root>
23+
</Loggers>
24+
</Configuration>

sink-connector-lightweight/tests/integration/helpers/cluster.py

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -596,15 +596,14 @@ def up(self, timeout=30 * 60):
596596
"IMAGE_DEPENDENCY_PROXY", ""
597597
)
598598
self.environ["COMPOSE_HTTP_TIMEOUT"] = "300"
599-
self.environ["CLICKHOUSE_TESTS_SERVER_BIN_PATH"] = (
600-
self.clickhouse_binary_path
601-
)
602-
self.environ["CLICKHOUSE_TESTS_ODBC_BRIDGE_BIN_PATH"] = (
603-
self.clickhouse_odbc_bridge_binary_path
604-
or os.path.join(
605-
os.path.dirname(self.clickhouse_binary_path),
606-
"clickhouse-odbc-bridge",
607-
)
599+
self.environ[
600+
"CLICKHOUSE_TESTS_SERVER_BIN_PATH"
601+
] = self.clickhouse_binary_path
602+
self.environ[
603+
"CLICKHOUSE_TESTS_ODBC_BRIDGE_BIN_PATH"
604+
] = self.clickhouse_odbc_bridge_binary_path or os.path.join(
605+
os.path.dirname(self.clickhouse_binary_path),
606+
"clickhouse-odbc-bridge",
608607
)
609608
self.environ["CLICKHOUSE_TESTS_DIR"] = self.configs_dir
610609

@@ -890,6 +889,10 @@ def query(
890889
if raise_on_exception:
891890
raise QueryRuntimeException(r.output)
892891
assert False, error(r.output)
892+
elif "ERROR" in r.output:
893+
if raise_on_exception:
894+
raise QueryRuntimeException(r.output)
895+
assert False, error(r.output)
893896

894897
return r
895898

@@ -970,16 +973,23 @@ def parse_value(input_string):
970973
else:
971974
raise ValueError(f"Failed to parse value from string: {input_string}")
972975

973-
def start_sink_connector(self, timeout=300, config_file=None):
976+
def start_sink_connector(self, timeout=300, config_file=None, log_file=None):
974977
"""Start ClickHouse Sink Connector."""
975978
if config_file is None:
976979
config_file = "config.yml"
977980

978981
config_file = config_file.rsplit("/", 1)[-1]
979982

980983
with Given("I start ClickHouse Sink Connector"):
984+
command = f"java -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005 -Xms4g -Xmx4g "
985+
986+
if log_file is None:
987+
log_file = "log4j2.xml"
988+
989+
command += f"-Dlog4j2.configurationFile={log_file} -jar /app.jar /configs/{config_file} com.altinity.clickhouse.debezium.embedded.ClickHouseDebeziumEmbeddedApplication >> /logs/sink-connector-lt.log 2>&1 &"
990+
981991
start_command = self.command(
982-
command=f"java -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005 -jar /app.jar /configs/{config_file} com.altinity.clickhouse.debezium.embedded.ClickHouseDebeziumEmbeddedApplication > /logs/sink-connector-lt.log 2>&1 &",
992+
command=command,
983993
exitcode=0,
984994
timeout=timeout,
985995
)

sink-connector-lightweight/tests/integration/helpers/create_config.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ def update(self, new_data):
2626

2727
def remove(self, key):
2828
"""Remove the ClickHouse Sink Connector configuration key."""
29-
self.data.pop(key)
29+
if key in self.data:
30+
self.data.pop(key)
3031

3132
def display_config(self):
3233
"""Print out the ClickHouse Sink Connector configuration."""

sink-connector-lightweight/tests/integration/helpers/default_config.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,10 @@
77
"database.user": "root",
88
"database.password": "root",
99
"database.server.name": "ER54",
10-
"database.include.list": "test",
1110
"clickhouse.server.url": "clickhouse",
1211
"clickhouse.server.user": "root",
1312
"clickhouse.server.password": "root",
1413
"clickhouse.server.port": "8123",
15-
"clickhouse.server.database": "test",
1614
"database.allowPublicKeyRetrieval": "true",
1715
"snapshot.mode": "initial",
1816
"offset.flush.interval.ms": "5000",

sink-connector-lightweight/tests/integration/regression_auto.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,15 @@
123123
),
124124
"/mysql to clickhouse replication/auto table creation/schema only/*": (
125125
Skip,
126-
"Seems to be broken in CI/CD. need oto fix.",
126+
"Seems to be broken in CI/CD. need to fix.",
127127
),
128128
"/mysql to clickhouse replication/auto table creation/cli/*": (
129129
Skip,
130-
"Seems to be broken in CI/CD. need oto fix.",
130+
"Seems to be broken in CI/CD. need to fix.",
131+
),
132+
"/mysql to clickhouse replication/auto table creation/parallel alters/multiple parallel add modify drop column": (
133+
Skip,
134+
"Test requires fixing.",
131135
),
132136
}
133137

sink-connector-lightweight/tests/integration/regression_auto_replicated.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,11 +127,15 @@
127127
),
128128
"/mysql to clickhouse replication/auto replicated table creation/schema only/*": (
129129
Skip,
130-
"Seems to be broken in CI/CD. need oto fix.",
130+
"Seems to be broken in CI/CD. need to fix.",
131131
),
132132
"/mysql to clickhouse replication/auto replicated table creation/cli/*": (
133133
Skip,
134-
"Seems to be broken in CI/CD. need oto fix.",
134+
"Seems to be broken in CI/CD. need to fix.",
135+
),
136+
"/mysql to clickhouse replication/auto replicated table creation/parallel alters/multiple parallel add modify drop column": (
137+
Skip,
138+
"Test requires fixing.",
135139
),
136140
}
137141

@@ -303,6 +307,7 @@ def regression(
303307

304308
join()
305309

310+
Feature(run=load("tests.databases", "module"))
306311
Feature(
307312
run=load("tests.schema_only", "module"),
308313
)

sink-connector-lightweight/tests/integration/requirements/requirements.md

Lines changed: 82 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,8 @@
190190
* 28 [Column Names](#column-names)
191191
* 28.1 [Replicate Tables With Special Column Names](#replicate-tables-with-special-column-names)
192192
* 28.1.1 [RQ.SRS-030.ClickHouse.MySQLToClickHouseReplication.ColumnNames.Special](#rqsrs-030clickhousemysqltoclickhousereplicationcolumnnamesspecial)
193+
* 28.2 [Replicate Tables With Backticks in Column Names](#replicate-tables-with-backticks-in-column-names)
194+
* 28.2.1 [RQ.SRS-030.ClickHouse.MySQLToClickHouseReplication.ColumnNames.Backticks](#rqsrs-030clickhousemysqltoclickhousereplicationcolumnnamesbackticks)
193195
* 29 [Replication Interruption](#replication-interruption)
194196
* 29.1 [Retry Replication When ClickHouse Instance Is Not Active](#retry-replication-when-clickhouse-instance-is-not-active)
195197
* 29.1.1 [RQ.SRS-030.ClickHouse.MySQLToClickHouseReplication.Interruption.ClickHouse.Instance.Stopped](#rqsrs-030clickhousemysqltoclickhousereplicationinterruptionclickhouseinstancestopped)
@@ -273,17 +275,21 @@
273275
* 34.4.1.1 [RQ.SRS-030.ClickHouse.MySQLToClickHouseReplication.MultipleDatabases.ConfigValues.IncludeList](#rqsrs-030clickhousemysqltoclickhousereplicationmultipledatabasesconfigvaluesincludelist)
274276
* 34.4.2 [Replicate All Databases](#replicate-all-databases)
275277
* 34.4.2.1 [RQ.SRS-030.ClickHouse.MySQLToClickHouseReplication.MultipleDatabases.ConfigValues.ReplicateAll](#rqsrs-030clickhousemysqltoclickhousereplicationmultipledatabasesconfigvaluesreplicateall)
276-
* 34.5 [Table Operations](#table-operations)
277-
* 34.5.1 [Specify Database Name in Table Operations](#specify-database-name-in-table-operations)
278-
* 34.5.1.1 [RQ.SRS-030.ClickHouse.MySQLToClickHouseReplication.MultipleDatabases.TableOperations.SpecifyDatabaseName](#rqsrs-030clickhousemysqltoclickhousereplicationmultipledatabasestableoperationsspecifydatabasename)
279-
* 34.5.2 [Table Operations Without Specifying Database Name](#table-operations-without-specifying-database-name)
280-
* 34.5.2.1 [RQ.SRS-030.ClickHouse.MySQLToClickHouseReplication.MultipleDatabases.TableOperations.NoSpecifyDatabaseName](#rqsrs-030clickhousemysqltoclickhousereplicationmultipledatabasestableoperationsnospecifydatabasename)
281-
* 34.6 [Error Handling](#error-handling)
282-
* 34.6.1 [When Replicated Database Does Not Exist on the Destination](#when-replicated-database-does-not-exist-on-the-destination)
283-
* 34.6.1.1 [RQ.SRS-030.ClickHouse.MySQLToClickHouseReplication.MultipleDatabases.ErrorHandling.DatabaseNotExist](#rqsrs-030clickhousemysqltoclickhousereplicationmultipledatabaseserrorhandlingdatabasenotexist)
284-
* 34.7 [Concurrent Actions](#concurrent-actions)
285-
* 34.7.1 [Perform Table Operations on Each Database Concurrently](#perform-table-operations-on-each-database-concurrently)
286-
* 34.7.1.1 [RQ.SRS-030.ClickHouse.MySQLToClickHouseReplication.MultipleDatabases.ConcurrentActions](#rqsrs-030clickhousemysqltoclickhousereplicationmultipledatabasesconcurrentactions)
278+
* 34.5 [Overriding Source To Destination Database Name Mapping](#overriding-source-to-destination-database-name-mapping)
279+
* 34.5.1 [RQ.SRS-030.ClickHouse.MySQLToClickHouseReplication.MultipleDatabases.ConfigValues.OverrideMap](#rqsrs-030clickhousemysqltoclickhousereplicationmultipledatabasesconfigvaluesoverridemap)
280+
* 34.5.2 [Multiple Database Names](#multiple-database-names)
281+
* 34.5.2.1 [RQ.SRS-030.ClickHouse.MySQLToClickHouseReplication.MultipleDatabases.ConfigValues.OverrideMap.MultipleValues](#rqsrs-030clickhousemysqltoclickhousereplicationmultipledatabasesconfigvaluesoverridemapmultiplevalues)
282+
* 34.6 [Table Operations](#table-operations)
283+
* 34.6.1 [Specify Database Name in Table Operations](#specify-database-name-in-table-operations)
284+
* 34.6.1.1 [RQ.SRS-030.ClickHouse.MySQLToClickHouseReplication.MultipleDatabases.TableOperations.SpecifyDatabaseName](#rqsrs-030clickhousemysqltoclickhousereplicationmultipledatabasestableoperationsspecifydatabasename)
285+
* 34.6.2 [Table Operations Without Specifying Database Name](#table-operations-without-specifying-database-name)
286+
* 34.6.2.1 [RQ.SRS-030.ClickHouse.MySQLToClickHouseReplication.MultipleDatabases.TableOperations.NoSpecifyDatabaseName](#rqsrs-030clickhousemysqltoclickhousereplicationmultipledatabasestableoperationsnospecifydatabasename)
287+
* 34.7 [Error Handling](#error-handling)
288+
* 34.7.1 [When Replicated Database Does Not Exist on the Destination](#when-replicated-database-does-not-exist-on-the-destination)
289+
* 34.7.1.1 [RQ.SRS-030.ClickHouse.MySQLToClickHouseReplication.MultipleDatabases.ErrorHandling.DatabaseNotExist](#rqsrs-030clickhousemysqltoclickhousereplicationmultipledatabaseserrorhandlingdatabasenotexist)
290+
* 34.8 [Concurrent Actions](#concurrent-actions)
291+
* 34.8.1 [Perform Table Operations on Each Database Concurrently](#perform-table-operations-on-each-database-concurrently)
292+
* 34.8.1.1 [RQ.SRS-030.ClickHouse.MySQLToClickHouseReplication.MultipleDatabases.ConcurrentActions](#rqsrs-030clickhousemysqltoclickhousereplicationmultipledatabasesconcurrentactions)
287293

288294
## Introduction
289295

@@ -1458,6 +1464,21 @@ CREATE TABLE new_table(col1 VARCHAR(255), col2 INT, is_deleted INT)
14581464

14591465
The `ReplacingMergeTree` table created on ClickHouse side SHALL be updated and the `is_deleted` column should be renamed to `_is_deleted` so there are no column name conflicts between ClickHouse and source table.
14601466

1467+
### Replicate Tables With Backticks in Column Names
1468+
1469+
#### RQ.SRS-030.ClickHouse.MySQLToClickHouseReplication.ColumnNames.Backticks
1470+
version: 1.0
1471+
1472+
[Altinity Sink Connector] SHALL support replication from the source tables that have backticks in column names.
1473+
1474+
For example,
1475+
1476+
If we create a source table that contains the column with the `is_deleted` name,
1477+
1478+
```sql
1479+
CREATE TABLE new_table(col1 VARCHAR(255), `col2` INT, `is_deleted` INT)
1480+
```
1481+
14611482
## Replication Interruption
14621483

14631484
### Retry Replication When ClickHouse Instance Is Not Active
@@ -1796,10 +1817,12 @@ Multiple Databases:
17961817
actions:
17971818
- Perform table operations on each database sequentially
17981819
- Perform table operations on all databases simultaneously
1820+
- Create database on source and map it to the database with different name on destination
17991821
- Remove database
18001822
configValues:
1801-
- database.include.list: database1, database2, ... , databaseN
18021823
- Don't specify database.include.list
1824+
- database.include.list: database1, database2, ... , databaseN
1825+
- clickhouse.database.override.map: "test:test2, products:products2"
18031826
TableOperations:
18041827
- types:
18051828
- With database name
@@ -1937,6 +1960,53 @@ version: 1.0
19371960

19381961
[Altinity Sink Connector] SHALL support the ability to monitor all databases from the source and replicate them to the destination without specifying the `database.include.list` configuration value.
19391962

1963+
### Overriding Source To Destination Database Name Mapping
1964+
1965+
#### RQ.SRS-030.ClickHouse.MySQLToClickHouseReplication.MultipleDatabases.ConfigValues.OverrideMap
1966+
version: 1.0
1967+
1968+
[Altinity Sink Connector] SHALL support the usage of the `clickhouse.database.override.map` configuration value to allow the user to replicate the data from the source database to the destination database with a different name.
1969+
1970+
For example, when using the following value in configuration,
1971+
1972+
```yaml
1973+
clickhouse.database.override.map: "mysql1:ch1"
1974+
```
1975+
1976+
The source database `mysql1` SHALL be mapped to the destination database `ch1`, and the data from the source `mysql1` SHALL only be replicated to the destination database `ch1`.
1977+
1978+
```mermaid
1979+
flowchart TD
1980+
B[Read clickhouse.database.override.map] --> D[Identify Source Database mysql1]
1981+
D --> E[Map to Destination Database ch1]
1982+
E --> F[Replicate Data to ch1]
1983+
```
1984+
1985+
#### Multiple Database Names
1986+
1987+
##### RQ.SRS-030.ClickHouse.MySQLToClickHouseReplication.MultipleDatabases.ConfigValues.OverrideMap.MultipleValues
1988+
version: 1.0
1989+
1990+
[Altinity Sink Connector] SHALL support the usage of the `clickhouse.database.override.map` configuration value to map multiple source databases to different databases on the destination.
1991+
1992+
For example, when using the following value in configuration,
1993+
1994+
```yaml
1995+
clickhouse.database.override.map: "mysql1:ch1, mysql2:ch2"
1996+
```
1997+
1998+
The source databases `mysql1` and `mysql2` SHALL be mapped to the destination databases `ch1` and `ch2`, and the data from these source databases SHALL only be replicated to the destination databases `ch1` and `ch2`.
1999+
2000+
```mermaid
2001+
flowchart TD
2002+
B[Read clickhouse.database.override.map]
2003+
B --> C[Parse Override Map]
2004+
C --> E[Map mysql1 to ch1]
2005+
C --> F[Map mysql2 to ch2]
2006+
E --> G[Replicate Data from mysql1 to ch1]
2007+
F --> H[Replicate Data from mysql2 to ch2]
2008+
```
2009+
19402010
### Table Operations
19412011

19422012
#### Specify Database Name in Table Operations

0 commit comments

Comments
 (0)