summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/test/regress/parallel_schedule3
-rw-r--r--src/test/regress/pg_regress.c679
2 files changed, 682 insertions, 0 deletions
diff --git a/src/test/regress/parallel_schedule b/src/test/regress/parallel_schedule
index 376f28d99a..2993f157c6 100644
--- a/src/test/regress/parallel_schedule
+++ b/src/test/regress/parallel_schedule
@@ -99,3 +99,6 @@ test: plancache limit plpgsql copy2 temp domain rangefuncs prepare without_oid c
# run stats by itself because its delay may be insufficient under heavy load
test: stats
+
+#Postgres-XC additional tests, they can be run in parallel
+test: xc_groupby xc_distkey xc_having xc_temp
diff --git a/src/test/regress/pg_regress.c b/src/test/regress/pg_regress.c
index 9fc9c1088f..1c463a6372 100644
--- a/src/test/regress/pg_regress.c
+++ b/src/test/regress/pg_regress.c
@@ -32,6 +32,25 @@
#include "getopt_long.h"
#include "pg_config_paths.h"
+#ifdef PGXC
+/*
+ * In Postgres-XC, a regression test check is run on 2 Coordinators
+ * and 2 Datanodes. Coordinator 1 is considered as being the default
+ * used in pg_regress.
+ * External connections are made to Coordinator 1.
+ * All connections to remote nodes are made from Coordinator 1.
+ * Here is the list of nodes identified with a unique ID.
+ */
+typedef enum
+{
+ PGXC_COORD_1,
+ PGXC_COORD_2,
+ PGXC_DATANODE_1,
+ PGXC_DATANODE_2,
+ PGXC_GTM
+} PGXCNodeTypeNum;
+#endif
+
/* for resultmap we need a list of pairs of strings */
typedef struct _resultmap
{
@@ -98,6 +117,27 @@ static bool nolocale = false;
static bool use_existing = false;
static char *hostname = NULL;
static int port = -1;
+#ifdef PGXC
+/*
+ * Additional port numbers for Coordinator 2 and Datanode 1&2
+ * Ports are chosen up to the default value which is 5432.
+ */
+static int port_coord2 = 5433;
+static int port_dn1 = 5434;
+static int port_dn2 = 5435;
+/*
+ * Poolers of coordinators 1 and 2 need an additional port value
+ * taken as the default value and the next value.
+ */
+static int co1_pooler_port = 6667;
+static int co2_pooler_port = 6668;
+/* Data folder of each node */
+const char *data_co1 = "data_co1"; /* Coordinator 1 */
+const char *data_co2 = "data_co2"; /* Coordinator 2 */
+const char *data_dn1 = "data_dn1"; /* Datanode 1 */
+const char *data_dn2 = "data_dn2"; /* Datanode 2 */
+const char *data_gtm = "data_gtm"; /* GTM */
+#endif
static bool port_specified_by_user = false;
static char *dlpath = PKGLIBDIR;
static char *user = NULL;
@@ -112,7 +152,16 @@ static char *difffilename;
static _resultmap *resultmap = NULL;
+#ifdef PGXC
+/* Additional PIDs for PGXC temporary nodes */
+static PID_TYPE coord1_pid = INVALID_PID;
+static PID_TYPE coord2_pid = INVALID_PID;
+static PID_TYPE dn1_pid = INVALID_PID;
+static PID_TYPE dn2_pid = INVALID_PID;
+static PID_TYPE gtm_pid = INVALID_PID;
+#else
static PID_TYPE postmaster_pid = INVALID_PID;
+#endif
static bool postmaster_running = false;
static int success_count = 0;
@@ -276,6 +325,95 @@ status_end(void)
fprintf(logfile, "\n");
}
+#ifdef PGXC
+/*
+ * Find data folder associated to node
+ */
+static
+const char *
+find_data_folder(PGXCNodeTypeNum node)
+{
+ const char *data_folder;
+
+ switch (node)
+ {
+ case PGXC_COORD_1:
+ data_folder = data_co1;
+ break;
+ case PGXC_COORD_2:
+ data_folder = data_co2;
+ break;
+ case PGXC_DATANODE_1:
+ data_folder = data_dn1;
+ break;
+ case PGXC_DATANODE_2:
+ data_folder = data_dn2;
+ break;
+ case PGXC_GTM:
+ data_folder = data_gtm;
+ break;
+ default:
+ /* Should not happen */
+ data_folder = NULL;
+ break;
+ }
+
+ return data_folder;
+}
+
+/*
+ * Stop GTM process
+ */
+static void
+stop_gtm(void)
+{
+ const char *data_folder = find_data_folder(PGXC_GTM);
+ int r;
+ char buf[MAXPGPATH * 2];
+
+ /* On Windows, system() seems not to force fflush, so... */
+ fflush(stdout);
+ fflush(stderr);
+
+ snprintf(buf, sizeof(buf),
+ SYSTEMQUOTE "\"%s/gtm_ctl\" stop -S gtm -D \"%s/%s\" -m fast" SYSTEMQUOTE,
+ bindir, temp_install, data_folder);
+ r = system(buf);
+ if (r != 0)
+ {
+ fprintf(stderr, _("\n%s: could not stop GTM: exit code was %d\n"),
+ progname, r);
+ exit(2); /* not exit_nicely(), that would be recursive */
+ }
+}
+
+/*
+ * Stop the given node
+ */
+static void
+stop_node(PGXCNodeTypeNum node)
+{
+ const char *data_folder = find_data_folder(node);
+ char buf[MAXPGPATH * 2];
+ int r;
+
+ /* On Windows, system() seems not to force fflush, so... */
+ fflush(stdout);
+ fflush(stderr);
+
+ snprintf(buf, sizeof(buf),
+ SYSTEMQUOTE "\"%s/pg_ctl\" stop -D \"%s/%s\" -s -m fast" SYSTEMQUOTE,
+ bindir, temp_install, data_folder);
+ r = system(buf);
+ if (r != 0)
+ {
+ fprintf(stderr, _("\n%s: could not stop postmaster: exit code was %d\n"),
+ progname, r);
+ exit(2); /* not exit_nicely(), that would be recursive */
+ }
+}
+#endif
+
/*
* shut down temp postmaster
*/
@@ -284,6 +422,20 @@ stop_postmaster(void)
{
if (postmaster_running)
{
+#ifdef PGXC
+ /*
+ * It is necessary to stop first the Coordinator 1,
+ * Then other nodes are stopped nicely.
+ * This is due to connection dependencies between nodes.
+ */
+ stop_node(PGXC_COORD_1);
+ stop_node(PGXC_COORD_2);
+ stop_node(PGXC_DATANODE_1);
+ stop_node(PGXC_DATANODE_2);
+
+ /* Stop GTM at the end */
+ stop_gtm();
+#else
/* We use pg_ctl to issue the kill and wait for stop */
char buf[MAXPGPATH * 2];
int r;
@@ -302,11 +454,455 @@ stop_postmaster(void)
progname, r);
exit(2); /* not exit_nicely(), that would be recursive */
}
+#endif
postmaster_running = false;
}
}
+#ifdef PGXC
+/*
+ * Handy subroutine for setting an environment variable "var" to "val"
+ */
+static void
+doputenv(const char *var, const char *val)
+{
+ char *s = malloc(strlen(var) + strlen(val) + 2);
+
+ sprintf(s, "%s=%s", var, val);
+ putenv(s);
+}
+
+/*
+ * Get node port of associated node
+ */
+static int
+get_port_number(PGXCNodeTypeNum node)
+{
+ switch (node)
+ {
+ case PGXC_COORD_1:
+ return port;
+ case PGXC_COORD_2:
+ return port_coord2;
+ case PGXC_DATANODE_1:
+ return port_dn1;
+ case PGXC_DATANODE_2:
+ return port_dn2;
+ default:
+ /* Should not happen */
+ return -1;
+ }
+}
+
+/*
+ * Get pooler port number
+ */
+static int
+get_pooler_port(PGXCNodeTypeNum node)
+{
+ switch (node)
+ {
+ case PGXC_COORD_1:
+ return co1_pooler_port;
+ case PGXC_COORD_2:
+ return co2_pooler_port;
+ case PGXC_DATANODE_1:
+ case PGXC_DATANODE_2:
+ default:
+ /* Should not happen */
+ return -1;
+ }
+}
+
+/*
+ * Set port number for given node
+ */
+static void
+set_port_number(PGXCNodeTypeNum node, int port_number)
+{
+ switch (node)
+ {
+ case PGXC_COORD_1:
+ port = port_number;
+ break;
+ case PGXC_COORD_2:
+ port_coord2 = port_number;
+ break;
+ case PGXC_DATANODE_1:
+ port_dn1 = port_number;
+ break;
+ case PGXC_DATANODE_2:
+ port_dn2 = port_number;
+ break;
+ default:
+ /* Should not happen */
+ break;
+ }
+}
+
+/*
+ * Calculate port number for given node.
+ * If node is main access point, set also environment variable PGPORT.
+ */
+static void
+calculate_node_port(PGXCNodeTypeNum node, bool is_main)
+{
+ int port_number, i;
+ char buf[MAXPGPATH * 4];
+
+ if (is_main)
+ {
+ char *pgport;
+
+ /*
+ * Try to respect environment setting
+ * or fallback to default
+ */
+ pgport = getenv("PGPORT");
+ if (!pgport)
+ port_number = get_port_number(node);
+ else
+ port_number = atoi(pgport);
+ }
+ else
+ {
+ /* Get port number for node */
+ port_number = get_port_number(node);
+ }
+
+ /*
+ * Check if there is a postmaster running already.
+ */
+ snprintf(buf, sizeof(buf),
+ SYSTEMQUOTE "\"%s/psql\" -p %d -X postgres <%s 2>%s" SYSTEMQUOTE,
+ bindir, port_number, DEVNULL, DEVNULL);
+
+ for (i = 0; i < 16; i++)
+ {
+ if (system(buf) == 0)
+ {
+
+ if ((is_main && port_specified_by_user) ||
+ i == 15)
+ {
+ fprintf(stderr, _("port %d apparently in use\n"), port);
+ if (!port_specified_by_user)
+ fprintf(stderr, _("%s: could not determine an available port\n"), progname);
+ fprintf(stderr, _("Specify an unused port using the --port option or shut down any conflicting PostgreSQL servers.\n"));
+ exit_nicely(2);
+ }
+
+ fprintf(stderr, _("port %d apparently in use, trying %d\n"),
+ port_number, port_number + 1);
+ port_number++;
+
+ if (is_main)
+ {
+ char s[16];
+
+ sprintf(s, "%d", port_number);
+ doputenv("PGPORT", s);
+ }
+ }
+ else
+ break;
+ }
+
+ /* Save static value of port for node */
+ set_port_number(node, port_number);
+}
+
+/*
+ * Set PID number for given node
+ */
+static void
+set_node_pid(PGXCNodeTypeNum node, PID_TYPE pid_number)
+{
+ switch (node)
+ {
+ case PGXC_COORD_1:
+ coord1_pid = pid_number;
+ break;
+ case PGXC_COORD_2:
+ coord2_pid = pid_number;
+ break;
+ case PGXC_DATANODE_1:
+ dn1_pid = pid_number;
+ break;
+ case PGXC_DATANODE_2:
+ dn2_pid = pid_number;
+ break;
+ case PGXC_GTM:
+ gtm_pid = pid_number;
+ break;
+ default:
+ /* Should not happen */
+ break;
+ }
+}
+
+/*
+ * Get PID number for given node
+ */
+static PID_TYPE
+get_node_pid(PGXCNodeTypeNum node)
+{
+ switch (node)
+ {
+ case PGXC_COORD_1:
+ return coord1_pid;
+ case PGXC_COORD_2:
+ return coord2_pid;
+ case PGXC_DATANODE_1:
+ return dn1_pid;
+ case PGXC_DATANODE_2:
+ return dn2_pid;
+ case PGXC_GTM:
+ return gtm_pid;
+ default:
+ /* Should not happen */
+ return -1;
+ }
+}
+
+/*
+ * Start GTM process
+ */
+static void
+start_gtm(void)
+{
+ char buf[MAXPGPATH * 4];
+ const char *data_folder = find_data_folder(PGXC_GTM);
+ PID_TYPE node_pid;
+
+ header(_("starting GTM process"));
+ snprintf(buf, sizeof(buf),
+ SYSTEMQUOTE "\"%s/gtm\" -D \"%s/%s\" -x 10000 > \"%s/log/gtm.log\" 2>&1" SYSTEMQUOTE,
+ bindir, temp_install, data_folder,
+ outputdir);
+
+ /* Start process */
+ node_pid = spawn_process(buf);
+ if (node_pid == INVALID_PID)
+ {
+ fprintf(stderr, _("\n%s: could not spawn GTM: %s\n"),
+ progname, strerror(errno));
+ exit_nicely(2);
+ }
+
+ /* Save static PID number */
+ set_node_pid(PGXC_GTM, node_pid);
+}
+
+/*
+ * Start given node
+ */
+static void
+start_node(PGXCNodeTypeNum node, bool is_coord, bool is_main)
+{
+ const char *data_folder = find_data_folder(node);
+ int port_number = get_port_number(node);
+ PID_TYPE node_pid;
+ char buf[MAXPGPATH * 4];
+
+ /* Start the node */
+ if (is_main)
+ snprintf(buf, sizeof(buf),
+ SYSTEMQUOTE "\"%s/postgres\" %s -i -p %d -D \"%s/%s\"%s -c \"listen_addresses=%s\" > \"%s/log/postmaster_%d.log\" 2>&1" SYSTEMQUOTE,
+ bindir,
+ is_coord ? "-C" : "-X",
+ port_number,
+ temp_install, data_folder,
+ debug ? " -d 5" : "",
+ hostname ? hostname : "",
+ outputdir,
+ node);
+ else
+ snprintf(buf, sizeof(buf),
+ SYSTEMQUOTE "\"%s/postgres\" %s -i -p %d -D \"%s/%s\"%s > \"%s/log/postmaster_%d.log\" 2>&1" SYSTEMQUOTE,
+ bindir,
+ is_coord ? "-C" : "-X",
+ port_number,
+ temp_install, data_folder,
+ debug ? " -d 5" : "",
+ outputdir,
+ node);
+
+ node_pid = spawn_process(buf);
+ if (node_pid == INVALID_PID)
+ {
+ fprintf(stderr, _("\n%s: could not spawn postmaster: %s\n"),
+ progname, strerror(errno));
+ exit_nicely(2);
+ }
+
+ /* Wait a little for full start */
+ pg_usleep(1000000L);
+
+ /* Save static PID number */
+ set_node_pid(node,node_pid);
+}
+
+/*
+ * Inistialize given node with initdb
+ */
+static void
+initdb_node(PGXCNodeTypeNum node)
+{
+ const char *data_folder = find_data_folder(node);
+ char buf[MAXPGPATH * 4];
+
+ snprintf(buf, sizeof(buf),
+ SYSTEMQUOTE "\"%s/initdb\" -D \"%s/%s\" -L \"%s\" --noclean%s%s > \"%s/log/initdb.log\" 2>&1" SYSTEMQUOTE,
+ bindir, temp_install, data_folder, datadir,
+ debug ? " --debug" : "",
+ nolocale ? " --no-locale" : "",
+ outputdir);
+ if (system(buf))
+ {
+ fprintf(stderr, _("\n%s: initdb failed\nExamine %s/log/initdb.log for the reason.\nCommand was: %s\n"), progname, outputdir, buf);
+ exit_nicely(2);
+ }
+}
+
+static void
+set_node_config_file(PGXCNodeTypeNum node)
+{
+ const char *data_folder = find_data_folder(node);
+ FILE *pg_conf;
+ char buf[MAXPGPATH * 4];
+
+ snprintf(buf, sizeof(buf), "%s/%s/postgresql.conf", temp_install, data_folder);
+ pg_conf = fopen(buf, "a");
+ if (pg_conf == NULL)
+ {
+ fprintf(stderr, _("\n%s: could not open \"%s\" for adding extra config: %s\n"), progname, buf, strerror(errno));
+ exit_nicely(2);
+ }
+ fputs("\n# Configuration added by pg_regress\n\n", pg_conf);
+
+ /*
+ * Cluster uses 2PC for write transactions involving multiple nodes
+ * This has to be set at least to a value corresponding to the maximum
+ * number of tests run in parallel.
+ */
+ fputs("max_prepared_transactions = 50\n", pg_conf);
+
+ /* Insert unique node ID, not 0 */
+ snprintf(buf, sizeof(buf), "pgxc_node_id = %d\n", node + 1);
+ fputs(buf, pg_conf);
+
+ if (temp_config != NULL)
+ {
+ FILE *extra_conf;
+ char line_buf[1024];
+
+ extra_conf = fopen(temp_config, "r");
+ if (extra_conf == NULL)
+ {
+ fprintf(stderr, _("\n%s: could not open \"%s\" to read extra config: %s\n"), progname, temp_config, strerror(errno));
+ exit_nicely(2);
+ }
+ while (fgets(line_buf, sizeof(line_buf), extra_conf) != NULL)
+ fputs(line_buf, pg_conf);
+ fclose(extra_conf);
+ }
+
+ fclose(pg_conf);
+}
+
+/*
+ * Set configuration file of given node
+ * depending on port numbers calculated.
+ */
+static void
+set_node_connection_config(PGXCNodeTypeNum node)
+{
+ const char *data_folder = find_data_folder(node);
+ FILE *pg_conf;
+ char buf[MAXPGPATH * 4];
+
+ /*
+ * Default connection is used for GTM (localhost:6666)
+ * PGXCTODO: Calculate GTM port dynamically.
+ */
+ snprintf(buf, sizeof(buf), "%s/%s/postgresql.conf", temp_install, data_folder);
+ pg_conf = fopen(buf, "a");
+ if (pg_conf == NULL)
+ {
+ fprintf(stderr, _("\n%s: could not open \"%s\" for adding connection config: %s\n"), progname, buf, strerror(errno));
+ exit_nicely(2);
+ }
+
+ fputs("#Connection parameters related to PGXC nodes\n", pg_conf);
+ fputs("num_data_nodes = 2\n", pg_conf);
+ fputs("num_coordinators = 2\n", pg_conf);
+
+ /* Coordinator connection parameters */
+ fputs("coordinator_hosts = 'localhost,localhost'\n", pg_conf);
+ snprintf(buf, sizeof(buf), "coordinator_ports = '%d,%d'\n",
+ get_port_number(PGXC_COORD_1),
+ get_port_number(PGXC_COORD_2));
+ fputs(buf, pg_conf);
+
+ /* Datanode connection parameters */
+ fputs("data_node_hosts = 'localhost,localhost'\n", pg_conf);
+ snprintf(buf, sizeof(buf), "data_node_ports = '%d,%d'\n",
+ get_port_number(PGXC_DATANODE_1),
+ get_port_number(PGXC_DATANODE_2));
+ fputs(buf, pg_conf);
+
+ /* Pooler port number */
+ snprintf(buf, sizeof(buf), "pooler_port = %d\n",
+ get_pooler_port(node));
+ fputs(buf, pg_conf);
+
+ fclose(pg_conf);
+}
+
+/*
+ * Check if given node has failed during startup
+ */
+static void
+check_node_fail(PGXCNodeTypeNum node)
+{
+ PID_TYPE pid_number = get_node_pid(node);
+
+#ifndef WIN32
+ if (kill(pid_number, 0) != 0)
+#else
+ if (WaitForSingleObject(pid_number, 0) == WAIT_OBJECT_0)
+#endif /* WIN32 */
+ {
+ fprintf(stderr, _("\n%s: postmaster failed\nExamine %s/log/postmaster_%d.log for the reason\n"), progname, outputdir, node);
+ exit_nicely(2);
+ }
+}
+
+/*
+ * Kill given node but do not exit
+ */
+static void
+kill_node(PGXCNodeTypeNum node)
+{
+ PID_TYPE pid_number = get_node_pid(node);
+
+ fprintf(stderr, _("\n%s: postmaster did not respond within 60 seconds\nExamine %s/log/postmaster_%d.log for the reason\n"), progname, outputdir, node);
+
+#ifndef WIN32
+ if (kill(pid_number, SIGKILL) != 0 &&
+ errno != ESRCH)
+ fprintf(stderr, _("\n%s: could not kill failed postmaster: %s\n"),
+ progname, strerror(errno));
+#else
+ if (TerminateProcess(pid_number, 255) == 0)
+ fprintf(stderr, _("\n%s: could not kill failed postmaster: %lu\n"),
+ progname, GetLastError());
+#endif
+}
+#endif
+
/*
* Always exit through here, not through plain exit(), to ensure we make
* an effort to shut down a temp postmaster
@@ -658,6 +1254,7 @@ get_expectfile(const char *testname, const char *file)
return NULL;
}
+#ifndef PGXC
/*
* Handy subroutine for setting an environment variable "var" to "val"
*/
@@ -669,6 +1266,7 @@ doputenv(const char *var, const char *val)
sprintf(s, "%s=%s", var, val);
putenv(s);
}
+#endif
/*
* Set the environment variable "pathname", prepending "addval" to its
@@ -2091,7 +2689,9 @@ regression_main(int argc, char *argv[], init_function ifunc, test_function tfunc
if (temp_install)
{
+#ifndef PGXC
FILE *pg_conf;
+#endif
_stringlist *sl;
/*
@@ -2155,6 +2755,13 @@ regression_main(int argc, char *argv[], init_function ifunc, test_function tfunc
/* initdb */
header(_("initializing database system"));
+#ifdef PGXC
+ /* Initialize nodes */
+ initdb_node(PGXC_COORD_1);
+ initdb_node(PGXC_COORD_2);
+ initdb_node(PGXC_DATANODE_1);
+ initdb_node(PGXC_DATANODE_2);
+#else
snprintf(buf, sizeof(buf),
SYSTEMQUOTE "\"%s/initdb\" -D \"%s/data\" -L \"%s\" --noclean%s%s > \"%s/log/initdb.log\" 2>&1" SYSTEMQUOTE,
bindir, temp_install, datadir,
@@ -2166,6 +2773,7 @@ regression_main(int argc, char *argv[], init_function ifunc, test_function tfunc
fprintf(stderr, _("\n%s: initdb failed\nExamine %s/log/initdb.log for the reason.\nCommand was: %s\n"), progname, outputdir, buf);
exit_nicely(2);
}
+#endif
/*
* Adjust the default postgresql.conf as needed for regression
@@ -2175,6 +2783,17 @@ regression_main(int argc, char *argv[], init_function ifunc, test_function tfunc
* don't set max_prepared_transactions any higher than actually needed
* by the prepared_xacts regression test.)
*/
+
+#ifdef PGXC
+ /*
+ * Update configuration file of each node with user-defined options
+ * and 2PC related information.
+ */
+ set_node_config_file(PGXC_COORD_1);
+ set_node_config_file(PGXC_COORD_2);
+ set_node_config_file(PGXC_DATANODE_1);
+ set_node_config_file(PGXC_DATANODE_2);
+#else
snprintf(buf, sizeof(buf), "%s/data/postgresql.conf", temp_install);
pg_conf = fopen(buf, "a");
if (pg_conf == NULL)
@@ -2202,7 +2821,15 @@ regression_main(int argc, char *argv[], init_function ifunc, test_function tfunc
}
fclose(pg_conf);
+#endif
+#ifdef PGXC
+ /* Determine port numbers for nodes */
+ calculate_node_port(PGXC_COORD_1, true);
+ calculate_node_port(PGXC_COORD_2, false);
+ calculate_node_port(PGXC_DATANODE_1, false);
+ calculate_node_port(PGXC_DATANODE_2, false);
+#else
/*
* Check if there is a postmaster running already.
*/
@@ -2233,11 +2860,33 @@ regression_main(int argc, char *argv[], init_function ifunc, test_function tfunc
else
break;
}
+#endif
+
+#ifdef PGXC
+ /*
+ * Add extra connection information for Coordinator 1
+ * Readjust conf file of Coordinator 1 with correct connection parameters.
+ * This is not necessary for Coordinator 2 as only the 1st one is used as remote for
+ * regression tests.
+ */
+ set_node_connection_config(PGXC_COORD_1);
+ set_node_connection_config(PGXC_COORD_2);
+#endif
/*
* Start the temp postmaster
*/
header(_("starting postmaster"));
+#ifdef PGXC
+ /* Start GTM */
+ start_gtm();
+
+ /* Start all the nodes */
+ start_node(PGXC_COORD_1, true, true);
+ start_node(PGXC_COORD_2, true, false);
+ start_node(PGXC_DATANODE_1, false, false);
+ start_node(PGXC_DATANODE_2, false, false);
+#else
snprintf(buf, sizeof(buf),
SYSTEMQUOTE "\"%s/postgres\" -D \"%s/data\" -F%s -c \"listen_addresses=%s\" > \"%s/log/postmaster.log\" 2>&1" SYSTEMQUOTE,
bindir, temp_install,
@@ -2251,6 +2900,7 @@ regression_main(int argc, char *argv[], init_function ifunc, test_function tfunc
progname, strerror(errno));
exit_nicely(2);
}
+#endif
/*
* Wait till postmaster is able to accept connections (normally only a
@@ -2263,6 +2913,13 @@ regression_main(int argc, char *argv[], init_function ifunc, test_function tfunc
if (system(buf2) == 0)
break;
+#ifdef PGXC
+ /* Check node failure */
+ check_node_fail(PGXC_COORD_1);
+ check_node_fail(PGXC_COORD_2);
+ check_node_fail(PGXC_DATANODE_1);
+ check_node_fail(PGXC_DATANODE_2);
+#else
/*
* Fail immediately if postmaster has exited
*/
@@ -2275,11 +2932,19 @@ regression_main(int argc, char *argv[], init_function ifunc, test_function tfunc
fprintf(stderr, _("\n%s: postmaster failed\nExamine %s/log/postmaster.log for the reason\n"), progname, outputdir);
exit_nicely(2);
}
+#endif /* PGXC */
pg_usleep(1000000L);
}
if (i >= 60)
{
+#ifdef PGXC
+ /* If one node fails, all fail */
+ kill_node(PGXC_COORD_1);
+ kill_node(PGXC_COORD_2);
+ kill_node(PGXC_DATANODE_1);
+ kill_node(PGXC_DATANODE_2);
+#else
fprintf(stderr, _("\n%s: postmaster did not respond within 60 seconds\nExamine %s/log/postmaster.log for the reason\n"), progname, outputdir);
/*
@@ -2298,6 +2963,7 @@ regression_main(int argc, char *argv[], init_function ifunc, test_function tfunc
fprintf(stderr, _("\n%s: could not kill failed postmaster: %lu\n"),
progname, GetLastError());
#endif
+#endif /* PGXC */
exit_nicely(2);
}
@@ -2310,8 +2976,21 @@ regression_main(int argc, char *argv[], init_function ifunc, test_function tfunc
#else
#define ULONGPID(x) (unsigned long) (x)
#endif
+
+#ifdef PGXC
+ /* Print info for each node */
+ printf(_("running on port %d with pid %lu for Coordinator 1\n"),
+ get_port_number(PGXC_COORD_1), ULONGPID(get_node_pid(PGXC_COORD_1)));
+ printf(_("running on port %d with pid %lu for Coordinator 2\n"),
+ get_port_number(PGXC_COORD_2), ULONGPID(get_node_pid(PGXC_COORD_2)));
+ printf(_("running on port %d with pid %lu for Datanode 1\n"),
+ get_port_number(PGXC_DATANODE_1), ULONGPID(get_node_pid(PGXC_DATANODE_1)));
+ printf(_("running on port %d with pid %lu for Datanode 2\n"),
+ get_port_number(PGXC_DATANODE_2), ULONGPID(get_node_pid(PGXC_DATANODE_2)));
+#else
printf(_("running on port %d with pid %lu\n"),
port, ULONGPID(postmaster_pid));
+#endif
}
else
{