Skip to content

test: reuse testcontainers harness for condenser reconcile tests - #371

Merged
aivong-openhands merged 1 commit into
openhands-org-condenser-defaults-enterprise-20260909from
port-condenser-tests-to-harness
Sep 11, 2026
Merged

aivong-openhands merged 1 commit into
openhands-org-condenser-defaults-enterprise-20260909from
port-condenser-tests-to-harness

Conversation

@aivong-openhands

@aivong-openhands aivong-openhands commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

Ports the org condenser reconcile tests onto the existing testcontainers harness, per the discussion on #369.

Base is the openhands-org-condenser-defaults-enterprise-20260909 branch (#337), because the tests exercise OrgStore.reconcile_applicable_org_condenser_max_tokens, which only exists there. Merge this into #337.

What changed

  • Moved tests/integration/test_org_condenser_reconciliation_postgres.py → tests/unit/test_org_condenser_reconciliation.py.
  • Dropped the bespoke postgres_session_maker fixture (service container + POSTGRES_TEST_DATABASE_URL + Org.__table__.drop/create) in favour of the harness's async_session_maker fixture from tests/unit/conftest.py.
  • Removed the now-unused postgresql marker from pytest.ini.

The three test bodies and all assertions are unchanged — only the database plumbing was swapped.

Why

As discussed in #369: the harness async_session_maker already gives each test an isolated database cloned from the alembic upgrade head template. That means:

  • Higher fidelity — tests hit the real migrated schema (e.g. migration 108's server_default on org.agent_settings), not a schema hand-built from the model.
  • No parallel infra — the tests run under the existing py-tests workflow (which already installs --all-groups and starts the harness). No new workflow, no service container, no POSTGRES_TEST_DATABASE_URL.
  • No harness collision — this is what caused the original ModuleNotFoundError: No module named 'testcontainers'; it disappears entirely.

Verification

Ran locally against a real testcontainers postgres:16 (uv sync --locked --all-groups + uv run pytest tests/unit/test_org_condenser_reconciliation.py):

3 passed in 0.67s

Two follow-ups I could not do (token lacks the workflow OAuth scope)

  1. Delete .github/workflows/postgres-integration-tests.yml — it is now orphaned (it runs pytest -m postgresql tests/integration, and that directory/marker are gone). Until it is removed, its check on feat: PLTF-3553 Add org condenser max_tokens rollout configuration #337 will fail; the py-tests check is the one that now covers these tests.
  2. Close fix: skip testcontainers when POSTGRES_TEST_DATABASE_URL is set #369 — it was only a workaround for the harness collision this change eliminates.

This PR was created by an AI agent (OpenHands) on behalf of the user.


Enterprise server image for this PR:

ghcr.io/openhands/enterprise-server:sha-12d059d

Port the org condenser reconcile tests off the bespoke Postgres harness
(a GitHub service container + POSTGRES_TEST_DATABASE_URL, with the schema
hand-built via Org table metadata) and onto the existing testcontainers
harness fixtures in tests/unit/conftest.py.

The async_session_maker fixture already provides a per-test database
cloned from the alembic-migrated template, so the tests now exercise the
real schema (including migration 108 server_default on org.agent_settings)
instead of a model-derived one. They run under the existing py-tests
workflow with no new CI, service container, or POSTGRES_TEST_DATABASE_URL
wiring.

Verified locally against testcontainers postgres:16: all 3 tests pass.

Follow-ups that need the workflow OAuth scope (this automation cannot push
workflow files): delete .github/workflows/postgres-integration-tests.yml,
and close PR #369 which only worked around the old harness collision.

Co-authored-by: openhands <openhands@all-hands.dev>
@github-actions github-actions Bot added the type: test Adding or fixing tests label Sep 11, 2026
@aivong-openhands
aivong-openhands merged commit 686d477 into openhands-org-condenser-defaults-enterprise-20260909 Sep 11, 2026
9 of 10 checks passed
@aivong-openhands
aivong-openhands deleted the port-condenser-tests-to-harness branch September 11, 2026 15:56
@github-actions

Copy link
Copy Markdown

Coverage report

This PR does not seem to contain any modification to coverable code.

aivong-openhands added a commit that referenced this pull request Sep 11, 2026
)

* Add org condenser default rollout configuration

Co-authored-by: openhands <openhands@all-hands.dev>

* Add org condenser rollout regression tests

Co-authored-by: openhands <openhands@all-hands.dev>

* test: reuse testcontainers harness for condenser reconcile tests (#371)

Port the org condenser reconcile tests off the bespoke Postgres harness
(a GitHub service container + POSTGRES_TEST_DATABASE_URL, with the schema
hand-built via Org table metadata) and onto the existing testcontainers
harness fixtures in tests/unit/conftest.py.

The async_session_maker fixture already provides a per-test database
cloned from the alembic-migrated template, so the tests now exercise the
real schema (including migration 108 server_default on org.agent_settings)
instead of a model-derived one. They run under the existing py-tests
workflow with no new CI, service container, or POSTGRES_TEST_DATABASE_URL
wiring.

Verified locally against testcontainers postgres:16: all 3 tests pass.

Follow-ups that need the workflow OAuth scope (this automation cannot push
workflow files): delete .github/workflows/postgres-integration-tests.yml,
and close PR #369 which only worked around the old harness collision.

Co-authored-by: openhands <openhands@all-hands.dev>

* Delete .github/workflows/postgres-integration-tests.yml

---------

Co-authored-by: openhands <openhands@all-hands.dev>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: test Adding or fixing tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant