-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce customizable control-plane timeout for
ApiServer
Fixes #291
- Loading branch information
Showing
2 changed files
with
57 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
src/test/java/com/dajudge/kindcontainer/ApiServerTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package com.dajudge.kindcontainer; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import java.util.concurrent.atomic.AtomicBoolean; | ||
import java.util.concurrent.atomic.AtomicReference; | ||
|
||
import static com.dajudge.kindcontainer.KubernetesVersionEnum.latest; | ||
import static java.time.Duration.ofSeconds; | ||
import static java.util.concurrent.TimeUnit.MINUTES; | ||
import static org.awaitility.Awaitility.await; | ||
import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
|
||
public class ApiServerTest { | ||
@Test | ||
public void configurableTimeout() { | ||
final AtomicBoolean containerCompleted = new AtomicBoolean(); | ||
final AtomicReference<Exception> containerFailed = new AtomicReference<>(); | ||
final ApiServerContainer<?> apiServer = new ApiServerContainer<>(latest(ApiServerContainerVersion.class).withImage("nginx")) | ||
.withCreateContainerCmdModifier(cmd -> cmd.withEntrypoint().withCmd()) | ||
.withCommand("nginx") | ||
.withControlPlaneReadyTimeout(ofSeconds(1)); | ||
final Thread containerThread = new Thread(() -> { | ||
try { | ||
apiServer.start(); | ||
apiServer.stop(); | ||
} catch (final Exception e) { | ||
containerFailed.set(e); | ||
} finally { | ||
containerCompleted.set(true); | ||
} | ||
}); | ||
try { | ||
containerThread.start(); | ||
|
||
await().timeout(5, MINUTES).until(containerCompleted::get); | ||
assertNotNull(containerFailed.get()); | ||
} finally { | ||
apiServer.stop(); | ||
} | ||
} | ||
|
||
} |