citus/src/test/regress
Jelte Fennema 895a484b39
Hopefully fix flakyeness in drop_partitioned_table (#6270)
Sometimes in CI our drop_partitioned_talbe test would fail with the
following error:

```diff
 NOTICE:  issuing SELECT worker_drop_distributed_table('drop_partitioned_table.child1')
 NOTICE:  issuing SELECT worker_drop_distributed_table('drop_partitioned_table.child1')
 NOTICE:  issuing DROP TABLE IF EXISTS drop_partitioned_table.child1_727001 CASCADE
-NOTICE:  issuing SELECT pg_catalog.citus_internal_delete_colocation_metadata(100047)
-NOTICE:  issuing SELECT pg_catalog.citus_internal_delete_colocation_metadata(100047)
+NOTICE:  issuing SELECT pg_catalog.citus_internal_delete_colocation_metadata(100046)
+NOTICE:  issuing SELECT pg_catalog.citus_internal_delete_colocation_metadata(100046)
 ROLLBACK;
 NOTICE:  issuing ROLLBACK
 NOTICE:  issuing ROLLBACK
```
Source: https://app.circleci.com/pipelines/github/citusdata/citus/26631/workflows/31536032-e1ba-493b-b12a-f40757f3a7d6/jobs/762170

For some reason the colocationid of the distributed partitioned table
would be one less than we expected. Why this happens I'm not sure, but
it seems fairly harmless that it does.

In an attempt to work around this flakyness I now reset the colocation
id sequence right before creating the table in question. This is good
practice in general, because it allows us to run the test successfully
using `check-minimal` and it also allows us to rerun it multiple times.
2022-08-30 12:21:16 +03:00
..
bin Pg15 support (#6085) 2022-08-24 17:59:17 +02:00
citus_tests Always copy normalized files after a regress run (#6254) 2022-08-30 07:15:29 +00:00
data Columnar: use generate_series for test rather than load. (#5181) 2021-08-16 16:12:06 -07:00
expected Hopefully fix flakyeness in drop_partitioned_table (#6270) 2022-08-30 12:21:16 +03:00
mitmscripts Fix flakyness in failure_connection_establishment (#6226) 2022-08-23 15:04:20 +03:00
spec Fix flakyness in isolation_distributed_deadlock_detection (#6240) 2022-08-26 12:03:40 +03:00
sql Hopefully fix flakyeness in drop_partitioned_table (#6270) 2022-08-30 12:21:16 +03:00
.gitignore Pg vanilla tests can be run with citus created. (#6018) 2022-08-11 12:53:22 +03:00
Makefile Increase isolation timeout because of shards splits (#6213) 2022-08-19 22:37:45 +03: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 Use citus_finish_citus_upgrade() in the tests 2022-06-13 13:15:15 +02:00
after_pg_upgrade_schedule Introduce citus_locks view 2022-07-21 03:06:57 +03:00
base_isolation_schedule Replace iso tester func only once (#5964) 2022-07-06 11:04:31 +03:00
base_schedule Fix errors in base_schedule (#6247) 2022-08-25 18:06:41 +02: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 Introduce citus_locks view 2022-07-21 03:06:57 +03:00
columnar_isolation_schedule Split columnar stripe reservation into two phases (#5188) 2021-09-02 11:49:14 +03:00
columnar_schedule Fix flakyness in columnar_first_row_number test (#6192) 2022-08-18 15:32:57 +03:00
create_schedule Improve nested execution checks and add GUC to disable 2022-05-20 18:55:43 +02:00
enterprise_failure_schedule Nonblocking tenant isolation is supported by using split api. (#6167) 2022-08-17 11:13:07 +03:00
enterprise_isolation_logicalrep_1_schedule Introduce Non-Blocking Shard Split Workflow 2022-08-04 16:32:38 +02:00
enterprise_isolation_logicalrep_2_schedule Replace iso tester func only once (#5964) 2022-07-06 11:04:31 +03:00
enterprise_isolation_logicalrep_3_schedule Enable binary logical replication for shard moves (#6017) 2022-08-23 16:38:00 +02:00
enterprise_isolation_schedule Nonblocking tenant isolation is supported by using split api. (#6167) 2022-08-17 11:13:07 +03:00
enterprise_schedule Nonblocking tenant isolation is supported by using split api. (#6167) 2022-08-17 11:13:07 +03:00
enterprise_split_schedule Introduce Non-Blocking Shard Split Workflow 2022-08-04 16:32:38 +02: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 Don't run any isolation tests in parallel (#6212) 2022-08-19 17:05:36 +02:00
json_table_select_only.out Support JSON_TABLE on PG 15 (#6241) 2022-08-24 19:11:18 +03:00
json_table_select_only_0.out Support JSON_TABLE on PG 15 (#6241) 2022-08-24 19:11:18 +03:00
log_test_times
minimal_schedule Reduce setup time of check-minimal and check-minimal-mx (#6117) 2022-08-02 17:58:59 +03: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 Add an allow_unsafe_constraints flag for constraints without distribution column (#6237) 2022-08-25 11:37:50 +03:00
multi_follower_schedule Fix metadata sync fails on multi_follower_schedule 2021-12-08 13:07:37 +03:00
multi_mx_schedule Add distributing lock command support 2022-05-20 12:28:07 +03:00
multi_schedule Support JSON_TABLE on PG 15 (#6241) 2022-08-24 19:11:18 +03: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 Reduce setup time of check-minimal and check-minimal-mx (#6117) 2022-08-02 17:58:59 +03:00
operations_schedule Support changing CPU priorities for backends and shard moves (#6126) 2022-08-16 13:07:17 +03:00
pg_regress_multi.pl Use Posix locale in the tests (#6261) 2022-08-29 12:52:03 +02:00
postgres_schedule Add an infrastructure to run same tests with arbitrary configs (#5316) 2021-10-12 14:24:19 +03:00
split_schedule Add worker_split_shard_release_dsm udf to release dynamic shared memory (#6248) 2022-08-26 18:27:32 +05:30
sql_base_schedule Remove base test as it is not useful anymore 2021-10-18 20:31:18 +03:00
sql_schedule Propagate dependent views upon distribution (#5950) 2022-05-26 14:23:45 +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/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.