use of de.codecentric.boot.admin.server.domain.entities.Instance in project spring-boot-admin by codecentric.
the class ProbeEndpointsStrategyTest method should_return_detect_endpoints.
@Test
public void should_return_detect_endpoints() {
// given
Instance instance = Instance.create(InstanceId.of("id")).register(Registration.create("test", this.wireMock.url("/mgmt/health")).managementUrl(this.wireMock.url("/mgmt")).build());
this.wireMock.stubFor(options(urlEqualTo("/mgmt/metrics")).willReturn(ok()));
this.wireMock.stubFor(options(urlEqualTo("/mgmt/stats")).willReturn(ok()));
this.wireMock.stubFor(options(urlEqualTo("/mgmt/info")).willReturn(ok()));
this.wireMock.stubFor(options(urlEqualTo("/mgmt/non-exist")).willReturn(notFound()));
this.wireMock.stubFor(options(urlEqualTo("/mgmt/error")).willReturn(serverError()));
this.wireMock.stubFor(options(urlEqualTo("/mgmt/exception")).willReturn(aResponse().withFault(Fault.EMPTY_RESPONSE)));
ProbeEndpointsStrategy strategy = new ProbeEndpointsStrategy(this.instanceWebClient, new String[] { "metrics:stats", "metrics", "info", "non-exist", "error", "exception" });
// when
StepVerifier.create(strategy.detectEndpoints(instance)).expectNext(Endpoints.single("metrics", this.wireMock.url("/mgmt/stats")).withEndpoint("info", //
this.wireMock.url("/mgmt/info"))).verifyComplete();
}
use of de.codecentric.boot.admin.server.domain.entities.Instance in project spring-boot-admin by codecentric.
the class ProbeEndpointsStrategyTest method should_return_empty.
@Test
public void should_return_empty() {
// given
Instance instance = Instance.create(InstanceId.of("id")).register(Registration.create("test", this.wireMock.url("/mgmt/health")).managementUrl(this.wireMock.url("/mgmt")).build());
this.wireMock.stubFor(options(urlEqualTo("/mgmt/stats")).willReturn(aResponse().withStatus(HttpStatus.NOT_FOUND_404)));
ProbeEndpointsStrategy strategy = new ProbeEndpointsStrategy(this.instanceWebClient, new String[] { "metrics:stats" });
// when
StepVerifier.create(strategy.detectEndpoints(instance)).verifyComplete();
}
use of de.codecentric.boot.admin.server.domain.entities.Instance in project spring-boot-admin by codecentric.
the class ProbeEndpointsStrategyTest 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());
this.wireMock.stubFor(options(urlEqualTo("/mgmt/metrics")).inScenario("retry").whenScenarioStateIs(STARTED).willReturn(aResponse().withFixedDelay(5000)).willSetStateTo("recovered"));
this.wireMock.stubFor(options(urlEqualTo("/mgmt/metrics")).inScenario("retry").whenScenarioStateIs("recovered").willReturn(ok()));
this.wireMock.stubFor(options(urlEqualTo("/mgmt/stats")).willReturn(ok()));
this.wireMock.stubFor(options(urlEqualTo("/mgmt/info")).willReturn(ok()));
this.wireMock.stubFor(options(urlEqualTo("/mgmt/non-exist")).willReturn(notFound()));
ProbeEndpointsStrategy strategy = new ProbeEndpointsStrategy(this.instanceWebClient, new String[] { "metrics:stats", "metrics", "info", "non-exist" });
// when
StepVerifier.create(strategy.detectEndpoints(instance)).expectNext(Endpoints.single("metrics", this.wireMock.url("/mgmt/stats")).withEndpoint("info", //
this.wireMock.url("/mgmt/info"))).verifyComplete();
}
use of de.codecentric.boot.admin.server.domain.entities.Instance in project spring-boot-admin by codecentric.
the class FilteringNotifierTest method test_filter.
@Test
public void test_filter() {
TestNotifier delegate = new TestNotifier();
FilteringNotifier notifier = new FilteringNotifier(delegate, repository);
AbstractNotificationFilter trueFilter = new AbstractNotificationFilter() {
@Override
public boolean filter(InstanceEvent event, Instance instance) {
return true;
}
};
notifier.addFilter(trueFilter);
StepVerifier.create(notifier.notify(event)).verifyComplete();
assertThat(delegate.getEvents()).doesNotContain(event);
notifier.removeFilter(trueFilter.getId());
StepVerifier.create(notifier.notify(event)).verifyComplete();
assertThat(delegate.getEvents()).contains(event);
}
use of de.codecentric.boot.admin.server.domain.entities.Instance in project spring-boot-admin by codecentric.
the class EndpointDetectorTest method should_update_endpoints.
@Test
public void should_update_endpoints() {
// given
Registration registration = Registration.create("foo", "http://health").managementUrl("http://mgmt").build();
Instance instance = Instance.create(InstanceId.of("onl")).register(registration).withStatusInfo(StatusInfo.ofUp());
StepVerifier.create(repository.save(instance)).expectNextCount(1).verifyComplete();
Instance noActuator = Instance.create(InstanceId.of("noActuator")).register(Registration.create("foo", "http://health").build()).withStatusInfo(StatusInfo.ofUp());
StepVerifier.create(repository.save(noActuator)).expectNextCount(1).verifyComplete();
Instance offline = Instance.create(InstanceId.of("off")).register(registration).withStatusInfo(StatusInfo.ofOffline());
StepVerifier.create(repository.save(offline)).expectNextCount(1).verifyComplete();
Instance unknown = Instance.create(InstanceId.of("unk")).register(registration).withStatusInfo(StatusInfo.ofUnknown());
StepVerifier.create(repository.save(unknown)).expectNextCount(1).verifyComplete();
when(strategy.detectEndpoints(any(Instance.class))).thenReturn(Mono.just(Endpoints.single("id", "url")));
// when/then
StepVerifier.create(Flux.from(eventStore).log("FOO", Level.SEVERE)).expectSubscription().then(() -> StepVerifier.create(detector.detectEndpoints(offline.getId())).verifyComplete()).then(() -> StepVerifier.create(detector.detectEndpoints(unknown.getId())).verifyComplete()).then(() -> StepVerifier.create(detector.detectEndpoints(noActuator.getId())).verifyComplete()).expectNoEvent(Duration.ofMillis(100L)).then(() -> StepVerifier.create(detector.detectEndpoints(instance.getId())).verifyComplete()).assertNext((event) -> assertThat(event).isInstanceOf(InstanceEndpointsDetectedEvent.class)).thenCancel().verify();
StepVerifier.create(repository.find(instance.getId())).assertNext((app) -> assertThat(app.getEndpoints()).isEqualTo(Endpoints.single("id", "url").withEndpoint("health", "http://health"))).verifyComplete();
}
Aggregations