fixtures

package
v3.0.0-...-8a51905 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2024 License: Apache-2.0 Imports: 48 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 (
	CI Need = func(s *E2ESuite) (bool, string) {
		return os.Getenv("CI") != "", "CI"
	}
	BaseLayerArtifacts Need = func(s *E2ESuite) (bool, string) {
		met, _ := None(K8SAPI, Kubelet)(s)
		return met, "base layer artifact support"
	}
	Docker   = Executor("docker")
	Emissary = Executor("emissary")
	K8SAPI   = Executor("k8sapi")
	Kubelet  = Executor("kubelet")
)
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"
	}
)
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()
	assert.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()
		if assert.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

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) Need

func (s *E2ESuite) Need(needs ...Need)

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 Need

type Need func(s *E2ESuite) (met bool, message string)

func All

func All(needs ...Need) Need

func Any

func Any(needs ...Need) Need

func Executor

func Executor(e string) Need

func None

func None(needs ...Need) Need

type Persistence

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

func (*Persistence) Close

func (s *Persistence) Close()

func (*Persistence) IsEnabled

func (s *Persistence) IsEnabled() bool

type PodCondition

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

func (t *Then) ExpectArtifact(nodeName, artifactName string, f func(t *testing.T, data []byte))

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) 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) 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) *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) 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) ResumeCronWorkflow

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

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

func (w *When) SuspendCronWorkflow() *When

func (*When) Then

func (w *When) Then() *Then

func (*When) UpdateConfigMap

func (w *When) UpdateConfigMap(name string, data 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

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"

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

func (*When) WaitForWorkflowList

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

Jump to

Keyboard shortcuts

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