citus/src/test/regress
Onur Tirtir 1b7b2ecf37 Fall-back to seq-scan when accessing columnar metadata if the index doesn't exist
Fixes #6570.

In the past, having columnar tables in the cluster was causing pg
upgrades to fail when attempting to access columnar metadata. This is
because, pg_dump doesn't see objects that we use for columnar-am related
booking as the dependencies of the tables using columnar-am.
To fix that; in #5456, we inserted some "normal dependency" edges (from
those objects to columnar-am) into pg_depend.

This helped us ensuring the existency of a class of metadata objects
--such as columnar.storageid_seq-- and helped fixing #5437.

However, the normal-dependency edges that we added for indexes on
columnar metadata tables --such columnar.stripe_pkey-- didn't help at
all because they were indeed causing dependency loops (#5510) and
pg_dump was not able to take those dependency edges into the account.

For this reason, instead of inserting such dependency edges from indexes
to columnar-am, we allow columnar metadata accessors to fall-back to
sequential scan during pg upgrades.

(cherry picked from commit 1c51ddae49)
2023-01-30 18:55:42 +03:00
..
bin Feature: run rebalancer in the background (#6215) 2022-09-12 20:46:53 +03:00
citus_tests Always copy normalized files after a regress run (#6254) 2022-08-30 07:15:29 +00:00
data
expected Fall-back to seq-scan when accessing columnar metadata if the index doesn't exist 2023-01-30 18:55:42 +03:00
mitmscripts Fix flakyness in failure_connection_establishment (#6226) 2022-08-23 15:04:20 +03:00
spec Tests moving a shard with RLS owned by nonbypassrls & nonsuperuser (#6369) 2022-10-12 15:14:44 +03:00
sql Fall-back to seq-scan when accessing columnar metadata if the index doesn't exist 2023-01-30 18:55:42 +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
Pipfile.lock
README.md
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 Add pg14->pg15 upgrade test for dist. triggers on part. tables (#6265) 2022-09-01 12:32:44 +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
before_pg_upgrade_schedule Add pg14->pg15 upgrade test for dist. triggers on part. tables (#6265) 2022-09-01 12:32:44 +03:00
columnar_isolation_schedule
columnar_schedule Fix flakyness in columnar_first_row_number test (#6192) 2022-08-18 15:32:57 +03:00
create_schedule
enterprise_failure_schedule 'Deferred Drop' and robust 'Shard Cleanup' for Splits. (#6258) 2022-09-06 12:11:20 -07:00
enterprise_isolation_logicalrep_1_schedule Tests moving a shard with RLS owned by nonbypassrls & nonsuperuser (#6369) 2022-10-12 15:14:44 +03: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 'Deferred Drop' and robust 'Shard Cleanup' for Splits. (#6258) 2022-09-06 12:11:20 -07:00
failure_base_schedule
failure_schedule Add non-blocking variant of create_distributed_table (#6087) 2022-08-30 15:35:40 +03:00
isolation_schedule Remove do_repair option from citus_copy_shard_placement (#6299) 2022-09-09 15:44:30 +02: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
mixed_before_citus_upgrade_schedule
multi_1_schedule Remove do_repair option from citus_copy_shard_placement (#6299) 2022-09-09 15:44:30 +02:00
multi_follower_schedule
multi_mx_schedule Fix crash when trying to replicate a ref table that is actually dropped (#6595) 2023-01-10 13:20:36 +03:00
multi_schedule Add tests for jsonpath changes on PG15 2022-10-12 15:13:08 +03:00
multi_schedule_hyperscale
multi_schedule_hyperscale_superuser
mx_base_schedule
mx_minimal_schedule Reduce setup time of check-minimal and check-minimal-mx (#6117) 2022-08-02 17:58:59 +03:00
operations_schedule Feature: run rebalancer in the background (#6215) 2022-09-12 20:46:53 +03:00
pg_regress_multi.pl Use Posix locale in the tests (#6261) 2022-08-29 12:52:03 +02:00
postgres_schedule
split_schedule 'Deferred Drop' and robust 'Shard Cleanup' for Splits. (#6258) 2022-09-06 12:11:20 -07:00
sql_base_schedule
sql_schedule

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.