mirror of https://github.com/dapr/java-sdk.git
Adding app health check parameters (#1465)
* adding app health check parameters Signed-off-by: salaboy <Salaboy@gmail.com> * fixing style Signed-off-by: salaboy <Salaboy@gmail.com> * testing with configure for coverage Signed-off-by: salaboy <Salaboy@gmail.com> * updating sched api on DaprContainer (#1462) Signed-off-by: salaboy <Salaboy@gmail.com> * fix Artur comments Signed-off-by: salaboy <Salaboy@gmail.com> --------- Signed-off-by: salaboy <Salaboy@gmail.com> Signed-off-by: sirivarma <siri.varma@outlook.com>
This commit is contained in:
parent
24430581b6
commit
0438f36e30
|
|
@ -77,6 +77,9 @@ public class DaprContainer extends GenericContainer<DaprContainer> {
|
||||||
private String appName;
|
private String appName;
|
||||||
private Integer appPort;
|
private Integer appPort;
|
||||||
private String appHealthCheckPath;
|
private String appHealthCheckPath;
|
||||||
|
private Integer appHealthCheckProbeInterval = 5; //default from docs
|
||||||
|
private Integer appHealthCheckProbeTimeout = 500; //default from docs
|
||||||
|
private Integer appHealthCheckThreshold = 3; //default from docs
|
||||||
private boolean shouldReusePlacement;
|
private boolean shouldReusePlacement;
|
||||||
private boolean shouldReuseScheduler;
|
private boolean shouldReuseScheduler;
|
||||||
|
|
||||||
|
|
@ -133,6 +136,21 @@ public class DaprContainer extends GenericContainer<DaprContainer> {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public DaprContainer withAppHealthCheckProbeInterval(Integer appHealthCheckProbeInterval) {
|
||||||
|
this.appHealthCheckProbeInterval = appHealthCheckProbeInterval;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DaprContainer withAppHealthCheckProbeTimeout(Integer appHealthCheckProbeTimeout) {
|
||||||
|
this.appHealthCheckProbeTimeout = appHealthCheckProbeTimeout;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DaprContainer withAppHealthCheckThreshold(Integer appHealthCheckThreshold) {
|
||||||
|
this.appHealthCheckThreshold = appHealthCheckThreshold;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public DaprContainer withConfiguration(Configuration configuration) {
|
public DaprContainer withConfiguration(Configuration configuration) {
|
||||||
this.configuration = configuration;
|
this.configuration = configuration;
|
||||||
return this;
|
return this;
|
||||||
|
|
@ -311,6 +329,16 @@ public class DaprContainer extends GenericContainer<DaprContainer> {
|
||||||
cmds.add("--enable-app-health-check");
|
cmds.add("--enable-app-health-check");
|
||||||
cmds.add("--app-health-check-path");
|
cmds.add("--app-health-check-path");
|
||||||
cmds.add(appHealthCheckPath);
|
cmds.add(appHealthCheckPath);
|
||||||
|
|
||||||
|
cmds.add("--app-health-probe-interval");
|
||||||
|
cmds.add(Integer.toString(appHealthCheckProbeInterval));
|
||||||
|
|
||||||
|
cmds.add("--app-health-probe-timeout");
|
||||||
|
cmds.add(Integer.toString(appHealthCheckProbeTimeout));
|
||||||
|
|
||||||
|
cmds.add("--app-health-threshold");
|
||||||
|
cmds.add(Integer.toString(appHealthCheckThreshold));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (configuration != null) {
|
if (configuration != null) {
|
||||||
|
|
@ -385,6 +413,22 @@ public class DaprContainer extends GenericContainer<DaprContainer> {
|
||||||
return appPort;
|
return appPort;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getAppHealthCheckPath() {
|
||||||
|
return appHealthCheckPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getAppHealthCheckProbeInterval() {
|
||||||
|
return appHealthCheckProbeInterval;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getAppHealthCheckProbeTimeout() {
|
||||||
|
return appHealthCheckProbeTimeout;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getAppHealthCheckThreshold() {
|
||||||
|
return appHealthCheckThreshold;
|
||||||
|
}
|
||||||
|
|
||||||
public String getAppChannelAddress() {
|
public String getAppChannelAddress() {
|
||||||
return appChannelAddress;
|
return appChannelAddress;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -44,4 +44,38 @@ public class DaprContainerTest {
|
||||||
assertEquals("daprio/scheduler:" + DAPR_VERSION, dapr.getSchedulerDockerImageName().asCanonicalNameString());
|
assertEquals("daprio/scheduler:" + DAPR_VERSION, dapr.getSchedulerDockerImageName().asCanonicalNameString());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void appHealthParametersTest(){
|
||||||
|
DaprContainer dapr = new DaprContainer(DAPR_RUNTIME_IMAGE_TAG)
|
||||||
|
.withAppName("dapr-app")
|
||||||
|
.withAppPort(8081)
|
||||||
|
.withAppHealthCheckPath("/test")
|
||||||
|
.withAppHealthCheckProbeInterval(10)
|
||||||
|
.withAppHealthCheckProbeTimeout(600)
|
||||||
|
.withAppHealthCheckThreshold(7);
|
||||||
|
|
||||||
|
dapr.configure();
|
||||||
|
|
||||||
|
assertEquals(10, dapr.getAppHealthCheckProbeInterval());
|
||||||
|
assertEquals(600, dapr.getAppHealthCheckProbeTimeout());
|
||||||
|
assertEquals(7, dapr.getAppHealthCheckThreshold());
|
||||||
|
assertEquals("/test", dapr.getAppHealthCheckPath());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void appHealthParametersDefaultsTest(){
|
||||||
|
//Check that the defaults are set by default
|
||||||
|
DaprContainer dapr2 = new DaprContainer(DAPR_RUNTIME_IMAGE_TAG)
|
||||||
|
.withAppName("dapr2-app")
|
||||||
|
.withAppPort(8082);
|
||||||
|
|
||||||
|
dapr2.configure();
|
||||||
|
|
||||||
|
assertEquals(5, dapr2.getAppHealthCheckProbeInterval());
|
||||||
|
assertEquals(500, dapr2.getAppHealthCheckProbeTimeout());
|
||||||
|
assertEquals(3, dapr2.getAppHealthCheckThreshold());
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue