Skip to content

ci: back postgres test data dir with tmpfs to avoid test timeout#765

Merged
gabriel-samfira merged 1 commit into
cloudbase:mainfrom
cbartz:ci/postgres-tests-tmpfs
Jun 4, 2026
Merged

ci: back postgres test data dir with tmpfs to avoid test timeout#765
gabriel-samfira merged 1 commit into
cloudbase:mainfrom
cbartz:ci/postgres-tests-tmpfs

Conversation

@cbartz

@cbartz cbartz commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

What

Mount the PostgreSQL service container's data directory (/var/lib/postgresql/data) on tmpfs in the Go Tests (PostgreSQL) job.

options: >-
  --health-cmd pg_isready
  --health-interval 10s
  --health-timeout 5s
  --health-retries 5
  --tmpfs /var/lib/postgresql/data

Why

The Go Tests (PostgreSQL) job has been hitting the go test timeout and failing, unrelated to the PR under test:

panic: test timed out after 15m0s
	running tests:
		TestGithubTestSuite (1m59s)
FAIL	github.com/cloudbase/garm/database/sql	900.382s

The database/sql suite creates a fresh schema and runs the full migration for every test case (OpenTestPostgresDB -> CREATE SCHEMA -> migrateDB). On the default postgres:16 service container that DDL is fsync'd to disk, and the goroutine dump confirms the suite was stuck server-side in CreateTable on IO wait.

GitHub Actions service containers can't pass server flags like postgres -c fsync=off (there's no command field), so the data directory is moved to tmpfs instead. This keeps all of Postgres's I/O in RAM, making fsync effectively free. The database is ephemeral and recreated for every job, so trading durability for speed has no downside here, and it mirrors the fsync=off config already used for local Postgres test runs.

Measured locally on the database/sql package with the same flags CI uses (-race -parallel=4): ~562s disk-backed vs ~60s on tmpfs (~9x faster), tests still passing.

@gabriel-samfira

gabriel-samfira commented Jun 4, 2026

Copy link
Copy Markdown
Member

Hah! The psql tests finished well before the sqlite tests this time 😄

edit: Actually time is about the same. This is great!

@cbartz cbartz marked this pull request as ready for review June 4, 2026 11:23
@gabriel-samfira gabriel-samfira merged commit 561f351 into cloudbase:main Jun 4, 2026
5 checks passed
@gabriel-samfira

Copy link
Copy Markdown
Member

thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants