use of de.codecentric.boot.admin.server.domain.entities.Instance in project spring-boot-admin by codecentric.
the class QueryIndexEndpointStrategyTest method should_retry.
@Test
public void should_retry() {
// given
Instance instance = Instance.create(InstanceId.of("id")).register(Registration.create("test", this.wireMock.url("/mgmt/health")).managementUrl(this.wireMock.url("/mgmt")).build());
String body = "{\"_links\":{\"metrics-requiredMetricName\":{\"templated\":true,\"href\":\"/mgmt/metrics/{requiredMetricName}\"},\"self\":{\"templated\":false,\"href\":\"/mgmt\"},\"metrics\":{\"templated\":false,\"href\":\"/mgmt/stats\"},\"info\":{\"templated\":false,\"href\":\"/mgmt/info\"}}}";
this.wireMock.stubFor(get("/mgmt").inScenario("retry").whenScenarioStateIs(STARTED).willReturn(aResponse().withFault(Fault.CONNECTION_RESET_BY_PEER)).willSetStateTo("recovered"));
this.wireMock.stubFor(get("/mgmt").inScenario("retry").whenScenarioStateIs("recovered").willReturn(ok(body).withHeader("Content-Type", ActuatorMediaType.V2_JSON)));
QueryIndexEndpointStrategy strategy = new QueryIndexEndpointStrategy(this.instanceWebClient);
// when
StepVerifier.create(strategy.detectEndpoints(instance)).expectNext(//
Endpoints.single("metrics", "/mgmt/stats").withEndpoint("info", "/mgmt/info")).verifyComplete();
}
use of de.codecentric.boot.admin.server.domain.entities.Instance in project spring-boot-admin by codecentric.
the class QueryIndexEndpointStrategyTest method should_return_endpoints.
@Test
public void should_return_endpoints() {
// given
Instance instance = Instance.create(InstanceId.of("id")).register(Registration.create("test", this.wireMock.url("/mgmt/health")).managementUrl(this.wireMock.url("/mgmt")).build());
String host = "https://localhost:" + this.wireMock.httpsPort();
String body = "{\"_links\":{\"metrics-requiredMetricName\":{\"templated\":true,\"href\":\"" + host + "/mgmt/metrics/{requiredMetricName}\"},\"self\":{\"templated\":false,\"href\":\"" + host + "/mgmt\"},\"metrics\":{\"templated\":false,\"href\":\"" + host + "/mgmt/stats\"},\"info\":{\"templated\":false,\"href\":\"" + host + "/mgmt/info\"}}}";
this.wireMock.stubFor(get("/mgmt").willReturn(ok(body).withHeader("Content-Type", ActuatorMediaType.V2_JSON)));
QueryIndexEndpointStrategy strategy = new QueryIndexEndpointStrategy(this.instanceWebClient);
// when
StepVerifier.create(strategy.detectEndpoints(instance)).expectNext(//
Endpoints.single("metrics", host + "/mgmt/stats").withEndpoint("info", host + "/mgmt/info")).verifyComplete();
}
use of de.codecentric.boot.admin.server.domain.entities.Instance in project spring-boot-admin by codecentric.
the class ApplicationRegistryTest method getApplications_allRegisteredApplications.
@Test
public void getApplications_allRegisteredApplications() {
Instance instance1 = getInstance("App1");
Instance instance2 = getInstance("App2");
when(this.instanceRegistry.getInstances()).thenReturn(Flux.just(instance1, instance2));
StepVerifier.create(this.applicationRegistry.getApplications()).recordWith(ArrayList::new).thenConsumeWhile((a) -> true).consumeRecordedWith((applications) -> assertThat(applications.stream().map(Application::getName)).containsExactlyInAnyOrder("App1", "App2")).verifyComplete();
}
use of de.codecentric.boot.admin.server.domain.entities.Instance in project spring-boot-admin by codecentric.
the class ApplicationRegistryTest method getApplication_matchingRegisteredApplications.
@Test
public void getApplication_matchingRegisteredApplications() {
Instance instance = getInstance("App1");
when(this.instanceRegistry.getInstances("App1")).thenReturn(Flux.just(instance));
StepVerifier.create(this.applicationRegistry.getApplication("App1")).assertNext((app) -> assertThat(app.getName()).isEqualTo("App1")).verifyComplete();
}
use of de.codecentric.boot.admin.server.domain.entities.Instance in project spring-boot-admin by codecentric.
the class ApplicationRegistryTest method getStatus.
@ParameterizedTest
@CsvSource({ "UP, UP, UP", "DOWN, DOWN, DOWN", "UNKNOWN, UNKNOWN, UNKNOWN", "UP, DOWN, RESTRICTED", "UP, UNKNOWN, RESTRICTED", "UP, OUT_OF_SERVICE, RESTRICTED", "UP, OFFLINE, RESTRICTED", "UP, RESTRICTED, RESTRICTED", "DOWN, UP, RESTRICTED" })
public void getStatus(String instance1Status, String instance2Status, String expectedApplicationStatus) {
Instance instance1 = getInstance("App1").withStatusInfo(StatusInfo.valueOf(instance1Status));
Instance instance2 = getInstance("App1").withStatusInfo(StatusInfo.valueOf(instance2Status));
when(this.instanceRegistry.getInstances()).thenReturn(Flux.just(instance1, instance2));
StepVerifier.create(this.applicationRegistry.getApplications()).recordWith(ArrayList::new).thenConsumeWhile((a) -> true).consumeRecordedWith((applications) -> assertThat(applications.stream().map(Application::getStatus)).containsExactly(expectedApplicationStatus)).verifyComplete();
}
Aggregations