testutils

package
v0.0.0-...-9ba49b0 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2024 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateMultinodeSampleCluster

func CreateMultinodeSampleCluster(baseDir string) *greenplum.Cluster

TODO remove in favor of MustCreateCluster

func CreateMultinodeSampleClusterPair

func CreateMultinodeSampleClusterPair(baseDir string) (*greenplum.Cluster, *greenplum.Cluster)

TODO remove in favor of MustCreateCluster

func CreateTablespaces

func CreateTablespaces() greenplum.Tablespaces

func FinishMock

func FinishMock(mock sqlmock.Sqlmock, t *testing.T)

finishMock is a defer function to make the sqlmock API a little bit more like gomock. Use it like this:

db, mock, err := sqlmock.New()
if err != nil {
    t.Fatalf("couldn't create sqlmock: %v", err)
}
defer finishMock(mock, t)

func GetTempDir

func GetTempDir(t *testing.T, prefix string) string

func MockCluster

func MockCluster() *greenplum.Cluster

MockCluster returns the Cluster equivalent of MockSegmentConfiguration().

When changing this implementation, make sure you change MockSegmentConfiguration() to match!

func MockSegmentConfiguration

func MockSegmentConfiguration() *sqlmock.Rows

MockSegmentConfiguration returns a set of sqlmock.Rows that contains the expected response to a gp_segment_configuration query.

When changing this implementation, make sure you change MockCluster() to match!

func MustAddTablespace

func MustAddTablespace(t *testing.T, cluster greenplum.Cluster, tablespaceDir string)

func MustApplySQLFile

func MustApplySQLFile(t *testing.T, gphome string, port string, path string)

func MustClearEnv

func MustClearEnv(t *testing.T, envar string) func()

MustClearEnv makes sure envar is cleared, and returns a function to be used in a defer that resets the state to what it was prior to this function being called.

func MustConvertStringToInt

func MustConvertStringToInt(t *testing.T, input string) int

func MustCreateDataDirs

func MustCreateDataDirs(t *testing.T) (string, string, func(*testing.T))

MustCreateDataDirs returns a temporary source and target data directory that looks like a postgres directory. The last argument returned is a cleanup function that can be used in a defer.

func MustCreateDir

func MustCreateDir(t *testing.T, path string)

func MustCreateDirRemotely

func MustCreateDirRemotely(t *testing.T, host string, path string)

func MustCreateFilespaceAndTablespace

func MustCreateFilespaceAndTablespace(t *testing.T, cluster greenplum.Cluster, tablespaceDir string)

func MustCreateTablespace

func MustCreateTablespace(t *testing.T, cluster greenplum.Cluster, tablespaceDir string)

func MustDeleteTablespaces

func MustDeleteTablespaces(t *testing.T, source greenplum.Cluster, target greenplum.Cluster)

MustDeleteTablespaces deletes tablespaces from the target cluster. However, since we do not yet support upgrading tablespaces from version GPDB 6+ we do not need to delete them as they do not exist.

func MustExecuteSQL

func MustExecuteSQL(t *testing.T, connection string, query string) int

func MustGetEnv

func MustGetEnv(key string) string

func MustGetExecutablePath

func MustGetExecutablePath(t *testing.T) string

func MustGetLog

func MustGetLog(t *testing.T, process string) string

func MustGetPort

func MustGetPort(t *testing.T) int

func MustListenOnPort

func MustListenOnPort(t *testing.T, port int) func()

MustListenOnPort listens on the specified port and returns a cleanup function that can be used in a defer clause.

func MustMakeTablespaceDir

func MustMakeTablespaceDir(t *testing.T, tablespaceOid int) (string, string, string)

MustMakeTablespaceDir returns a temporary tablespace directory, its parent dbID directory, and its grandparent tablespace location. The location should be removed for cleanup.

func MustMoveRemoteFile

func MustMoveRemoteFile(t *testing.T, host string, source string, destination string)

func MustQuery

func MustQuery(t *testing.T, connection string, query string) interface{}

func MustQueryRow

func MustQueryRow(t *testing.T, connection string, query string) int

func MustReadFile

func MustReadFile(t *testing.T, path string) string

func MustRemoveAll

func MustRemoveAll(t *testing.T, dir string)

func MustRemoveAllRemotely

func MustRemoveAllRemotely(t *testing.T, host string, path string)

func MustRename

func MustRename(t *testing.T, oldPath string, newPath string)

func MustTruncateTablespaces

func MustTruncateTablespaces(t *testing.T, cluster greenplum.Cluster)

func MustWriteToFile

func MustWriteToFile(t *testing.T, path string, contents string)

func MustWriteToRemoteFile

func MustWriteToRemoteFile(t *testing.T, host string, path string, contents string)

MustWriteToRemoteFile writes a local file in a temp directory and rsync's it to the remote host. It does this since writing remotely is difficult and error prone.

func PathMustExist

func PathMustExist(t *testing.T, path string)

func PathMustNotExist

func PathMustNotExist(t *testing.T, path string)

func RemotePathMustExist

func RemotePathMustExist(t *testing.T, host string, path string)

func RemotePathMustNotExist

func RemotePathMustNotExist(t *testing.T, host string, path string)

func RemoteProcessMustBeRunning

func RemoteProcessMustBeRunning(t *testing.T, host string, process string)

func RemoteProcessMustNotBeRunning

func RemoteProcessMustNotBeRunning(t *testing.T, host string, process string)

func SetEnv

func SetEnv(t *testing.T, envar, value string) func()

func SetStdin

func SetStdin(t *testing.T, input string) func()

func VerifyClusterIsRunning

func VerifyClusterIsRunning(t *testing.T, cluster greenplum.Cluster)

func VerifyClusterIsStopped

func VerifyClusterIsStopped(t *testing.T, cluster greenplum.Cluster)

func VerifyRename

func VerifyRename(t *testing.T, source, target string)

VerifyRename ensures the source and archive data directories exist, and the target directory does not exist.

func VerifyTablespaceData

func VerifyTablespaceData(t *testing.T, cluster greenplum.Cluster)

Types

type DevNullSpy

type DevNullSpy struct {
	OutStream io.Writer
}

DevNullWithClose implements step.OutStreams

func (DevNullSpy) Stderr

func (s DevNullSpy) Stderr() io.Writer

func (DevNullSpy) Stdout

func (s DevNullSpy) Stdout() io.Writer

type FailingStreams

type FailingStreams struct {
	Err error
}

FailingStreams is an implementation of OutStreams for which every call to a stream's Write() method will fail with the given error.

func (FailingStreams) Stderr

func (f FailingStreams) Stderr() io.Writer

func (FailingStreams) Stdout

func (f FailingStreams) Stdout() io.Writer

type FailingWriter

type FailingWriter struct {
	Err error
}

FailingWriter is an io.Writer for which all calls to Write() return an error.

func (*FailingWriter) Write

func (f *FailingWriter) Write(_ []byte) (int, error)

Directories

Path Synopsis
Package exectest provides helpers for test code that wants to mock out pieces of the os/exec package, namely exec.Command().
Package exectest provides helpers for test code that wants to mock out pieces of the os/exec package, namely exec.Command().

Jump to

Keyboard shortcuts

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