7536830f85
CI / push-validation (pull_request) Successful in 22s
CI / helm (pull_request) Successful in 31s
CI / build (pull_request) Successful in 45s
CI / quality (pull_request) Successful in 47s
CI / lint (pull_request) Successful in 55s
CI / typecheck (pull_request) Successful in 55s
CI / security (pull_request) Successful in 1m5s
CI / integration_tests (pull_request) Successful in 3m30s
CI / unit_tests (pull_request) Failing after 3m42s
CI / coverage (pull_request) Has been skipped
CI / docker (pull_request) Has been skipped
CI / status-check (pull_request) Failing after 3s
Cover previously-uncovered code paths added in the PostgreSQL backend PR: - UnitOfWork argument validation (empty URL, pool_size=0, max_overflow=-1, pool_recycle=-2) - dispose() with active engine (True branch) and without engine (False branch) - __enter__/__exit__ context manager protocol - psycopg2 ImportError path when psycopg2 is unavailable - settings.is_postgresql() except ValueError branch (server_mode + SQLite URL) ISSUES CLOSED: #1118
112 lines
4.7 KiB
Gherkin
112 lines
4.7 KiB
Gherkin
@phase1 @database @postgresql @server_mode
|
|
Feature: PostgreSQL Storage Backend for Server Mode
|
|
As a platform operator
|
|
I want CleverAgents to support PostgreSQL as its storage backend
|
|
So that server mode can handle multi-user collaborative access
|
|
|
|
Background:
|
|
Given I have imported the database infrastructure modules
|
|
|
|
# ── Settings & URL Selection ──────────────────────────────────────
|
|
|
|
@settings @database_url
|
|
Scenario: Default database URL is SQLite in local mode
|
|
Given I create settings with server_mode disabled
|
|
Then the resolved database URL should start with "sqlite"
|
|
|
|
@settings @database_url
|
|
Scenario: Server mode with default URL raises ValueError
|
|
Given I create settings with server_mode enabled
|
|
And the database_url is the default SQLite value
|
|
Then resolving the database URL should raise a ValueError
|
|
|
|
@settings @database_url
|
|
Scenario: Server mode with explicit PostgreSQL URL uses that URL
|
|
Given I create settings with server_mode enabled
|
|
And the database_url is "postgresql://myhost/mydb"
|
|
Then the resolved database URL should be "postgresql://myhost/mydb"
|
|
|
|
@settings @database_url
|
|
Scenario: is_postgresql returns True for PostgreSQL URLs
|
|
Given I create settings with server_mode enabled
|
|
And the database_url is "postgresql://localhost/cleveragents"
|
|
Then is_postgresql should return True
|
|
|
|
@settings @database_url
|
|
Scenario: is_postgresql returns False for SQLite URLs
|
|
Given I create settings with server_mode disabled
|
|
Then is_postgresql should return False
|
|
|
|
@settings @database_url
|
|
Scenario: is_postgresql returns False when server mode raises ValueError for SQLite URL
|
|
Given I create settings with server_mode enabled
|
|
And the database_url is the default SQLite value
|
|
Then is_postgresql should return False
|
|
|
|
# ── Pool Configuration ────────────────────────────────────────────
|
|
|
|
@settings @pool
|
|
Scenario: Default pool settings are appropriate for multi-user
|
|
Given I create settings with server_mode enabled
|
|
Then the db_pool_size should be 5
|
|
And the db_max_overflow should be 10
|
|
And the db_pool_recycle should be 1800
|
|
|
|
@settings @pool
|
|
Scenario: Pool settings can be overridden via environment
|
|
Given I create settings with custom pool configuration
|
|
| setting | value |
|
|
| db_pool_size | 20 |
|
|
| db_max_overflow | 30 |
|
|
| db_pool_recycle | 900 |
|
|
Then the db_pool_size should be 20
|
|
And the db_max_overflow should be 30
|
|
And the db_pool_recycle should be 900
|
|
|
|
# ── UnitOfWork Engine Creation ────────────────────────────────────
|
|
|
|
@engine @sqlite
|
|
Scenario: UnitOfWork creates SQLite engine for local mode
|
|
Given I create a UnitOfWork with URL "sqlite:///:memory:"
|
|
When I access the engine
|
|
Then the engine dialect should be "sqlite"
|
|
|
|
@engine @pool
|
|
Scenario: UnitOfWork passes pool parameters to non-SQLite engines
|
|
Given I create a UnitOfWork with URL "sqlite:///:memory:" and pool_size 8
|
|
Then the UnitOfWork pool_size should be 8
|
|
And the UnitOfWork max_overflow should be 10
|
|
And the UnitOfWork pool_recycle should be 1800
|
|
|
|
# ── ORM Model Dialect Compatibility ───────────────────────────────
|
|
|
|
@models @dialect
|
|
Scenario: ORM models use only dialect-agnostic column types
|
|
Given I inspect all ORM models from the Base metadata
|
|
Then no column should use a SQLite-specific type
|
|
And all columns should use standard SQLAlchemy types
|
|
|
|
@models @dialect
|
|
Scenario: ORM models define no raw SQL or sqlite3 imports
|
|
Given I read the models module source code
|
|
Then the source should not contain "sqlite3"
|
|
And the source should not contain "PRAGMA"
|
|
And the source should not contain "raw_sql"
|
|
|
|
@models @dialect
|
|
Scenario: All table names are valid PostgreSQL identifiers
|
|
Given I inspect all ORM models from the Base metadata
|
|
Then all table names should be valid SQL identifiers
|
|
|
|
# ── Migration Runner ──────────────────────────────────────────────
|
|
|
|
@migration
|
|
Scenario: Migration runner handles SQLite URLs
|
|
Given I create a MigrationRunner with URL "sqlite:///:memory:"
|
|
Then the migration runner database_url should start with "sqlite"
|
|
|
|
@migration
|
|
Scenario: Migration runner handles PostgreSQL URLs
|
|
Given I create a MigrationRunner with URL "postgresql://localhost/test"
|
|
Then the migration runner database_url should start with "postgresql"
|