Skip to content

Commit

Permalink
fix another flaky test
Browse files Browse the repository at this point in the history
Signed-off-by: tvallin <thibault.vallin@oracle.com>
  • Loading branch information
tvallin committed Apr 22, 2024
1 parent e4f9340 commit 60fe4bd
Showing 1 changed file with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2023 Oracle and/or its affiliates.
* Copyright (c) 2023, 2024 Oracle and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -21,6 +21,9 @@
import io.helidon.webserver.WebServer;

import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.DisabledOnOs;
import org.junit.jupiter.api.condition.EnabledOnOs;
import org.junit.jupiter.api.condition.OS;

import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
Expand All @@ -29,7 +32,20 @@
class WebServerStopIdleTest {

@Test
@DisabledOnOs(OS.WINDOWS)
void stopWhenIdleExpectTimelyStop() {
stopWhenIdleExpectTimelyStop(500);
}

@Test
@EnabledOnOs(
value = OS.WINDOWS,
disabledReason = "Slow pipeline runner make it stop a few millisecond later")
void stopWhenIdleExpectTimelyStopWindows() {
stopWhenIdleExpectTimelyStop(505);
}

void stopWhenIdleExpectTimelyStop(int maximumTime) {
WebServer webServer = WebServer.builder()
.routing(router -> router.get("ok", (req, res) -> res.send("ok")))
.build();
Expand All @@ -46,6 +62,6 @@ void stopWhenIdleExpectTimelyStop() {
long startMillis = System.currentTimeMillis();
webServer.stop();
int stopExecutionTimeInMillis = (int) (System.currentTimeMillis() - startMillis);
assertThat(stopExecutionTimeInMillis, is(lessThan(500)));
assertThat(stopExecutionTimeInMillis, is(lessThan(maximumTime)));
}
}

0 comments on commit 60fe4bd

Please sign in to comment.