Skip to content

Commit

Permalink
Set HealthStatusUpdateHAndler to public
Browse files Browse the repository at this point in the history
  • Loading branch information
seonWKim committed Jun 22, 2024
1 parent 495ce58 commit 487997f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
* Handler which updates the healthiness of the {@link Server}. Supports {@code PUT}, {@code POST} and
* {@code PATCH} requests and tells if the {@link Server} needs update its {@link HealthStatus}.
*/
enum HealthStatusUpdateHandler implements HealthCheckUpdateHandler {
public enum HealthStatusUpdateHandler implements HealthCheckUpdateHandler {

INSTANCE;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import java.nio.charset.StandardCharsets;
import java.time.Duration;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.concurrent.atomic.AtomicReference;
Expand Down Expand Up @@ -527,15 +526,16 @@ void checkStatus(String status) {
}

@Test
void pollSameHealthState() throws ExecutionException, InterruptedException {
void pollHealthState() throws Exception {
checker.setHealthStatus(HealthStatus.HEALTHY);
final CompletableFuture<AggregatedHttpResponse> f = sendLongPollingGet("healthy", "/hc");
assertThatThrownBy(() -> f.get(1, TimeUnit.SECONDS)).isInstanceOf(TimeoutException.class);

// Because we did not poll for specific status, no response is sent.
// Because the health state is unchanged(from healthy to healthy), response is not received.
checker.setHealthStatus(HealthStatus.DEGRADED);
assertThatThrownBy(() -> f.get(1, TimeUnit.SECONDS)).isInstanceOf(TimeoutException.class);

// Because the health state is changed(from healthy to unhealthy), response is received.
checker.setHealthStatus(HealthStatus.UNHEALTHY);
assertThat(f.get().contentUtf8()).isEqualTo(
"{\"healthy\":" + "false" + ",\"status\":\"" + "UNHEALTHY" + "\"}");
Expand Down

0 comments on commit 487997f

Please sign in to comment.