36/71
Sign inSign up free

807. Integration Tests Against a Real Database

medium 20 XP ~10 minHands-on lab

The integration tests of billing-service (job integration in /home/student/repos/billing-service/.github/workflows/ci.yml) need a PostgreSQL database. Today they fail because nothing is listening on localhost:5432.

Task

Give the integration job a service container named postgres that:

  • runs the image postgres:17,
  • is started with POSTGRES_USER=app, POSTGRES_PASSWORD=app and POSTGRES_DB=app_test,
  • publishes port 5432 on the runner as 5432,
  • has a health check with pg_isready (so the job waits until the database accepts connections).

The test step gets DATABASE_URL=postgres://app:app@localhost:5432/app_test as an environment variable.

About this machine

Ubuntu 24.04 with no internet access. You are student with passwordless sudo. The grader checks the final state of the machine, not the commands you typed. Values like names and ports are generated for you.

Teaching or writing about this? Embed this lab on your page

TerminalNot started

Your machine is ready to start

A fresh, isolated Ubuntu machine boots in a few seconds with the task already set up.

No account needed: 3 of 3 free tries left. Guest machines last 30 minutes.