DBZ-1242 Fixed typo and added negative test checks

This commit is contained in:
Chris Cranford 2019-06-05 13:29:58 -04:00 committed by Chris Cranford
parent c53435c26b
commit 0aadaa10dc
7 changed files with 84 additions and 9 deletions

View File

@ -366,7 +366,7 @@ protected boolean performInitialSync() {
}
if (collections.isEmpty()) {
logger.warn("After applying blacklist/whitelist filters there is no tables to monitor, please check your configuration");
logger.warn("After applying blacklist/whitelist filters there are no tables to monitor, please check your configuration");
}
if (logger.isInfoEnabled()) {

View File

@ -308,8 +308,10 @@ public void shouldConsumeAllEventsFromDatabase() throws InterruptedException, IO
}
@Test
@FixFor("DBZ-865")
@FixFor("DBZ-865 and DBZ-1242")
public void shouldConsumeEventsFromCollectionWithReplacedTopicName() throws InterruptedException, IOException {
// This captures all logged messages, allowing us to verify log message was written.
final LogInterceptor logInterceptor = new LogInterceptor();
// Use the DB configuration to define the connector's configuration ...
config = TestHelper.getConfiguration().edit()
@ -356,7 +358,7 @@ public void shouldConsumeEventsFromCollectionWithReplacedTopicName() throws Inte
// ---------------------------------------------------------------------------------------------------------------
// Stop the connector
// ---------------------------------------------------------------------------------------------------------------
stopConnector();
stopConnector(value -> assertThat(logInterceptor.containsWarnMessage(NO_MONITORED_TABLES_WARNING)).isFalse());
}
@Test
@ -394,7 +396,7 @@ public void testEmptySchemaWarningAfterApplyingCollectionFilters() throws Except
// Consume all records
consumeRecordsByTopic(12);
stopConnector(value -> assertThat(logInterceptor.containsWarnMessage("After applying blacklist/whitelist filters there is no tables to monitor, please check your configuration")).isTrue());
stopConnector(value -> assertThat(logInterceptor.containsWarnMessage(NO_MONITORED_TABLES_WARNING)).isTrue());
}
protected void verifyFromInitialSync(SourceRecord record, AtomicBoolean foundLast) {

View File

@ -1750,7 +1750,24 @@ public void testEmptySchemaLogWarningWithDatabaseWhitelist() throws Exception {
consumeRecordsByTopic(12);
waitForAvailableRecords(100, TimeUnit.MILLISECONDS);
stopConnector(value -> assertThat(logInterceptor.containsWarnMessage("After applying blacklist/whitelist filters there is no tables to monitor, please check your configuration")).isTrue());
stopConnector(value -> assertThat(logInterceptor.containsWarnMessage(NO_MONITORED_TABLES_WARNING)).isTrue());
}
@Test
@FixFor("DBZ-1242")
public void testNoEmptySchemaLogWarningWithDatabaseWhitelist() throws Exception {
final LogInterceptor logInterceptor = new LogInterceptor();
config = DATABASE.defaultConfig()
.with(MySqlConnectorConfig.SNAPSHOT_MODE, SnapshotMode.INITIAL)
.build();
start(MySqlConnector.class, config);
consumeRecordsByTopic(12);
waitForAvailableRecords(100, TimeUnit.MILLISECONDS);
stopConnector(value -> assertThat(logInterceptor.containsWarnMessage(NO_MONITORED_TABLES_WARNING)).isFalse());
}
@Test
@ -1770,7 +1787,26 @@ public void testEmptySchemaWarningWithTableWhitelist() throws Exception {
consumeRecordsByTopic(12);
waitForAvailableRecords(100, TimeUnit.MILLISECONDS);
stopConnector(value -> assertThat(logInterceptor.containsWarnMessage("After applying blacklist/whitelist filters there is no tables to monitor, please check your configuration")).isTrue());
stopConnector(value -> assertThat(logInterceptor.containsWarnMessage(NO_MONITORED_TABLES_WARNING)).isTrue());
}
@Test
@FixFor("DBZ-1242")
public void testNoEmptySchemaWarningWithTableWhitelist() throws Exception {
// This captures all logged messages, allowing us to verify log message was written.
final LogInterceptor logInterceptor = new LogInterceptor();
config = DATABASE.defaultConfig()
.with(MySqlConnectorConfig.SNAPSHOT_MODE, MySqlConnectorConfig.SnapshotMode.INITIAL)
.build();
start(MySqlConnector.class, config);
assertConnectorIsRunning();
consumeRecordsByTopic(12);
waitForAvailableRecords(100, TimeUnit.MILLISECONDS);
stopConnector(value -> assertThat(logInterceptor.containsWarnMessage(NO_MONITORED_TABLES_WARNING)).isFalse());
}
private List<SourceRecord> recordsForTopicForRoProductsTable(SourceRecords records) {

View File

@ -861,7 +861,26 @@ public void testEmptySchemaWarningAfterApplyingFilters() throws Exception {
assertConnectorIsRunning();
waitForAvailableRecords(100, TimeUnit.MILLISECONDS);
stopConnector(value -> assertThat(logInterceptor.containsWarnMessage("After applying blacklist/whitelist filters there is no tables to monitor, please check your configuration")).isTrue());
stopConnector(value -> assertThat(logInterceptor.containsWarnMessage(NO_MONITORED_TABLES_WARNING)).isTrue());
}
@Test
@FixFor("DBZ-1242")
public void testNoEmptySchemaWarningAfterApplyingFilters() throws Exception {
// This captures all logged messages, allowing us to verify log message was written.
final LogInterceptor logInterceptor = new LogInterceptor();
TestHelper.dropAllSchemas();
TestHelper.executeDDL("postgres_create_tables.ddl");
Configuration.Builder configBuilder = TestHelper.defaultConfig()
.with(PostgresConnectorConfig.SNAPSHOT_MODE, SnapshotMode.INITIAL_ONLY.getValue());
start(PostgresConnector.class, configBuilder.build());
assertConnectorIsRunning();
waitForAvailableRecords(100, TimeUnit.MILLISECONDS);
stopConnector(value -> assertThat(logInterceptor.containsWarnMessage(NO_MONITORED_TABLES_WARNING)).isFalse());
}
private CompletableFuture<Void> batchInsertRecords(long recordsCount, int batchSize) {

View File

@ -697,7 +697,24 @@ public void testEmptySchemaWarningAfterApplyingFilters() throws Exception {
assertConnectorIsRunning();
waitForAvailableRecords(100, TimeUnit.MILLISECONDS);
stopConnector(value -> assertThat(logInterceptor.containsWarnMessage("After applying blacklist/whitelist filters there is no tables to monitor, please check your configuration")).isTrue());
stopConnector(value -> assertThat(logInterceptor.containsWarnMessage(NO_MONITORED_TABLES_WARNING)).isTrue());
}
@Test
@FixFor("DBZ-1242")
public void testNoEmptySchemaWarningAfterApplyingFilters() throws Exception {
// This captures all logged messages, allowing us to verify log message was written.
final LogInterceptor logInterceptor = new LogInterceptor();
Configuration config = TestHelper.defaultConfig()
.with(SqlServerConnectorConfig.SNAPSHOT_MODE, SnapshotMode.INITIAL)
.build();
start(SqlServerConnector.class, config);
assertConnectorIsRunning();
waitForAvailableRecords(100, TimeUnit.MILLISECONDS);
stopConnector(value -> assertThat(logInterceptor.containsWarnMessage(NO_MONITORED_TABLES_WARNING)).isFalse());
}
private void assertRecord(Struct record, List<SchemaAndValueField> expected) {

View File

@ -78,7 +78,7 @@ public Set<TableId> tableIds() {
public void assureNonEmptySchema() {
if (tableIds().isEmpty()) {
LOG.warn("After applying blacklist/whitelist filters there is no tables to monitor, please check your configuration");
LOG.warn("After applying blacklist/whitelist filters there are no tables to monitor, please check your configuration");
}
}

View File

@ -78,6 +78,7 @@ public abstract class AbstractConnectorTest implements Testing {
public TestRule skipTestRule = new SkipTestRule();
protected static final Path OFFSET_STORE_PATH = Testing.Files.createTestingPath("file-connector-offsets.txt").toAbsolutePath();
protected static final String NO_MONITORED_TABLES_WARNING = "After applying blacklist/whitelist filters there are no tables to monitor, please check your configuration";
private ExecutorService executor;
protected EmbeddedEngine engine;