This directory contains the generation script for small embedded DuckDB databases used for testing BenchBox functionality. The databases are created automatically during test execution and cleaned up afterwards.
basic_test.duckdb- Simple tables for connection and basic SQL testingtpch_test.duckdb- Minimal TPC-H benchmark tables with sample datatpcds_test.duckdb- Minimal TPC-DS benchmark tables with sample datassb_test.duckdb- Star Schema Benchmark tables with sample dataprimitives_test.duckdb- Tables for testing OLAP operations and window functions
- Size: Each database is kept small (< 5MB) for fast test execution
- Data: Contains minimal but representative data for testing functionality
- Schema: Follows the standard benchmark schemas but with reduced data volume
- Read-Only: Test fixtures open databases in read-only mode to prevent contamination
- Temporary: Created before tests run and cleaned up after tests complete
- Not Committed: Database files are excluded from git via .gitignore
These databases are accessed through fixtures defined in tests/fixtures/database_fixtures.py:
def test_example(tpch_test_db):
# Use the TPC-H test database
result = tpch_test_db.execute("SELECT COUNT(*) FROM customer").fetchone()
assert result[0] > 0Available fixtures:
basic_test_db- Connection to basic_test.duckdbtpch_test_db- Connection to tpch_test.duckdbtpcds_test_db- Connection to tpcds_test.duckdbssb_test_db- Connection to ssb_test.duckdbprimitives_test_db- Connection to primitives_test.duckdb
The test databases are managed automatically by the test framework:
- Creation: Databases are created before test sessions start (via
pytest_sessionstart) - On-Demand: If a database is missing during a test, it's created automatically
- Cleanup: All databases are removed after test sessions complete (via
pytest_sessionfinish)
If you need to create databases manually for debugging:
uv run -- python tests/databases/create_test_databases.pyThis will recreate all database files with fresh data.
- No Mocks: These databases eliminate the need for database mocking in tests
- Realistic Data: Provides actual SQL execution against real data
- Fast Tests: Small size ensures quick test execution
- Deterministic: Same data every time for consistent test results
- Isolated: Each test gets a fresh connection to prevent interference
- Reliability: Tests execute against real databases, catching SQL errors
- Performance: Small databases load quickly while providing realistic execution
- Maintainability: No complex mock setup and teardown logic
- Accuracy: Tests verify actual database behavior rather than mock behavior