utils

package
v0.0.0-...-02c6b06 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var EmptyMockLocation = &LocationsMock{
	GetTestDefinitionsFunc: func(step tmv1beta1.StepDefinition) ([]*testdefinition.TestDefinition, error) {
		return []*testdefinition.TestDefinition{}, nil
	},
}

Functions

func DeleteTestrun

func DeleteTestrun(tmClient client.Client, tr *tmv1beta1.Testrun)

DeleteTestrun deletes a testrun and expects to be successful.

func DisruptiveTestDef

func DisruptiveTestDef(name string) *testdefinition.TestDefinition

DisruptiveTestDef creates a new disruptive testdefinition with a name

func DumpState

func DumpState(ctx context.Context, log logr.Logger, client client.Client, tr, foundTestrun *tmv1beta1.Testrun)

DumpState dumps the current testrun und workflow state

func GetWorkflow

func GetWorkflow(ctx context.Context, tmClient client.Client, tr *tmv1beta1.Testrun) (*argov1.Workflow, error)

GetWorkflow returns the argo workflow of a testrun.

func HTTPGet

func HTTPGet(url string) (*http.Response, error)

HTTPGet performs an HTTP get with a default timeout of 60 seconds

func ReadJSONFile

func ReadJSONFile(path string, obj interface{}) error

ReadJSONFile reads a file and deserializes the json into the given object

func ReadYAMLFile

func ReadYAMLFile(path string, obj interface{}) error

ReadYAMLFile reads a file and deserializes the yaml into the given object

func RunTestrun

func RunTestrun(ctx context.Context, log logr.Logger, tmClient client.Client, tr *tmv1beta1.Testrun, phase argov1.WorkflowPhase, timeout time.Duration, f WatchFunc) (*tmv1beta1.Testrun, *argov1.Workflow, error)

RunTestrunUntilCompleted executes a testrun on a cluster until a specific state has been reached and returns the corresponding executed testrun and workflow. Note: Deletion of the workflow on error should be handled by the calling test.

func RunTestrunUntilCompleted

func RunTestrunUntilCompleted(ctx context.Context, log logr.Logger, tmClient client.Client, tr *tmv1beta1.Testrun, phase argov1.WorkflowPhase, timeout time.Duration) (*tmv1beta1.Testrun, *argov1.Workflow, error)

RunTestrunUntilCompleted executes a testrun on a cluster until it is finished and returns the corresponding executed testrun and workflow. Note: Deletion of the workflow on error should be handled by the calling test. DEPRECATED: this is just a wrapper function to keep functionality across tests. In the future the RunTestrun function should be directly used.

func SerialTestDef

func SerialTestDef(name string) *testdefinition.TestDefinition

SerialTestDef creates a new serial testdefinition with a name

func TestDef

func TestDef(name string) *testdefinition.TestDefinition

TestDef creates a new empty testdefinition with a step name

func TestDefWithConfig

TestDefWithConfig adds a config to the given testdefinition and returns it

func WaitForClusterReadiness

func WaitForClusterReadiness(log logr.Logger, clusterClient client.Client, namespace string, maxWaitTime time.Duration) error

WaitForClusterReadiness waits for all testmachinery components to be ready.

func WatchTestrun

func WatchTestrun(ctx context.Context, tmClient client.Client, tr *tmv1beta1.Testrun, timeout time.Duration, f WatchFunc) error

WatchTestrun watches a testrun until the maxwait is reached. Every time a testrun can be found without a problem the function f is called.

func WatchTestrunUntilCompleted

func WatchTestrunUntilCompleted(ctx context.Context, tmClient client.Client, tr *tmv1beta1.Testrun, timeout time.Duration) (*tmv1beta1.Testrun, error)

WatchTestrunUntilCompleted watches a testrun to finish and returns the newest testrun object.

func WatchUntilCompletedFunc

func WatchUntilCompletedFunc(tr *tmv1beta1.Testrun) (bool, error)

WatchUntilCompletedFunc waits until the testrun is completed

Types

type LocationsMock

type LocationsMock struct {
	TestDefinitions        []*testdefinition.TestDefinition
	StepToTestDefinitions  map[string][]*testdefinition.TestDefinition
	GetTestDefinitionsFunc func(step tmv1beta1.StepDefinition) ([]*testdefinition.TestDefinition, error)
}

func (*LocationsMock) GetTestDefinitions

func (t *LocationsMock) GetTestDefinitions(step tmv1beta1.StepDefinition) ([]*testdefinition.TestDefinition, error)

type TDLocationMock

type TDLocationMock struct{}

func (*TDLocationMock) GetLocation

func (l *TDLocationMock) GetLocation() *tmv1beta1.TestLocation

func (*TDLocationMock) GitInfo

func (l *TDLocationMock) GitInfo() testdefinition.GitInfo

func (*TDLocationMock) Name

func (l *TDLocationMock) Name() string

func (*TDLocationMock) SetTestDefs

func (l *TDLocationMock) SetTestDefs(_ map[string]*testdefinition.TestDefinition) error

func (*TDLocationMock) Type

type WatchFunc

type WatchFunc = func(*tmv1beta1.Testrun) (bool, error)

WatchFunc is the function to check if the testrun has a specific state

func WatchUntil

func WatchUntil(timeout time.Duration) WatchFunc

WatchUntil waits a certain timeout before the testrun watch is canceled.

Jump to

Keyboard shortcuts

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