From e15a94ec3b5f353959f795a4f375854e78685130 Mon Sep 17 00:00:00 2001 From: German Eichberger Date: Mon, 17 Mar 2025 21:14:53 +0000 Subject: [PATCH] Adds the necessary regress tests --- .../expected/multi_cluster_management.out | 24 +++++++++++++++++++ .../regress/sql/multi_cluster_management.sql | 6 +++++ 2 files changed, 30 insertions(+) diff --git a/src/test/regress/expected/multi_cluster_management.out b/src/test/regress/expected/multi_cluster_management.out index 3eb549ab5..e6634d5c6 100644 --- a/src/test/regress/expected/multi_cluster_management.out +++ b/src/test/regress/expected/multi_cluster_management.out @@ -25,6 +25,15 @@ SELECT citus_is_coordinator(); t (1 row) +-- I am primary node (fails beacuse not set in pg_dist) +select citus_is_primary_node(); +WARNING: could not find the current node in pg_dist_node +DETAIL: If this is the coordinator node, consider adding it into the metadata by using citus_set_coordinator_host() UDF. Otherwise, if you're going to use this node as a worker node for a new cluster, make sure to add this node into the metadata from the coordinator by using citus_add_node() UDF. + citus_is_primary_node +--------------------------------------------------------------------- + +(1 row) + -- make sure coordinator is always in metadata. SELECT citus_set_coordinator_host('localhost'); citus_set_coordinator_host @@ -32,6 +41,13 @@ SELECT citus_set_coordinator_host('localhost'); (1 row) +-- I am primary node +select citus_is_primary_node(); + citus_is_primary_node +--------------------------------------------------------------------- + t +(1 row) + -- workers are not coordinator SELECT result FROM run_command_on_workers('SELECT citus_is_coordinator()'); result @@ -40,6 +56,14 @@ SELECT result FROM run_command_on_workers('SELECT citus_is_coordinator()'); f (2 rows) +-- primary workers are primary node +SELECT result FROM run_command_on_workers('SELECT citus_is_primary_node()'); + result +--------------------------------------------------------------------- + t + t +(2 rows) + -- get the active nodes SELECT master_get_active_worker_nodes(); master_get_active_worker_nodes diff --git a/src/test/regress/sql/multi_cluster_management.sql b/src/test/regress/sql/multi_cluster_management.sql index 86fbd15b6..b6f432ddb 100644 --- a/src/test/regress/sql/multi_cluster_management.sql +++ b/src/test/regress/sql/multi_cluster_management.sql @@ -14,12 +14,18 @@ RESET citus.metadata_sync_mode; -- I am coordinator SELECT citus_is_coordinator(); +-- I am primary node +select citus.citus_is_primary_node(); + -- make sure coordinator is always in metadata. SELECT citus_set_coordinator_host('localhost'); -- workers are not coordinator SELECT result FROM run_command_on_workers('SELECT citus_is_coordinator()'); +-- primary workers are primary node +SELECT result FROM run_command_on_workers('SELECT citus_is_primary_node()'); + -- get the active nodes SELECT master_get_active_worker_nodes();