Skip to content

CI: run the Behave tests on a multi-host cluster - #2477

Open
tuhaihe wants to merge 15 commits into
apache:mainfrom
tuhaihe:behave-multihost
Open

tuhaihe wants to merge 15 commits into
apache:mainfrom
tuhaihe:behave-multihost

Conversation

@tuhaihe

@tuhaihe tuhaihe commented Dec 2, 2026

Copy link
Copy Markdown
Member

Fixes #ISSUE_Number

What does this PR do?

Type of Change

  • Bug fix (non-breaking change)
  • New feature (non-breaking change)
  • Breaking change (fix or feature with breaking changes)
  • Documentation update

Breaking Changes

Test Plan

  • Unit tests added/updated
  • Integration tests added/updated
  • Passed make installcheck
  • Passed make -C src/test installcheck-cbdb-parallel

Impact

Performance:

User-facing changes:

Dependencies:

Checklist

Additional Context


@tuhaihe
tuhaihe marked this pull request as draft December 2, 2026 08:55
@tuhaihe tuhaihe added this to the Behave tests milestone Dec 2, 2026
The scenario "validate session GUC passed with -x is set" has the
@not_implemented tag, so CI does not run it. Remove the tag.

The scenario starts the coordinator with gpstart -ma and expects
gpcheckcat to fail without -x gp_role=utility. It fails on main,
because Cloudberry does not reject non-utility connections to a
utility-mode postmaster. The next commit restores that check.

Assisted-by: Claude Code
gpstart -m starts the coordinator alone, in utility mode, so that an
administrator can do maintenance on an isolated system. Greenplum
rejects each connection to such a postmaster unless the client also
asks for utility mode (gp_role=utility). Cloudberry lost this check,
so any client can connect.

Restore the check from Greenplum (gpdb-archive commit 482967c1b4).
InitPostgres() sets a flag before it reads the startup packet, and
assign_gp_role() clears the flag when the client sets gp_role=utility.

Cloudberry needs more exemptions than Greenplum:

- A single-node deployment always runs in the utility role, so the
  check uses IS_UTILITY_BUT_NOT_SINGLENODE().
- The login monitor, background workers (such as logical replication
  apply workers and parallel workers) and walsenders do not send
  gp_role, so do not check them. Without this exemption, the TAP test
  recovery/035_standby_logical_decoding fails.

After gpstart -m, a client must set PGOPTIONS='-c gp_role=utility' to
connect, as in Greenplum.

Assisted-by: Claude Code
TAP nodes run in utility mode, and the test framework sets
PGOPTIONS='-c gp_role=utility' for each client. Two blocks in
pgbench/001 replace PGOPTIONS to set default_transaction_isolation,
so pgbench connects without gp_role=utility. With the utility-mode
check from the previous commit, the node rejects these connections
and the retry tests 434-443 fail. Keep gp_role=utility in both
blocks.

Other TAP tests that set PGOPTIONS and then use $node->psql are not
affected, because Cluster.pm sets gp_role=utility again inside psql.

Assisted-by: Claude Code
The gpstart scenarios that check connections in -m, -m -R and -R mode
have the @concourse_cluster tag, so CI does not run them. They only
need the single-host demo cluster. Remove the tag from them, and from
the foouser setup and cleanup scenarios that they use.

Assisted-by: Claude Code
Fix the two problems that stop these scenarios from passing:

- The step "when utility mode is set to {utility_mode}" kept the
  quotes around the value. The value never matched "True", so the
  step never set PGOPTIONS. Put the quotes in the step pattern.
- The expected error messages were old. psql now prints "connection
  to server ... failed:" before FATAL, and PostgreSQL 16 changed the
  message for reserved connection slots.

The CI gpstart job now runs 21 scenarios instead of 3.

Assisted-by: Claude Code
@tuhaihe

tuhaihe commented Dec 2, 2026

Copy link
Copy Markdown
Member Author

This PR temporarily includes the commits of #2452 and #2457, so the multi-host Behave run shows the result with all three changes together. After #2452 and #2457 are merged, I will rebase this PR onto main, which drops their commits.

@tuhaihe
tuhaihe force-pushed the behave-multihost branch 3 times, most recently from be48e73 to c68b7da Compare December 2, 2026 14:10
tuhaihe and others added 10 commits December 3, 2026 20:39
Pull requests run the gpMgmt Behave tests on a single-host demo
cluster.  The @concourse_cluster scenarios and the gpexpand,
gprecoverseg_newhost and gpssh-exkeys features need more than one
host, so no CI job runs them.

