-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat/63 implement health endpoint #79
Merged
stephane-segning
merged 9 commits into
ADORSYS-GIS:main
from
mbunwe-victor:feat/63-implement-health-endpoint
Mar 19, 2024
Merged
Changes from 3 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
fa5ac7a
feat: configure the health and metrics endpoints
mbunwe-victor 6e39712
feat: implement unit test for the health endpoint
chendiblessing af4bb45
Update pom.xml
Awambeng e678f76
updated: pom.xml file
chendiblessing af52e46
Merge branch 'feat/63-implement-health-endpoint' of github.com:mbunwe…
chendiblessing 43ec660
fix: remove unneccessary file
Awambeng d886422
Update PowerPayBackendHealthTest.java
Awambeng dc89669
Add test case for handling server failures in health endpoint
Awambeng 653fb3d
fix test
Awambeng File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
...d/src/main/java/com/adorsys/gis/powerpay/powerpaybackend/controller/HealthController.java
stephane-segning marked this conversation as resolved.
Show resolved
Hide resolved
stephane-segning marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.adorsys.gis.powerpay.powerpaybackend.controller; | ||
|
||
import org.springframework.boot.actuate.health.Health; | ||
import org.springframework.stereotype.Component; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RestController | ||
@Component | ||
public class HealthController { | ||
|
||
@RequestMapping("/actuator/health") | ||
public Health testBackendHealth(){ | ||
return new Health.Builder().status("Up").build(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
management: | ||
endpoints: | ||
web: | ||
exposure: | ||
include: health, metrics | ||
endpoint: | ||
health: | ||
show-details: always |
24 changes: 24 additions & 0 deletions
24
...end/src/test/java/com/adorsys/gis/powerpay/powerpaybackend/PowerPayBackendHealthTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.adorsys.gis.powerpay.powerpaybackend; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; | ||
import org.springframework.test.context.ContextConfiguration; | ||
import org.springframework.test.web.servlet.MockMvc; | ||
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; | ||
import org.springframework.test.web.servlet.result.MockMvcResultMatchers; | ||
|
||
@WebMvcTest | ||
@ContextConfiguration(classes = { PowerPayBackendApplication.class }) | ||
public class PowerPayBackendHealthTest { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is testing the best case. You should also test the case the server is not sending 200 ok |
||
|
||
@Autowired | ||
private MockMvc mockMvc; | ||
|
||
@Test | ||
public void healthEndpointTest() throws Exception { | ||
mockMvc.perform(MockMvcRequestBuilders.get("/actuator/health")) | ||
.andExpect(MockMvcResultMatchers.status().isOk()) | ||
.andExpect(MockMvcResultMatchers.jsonPath("$.status").value("Up")); | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this change?