Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
'name': 'JVM'
'uses': 'JorisJonkers-dev/github-workflows/.github/workflows/jvm-ci.yml@v0.8.1'
'with':
'lint-gradle-args': ':api:detekt :api:ktlintCheck'
'lint-gradle-args': ':api:detektMain :api:detektTest :api:detektIntegrationTest :api:ktlintCheck'
'test-gradle-args': ':api:test :api:integrationTest :api:jacocoTestCoverageVerification :api:exportOpenApiSpec'
'secrets':
'packages-token': '${{ secrets.GITHUB_TOKEN }}'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,33 +18,37 @@ import org.springframework.web.context.WebApplicationContext
* HealthIntegrationTest but without security (knowledge-api 4a doesn't
* wire in spring-security yet).
*/
class HealthIntegrationTest : IntegrationTestBase() {
class HealthIntegrationTest
@Autowired
private lateinit var context: WebApplicationContext

private lateinit var mockMvc: MockMvc

private val objectMapper = jacksonObjectMapper()

@BeforeEach
fun setUp() {
mockMvc = MockMvcBuilders.webAppContextSetup(context).build()
}

@Test
fun `composite health returns 200 with status UP and a db contributor`() {
val result = mockMvc.get("/api/actuator/health").andReturn()

assertThat(result.response.status)
.describedAs("composite /api/actuator/health body=%s", result.response.contentAsString)
.isEqualTo(200)

val body = objectMapper.readTree(result.response.contentAsString)
assertThat(body["status"].asText()).isEqualTo("UP")

val components = body["components"] ?: body["details"] ?: error("no components: $body")
assertThat(components.fieldNames().asSequence().toList())
.describedAs("expected core infra contributors to be present: $body")
.contains("db", "ping")
constructor(
private val context: WebApplicationContext,
) : IntegrationTestBase() {
private lateinit var mockMvc: MockMvc

private val objectMapper = jacksonObjectMapper()

@BeforeEach
fun setUp() {
mockMvc = MockMvcBuilders.webAppContextSetup(context).build()
}

@Test
fun compositeHealthReturnsOkWithStatusUPAndADbContributor() {
val result = mockMvc.get("/api/actuator/health").andReturn()

assertThat(result.response.status)
.describedAs("composite /api/actuator/health body=%s", result.response.contentAsString)
.isEqualTo(
org.springframework.http.HttpStatus.OK
.value(),
)

val body = objectMapper.readTree(result.response.contentAsString)
assertThat(body["status"].asText()).isEqualTo("UP")

val components = body["components"] ?: body["details"] ?: error("no components: $body")
assertThat(components.fieldNames().asSequence().toList())
.describedAs("expected core infra contributors to be present: $body")
.contains("db", "ping")
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,11 @@ import org.testcontainers.rabbitmq.RabbitMQContainer
@Tag("integration")
@SpringBootTest
@Testcontainers
abstract class IntegrationTestBase {
@Autowired
private lateinit var dsl: DSLContext

open class IntegrationTestBase {
@AfterEach
fun resetSharedState() {
fun resetSharedState(
@Autowired dsl: DSLContext,
) {
dsl.execute(
"TRUNCATE TABLE kb_notes, kb_note_tags, kb_relations, kb_audit " +
"RESTART IDENTITY CASCADE",
Expand Down
Loading
Loading