citus/src/test/regress
Sait Talha Nisanci a3f11ac10c Add alternative output for multi-mx 2021-08-25 16:53:56 +03:00
..
bin Add alternative output for multi-mx 2021-08-25 16:53:56 +03:00
data Columnar: use generate_series for test rather than load. (#5181) 2021-08-16 16:12:06 -07:00
expected Add alternative output for multi-mx 2021-08-25 16:53:56 +03:00
input Not print metapage.reserved_offset in regression tests (#5168) 2021-08-23 11:07:10 +03:00
mitmscripts
output Not print metapage.reserved_offset in regression tests (#5168) 2021-08-23 11:07:10 +03:00
spec Bind seg version to 1.3 in isolation_textension_commands 2021-08-25 16:50:23 +03:00
sql Add alternative output for multi-mx 2021-08-25 16:53:56 +03:00
upgrade Add test for idempotency of citus_prepare_pg_upgrade 2021-07-08 12:24:51 +02:00
.gitignore Ignore temporary output files 2021-03-25 09:59:21 +03:00
Makefile Use correct test schedule name in columnar vg test target (#5027) 2021-06-18 11:31:16 +03:00
Pipfile Update failure test dependencies (#4284) 2020-11-17 19:16:08 +03:00
Pipfile.lock Bump jinja2 from 2.11.2 to 2.11.3 in /src/test/regress 2021-03-20 05:51:26 +00:00
README.md
after_citus_upgrade_coord_schedule Columnnar: metapage changes. (#4907) 2021-05-10 20:16:46 +03:00
after_pg_upgrade_schedule Columnar: pg_upgrade support (#4354) 2020-12-02 08:46:59 -08:00
base_isolation_schedule Add base isolation schedule (#3784) 2020-04-24 12:38:37 +03:00
base_schedule Move columnar test helpers to a separate file (#4908) 2021-04-16 18:56:21 +03:00
before_citus_upgrade_coord_schedule Columnnar: metapage changes. (#4907) 2021-05-10 20:16:46 +03:00
before_pg_upgrade_schedule Fix flaky test because of parallel metadata syncing (#5004) 2021-05-28 13:19:15 +03:00
columnar_isolation_schedule Support columnar table index builds with CONCURRENTLY option (#5032) 2021-07-09 13:44:58 +03:00
columnar_schedule Re-cost columnar table index paths 2021-08-02 11:16:37 +03:00
failure_base_schedule Adds multi_schedule_hyperscale schedule 2020-04-10 15:54:47 +03:00
failure_schedule Local node connection management 2020-12-03 14:16:13 +03:00
isolation_schedule Acquire AccessShareLock before updating table statistics (#5155) 2021-08-12 13:58:15 +03:00
log_test_times
minimal_schedule Move columnar test helpers to a separate file (#4908) 2021-04-16 18:56:21 +03:00
mixed_after_citus_upgrade_schedule Separate schedules for mixed mode and normal mode in upgrade (#4420) 2021-01-19 14:08:11 +03:00
mixed_before_citus_upgrade_schedule Separate schedules for mixed mode and normal mode in upgrade (#4420) 2021-01-19 14:08:11 +03:00
multi_1_schedule Add partition_wise_join to avoid big alternative output 2021-08-25 16:50:01 +03:00
multi_follower_schedule Remove task tracker executor (#3850) 2020-07-18 13:11:36 +03:00
multi_mx_schedule Introduce citus_internal_update_relation_colocation 2021-08-03 11:44:58 +02:00
multi_schedule Dropped columns do not diverge distribution column for partitioned tables 2021-08-06 13:36:12 +02:00
multi_schedule_hyperscale Fix a test in hyperscale schedule (#5042) 2021-06-17 13:40:05 +03:00
multi_schedule_hyperscale_superuser Fix a test in hyperscale schedule (#5042) 2021-06-17 13:40:05 +03:00
mx_base_schedule Adds multi_schedule_hyperscale schedule 2020-04-10 15:54:47 +03:00
mx_minimal_schedule Add a CI check to see if all tests are part of a schedule (#3959) 2020-07-03 11:34:55 +02:00
operations_schedule Not include to-be-deleted shards while finding shard placements 2021-06-28 13:05:31 +03:00
pg_regress_multi.pl Disable queryId calculation in our test suite 2021-08-25 16:52:07 +03:00
worker_schedule Remove task tracker executor (#3850) 2020-07-18 13:11:36 +03:00

README.md

How our testing works

We use the test tooling of postgres to run our tests. This tooling is very simple but effective. The basics it runs a series of .sql scripts, gets their output and stores that in results/$sqlfilename.out. It then compares the actual output to the expected output with a simple diff command:

diff results/$sqlfilename.out expected/$sqlfilename.out

Schedules

Which sql scripts to run is defined in a schedule file, e.g. multi_schedule, multi_mx_schedule.

Makefile

In our Makefile we have rules to run the different types of test schedules. You can run them from the root of the repository like so:

# e.g. the multi_schedule
make install -j9 && make -C src/test/regress/ check-multi

Take a look at the makefile for a list of all the testing targets.

Running a specific test

Often you want to run a specific test and don't want to run everything. You can use one of the following commands to do so:

# If your tests needs almost no setup you can use check-minimal
make install -j9 && make -C src/test/regress/ check-minimal EXTRA_TESTS='multi_utility_warnings'
# Often tests need some testing data, if you get missing table errors using
# check-minimal you should try check-base
make install -j9 && make -C src/test/regress/ check-base EXTRA_TESTS='with_prepare'
# Sometimes this is still not enough and some other test needs to be run before
# the test you want to run. You can do so by adding it to EXTRA_TESTS too.
make install -j9 && make -C src/test/regress/ check-base EXTRA_TESTS='add_coordinator coordinator_shouldhaveshards'

Normalization

The output of tests is sadly not completely predictable. Still we want to compare the output of different runs and error when the important things are different. We do this by not using the regular system diff to compare files. Instead we use src/test/regress/bin/diff which does the following things:

  1. Change the $sqlfilename.out file by running it through sed using the src/test/regress/bin/normalize.sed file. This does stuff like replacing numbers that keep changing across runs with an XXX string, e.g. portnumbers or transaction numbers.
  2. Backup the original output to $sqlfilename.out.unmodified in case it's needed for debugging
  3. Compare the changed results and expected files with the system diff command.

Updating the expected test output

Sometimes you add a test to an existing file, or test output changes in a way that's not bad (possibly even good if support for queries is added). In those cases you want to update the expected test output. The way to do this is very simple, you run the test and copy the new .out file in the results directory to the expected directory, e.g.:

make install -j9 && make -C src/test/regress/ check-minimal EXTRA_TESTS='multi_utility_warnings'
cp src/test/regress/{results,expected}/multi_utility_warnings.out

Adding a new test file

Adding a new test file is quite simple:

  1. Write the SQL file in the sql directory
  2. Add it to a schedule file, to make sure it's run in CI
  3. Run the test
  4. Check that the output is as expected
  5. Copy the .out file from results to expected

Isolation testing

See src/test/regress/spec/README.md

Upgrade testing

See src/test/regress/upgrade/README.md

Failure testing

See src/test/regress/mitmscripts/README.md

Perl test setup script

To automatically setup a citus cluster in tests we use our src/test/regress/pg_regress_multi.pl script. This sets up a citus cluster and then starts the standard postgres test tooling. You almost never have to change this file.