Search in sources :

Example 6 with HealthEndpointGroups

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

the class AutoConfiguredHealthEndpointGroupsTests method createWhenHasStatusAggregatorPropertyAndGroupQualifiedBeanReturnsInstanceWithBeanUsedForExpectedGroups.

@Test
void createWhenHasStatusAggregatorPropertyAndGroupQualifiedBeanReturnsInstanceWithBeanUsedForExpectedGroups() {
    this.contextRunner.withUserConfiguration(CustomStatusAggregatorGroupAConfiguration.class).withPropertyValues("management.endpoint.health.status.order=up,down", "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.UP);
        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 7 with HealthEndpointGroups

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

the class AutoConfiguredHealthEndpointGroupsTests method getPrimaryGroupMatchesAllMembers.

@Test
void getPrimaryGroupMatchesAllMembers() {
    this.contextRunner.run((context) -> {
        HealthEndpointGroups groups = context.getBean(HealthEndpointGroups.class);
        HealthEndpointGroup primary = groups.getPrimary();
        assertThat(primary.isMember("a")).isTrue();
        assertThat(primary.isMember("b")).isTrue();
        assertThat(primary.isMember("C")).isTrue();
    });
}
Also used : HealthEndpointGroups(org.springframework.boot.actuate.health.HealthEndpointGroups) HealthEndpointGroup(org.springframework.boot.actuate.health.HealthEndpointGroup) Test(org.junit.jupiter.api.Test)

Example 8 with HealthEndpointGroups

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

the class AutoConfiguredHealthEndpointGroupsTests method createWhenHasHttpCodeStatusMapperPropertyAndGroupQualifiedBeanReturnsInstanceWithBeanUsedForExpectedGroups.

@Test
void createWhenHasHttpCodeStatusMapperPropertyAndGroupQualifiedBeanReturnsInstanceWithBeanUsedForExpectedGroups() {
    this.contextRunner.withUserConfiguration(CustomHttpCodeStatusMapperGroupAConfiguration.class).withPropertyValues("management.endpoint.health.status.http-mapping.down=201", "management.endpoint.health.group.a.include=*", "management.endpoint.health.group.a.status.http-mapping.down=201", "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.getHttpCodeStatusMapper().getStatusCode(Status.DOWN)).isEqualTo(201);
        assertThat(groupA.getHttpCodeStatusMapper().getStatusCode(Status.DOWN)).isEqualTo(200);
        assertThat(groupB.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 9 with HealthEndpointGroups

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

the class AutoConfiguredHealthEndpointGroupsTests method createWhenHasStatusAggregatorPropertyAndGroupSpecificPropertyReturnsInstanceWithPropertyUsedForExpectedGroups.

@Test
void createWhenHasStatusAggregatorPropertyAndGroupSpecificPropertyReturnsInstanceWithPropertyUsedForExpectedGroups() {
    this.contextRunner.withPropertyValues("management.endpoint.health.status.order=up,down", "management.endpoint.health.group.a.include=*", "management.endpoint.health.group.a.status.order=unknown,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.UP);
        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 10 with HealthEndpointGroups

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

the class AutoConfiguredHealthEndpointGroupsTests method getGroupWhenGroupExistsReturnsGroup.

@Test
void getGroupWhenGroupExistsReturnsGroup() {
    this.contextRunner.withPropertyValues("management.endpoint.health.group.a.include=*").run((context) -> {
        HealthEndpointGroups groups = context.getBean(HealthEndpointGroups.class);
        HealthEndpointGroup group = groups.get("a");
        assertThat(group).isNotNull();
    });
}
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