cd

package
v0.0.11 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package cd provides Terratest-style helpers for testing Argo CD Applications and AppProjects. It includes functions to wait for Applications to become Synced and Healthy, as well as utilities to verify AppProject presence.

Index

Constants

This section is empty.

Variables

View Source
var NewArgoCDClient = newArgoCDClient

NewArgoCDClient creates a new ArgoCD client interface for use in tests. This function attempts to use the REST configuration from options if available, otherwise it will create a new REST configuration using the kubectl options.

Parameters:

  • t: Testing context that implements the testing.TB interface
  • options: Kubectl configuration options that may contain a REST client configuration

Returns:

  • An ArgoCD client interface that can be used to interact with ArgoCD
  • An error if the client creation fails

Functions

func IsApplicationHealthyAndSynced

func IsApplicationHealthyAndSynced(app *argocdv1alpha1.Application) bool

IsApplicationHealthyAndSynced returns true if the given Argo CD application is both healthy and synced. It checks that the application's health status is 'Healthy' and its sync status is 'Synced'.

func ListAppProjects added in v0.0.6

func ListAppProjects(t *testing.T, options *k8s.KubectlOptions, namespace string) []argocdv1alpha1.AppProject

ListAppProjects retrieves a list of Argo CD AppProject resources in the specified namespace.

Parameters:

  • t: The testing context used for logging and error handling.
  • options: The kubectl options used to configure access to the Kubernetes cluster.
  • namespace: The namespace from which to list AppProjects.

Returns:

  • A slice of AppProject resources found in the given namespace.

This function will fail the test if it cannot create the Argo CD client or if it fails to list the AppProjects.

func ListApplicationSets added in v0.0.6

func ListApplicationSets(t *testing.T, options *k8s.KubectlOptions, namespace string) []argocdv1alpha1.ApplicationSet

ListApplicationSets retrieves all Argo CD ApplicationSet resources in the specified namespace. It uses the provided testing context and kubectl options to create an Argo CD client, then lists the ApplicationSets in the given namespace. The function fails the test if client creation or listing fails, and returns the list of ApplicationSet items.

Parameters:

  • t: The testing context.
  • options: The kubectl options for connecting to the Kubernetes cluster.
  • namespace: The namespace from which to list ApplicationSets.

Returns:

  • A slice of ApplicationSet resources found in the specified namespace.

func ListApplications added in v0.0.6

func ListApplications(t *testing.T, options *k8s.KubectlOptions, namespace string) []argocdv1alpha1.Application

ListApplications retrieves a list of Argo CD Application resources from the specified namespace. It uses the provided testing context and kubectl options to create an Argo CD client, then lists all Application resources in the given namespace. The function fails the test if the client cannot be created or if the list operation fails.

Parameters:

  • t: The testing context.
  • options: The kubectl options used to configure the client.
  • namespace: The Kubernetes namespace from which to list Application resources.

Returns:

  • A slice of v1alpha1.Application representing the Applications found in the namespace.

func WaitForAppProjectExists

func WaitForAppProjectExists(t *testing.T, options *k8s.KubectlOptions, name, namespace string, timeout time.Duration)

WaitForAppProjectExists waits until an Argo CD AppProject with the specified name exists in the given namespace. It polls the Kubernetes API at regular intervals until the AppProject is found or the timeout is reached. If the AppProject does not appear within the timeout, the test fails. Parameters:

  • t: The testing context.
  • options: Kubectl options containing the REST config for the Kubernetes cluster.
  • name: The name of the AppProject to wait for.
  • namespace: The namespace in which to look for the AppProject.
  • timeout: The maximum duration to wait for the AppProject to appear.

func WaitForApplicationHealthyAndSynced

func WaitForApplicationHealthyAndSynced(t *testing.T, options *k8s.KubectlOptions, name, namespace string, timeout time.Duration)

WaitForApplicationHealthyAndSynced waits until the specified Argo CD Application resource in the given namespace reaches both "Healthy" and "Synced" status within the provided timeout. It polls the Application status every 2 seconds using the Argo CD client and fails the test if the desired state is not achieved within the timeout period.

Parameters:

t        - The testing context.
options  - Kubectl options containing the Kubernetes REST config.
name     - The name of the Argo CD Application.
namespace- The namespace where the Application resides.
timeout  - The maximum duration to wait for the Application to become Healthy and Synced.

Fails the test if the Application does not reach the desired state within the timeout.

func WaitForApplicationSetHealthyAndSynced

func WaitForApplicationSetHealthyAndSynced(t *testing.T, options *k8s.KubectlOptions, name, namespace string, timeout time.Duration)

WaitForApplicationSetHealthyAndSynced waits until the specified Argo CD ApplicationSet in the given namespace is healthy and its resources are up to date, or until the provided timeout is reached. It polls the ApplicationSet status every 2 seconds, checking for the "ResourcesUpToDate" condition with a "True" status. If the ApplicationSet does not become healthy and synced within the timeout, the test fails. Parameters:

  • t: The testing context.
  • options: Kubectl options containing the Kubernetes REST config.
  • name: The name of the ApplicationSet.
  • namespace: The namespace where the ApplicationSet resides.
  • timeout: The maximum duration to wait for the ApplicationSet to become healthy and synced.

Types

This section is empty.

Jump to

Keyboard shortcuts

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