Contents
PostgreSQL Regression Tests for ParadeDB
This directory contains regression tests for ParadeDB’s pg_search
extension.
Directory Structure
sql/
: Contains SQL script files that are executed during testingexpected/
: Contains expected output files for each testresults/
(ignored under git): Stores actual output files generated during test runscommon/
: Contains common setup and cleanup scripts used by multiple tests
Test Organization
Tests are organized into logical groups with a common prefix:
mixedff_
: Mixed Fast Fields testsmixedff_basic_*
: Basic mixed fast fields functionality testsmixedff_edgecases_*
: Edge cases and boundary condition testsmixedff_queries_*
: Tests for complex query featuresmixedff_advanced_*
: Tests for advanced features and optimizations
Each group uses its own setup and cleanup scripts from the common/
directory.
Adding New Tests
Step 1: Create SQL Test File
-
Name your test file using the appropriate prefix and sequence number (e.g.,
PREFIX_your_test.sql
) -
Start with the common setup script for your test group, e.g.,:
\i common/PREFIX_setup.sql
-
Add a descriptive header and echo statement:
-- Tests my new feature
-
Use deterministic data and ORDER BY clauses to ensure consistent results
-
End with the appropriate cleanup script, e.g.,:
\i common/PREFIX_cleanup.sql
Step 2: Generate Expected Output
Run your test to generate the expected output file:
cd pg_search
cargo pgrx regress --auto
Step 3: Verify the Expected Output
- Check the generated output file in
expected/PREFIX_your_test.out
- Ensure all queries return at least one row of data
- Verify that any EXPLAIN plans look reasonable
Running Tests
Run All Tests
cd pg_search
cargo pgrx regress
Run Specific Tests
cd pg_search
cargo pgrx regress pg17 PREFIX_your_test
Common Pitfalls
- Non-deterministic Results: Use fixed dates and ORDER BY clauses to ensure consistent results
- Missing Data: Verify that all test queries return at least one row of data
- Timing Variations: Use
COSTS OFF, TIMING OFF
in EXPLAIN to avoid timing-dependent output
Contributing New Tests
When contributing new tests:
- Follow the naming convention of existing tests
- Use the appropriate common setup/cleanup scripts
- Check that your test produces deterministic results
- Include metadata comments at the top of the file explaining what’s being tested