Documentation ¶
Index ¶
- type BasicOperation
- type Operation
- type Operator
- func (o *Operator) ExecuteOperations(ctx context.Context, operations ...Operation) error
- func (o *Operator) ExecuteReversibleOperations(ctx context.Context, operations ...ReversibleOperation) error
- func (o *Operator) Logf(messageFmt string, args ...any)
- func (o *Operator) WithAssertionInterceptor(assertionInterceptor func(func()) error) *Operator
- func (o *Operator) WithProgressWriter(writer io.Writer) *Operator
- type ReversibleOperation
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 (o *BasicOperation) Assertion() assertions.ClusterAssertion
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 (*Operator) ExecuteOperations ¶
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 ¶
WithAssertionInterceptor sets the function that will be used to intercept ScenarioAssertion failures
type ReversibleOperation ¶
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.