Skip to content

Commit

Permalink
retry on kafka connect test setup failure
Browse files Browse the repository at this point in the history
  • Loading branch information
Dugong42 committed Nov 6, 2024
1 parent 8f5915c commit 62598e4
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions api/src/test/java/io/kafbat/ui/KafkaConnectServiceTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
Expand Down Expand Up @@ -44,6 +45,26 @@ public class KafkaConnectServiceTests extends AbstractIntegrationTest {

@BeforeEach
public void setUp() {

int limit = 5;
int tries = 0;
boolean failed = false;

do {
try {
TimeUnit.SECONDS.sleep(1);
webTestClient.get()
.uri("/api/clusters/{clusterName}/connects/{connectName}/connectors", LOCAL,
connectName)
.exchange()
.expectStatus().isOk();
} catch (Exception e) {
failed = true;
System.out.println("failed to retrieve connectors: " + tries);
}
tries++;
} while (failed == true && tries < limit);

webTestClient.post()
.uri("/api/clusters/{clusterName}/connects/{connectName}/connectors", LOCAL, connectName)
.bodyValue(new NewConnectorDTO()
Expand Down

0 comments on commit 62598e4

Please sign in to comment.