testutil

package
v0.38.0 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2026 License: AGPL-3.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AvailableTCPPort

func AvailableTCPPort() (port int, err error)

AvailableTCPPort returns an available loopback TCP port.

func CheckClusterPrerequisites

func CheckClusterPrerequisites(ctx context.Context) error

CheckClusterPrerequisites verifies that Docker and k3d are available.

func CheckDockerRunning

func CheckDockerRunning(t *testing.T, reason string)

CheckDockerRunning skips the test when Docker is unavailable.

func CleanupEnabled

func CleanupEnabled(envVar string) (bool, error)

CleanupEnabled parses the boolean environment variable controlling test cleanup.

func CopyDir

func CopyDir(src, dst string) error

CopyDir recursively copies src into dst.

func CreateBundleArtifact

func CreateBundleArtifact(t *testing.T, udsPath, bundleDir string) string

CreateBundleArtifact creates and locates an unsigned bundle artifact in bundleDir.

func CreateBundleFromTestData

func CreateBundleFromTestData(t *testing.T, testDataRelPath, arch string) string

CreateBundleFromTestData creates a bundle from repository test data.

func CreateBundleFromTestDataCLI

func CreateBundleFromTestDataCLI(t *testing.T, testDataRelPath, arch string) string

CreateBundleFromTestDataCLI creates a bundle through the configured CLI binary.

func CreateBundleFromTestDataCLIWithBinary

func CreateBundleFromTestDataCLIWithBinary(t *testing.T, udsPath, testDataRelPath, arch string) string

CreateBundleFromTestDataCLIWithBinary creates a bundle through udsPath.

func CreateBundleFromTestDataCobra

func CreateBundleFromTestDataCobra(t *testing.T, testDataRelPath, arch string) string

CreateBundleFromTestDataCobra creates a bundle through Cobra command wiring.

func CreateBundleFromTestDataExpectError

func CreateBundleFromTestDataExpectError(t *testing.T, testDataRelPath, arch string) string

CreateBundleFromTestDataExpectError asserts that creating a test bundle fails.

func CreateBundleFromTestDataWithDiagnostics

func CreateBundleFromTestDataWithDiagnostics(t *testing.T, testDataRelPath, arch string) (string, string)

CreateBundleFromTestDataWithDiagnostics creates a bundle and returns captured diagnostics.

func DeleteK3dCluster

func DeleteK3dCluster(t *testing.T, clusterName string)

DeleteK3dCluster deletes a test cluster if it exists.

func DeleteK3dClusterContext

func DeleteK3dClusterContext(ctx context.Context, clusterName string) error

DeleteK3dClusterContext deletes a cluster and ignores an already-missing cluster.

func GenerateCosignKeyPair

func GenerateCosignKeyPair(t *testing.T) (string, string)

GenerateCosignKeyPair writes a passwordless Cosign key pair for a test.

func K3dClusterStatus

func K3dClusterStatus(ctx context.Context, clusterName string) (exists, running bool, err error)

K3dClusterStatus reports whether the named cluster exists and is fully running.

func PrepareBundleDir

func PrepareBundleDir(t *testing.T, testDataRelPath string) string

PrepareBundleDir copies bundle test data into a temporary directory.

func PreparePodinfoBundle

func PreparePodinfoBundle(t *testing.T, podinfoPackagePath, packageLabel, namespace string) string

PreparePodinfoBundle creates a podinfo bundle directory for a cluster test.

func PrepareTwoPodinfoBundle

func PrepareTwoPodinfoBundle(t *testing.T, podinfoPackagePath, firstNamespace, secondNamespace string) string

PrepareTwoPodinfoBundle creates a bundle containing two namespaced podinfo packages.

func RegisterBundleCleanup

func RegisterBundleCleanup(t *testing.T, udsPath, bundlePath string, cleanupTimeout time.Duration) func()

RegisterBundleCleanup registers fallback removal of a deployed bundle.

func RemoveBundle

func RemoveBundle(t *testing.T, udsPath, bundlePath string, args ...string) bundle.RemoveResult

RemoveBundle removes a bundle with the CLI and returns its structured result.

func RequireUDSCommand

func RequireUDSCommand(t *testing.T, udsPath string, args ...string) []byte

RequireUDSCommand runs the CLI and fails the test when the command fails.

func ResolveUDSCLIPath

func ResolveUDSCLIPath() (string, error)

ResolveUDSCLIPath resolves the CLI binary configured for integration tests.

func RunBundleDeploy

func RunBundleDeploy(t *testing.T, udsPath, artifactPath string)

RunBundleDeploy runs bundle deploy through the supplied CLI binary.

func RunCommand

