utils

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2024 License: UPL-1.0 Imports: 18 Imported by: 0

Documentation

Overview

Package utils provides various utilities for testing the coherence-go-client.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertPersonResult

func AssertPersonResult(g *gomega.WithT, result Person, expectedValue Person)

func AssertSize

func AssertSize[K comparable, V any](g *gomega.WithT, namedMap coherence.NamedMap[K, V], expectedSize int)

func ClearNamedMap

func ClearNamedMap[K comparable, V any](g *gomega.WithT, namedCache coherence.NamedMap[K, V])

func CollectDockerLogs

func CollectDockerLogs() error

CollectDockerLogs collects docker logs

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 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 GetFilePath

func GetFilePath(fileName string) string

GetFilePath returns the file path of a file

func GetGrpcURL

func GetGrpcURL(hostname string, port int) string

GetGrpcURL returns the gRPC URL given a host and port

func GetManagementURL

func GetManagementURL(httpPort int) string

GetManagementURL returns the management URL given a management port

func GetNamedCache

func GetNamedCache[K comparable, V any](g *gomega.WithT, session *coherence.Session, cacheName string) coherence.NamedCache[K, V]

func GetNamedCacheWithScope

func GetNamedCacheWithScope[K comparable, V any](g *gomega.WithT, session *coherence.Session, cacheName, _ string) coherence.NamedCache[K, V]

func GetNamedMap

func GetNamedMap[K comparable, V any](g *gomega.WithT, session *coherence.Session, cacheName string) coherence.NamedMap[K, V]

func GetNamedMapWithScope

func GetNamedMapWithScope[K comparable, V any](g *gomega.WithT, session *coherence.Session, cacheName, _ string) coherence.NamedMap[K, V]

func GetRestURL

func GetRestURL(restPort int) string

GetRestURL returns the REST URL

func GetSession

func GetSession(options ...func(session *coherence.SessionOptions)) (*coherence.Session, error)

GetSession returns a coherence session for testing

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 RunKeyValueTest

func RunKeyValueTest[K comparable, V any](g *gomega.WithT, cache coherence.NamedMap[K, V], key K, value V)

RunKeyValueTest runs a basic Put/Get test against various key/ values

func RunKeyValueTestNamedCache

func RunKeyValueTestNamedCache[K comparable, V any](g *gomega.WithT, cache coherence.NamedCache[K, V], key K, value V)

RunKeyValueTestNamedCache runs a basic Put/Get test against various key/ values

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 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

Types

type Address

type Address struct {
	Address1 string `json:"address1"`
	Address2 string `json:"address2"`
	City     string `json:"city"`
	State    string `json:"state"`
	PostCode int    `json:"postCode"`
}

type BooleanTest

type BooleanTest struct {
	ID     int    `json:"id"`
	Name   string `json:"name"`
	Active bool   `json:"active"`
}

type Person

type Person struct {
	ID          int      `json:"id"`
	Name        string   `json:"name"`
	HomeAddress Address  `json:"homeAddress"`
	Age         int      `json:"age"`
	Salary      float32  `json:"salary"`
	Languages   []string `json:"languages"`
	Phone       string   `json:"phone"`
	Department  string   `json:"department"`
}

type TestContext

type TestContext struct {
	ClusterName     string
	HostName        string
	GrpcPort        int
	HTTPPort        int
	URL             string
	RestURL         string
	ExpectedServers int
	Username        string
	Password        string
	SecureMode      string // value of "env" means read from environment and "options" for options to NewSession()
	ClientCertPath  string
	ClientKeyPath   string
	CaCertPath      string
}

TestContext is a context to pass to tests

func GetTestContext

func GetTestContext() *TestContext

GetTestContext gets the current context

type VersionedPerson

type VersionedPerson struct {
	Version int     `json:"@version"`
	ID      int     `json:"id"`
	Name    string  `json:"name"`
	Age     int     `json:"age"`
	Salary  float32 `json:"salary"`
}

Jump to

Keyboard shortcuts

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