mirror of
https://github.com/apache/maven-mvnd.git
synced 2025-09-26 05:58:27 +00:00
Fix DaemonCrashTest silently failing
This commit is contained in:
@@ -22,6 +22,7 @@ import java.util.stream.Stream;
|
||||
import javax.inject.Inject;
|
||||
import org.assertj.core.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.Timeout;
|
||||
import org.mvndaemon.mvnd.assertj.TestClientOutput;
|
||||
import org.mvndaemon.mvnd.client.Client;
|
||||
import org.mvndaemon.mvnd.client.DaemonParameters;
|
||||
@@ -30,7 +31,8 @@ import org.mvndaemon.mvnd.junit.MvndTest;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
@MvndTest(projectDir = "src/test/projects/daemon-crash")
|
||||
@MvndTest(projectDir = "src/test/projects/daemon-crash", keepAlive = "100ms", maxLostKeepAlive = "30")
|
||||
@Timeout(30)
|
||||
public class DaemonCrashTest {
|
||||
|
||||
@Inject
|
||||
|
@@ -37,4 +37,8 @@ public @interface MvndNativeTest {
|
||||
* Timeout for {@link Client#execute(org.mvndaemon.mvnd.common.ClientOutput, java.util.List)} in seconds
|
||||
*/
|
||||
long timeoutSec() default 300;
|
||||
|
||||
String keepAlive() default "";
|
||||
|
||||
String maxLostKeepAlive() default "";
|
||||
}
|
||||
|
@@ -30,4 +30,8 @@ public @interface MvndTest {
|
||||
* <code>@MvndTest(projectDir = "src/test/projects/my-project")</code>
|
||||
*/
|
||||
String projectDir();
|
||||
|
||||
String keepAlive() default "";
|
||||
|
||||
String maxLostKeepAlive() default "";
|
||||
}
|
||||
|
@@ -56,14 +56,17 @@ public class MvndTestExtension implements BeforeAllCallback, BeforeEachCallback,
|
||||
try {
|
||||
final Store store = context.getRoot().getStore(ExtensionContext.Namespace.GLOBAL);
|
||||
final Class<?> testClass = context.getRequiredTestClass();
|
||||
final MvndTest mnvdTest = testClass.getAnnotation(MvndTest.class);
|
||||
if (mnvdTest != null) {
|
||||
final MvndTest mvndTest = testClass.getAnnotation(MvndTest.class);
|
||||
String keepAlive = Environment.MVND_KEEP_ALIVE.getDefault();
|
||||
if (mvndTest != null) {
|
||||
store.put(MvndResource.class.getName(),
|
||||
MvndResource.create(
|
||||
context.getRequiredTestClass().getSimpleName(),
|
||||
mnvdTest.projectDir(),
|
||||
mvndTest.projectDir(),
|
||||
false,
|
||||
-1L));
|
||||
-1L,
|
||||
mvndTest.keepAlive(),
|
||||
mvndTest.maxLostKeepAlive()));
|
||||
} else {
|
||||
final MvndNativeTest mvndNativeTest = testClass.getAnnotation(MvndNativeTest.class);
|
||||
store.put(MvndResource.class.getName(),
|
||||
@@ -71,7 +74,9 @@ public class MvndTestExtension implements BeforeAllCallback, BeforeEachCallback,
|
||||
context.getRequiredTestClass().getSimpleName(),
|
||||
mvndNativeTest.projectDir(),
|
||||
true,
|
||||
mvndNativeTest.timeoutSec() * 1000L));
|
||||
mvndNativeTest.timeoutSec() * 1000L,
|
||||
mvndNativeTest.keepAlive(),
|
||||
mvndNativeTest.maxLostKeepAlive()));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
this.bootException = e;
|
||||
@@ -142,7 +147,8 @@ public class MvndTestExtension implements BeforeAllCallback, BeforeEachCallback,
|
||||
private final boolean isNative;
|
||||
private final long timeoutMs;
|
||||
|
||||
public static MvndResource create(String className, String rawProjectDir, boolean isNative, long timeoutMs)
|
||||
public static MvndResource create(String className, String rawProjectDir, boolean isNative, long timeoutMs,
|
||||
String keepAlive, String maxLostKeepAlive)
|
||||
throws IOException {
|
||||
if (rawProjectDir == null) {
|
||||
throw new IllegalStateException("rawProjectDir of @MvndTest must be set");
|
||||
@@ -220,8 +226,10 @@ public class MvndTestExtension implements BeforeAllCallback, BeforeEachCallback,
|
||||
localMavenRepository, settingsPath,
|
||||
logback,
|
||||
TimeUtils.toDuration(Environment.MVND_IDLE_TIMEOUT.getDefault()),
|
||||
TimeUtils.toDuration(Environment.MVND_KEEP_ALIVE.getDefault()).multipliedBy(10),
|
||||
Integer.parseInt(Environment.MVND_MAX_LOST_KEEP_ALIVE.getDefault()) * 10);
|
||||
keepAlive != null && !keepAlive.isEmpty() ? TimeUtils.toDuration(keepAlive)
|
||||
: TimeUtils.toDuration(Environment.MVND_KEEP_ALIVE.getDefault()).multipliedBy(10),
|
||||
maxLostKeepAlive != null && !maxLostKeepAlive.isEmpty() ? Integer.parseInt(maxLostKeepAlive)
|
||||
: Integer.parseInt(Environment.MVND_MAX_LOST_KEEP_ALIVE.getDefault()) * 10);
|
||||
final TestRegistry registry = new TestRegistry(parameters.registry());
|
||||
|
||||
return new MvndResource(parameters, registry, isNative, timeoutMs);
|
||||
|
Reference in New Issue
Block a user