Search in sources :

Example 26 with HealthEndpointGroups

use of org.springframework.boot.actuate.health.HealthEndpointGroups in project spring-boot by spring-projects.

the class AvailabilityProbesHealthEndpointGroupsTests method getLivenessProbeHasOnlyLivenessStateAsMember.

@Test
void getLivenessProbeHasOnlyLivenessStateAsMember() {
    HealthEndpointGroups availabilityProbes = new AvailabilityProbesHealthEndpointGroups(this.delegate, false);
    HealthEndpointGroup probeGroup = availabilityProbes.get("liveness");
    assertThat(probeGroup.isMember("livenessState")).isTrue();
    assertThat(probeGroup.isMember("readinessState")).isFalse();
}
Also used : HealthEndpointGroups(org.springframework.boot.actuate.health.HealthEndpointGroups) HealthEndpointGroup(org.springframework.boot.actuate.health.HealthEndpointGroup) Test(org.junit.jupiter.api.Test)

Example 27 with HealthEndpointGroups

use of org.springframework.boot.actuate.health.HealthEndpointGroups in project spring-boot by spring-projects.

the class HealthEndpointAutoConfigurationTests method runCreatesHealthEndpointGroups.

@Test
void runCreatesHealthEndpointGroups() {
    this.contextRunner.withPropertyValues("management.endpoint.health.group.ready.include=*").run((context) -> {
        HealthEndpointGroups groups = context.getBean(HealthEndpointGroups.class);
        assertThat(groups).isInstanceOf(AutoConfiguredHealthEndpointGroups.class);
        assertThat(groups.getNames()).containsOnly("ready");
    });
}
Also used : HealthEndpointGroups(org.springframework.boot.actuate.health.HealthEndpointGroups) Test(org.junit.jupiter.api.Test)

Example 28 with HealthEndpointGroups

use of org.springframework.boot.actuate.health.HealthEndpointGroups in project spring-boot by spring-projects.

the class AutoConfiguredHealthEndpointGroupsTests method createWhenHasHttpCodeStatusMapperPropertyReturnsInstanceWithPropertyUsedForAllGroups.

@Test
void createWhenHasHttpCodeStatusMapperPropertyReturnsInstanceWithPropertyUsedForAllGroups() {
    this.contextRunner.withPropertyValues("management.endpoint.health.status.http-mapping.down=201", "management.endpoint.health.group.a.include=*").run((context) -> {
        HealthEndpointGroups groups = context.getBean(HealthEndpointGroups.class);
        HealthEndpointGroup primary = groups.getPrimary();
        HealthEndpointGroup groupA = groups.get("a");
        assertThat(primary.getHttpCodeStatusMapper().getStatusCode(Status.DOWN)).isEqualTo(201);
        assertThat(groupA.getHttpCodeStatusMapper().getStatusCode(Status.DOWN)).isEqualTo(201);
    });
}
Also used : HealthEndpointGroups(org.springframework.boot.actuate.health.HealthEndpointGroups) HealthEndpointGroup(org.springframework.boot.actuate.health.HealthEndpointGroup) Test(org.junit.jupiter.api.Test)

Example 29 with HealthEndpointGroups

use of org.springframework.boot.actuate.health.HealthEndpointGroups in project spring-boot by spring-projects.

the class AutoConfiguredHealthEndpointGroupsTests method createWhenHasGroupSpecificStatusAggregatorPropertyAndGroupQualifiedBeanReturnsInstanceWithBeanUsedForExpectedGroups.

@Test
void createWhenHasGroupSpecificStatusAggregatorPropertyAndGroupQualifiedBeanReturnsInstanceWithBeanUsedForExpectedGroups() {
    this.contextRunner.withUserConfiguration(CustomStatusAggregatorGroupAConfiguration.class).withPropertyValues("management.endpoint.health.group.a.include=*", "management.endpoint.health.group.a.status.order=up,down", "management.endpoint.health.group.b.include=*", "management.endpoint.health.group.b.status.order=up,down").run((context) -> {
        HealthEndpointGroups groups = context.getBean(HealthEndpointGroups.class);
        HealthEndpointGroup primary = groups.getPrimary();
        HealthEndpointGroup groupA = groups.get("a");
        HealthEndpointGroup groupB = groups.get("b");
        assertThat(primary.getStatusAggregator().getAggregateStatus(Status.UP, Status.DOWN, Status.UNKNOWN)).isEqualTo(Status.DOWN);
        assertThat(groupA.getStatusAggregator().getAggregateStatus(Status.UP, Status.DOWN, Status.UNKNOWN)).isEqualTo(Status.UNKNOWN);
        assertThat(groupB.getStatusAggregator().getAggregateStatus(Status.UP, Status.DOWN, Status.UNKNOWN)).isEqualTo(Status.UP);
    });
}
Also used : HealthEndpointGroups(org.springframework.boot.actuate.health.HealthEndpointGroups) HealthEndpointGroup(org.springframework.boot.actuate.health.HealthEndpointGroup) Test(org.junit.jupiter.api.Test)

Example 30 with HealthEndpointGroups

use of org.springframework.boot.actuate.health.HealthEndpointGroups in project spring-boot by spring-projects.

the class AutoConfiguredHealthEndpointGroupsTests method getGroupWhenGroupDoesNotExistReturnsNull.

@Test
void getGroupWhenGroupDoesNotExistReturnsNull() {
    this.contextRunner.withPropertyValues("management.endpoint.health.group.a.include=*").run((context) -> {
        HealthEndpointGroups groups = context.getBean(HealthEndpointGroups.class);
        HealthEndpointGroup group = groups.get("b");
        assertThat(group).isNull();
    });
}
Also used : HealthEndpointGroups(org.springframework.boot.actuate.health.HealthEndpointGroups) HealthEndpointGroup(org.springframework.boot.actuate.health.HealthEndpointGroup) Test(org.junit.jupiter.api.Test)

Aggregations

HealthEndpointGroups (org.springframework.boot.actuate.health.HealthEndpointGroups)35 Test (org.junit.jupiter.api.Test)34 HealthEndpointGroup (org.springframework.boot.actuate.health.HealthEndpointGroup)22 LinkedHashSet (java.util.LinkedHashSet)3 MockEnvironment (org.springframework.mock.env.MockEnvironment)1