Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
{
"groups": [
{
"name": "sofa.boot.actuator.health",
"type": "com.alipay.sofa.boot.actuator.autoconfigure.health.HealthProperties",
"description": "SOFABoot actuator health configuration properties for readiness checks, health checker timeouts, and status mapping.",
"sourceType": "com.alipay.sofa.boot.actuator.autoconfigure.health.HealthProperties"
},
{
"name": "sofa.boot.startup",
"type": "com.alipay.sofa.boot.actuator.autoconfigure.startup.StartupProperties",
"description": "SOFABoot startup report configuration properties.",
"sourceType": "com.alipay.sofa.boot.actuator.autoconfigure.startup.StartupProperties"
},
{
"name": "sofa.boot.startup.threads.virtual",
"description": "SOFABoot virtual thread startup configuration properties."
}
],
"properties": [
{
"name": "sofa.boot.actuator.health.excluded-indicators",
"description": "HealthIndicator bean names excluded from readiness health checks."
},
{
"name": "sofa.boot.actuator.health.global-health-checker-timeout",
"description": "Global HealthChecker timeout in milliseconds.",
"defaultValue": 60000
},
{
"name": "sofa.boot.actuator.health.global-health-indicator-timeout",
"description": "Global HealthIndicator timeout in milliseconds.",
"defaultValue": 60000
},
{
"name": "sofa.boot.actuator.health.health-checker-config",
"description": "Per HealthChecker configuration keyed by component name."
},
{
"name": "sofa.boot.actuator.health.health-indicator-config",
"description": "Per HealthIndicator configuration keyed by bean name."
},
{
"name": "sofa.boot.actuator.health.parallel-check-timeout",
"description": "Timeout for parallel health checks in milliseconds.",
"defaultValue": 120000
},
{
"name": "sofa.boot.actuator.health.status.http-mapping",
"description": "HTTP status code mapping keyed by health status."
},
{
"name": "sofa.boot.actuator.health.status.order",
"description": "Ordered health statuses from most severe to least severe."
},
{
"name": "sofa.boot.startup.threads.virtual.enabled",
"type": "java.lang.Boolean",
"description": "Whether SOFABoot startup tasks use virtual threads when running on Java 21 or later.",
"defaultValue": false
}
],
"hints": [
{
"name": "sofa.boot.actuator.health.status.http-mapping.keys",
"values": [
{
"value": "UP",
"description": "Application is healthy."
},
{
"value": "DOWN",
"description": "Application is unhealthy."
},
{
"value": "OUT_OF_SERVICE",
"description": "Application is out of service."
},
{
"value": "UNKNOWN",
"description": "Application health is unknown."
}
]
},
{
"name": "sofa.boot.actuator.health.status.order",
"values": [
{
"value": "DOWN,OUT_OF_SERVICE,UNKNOWN,UP",
"description": "Default severity order used by Spring Boot health status aggregation."
}
]
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alipay.sofa.boot.actuator.autoconfigure;

import org.junit.jupiter.api.Test;
import org.springframework.boot.json.JsonParserFactory;
import org.springframework.core.io.ClassPathResource;
import org.springframework.util.StreamUtils;

import java.nio.charset.StandardCharsets;
import java.util.List;
import java.util.Map;

import static org.assertj.core.api.Assertions.assertThat;

public class ConfigurationMetadataTests {

private static final String ADDITIONAL_METADATA = "META-INF/additional-spring-configuration-metadata.json";

private static final String GENERATED_METADATA = "META-INF/spring-configuration-metadata.json";

@Test
void additionalMetadataShouldDescribeActuatorGroups() {
Map<String, Object> metadata = readMetadata(ADDITIONAL_METADATA);

assertThat(names(metadata, "groups")).contains("sofa.boot.actuator.health",
"sofa.boot.startup", "sofa.boot.startup.threads.virtual");
assertThat(items(metadata, "groups")).allSatisfy((group) -> assertThat(group)
.containsKeys("name", "description"));
}

@Test
void additionalMetadataShouldDefineCompletionPropertiesAndHints() {
Map<String, Object> metadata = readMetadata(ADDITIONAL_METADATA);

assertThat(names(metadata, "properties")).contains(
"sofa.boot.actuator.health.global-health-checker-timeout",
"sofa.boot.actuator.health.global-health-indicator-timeout",
"sofa.boot.actuator.health.parallel-check-timeout",
"sofa.boot.actuator.health.status.http-mapping",
"sofa.boot.startup.threads.virtual.enabled");
assertThat(names(metadata, "hints")).contains(
"sofa.boot.actuator.health.status.http-mapping.keys",
"sofa.boot.actuator.health.status.order");
}

@Test
void generatedMetadataShouldContainMergedAdditionalItems() {
Map<String, Object> metadata = readMetadata(GENERATED_METADATA);

assertThat(names(metadata, "properties")).contains(
"sofa.boot.actuator.health.global-health-checker-timeout",
"sofa.boot.actuator.health.global-health-indicator-timeout",
"sofa.boot.startup.threads.virtual.enabled");
assertThat(names(metadata, "hints")).contains(
"sofa.boot.actuator.health.status.http-mapping.keys",
"sofa.boot.actuator.health.status.order");
}

private Map<String, Object> readMetadata(String location) {
try {
ClassPathResource resource = new ClassPathResource(location);
assertThat(resource.exists()).as(location).isTrue();
String content = StreamUtils.copyToString(resource.getInputStream(),
StandardCharsets.UTF_8);
return JsonParserFactory.getJsonParser().parseMap(content);
} catch (Exception ex) {
throw new IllegalStateException("Failed to read " + location, ex);
}
}

private List<String> names(Map<String, Object> metadata, String itemName) {
return items(metadata, itemName).stream().map((item) -> (String) item.get("name")).toList();
}

@SuppressWarnings("unchecked")
private List<Map<String, Object>> items(Map<String, Object> metadata, String itemName) {
return (List<Map<String, Object>>) metadata.get(itemName);
}
}
Loading
Loading