Search in sources :

Example 31 with HealthEndpointGroups

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

the class AutoConfiguredHealthEndpointGroupsTests method createWhenHasStatusAggregatorPropertyReturnsInstanceWithPropertyUsedForAllGroups.

@Test
void createWhenHasStatusAggregatorPropertyReturnsInstanceWithPropertyUsedForAllGroups() {
    this.contextRunner.withPropertyValues("management.endpoint.health.status.order=up,down", "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.getStatusAggregator().getAggregateStatus(Status.UP, Status.DOWN)).isEqualTo(Status.UP);
        assertThat(groupA.getStatusAggregator().getAggregateStatus(Status.UP, Status.DOWN)).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 32 with HealthEndpointGroups

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

the class AutoConfiguredHealthEndpointGroupsTests method getNamesReturnsGroupNames.

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

Example 33 with HealthEndpointGroups

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

the class AutoConfiguredHealthEndpointGroupsTests method createWhenNoDefinedBeansAdaptsProperties.

@Test
void createWhenNoDefinedBeansAdaptsProperties() {
    this.contextRunner.withPropertyValues("management.endpoint.health.show-components=always", "management.endpoint.health.show-details=never", "management.endpoint.health.status.order=up,down", "management.endpoint.health.status.http-mapping.down=200").run((context) -> {
        HealthEndpointGroups groups = context.getBean(HealthEndpointGroups.class);
        HealthEndpointGroup primary = groups.getPrimary();
        assertThat(primary.showComponents(SecurityContext.NONE)).isTrue();
        assertThat(primary.showDetails(SecurityContext.NONE)).isFalse();
        assertThat(primary.getStatusAggregator().getAggregateStatus(Status.UP, Status.DOWN)).isEqualTo(Status.UP);
        assertThat(primary.getHttpCodeStatusMapper().getStatusCode(Status.DOWN)).isEqualTo(200);
    });
}
Also used : HealthEndpointGroups(org.springframework.boot.actuate.health.HealthEndpointGroups) HealthEndpointGroup(org.springframework.boot.actuate.health.HealthEndpointGroup) Test(org.junit.jupiter.api.Test)

Example 34 with HealthEndpointGroups

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

the class AutoConfiguredHealthEndpointGroupsTests method createWhenHasStatusAggregatorBeanReturnsInstanceWithAggregatorUsedForAllGroups.

@Test
void createWhenHasStatusAggregatorBeanReturnsInstanceWithAggregatorUsedForAllGroups() {
    this.contextRunner.withUserConfiguration(CustomStatusAggregatorConfiguration.class).withPropertyValues("management.endpoint.health.status.order=up,down", "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.getStatusAggregator().getAggregateStatus(Status.UP, Status.DOWN, Status.UNKNOWN)).isEqualTo(Status.UNKNOWN);
        assertThat(groupA.getStatusAggregator().getAggregateStatus(Status.UP, Status.DOWN, Status.UNKNOWN)).isEqualTo(Status.UNKNOWN);
    });
}
Also used : HealthEndpointGroups(org.springframework.boot.actuate.health.HealthEndpointGroups) HealthEndpointGroup(org.springframework.boot.actuate.health.HealthEndpointGroup) Test(org.junit.jupiter.api.Test)

Example 35 with HealthEndpointGroups

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

the class AutoConfiguredHealthEndpointGroupsTests method createWhenHasStatusAggregatorBeanAndGroupSpecificPropertyReturnsInstanceThatUsesBeanOnlyForUnconfiguredGroups.

@Test
void createWhenHasStatusAggregatorBeanAndGroupSpecificPropertyReturnsInstanceThatUsesBeanOnlyForUnconfiguredGroups() {
    this.contextRunner.withUserConfiguration(CustomStatusAggregatorConfiguration.class).withPropertyValues("management.endpoint.health.group.a.include=*", "management.endpoint.health.group.a.status.order=up,down", "management.endpoint.health.group.b.include=*").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.UNKNOWN);
        assertThat(groupA.getStatusAggregator().getAggregateStatus(Status.UP, Status.DOWN, Status.UNKNOWN)).isEqualTo(Status.UP);
        assertThat(groupB.getStatusAggregator().getAggregateStatus(Status.UP, Status.DOWN, Status.UNKNOWN)).isEqualTo(Status.UNKNOWN);
    });
}
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