Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix health check attributes #519

Merged
merged 2 commits into from
Jun 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ private void checkHealth() {

@VisibleForTesting
void checkHealth(String serviceName) {
if (options.getDisableHealthCheck()) {
if (!options.getDisableHealthCheck()) {
RpcRetryOptions retryOptions =
RpcRetryOptions.newBuilder()
.setExpiration(getOptions().getHealthCheckTimeout())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ private WorkflowServiceStubsOptions(Builder builder) {
this.headers = builder.headers;
this.metricsScope = builder.metricsScope;
this.disableHealthCheck = builder.disableHealthCheck;
this.healthCheckAttemptTimeout = builder.HealthCheckAttemptTimeout;
this.healthCheckAttemptTimeout = builder.healthCheckAttemptTimeout;
this.healthCheckTimeout = builder.healthCheckTimeout;
this.enableKeepAlive = builder.enableKeepAlive;
this.keepAliveTime = builder.keepAliveTime;
Expand Down Expand Up @@ -210,9 +210,9 @@ private WorkflowServiceStubsOptions(Builder builder, boolean ignore) {
this.metricsScope = builder.metricsScope == null ? new NoopScope() : builder.metricsScope;
this.disableHealthCheck = builder.disableHealthCheck;
this.healthCheckAttemptTimeout =
builder.healthCheckTimeout == null
builder.healthCheckAttemptTimeout == null
? Duration.ofSeconds(5)
: builder.HealthCheckAttemptTimeout;
: builder.healthCheckAttemptTimeout;
this.healthCheckTimeout =
builder.healthCheckTimeout == null ? Duration.ofSeconds(10) : builder.healthCheckTimeout;
this.enableKeepAlive = builder.enableKeepAlive;
Expand All @@ -239,7 +239,7 @@ public boolean getEnableHttps() {
return enableHttps;
}

/** @return true when client checks endpoint to make sure that the server is accessible. */
/** @return false when client checks endpoint to make sure that the server is accessible. */
public boolean getDisableHealthCheck() {
return disableHealthCheck;
}
Expand Down Expand Up @@ -352,7 +352,7 @@ public static class Builder {
private boolean enableHttps;
private String target;
private boolean disableHealthCheck;
private Duration HealthCheckAttemptTimeout;
private Duration healthCheckAttemptTimeout;
private Duration healthCheckTimeout;
private boolean enableKeepAlive;
private Duration keepAliveTime;
Expand Down Expand Up @@ -395,7 +395,7 @@ private Builder(WorkflowServiceStubsOptions options) {
this.headers = options.headers;
this.metricsScope = options.metricsScope;
this.disableHealthCheck = options.disableHealthCheck;
this.HealthCheckAttemptTimeout = options.healthCheckAttemptTimeout;
this.healthCheckAttemptTimeout = options.healthCheckAttemptTimeout;
this.healthCheckTimeout = options.healthCheckTimeout;
this.enableKeepAlive = options.enableKeepAlive;
this.keepAliveTime = options.keepAliveTime;
Expand Down Expand Up @@ -545,17 +545,17 @@ public Builder setMetricsScope(Scope metricsScope) {
}

/**
* If true, enables client to make a request to health check endpoint to make sure that the
* If false, enables client to make a request to health check endpoint to make sure that the
* server is accessible.
*/
public Builder setDisableHealthCheck(boolean disableHealthCheck) {
this.disableHealthCheck = disableHealthCheck;
return this;
}

/** Set the time to wait between service responses on each health check. */
public Builder setEnableKeepAlive(Duration HealthCheckAttemptTimeout) {
this.HealthCheckAttemptTimeout = HealthCheckAttemptTimeout;
/** Set the time to wait between service responses on each health check */
public Builder setHealthCheckAttemptTimeout(Duration healthCheckAttemptTimeout) {
this.healthCheckAttemptTimeout = healthCheckAttemptTimeout;
return this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public void testFaiLedHealthCheck() {
WorkflowServiceStubsOptions.newBuilder().setDisableHealthCheck(false).build());
try {
service.checkHealth("IncorrectServiceName");
Assert.fail("Health check for IncorrectServiceName should fail");
} catch (RuntimeException e) {
Assert.assertTrue(e.getMessage().startsWith("Health check returned unhealthy status: "));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,10 @@ public Client() {
channel = InProcessChannelBuilder.forName(serverName).directExecutor().build();
stubs =
WorkflowServiceStubs.newInstance(
WorkflowServiceStubsOptions.newBuilder().setChannel(channel).build());
WorkflowServiceStubsOptions.newBuilder()
.setChannel(channel)
.setDisableHealthCheck(true)
.build());
}

public final String serverName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ public TestActivityEnvironmentInternal(TestEnvironmentOptions options) {
.setChannel(channel)
.setMetricsScope(options.getMetricsScope())
.setQueryRpcTimeout(Duration.ofSeconds(60))
.setDisableHealthCheck(true)
.build());
activityTaskHandler =
new POJOActivityTaskHandler(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ public TestWorkflowEnvironmentInternal(TestEnvironmentOptions options) {
service,
WorkflowServiceStubsOptions.newBuilder()
.setMetricsScope(options.getMetricsScope())
.setDisableHealthCheck(true)
.build());
}
WorkflowClient client = WorkflowClient.newInstance(workflowServiceStubs, workflowClientOptions);
Expand Down