@@ -38,7 +38,7 @@ void live_returnsUpStatus() {
3838 void ready_usesDatabaseAndRabbitmqIndicators () {
3939 HealthEndpoint healthEndpoint = healthEndpoint (Map .of (
4040 "db" , indicator (Status .UP , Map .of ("connections" , 12 )),
41- "rabbitmq " , indicator (Status .UP , Map .of ("host" , "localhost" ))
41+ "rabbit " , indicator (Status .UP , Map .of ("host" , "localhost" )) // Actuator 실제 키
4242 ));
4343 SystemHealthService systemHealthService = new SystemHealthService (healthEndpoint );
4444
@@ -54,7 +54,7 @@ void ready_usesDatabaseAndRabbitmqIndicators() {
5454 void health_includesDatabaseRabbitmqS3AndAiServer () {
5555 HealthEndpoint healthEndpoint = healthEndpoint (Map .of (
5656 "db" , indicator (Status .UP , Map .of ()),
57- "rabbitmq " , indicator (Status .DOWN , Map .of ("reachable" , false ))
57+ "rabbit " , indicator (Status .DOWN , Map .of ("reachable" , false )) // Actuator 실제 키
5858 ));
5959 SystemHealthService systemHealthService = new SystemHealthService (healthEndpoint );
6060
@@ -66,6 +66,44 @@ void health_includesDatabaseRabbitmqS3AndAiServer() {
6666 assertThat (response .components ().get ("aiServer" ).status ()).isEqualTo (Status .UNKNOWN .getCode ());
6767 }
6868
69+ /**
70+ * 응답 키와 Actuator 컴포넌트 키가 다르다는 사실 자체를 못 박는다.
71+ *
72+ * <p>운영에서 rabbitmq 가 영구 UNKNOWN 이었던 원인이 여기였다 — Actuator 는
73+ * {@code rabbitHealthContributor} 빈을 "rabbit" 으로 등록하는데 "rabbitmq" 로 조회했다.
74+ * 기존 테스트는 픽스처를 "rabbitmq" 로 등록해서 같은 실수를 그대로 재현하고 있었다.
75+ */
76+ @ Test
77+ void health_readsRabbitFromActuatorKeyNotResponseKey () {
78+ HealthEndpoint healthEndpoint = healthEndpoint (Map .of (
79+ "db" , indicator (Status .UP , Map .of ()),
80+ "rabbit" , indicator (Status .UP , Map .of ("version" , "3.13" ))
81+ ));
82+ SystemHealthService systemHealthService = new SystemHealthService (healthEndpoint );
83+
84+ var response = systemHealthService .ready ();
85+
86+ // 응답 키는 그대로 rabbitmq — 공개 계약은 바뀌지 않는다.
87+ assertThat (response .components ().get ("rabbitmq" ).status ()).isEqualTo (Status .UP .getCode ());
88+ assertThat (response .components ().get ("rabbitmq" ).details ()).containsEntry ("version" , "3.13" );
89+ assertThat (response .status ()).isEqualTo (Status .UP .getCode ());
90+ }
91+
92+ // Actuator 에 없는 이름으로 조회하면 UNKNOWN 이 된다 — 회귀 시 이 테스트가 아니라
93+ // 위 테스트가 깨지도록, 여기서는 '없을 때의 동작'만 확인한다.
94+ @ Test
95+ void health_reportsUnknownWhenActuatorHasNoSuchComponent () {
96+ HealthEndpoint healthEndpoint = healthEndpoint (Map .of (
97+ "db" , indicator (Status .UP , Map .of ())
98+ ));
99+ SystemHealthService systemHealthService = new SystemHealthService (healthEndpoint );
100+
101+ var response = systemHealthService .ready ();
102+
103+ assertThat (response .components ().get ("rabbitmq" ).status ()).isEqualTo (Status .UNKNOWN .getCode ());
104+ assertThat (response .status ()).isEqualTo (Status .UNKNOWN .getCode ());
105+ }
106+
69107 private static HealthEndpoint healthEndpoint (Map <String , HealthIndicator > indicators ) {
70108 HealthContributorRegistry registry = new DefaultHealthContributorRegistry ();
71109 indicators .forEach (registry ::registerContributor );
0 commit comments