util

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2019 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Logf added in v0.32.0

func Logf(str string, args ...interface{})

Logf writes logs to stdout if -v is set.

func Retry added in v0.22.0

func Retry(t *testing.T, callback func() error, d time.Duration, attempts int) (err error)

Retry tries the callback for a number of attempts, with a delay between attempts

func Retry2 added in v1.3.0

func Retry2(callback func() error, d time.Duration, attempts int) (err error)

Retry2 tries the callback for a number of attempts, with a delay without *testing.T

func RetryX added in v1.3.0

func RetryX(callback func() error, initInterv time.Duration, maxTime time.Duration) error

RetryX is expontential backoff retry

func WaitForBusyboxRunning added in v0.22.0

func WaitForBusyboxRunning(t *testing.T, namespace string, miniProfile string) error

WaitForBusyboxRunning waits until busybox pod to be running

Types

type KubectlRunner

type KubectlRunner struct {
	Profile    string // kube-context maps to a minikube profile
	T          *testing.T
	BinaryPath string
}

KubectlRunner runs a command using kubectl

func NewKubectlRunner

func NewKubectlRunner(t *testing.T, profile ...string) *KubectlRunner

NewKubectlRunner creates a new KubectlRunner

func (*KubectlRunner) CreateRandomNamespace

func (k *KubectlRunner) CreateRandomNamespace() string

CreateRandomNamespace creates a random namespace

func (*KubectlRunner) DeleteNamespace

func (k *KubectlRunner) DeleteNamespace(namespace string) error

DeleteNamespace deletes the namespace

func (*KubectlRunner) RunCommand

func (k *KubectlRunner) RunCommand(args []string, useKubeContext ...bool) (stdout []byte, err error)

RunCommand runs a command, returning stdout

func (*KubectlRunner) RunCommandParseOutput

func (k *KubectlRunner) RunCommandParseOutput(args []string, outputObj interface{}, useKubeContext ...bool) error

RunCommandParseOutput runs a command and parses the JSON output

type MinikubeRunner

type MinikubeRunner struct {
	Profile      string
	T            *testing.T
	BinaryPath   string
	GlobalArgs   string
	StartArgs    string
	MountArgs    string
	Runtime      string
	TimeOutStart time.Duration // time to wait for minikube start before killing it
}

MinikubeRunner runs a command

func (*MinikubeRunner) CheckStatus

func (m *MinikubeRunner) CheckStatus(desired string)

CheckStatus makes sure the service has the desired status, or cause fatal error

func (*MinikubeRunner) CheckStatusNoFail added in v0.17.0

func (m *MinikubeRunner) CheckStatusNoFail(desired string) error

CheckStatusNoFail makes sure the service has the desired status, returning error

func (*MinikubeRunner) EnsureRunning

func (m *MinikubeRunner) EnsureRunning(opts ...string)

EnsureRunning makes sure the container runtime is running

func (*MinikubeRunner) GetLogs added in v0.22.2

func (m *MinikubeRunner) GetLogs() string

GetLogs returns the logs of a service

func (*MinikubeRunner) ParseEnvCmdOutput added in v0.31.0

func (m *MinikubeRunner) ParseEnvCmdOutput(out string) map[string]string

ParseEnvCmdOutput parses the output of `env` (assumes bash)

func (*MinikubeRunner) Remove added in v0.22.0

func (m *MinikubeRunner) Remove(f assets.CopyableFile) error

Remove removes a file

func (*MinikubeRunner) RunCommand

func (m *MinikubeRunner) RunCommand(cmdStr string, failError bool, waitForRun ...bool) (string, string)

RunCommand executes a command, optionally checking for error and by default waits for run to finish

func (*MinikubeRunner) RunCommandRetriable added in v1.3.0

func (m *MinikubeRunner) RunCommandRetriable(cmdStr string, waitForRun ...bool) (stdout string, stderr string, err error)

RunCommandRetriable Error executes a command, returns error the purpose of this command is to make it retriable and better logging for retrying

func (*MinikubeRunner) RunDaemon added in v0.18.0

func (m *MinikubeRunner) RunDaemon(cmdStr string) (*exec.Cmd, *bufio.Reader)

RunDaemon executes a command, returning the stdout

func (*MinikubeRunner) RunDaemon2 added in v0.34.0

func (m *MinikubeRunner) RunDaemon2(cmdStr string) (*exec.Cmd, *bufio.Reader, *bufio.Reader)

RunDaemon2 executes a command, returning the stdout and stderr

func (*MinikubeRunner) RunWithContext added in v0.31.0

func (m *MinikubeRunner) RunWithContext(ctx context.Context, cmdStr string, wait ...bool) (string, string, error)

RunWithContext calls the minikube command with a context, useful for timeouts.

func (*MinikubeRunner) SSH

func (m *MinikubeRunner) SSH(cmdStr string) (string, error)

SSH returns the output of running a command using SSH

func (*MinikubeRunner) Start

func (m *MinikubeRunner) Start(opts ...string) (stdout string, stderr string, err error)

Start starts the cluster

func (*MinikubeRunner) Status added in v1.3.0

func (m *MinikubeRunner) Status() (status string, stderr string, err error)

Status returns the status of a service

func (*MinikubeRunner) TearDown added in v1.3.0

func (m *MinikubeRunner) TearDown(t *testing.T)

TearDown deletes minikube without waiting for it. used to free up ram/cpu after each test

Jump to

Keyboard shortcuts

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