upgrade

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2022 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidTestingOutputMethod when given invalid testing output method.
	ErrInvalidTestingOutputMethod = errors.New("invalid testing output method")
	// ErrNoTestingTRegisteredForTest when no testing.TB registered for test.
	ErrNoTestingTRegisteredForTest = errors.New("no testing.TB registered for test")
)
View Source
var (
	// DefaultWaitTime holds a default value for WaitForStopEventConfiguration
	// when used within a NewBackgroundVerification function.
	DefaultWaitTime = 20 * time.Millisecond

	// DefaultOnWait is a implementation that will be called by default for each
	// wait performed by WaitForStopEvent when used within
	// NewBackgroundVerification function.
	DefaultOnWait = func(bc BackgroundContext, self WaitForStopEventConfiguration) {

	}
)

Functions

func WaitForStopEvent

func WaitForStopEvent(bc BackgroundContext, w WaitForStopEventConfiguration)

WaitForStopEvent will wait until upgrade suite sends a stop event to it. After that happen a handler is invoked to verify environment state and report failures.

Types

type BackgroundContext

type BackgroundContext struct {
	Log  *zap.SugaredLogger
	Stop <-chan StopEvent
	// contains filtered or unexported fields
}

BackgroundContext is a upgrade test execution context that will be passed down to each handler of BackgroundOperation. It contains a StopEvent channel which end user should use to obtain a testing.T for error reporting. Until StopEvent is sent user may use zap.SugaredLogger to log state of execution if necessary. The logs are stored in a threadSafeBuffer and flushed to the test output when the test fails.

type BackgroundOperation

type BackgroundOperation interface {
	// Name is a human readable operation title, and it will be used in t.Run.
	Name() string
	// Setup method may be used to set up environment before upgrade/downgrade is
	// performed.
	Setup() func(c Context)
	// Handler will be executed in background while upgrade/downgrade is being
	// executed. It can be used to constantly validate environment during that
	// time and/or wait for StopEvent being sent. After StopEvent is received
	// user should validate environment, clean up resources, and report found
	// issues to testing.T forwarded in StepEvent.
	Handler() func(bc BackgroundContext)
}

BackgroundOperation represents a upgrade test operation that will be performed in background while other operations is running. To achieve that a passed BackgroundContext should be used to synchronize it's operations with Ready and Stop channels.

func NewBackgroundOperation

func NewBackgroundOperation(name string, setup func(c Context),
	handler func(bc BackgroundContext)) BackgroundOperation

NewBackgroundOperation creates a new background operation or test that can be notified to stop its operation.

func NewBackgroundVerification

func NewBackgroundVerification(name string, setup func(c Context), verify func(c Context)) BackgroundOperation

NewBackgroundVerification is convenience function to easily setup a background operation that will setup environment and then verify environment status after receiving a StopEvent.

type Configuration

type Configuration struct {
	T *testing.T
	// TODO(mgencur): Remove when dependent repositories migrate to LogConfig.
	// Keep this for backwards compatibility.
	Log *zap.Logger
	LogConfig
}

Configuration holds required and optional configuration to run upgrade tests.

type Context

type Context struct {
	T   *testing.T
	Log *zap.SugaredLogger
}

Context is an object that is passed to every operation. It contains testing.T for error reporting and zap.SugaredLogger for unbuffered logging.

type Installations

type Installations struct {
	Base          []Operation
	UpgradeWith   []Operation
	DowngradeWith []Operation
}

Installations holds a list of operations that will install Knative components in different versions.

type LogConfig

type LogConfig struct {
	// Config from which the zap.Logger be created.
	Config zap.Config
	// Options holds options for the zap.Logger.
	Options []zap.Option
}

LogConfig holds the logger configuration. It allows for passing just the logger configuration and also a custom function for building the resulting logger.

type Operation

type Operation interface {
	// Name is a human readable operation title, and it will be used in t.Run.
	Name() string
	// Handler is a function that will be called to perform an operation.
	Handler() func(c Context)
}

Operation represents a upgrade test operation like test or installation that can be provided by specific component or reused in aggregating components.

func NewOperation

func NewOperation(name string, handler func(c Context)) Operation

NewOperation creates a new upgrade operation or test.

type StopEvent

type StopEvent struct {
	T        *testing.T
	Finished chan<- struct{}
	// contains filtered or unexported fields
}

StopEvent represents an event that is to be received by background operation to indicate that is should stop it's operations and validate results using passed T. User should use Finished channel to signalize upgrade suite that all stop & verify operations are finished and it is safe to end tests.

func (*StopEvent) Name

func (s *StopEvent) Name() string

Name returns a friendly human readable text.

type Suite

type Suite struct {
	Tests         Tests
	Installations Installations
}

Suite represents a upgrade tests suite that can be executed and will perform execution in predictable manner.

func (*Suite) Execute

func (s *Suite) Execute(c Configuration)

Execute the Suite of upgrade tests with a Configuration given.

type SuiteExecutor

type SuiteExecutor interface {
	Execute(c Configuration)
}

SuiteExecutor is to execute upgrade test suite.

type Tests

type Tests struct {
	PreUpgrade    []Operation
	PostUpgrade   []Operation
	PostDowngrade []Operation
	Continual     []BackgroundOperation
}

Tests holds a list of operations for various part of upgrade suite.

type WaitForStopEventConfiguration

type WaitForStopEventConfiguration struct {
	Name     string
	OnStop   func(event StopEvent)
	OnWait   func(bc BackgroundContext, self WaitForStopEventConfiguration)
	WaitTime time.Duration
}

WaitForStopEventConfiguration holds a values to be used be WaitForStopEvent function. OnStop will be called when StopEvent is sent. OnWait will be invoked in a loop while waiting, and each wait act is driven by WaitTime amount.

Jump to

Keyboard shortcuts

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