fixtures

package
v3.6.2 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2024 License: Apache-2.0 Imports: 51 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Namespace = "argo"
	Label     = workflow.WorkflowFullName + "/test" // mark this workflow as a test
)

Variables

View Source
var (
	ToBeRunning             = ToHavePhase(wfv1.WorkflowRunning)
	ToBeSucceeded           = ToHavePhase(wfv1.WorkflowSucceeded)
	ToBeErrored             = ToHavePhase(wfv1.WorkflowError)
	ToBeFailed              = ToHavePhase(wfv1.WorkflowFailed)
	ToBeCompleted Condition = func(wf *wfv1.Workflow) (bool, string) {
		return wf.Labels[common.LabelKeyCompleted] == "true", "to be completed"
	}
	ToStart          Condition = func(wf *wfv1.Workflow) (bool, string) { return !wf.Status.StartedAt.IsZero(), "to start" }
	ToHaveRunningPod Condition = func(wf *wfv1.Workflow) (bool, string) {
		return wf.Status.Nodes.Any(func(node wfv1.NodeStatus) bool {
			return node.Type == wfv1.NodeTypePod && node.Phase == wfv1.NodeRunning
		}), "to have running pod"
	}
	ToHaveFailedPod Condition = func(wf *wfv1.Workflow) (bool, string) {
		return wf.Status.Nodes.Any(func(node wfv1.NodeStatus) bool {
			return node.Type == wfv1.NodeTypePod && node.Phase == wfv1.NodeFailed
		}), "to have failed pod"
	}
)
View Source
var EnvFactor = env.LookupEnvIntOr("E2E_ENV_FACTOR", 1)
View Source
var HasInvolvedObject = func(kind string, uid types.UID) func(event apiv1.Event) bool {
	return func(e apiv1.Event) bool {
		return e.InvolvedObject.Kind == kind && e.InvolvedObject.UID == uid
	}
}
View Source
var HasInvolvedObjectWithName = func(kind string, name string) func(event apiv1.Event) bool {
	return func(e apiv1.Event) bool {
		return e.InvolvedObject.Kind == kind && e.InvolvedObject.Name == name
	}
}
View Source
var NoError = func(t *testing.T, output string, err error) {
	t.Helper()
	require.NoError(t, err, output)
}
View Source
var OutputRegexp = func(rx string) func(t *testing.T, output string, err error) {
	return func(t *testing.T, output string, err error) {
		t.Helper()
		require.NoError(t, err, output)
		assert.Regexp(t, rx, output)
	}
}
View Source
var ToHavePhase = func(p wfv1.WorkflowPhase) Condition {
	return func(wf *wfv1.Workflow) (bool, string) {
		return wf.Status.Phase == p && wf.Labels[common.LabelKeyWorkflowArchivingStatus] != "Pending", fmt.Sprintf("to be %s", p)
	}
}

Functions

func Exec

func Exec(name string, args ...string) (string, error)

func LoadObject

func LoadObject(text string) (runtime.Object, error)

LoadObject is used to load yaml to runtime.Object

Types

type Condition

type Condition func(wf *wfv1.Workflow) (bool, string)
var ToBeArchived Condition = func(wf *wfv1.Workflow) (bool, string) {
	return wf.Labels[common.LabelKeyWorkflowArchivingStatus] == "Archived", "to be archived"
}
var ToBeDone Condition = func(wf *wfv1.Workflow) (bool, string) {
	toBeCompleted, _ := ToBeCompleted(wf)
	return toBeCompleted && wf.Labels[common.LabelKeyWorkflowArchivingStatus] != "Pending", "to be done"
}

`ToBeDone` replaces `ToFinish` which also makes sure the workflow is both complete not pending archiving. This additional check is not needed for most use case, however in `AfterTest` we delete the workflow and this creates a lot of warning messages in the logs that are cause by misuse rather than actual problems.

var ToBeWaitingOnAMutex Condition = func(wf *wfv1.Workflow) (bool, string) {
	return wf.Status.Synchronization != nil && wf.Status.Synchronization.Mutex != nil, "to be waiting on a mutex"
}

type E2ESuite

type E2ESuite struct {
	suite.Suite
	Config      *config.Config
	Persistence *Persistence
	RestConfig  *rest.Config

	KubeClient kubernetes.Interface
	// contains filtered or unexported fields
}

func (*E2ESuite) AfterTest added in v3.1.0

func (s *E2ESuite) AfterTest(suiteName, testName string)

func (*E2ESuite) BeforeTest

func (s *E2ESuite) BeforeTest(string, string)

func (*E2ESuite) CheckError

func (s *E2ESuite) CheckError(err error)

func (*E2ESuite) DeleteResources

func (s *E2ESuite) DeleteResources()

func (*E2ESuite) GetBasicAuthToken

func (s *E2ESuite) GetBasicAuthToken() string

func (*E2ESuite) GetServiceAccountToken

func (s *E2ESuite) GetServiceAccountToken() (string, error)

func (*E2ESuite) Given

func (s *E2ESuite) Given() *Given

func (*E2ESuite) SetupSuite

func (s *E2ESuite) SetupSuite()

func (*E2ESuite) TearDownSuite

func (s *E2ESuite) TearDownSuite()

type Given

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

func (*Given) ClusterWorkflowTemplate

func (g *Given) ClusterWorkflowTemplate(text string) *Given

func (*Given) CronWorkflow

func (g *Given) CronWorkflow(text string) *Given

func (*Given) Exec

func (g *Given) Exec(name string, args []string, block func(t *testing.T, output string, err error)) *Given

func (*Given) RunCli

func (g *Given) RunCli(args []string, block func(t *testing.T, output string, err error)) *Given

func (*Given) When

func (g *Given) When() *When

func (*Given) Workflow

func (g *Given) Workflow(text string) *Given

creates a workflow based on the parameter, this may be:

1. A file name if it starts with "@" 2. Raw YAML.

func (*Given) WorkflowEventBinding

func (g *Given) WorkflowEventBinding(text string) *Given

func (*Given) WorkflowName

func (g *Given) WorkflowName(name string) *Given

func (*Given) WorkflowTemplate

func (g *Given) WorkflowTemplate(text string) *Given

type Persistence

type Persistence struct {
	WorkflowArchive sqldb.WorkflowArchive
	// contains filtered or unexported fields
}

func (*Persistence) Close

func (s *Persistence) Close()

func (*Persistence) IsEnabled

func (s *Persistence) IsEnabled() bool

type PodCondition added in v3.2.5

type PodCondition func(p *corev1.Pod) bool
var (
	PodCompleted PodCondition = func(p *corev1.Pod) bool {
		return p.Labels[common.LabelKeyCompleted] == "true"
	}
	PodDeleted PodCondition = func(p *corev1.Pod) bool {
		return !p.DeletionTimestamp.IsZero()
	}
)

type Then

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

func (*Then) ExpectArtifact added in v3.1.0

func (t *Then) ExpectArtifact(nodeName string, artifactName string, bucketName string, f func(t *testing.T, object minio.ObjectInfo, err error))

func (*Then) ExpectArtifactByKey added in v3.4.0

func (t *Then) ExpectArtifactByKey(key string, bucketName string, f func(t *testing.T, object minio.ObjectInfo, err error))

func (*Then) ExpectAuditEvents

func (t *Then) ExpectAuditEvents(filter func(event apiv1.Event) bool, num int, block func(*testing.T, []apiv1.Event)) *Then

func (*Then) ExpectCron

func (t *Then) ExpectCron(block func(t *testing.T, cronWf *wfv1.CronWorkflow)) *Then

func (*Then) ExpectPVCDeleted added in v3.4.6

func (t *Then) ExpectPVCDeleted() *Then

func (*Then) ExpectPods added in v3.3.0

func (t *Then) ExpectPods(f func(t *testing.T, pods []apiv1.Pod)) *Then

func (*Then) ExpectWorkflow

func (t *Then) ExpectWorkflow(block func(t *testing.T, metadata *metav1.ObjectMeta, status *wfv1.WorkflowStatus)) *Then

func (*Then) ExpectWorkflowDeleted

func (t *Then) ExpectWorkflowDeleted() *Then

func (*Then) ExpectWorkflowList

func (t *Then) ExpectWorkflowList(listOptions metav1.ListOptions, block func(t *testing.T, wfList *wfv1.WorkflowList)) *Then

func (*Then) ExpectWorkflowName

func (t *Then) ExpectWorkflowName(workflowName string, block func(t *testing.T, metadata *metav1.ObjectMeta, status *wfv1.WorkflowStatus)) *Then

func (*Then) ExpectWorkflowNode

func (t *Then) ExpectWorkflowNode(selector func(status wfv1.NodeStatus) bool, f func(t *testing.T, status *wfv1.NodeStatus, pod *apiv1.Pod)) *Then

Check on a specific node in the workflow. If no node matches the selector, then the NodeStatus and Pod will be nil. If the pod does not exist (e.g. because it was deleted) then the Pod will be nil too.

func (*Then) ExpectWorkflowTaskSet added in v3.4.17

func (t *Then) ExpectWorkflowTaskSet(block func(t *testing.T, wfts *wfv1.WorkflowTaskSet)) *Then

func (*Then) RunCli

func (t *Then) RunCli(args []string, block func(t *testing.T, output string, err error)) *Then

func (*Then) When

func (t *Then) When() *When

type When

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

func (*When) And

func (w *When) And(block func()) *When

func (*When) CreateClusterWorkflowTemplates

func (w *When) CreateClusterWorkflowTemplates() *When

func (*When) CreateConfigMap

func (w *When) CreateConfigMap(name string, data map[string]string, customLabels map[string]string) *When

func (*When) CreateCronWorkflow

func (w *When) CreateCronWorkflow() *When

func (*When) CreateWorkflowEventBinding

func (w *When) CreateWorkflowEventBinding() *When

func (*When) CreateWorkflowTemplates

func (w *When) CreateWorkflowTemplates() *When

func (*When) DeleteConfigMap

func (w *When) DeleteConfigMap(name string) *When

func (*When) DeleteMemoryQuota

func (w *When) DeleteMemoryQuota() *When

func (*When) DeletePodsQuota

func (w *When) DeletePodsQuota() *When

func (*When) DeleteStorageQuota

func (w *When) DeleteStorageQuota() *When

func (*When) DeleteWorkflow

func (w *When) DeleteWorkflow() *When

func (*When) Exec

func (w *When) Exec(name string, args []string, block func(t *testing.T, output string, err error)) *When

func (*When) GetWorkflow added in v3.5.8

func (w *When) GetWorkflow() *wfv1.Workflow

func (*When) Given

func (w *When) Given() *Given

func (*When) MemoryQuota

func (w *When) MemoryQuota(memoryLimit string) *When

func (*When) PodsQuota

func (w *When) PodsQuota(podLimit int) *When

func (*When) RemoveFinalizers added in v3.4.0

func (w *When) RemoveFinalizers(shouldErr bool) *When

func (*When) ResumeCronWorkflow added in v3.3.0

func (w *When) ResumeCronWorkflow(string) *When

func (*When) RunCli

func (w *When) RunCli(args []string, block func(t *testing.T, output string, err error)) *When

func (*When) ShutdownWorkflow added in v3.3.0

func (w *When) ShutdownWorkflow(strategy wfv1.ShutdownStrategy) *When

func (*When) StorageQuota

func (w *When) StorageQuota(storageLimit string) *When

func (*When) SubmitWorkflow

func (w *When) SubmitWorkflow() *When

func (*When) SubmitWorkflowsFromClusterWorkflowTemplates

func (w *When) SubmitWorkflowsFromClusterWorkflowTemplates() *When

func (*When) SubmitWorkflowsFromCronWorkflows

func (w *When) SubmitWorkflowsFromCronWorkflows() *When

func (*When) SubmitWorkflowsFromWorkflowTemplates

func (w *When) SubmitWorkflowsFromWorkflowTemplates() *When

func (*When) SuspendCronWorkflow added in v3.3.0

func (w *When) SuspendCronWorkflow() *When

func (*When) Then

func (w *When) Then() *Then

func (*When) UpdateConfigMap added in v3.2.0

func (w *When) UpdateConfigMap(name string, data map[string]string, customLabels map[string]string) *When

func (*When) Wait

func (w *When) Wait(timeout time.Duration) *When

Wait creates slow flaky tests DEPRECATED: do not use this

func (*When) WaitForPod added in v3.2.5

func (w *When) WaitForPod(condition PodCondition) *When

func (*When) WaitForWorkflow

func (w *When) WaitForWorkflow(options ...interface{}) *When

Wait for a workflow to meet a condition: Options: * `time.Duration` - change the timeout - 30s by default * `string` - either:

  • the workflow's name (not spaces)
  • or a new message (if it contain spaces) - default "to finish"

* `WorkflowCompletionOkay“ (bool alias): if this is true, we won't stop checking for the other options

  • just because the Workflow completed

* `Condition` - a condition - `ToFinish` by default

func (*When) WaitForWorkflowDeletion added in v3.4.0

func (w *When) WaitForWorkflowDeletion() *When

func (*When) WaitForWorkflowList added in v3.3.0

func (w *When) WaitForWorkflowList(listOptions metav1.ListOptions, condition func(list []wfv1.Workflow) bool) *When

func (*When) WorkflowCondition added in v3.4.5

func (w *When) WorkflowCondition(condition func(wf *wfv1.Workflow) bool) bool

test condition function on Workflow

type WorkflowCompletionOkay added in v3.4.0

type WorkflowCompletionOkay bool

Jump to

Keyboard shortcuts

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