Add a workflow for them.  It builds the RPM once.  Then each matrix
entry starts eight containers on one runner, with the host names the
tests expect: cdw (alias mdw) as the coordinator, scdw as the standby,
sdw1-sdw4 with two primaries and two mirrors each, and sdw5/sdw6 as
spare hosts.  It creates the cluster with gpinitsystem and runs its
features from cdw.

Each matrix entry runs one feature on its own cluster.  The scenarios
stop segments, create their own clusters and change
COORDINATOR_DATA_DIRECTORY, so a feature cannot rely on the state that
another one leaves.  The utility features run their @concourse_cluster
scenarios; gpexpand, gprecoverseg_newhost and gpssh-exkeys run in full.
The @Extended, @not_implemented and @Differential scenarios are
excluded, and so is @gpexpand_icw_db_concourse, which loads a dump of
the ICW database that only the Concourse clusters had.  gpmovemirrors
runs on a cluster with spread mirroring over three hosts, as its
scenarios expect.  behave stops after 180 minutes, so a scenario that
waits for a cluster that cannot recover does not hold the runner until
the job times out, and the logs are still collected.

Every host lists all hosts in /etc/hosts, because the tests look up
addresses there to add blackhole routes, and gpssh-exkeys finds the
coordinator's aliases there.  Each host also has its own localhost
host keys in known_hosts.

The workflow runs on pull requests to main that change the same paths
as behave-cloudberry.yml, and by manual dispatch, so a failure shows up
on the pull request that causes it.  It is not a required check.

Assisted-by: Claude Code
The step "the user writes ... to the coordinator config file" appended
the line to the standby's postgresql.conf with open(), so it assumed
that the standby is on the coordinator host.  When the standby is on
another host, the line went to the coordinator's file a second time
and the standby's file did not change, so gpconfig reported the GUC
out of sync.

Append to the standby's file over ssh.  The line goes on stdin, so the
values with spaces or quotes need no escaping.  On a demo cluster ssh
goes to the same host, so the result does not change there.

Assisted-by: Claude Code
Without -S, gpcheckperf writes twice the memory size to each directory
for the disk test.  On a CI runner with 16GB of memory, the two hosts
in the scenario share one disk and would write 64GB.  The scenario only
checks that the disk and stream tests run and print their results, so
pass "-S 1GB".

Assisted-by: Claude Code
The single-host Behave workflow excludes the @Extended scenarios on
pull requests and on push, so no workflow runs them.  They need only one
host, so run them there: the three gpinitsystem scenarios that
check the backout file and the three replication_slots scenarios that
check the slots after failover, full recovery and expansion.  Together
they add about ten minutes, split over two jobs.

Drop "--tags ~@Extended" from every entry, so @Extended scenarios added
later run too, and say so in the matrix comment and in the multi-host
workflow.

Assisted-by: Claude Code
gprecoverseg skips a mirror when a pg_basebackup is already running for
its content.  gpmovemirrors runs gprecoverseg with an input file, and
then removed the old directory of every mirror in that file, including
the ones gprecoverseg skipped.  When the skipped mirror was being
recovered in place by another gprecoverseg, this removed the directory
that its pg_basebackup was writing to, and that recovery failed with
"could not open write-ahead log file".

Read the configuration again after gprecoverseg, and remove only the
old directories of mirrors that are no longer in it.

This is the gpmovemirrors part of Greenplum commit 6d759a75563.
Cloudberry already has the gprecoverseg part, which skips the mirror.
The multi-host Behave scenario "gpmovemirrors gives warning if
pg_basebackup is already running for one of the mirrors to be moved"
fails without it.

Assisted-by: Claude Code
gpexpand makes the new segments from a copy of the coordinator, then
empties the tables that only the coordinator has.  Its lists of these
tables still have pg_auth_time_constraint, pg_shdescription and
pg_description, which every segment has.  So after gpexpand, the new
segments have no comments and no time-based login constraints, and a
DROP of such a constraint fails on them with "cannot find matching
DENY rules".

