Documentation
¶
Overview ¶
Package workflows provides Terratest-style helpers for testing Argo Workflows. These include functions to wait for specific workflow phases (Succeeded, Failed, etc.), and utilities to assert workflow conditions using the Argo Workflows clientset.
Index ¶
- func ListArgoClusterWorkflowTemplates(t *testing.T, options *k8s.KubectlOptions, namespace string) []workflowv1alpha1.ClusterWorkflowTemplate
- func ListArgoWorkflowTaskResults(t *testing.T, options *k8s.KubectlOptions, namespace string) []workflowv1alpha1.WorkflowTaskResult
- func ListArgoWorkflowTaskSet(t *testing.T, options *k8s.KubectlOptions, namespace string) []workflowv1alpha1.WorkflowTaskSet
- func ListArgoWorkflowTemplates(t *testing.T, options *k8s.KubectlOptions, namespace string) []workflowv1alpha1.WorkflowTemplate
- func ListArgoWorkflows(t *testing.T, options *k8s.KubectlOptions, namespace string) []workflowv1alpha1.Workflow
- func ListCronWorkflows(t *testing.T, options *k8s.KubectlOptions, namespace string) []workflowv1alpha1.CronWorkflow
- func ListWorkflowPhases(t *testing.T, options *k8s.KubectlOptions, namespace string) []workflowv1alpha1.WorkflowPhase
- func ListWorkflows(t *testing.T, options *k8s.KubectlOptions, namespace string) []workflowv1alpha1.Workflow
- func NewArgoWorkflowsClient(t *testing.T, options *k8s.KubectlOptions) (workflowsClientSet.Interface, error)
- func WaitForCronWorkflowActive(t *testing.T, options *k8s.KubectlOptions, name, namespace string, ...)
- func WaitForCronWorkflowPhase(t *testing.T, options *k8s.KubectlOptions, name, namespace string, ...)
- func WaitForCronWorkflowStopped(t *testing.T, options *k8s.KubectlOptions, name, namespace string, ...)
- func WaitForWorkflowError(t *testing.T, options *k8s.KubectlOptions, name, namespace string, ...)
- func WaitForWorkflowPending(t *testing.T, options *k8s.KubectlOptions, name, namespace string, ...)
- func WaitForWorkflowPhase(t *testing.T, options *k8s.KubectlOptions, name, namespace string, ...)
- func WaitForWorkflowRunning(t *testing.T, options *k8s.KubectlOptions, name, namespace string, ...)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ListArgoClusterWorkflowTemplates ¶ added in v0.0.5
func ListArgoClusterWorkflowTemplates(t *testing.T, options *k8s.KubectlOptions, namespace string) []workflowv1alpha1.ClusterWorkflowTemplate
ListArgoClusterWorkflowTemplates retrieves all Argo ClusterWorkflowTemplates in the specified namespace using the provided KubectlOptions. It returns a slice of ClusterWorkflowTemplate objects. The function will fail the test if there is an error creating the client or listing the ClusterWorkflowTemplates.
Parameters:
- t: The testing context.
- options: The kubectl options to use for connecting to the cluster.
- namespace: The namespace to list ClusterWorkflowTemplates from.
Returns:
- A slice of ClusterWorkflowTemplate objects.
func ListArgoWorkflowTaskResults ¶ added in v0.0.5
func ListArgoWorkflowTaskResults(t *testing.T, options *k8s.KubectlOptions, namespace string) []workflowv1alpha1.WorkflowTaskResult
ListArgoWorkflowTaskResults retrieves a list of Argo WorkflowTaskResult resources from the specified namespace. It uses the provided testing context and kubectl options to create an Argo Workflows client. The function fails the test if the client cannot be created or if listing the WorkflowTaskResults fails.
Parameters:
- t: The testing context.
- options: The kubectl options used to configure the client.
- namespace: The Kubernetes namespace from which to list WorkflowTaskResults.
Returns:
- A slice of WorkflowTaskResult resources found in the specified namespace.
func ListArgoWorkflowTaskSet ¶ added in v0.0.5
func ListArgoWorkflowTaskSet(t *testing.T, options *k8s.KubectlOptions, namespace string) []workflowv1alpha1.WorkflowTaskSet
ListArgoWorkflowTaskSet retrieves all Argo WorkflowTaskSet resources in the specified namespace. It uses the provided testing context and kubectl options to create an Argo Workflows client, then lists the WorkflowTaskSets in the given namespace. If any error occurs during client creation or listing, the test will fail. Returns a slice of WorkflowTaskSet objects found in the namespace.
Parameters:
- t: The testing context.
- options: The kubectl options for connecting to the Kubernetes cluster.
- namespace: The namespace from which to list WorkflowTaskSets.
Returns:
- A slice of WorkflowTaskSet objects present in the specified namespace.
func ListArgoWorkflowTemplates ¶ added in v0.0.5
func ListArgoWorkflowTemplates(t *testing.T, options *k8s.KubectlOptions, namespace string) []workflowv1alpha1.WorkflowTemplate
ListArgoWorkflowTemplates retrieves all Argo WorkflowTemplates in the specified namespace.
It uses the provided testing context and kubectl options to create an Argo Workflows client, then lists all WorkflowTemplates in the given namespace. The function fails the test if any errors occur during client creation or listing.
Parameters:
- t: The testing context.
- options: The kubectl options for accessing the Kubernetes cluster.
- namespace: The namespace from which to list WorkflowTemplates.
Returns:
- A slice of WorkflowTemplate objects found in the specified namespace.
func ListArgoWorkflows ¶ added in v0.0.5
func ListArgoWorkflows(t *testing.T, options *k8s.KubectlOptions, namespace string) []workflowv1alpha1.Workflow
ListArgoWorkflows retrieves all Argo Workflows in the specified namespace using the provided KubectlOptions. It returns a slice of Workflow objects. The function will fail the test if it cannot create the client or list the workflows.
Parameters:
- t: The testing context.
- options: The kubectl options to use for connecting to the Kubernetes cluster.
- namespace: The namespace from which to list the workflows.
Returns:
- A slice of Workflow objects present in the specified namespace.
func ListCronWorkflows ¶ added in v0.0.5
func ListCronWorkflows(t *testing.T, options *k8s.KubectlOptions, namespace string) []workflowv1alpha1.CronWorkflow
ListCronWorkflows retrieves all Argo CronWorkflows in the specified namespace using the provided kubectl options. It returns a slice of CronWorkflow objects. The function fails the test if the client cannot be created or if listing the CronWorkflows fails.
Parameters:
- t: The testing context.
- options: The kubectl options to use for connecting to the Kubernetes cluster.
- namespace: The namespace from which to list the CronWorkflows.
Returns:
- A slice of workflowv1alpha1.CronWorkflow representing the CronWorkflows found in the namespace.
func ListWorkflowPhases ¶ added in v0.0.5
func ListWorkflowPhases(t *testing.T, options *k8s.KubectlOptions, namespace string) []workflowv1alpha1.WorkflowPhase
ListWorkflowPhases retrieves the phases of all Argo Workflows in the specified namespace. It uses the provided testing context and kubectl options to create an Argo Workflows client, lists all workflows in the given namespace, and returns a slice containing the phase of each workflow.
Parameters:
- t: The testing context used for logging and error handling.
- options: The kubectl options used to configure the Kubernetes client.
- namespace: The namespace from which to list the workflows.
Returns:
- A slice of workflowv1alpha1.WorkflowPhase representing the phase of each workflow in the namespace.
Panics if there is an error creating the client or listing the workflows.
func ListWorkflows ¶ added in v0.0.5
func ListWorkflows(t *testing.T, options *k8s.KubectlOptions, namespace string) []workflowv1alpha1.Workflow
ListWorkflows retrieves all Argo Workflows in the specified namespace using the provided KubectlOptions. It requires a testing.T instance for error handling and context propagation. The function returns a slice of Workflow objects present in the given namespace. If the client creation or workflow listing fails, the test will be failed with an appropriate error message.
Parameters:
- t: The testing.T instance used for test context and assertions.
- options: The KubectlOptions used to configure access to the Kubernetes cluster.
- namespace: The namespace from which to list the workflows.
Returns:
- []workflowv1alpha1.Workflow: A slice containing the workflows found in the specified namespace.
func NewArgoWorkflowsClient ¶ added in v0.0.5
func NewArgoWorkflowsClient(t *testing.T, options *k8s.KubectlOptions) (workflowsClientSet.Interface, error)
NewArgoWorkflowsClient creates a new Argo Workflows client using the provided testing context and Kubernetes options. It returns an implementation of the workflowv1alpha1.Interface for interacting with Argo Workflows resources. If the provided KubectlOptions does not include a RestConfig, it attempts to generate one. Returns an error if the client cannot be created.
func WaitForCronWorkflowActive ¶
func WaitForCronWorkflowActive(t *testing.T, options *k8s.KubectlOptions, name, namespace string, timeout time.Duration)
WaitForCronWorkflowActive waits until the specified Argo CronWorkflow reaches the 'Active' phase within the given timeout. It uses the provided KubectlOptions, workflow name, and namespace for the check. Fails the test if the CronWorkflow does not become active within the timeout.
func WaitForCronWorkflowPhase ¶
func WaitForCronWorkflowPhase(t *testing.T, options *k8s.KubectlOptions, name, namespace string, desiredPhase workflowv1alpha1.CronWorkflowPhase, timeout time.Duration)
WaitForCronWorkflowPhase waits until the specified Argo CronWorkflow reaches the desired phase within the given timeout. It polls the CronWorkflow status at regular intervals and fails the test if the desired phase is not reached in time.
Parameters:
t - The testing context. options - Kubectl options containing Kubernetes REST config. name - The name of the CronWorkflow. namespace - The namespace of the CronWorkflow. desiredPhase - The target phase to wait for. timeout - The maximum duration to wait for the desired phase.
Fails the test if the CronWorkflow does not reach the desired phase within the timeout.
func WaitForCronWorkflowStopped ¶
func WaitForCronWorkflowStopped(t *testing.T, options *k8s.KubectlOptions, name, namespace string, timeout time.Duration)
WaitForCronWorkflowStopped waits until the specified Argo CronWorkflow reaches the "Stopped" phase within the given timeout. It uses the provided testing context, kubectl options, workflow name, and namespace. If the workflow does not reach the "Stopped" phase within the timeout, the test will fail.
func WaitForWorkflowError ¶ added in v0.0.6
func WaitForWorkflowError(t *testing.T, options *k8s.KubectlOptions, name, namespace string, timeout time.Duration)
WaitForWorkflowError waits until the specified Argo workflow reaches the "Error" phase or the timeout is reached. It fails the test if the workflow does not enter the "Error" phase within the given duration.
Parameters:
t - The testing context. options - The kubectl options to use for interacting with the Kubernetes cluster. name - The name of the workflow to monitor. namespace - The namespace where the workflow is running. timeout - The maximum duration to wait for the workflow to reach the "Error" phase.
func WaitForWorkflowPending ¶
func WaitForWorkflowPending(t *testing.T, options *k8s.KubectlOptions, name, namespace string, timeout time.Duration)
WaitForWorkflowPending waits until the specified Argo workflow reaches the "Pending" phase within the given timeout. It uses the provided testing context, kubectl options, workflow name, and namespace. If the workflow does not reach the "Pending" phase within the timeout, the test will fail.
Parameters:
- t: The testing context.
- options: The kubectl options for connecting to the Kubernetes cluster.
- name: The name of the workflow to check.
- namespace: The namespace where the workflow resides.
- timeout: The maximum duration to wait for the workflow to reach the "Pending" phase.
This function delegates to WaitForWorkflowPhase with the "Pending" phase.
func WaitForWorkflowPhase ¶
func WaitForWorkflowPhase(t *testing.T, options *k8s.KubectlOptions, name, namespace string, desiredPhase workflowv1alpha1.WorkflowPhase, timeout time.Duration)
WaitForWorkflowPhase waits until the specified Argo Workflow reaches the desired phase within the given timeout. It polls the workflow status every 2 seconds using the provided Kubernetes options and namespace. If the workflow does not reach the desired phase in time, the test fails with a fatal error.
Parameters:
t - The testing context. options - The Kubernetes KubectlOptions containing REST config. name - The name of the workflow to monitor. namespace - The namespace where the workflow resides. desiredPhase - The target WorkflowPhase to wait for. timeout - The maximum duration to wait for the workflow to reach the desired phase.
Fails the test if the workflow does not reach the desired phase within the timeout.
func WaitForWorkflowRunning ¶
func WaitForWorkflowRunning(t *testing.T, options *k8s.KubectlOptions, name, namespace string, timeout time.Duration)
WaitForWorkflowRunning waits until the specified Argo workflow reaches the "Running" phase or the timeout is reached. It uses the provided testing context, kubectl options, workflow name, namespace, and timeout duration. Fails the test if the workflow does not reach the "Running" phase within the timeout.
Parameters:
- t: The testing context.
- options: The kubectl options for connecting to the Kubernetes cluster.
- name: The name of the workflow to check.
- namespace: The namespace where the workflow resides.
- timeout: The maximum duration to wait for the workflow to reach the "Running" phase.
Types ¶
This section is empty.