func RunCommand(ctx context.Context, env []string, name string, args ...string) error

RunCommand runs a command with output streamed to the test process.

func StartLocalRegistry added in v0.37.0

func StartLocalRegistry(t *testing.T) string

StartLocalRegistry starts an in-memory HTTP OCI registry and returns its host.

func TestDataPath

func TestDataPath(relPath string) string

TestDataPath returns an absolute path beneath tests/test_data.

func UDSCLIPath

func UDSCLIPath(t *testing.T, runHint string) string

UDSCLIPath returns the configured CLI binary path or skips the test.

func WriteBootstrapConfig

func WriteBootstrapConfig(path, clusterName string, apiPort int) error

WriteBootstrapConfig writes the cluster bootstrap variables used by integration tests.

func WriteK3dKubeconfig

func WriteK3dKubeconfig(ctx context.Context, clusterName, path string) error

WriteK3dKubeconfig writes the named cluster's kubeconfig and selects it for the process.

func ZarfPackageStateSecretName

func ZarfPackageStateSecretName(packageName, namespace string) string

ZarfPackageStateSecretName returns the state secret name for a package override.

Types

type K8sClient

type K8sClient struct {
	*kubernetes.Clientset
	// contains filtered or unexported fields
}

func AllocateTestNamespace

func AllocateTestNamespace(t *testing.T, clusterName string, cleanupTimeout time.Duration) (string, *K8sClient)

AllocateTestNamespace creates a unique namespace and registers its cleanup.

func NewK8sClientOrFail

func NewK8sClientOrFail(t *testing.T) *K8sClient

func NewK8sClientOrSkip

func NewK8sClientOrSkip(t *testing.T) *K8sClient

func (*K8sClient) AssertDeploymentContainerRequests

func (c *K8sClient) AssertDeploymentContainerRequests(namespace, deploymentName, containerName, expectedCPU, expectedMemory string)

func (*K8sClient) AssertDeploymentExists

func (c *K8sClient) AssertDeploymentExists(namespace, name string)

func (*K8sClient) AssertDeploymentNotExists

func (c *K8sClient) AssertDeploymentNotExists(namespace, name string)

func (*K8sClient) AssertDeploymentPodAnnotation

func (c *K8sClient) AssertDeploymentPodAnnotation(namespace, name, key, value string)

func (*K8sClient) AssertDeploymentPodToleration

func (c *K8sClient) AssertDeploymentPodToleration(namespace, name, key string, operator corev1.TolerationOperator, effect corev1.TaintEffect)

func (*K8sClient) AssertDeploymentReplicas

func (c *K8sClient) AssertDeploymentReplicas(namespace, name string, expected int32)

func (*K8sClient) AssertNamespaceExists

func (c *K8sClient) AssertNamespaceExists(namespace string)

func (*K8sClient) AssertNamespaceNotExists

func (c *K8sClient) AssertNamespaceNotExists(namespace string)

func (*K8sClient) AssertSecretExists

func (c *K8sClient) AssertSecretExists(namespace, name string)

func (*K8sClient) AssertSecretNotExists

func (c *K8sClient) AssertSecretNotExists(namespace, name string)

func (*K8sClient) AssertServiceNotExists

func (c *K8sClient) AssertServiceNotExists(namespace, name string)

func (*K8sClient) AssertStatefulSetReplicas

func (c *K8sClient) AssertStatefulSetReplicas(namespace, name string, expected int32)

func (*K8sClient) CreateNamespace

func (c *K8sClient) CreateNamespace(name string, labels map[string]string)

CreateNamespace creates a namespace with the provided labels.

func (*K8sClient) DeleteNamespaceAndWait

func (c *K8sClient) DeleteNamespaceAndWait(name string, timeout time.Duration)

DeleteNamespaceAndWait deletes a namespace and waits until it no longer exists.

func (*K8sClient) GetNamespace

func (c *K8sClient) GetNamespace(name string) *corev1.Namespace

func (*K8sClient) GetSecret

func (c *K8sClient) GetSecret(namespace, name string) *corev1.Secret

func (*K8sClient) WaitForDeploymentReady

func (c *K8sClient) WaitForDeploymentReady(namespace, name string, timeout time.Duration)

func (*K8sClient) WaitForNamespace

func (c *K8sClient) WaitForNamespace(namespace string, timeout time.Duration)

func (*K8sClient) WaitForReadyPodBySelector

func (c *K8sClient) WaitForReadyPodBySelector(namespace, labelSelector string, timeout time.Duration)

func (*K8sClient) WaitForStatefulSetReady

func (c *K8sClient) WaitForStatefulSetReady(namespace, name string, timeout time.Duration)

Jump to

Keyboard shortcuts

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