citus/src/test/regress
Marco Slot 43e4dd3808 Add a citus.internal_reserved_connections setting 2022-03-02 19:13:53 +01:00
..
bin Speed up test runs on WSL2 a lot (#5736) 2022-02-23 13:03:29 +01:00
citus_tests Enable local_shared_pool_size 5 in arbitrary configs test 2022-02-23 19:40:21 +01:00
data Columnar: use generate_series for test rather than load. (#5181) 2021-08-16 16:12:06 -07:00
expected Add a citus.internal_reserved_connections setting 2022-03-02 19:13:53 +01:00
input Start to propagate functions to worker nodes with 2022-02-18 13:56:51 +03:00
mitmscripts fluent.py: prefer simpler return based control flow in _accept rather than relying on raising an exception 2022-02-17 13:30:17 +00:00
output Use intermediate results for re-partition joins 2022-02-23 19:40:21 +01:00
spec Add a citus.internal_reserved_connections setting 2022-03-02 19:13:53 +01:00
sql Add a citus.internal_reserved_connections setting 2022-03-02 19:13:53 +01:00
.gitignore Remove copy into new append shard logic 2021-11-07 21:01:40 +01:00
Makefile Remove copy into new append shard logic 2021-11-07 21:01:40 +01:00
Pipfile Bump mitmproxy version (#5334) 2021-10-27 17:57:13 +02:00
Pipfile.lock Bump mitmproxy version (#5334) 2021-10-27 17:57:13 +02:00
README.md Update broken link for upgrade tests (#5408) 2021-12-02 15:25:36 +01:00
after_citus_upgrade_coord_schedule Add a new API for enabling Citus MX for clusters upgrading from earlier versions 2022-03-02 17:02:55 +01:00
after_pg_upgrade_schedule Skip deleting options if columnar.options is already dropped (#5458) 2021-11-12 12:30:09 +03:00
base_isolation_schedule Add base isolation schedule (#3784) 2020-04-24 12:38:37 +03:00
base_schedule Run failure_test_helpers in base schedule (#5559) 2021-12-23 12:54:12 +01:00
before_citus_upgrade_coord_schedule Add a new API for enabling Citus MX for clusters upgrading from earlier versions 2022-03-02 17:02:55 +01:00
before_pg_upgrade_schedule Turn metadata sync on in upgrade schedules 2021-12-08 10:19:02 +03:00
columnar_isolation_schedule Split columnar stripe reservation into two phases (#5188) 2021-09-02 11:49:14 +03:00
columnar_schedule Allow disabling node(s) when multiple failures happen 2021-12-01 10:19:48 +01:00
create_schedule Introduce citus_check_cluster_node_health UDF 2021-12-15 01:41:51 +03:00
failure_base_schedule Turn metadata sync on in base/minimal schedules 2021-12-08 13:34:41 +03:00
failure_schedule Enable MX for the remaining failure tests (#5606) 2022-01-07 17:24:31 +01:00
isolation_schedule Add a citus.internal_reserved_connections setting 2022-03-02 19:13:53 +01:00
log_test_times
minimal_schedule Fix check-minimal 2022-01-19 16:21:59 +01:00
mixed_after_citus_upgrade_schedule Turn metadata sync on in upgrade schedules 2021-12-08 10:19:02 +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 Allow unsafe triggers via a GUC 2022-02-21 22:45:17 -08:00
multi_follower_schedule Fix metadata sync fails on multi_follower_schedule 2021-12-08 13:07:37 +03:00
multi_mx_schedule Support foreign tables in MX (#5461) 2022-01-06 18:50:34 +03:00
multi_schedule (1) Functions will be delegated even when present in the scope of an explicit 2022-01-19 16:43:33 -08:00
multi_schedule_hyperscale Remove copy into new append shard logic 2021-11-07 21:01:40 +01:00
multi_schedule_hyperscale_superuser Remove copy into new append shard logic 2021-11-07 21:01:40 +01:00
mx_base_schedule Turn metadata sync on in base/minimal schedules 2021-12-08 13:34:41 +03:00
mx_minimal_schedule Turn metadata sync on in base/minimal schedules 2021-12-08 13:34:41 +03:00
operations_schedule Enable MX for rebalancer tests 2022-01-11 12:07:39 +01:00
pg_regress_multi.pl Hide shards from application_name's with a specific prefix 2022-01-18 15:20:55 +04:00
postgres_schedule Add an infrastructure to run same tests with arbitrary configs (#5316) 2021-10-12 14:24:19 +03:00
sql_base_schedule Remove base test as it is not useful anymore 2021-10-18 20:31:18 +03:00
sql_schedule Avoid round trips while fixing index names (#5549) 2021-12-27 10:29:37 +01:00
worker_schedule Enable binary encoding by default on PG14 2021-09-06 10:27:29 +02: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/citus_tests/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.