Migrate Integration Tests from Shared Postgres Instance to Testcontainers #42

Open
opened 2026-06-25 21:58:10 +02:00 by kasun · 0 comments
Owner

Description:
Currently, Gitea Actions CI/CD pipeline runs integration tests (e.g., HomeboxIntegrationTest) by connecting directly to my live/shared Postgres container (postgres:5432/vaessl_test) via the host network. This creates a tight infrastructure coupling, risks data contamination between pipeline runs, and prevents us from running parallel builds safely.

I need to migrate the integration tests to use Testcontainers. This will allow Spring Boot to dynamically provision and tear down an isolated PostgreSQL Docker instance on-demand during the Gradle test task, eliminating the need for hardcoded database secrets and shared network configurations in our workflow files.

Acceptance Criteria:

[ ] Add Testcontainers dependencies (spring-boot-testcontainers, testcontainers:postgresql) to backend/build.gradle.kts.

[ ] Refactor existing database integration tests to use the @Testcontainers and @Container annotations.

[ ] Configure dynamic database property injection via @DynamicPropertySource so tests discover the ephemeral container's randomized port.

[ ] Remove hardcoded database environment variables (DB_URL, DB_USERNAME, DB_PASSWORD) from the Gitea Actions workflow YAML file.

[ ] Verify that the Build and Analyze job passes cleanly in Gitea without relying on an external, pre-configured database instance.

Description: Currently, Gitea Actions CI/CD pipeline runs integration tests (e.g., HomeboxIntegrationTest) by connecting directly to my live/shared Postgres container (postgres:5432/vaessl_test) via the host network. This creates a tight infrastructure coupling, risks data contamination between pipeline runs, and prevents us from running parallel builds safely. I need to migrate the integration tests to use Testcontainers. This will allow Spring Boot to dynamically provision and tear down an isolated PostgreSQL Docker instance on-demand during the Gradle test task, eliminating the need for hardcoded database secrets and shared network configurations in our workflow files. Acceptance Criteria: [ ] Add Testcontainers dependencies (spring-boot-testcontainers, testcontainers:postgresql) to backend/build.gradle.kts. [ ] Refactor existing database integration tests to use the @Testcontainers and @Container annotations. [ ] Configure dynamic database property injection via @DynamicPropertySource so tests discover the ephemeral container's randomized port. [ ] Remove hardcoded database environment variables (DB_URL, DB_USERNAME, DB_PASSWORD) from the Gitea Actions workflow YAML file. [ ] Verify that the Build and Analyze job passes cleanly in Gitea without relying on an external, pre-configured database instance.
kasun added the
Priority
High
2
Kind/Infrastructure
labels 2026-06-25 21:58:10 +02:00
kasun self-assigned this 2026-06-25 21:58:10 +02:00
kasun added this to the Initial features development project 2026-06-25 21:58:10 +02:00
Sign in to join this conversation.