테스트 코드 런타임 에러
- 동시성 처리 테스트 진행을 위해 재고 감소 로직 테스트 코드 작성 중 런타임 에러 발생
💡런타임 에러 내용
ConfigClientFailFastException: Could not locate PropertySource ... failing
ResourceAccessException: I/O error ... http://localhost:8888/... Connection refused
- 테스트가 @SpringBootTest로 ApplicationContext를 띄우는 순간 Spring Cloud Config Client가 설정을 가져오려고 http://localhost:8888/product-service/default 로 GET 요청을 보냄
- 그런데 localhost:8888(Config Server)가 안 떠있어서 Connection refused
Spring Cloud Config Client
💡Spring Cloud Config Client 란?
Spring Cloud Config provides client-side and server-side support for externalized configuration in a distributed system.
- Spring Cloud Config는 분산 시스템에서 외부화된 설정을 관리하기 위해 클라이언트 측과 서버 측 지원을 제공한다. (출처)
- Config Client는 애플리케이션 안에 포함되는 라이브러리이다.
- 애플리케이션이 시작될 때 외부 Config Server로부터 설정을 가져오는 역할을 한다.
요약
Spring Cloud Config Client는 애플리케이션 시작 시 외부 Config Server에서 설정을 로드하는 선택적 컴포넌트이며,
테스트 환경에서는 spring.cloud.config.enabled=false 또는 optional:configserver: 설정을 통해 로컬 설정만 사용하도록 구성할 수 있다.
어렵다.
참고 자료
1) Spring docs
https://docs.spring.io/spring-cloud-config/docs/current/reference/html/
Spring Cloud Config
Spring Cloud Config provides server-side and client-side support for externalized configuration in a distributed system. With the Config Server, you have a central place to manage external properties for applications across all environments. The concepts o
docs.spring.io
'Projects > HubEleven' 카테고리의 다른 글
| [리팩토링] 권한 별 기능 제한 로직 구현 (1) (업데이트 중..) (0) | 2026.01.07 |
|---|---|
| [리팩토링] Swagger Request DTO 메서드 충돌 트러블슈팅 (0) | 2026.01.06 |
| [동시성 처리] 재고 감소 통합 테스트 코드 3 - Test Fixture (0) | 2026.01.01 |
| [리팩토링] Stock 도메인 리팩토링 (2) (0) | 2025.12.27 |
| [리팩토링] Stock 도메인 리팩토링 (1) (0) | 2025.12.18 |