Search in sources :

Example 6 with HealthEndpointGroup

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

the class AutoConfiguredHealthEndpointGroupsTests method createWhenHasHttpCodeStatusMapperPropertyAndGroupSpecificPropertyReturnsInstanceWithPropertyUsedForExpectedGroups.

@Test
void createWhenHasHttpCodeStatusMapperPropertyAndGroupSpecificPropertyReturnsInstanceWithPropertyUsedForExpectedGroups() {
    this.contextRunner.withPropertyValues("management.endpoint.health.status.http-mapping.down=201", "management.endpoint.health.group.a.include=*", "management.endpoint.health.group.a.status.http-mapping.down=202", "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(202);
        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 7 with HealthEndpointGroup

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

the class AutoConfiguredHealthEndpointGroupsTests method createWhenGroupWithNoShowDetailsOverrideInheritsShowDetails.

@Test
void createWhenGroupWithNoShowDetailsOverrideInheritsShowDetails() {
    this.contextRunner.withPropertyValues("management.endpoint.health.show-details=always", "management.endpoint.health.group.a.include=*").run((context) -> {
        HealthEndpointGroups groups = context.getBean(HealthEndpointGroups.class);
        HealthEndpointGroup groupA = groups.get("a");
        assertThat(groupA.showDetails(SecurityContext.NONE)).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 HealthEndpointGroup

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

the class AutoConfiguredHealthEndpointGroupsTests method createWhenHasGroupSpecificHttpCodeStatusMapperPropertyAndGroupQualifiedBeanReturnsInstanceWithBeanUsedForExpectedGroups.

@Test
void createWhenHasGroupSpecificHttpCodeStatusMapperPropertyAndGroupQualifiedBeanReturnsInstanceWithBeanUsedForExpectedGroups() {
    this.contextRunner.withUserConfiguration(CustomHttpCodeStatusMapperGroupAConfiguration.class).withPropertyValues("management.endpoint.health.group.a.include=*", "management.endpoint.health.group.a.status.http-mapping.down=201", "management.endpoint.health.group.b.include=*", "management.endpoint.health.group.b.status.http-mapping.down=201").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(503);
        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 HealthEndpointGroup

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

the class AutoConfiguredHealthEndpointGroupsTests method createWhenHasHttpCodeStatusMapperBeanAndGroupSpecificPropertyReturnsInstanceThatUsesBeanOnlyForUnconfiguredGroups.

@Test
void createWhenHasHttpCodeStatusMapperBeanAndGroupSpecificPropertyReturnsInstanceThatUsesBeanOnlyForUnconfiguredGroups() {
    this.contextRunner.withUserConfiguration(CustomHttpCodeStatusMapperConfiguration.class).withPropertyValues("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(200);
        assertThat(groupA.getHttpCodeStatusMapper().getStatusCode(Status.DOWN)).isEqualTo(201);
        assertThat(groupB.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 10 with HealthEndpointGroup

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

the class AutoConfiguredHealthEndpointGroupsTests method createWhenHasHttpCodeStatusMapperBeanReturnsInstanceWithMapperUsedForAllGroups.

@Test
void createWhenHasHttpCodeStatusMapperBeanReturnsInstanceWithMapperUsedForAllGroups() {
    this.contextRunner.withUserConfiguration(CustomHttpCodeStatusMapperConfiguration.class).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(200);
        assertThat(groupA.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)

Aggregations

HealthEndpointGroup (org.springframework.boot.actuate.health.HealthEndpointGroup)25 Test (org.junit.jupiter.api.Test)22 HealthEndpointGroups (org.springframework.boot.actuate.health.HealthEndpointGroups)22 AdditionalHealthEndpointPath (org.springframework.boot.actuate.health.AdditionalHealthEndpointPath)3 WebOperation (org.springframework.boot.actuate.endpoint.web.WebOperation)2 WebOperationRequestPredicate (org.springframework.boot.actuate.endpoint.web.WebOperationRequestPredicate)2 LinkedHashMap (java.util.LinkedHashMap)1 Show (org.springframework.boot.actuate.autoconfigure.health.HealthProperties.Show)1 Status (org.springframework.boot.actuate.autoconfigure.health.HealthProperties.Status)1 HttpCodeStatusMapper (org.springframework.boot.actuate.health.HttpCodeStatusMapper)1 SimpleHttpCodeStatusMapper (org.springframework.boot.actuate.health.SimpleHttpCodeStatusMapper)1 SimpleStatusAggregator (org.springframework.boot.actuate.health.SimpleStatusAggregator)1 StatusAggregator (org.springframework.boot.actuate.health.StatusAggregator)1 RequestMappingInfo (org.springframework.web.reactive.result.method.RequestMappingInfo)1