# ----------
# $Id$
#
# Regression tests that create/drop the Citus extension in the regression database.
# This schedule includes both prerequisites these tests depend on and downstream tests that depend on them.
# These tests are separated from multi_1_schedule so that the tests remain in there
# do not change the version of the citus extension in regression database.
#
# Also the tests that assume a clean start after extension creation are moved here.
#
# ----------

# ---
# Tests around extension creation / upgrades.
# ---
test: multi_extension
test: multi_test_helpers multi_test_helpers_superuser
test: multi_cluster_management

# create_role_propagation expects the default password_encryption (scram-sha-256), so it runs
# before multi_metadata_sync, which sets password_encryption to md5 cluster-wide. It is kept in
# this schedule because the N-1 (previous minor) binary does not propagate the stored password
# verifier and N-1 targets skip check-multi-1-create-citus.
test: create_role_propagation
test: multi_create_fdw

# ---
# Prerequisites for multi_metadata_sync (from citus_tests/run_test.py)
# Tests need a clean start, such as multi_read_from_secondaries
# ---
test: alter_role_propagation
test: multi_test_catalog_views
test: multi_table_ddl
test: multi_sequence_default
test: multi_read_from_secondaries
test: alter_database_propagation

# ----------
# multi_replicate_reference_table tests replicating reference tables to new nodes after we add new nodes
# multi_remove_node_reference_table tests metadata changes after master_remove_node
# ----------
test: multi_replicate_reference_table
test: multi_remove_node_reference_table

# ----------
# Test for tenant statistics
# ----------
test: citus_stat_tenants

test: multi_modifying_xacts
test: multi_transaction_recovery

# ---
# multi_drop_extension makes sure we can safely drop and recreate the extension.
# ---
test: multi_drop_extension

# ---
# multi_metadata_sync tests the propagation of mx-related metadata changes to metadata workers.
# multi_metadata_sync_domain tests that metadata sync works correctly with DOMAIN types in non-public schemas
# ---
test: multi_metadata_sync
test: multi_metadata_sync_domain
test: metadata_replay_security

test: grant_on_function_propagation
test: grant_on_foreign_server_propagation

# ----------
# grant_on_schema_propagation tests if the GRANT ... ON SCHEMA queries are propagated correctly
# multi_schema_support makes sure we can work with tables in schemas other than public with no problem
# ----------
test: grant_on_schema_propagation
test: multi_schema_support


# ----------
# multi_colocation_utils tests utility functions written for co-location feature & internal API
# ----------
test: multi_colocation_utils

test: coordinator_shouldhaveshards
test: mx_regular_user

# ----------
# multi_multiuser tests simple combinations of permission access and queries
# ----------
test: multi_multiuser

# Don't parallelize stat_counters with others because we don't want statistics
# to be updated by other tests concurrently except Citus Maintenance Daemon.
#
# Also, this needs to be the first test that calls citus_stat_counters()
# because it checks the value of stats_reset column before calling the function.
test: stat_counters

test: function_propagation
test: citus_internal_distribute_object
test: drop_database
test: pg16
test: multi_transaction_recovery_multiple_databases

# Have this placeholder section at the end for the tests that need to be moved back
# to their original schedules with the next major version of Citus are listed below.
#
# These tests are kept here to prevent N-1 test failures for the features that are
# not present in the minor version.
# ---------------------------------------------------------------------------------

# ----------
# ----------
# multi_unsupported_worker_operations tests that unsupported operations error out on metadata workers
# ----------
test: multi_unsupported_worker_operations

# Don't parallelize the following two tests as they directly alter pg_dist_shardid_seq
# on the coordinator and restore it at the end.
# Will be moved back to multi_1_schedule at Citus 15.
test: schema_based_sharding_from_workers_a
test: schema_based_sharding_from_workers_b

# ----------
# citus_cluster_changes_block tests UDFs introduced in 13.3; not present in the
# N-1 (13.2-1) extension, so run it only under check-multi-1-create-citus which
# is not part of the N-1 test matrix. Move back to multi_schedule at Citus 14.
# ----------
test: citus_cluster_changes_block

# ----------
# allow_unsafe_insert_select_pushdown exercises the citus.allow_unsafe_insert_select_pushdown
# GUC introduced in 13.4; not present in the N-1 (13.2-1) Citus binary, so the SET errors out
# and the plans fall back under N-1. Run it only under check-multi-1-create-citus, which is not
# part of the N-1 test matrix. Move back to multi_schedule at Citus 14.
# ----------
test: allow_unsafe_insert_select_pushdown
test: extract_deparse

# ----------
# update_subscript_fetch_8987 covers an UPDATE .. SET crash (#8987); the N-1
# (13.4-1) coordinator library still segfaults on these statements, so this
# cannot run under the N-1 test matrix. Move to multi_schedule, next to
# subscripting_op, once the N-1 coordinator library has the fix.
# ----------
test: update_subscript_fetch_8987

# ----------
# multi_having_var_remapping covers a planner fix introduced in 13.5, absent from
# the N-1 (13.4.0) Citus binary. Keep these cases out of the N-1 test matrix;
# they remain part of multi_having_pushdown on main.
# ----------
test: multi_having_var_remapping

# ----------
# citus_use_authinfo covers a superuser check introduced in 13.5; not present
# in the N-1 (13.4-1) coordinator library. Run it only under
# check-multi-1-create-citus, which is not part of the N-1 test matrix.
# ----------
test: citus_use_authinfo

# PostgreSQL join-removal compatibility is absent from the N-1 Citus library.
# Move back to multi_1_schedule at Citus 14.
test: local_dist_join_removed_outer_join

# ----------
# insert_select_single_shard_table_8959 covers an INSERT ... SELECT crash
# (#8959) fixed in 14.3; the N-1 (14.2-1) coordinator library still segfaults
# or produces invalid worker SQL on these statements, so this cannot run under
# the N-1 test matrix. Move back to multi_1_schedule at Citus 15.
# ----------
test: insert_select_single_shard_table_8959

# ----------
# non_var_group_by covers the planner fix backported in 13.5; not present in
# the N-1 (13.4.0) coordinator library. Run it only under
# check-multi-1-create-citus, outside the N-1 matrix.
# Move back to multi_schedule at Citus 14.
# ----------
test: non_var_group_by

# ----------
# node_removal_transaction_recovery covers node removal behavior backported for
# 13.6; not present in the N-1 coordinator library. Run it only under
# check-multi-1-create-citus, which is not part of the N-1 test matrix.
# ----------
test: node_removal_transaction_recovery

# ----------
# insert_typmod_routing covers routing INSERTs by the distribution column
# value after the column's typmod is applied. The N-1 coordinator library
# routes a constant value before the typmod is applied, so this cannot run
# under the N-1 test matrix. Move to multi_1_schedule once the N-1 library has
# the fix.
# ----------
test: insert_typmod_routing
