Skip to content

Commit 45e9efe

Browse files
committed
fixed ut test
1 parent b95b188 commit 45e9efe

File tree

2 files changed

+81
-2
lines changed

2 files changed

+81
-2
lines changed

flink-cdc-connect/flink-cdc-source-connectors/flink-connector-tidb-cdc/src/main/java/org/apache/flink/cdc/connectors/tidb/table/TiDBTableSource.java

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
import java.util.Collections;
4747
import java.util.List;
4848
import java.util.Map;
49+
import java.util.Objects;
4950
import java.util.Properties;
5051
import java.util.stream.Collectors;
5152
import java.util.stream.Stream;
@@ -293,4 +294,78 @@ private MetadataConverter[] getMetadataConverters() {
293294
.map(TiDBReadableMetadata::getConverter)
294295
.toArray(MetadataConverter[]::new);
295296
}
297+
298+
@Override
299+
public boolean equals(Object o) {
300+
if (this == o) {
301+
return true;
302+
}
303+
if (o == null || getClass() != o.getClass()) {
304+
return false;
305+
}
306+
TiDBTableSource that = (TiDBTableSource) o;
307+
return port == that.port
308+
&& enableParallelRead == that.enableParallelRead
309+
&& splitSize == that.splitSize
310+
&& splitMetaGroupSize == that.splitMetaGroupSize
311+
&& fetchSize == that.fetchSize
312+
&& connectionPoolSize == that.connectionPoolSize
313+
&& connectMaxRetries == that.connectMaxRetries
314+
&& Double.compare(that.distributionFactorUpper, distributionFactorUpper) == 0
315+
&& Double.compare(that.distributionFactorLower, distributionFactorLower) == 0
316+
&& physicalSchema.equals(that.physicalSchema)
317+
&& startupOptions.equals(that.startupOptions)
318+
&& Objects.equals(tableList, that.tableList)
319+
&& Objects.equals(tableName, that.tableName)
320+
&& Objects.equals(connectTimeout, that.connectTimeout)
321+
&& Objects.equals(jdbcDriver, that.jdbcDriver)
322+
&& Objects.equals(serverTimeZone, that.serverTimeZone)
323+
&& Objects.equals(pdAddresses, that.pdAddresses)
324+
&& Objects.equals(hostMapping, that.hostMapping)
325+
&& Objects.equals(hostName, that.hostName)
326+
&& Objects.equals(database, that.database)
327+
&& Objects.equals(username, that.username)
328+
&& Objects.equals(password, that.password)
329+
&& Objects.equals(heartbeatInterval, that.heartbeatInterval)
330+
&& Objects.equals(chunkKeyColumn, that.chunkKeyColumn)
331+
&& Objects.equals(chunkKeyColumns, that.chunkKeyColumns)
332+
&& Objects.equals(jdbcProperties, that.jdbcProperties)
333+
&& Objects.equals(options, that.options)
334+
&& Objects.equals(producedDataType, that.producedDataType)
335+
&& Objects.equals(metadataKeys, that.metadataKeys);
336+
}
337+
338+
@Override
339+
public int hashCode() {
340+
return Objects.hash(
341+
physicalSchema,
342+
startupOptions,
343+
tableList,
344+
tableName,
345+
connectTimeout,
346+
jdbcDriver,
347+
serverTimeZone,
348+
pdAddresses,
349+
hostMapping,
350+
port,
351+
hostName,
352+
database,
353+
username,
354+
password,
355+
heartbeatInterval,
356+
splitSize,
357+
splitMetaGroupSize,
358+
fetchSize,
359+
connectMaxRetries,
360+
connectionPoolSize,
361+
distributionFactorUpper,
362+
distributionFactorLower,
363+
chunkKeyColumn,
364+
chunkKeyColumns,
365+
jdbcProperties,
366+
options,
367+
enableParallelRead,
368+
producedDataType,
369+
metadataKeys);
370+
}
296371
}

flink-cdc-connect/flink-cdc-source-connectors/flink-connector-tidb-cdc/src/test/java/org/apache/flink/cdc/connectors/tidb/table/TiDBTableSourceFactoryTest.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,10 @@ public void testOptionalProperties() {
137137
properties.put("port", MY_PORT);
138138
properties.put("scan.startup.mode", "initial");
139139
properties.put("heartbeat.interval.ms", "15213ms");
140+
properties.put("debezium.tombstones.on.delete", "true");
141+
properties.put("debezium.snapshot.mode", "never");
142+
properties.put("debezium.offset.flush.interval.ms", "3000");
143+
properties.put("debezium.test", "test");
140144
// properties.put("server-time-zone", "Asia/Shanghai");
141145

142146
Properties dbzProperties = new Properties();
@@ -156,7 +160,7 @@ public void testOptionalProperties() {
156160
TiDBTableSource expectedSource =
157161
new TiDBTableSource(
158162
SCHEMA,
159-
4111,
163+
4000,
160164
MY_HOSTNAME,
161165
MY_DATABASE,
162166
MY_TABLE,
@@ -179,7 +183,7 @@ public void testOptionalProperties() {
179183
SPLIT_KEY_EVEN_DISTRIBUTION_FACTOR_UPPER_BOUND.defaultValue(),
180184
SPLIT_KEY_EVEN_DISTRIBUTION_FACTOR_LOWER_BOUND.defaultValue(),
181185
null,
182-
null,
186+
new HashMap<>(),
183187
JDBC_DRIVER.defaultValue(),
184188
StartupOptions.initial());
185189
Assertions.assertThat(expectedSource).isEqualTo(actualSource);

0 commit comments

Comments
 (0)