Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Regression Tests Guide

Siwen edited this page Apr 25, 2025 · 1 revision

Overview

PostgreSQL regression tests are used to verify the correctness of features and catch regressions. These tests execute SQL scripts and compare the results with predefined .out files.

Each test should ensure isolation and repeatability using specific settings (see below).


Adding a New Test

Create a SQL file

Create your test file under the appropriate directory:

Include required collection settings

Each test file must begin with the following:

SET documentdb.next_collection_id TO <COLLECTION_ID>;
SET documentdb.next_collection_index_id TO <COLLECTION_INDEX_ID>;

Important Constraints:

  • CollectionId must be a multiple of 100 and you can get the next available number by validate_test_output.sh
  • CollectionId and CollectionIndexId must match

This ensures test isolation and repeatable results.


Add test to the schedule

Add the file name (without .sql) to the appropriate schedule file to include it in the make check run. For example:


Running Tests

Run a single test:

make check-minimal -C pg_documentdb EXTRA_TESTS=<test-name-without-extension>
# Example:
make check-minimal -C pg_documentdb EXTRA_TESTS=commands_delete

Review the result:

If it's a new test, you'll get a failure because there’s no expected .out file yet. One will be auto-created (and empty) in:

pg_documentdb/src/test/regress/expected/

If the output of your test looks as expected, copy the contents into the expected .out file.

cp pg_documentdb/src/test/regress/results/<your_test>.out pg_documentdb/src/test/regress/expected/<your_test>.out

Run all tests:

make check

Get the next collection ID

To avoid ID collisions and find the next available collection ID, run:

pg_documentdb/src/test/regress/validate_test_output.sh <pg_version>