upgrade

package
v0.0.0-...-8119179 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2024 License: Apache-2.0 Imports: 4 Imported by: 17

Documentation

Index

Constants

This section is empty.

Variables

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 {
	T    *testing.T
	Log  *zap.SugaredLogger
	Stop <-chan struct{}
}

BackgroundContext is a upgrade test execution context that will be passed down to each handler of BackgroundOperation. It contains a stop event channel. Until stop event is sent user may use zap.SugaredLogger to log state of execution if necessary.

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 stop event.

type Configuration

type Configuration struct {
	T *testing.T
	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.
	// Deprecated: This config doesn't have effect. Use Options instead.
	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 options.

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 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. When the suite includes Continual tests the number of logical CPUs usable by the test process must be at least <NUMBER OF CONTINUAL TESTS> + 1. The -parallel test flag or GOMAXPROCS environment variable might be used to adjust the settings.

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()
	OnWait   func(bc BackgroundContext, self WaitForStopEventConfiguration)
	WaitTime time.Duration
}

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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