integration

package
v1.8.1 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2020 License: Apache-2.0 Imports: 23 Imported by: 0

README

Integration tests

The basics

To run all tests from the minikube root directory:

make integration

Quickly iterating on a single test

Run a single test on an active cluster:

make integration -e TEST_ARGS="-test.run TestFunctional/parallel/MountCmd --profile=minikube --cleanup=false"

WARNING: For this to work repeatedly, the test must be written so that it cleans up after itself.

See main.go for details.

Disabling parallelism

make integration -e TEST_ARGS="-test.parallel=1"

Testing philosophy

  • Tests should be so simple as to be correct by inspection
  • Readers should need to read only the test body to understand the test
  • Top-to-bottom readability is more important than code de-duplication

Tests are typically read with a great air of skepticism, because chances are they are being read only when things are broken.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CanCleanup added in v1.5.0

func CanCleanup() bool

CanCleanup returns if cleanup is allowed

func Cleanup added in v1.4.0

func Cleanup(t *testing.T, profile string, cancel context.CancelFunc)

Cleanup cleans up after a test run

func CleanupWithLogs added in v1.4.0

func CleanupWithLogs(t *testing.T, profile string, cancel context.CancelFunc)

CleanupWithLogs cleans up after a test run, fetching logs and deleting the profile

func ExpectedDefaultDriver added in v1.5.0

func ExpectedDefaultDriver() string

ExpectedDefaultDriver returns the expected default driver, if any

func HyperVDriver added in v1.4.0

func HyperVDriver() bool

HyperVDriver returns whether or not this test is using the Hyper-V driver

func MaybeParallel added in v1.4.0

func MaybeParallel(t *testing.T)

MaybeParallel sets that the test should run in parallel

func Minutes added in v1.8.0

func Minutes(n int) time.Duration

Minutes will return timeout in minutes based on how slow the machine is

func NoneDriver added in v1.4.0

func NoneDriver() bool

NoneDriver returns whether or not this test is using the none driver

func PodWait added in v1.4.0

func PodWait(ctx context.Context, t *testing.T, profile string, ns string, selector string, timeout time.Duration) ([]string, error)

PodWait waits for pods to achieve a running state.

func ReadLineWithTimeout added in v1.4.0

func ReadLineWithTimeout(b *bufio.Reader, timeout time.Duration) (string, error)

ReadLineWithTimeout reads a line of text from a buffer with a timeout

func Seconds added in v1.8.0

func Seconds(n int) time.Duration

Seconds will return timeout in minutes based on how slow the machine is

func StartArgs added in v1.4.0

func StartArgs() []string

StartArgs returns the arguments normally used for starting minikube

func Status added in v1.4.0

func Status(ctx context.Context, t *testing.T, path string, profile string, key string) string

Status returns a minikube component status as a string

func Target added in v1.4.0

func Target() string

Target returns where the minikube binary can be found

func TestMain

func TestMain(m *testing.M)

TestMain is the test main

func UniqueProfileName added in v1.4.0

func UniqueProfileName(prefix string) string

UniqueProfileName returns a reasonably unique profile name

Types

type RunResult added in v1.4.0

type RunResult struct {
	Stdout   *bytes.Buffer
	Stderr   *bytes.Buffer
	ExitCode int
	Args     []string
}

RunResult stores the result of an cmd.Run call

func Run added in v1.4.0

func Run(t *testing.T, cmd *exec.Cmd) (*RunResult, error)

Run is a test helper to log a command being executed \_(ツ)_/¯

func (RunResult) Command added in v1.4.0

func (rr RunResult) Command() string

Command returns a human readable command string that does not induce eye fatigue

func (RunResult) Output added in v1.4.0

func (rr RunResult) Output() string

Output returns human-readable output for an execution result

type StartSession added in v1.4.0

type StartSession struct {
	Stdout *bufio.Reader
	Stderr *bufio.Reader
	// contains filtered or unexported fields
}

StartSession stores the result of an cmd.Start call

func Start added in v1.4.0

func Start(t *testing.T, cmd *exec.Cmd) (*StartSession, error)

Start starts a process in the background, streaming output

func (*StartSession) Stop added in v1.4.0

func (ss *StartSession) Stop(t *testing.T)

Stop stops the started process

Jump to

Keyboard shortcuts

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