Documentation
¶
Overview ¶
Package postgres provides Ginkgo/Gomega assertions over the Postgres data plane: test data setup, recovery mode checks, and helper query strings.
Callers that also import tests/utils/postgres should alias one of the two (e.g. pgasserts for this package, postgres for the primitive layer).
Index ¶
- func AssertApplicationDatabaseConnection(env *environment.TestingEnvironment, ...)
- func AssertConnection(env *environment.TestingEnvironment, namespace string, service string, ...)
- func AssertCreateTestData(env *environment.TestingEnvironment, tl TableLocator)
- func AssertCreateTestDataLargeObject(env *environment.TestingEnvironment, namespace, clusterName string, oid int, ...)
- func AssertCreationOfTestDataForTargetDB(env *environment.TestingEnvironment, ...)
- func AssertDataExpectedCount(env *environment.TestingEnvironment, tl TableLocator, expectedValue int)
- func AssertLargeObjectValue(env *environment.TestingEnvironment, testTimeouts map[timeouts.Timeout]int, ...)
- func AssertPgRecoveryMode(env *environment.TestingEnvironment, pod *corev1.Pod, expectedValue bool)
- func BoolPGOutput(expectedValue bool) string
- func DatabaseExistsQuery(dbName string) string
- func ExtensionExistsQuery(extName string) string
- func FDWExistsQuery(fdwName string) string
- func ForeignServerExistsQuery(serverName string) string
- func InsertRecordIntoTable(tableName string, value int, conn *sql.DB)
- func QueryMatchExpectationPredicate(env *environment.TestingEnvironment, pod *corev1.Pod, dbname exec.DatabaseName, ...) func(g Gomega)
- func RoleExistsQuery(roleName string) string
- func SchemaExistsQuery(namespaceName string) string
- type TableLocator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssertApplicationDatabaseConnection ¶
func AssertApplicationDatabaseConnection( env *environment.TestingEnvironment, namespace, clusterName, appUser, appDB, appPassword, appSecretName string, )
AssertApplicationDatabaseConnection verifies that the cluster can be reached via its read-write service using the application user. When appPassword is empty, it is read from appSecretName (or the auto-generated <cluster>-app secret if appSecretName is empty).
func AssertConnection ¶
func AssertConnection( env *environment.TestingEnvironment, namespace string, service string, dbname string, user string, password string, )
AssertConnection opens a forwarded psql connection to a service, asserting that a basic SELECT 1 succeeds within RetryTimeout.
func AssertCreateTestData ¶
func AssertCreateTestData(env *environment.TestingEnvironment, tl TableLocator)
AssertCreateTestData creates a small table at the given TableLocator. When DatabaseName or Tablespace are empty they default to AppDBName and the default tablespace.
func AssertCreateTestDataLargeObject ¶
func AssertCreateTestDataLargeObject( env *environment.TestingEnvironment, namespace, clusterName string, oid int, data string, )
AssertCreateTestDataLargeObject creates an image table containing a large object with the given oid and data.
func AssertCreationOfTestDataForTargetDB ¶
func AssertCreationOfTestDataForTargetDB( env *environment.TestingEnvironment, namespace, clusterName, targetDBName, tableName string, )
AssertCreationOfTestDataForTargetDB creates a target database with the application user as owner, then creates a placeholder table inside it and grants SELECT on every public table to pg_monitor.
func AssertDataExpectedCount ¶
func AssertDataExpectedCount( env *environment.TestingEnvironment, tl TableLocator, expectedValue int, )
AssertDataExpectedCount verifies that the named table has exactly expectedValue rows.
func AssertLargeObjectValue ¶
func AssertLargeObjectValue( env *environment.TestingEnvironment, testTimeouts map[timeouts.Timeout]int, namespace, clusterName string, oid int, data string, )
AssertLargeObjectValue checks that the large object identified by oid in the cluster's app database eventually returns the expected decoded data.
func AssertPgRecoveryMode ¶
func AssertPgRecoveryMode(env *environment.TestingEnvironment, pod *corev1.Pod, expectedValue bool)
AssertPgRecoveryMode verifies whether the pod is in recovery mode.
func BoolPGOutput ¶
BoolPGOutput translates a Go bool into the textual representation Postgres returns from a boolean expression ("t" or "f").
func DatabaseExistsQuery ¶
DatabaseExistsQuery builds a SELECT EXISTS query for the named database.
func ExtensionExistsQuery ¶
ExtensionExistsQuery builds a SELECT EXISTS query for the named extension.
func FDWExistsQuery ¶
FDWExistsQuery builds a SELECT EXISTS query for the named foreign data wrapper.
func ForeignServerExistsQuery ¶
ForeignServerExistsQuery builds a SELECT EXISTS query for the named foreign server.
func InsertRecordIntoTable ¶
InsertRecordIntoTable inserts a single integer value into the named table over an open *sql.DB connection.
func QueryMatchExpectationPredicate ¶
func QueryMatchExpectationPredicate( env *environment.TestingEnvironment, pod *corev1.Pod, dbname exec.DatabaseName, query string, expectedOutput string, ) func(g Gomega)
QueryMatchExpectationPredicate returns a Gomega predicate that runs the query inside the given pod and checks the trimmed output equals expectedOutput.
func RoleExistsQuery ¶
RoleExistsQuery builds a SELECT EXISTS query for the named pg_role.
func SchemaExistsQuery ¶
SchemaExistsQuery builds a SELECT EXISTS query for the named schema.