replication

package
v1.30.0-rc1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 19, 2026 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Overview

Package replication provides Ginkgo/Gomega assertions for streaming replication state: read-only / read-write service behaviour, replica promotion and lag, replication slot accounting, replica clusters, and the fast-failover end-to-end choreography.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertClusterHAReplicationSlots

func AssertClusterHAReplicationSlots(env *environment.TestingEnvironment, namespace, clusterName string)

AssertClusterHAReplicationSlots verifies that the replication slots of each pod of the cluster exist and are aligned.

func AssertClusterReplicationSlotsAligned

func AssertClusterReplicationSlotsAligned(
	env *environment.TestingEnvironment,
	namespace, clusterName string,
)

AssertClusterReplicationSlotsAligned compares the replication slot restart_lsn across the cluster; the assertion succeeds if all values match.

func AssertClusterStandbysAreStreaming

func AssertClusterStandbysAreStreaming(
	env *environment.TestingEnvironment,
	namespace, clusterName string,
	timeout int,
)

AssertClusterStandbysAreStreaming verifies that all the standbys of a cluster have a wal-receiver running.

func AssertDetachReplicaModeCluster

func AssertDetachReplicaModeCluster(
	env *environment.TestingEnvironment,
	testTimeouts map[timeouts.Timeout]int,
	namespace, srcClusterName, srcDatabaseName string,
	replicaClusterName, replicaDatabaseName, replicaUserName string,
	testTableName string,
)

AssertDetachReplicaModeCluster verifies that a replica cluster can be detached from the source cluster, and its target primary can be promoted. After detachment, new writes on the source cluster shouldn't reach the detached replica cluster, and the replica cluster must not have a bootstrap.initdb-style "app" database.

func AssertFastFailOver

func AssertFastFailOver(
	env *environment.TestingEnvironment,
	testTimeouts map[timeouts.Timeout]int,
	namespace, sampleFile, clusterName, webTestFile, webTestJob string,
	maxReattachTime, maxFailoverTime int,
	quickDeletionPeriod int64,
)

AssertFastFailOver creates a cluster, drives load against it via a webtest deployment, force-deletes the primary, and verifies that standbys follow promotion and writes resume before the deadlines.

func AssertReplicaModeCluster

func AssertReplicaModeCluster(
	env *environment.TestingEnvironment,
	testTimeouts map[timeouts.Timeout]int,
	namespace, srcClusterName, srcClusterDBName, replicaClusterSample, testTableName string,
)

AssertReplicaModeCluster checks that, after inserting some data in a source cluster, a replica cluster can be bootstrapped using pg_basebackup and is properly replicating from the source cluster.

func AssertReplicationSlotsOnPod

func AssertReplicationSlotsOnPod(
	env *environment.TestingEnvironment,
	namespace, clusterName string,
	pod corev1.Pod,
	expectedSlots []string,
	isActiveOnPrimary bool,
	isActiveOnReplica bool,
)

AssertReplicationSlotsOnPod checks that all the required replication slots exist in a given pod, and that obsolete slots are correctly deleted (post management operations). On the primary it also verifies the slots are active.

func AssertStandbysFollowPromotion

func AssertStandbysFollowPromotion(
	env *environment.TestingEnvironment,
	testTimeouts map[timeouts.Timeout]int,
	namespace, clusterName string,
	timeout int,
)

AssertStandbysFollowPromotion verifies every cluster pod observes timeline 2 after a primary promotion, and that the cluster reaches Ready before the deadline.

func AssertWritesResumedBeforeTimeout

func AssertWritesResumedBeforeTimeout(
	env *environment.TestingEnvironment,
	namespace, clusterName string,
	timeout int,
)

AssertWritesResumedBeforeTimeout measures the gap in seconds between the last write on the old timeline and the first write on the new timeline, asserting it is below timeout.

func AssertWritesToPrimarySucceeds

func AssertWritesToPrimarySucceeds(
	env *environment.TestingEnvironment,
	namespace, service, appDBName, appDBUser, appDBPass string,
	connectionParams ...map[string]string,
)

AssertWritesToPrimarySucceeds opens a connection to the named service and expects it to land on the primary, where DDL succeeds.

func AssertWritesToReplicaFails

func AssertWritesToReplicaFails(
	env *environment.TestingEnvironment,
	namespace, service, appDBName, appDBUser, appDBPass string,
	connectionParams ...map[string]string,
)

AssertWritesToReplicaFails opens a connection to the named service and expects it to land on a replica (recovery=true) where DDL is rejected.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL