Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
/**
* Integration test to validate support for replication of multiple databases.
*/
@Disabled
@Testcontainers
@DisplayName("Integration Test that validates basic replication of MariaDB databases in single threaded mode")
public class MariaDBIT
Expand Down Expand Up @@ -125,7 +124,7 @@
// Create connection to clickhouse and validate if the tables are replicated.
BaseDbWriter writer = ITCommon.getDBWriter(clickHouseContainer);

ResultSet rs = ITCommon.executeQueryWithResultSet("SELECT * FROM employees.audience", writer.getConnection());

Check failure on line 127 in sink-connector-lightweight/src/test/java/com/altinity/clickhouse/debezium/embedded/MariaDBIT.java

View workflow job for this annotation

GitHub Actions / JUnit Test Report

MariaDBIT.testMultipleDatabases

Code: 60. DB::Exception: Unknown table expression identifier 'employees.audience' in scope SELECT * FROM employees.audience. (UNKNOWN_TABLE) (version 25.3.2.39 (official build))
Raw output
java.sql.BatchUpdateException: 
Code: 60. DB::Exception: Unknown table expression identifier 'employees.audience' in scope SELECT * FROM employees.audience. (UNKNOWN_TABLE) (version 25.3.2.39 (official build))

	at com.altinity.clickhouse.debezium.embedded.MariaDBIT.testMultipleDatabases(MariaDBIT.java:127)
// Validate the data
boolean recordFound = false;
while(rs.next()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@
}

@Test
@Disabled
public void testRestClient() throws Exception {

Injector injector = Guice.createInjector(new AppInjector());
Expand Down Expand Up @@ -105,7 +104,7 @@
HttpEntity entity = httpResponse.getEntity();
if(entity != null) {
String json = EntityUtils.toString(entity);
Assert.assertTrue(json.contains("Replica_Running"));

Check failure on line 107 in sink-connector-lightweight/src/test/java/com/altinity/clickhouse/debezium/embedded/client/SinkConnectorClientRestAPITest.java

View workflow job for this annotation

GitHub Actions / JUnit Test Report

SinkConnectorClientRestAPITest.testRestClient

java.lang.AssertionError at com.altinity.clickhouse.debezium.embedded.client.SinkConnectorClientRestAPITest.testRestClient(SinkConnectorClientRestAPITest.java:107)
Raw output
java.lang.AssertionError
	at com.altinity.clickhouse.debezium.embedded.client.SinkConnectorClientRestAPITest.testRestClient(SinkConnectorClientRestAPITest.java:107)
Assert.assertTrue(json.contains("Database"));
Assert.assertTrue(json.contains("Seconds_Behind_Source"));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -974,6 +974,7 @@
Assert.assertTrue(clickHouseQuery2.toString().equalsIgnoreCase("CREATE TABLE employees.`_j_failed_s_g`(id Nullable(Int32),`_version` UInt64,`is_deleted` UInt8) Engine=ReplacingMergeTree(_version,is_deleted) ORDER BY id"));
}

@Test
public void testCreateDefiner() {
String sql = "CREATE DEFINER=`bcadmin`@`%` PROCEDURE `sp_next_available_otc_instance_strategy_id`()\n" +
"begin\n" +
Expand All @@ -992,6 +993,70 @@
Assert.assertTrue(clickHouseQuery.toString().equalsIgnoreCase(""));
}

@Test
public void testCreateDefinerWithTrigger() {
String sql = "CREATE DEFINER=`bcadmin`@`%` TRIGGER host_id_constraint BEFORE INSERT ON host\n" +
"FOR EACH ROW\n" +
"BEGIN\n" +
" declare next_id int;\n" +
" declare max_id int;\n" +
" declare error_msg varchar(100);\n" +
" declare current_trade_date date;\n" +
" set max_id = power(2, 9)-1;\n" +
" set next_id = null;\n" +
" select tradeDate() into current_trade_date;\n" +
" IF (NEW.validFromDate <= '2000-01-01') THEN\n" +
" set NEW.validFromDate = current_trade_date;\n" +
" END IF;\n" +
" IF (NEW.name in (select name from host where name = NEW.name and (validFromDate <= NEW.validFromDate) and (validToDate > NEW.validFromDate or validToDate is null))) THEN\n" +
" SET @message_text = concat('cannot create new dated entry for name: ', NEW.name, ', as host already has a valid entry for this date range');\n" +
" signal sqlstate '45000' set MESSAGE_TEXT = @message_text;\n" +
" ELSEIF (!isnull(NEW.validToDate) and NEW.name in (select name from host where name = NEW.name and (validFromDate <= NEW.validToDate) and (validToDate > NEW.validFromDate or validToDate is null))) THEN\n" +
" SET @message_text = concat('cannot create new dated entry for name: ', NEW.name, ', as date range overlaps');\n" +
" signal sqlstate '45000' set MESSAGE_TEXT = @message_text;\n" +
" ELSEIF (isnull(NEW.validToDate) and NEW.name in (select name from host where name = NEW.name and validToDate is null)) THEN\n" +
" SET @message_text = concat('cannot create new dated entry for name: ', NEW.name, ', as host already has a valid current entry');\n" +
" signal sqlstate '45000' set MESSAGE_TEXT = @message_text;\n" +
" END IF;\n" +
" IF (NEW.id in (select id from host where id = NEW.id and (validFromDate <= NEW.validFromDate) and (validToDate > NEW.validFromDate or validToDate is null))) THEN\n" +
" SET @message_text = concat('cannot create new dated entry for id: ', NEW.id, ', as host already has a valid entry for this date range');\n" +
" signal sqlstate '45000' set MESSAGE_TEXT = @message_text;\n" +
" ELSEIF (!isnull(NEW.validToDate) and NEW.id in (select id from host where id = NEW.id and (validFromDate <= NEW.validToDate) and (validToDate > NEW.validFromDate or validToDate is null))) THEN\n" +
" SET @message_text = concat('cannot create new dated entry for id: ', NEW.id, ', as date range overlaps');\n" +
" signal sqlstate '45000' set MESSAGE_TEXT = @message_text;\n" +
" ELSEIF (isnull(NEW.validToDate) and NEW.id in (select id from host where id = NEW.id and validToDate is null)) THEN\n" +
" SET @message_text = concat('cannot create new dated entry for id: ', NEW.id, ', as host already has a valid current entry');\n" +
" signal sqlstate '45000' set MESSAGE_TEXT = @message_text;\n" +
" END IF;\n" +
" select min(st.value) into next_id\n" +
" from SEQUENCE_TABLE(max_id+1) st\n" +
" left join host h on h.id=st.value\n" +
" where st.value > 0\n" +
" and h.id is null;\n" +
" IF isnull(next_id) THEN\n" +
" select t1.id into next_id from (select id from host where id = NEW.id and id not in (select id from host where id = NEW.id and (validFromDate <= NEW.validFromDate) and (validToDate > NEW.validFromDate or validToDate is null))) as t1;\n" +
" END IF;\n" +
" IF isnull(next_id) THEN\n" +
" select t1.id into next_id from (select id, max(validToDate) as validToDate from host where id not in (select id from host where validToDate is NULL or NEW.validFromDate < validToDate) group by id order by validToDate, id limit 0, 1) as t1;\n" +
" END IF;\n" +
" IF isnull(next_id) THEN\n" +
" set error_msg = concat('no free ids in range [1, ', cast(max_id as char), ']');\n" +
" signal sqlstate '45000' set MESSAGE_TEXT = error_msg;\n" +
" END IF;\n" +
" IF next_id > max_id THEN\n" +
" set error_msg = concat('next id too high to insert: next_id=', cast(next_id as char), ' max_id=', cast(max_id as char));\n" +
" signal sqlstate '45000' set MESSAGE_TEXT = error_msg;\n" +
" END IF;\n" +
" set NEW.id = next_id;\n" +
"END\n" +
"/*!*/;";

StringBuffer clickHouseQuery = new StringBuffer();
mySQLDDLParserService.parseSql(sql, "employees", clickHouseQuery);

Check failure on line 1055 in sink-connector-lightweight/src/test/java/com/altinity/clickhouse/debezium/embedded/ddl/parser/MySqlDDLParserListenerImplTest.java

View workflow job for this annotation

GitHub Actions / JUnit Test Report

MySqlDDLParserListenerImplTest.testCreateDefinerWithTrigger

Error parsing DDL
Raw output
java.lang.RuntimeException: Error parsing DDL
	at com.altinity.clickhouse.debezium.embedded.ddl.parser.MySqlDDLParserListenerImplTest.testCreateDefinerWithTrigger(MySqlDDLParserListenerImplTest.java:1055)

// Just validates that the debezium parsor does not throw an error
Assert.assertTrue(clickHouseQuery.toString().equalsIgnoreCase(""));
}
@Test
public void testCreateTableWithPartitionByRange() {

Expand Down
Loading