Skip to content

Commit

Permalink
try to fix health check
Browse files Browse the repository at this point in the history
  • Loading branch information
mucsi96 committed Apr 5, 2023
1 parent aa02f2e commit 0f833d2
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 16 deletions.
2 changes: 1 addition & 1 deletion server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<dependency>
<groupId>io.github.mucsi96</groupId>
<artifactId>kubetools</artifactId>
<version>1.18-SNAPSHOT</version>
<version>1.19-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
Expand Down
7 changes: 7 additions & 0 deletions server/src/main/resources/application-prod.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
management:
server:
port: ${SPRING_ACTUATOR_PORT}
endpoints:
web:
exposure:
include: "*"
spring:
boot:
admin:
Expand Down
18 changes: 6 additions & 12 deletions server/src/main/resources/application.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
server:
forward-headers-strategy: framework
shutdown: graceful
management:
endpoint:
health:
show-details: always
probes:
enabled: true
spring:
security:
oauth2:
Expand Down Expand Up @@ -28,18 +34,6 @@ spring:
properties:
hibernate:
dialect: org.hibernate.dialect.PostgreSQLDialect
management:
server:
port: ${SPRING_ACTUATOR_PORT}
endpoints:
web:
exposure:
include: "*"
endpoint:
health:
show-details: always
probes:
enabled: true
logging:
level:
com:
Expand Down
22 changes: 22 additions & 0 deletions server/src/test/java/mucsi96/traininglog/HealthTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package mucsi96.traininglog;

import static org.assertj.core.api.Assertions.assertThat;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;

import org.junit.jupiter.api.Test;
import org.springframework.mock.web.MockHttpServletResponse;

import com.jayway.jsonpath.DocumentContext;
import com.jayway.jsonpath.JsonPath;

public class HealthTest extends BaseIntegrationTest {

@Test
void retunrs_status() throws Exception {
MockHttpServletResponse response = mockMvc.perform(get("/actuator/health/liveness")).andReturn().getResponse();

assertThat(response.getStatus()).isEqualTo(200);
DocumentContext body = JsonPath.parse(response.getContentAsString());
assertThat(body.read("$.status", String.class)).isEqualTo("UP");
}
}
10 changes: 7 additions & 3 deletions server/src/test/resources/application.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
server:
forward-headers-strategy: framework
management:
endpoint:
health:
show-details: always
probes:
enabled: true
spring:
autoconfigure:
exclude:
Expand Down Expand Up @@ -27,7 +33,5 @@ spring:
show-sql: true
properties:
hibernate:
dialect: org.hibernate.dialect.H2Dialect
format-sql: true
management:
server:
port: 8082

0 comments on commit 0f833d2

Please sign in to comment.