DBZ-5307 Fix adding events from WireMock
In existing test we added all events in the loop which can lead into adding one event multiple times and therefore failing the tests. When test run alone, this probably never happen or it was very rare. Now, when test runs with Debezium server already running, it fails more often. Fix it by removing already added events from WireMock.
This commit is contained in:
parent
37d6d3685b
commit
e70ceeeacd
@ -10,6 +10,7 @@
|
||||
import static com.github.tomakehurst.wiremock.client.WireMock.configureFor;
|
||||
import static com.github.tomakehurst.wiremock.client.WireMock.getAllServeEvents;
|
||||
import static com.github.tomakehurst.wiremock.client.WireMock.post;
|
||||
import static com.github.tomakehurst.wiremock.client.WireMock.removeServeEvent;
|
||||
import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
|
||||
|
||||
import java.io.IOException;
|
||||
@ -118,7 +119,13 @@ public void testHttpServer() {
|
||||
stubFor(post("/").willReturn(aResponse().withStatus(200)));
|
||||
|
||||
Awaitility.await().atMost(Duration.ofSeconds(60)).until(() -> {
|
||||
events.addAll(getAllServeEvents());
|
||||
List<ServeEvent> currentEvents = getAllServeEvents();
|
||||
events.addAll(currentEvents);
|
||||
// Remove already added events, if e.g. 3 out of 4 events are added, in next attempt all 4 events
|
||||
// are added again and test fails.
|
||||
for (ServeEvent e : currentEvents) {
|
||||
removeServeEvent(e.getId());
|
||||
}
|
||||
|
||||
return events.size() == MESSAGE_COUNT;
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user