Search in sources :

Example 21 with Registration

use of de.codecentric.boot.admin.server.domain.values.Registration in project spring-boot-admin by codecentric.

the class CloudFoundryHttpHeaderProviderTest method test_no_header.

@Test
public void test_no_header() {
    Registration registration = Registration.create("foo", "http://health").build();
    Instance instance = Instance.create(InstanceId.of("id")).register(registration);
    assertThat(headersProvider.getHeaders(instance)).isEmpty();
}
Also used : Instance(de.codecentric.boot.admin.server.domain.entities.Instance) Registration(de.codecentric.boot.admin.server.domain.values.Registration) Test(org.junit.jupiter.api.Test)

Example 22 with Registration

use of de.codecentric.boot.admin.server.domain.values.Registration 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);
}
Also used : InstanceId(de.codecentric.boot.admin.server.domain.values.InstanceId) Registration(de.codecentric.boot.admin.server.domain.values.Registration)

Example 23 with Registration

use of de.codecentric.boot.admin.server.domain.values.Registration 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();
}
Also used : Test(org.junit.jupiter.api.Test) Registration(de.codecentric.boot.admin.server.domain.values.Registration) AtomicLong(java.util.concurrent.atomic.AtomicLong) Endpoints(de.codecentric.boot.admin.server.domain.values.Endpoints) StepVerifier(reactor.test.StepVerifier) AssertionFailedError(org.opentest4j.AssertionFailedError) InstanceId(de.codecentric.boot.admin.server.domain.values.InstanceId) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Mono(reactor.core.publisher.Mono) InstanceId(de.codecentric.boot.admin.server.domain.values.InstanceId) Registration(de.codecentric.boot.admin.server.domain.values.Registration) Test(org.junit.jupiter.api.Test)

Example 24 with Registration

use of de.codecentric.boot.admin.server.domain.values.Registration in project spring-boot-admin by codecentric.

the class InstanceTest method should_yield_same_status_from_replaying.

@Test
public void should_yield_same_status_from_replaying() {
    Registration registration = Registration.create("foo-instance", "http://health").metadata("version", "1.0.0").build();
    Instance instance = Instance.create(InstanceId.of("id")).register(registration.toBuilder().clearMetadata().build()).register(registration).withEndpoints(Endpoints.single("info", "info")).withStatusInfo(StatusInfo.ofUp()).withInfo(Info.from(singletonMap("foo", "bar")));
    Instance loaded = Instance.create(InstanceId.of("id")).apply(instance.getUnsavedEvents());
    assertThat(loaded.getUnsavedEvents()).isEmpty();
    assertThat(loaded.getRegistration()).isEqualTo(registration);
    assertThat(loaded.isRegistered()).isTrue();
    assertThat(loaded.getStatusInfo()).isEqualTo(StatusInfo.ofUp());
    assertThat(loaded.getStatusTimestamp()).isEqualTo(instance.getStatusTimestamp());
    assertThat(loaded.getInfo()).isEqualTo(Info.from(singletonMap("foo", "bar")));
    assertThat(loaded.getEndpoints()).isEqualTo(Endpoints.single("info", "info").withEndpoint("health", "http://health"));
    assertThat(loaded.getVersion()).isEqualTo(4L);
    assertThat(loaded.getBuildVersion()).isEqualTo(BuildVersion.valueOf("1.0.0"));
    Instance deregisteredInstance = instance.deregister();
    loaded = Instance.create(InstanceId.of("id")).apply(deregisteredInstance.getUnsavedEvents());
    assertThat(loaded.getUnsavedEvents()).isEmpty();
    assertThat(loaded.isRegistered()).isFalse();
    assertThat(loaded.getInfo()).isEqualTo(Info.empty());
    assertThat(loaded.getStatusInfo()).isEqualTo(StatusInfo.ofUnknown());
    assertThat(loaded.getStatusTimestamp()).isEqualTo(deregisteredInstance.getStatusTimestamp());
    assertThat(loaded.getEndpoints()).isEqualTo(Endpoints.empty());
    assertThat(loaded.getVersion()).isEqualTo(5L);
    assertThat(loaded.getBuildVersion()).isEqualTo(null);
}
Also used : Registration(de.codecentric.boot.admin.server.domain.values.Registration) Test(org.junit.jupiter.api.Test)

Example 25 with Registration

use of de.codecentric.boot.admin.server.domain.values.Registration in project spring-boot-admin by codecentric.

the class InstanceTest method should_extract_tags.

@Test
public void should_extract_tags() {
    Instance instance = Instance.create(InstanceId.of("id"));
    assertThat(instance.getTags().getValues()).isEmpty();
    Registration registration = Registration.create("foo-instance", "http://health").metadata("tags.environment", "test").metadata("tags.region", "EU").build();
    instance = instance.register(registration);
    assertThat(instance.getTags().getValues()).containsExactly(entry("environment", "test"), entry("region", "EU"));
    instance = instance.withInfo(Info.from(singletonMap("tags", singletonMap("region", "US-East"))));
    assertThat(instance.getTags().getValues()).containsExactly(entry("environment", "test"), entry("region", "US-East"));
    instance = instance.deregister();
    assertThat(instance.getTags().getValues()).isEmpty();
    instance = instance.register(registration.toBuilder().clearMetadata().build());
    assertThat(instance.getTags().getValues()).isEmpty();
}
Also used : Registration(de.codecentric.boot.admin.server.domain.values.Registration) Test(org.junit.jupiter.api.Test)

Aggregations

Registration (de.codecentric.boot.admin.server.domain.values.Registration)53 Test (org.junit.jupiter.api.Test)46 Instance (de.codecentric.boot.admin.server.domain.entities.Instance)15 InstanceId (de.codecentric.boot.admin.server.domain.values.InstanceId)12 ServiceInstance (org.springframework.cloud.client.ServiceInstance)9 JSONObject (org.json.JSONObject)8 DefaultServiceInstance (org.springframework.cloud.client.DefaultServiceInstance)8 StatusInfo (de.codecentric.boot.admin.server.domain.values.StatusInfo)7 InstanceRepository (de.codecentric.boot.admin.server.domain.entities.InstanceRepository)6 Info (de.codecentric.boot.admin.server.domain.values.Info)6 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)6 StepVerifier (reactor.test.StepVerifier)6 EventsourcingInstanceRepository (de.codecentric.boot.admin.server.domain.entities.EventsourcingInstanceRepository)5 InstanceRegisteredEvent (de.codecentric.boot.admin.server.domain.events.InstanceRegisteredEvent)5 InstanceRegistrationUpdatedEvent (de.codecentric.boot.admin.server.domain.events.InstanceRegistrationUpdatedEvent)5 Endpoints (de.codecentric.boot.admin.server.domain.values.Endpoints)5 InMemoryEventStore (de.codecentric.boot.admin.server.eventstore.InMemoryEventStore)5 BeforeEach (org.junit.jupiter.api.BeforeEach)5 Collections.singletonMap (java.util.Collections.singletonMap)4 InstanceInfo (com.netflix.appinfo.InstanceInfo)3