use of io.gravitee.definition.model.Endpoint in project gravitee-gateway by gravitee-io.
the class EndpointStatusDecoratorTest method testEndpointStatus_transitionallyDown.
@Test
public void testEndpointStatus_transitionallyDown() {
Endpoint endpoint = createEndpoint();
EndpointStatusDecorator manager = new EndpointStatusDecorator(endpoint);
manager.updateStatus(true);
manager.updateStatus(false);
Assert.assertEquals(Endpoint.Status.TRANSITIONALLY_DOWN, endpoint.getStatus());
}
use of io.gravitee.definition.model.Endpoint in project gravitee-gateway by gravitee-io.
the class EndpointStatusDecoratorTest method testEndpointStatus_scenario.
@Test
public void testEndpointStatus_scenario() {
Endpoint endpoint = createEndpoint();
EndpointStatusDecorator manager = new EndpointStatusDecorator(endpoint);
Assert.assertEquals(Endpoint.Status.UP, endpoint.getStatus());
manager.updateStatus(false);
Assert.assertEquals(Endpoint.Status.TRANSITIONALLY_DOWN, endpoint.getStatus());
manager.updateStatus(false);
Assert.assertEquals(Endpoint.Status.TRANSITIONALLY_DOWN, endpoint.getStatus());
manager.updateStatus(false);
Assert.assertEquals(Endpoint.Status.DOWN, endpoint.getStatus());
manager.updateStatus(true);
Assert.assertEquals(Endpoint.Status.TRANSITIONALLY_UP, endpoint.getStatus());
manager.updateStatus(false);
Assert.assertEquals(Endpoint.Status.DOWN, endpoint.getStatus());
manager.updateStatus(true);
Assert.assertEquals(Endpoint.Status.TRANSITIONALLY_UP, endpoint.getStatus());
manager.updateStatus(true);
Assert.assertEquals(Endpoint.Status.UP, endpoint.getStatus());
manager.updateStatus(false);
Assert.assertEquals(Endpoint.Status.TRANSITIONALLY_DOWN, endpoint.getStatus());
}
use of io.gravitee.definition.model.Endpoint in project gravitee-gateway by gravitee-io.
the class EndpointStatusDecoratorTest method testEndpointStatus_downAfterTransitionallyUp.
@Test
public void testEndpointStatus_downAfterTransitionallyUp() {
Endpoint endpoint = createEndpoint();
EndpointStatusDecorator manager = new EndpointStatusDecorator(endpoint);
manager.updateStatus(false);
manager.updateStatus(false);
manager.updateStatus(false);
Assert.assertEquals(Endpoint.Status.DOWN, endpoint.getStatus());
manager.updateStatus(true);
Assert.assertEquals(Endpoint.Status.TRANSITIONALLY_UP, endpoint.getStatus());
}
use of io.gravitee.definition.model.Endpoint in project gravitee-gateway by gravitee-io.
the class EndpointStatusDecoratorTest method testEndpointStatus_noHealthCheckDone.
@Test
public void testEndpointStatus_noHealthCheckDone() {
Endpoint endpoint = createEndpoint();
Assert.assertEquals(Endpoint.Status.UP, endpoint.getStatus());
}
use of io.gravitee.definition.model.Endpoint in project gravitee-gateway by gravitee-io.
the class HttpEndpointRuleHandlerTest method shouldValidateFromRoot.
@Test
public void shouldValidateFromRoot(TestContext context) throws InterruptedException {
// Prepare HTTP endpoint
stubFor(get(urlEqualTo("/")).willReturn(aResponse().withStatus(200).withBody("{\"status\": \"green\"}")));
// Prepare
EndpointRule rule = mock(EndpointRule.class);
Endpoint endpoint = createEndpoint();
endpoint.setTarget(endpoint.getTarget() + "/additional-but-unused-path-for-hc");
when(rule.endpoint()).thenReturn(endpoint);
io.gravitee.definition.model.services.healthcheck.Step step = new io.gravitee.definition.model.services.healthcheck.Step();
Request request = new Request();
request.setPath("/");
request.setFromRoot(true);
request.setMethod(HttpMethod.GET);
step.setRequest(request);
Response response = new Response();
response.setAssertions(Collections.singletonList(Response.DEFAULT_ASSERTION));
step.setResponse(response);
when(rule.steps()).thenReturn(Collections.singletonList(step));
HttpEndpointRuleHandler runner = new HttpEndpointRuleHandler(vertx, rule);
Async async = context.async();
// Verify
runner.setStatusHandler(new Handler<EndpointStatus>() {
@Override
public void handle(EndpointStatus status) {
Assert.assertTrue(status.isSuccess());
async.complete();
}
});
// Run
runner.handle(null);
// Wait until completion
async.awaitSuccess();
}
Aggregations