fixtures

package
v3.0.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2021 License: Apache-2.0 Imports: 39 Imported by: 0

Documentation

Index

Constants

View Source
const Label = "argo-e2e"
View Source
const Namespace = "argo"

Variables

View Source
var (
	RBAC Need = func(s *E2ESuite) (bool, string) {
		return os.Getenv("CI") != "", "Kubernetes RBAC (and therefore CI)"
	}
	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"
	}
	Offloading Need = func(s *E2ESuite) (bool, string) {
		return s.Persistence.IsEnabled(), "offloading enabled"
	}
	WorkflowArchive Need = func(s *E2ESuite) (bool, string) {
		return s.Persistence.IsEnabled(), "workflow archive enabled"
	}
	Docker  = Executor("docker")
	K8SAPI  = Executor("k8sapi")
	Kubelet = Executor("kubelet")
	PNS     = Executor("pns")
)
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)
		}
	}
}

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
var ToBeArchived Condition = func(wf *wfv1.Workflow) bool { return wf.Labels[common.LabelKeyWorkflowArchivingStatus] == "Archived" }
var ToBeCompleted Condition = func(wf *wfv1.Workflow) bool { return wf.Labels[common.LabelKeyCompleted] == "true" }
var ToBeDone Condition = func(wf *wfv1.Workflow) bool {
	return ToBeCompleted(wf) && wf.Labels[common.LabelKeyWorkflowArchivingStatus] != "Pending"
}

`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 ToBeRunning Condition = func(wf *wfv1.Workflow) bool {
	return wf.Status.Nodes.Any(func(node wfv1.NodeStatus) bool {
		return node.Phase == wfv1.NodeRunning
	})
}
var ToBeSucceeded Condition = func(wf *wfv1.Workflow) bool { return wf.Status.Phase == wfv1.WorkflowSucceeded }
var ToBeWaitingOnAMutex Condition = func(wf *wfv1.Workflow) bool {
	return wf.Status.Synchronization != nil && wf.Status.Synchronization.Mutex != nil
}
var ToStart Condition = func(wf *wfv1.Workflow) bool { return !wf.Status.StartedAt.IsZero() }

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

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

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

func (w *When) RunCli(args []string, block func(t *testing.T, output string, err error)) *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) Then

func (w *When) Then() *Then

func (*When) Wait

func (w *When) Wait(timeout time.Duration) *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

Jump to

Keyboard shortcuts

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