operations

package
v1.17.0-beta22 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BasicOperation

type BasicOperation struct {
	OpName       string
	OpAction     actions.ClusterAction
	OpAssertion  assertions.ClusterAssertion
	OpAssertions []assertions.ClusterAssertion
}

BasicOperation is an implementation of the Operation interface, with the minimal properties required

func (*BasicOperation) Action

func (o *BasicOperation) Action() actions.ClusterAction

func (*BasicOperation) Assertion

func (*BasicOperation) String

func (o *BasicOperation) String() string

type Operation

type Operation interface {
	fmt.Stringer

	// Action returns the actions.ClusterAction that will be executed against the cluster
	// This is a function that mutates state on the cluster
	Action() actions.ClusterAction

	// Assertion returns the assertions.ClusterAssertion that will run after the Action is executed
	// This is a function that asserts behavior of the cluster
	Assertion() assertions.ClusterAssertion
}

Operation defines the properties of an operation that can be applied to a Kubernetes cluster An Operation is intended to be simple, and encapsulate two concepts:

Action - A mutation that is applied to a cluster
Assertion - An assertion that the mutation behaved appropriately

type Operator

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

Operator is responsible for executing Operation against a Kubernetes Cluster. This is meant to mirror the behavior of a user of the Gloo Gateway product. Although we operate against a Kubernetes Cluster, an Operator is intentionally unaware of Kubernetes behavior, and instead is more of a scheduler of Operation. This allows us to test its functionality, and also more easily inject behaviors

func NewGinkgoOperator

func NewGinkgoOperator() *Operator

NewGinkgoOperator returns an Operator used for the Ginkgo test framework

func NewOperator

func NewOperator() *Operator

NewOperator returns an Operator

func (*Operator) ExecuteOperations

func (o *Operator) ExecuteOperations(ctx context.Context, operations ...Operation) error

ExecuteOperations executes a set of Operation. NOTE: The Operator doesn't attempt to undo any of these Operation so if you are modifying resources on the Cluster, it is your responsibility to perform Operation to undo those changes If you would like to rely on this functionality, please see ExecuteReversibleOperations.

func (*Operator) ExecuteReversibleOperations

func (o *Operator) ExecuteReversibleOperations(ctx context.Context, operations ...ReversibleOperation) error

ExecuteReversibleOperations executes a set of ReversibleOperation. In order, the ReversibleOperation.Do will be executed, and then on success or failure the ReversibleOperation.Undo will also be executed. This way, developers do not need to worry about resources being cleaned up appropriately in tests.

func (*Operator) WithAssertionInterceptor

func (o *Operator) WithAssertionInterceptor(assertionInterceptor func(func()) error) *Operator

WithAssertionInterceptor sets the function that will be used to intercept ScenarioAssertion failures

func (*Operator) WithProgressWriter

func (o *Operator) WithProgressWriter(writer io.Writer) *Operator

WithProgressWriter sets the io.Writer used by the Operator

type ReversibleOperation

type ReversibleOperation struct {
	Do   Operation
	Undo Operation
}

ReversibleOperation combines two Operation, that are the inverse of one another We recommend that developers write tests using ReversibleOperation. This is because it requires developers to consider how to write operations that leave the cluster in the state they left it. If resources are accidentally not cleaned up properly, that can lead to pollution in the cluster and test flakes.

Jump to

Keyboard shortcuts

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