Greenplum fixed this in 48865db, and split the list into the
mapped and non-mapped tables in 7480806.  Cloudberry merged the
split first (apache#666), resolved against the list from before the fix, and
then the fix (apache#847), which removed the tables only from the old list
that gpexpand no longer uses.  Remove them from the two new lists, as
in Greenplum.

The gpexpand Behave scenario that checks these tables on the new
segments now passes.

Backpatch-through: REL_2_STABLE
Assisted-by: Claude Code
In Greenplum, gparray treats only the segments that are up as valid,
so gpstart does not start a segment that FTS has marked down, and
gpstop and gpexpand also act on the valid segments only.  Cloudberry
made every segment valid, because an external FTS service runs apart
from the cluster and can mark healthy segments down while the cluster
stops.  That broke the Behave scenario "gpstart correctly identifies
down segments", and it also applies to builds without external FTS.

Use the Greenplum rule again, and keep every segment valid only when
Cloudberry was built with --enable-external-fts.  gparray checks the
build with pg_config the first time it reads a segment that is down,
and keeps the result.

Assisted-by: Claude Code
The multi-host workflow runs scenarios that were written for the
Concourse clusters and that no CI job ran before.  Fix the ones that
fail on its cluster:

- gprecoverseg: SUSPEND_PG_REWIND must reach pg_rewind, which runs over
  ssh on the segment hosts.  A new step also exports the variable there
  from ~/.bashrc, and removes it again at cleanup.
- gprecoverseg: match dbids with \d+.  The cluster has dbids above 9.
- The steps that wait for a process or kill gpcreateseg skip zombies.
  In a CI container, PID 1 does not reap the orphans of a killed
  process, so they stay in ps as <defunct>.
- "the user runs command ... on all hosts" reads the host list in
  utility mode.  After a scenario sets an address that does not
  resolve, the coordinator refuses other connections.
- The gpAdminLogs step takes a host list, as in Greenplum cc98e79a88e.
  For "all segment hosts", a file must be on at least one host, because
  a recovery writes logs only on the hosts of the segments it recovers.
- gprecoverseg_newhost: delete the logs of earlier scenarios first, and
  expect the pg_basebackup logs of the failed recovery on sdw5.
  gprecoverseg keeps them, as in Greenplum since cc98e79a88e.
- gpexpand: insert 12000000 rows instead of 4000000 in the
  @gpexpand_timing scenarios.  gpexpand checks the end time only every
  5 seconds, and with fewer rows the redistribution sometimes finished
  before the first check.
- gpexpand: tag @not_implemented the scenarios that need Greenplum
  changes that Cloudberry does not have: the ICProxy checks of
  ceb66bab5a1, 988c9400ef1 and the table skip of 6b7e4c3dbb5.

Assisted-by: Claude Code
…ed (#13323)

gprecoverseg changes to continue recovery even if failed host is unreachable
Previously recovery was aborted in case if failed host is not in reach.
Also added supporting test cases for the same.

(cherry picked from commit 8907569f7ec4cfdefec2192b11279bd999ffda24)

Cloudberry: Cloudberry already had the gprecoverseg_newhost scenarios of
this commit, but not the code they test.  `gprecoverseg -i` to a new host
skipped every segment of an unreachable failed host, printed "No segments
to recover" and returned 0.  Conflicts resolved for the newer
_convert_requests_to_triplets():

- The unreachable check stays before the failover block.  It skips only
  recovery in place, as upstream does.
- The failover hosts are checked over ssh by hostname, and the result
  is compared with the hostname.  Upstream checks the address but
  compares the hostname.  Cloudberry splits the failover host into a
  hostname and an address, and ssh to an address such as an IP can
  fail on a host that is up.  A unit test covers this.
- The scenarios in gprecoverseg_newhost.feature were already there.

Assisted-by: Claude Code
After the merging of https://github.com/greenplum-db/gpdb/pull/15700, there were some intermittent `gprecoverseg` and `gprecoverseg_new_hosts` job failures. They were happening for a couple of reasons -
- The `signal_handler` in the `gpsegrecovery` process would be called multiple times and sometimes the logger would close the buffer for writing leading to a logging error. Fixed this by moving the logging outside the handler and ignoring the signal once inside the function so that it cannot be called multiple times.
- The timeout for waiting for the `pg_basebackup/pg_rewind` process was less (around 1 min) so increase it.

(cherry picked from commit b24e8be66862bcad48c635167ea7d8cf7bcb9752)

Cloudberry: the gprecoverseg.feature part of this commit was already
there.  Without the rest, the SIGTERM scenario in
gprecoverseg_newhost.feature could send SIGTERM before gpsegrecovery had
set its signal handler.  The backout then failed with "SQL affected -1
rows but 1 were expected".

Assisted-by: Claude Code
@tuhaihe
tuhaihe marked this pull request as ready for review December 3, 2026 12:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants