|
48 | 48 | import static org.apache.flink.cdc.connectors.postgres.source.PostgresDataSourceOptions.HOSTNAME; |
49 | 49 | import static org.apache.flink.cdc.connectors.postgres.source.PostgresDataSourceOptions.PASSWORD; |
50 | 50 | import static org.apache.flink.cdc.connectors.postgres.source.PostgresDataSourceOptions.PG_PORT; |
| 51 | +import static org.apache.flink.cdc.connectors.postgres.source.PostgresDataSourceOptions.SCAN_NEWLY_ADDED_TABLE_ENABLED; |
51 | 52 | import static org.apache.flink.cdc.connectors.postgres.source.PostgresDataSourceOptions.SLOT_NAME; |
52 | 53 | import static org.apache.flink.cdc.connectors.postgres.source.PostgresDataSourceOptions.TABLES; |
53 | 54 | import static org.apache.flink.cdc.connectors.postgres.source.PostgresDataSourceOptions.TABLES_EXCLUDE; |
@@ -97,6 +98,25 @@ public void testCreateDataSource() { |
97 | 98 | .isEqualTo(Arrays.asList("inventory.products")); |
98 | 99 | } |
99 | 100 |
|
| 101 | + @Test |
| 102 | + public void testScanNewlyAddedTableEnabled() { |
| 103 | + Map<String, String> options = new HashMap<>(); |
| 104 | + options.put(HOSTNAME.key(), POSTGRES_CONTAINER.getHost()); |
| 105 | + options.put( |
| 106 | + PG_PORT.key(), String.valueOf(POSTGRES_CONTAINER.getMappedPort(POSTGRESQL_PORT))); |
| 107 | + options.put(USERNAME.key(), TEST_USER); |
| 108 | + options.put(PASSWORD.key(), TEST_PASSWORD); |
| 109 | + options.put(TABLES.key(), POSTGRES_CONTAINER.getDatabaseName() + ".inventory.prod\\.*"); |
| 110 | + options.put(SLOT_NAME.key(), slotName); |
| 111 | + options.put(SCAN_NEWLY_ADDED_TABLE_ENABLED.key(), "true"); |
| 112 | + |
| 113 | + Factory.Context context = new MockContext(Configuration.fromMap(options)); |
| 114 | + PostgresDataSourceFactory factory = new PostgresDataSourceFactory(); |
| 115 | + PostgresDataSource dataSource = (PostgresDataSource) factory.createDataSource(context); |
| 116 | + |
| 117 | + assertThat(dataSource.getPostgresSourceConfig().isScanNewlyAddedTableEnabled()).isTrue(); |
| 118 | + } |
| 119 | + |
100 | 120 | @Test |
101 | 121 | public void testNoMatchedTable() { |
102 | 122 | Map<String, String> options = new HashMap<>(); |
|
0 commit comments