Skip to content

Commit

Permalink
Improve reliability of process shutdown test
Browse files Browse the repository at this point in the history
  • Loading branch information
jjlauer committed Nov 4, 2024
1 parent 07b90bc commit 5502bf8
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.fizzed.blaze.util;

import com.fizzed.crux.util.Resources;
import com.fizzed.crux.util.WaitFor;
import com.fizzed.jne.OperatingSystem;
import com.fizzed.jne.PlatformInfo;
import org.junit.Test;
Expand All @@ -10,6 +11,7 @@
import org.zeroturnaround.exec.StartedProcess;

import java.nio.file.Path;
import java.util.concurrent.TimeUnit;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*;
Expand All @@ -33,7 +35,8 @@ public void destroy() throws Exception {
.command(binFile.toAbsolutePath().toString())
.start();

assertThat(startedProcess.getProcess().isAlive(), is(true));
// processes can take awhile to start sometimes, so wait for it to be alive
WaitFor.of(() -> startedProcess.getProcess().isAlive()).awaitMillis(3000L, 50L);

PROCESS_HELPER.destroy(startedProcess.getProcess(), 5000L);

Expand All @@ -53,7 +56,8 @@ public void destroyWithDescendants() throws Exception {
.command(binFile.toAbsolutePath().toString())
.start();

assertThat(startedProcess.getProcess().isAlive(), is(true));
// processes can take awhile to start sometimes, so wait for it to be alive
WaitFor.of(() -> startedProcess.getProcess().isAlive()).awaitMillis(3000L, 50L);

PROCESS_HELPER.destroyWithDescendants(startedProcess.getProcess(), 5000L);

Expand Down

0 comments on commit 5502bf8

Please sign in to comment.