utils

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2025 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package testutil provides common test utilities and helper functions for controller tests.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CleanupAllResources

func CleanupAllResources(ctx context.Context, k8sClient client.Client)

CleanupAllResources removes all test resources from the cluster. It deletes AgentGateways, AgentGatewayClasses, Agents, Services, ConfigMaps, and Deployments. System resources (like the kubernetes service and system configmaps) are preserved.

func CreateTestAgent

func CreateTestAgent(name, namespace string, exposed bool) *agentruntimev1alpha1.Agent

CreateTestAgent creates a test Agent resource with the given name, namespace, and exposed flag.

func CreateTestAgentGateway

func CreateTestAgentGateway(name, namespace string, className *string) *agentruntimev1alpha1.AgentGateway

CreateTestAgentGateway creates a test AgentGateway resource with the given name and namespace. If className is provided, it will be set in the spec.

func CreateTestAgentGatewayClass

func CreateTestAgentGatewayClass(name, controller string) *agentruntimev1alpha1.AgentGatewayClass

CreateTestAgentGatewayClass creates a test AgentGatewayClass with the given name and controller.

func CreateTestAgentGatewayClassWithDefault

func CreateTestAgentGatewayClassWithDefault(name, controllerName string) *agentruntimev1alpha1.AgentGatewayClass

CreateTestAgentGatewayClassWithDefault creates a test AgentGatewayClass with default annotation. The controller is set to the provided controllerName.

func EventuallyResourceExists

func EventuallyResourceExists(ctx context.Context, k8sClient client.Client, name, namespace string, obj client.Object, timeout, interval time.Duration)

EventuallyResourceExists waits for a Kubernetes resource to exist using Eventually. It polls the API until the resource is found or the timeout is reached.

func FetchAgentGateway

func FetchAgentGateway(ctx context.Context, k8sClient client.Client, name, namespace string) *agentruntimev1alpha1.AgentGateway

FetchAgentGateway retrieves an AgentGateway from the Kubernetes API and asserts it exists.

func FetchService

func FetchService(ctx context.Context, k8sClient client.Client, name, namespace string) *corev1.Service

FetchService retrieves a Service from the Kubernetes API and asserts it exists.

func Int32Ptr

func Int32Ptr(i int32) *int32

Int32Ptr returns a pointer to an int32 value. Useful for setting optional int32 fields in Kubernetes resources.

func IsSystemConfigMap

func IsSystemConfigMap(name string) bool

IsSystemConfigMap returns true if the given configmap name is a system configmap that should not be deleted.

func ReconcileAndExpectSuccess

func ReconcileAndExpectSuccess(ctx context.Context, reconciler interface {
	Reconcile(context.Context, ctrl.Request) (ctrl.Result, error)
}, name, namespace string)

ReconcileAndExpectSuccess invokes the reconciler and asserts successful reconciliation. It verifies that no error occurred and that the result indicates no requeue.

func SetAgentUrl

func SetAgentUrl(ctx context.Context, k8sClient client.Client, agent *agentruntimev1alpha1.Agent, url string)

SetAgentUrl updates the agent's status URL and asserts the update succeeds.

Types

This section is empty.

Jump to

Keyboard shortcuts

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