velero

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package velero provides Terratest-style helpers for testing Velero backups, restores, and storage configurations. Helpers include wait functions for BackupStorageLocations, Backups, and Restores using status conditions and phases.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ListBackupStorageLocation added in v0.0.6

func ListBackupStorageLocation(t *testing.T, options *k8s.KubectlOptions, namespace string) []velerov1.BackupStorageLocation

ListBackupStorageLocation retrieves a list of Velero BackupStorageLocation resources in the specified namespace. It uses the provided testing context and Kubernetes options to create a Velero client and perform the list operation. 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 containing the Kubernetes REST config.
  • namespace: The namespace from which to list BackupStorageLocations.

Returns:

  • A slice of velerov1.BackupStorageLocation objects found in the specified namespace.

func ListBackups added in v0.0.6

func ListBackups(t *testing.T, options *k8s.KubectlOptions, namespace string) []velerov1.Backup

ListBackups retrieves a list of Velero Backup resources in the specified namespace. It uses the provided testing context and Kubernetes options to create a Velero client, then lists all Backup objects within 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 Kubernetes KubectlOptions to use for client configuration.
  • namespace: The namespace from which to list Velero Backups.

Returns:

  • A slice of velerov1.Backup objects found in the specified namespace.

func ListRestores added in v0.0.6

func ListRestores(t *testing.T, options *k8s.KubectlOptions, namespace string) []velerov1.Restore

ListRestores retrieves a list of Velero Restore resources in the specified namespace. It uses the provided testing context and Kubernetes options to create a Velero client, then lists all Restore objects within 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 Kubernetes options containing the REST config.
  • namespace: The namespace from which to list Restore resources.

Returns:

  • A slice of velerov1.Restore objects found in the specified namespace.

func ListSchedules added in v0.0.6

func ListSchedules(t *testing.T, options *k8s.KubectlOptions, namespace string) []velerov1.Schedule

ListSchedules retrieves all Velero Schedule resources in the specified namespace using the provided Kubernetes options. It returns a slice of velerov1.Schedule objects. The function fails the test if the Velero client cannot be created or if listing the schedules fails.

Parameters:

  • t: The testing context.
  • options: The Kubernetes options containing the REST config.
  • namespace: The namespace from which to list Velero Schedules.

Returns:

  • A slice of velerov1.Schedule representing the schedules found in the given namespace.

func NewVeleroClient

func NewVeleroClient(cfg *rest.Config) (client.Client, error)

NewVeleroClient creates and returns a new controller-runtime client for interacting with Velero resources. It initializes a new runtime scheme, adds the Velero v1 API to the scheme, and constructs the client using the provided Kubernetes REST configuration.

Parameters:

  • cfg: A pointer to a rest.Config object containing the Kubernetes API server configuration.

Returns:

  • client.Client: A controller-runtime client configured for Velero resources.
  • error: An error if the client could not be created.

func WaitForBackupStorageLocationReady

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

WaitForBackupStorageLocationReady waits until the specified Velero BackupStorageLocation resource reaches the "Available" phase or the provided timeout is reached. It polls the resource status every 2 seconds. If the resource does not become available within the timeout, the test fails.

Parameters:

  • t: The testing context.
  • options: The kubectl options containing the Kubernetes REST config.
  • name: The name of the BackupStorageLocation resource.
  • namespace: The namespace of the BackupStorageLocation resource.
  • timeout: The maximum duration to wait for the resource to become available.

This function is intended for use in integration or end-to-end tests to ensure that a Velero BackupStorageLocation is ready before proceeding.

func WaitForBackupSucceeded

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

WaitForBackupSucceeded waits until the specified Velero backup reaches the "Completed" phase or the timeout is reached. It polls the backup status every 2 seconds and fails the test if the backup does not complete successfully within the given timeout.

Parameters:

  • t: The testing context.
  • options: The kubectl options containing the Kubernetes REST config.
  • name: The name of the Velero backup to check.
  • namespace: The namespace where the backup resides.
  • timeout: The maximum duration to wait for the backup to complete.

This function will call t.Fatalf if the backup does not complete successfully within the timeout.

func WaitForRestoreCompleted

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

WaitForRestoreCompleted waits until a Velero Restore resource reaches the "Completed" phase or the specified timeout is reached. It polls the status of the Restore resource every 2 seconds. If the Restore does not reach the "Completed" phase within the timeout, the test fails with a fatal error. If the Restore resource is not found during polling, it logs a retry message and continues polling.

Parameters:

  • t: The testing context.
  • options: The kubectl options containing the Kubernetes REST config.
  • name: The name of the Velero Restore resource.
  • namespace: The namespace where the Restore resource is located.
  • timeout: The maximum duration to wait for the Restore to complete.

func WaitForScheduleToExist

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

WaitForScheduleToExist waits until a Velero Schedule resource with the specified name and namespace exists and is in the "Enabled" phase, or until the given timeout is reached. It polls the Kubernetes API at regular intervals and fails the test if the schedule does not become enabled within the timeout period.

Parameters:

  • t: The testing context.
  • options: The kubectl options containing the Kubernetes REST config.
  • name: The name of the Velero Schedule resource to wait for.
  • namespace: The namespace where the Velero Schedule resource is expected to exist.
  • timeout: The maximum duration to wait for the schedule to become enabled.

This function logs retries and fails the test with a fatal error if the schedule does not become enabled in time.

Types

This section is empty.

Jump to

Keyboard shortcuts

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