use of de.codecentric.boot.admin.server.domain.values.InstanceId in project spring-boot-admin by codecentric.
the class InstanceRegistryTest method deregister.
@Test
public void deregister() {
InstanceId id = registry.register(Registration.create("abc", "http://localhost:8080/health").build()).block();
registry.deregister(id).block();
StepVerifier.create(registry.getInstance(id)).assertNext((app) -> assertThat(app.isRegistered()).isFalse()).verifyComplete();
}
use of de.codecentric.boot.admin.server.domain.values.InstanceId in project spring-boot-admin by codecentric.
the class ApplicationRegistryTest method getInstance.
private Instance getInstance(String applicationName, String version) {
Registration registration = Registration.create(applicationName, "http://localhost:8080/health").metadata("version", version).build();
InstanceId id = InstanceId.of("TEST" + applicationName);
return Instance.create(id).register(registration);
}
use of de.codecentric.boot.admin.server.domain.values.InstanceId in project spring-boot-admin by codecentric.
the class ApplicationRegistryTest method deregister.
@Test
public void deregister() {
Instance instance1 = getInstance("App1");
InstanceId instance1Id = instance1.getId();
when(this.instanceRegistry.getInstances("App1")).thenReturn(Flux.just(instance1));
when(this.instanceRegistry.deregister(instance1Id)).thenReturn(Mono.just(instance1Id));
StepVerifier.create(this.applicationRegistry.deregister("App1")).assertNext((instanceId) -> assertThat(instanceId).isEqualTo(instance1Id)).verifyComplete();
verify(this.instanceRegistry).deregister(instance1Id);
}
use of de.codecentric.boot.admin.server.domain.values.InstanceId in project spring-boot-admin by codecentric.
the class AbstractInstanceRepositoryTest method should_run_compute_with_null.
@Test
public void should_run_compute_with_null() {
InstanceId instanceId = InstanceId.of("app-1");
Registration registration = Registration.create("app", "http://health").build();
// when
StepVerifier.create(this.repository.compute(this.instance1.getId(), (key, application) -> {
assertThat(application).isNull();
return Mono.just(Instance.create(key).register(registration));
})).assertNext((v) -> {
assertThat(v.getId()).isEqualTo(instanceId);
assertThat(v.getRegistration()).isEqualTo(registration);
}).verifyComplete();
// then
StepVerifier.create(this.repository.find(instanceId)).assertNext((v) -> {
assertThat(v.getId()).isEqualTo(instanceId);
assertThat(v.getRegistration()).isEqualTo(registration);
}).verifyComplete();
}
use of de.codecentric.boot.admin.server.domain.values.InstanceId in project spring-boot-admin by codecentric.
the class InstancesProxyController method endpointProxy.
@ResponseBody
@RequestMapping(path = INSTANCE_MAPPED_PATH, method = { RequestMethod.GET, RequestMethod.HEAD, RequestMethod.POST, RequestMethod.PUT, RequestMethod.PATCH, RequestMethod.DELETE, RequestMethod.OPTIONS })
public void endpointProxy(@PathVariable("instanceId") String instanceId, HttpServletRequest servletRequest, HttpServletResponse servletResponse) {
ServletServerHttpRequest request = new ServletServerHttpRequest(servletRequest);
Flux<DataBuffer> requestBody = DataBufferUtils.readInputStream(request::getBody, this.bufferFactory, 4096);
InstanceWebProxy.ForwardRequest fwdRequest = createForwardRequest(request, requestBody, this.adminContextPath + INSTANCE_MAPPED_PATH);
this.instanceWebProxy.forward(this.registry.getInstance(InstanceId.of(instanceId)), fwdRequest, (clientResponse) -> {
ServerHttpResponse response = new ServletServerHttpResponse(servletResponse);
response.setStatusCode(clientResponse.statusCode());
response.getHeaders().addAll(this.httpHeadersFilter.filterHeaders(clientResponse.headers().asHttpHeaders()));
try {
OutputStream responseBody = response.getBody();
response.flush();
return clientResponse.body(BodyExtractors.toDataBuffers()).window(1).concatMap((body) -> writeAndFlush(body, responseBody)).then();
} catch (IOException ex) {
return Mono.error(ex);
}
}).block();
}
Aggregations