use of de.codecentric.boot.admin.server.domain.entities.Instance in project spring-boot-admin by codecentric.
the class InstanceNameNotificationFilterTest method test_filterByName.
@Test
public void test_filterByName() {
NotificationFilter filter = new ApplicationNameNotificationFilter("foo", null);
Instance filteredInstance = Instance.create(InstanceId.of("-")).register(Registration.create("foo", "http://health").build());
InstanceRegisteredEvent filteredEvent = new InstanceRegisteredEvent(filteredInstance.getId(), filteredInstance.getVersion(), filteredInstance.getRegistration());
assertThat(filter.filter(filteredEvent, filteredInstance)).isTrue();
Instance ignoredInstance = Instance.create(InstanceId.of("-")).register(Registration.create("bar", "http://health").build());
InstanceRegisteredEvent ignoredEvent = new InstanceRegisteredEvent(ignoredInstance.getId(), ignoredInstance.getVersion(), ignoredInstance.getRegistration());
assertThat(filter.filter(ignoredEvent, ignoredInstance)).isFalse();
}
use of de.codecentric.boot.admin.server.domain.entities.Instance in project spring-boot-admin by codecentric.
the class InfoUpdaterTest method should_retry.
@Test
public void should_retry() {
// given
Registration registration = Registration.create("foo", this.wireMock.url("/health")).build();
Instance instance = Instance.create(InstanceId.of("onl")).register(registration).withEndpoints(Endpoints.single("info", this.wireMock.url("/info"))).withStatusInfo(StatusInfo.ofUp());
StepVerifier.create(this.repository.save(instance)).expectNextCount(1).verifyComplete();
this.wireMock.stubFor(get("/info").inScenario("retry").whenScenarioStateIs(STARTED).willReturn(aResponse().withFixedDelay(5000)).willSetStateTo("recovered"));
String body = "{ \"foo\": \"bar\" }";
this.wireMock.stubFor(get("/info").inScenario("retry").whenScenarioStateIs("recovered").willReturn(okJson(body).withHeader("Content-Length", Integer.toString(body.length()))));
// when
StepVerifier.create(this.eventStore).expectSubscription().then(() -> StepVerifier.create(this.updater.updateInfo(instance.getId())).verifyComplete()).assertNext((event) -> assertThat(event).isInstanceOf(InstanceInfoChangedEvent.class)).thenCancel().verify();
StepVerifier.create(this.repository.find(instance.getId())).assertNext((app) -> assertThat(app.getInfo()).isEqualTo(Info.from(singletonMap("foo", "bar")))).verifyComplete();
}
use of de.codecentric.boot.admin.server.domain.entities.Instance in project spring-boot-admin by codecentric.
the class CloudFoundryHttpHeaderProviderTest method test_cloud_foundry_header.
@Test
public void test_cloud_foundry_header() {
Registration registration = Registration.create("foo", "http://health").metadata("applicationId", "549e64cf-a478-423d-9d6d-02d803a028a8").metadata("instanceId", "0").build();
Instance instance = Instance.create(InstanceId.of("id")).register(registration);
assertThat(headersProvider.getHeaders(instance).get("X-CF-APP-INSTANCE")).containsOnly("549e64cf-a478-423d-9d6d-02d803a028a8:0");
}
use of de.codecentric.boot.admin.server.domain.entities.Instance in project spring-boot-admin by codecentric.
the class InstanceWebClientTest method should_add_instance_attribute.
@Test
public void should_add_instance_attribute() {
Instance instance = Instance.create(InstanceId.of("i"));
Mono<ClientResponse> response = InstanceWebClient.builder().filter((inst, req, next) -> {
assertThat(req.attribute(ATTRIBUTE_INSTANCE)).hasValue(instance);
assertThat(inst).isEqualTo(instance);
return Mono.just(ClientResponse.create(HttpStatus.OK).build());
}).build().instance(Mono.just(instance)).get().uri("http://test/health").exchangeToMono(Mono::just);
StepVerifier.create(response).assertNext((r) -> assertThat(r.statusCode()).isEqualTo(HttpStatus.OK)).verifyComplete();
}
Aggregations