Skip to content

Add PostgreSQL support for CI testing - #69

Draft
sjha4 wants to merge 7 commits into
Katello:mainfrom
sjha4:postgres-testing
Draft

sjha4 wants to merge 7 commits into
Katello:mainfrom
sjha4:postgres-testing

Conversation

@sjha4

@sjha4 sjha4 commented Sep 3, 2026

Copy link
Copy Markdown
Member

Updates test suite to use PostgreSQL in CI environments while maintaining SQLite for local development. This provides better production parity in automated tests and catches database-specific issues earlier.

Changes:

  • Configure DATABASE_URL in test_helper.rb (Postgres in CI, SQLite locally)
  • Update all test files to use ENV['DATABASE_URL'] instead of hardcoded SQLite
  • Add proper database cleanup in setup/teardown methods
  • Configure CI workflow to use PostgreSQL service
  • Update README with instructions for running tests with both databases

The test suite remains backward compatible - developers can continue using SQLite by default or opt into PostgreSQL testing via DATABASE_URL.

Updates test suite to use PostgreSQL in CI environments while maintaining
SQLite for local development. This provides better production parity in
automated tests and catches database-specific issues earlier.

Changes:
- Configure DATABASE_URL in test_helper.rb (Postgres in CI, SQLite locally)
- Update all test files to use ENV['DATABASE_URL'] instead of hardcoded SQLite
- Add proper database cleanup in setup/teardown methods
- Configure CI workflow to use PostgreSQL service
- Update README with instructions for running tests with both databases

The test suite remains backward compatible - developers can continue using
SQLite by default or opt into PostgreSQL testing via DATABASE_URL.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
sjha4 and others added 6 commits September 3, 2026 18:17
The theforeman/actions reusable workflow doesn't support a database
parameter, which caused the initial CI run to fail with a startup error.
This commit replaces the reusable workflow with a custom test job that
properly sets up PostgreSQL as a service container.

Changes:
- Add PostgreSQL 15 service container with health checks
- Set DATABASE_URL environment variable for tests
- Use ruby/setup-ruby with bundler-cache for faster builds
- Keep rubocop job using theforeman/actions reusable workflow

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Set CI=true and RACK_ENV=test explicitly
- Add step to list test files before running
- Add echo statements to show test execution progress

This will help diagnose why not all tests appear to be running.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Verify PostgreSQL connection before running tests
- Attempt to load each test file individually to identify failures
- Continue on error to see which files fail to load

This will help identify why only 1 of 3 test files is running.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
The require statements inside the class bodies were preventing the test
classes from being fully defined, causing those tests to be skipped.
Moving them to the top of the file (like integration_test.rb) fixes this.

This should make all tests run instead of just integration_test.rb.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Remove extra empty line at the beginning of the class body.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Tests are now fixed, so remove the debugging steps and run tests directly.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@sjha4
sjha4 marked this pull request as draft September 3, 2026 18:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant