Skip to content

Commit 0f833d2

Browse files
committed
try to fix health check
1 parent aa02f2e commit 0f833d2

File tree

5 files changed

+43
-16
lines changed

5 files changed

+43
-16
lines changed

server/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<dependency>
2121
<groupId>io.github.mucsi96</groupId>
2222
<artifactId>kubetools</artifactId>
23-
<version>1.18-SNAPSHOT</version>
23+
<version>1.19-SNAPSHOT</version>
2424
</dependency>
2525
<dependency>
2626
<groupId>org.springframework.boot</groupId>

server/src/main/resources/application-prod.yml

+7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
management:
2+
server:
3+
port: ${SPRING_ACTUATOR_PORT}
4+
endpoints:
5+
web:
6+
exposure:
7+
include: "*"
18
spring:
29
boot:
310
admin:

server/src/main/resources/application.yml

+6-12
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
server:
22
forward-headers-strategy: framework
33
shutdown: graceful
4+
management:
5+
endpoint:
6+
health:
7+
show-details: always
8+
probes:
9+
enabled: true
410
spring:
511
security:
612
oauth2:
@@ -28,18 +34,6 @@ spring:
2834
properties:
2935
hibernate:
3036
dialect: org.hibernate.dialect.PostgreSQLDialect
31-
management:
32-
server:
33-
port: ${SPRING_ACTUATOR_PORT}
34-
endpoints:
35-
web:
36-
exposure:
37-
include: "*"
38-
endpoint:
39-
health:
40-
show-details: always
41-
probes:
42-
enabled: true
4337
logging:
4438
level:
4539
com:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package mucsi96.traininglog;
2+
3+
import static org.assertj.core.api.Assertions.assertThat;
4+
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
5+
6+
import org.junit.jupiter.api.Test;
7+
import org.springframework.mock.web.MockHttpServletResponse;
8+
9+
import com.jayway.jsonpath.DocumentContext;
10+
import com.jayway.jsonpath.JsonPath;
11+
12+
public class HealthTest extends BaseIntegrationTest {
13+
14+
@Test
15+
void retunrs_status() throws Exception {
16+
MockHttpServletResponse response = mockMvc.perform(get("/actuator/health/liveness")).andReturn().getResponse();
17+
18+
assertThat(response.getStatus()).isEqualTo(200);
19+
DocumentContext body = JsonPath.parse(response.getContentAsString());
20+
assertThat(body.read("$.status", String.class)).isEqualTo("UP");
21+
}
22+
}

server/src/test/resources/application.yml

+7-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
server:
22
forward-headers-strategy: framework
3+
management:
4+
endpoint:
5+
health:
6+
show-details: always
7+
probes:
8+
enabled: true
39
spring:
410
autoconfigure:
511
exclude:
@@ -27,7 +33,5 @@ spring:
2733
show-sql: true
2834
properties:
2935
hibernate:
36+
dialect: org.hibernate.dialect.H2Dialect
3037
format-sql: true
31-
management:
32-
server:
33-
port: 8082

0 commit comments

Comments
 (0)