Add checkpointEvent extension property.
It should allow to configure other events than org.springframework.boot.context.event.ApplicationReadyEvent to trigger the checkpoint. Closes gh-22
This commit is contained in:
@@ -73,6 +73,7 @@ public class CrSmokeTestPlugin implements Plugin<Project> {
|
||||
CrSmokeTestExtension extension = project.getExtensions()
|
||||
.create("crSmokeTest", CrSmokeTestExtension.class, project);
|
||||
extension.getWebApplication().convention(false);
|
||||
extension.getCheckpointEvent().convention("org.springframework.boot.context.event.ApplicationReadyEvent");
|
||||
JavaPluginExtension javaExtension = project.getExtensions().getByType(JavaPluginExtension.class);
|
||||
SourceSet appTest = javaExtension.getSourceSets().create("appTest");
|
||||
javaExtension.setSourceCompatibility(JavaVersion.VERSION_17);
|
||||
@@ -262,6 +263,9 @@ public class CrSmokeTestPlugin implements Plugin<Project> {
|
||||
start.getOutputDirectory().set(outputDirectory);
|
||||
start.setDescription("Starts the " + type.description + " application.");
|
||||
start.getWebApplication().convention(extension.getWebApplication());
|
||||
if (start instanceof StartAndCheckpointJvmApplication startAndCheckpoint) {
|
||||
startAndCheckpoint.getCheckpointEvent().convention(extension.getCheckpointEvent());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -31,9 +31,12 @@ public class CrSmokeTestExtension {
|
||||
|
||||
private final Property<Boolean> webApplication;
|
||||
|
||||
private final Property<String> checkpointEvent;
|
||||
|
||||
@Inject
|
||||
public CrSmokeTestExtension(Project project) {
|
||||
this.webApplication = project.getObjects().property(Boolean.class);
|
||||
this.checkpointEvent = project.getObjects().property(String.class);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -44,4 +47,11 @@ public class CrSmokeTestExtension {
|
||||
return this.webApplication;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The Spring event class name to be used to trigger a checkpoint.
|
||||
*/
|
||||
public Property<String> getCheckpointEvent() {
|
||||
return this.checkpointEvent;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -8,6 +8,8 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.gradle.api.Task;
|
||||
import org.gradle.api.provider.Property;
|
||||
import org.gradle.api.tasks.Input;
|
||||
import org.gradle.api.tasks.TaskAction;
|
||||
import org.gradle.internal.jvm.Jvm;
|
||||
|
||||
@@ -32,7 +34,8 @@ public abstract class StartAndCheckpointJvmApplication extends StartApplication
|
||||
command.add("/bin/bash");
|
||||
command.add("-c");
|
||||
StringBuilder builder = new StringBuilder(executable.getAbsolutePath());
|
||||
builder.append(" -Dorg.springframework.cr.smoketest.checkpoint=org.springframework.boot.context.event.ApplicationReadyEvent");
|
||||
builder.append(" -Dorg.springframework.cr.smoketest.checkpoint=");
|
||||
builder.append(getCheckpointEvent().get());
|
||||
builder.append(" -XX:CRaCCheckpointTo=");
|
||||
builder.append(outputDirectory);
|
||||
if (getWebApplication().get()) {
|
||||
@@ -67,5 +70,10 @@ public abstract class StartAndCheckpointJvmApplication extends StartApplication
|
||||
Files.write(pid, List.of(Long.toString(process.pid())));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The Spring event class name to be used to trigger a checkpoint.
|
||||
*/
|
||||
@Input
|
||||
public abstract Property<String> getCheckpointEvent();
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user