helper

package
v0.8.2 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2025 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Overview

Simple copy file

Simplifies work with file testing

Simplifies work with ssh testing

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompareDirFiles added in v0.7.6

func CompareDirFiles(dir1, dir2 string) error

func CopyFile

func CopyFile(src, dst string) error

CopyFile will copy files around

func CreateRandomFiles added in v0.7.6

func CreateRandomFiles(dir string, amount int) ([]string, error)

CreateRandomFiles will take directory and put there as much random files as you want

func ExpectFailure

func ExpectFailure(t *testing.T, f func(tt testing.TB))

xpectFailure when failure expected

func MockSSHPortServer added in v0.7.6

func MockSSHPortServer(t *testing.T, user, pass, key string) (string, string)

func MockSSHPtyServer added in v0.7.6

func MockSSHPtyServer(t *testing.T, user, pass, key string) (string, string)

func MockSSHServer added in v0.7.6

func MockSSHServer(t *testing.T, sshSrv *sshd.Server, user, pass, key string) (string, string)

Base ssh server with no handler

func MockSSHSftpServer added in v0.7.6

func MockSSHSftpServer(t *testing.T, user, pass, key string) (string, string)

func Retry

func Retry(r Retryer, t Failer, f func(r *R))

Retry again

func RunCmdPtySSH added in v0.7.6

func RunCmdPtySSH(addr, username, password, cmd string) ([]byte, error)

func RunSftp added in v0.7.6

func RunSftp(addr, username, password string, files []string, toPath string, toRemote bool) error

SCP nowadays uses sftp subsystem with no need for scp binary on the target, so use it directly

Types

type AFInstance added in v0.7.5

type AFInstance struct {
	// contains filtered or unexported fields
}

AFInstance saves state of the running Aquarium Fish for particular test

func NewAfInstance

func NewAfInstance(tb testing.TB, name, cfg string) *AFInstance

NewAfInstance helpful if you need to create instance without starting it up right away

func NewAquariumFish

func NewAquariumFish(tb testing.TB, name, cfg string, args ...string) *AFInstance

NewAquariumFish simple creates and run the fish node

func (*AFInstance) APIAddress added in v0.7.5

func (afi *AFInstance) APIAddress(path string) string

APIAddress will return url to access API of AquariumFish

func (*AFInstance) APIEndpoint added in v0.7.6

func (afi *AFInstance) APIEndpoint() string

APIEndpoint will return IP:PORT

func (*AFInstance) AdminToken added in v0.7.5

func (afi *AFInstance) AdminToken() string

AdminToken returns admin token

func (*AFInstance) Cleanup added in v0.7.5

func (afi *AFInstance) Cleanup(tb testing.TB)

Cleanup after the test execution

func (*AFInstance) IsRunning added in v0.7.5

func (afi *AFInstance) IsRunning() bool

IsRunning checks the fish instance is running

func (*AFInstance) NewAfInstanceCluster added in v0.7.5

func (afi *AFInstance) NewAfInstanceCluster(tb testing.TB, name, cfg string) *AFInstance

NewAfInstanceCluster just creates the node based on the existing cluster node

func (*AFInstance) NewClusterNode added in v0.7.5

func (afi *AFInstance) NewClusterNode(tb testing.TB, name, cfg string, args ...string) *AFInstance

NewClusterNode starts another node of cluster It will automatically add cluster_join parameter to the config

func (*AFInstance) PrintMemUsage added in v0.8.0

func (afi *AFInstance) PrintMemUsage(tb testing.TB)

func (*AFInstance) ProxySSHEndpoint added in v0.7.6

func (afi *AFInstance) ProxySSHEndpoint() string

ProxySSHEndpoint will return IP:PORT

func (*AFInstance) Restart added in v0.7.5

func (afi *AFInstance) Restart(tb testing.TB, args ...string)

Restart the application

func (*AFInstance) Start added in v0.7.5

func (afi *AFInstance) Start(tb testing.TB, args ...string)

Start the fish node executable

func (*AFInstance) Stop added in v0.7.5

func (afi *AFInstance) Stop(tb testing.TB)

Stop the fish node executable

func (*AFInstance) WaitForLog added in v0.8.0

func (afi *AFInstance) WaitForLog(substring string, call func(string, string) bool)

WaitForLog stores substring to be looked in the Fish log to execute call function with substring & found line

func (*AFInstance) Workspace added in v0.7.5

func (afi *AFInstance) Workspace() string

Workspace will return workspace of the AquariumFish

type Counter

type Counter struct {
	Count int
	Wait  time.Duration
	// contains filtered or unexported fields
}

Counter repeats an operation a given number of times and waits between subsequent operations.

func (*Counter) Continue

func (r *Counter) Continue() bool

Continue counter

type Failer

type Failer interface {
	Helper()

	// Log is called for the final test output
	Log(args ...any)

	// FailNow is called when the retrying is abandoned.
	FailNow()
}

Failer is an interface compatible with testing.T.

type MockT

type MockT struct {
	testing.T

	FailNowCalled bool
	// contains filtered or unexported fields
}

MockT is useful to capture the failed test

func (*MockT) FailNow

func (m *MockT) FailNow()

FailNow when it's the right time

func (*MockT) Fatal

func (m *MockT) Fatal(args ...any)

Fatal message

func (*MockT) Fatalf

func (m *MockT) Fatalf(format string, args ...any)

Fatalf message

func (*MockT) Log

func (m *MockT) Log(args ...any)

Log message

func (*MockT) Logf

func (m *MockT) Logf(format string, args ...any)

Logf message

type R

type R struct {
	// contains filtered or unexported fields
}

R provides context for the retryer.

func (*R) Check

func (r *R) Check(err error)

Check check if everything is ok

func (*R) Error

func (r *R) Error(args ...any)

Error log error

func (*R) Errorf

func (r *R) Errorf(format string, args ...any)

Errorf log error

func (*R) FailNow

func (r *R) FailNow()

FailNow will fail the retry

func (*R) Fatal

func (r *R) Fatal(args ...any)

Fatal fail and log

func (*R) Fatalf

func (r *R) Fatalf(format string, args ...any)

Fatalf fail and log

func (*R) Helper

func (*R) Helper()

Helper shows this struct as helper

func (*R) Stop

func (r *R) Stop(err error)

Stop retrying, and fail the test with the specified error.

type Retryer

type Retryer interface {
	// Continue returns true if the operation should be repeated, otherwise it
	// returns false to indicate retrying should stop.
	Continue() bool
}

Retryer provides an interface for repeating operations until they succeed or an exit condition is met.

type Timer

type Timer struct {
	Timeout time.Duration
	Wait    time.Duration
	// contains filtered or unexported fields
}

Timer repeats an operation for a given amount of time and waits between subsequent operations.

func (*Timer) Continue

func (r *Timer) Continue() bool

Continue the timer

Jump to

Keyboard shortcuts

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