SIGN IN SIGN UP

refactor(tests): split asserts_test.go into per-topic packages (#10681)

tests/e2e/asserts_test.go was a 3,120-line, 87-function module in
package e2e. Because its helpers lived in a _test.go file they were
invisible outside that single package, which blocked splitting tests/e2e
into per-topic subdirectories: each subdir would be its own Go package
and could not import what it needed.

The helpers now live in per-topic packages under
`tests/internal/asserts/<topic>/`: postgres, cluster, backup, minio,
pgbouncer, replication, secrets, storage, metrics, logs. The
YAML-materialisation helpers (CreateResourceFromFile and friends) are
ginkgo-coupled but not assertions, so they live in a sibling
`tests/internal/resources/` package. Living under tests/internal/ means
Go's "internal" import rule blocks anything outside tests/ (and any
external module that vendors this repo) from depending on them; they are
test infrastructure, not a public API. Each helper takes
*environment.TestingEnvironment (and the testTimeouts map where needed)
explicitly instead of reaching for the package-level globals in
suite_test.go. tests/utils/backups and tests/utils/logs each lost one
assert function to the new tree (AssertBackupConditionInClusterStatus,
AssertQueryRecord).

The new API gets polish along the way: AssertUpdateSecret takes
namespace/cluster right after env, AssertFastFailOver groups
quickDeletionPeriod with the other timing knobs at the end, timeout
types harmonize to int, and six helpers that used to shell out to
kubectl now use env.Client / env.EventuallyExecCommand /
resources.CreateResourceFromFile so they honour the configured
kubeconfig and env.Ctx. Two pre-existing bugs the refactor would have
promoted to public API are fixed: an inverted condition that suppressed
a "Write activity resumed in N seconds" diagnostic, and a "Priting" ->
"Printing" typo.

One behaviour delta: buildTemplateEnvs in tests/internal/resources uses
strings.SplitN(s, "=", 2). The old code silently truncated env-var
values containing "=" before they reached envsubst. No fixture is known
to rely on the truncation, but if a .template substitution starts
behaving differently this is where to look.

Closes #10684

Assisted-by: Claude

Signed-off-by: Marco Nenciarini <marco.nenciarini@enterprisedb.com>
Signed-off-by: Armando Ruocco <armando.ruocco@enterprisedb.com>
Co-authored-by: Armando Ruocco <armando.ruocco@enterprisedb.com>
M
Marco Nenciarini committed
201f499cd06da2b577243567450b77abcb76b9e5
Parent: 2685bb6
Committed by GitHub <noreply@github.com> on 5/29/2026, 9:27:42 AM