Skip to content

Commit

Permalink
Fix Quarkus-cli flacky test on Quarkus start
Browse files Browse the repository at this point in the history
  • Loading branch information
pablo gonzalez granados committed Oct 28, 2021
1 parent 8cc2cf7 commit 7ab82f1
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
import static io.quarkus.test.utils.AwaitilityUtils.untilAsserted;
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.time.Duration;
import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.stream.Stream;

import javax.inject.Inject;
Expand All @@ -24,6 +26,7 @@ public class QuarkusCliClientIT {

static final String RESTEASY_EXTENSION = "quarkus-resteasy";
static final String SMALLRYE_HEALTH_EXTENSION = "quarkus-smallrye-health";
static final int CMD_DELAY_SEC = 3;

@Inject
static QuarkusCliClient cliClient;
Expand All @@ -43,7 +46,7 @@ public void shouldCreateApplicationOnJvm() {
}

@Test
public void shouldAddAndRemoveExtensions() {
public void shouldAddAndRemoveExtensions() throws InterruptedException {
// Create application
QuarkusCliRestService app = cliClient.createApplication("app");

Expand All @@ -67,7 +70,7 @@ public void shouldAddAndRemoveExtensions() {
assertTrue(result.isSuccessful(), SMALLRYE_HEALTH_EXTENSION + " was not uninstalled. Output: " + result.getOutput());

// The health endpoint should be now gone
app.start();
startAfter(app, Duration.ofSeconds(CMD_DELAY_SEC));
untilAsserted(() -> app.given().get("/q/health").then().statusCode(HttpStatus.SC_NOT_FOUND));
}

Expand All @@ -76,4 +79,9 @@ private void assertInstalledExtensions(QuarkusCliRestService app, String... expe
Stream.of(expectedExtensions).forEach(expectedExtension -> assertTrue(extensions.contains(expectedExtension),
expectedExtension + " not found in " + extensions));
}

private void startAfter(QuarkusCliRestService app, Duration duration) throws InterruptedException {
TimeUnit.SECONDS.sleep(duration.getSeconds());
app.start();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.time.Duration;
import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.stream.Stream;

import javax.inject.Inject;
Expand All @@ -31,6 +33,7 @@ public class QuarkusCliClientIT {
static final String RESTEASY_SPRING_WEB_EXTENSION = "quarkus-spring-web";
static final String RESTEASY_EXTENSION = "quarkus-resteasy";
static final String SMALLRYE_HEALTH_EXTENSION = "quarkus-smallrye-health";
static final int CMD_DELAY_SEC = 3;

@Inject
static QuarkusCliClient cliClient;
Expand Down Expand Up @@ -85,7 +88,7 @@ public void shouldCreateApplicationWithCodeStarter() {
}

@Test
public void shouldAddAndRemoveExtensions() {
public void shouldAddAndRemoveExtensions() throws InterruptedException {
// Create application
QuarkusCliRestService app = cliClient.createApplication("app");

Expand All @@ -109,7 +112,7 @@ public void shouldAddAndRemoveExtensions() {
assertTrue(result.isSuccessful(), SMALLRYE_HEALTH_EXTENSION + " was not uninstalled. Output: " + result.getOutput());

// The health endpoint should be now gone
app.start();
startAfter(app, Duration.ofSeconds(CMD_DELAY_SEC));
untilAsserted(() -> app.given().get("/q/health").then().statusCode(HttpStatus.SC_NOT_FOUND));
}

Expand All @@ -118,4 +121,9 @@ private void assertInstalledExtensions(QuarkusCliRestService app, String... expe
Stream.of(expectedExtensions).forEach(expectedExtension -> assertTrue(extensions.contains(expectedExtension),
expectedExtension + " not found in " + extensions));
}

private void startAfter(QuarkusCliRestService app, Duration duration) throws InterruptedException {
TimeUnit.SECONDS.sleep(duration.getSeconds());
app.start();
}
}

0 comments on commit 7ab82f1

Please sign in to comment.