test_utils

package
v0.0.0-...-b7e2043 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2024 License: UPL-1.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CleanupConfigFileAfterTest

func CleanupConfigFileAfterTest(t *testing.T, file string)

CleanupConfigFileAfterTest cleans up a config file after a test.

func CleanupDirectoryAfterTest

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

CleanupDirectoryAfterTest cleans up a directory after a test.

func CollectDockerLogs

func CollectDockerLogs() error

CollectDockerLogs collects docker logs.

func CreateNewConfigYaml

func CreateNewConfigYaml(name string) (string, error)

CreateNewConfigYaml creates a full path of a new directory and config.

func CreateTempDirectory

func CreateTempDirectory(pattern string) string

CreateTempDirectory creates a temporary directory.

func DockerComposeDown

func DockerComposeDown(composeFile string) (string, error)

DockerComposeDown runs docker compose down on a given file.

func DockerComposeUp

func DockerComposeUp(composeFile string) (string, error)

DockerComposeUp runs docker compose up on a given file.

func EnsureCommandContains

func EnsureCommandContains(g *WithT, t *testing.T, command *cobra.Command, expected string, args ...string)

EnsureCommandContains executes a command and checks that it contains the output expected.

func EnsureCommandContainsAll

func EnsureCommandContainsAll(g *WithT, t *testing.T, command *cobra.Command, expectedCSV string, args ...string)

EnsureCommandContainsAll executes a command and checks that it contains all the comma separated values in expectedCSV.

func EnsureCommandErrorContains

func EnsureCommandErrorContains(g *WithT, t *testing.T, command *cobra.Command, expected string, args ...string)

EnsureCommandErrorContains executes a command and checks that the error contains expected output.

func EnsureCommandNotContains

func EnsureCommandNotContains(g *WithT, t *testing.T, command *cobra.Command, expected string, args ...string)

EnsureCommandNotContains executes a command and checks that it does not contain the output expected.

func EnsureCommandOutputEquals

func EnsureCommandOutputEquals(g *WithT, t *testing.T, command *cobra.Command, expected string, args ...string)

EnsureCommandOutputEquals executes a command and checks that it equals the output expected.

func ExecuteCommand

func ExecuteCommand(t *testing.T, root *cobra.Command, args ...string) (c *cobra.Command, output string, err error)

ExecuteCommand executes a given command with the arguments provided.

func ExecuteHostCommand

func ExecuteHostCommand(name string, arg ...string) (string, error)

ExecuteHostCommand executes a host command.

func FileExistsInDirectory

func FileExistsInDirectory(dir string, file string) bool

FileExistsInDirectory returns true if a file exists in a directory.

func GetCommandOutput

func GetCommandOutput(t *testing.T, command *cobra.Command, args ...string) string

GetCommandOutput returns the output from a command.

func GetFilePath

func GetFilePath(fileName string) string

GetFilePath returns the file path of a file.

func GetManagementUrl

func GetManagementUrl(httpPort int) string

GetManagementUrl returns the management URL given a management port.

func GetRestUrl

func GetRestUrl(restPort int) string

GetRestUrl returns the REST URL.

func IssueGetRequest

func IssueGetRequest(url string) ([]byte, error)

IssueGetRequest issues a HTTP GET request using the URL.

func IssuePostRequest

func IssuePostRequest(url string) ([]byte, error)

IssuePostRequest issues a HTTP POST request using the URL.

func SetTestContext

func SetTestContext(context *TestContext)

SetTestContext sets the current context.

func Sleep

func Sleep(seconds int)

Sleep will sleep for a duration of seconds.

func StartCoherenceCluster

func StartCoherenceCluster(fileName, url string) error

StartCoherenceCluster starts a Coherence cluster.

func StartDockerImage

func StartDockerImage(t *testing.T, image string, name string, httpPort int, clusterName string, delete bool) (string, error)

StartDockerImage starts a coherence image using docker.

func StopDockerImage

func StopDockerImage(name string) (string, error)

StopDockerImage stops a docker image with the given name.

func WaitForHttpBalancedServices

func WaitForHttpBalancedServices(url string, timeout int) error

WaitForHttpBalancedServices waits for all services to be balanced.

func WaitForHttpReady

func WaitForHttpReady(url string, timeout int) error

WaitForHttpReady waits for the HTTP endpoint to be ready.

func WaitForIdlePersistence

func WaitForIdlePersistence(timeout int, dataFetcher fetcher.Fetcher, serviceName string) error

WaitForIdlePersistence waits for idle persistence coordinator which means the last operation has completed.

Types

type TestContext

type TestContext struct {
	ClusterName     string
	HttpPort        int
	Url             string
	RestUrl         string
	ExpectedServers int
	Username        string
	Password        string
}

TestContext is a context to pass to tests.

func GetTestContext

func GetTestContext() *TestContext

GetTestContext gets the current context.

Jump to

Keyboard shortcuts

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