-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat : adds health checks and testcase
- Loading branch information
1 parent
fffbc95
commit 65e1987
Showing
5 changed files
with
30 additions
and
17 deletions.
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
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
9 changes: 4 additions & 5 deletions
9
boot-opensearch-sample/src/main/resources/application-local.properties
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 |
---|---|---|
@@ -1,5 +1,4 @@ | ||
spring.datasource.driver-class-name=org.postgresql.Driver | ||
spring.datasource.url=jdbc:postgresql://localhost:5432/appdb | ||
spring.datasource.username=appuser | ||
spring.datasource.password=secret | ||
|
||
################ opensearch ##################### | ||
opensearch.uris=http://localhost:9200 | ||
opensearch.username=admin | ||
opensearch.password=D3v3l0p-ment |
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
21 changes: 20 additions & 1 deletion
21
boot-opensearch-sample/src/test/java/com/example/opensearch/ApplicationIntegrationTest.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 |
---|---|---|
@@ -1,10 +1,29 @@ | ||
package com.example.opensearch; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import com.example.opensearch.common.AbstractIntegrationTest; | ||
import com.fasterxml.jackson.databind.JsonNode; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import org.junit.jupiter.api.Test; | ||
import org.opensearch.client.Request; | ||
import org.opensearch.client.Response; | ||
import org.opensearch.client.RestClient; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
|
||
class ApplicationIntegrationTest extends AbstractIntegrationTest { | ||
|
||
@Autowired private RestClient restClient; | ||
|
||
@Test | ||
void contextLoads() {} | ||
void restClientOpenSearchNodeVersion() throws IOException { | ||
final Request request = new Request("GET", "/"); | ||
final Response response = restClient.performRequest(request); | ||
try (InputStream input = response.getEntity().getContent()) { | ||
JsonNode result = new ObjectMapper().readTree(input); | ||
assertThat(result.path("version").path("number").asText()).isEqualTo("2.16.0"); | ||
} | ||
} | ||
} |