Skip to content

Switch test suite from SQLite to PostgreSQL#12925

Draft
Copilot wants to merge 3 commits intomainfrom
copilot/update-test-suite-to-use-postgresql
Draft

Switch test suite from SQLite to PostgreSQL#12925
Copilot wants to merge 3 commits intomainfrom
copilot/update-test-suite-to-use-postgresql

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 9, 2026

SQLite doesn't support certain JSON field queries used in production, making those code paths untestable. Aligns test environment with production PostgreSQL.

Changes

  • readthedocs/settings/test.py — Replace SQLite with postgresql_psycopg2 for both default and telemetry databases; credentials via DB_USER/DB_PWD/DB_HOST env vars (defaults: docs_user/docs_pwd/localhost):

    "default": {
        "ENGINE": "django.db.backends.postgresql_psycopg2",
        "NAME": "test_docs_db",
        "USER": os.environ.get("DB_USER", "docs_user"),
        "PASSWORD": os.environ.get("DB_PWD", "docs_pwd"),
        "HOST": os.environ.get("DB_HOST", "localhost"),
        "PORT": "",
    },
  • tox.ini — Add DB_USER, DB_PWD, DB_HOST to passenv so they propagate into the tox virtualenv.

  • .circleci/config.yml — Add cimg/postgres:14.0 sidecar to tests, tests-search, and tests-proxito jobs; add a reusable wait-for-postgres command that polls readiness via pg_isready and explicitly creates the test_telemetry database (test_docs_db is created automatically via POSTGRES_DB); install postgresql-client in each affected job.

Generated by Copilot

Copilot AI linked an issue Apr 9, 2026 that may be closed by this pull request
Copilot AI changed the title [WIP] Update test suite to run with PostgreSQL Switch test suite from SQLite to PostgreSQL Apr 9, 2026
Copilot AI requested a review from humitos April 9, 2026 15:20
Copy link
Copy Markdown
Member

@humitos humitos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good so far... let's see if there are tests failing or not.

DB_USER: docs_user
DB_PWD: docs_pwd
DB_HOST: localhost
- image: 'cimg/postgres:14.0'
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- image: 'cimg/postgres:14.0'
- image: 'cimg/postgres:16.3'

We are using version 16.3 locally, so we should use the same if it's available.

DB_USER: docs_user
DB_PWD: docs_pwd
DB_HOST: localhost
- image: 'cimg/postgres:14.0'
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here.

Comment on lines +112 to +120
"HOST": os.environ.get("DB_HOST", "localhost"),
"PORT": "",
},
"telemetry": {
"ENGINE": "django.db.backends.sqlite3",
"NAME": os.path.join(self.SITE_ROOT, "telemetry.dev.db"),
"ENGINE": "django.db.backends.postgresql_psycopg2",
"NAME": "test_telemetry",
"USER": os.environ.get("DB_USER", "docs_user"),
"PASSWORD": os.environ.get("DB_PWD", "docs_pwd"),
"HOST": os.environ.get("DB_HOST", "localhost"),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Locally it runs in another container, so we need to use database as a host.

Suggested change
"HOST": os.environ.get("DB_HOST", "localhost"),
"PORT": "",
},
"telemetry": {
"ENGINE": "django.db.backends.sqlite3",
"NAME": os.path.join(self.SITE_ROOT, "telemetry.dev.db"),
"ENGINE": "django.db.backends.postgresql_psycopg2",
"NAME": "test_telemetry",
"USER": os.environ.get("DB_USER", "docs_user"),
"PASSWORD": os.environ.get("DB_PWD", "docs_pwd"),
"HOST": os.environ.get("DB_HOST", "localhost"),
"HOST": os.environ.get("DB_HOST", "database"),
"PORT": "",
},
"telemetry": {
"ENGINE": "django.db.backends.postgresql_psycopg2",
"NAME": "test_telemetry",
"USER": os.environ.get("DB_USER", "docs_user"),
"PASSWORD": os.environ.get("DB_PWD", "docs_pwd"),
"HOST": os.environ.get("DB_HOST", "database"),

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.

Use PostgreSQL to run the test suite

2 participants