Documentation
¶
Index ¶
- Constants
- Variables
- func Exec(ctx context.Context, name string, stdin string, args ...string) (string, error)
- func LoadObject(text string) (runtime.Object, error)
- type Condition
- type E2ESuite
- func (s *E2ESuite) AfterTest(suiteName, testName string)
- func (s *E2ESuite) BeforeTest(string, string)
- func (s *E2ESuite) CheckError(err error)
- func (s *E2ESuite) DeleteResources()
- func (s *E2ESuite) GetBasicAuthToken() string
- func (s *E2ESuite) GetServiceAccountToken() (string, error)
- func (s *E2ESuite) Given() *Given
- func (s *E2ESuite) SetupSuite()
- func (s *E2ESuite) TearDownSuite()
- type Given
- func (g *Given) ClusterWorkflowTemplate(text string) *Given
- func (g *Given) CronWorkflow(text string) *Given
- func (g *Given) ExampleWorkflow(wf *wfv1.Workflow) *Given
- func (g *Given) Exec(name string, args []string, stdin string, ...) *Given
- func (g *Given) KubectlApply(file string, block func(t *testing.T, output string, err error)) *Given
- func (g *Given) RunCli(args []string, block func(t *testing.T, output string, err error)) *Given
- func (g *Given) RunCliStdin(args []string, stdin string, ...) *Given
- func (g *Given) When() *When
- func (g *Given) Workflow(text string) *Given
- func (g *Given) WorkflowEventBinding(text string) *Given
- func (g *Given) WorkflowName(name string) *Given
- func (g *Given) WorkflowTemplate(text string) *Given
- func (g *Given) WorkflowWorkflow(wf *wfv1.Workflow) *Given
- type MetricBaseline
- type Persistence
- type PodCondition
- type Then
- func (t *Then) ExpectArtifact(nodeName string, artifactName string, bucketName string, ...)
- func (t *Then) ExpectArtifactByKey(key string, bucketName string, ...)
- func (t *Then) ExpectAuditEvents(filter func(event apiv1.Event) bool, num int, ...) *Then
- func (t *Then) ExpectContainerLogs(container string, f func(t *testing.T, logs string)) *Then
- func (t *Then) ExpectCron(block func(t *testing.T, cronWf *wfv1.CronWorkflow)) *Then
- func (t *Then) ExpectPVCDeleted() *Then
- func (t *Then) ExpectPods(f func(t *testing.T, pods []apiv1.Pod)) *Then
- func (t *Then) ExpectWorkflow(...) *Then
- func (t *Then) ExpectWorkflowCompressed() *Then
- func (t *Then) ExpectWorkflowDeleted() *Then
- func (t *Then) ExpectWorkflowList(listOptions metav1.ListOptions, ...) *Then
- func (t *Then) ExpectWorkflowListFromCronWorkflow(block func(t *testing.T, wfList *wfv1.WorkflowList)) *Then
- func (t *Then) ExpectWorkflowName(workflowName string, ...) *Then
- func (t *Then) ExpectWorkflowNode(selector func(status wfv1.NodeStatus) bool, ...) *Then
- func (t *Then) ExpectWorkflowTaskSet(block func(t *testing.T, wfts *wfv1.WorkflowTaskSet)) *Then
- func (t *Then) RunCli(args []string, block func(t *testing.T, output string, err error)) *Then
- func (t *Then) When() *When
- type When
- func (w *When) AddNamespaceLimit(limit string) *When
- func (w *When) And(block func()) *When
- func (w *When) ClearDBSemaphoreState() *When
- func (w *When) CreateClusterWorkflowTemplates() *When
- func (w *When) CreateConfigMap(name string, data map[string]string, customLabels map[string]string) *When
- func (w *When) CreateCronWorkflow() *When
- func (w *When) CreateWorkflowEventBinding() *When
- func (w *When) CreateWorkflowTemplates() *When
- func (w *When) DeleteConfigMap(name string) *When
- func (w *When) DeleteMemoryQuota() *When
- func (w *When) DeletePodsQuota() *When
- func (w *When) DeleteStorageQuota() *When
- func (w *When) DeleteWorkflow() *When
- func (w *When) Exec(name string, args []string, block func(t *testing.T, output string, err error)) *When
- func (w *When) GetWorkflow() *wfv1.Workflow
- func (w *When) Given() *Given
- func (w *When) MemoryQuota(memoryLimit string) *When
- func (w *When) PodsQuota(podLimit int) *When
- func (w *When) RemoveFinalizers(shouldErr bool) *When
- func (w *When) ResumeCronWorkflow(string) *When
- func (w *When) RunCli(args []string, block func(t *testing.T, output string, err error)) *When
- func (w *When) SetDBSemaphoreControllerHB(name *string, timestamp time.Time) *When
- func (w *When) SetDBSemaphoreState(name string, workflowKey string, controller *string, mutex bool, held bool, ...) *When
- func (w *When) SetupDatabaseSemaphore(name string, limit int) *When
- func (w *When) ShutdownWorkflow(strategy wfv1.ShutdownStrategy) *When
- func (w *When) StorageQuota(storageLimit string) *When
- func (w *When) SubmitWorkflow() *When
- func (w *When) SubmitWorkflowsFromClusterWorkflowTemplates() *When
- func (w *When) SubmitWorkflowsFromCronWorkflows() *When
- func (w *When) SubmitWorkflowsFromWorkflowTemplates() *When
- func (w *When) SuspendCronWorkflow() *When
- func (w *When) Then() *Then
- func (w *When) UpdateConfigMap(name string, data map[string]string, customLabels map[string]string) *When
- func (w *When) Wait(timeout time.Duration) *When
- func (w *When) WaitForCronWorkflow() *When
- func (w *When) WaitForCronWorkflowCompleted(timeout time.Duration) *When
- func (w *When) WaitForNewWorkflow(condition Condition) *When
- func (w *When) WaitForPod(condition PodCondition) *When
- func (w *When) WaitForWorkflow(options ...interface{}) *When
- func (w *When) WaitForWorkflowDeletion() *When
- func (w *When) WaitForWorkflowListCount(timeout time.Duration, count int) *When
- func (w *When) WaitForWorkflowListFailedCount(count int) *When
- func (w *When) WorkflowCondition(condition func(wf *wfv1.Workflow) bool) bool
- type WorkflowCompletionOkay
Constants ¶
const ( Namespace = "argo" Label = workflow.WorkflowFullName + "/test" // mark this workflow as a test Backfill = workflow.WorkflowFullName + "/backfill" // clean backfill workflows )
Variables ¶
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" } ToBePending = ToHavePhase(wfv1.WorkflowPending) )
var EnvFactor = env.LookupEnvIntOr(logging.InitLoggerInContext(), "E2E_ENV_FACTOR", 1)
var ErrorOutput = func(contains string) func(t *testing.T, output string, err error) { return func(t *testing.T, output string, err error) { t.Helper() require.Error(t, err) assert.Contains(t, output, contains) } }
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 } }
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 } }
var NoError = func(t *testing.T, output string, err error) { t.Helper() require.NoError(t, err, output) }
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) } }
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 ¶
Types ¶
type Condition ¶
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.
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 (*E2ESuite) CheckError ¶
func (*E2ESuite) DeleteResources ¶
func (s *E2ESuite) DeleteResources()
func (*E2ESuite) GetBasicAuthToken ¶
func (*E2ESuite) GetServiceAccountToken ¶
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 NewGiven ¶
func NewGiven( t *testing.T, client v1alpha1.WorkflowInterface, wfebClient v1alpha1.WorkflowEventBindingInterface, wfTemplateClient v1alpha1.WorkflowTemplateInterface, wftsClient v1alpha1.WorkflowTaskSetInterface, cwfTemplateClient v1alpha1.ClusterWorkflowTemplateInterface, cronClient v1alpha1.CronWorkflowInterface, hydrator hydrator.Interface, kubeClient kubernetes.Interface, bearerToken string, restConfig *rest.Config, config *config.Config, ) *Given
func (*Given) ClusterWorkflowTemplate ¶
func (*Given) CronWorkflow ¶
func (*Given) ExampleWorkflow ¶
Load parsed Workflow that's assumed to be from the "examples/" directory
func (*Given) KubectlApply ¶
func (g *Given) KubectlApply(file string, block func(t *testing.T, output string, err error)) *Given
Use Kubectl to server-side apply the given file
func (*Given) RunCliStdin ¶
func (*Given) Workflow ¶
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 (*Given) WorkflowName ¶
func (*Given) WorkflowTemplate ¶
type MetricBaseline ¶
type MetricBaseline struct {
// contains filtered or unexported fields
}
MetricBaseline stores baseline metric values for comparison
func NewMetricBaseline ¶
func NewMetricBaseline(t *testing.T, httpClient func() *httpexpect.Expect) *MetricBaseline
NewMetricBaseline creates a new metric baseline tracker
func (*MetricBaseline) CaptureBaseline ¶
func (mb *MetricBaseline) CaptureBaseline(expectedIncreases map[string]float64) *MetricBaseline
CaptureBaseline captures baselines for all metrics in the expected increases map and stores the expected increases for later use with ExpectIncrease()
func (*MetricBaseline) ExpectIncrease ¶
func (mb *MetricBaseline) ExpectIncrease()
ExpectIncrease checks that the metrics have increased by the amounts specified in the map passed to CaptureBaseline()
type Persistence ¶
type Persistence struct {
WorkflowArchive persist.WorkflowArchive
OffloadNodeStatusRepo persist.OffloadNodeStatusRepo
// contains filtered or unexported fields
}
func NewPersistence ¶
func NewPersistence(ctx context.Context, kubeClient kubernetes.Interface, wcConfig *config.Config) *Persistence
func (*Persistence) Close ¶
func (s *Persistence) Close()
func (*Persistence) IsEnabled ¶
func (s *Persistence) IsEnabled() bool
type PodCondition ¶
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 (*Then) ExpectArtifactByKey ¶
func (*Then) ExpectAuditEvents ¶
func (*Then) ExpectContainerLogs ¶
func (*Then) ExpectCron ¶
func (*Then) ExpectPVCDeleted ¶
func (*Then) ExpectWorkflow ¶
func (t *Then) ExpectWorkflow(block func(t *testing.T, metadata *metav1.ObjectMeta, status *wfv1.WorkflowStatus)) *Then
func (*Then) ExpectWorkflowCompressed ¶ added in v4.0.6
func (*Then) ExpectWorkflowDeleted ¶
func (*Then) ExpectWorkflowList ¶
func (t *Then) ExpectWorkflowList(listOptions metav1.ListOptions, block func(t *testing.T, wfList *wfv1.WorkflowList)) *Then
func (*Then) ExpectWorkflowListFromCronWorkflow ¶
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 ¶
type When ¶
type When struct {
// contains filtered or unexported fields
}
func (*When) AddNamespaceLimit ¶
func (*When) ClearDBSemaphoreState ¶
ClearDBSemaphoreState deletes all records from the semaphore state table except for the controller heartbeat records
func (*When) CreateClusterWorkflowTemplates ¶
func (*When) CreateConfigMap ¶
func (*When) CreateCronWorkflow ¶
func (*When) CreateWorkflowEventBinding ¶
func (*When) CreateWorkflowTemplates ¶
func (*When) DeleteConfigMap ¶
func (*When) DeleteMemoryQuota ¶
func (*When) DeletePodsQuota ¶
func (*When) DeleteStorageQuota ¶
func (*When) DeleteWorkflow ¶
func (*When) GetWorkflow ¶
func (*When) MemoryQuota ¶
func (*When) RemoveFinalizers ¶
func (*When) ResumeCronWorkflow ¶
func (*When) SetDBSemaphoreControllerHB ¶
SetDBSemaphoreControllerHB inserts or updates a record in the semaphore controller heartbeat table
func (*When) SetDBSemaphoreState ¶
func (w *When) SetDBSemaphoreState(name string, workflowKey string, controller *string, mutex bool, held bool, priority int32, timestamp time.Time) *When
SetDBSemaphoreState inserts or updates a record in the semaphore state table
func (*When) SetupDatabaseSemaphore ¶
SetupDatabaseSemaphore creates a database semaphore with the specified limit
func (*When) ShutdownWorkflow ¶
func (w *When) ShutdownWorkflow(strategy wfv1.ShutdownStrategy) *When
func (*When) StorageQuota ¶
func (*When) SubmitWorkflow ¶
func (*When) SubmitWorkflowsFromClusterWorkflowTemplates ¶
func (*When) SubmitWorkflowsFromCronWorkflows ¶
func (*When) SubmitWorkflowsFromWorkflowTemplates ¶
func (*When) SuspendCronWorkflow ¶
func (*When) UpdateConfigMap ¶
func (*When) WaitForCronWorkflow ¶
func (*When) WaitForCronWorkflowCompleted ¶
func (*When) WaitForNewWorkflow ¶
Waits for workflow to be created with different name than the current one
func (*When) WaitForPod ¶
func (w *When) WaitForPod(condition PodCondition) *When
func (*When) WaitForWorkflow ¶
Wait for a workflow to meet a condition: Options: * `time.Duration` - change the timeout - 30s by default
* `metav1.ListOptions` - override label/field selectors
* `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 ¶
func (*When) WaitForWorkflowListCount ¶
func (*When) WaitForWorkflowListFailedCount ¶
type WorkflowCompletionOkay ¶
type WorkflowCompletionOkay bool