Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Quarkus-cli flacky test #321

Merged
merged 1 commit into from
Oct 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,10 @@ private void assertInstalledExtensions(QuarkusCliRestService app, String... expe
Stream.of(expectedExtensions).forEach(expectedExtension -> assertTrue(extensions.contains(expectedExtension),
expectedExtension + " not found in " + extensions));
}

// https://github.com/quarkusio/quarkus/issues/21070
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,10 @@ private void assertInstalledExtensions(QuarkusCliRestService app, String... expe
Stream.of(expectedExtensions).forEach(expectedExtension -> assertTrue(extensions.contains(expectedExtension),
expectedExtension + " not found in " + extensions));
}

// https://github.com/quarkusio/quarkus/issues/21070
private void startAfter(QuarkusCliRestService app, Duration duration) throws InterruptedException {
pjgg marked this conversation as resolved.
Show resolved Hide resolved
TimeUnit.SECONDS.sleep(duration.getSeconds());
app.start();
}
}