DBZ-4475 Fix randomly failing updatePrimaryKeyTwiceWithRestartInMiddleOfTx

Fix randomly failing
SqlServerConnectorIT#updatePrimaryKeyTwiceWithRestartInMiddleOfTx

Wait for snapshot to be complteted and consume expected number of
records.
This commit is contained in:
Vojtech Juranek 2022-09-23 14:17:11 +02:00 committed by Jiri Pechanec
parent f6264fb8ca
commit 63167469c2

View File

@ -639,7 +639,9 @@ public void updatePrimaryKeyTwiceWithRestartInMiddleOfTx() throws Exception {
}); });
assertConnectorIsRunning(); assertConnectorIsRunning();
consumeRecordsByTopic(1); TestHelper.waitForDatabaseSnapshotToBeCompleted(TestHelper.TEST_DATABASE_1);
final SourceRecords snapshotRecords = consumeRecordsByTopic(1);
Assertions.assertThat(snapshotRecords.allRecordsInOrder()).hasSize(1);
connection.setAutoCommit(false); connection.setAutoCommit(false);
@ -659,12 +661,14 @@ public void updatePrimaryKeyTwiceWithRestartInMiddleOfTx() throws Exception {
start(SqlServerConnector.class, config); start(SqlServerConnector.class, config);
assertConnectorIsRunning(); assertConnectorIsRunning();
final SourceRecords records2 = consumeRecordsByTopic(6);
final int expectedRecords = 20;
final SourceRecords records2 = consumeRecordsByTopic(expectedRecords - records1.allRecordsInOrder().size());
final List<SourceRecord> tableB = records1.recordsForTopic("server1.testDB1.dbo.tableb"); final List<SourceRecord> tableB = records1.recordsForTopic("server1.testDB1.dbo.tableb");
tableB.addAll(records2.recordsForTopic("server1.testDB1.dbo.tableb")); tableB.addAll(records2.recordsForTopic("server1.testDB1.dbo.tableb"));
Assertions.assertThat(tableB).hasSize(20); Assertions.assertThat(tableB).hasSize(expectedRecords);
stopConnector(); stopConnector();
} }