Documentation
¶
Overview ¶
Package testutil provides common test utilities and helper functions for controller tests.
Index ¶
- func CleanupAllResources(ctx context.Context, k8sClient client.Client)
- func CreateTestAgent(name, namespace string, exposed bool) *agentruntimev1alpha1.Agent
- func CreateTestAgentGateway(name, namespace string, className *string) *agentruntimev1alpha1.AgentGateway
- func CreateTestAgentGatewayClass(name, controller string) *agentruntimev1alpha1.AgentGatewayClass
- func CreateTestAgentGatewayClassWithDefault(name, controllerName string) *agentruntimev1alpha1.AgentGatewayClass
- func EventuallyResourceExists(ctx context.Context, k8sClient client.Client, name, namespace string, ...)
- func FetchAgentGateway(ctx context.Context, k8sClient client.Client, name, namespace string) *agentruntimev1alpha1.AgentGateway
- func FetchService(ctx context.Context, k8sClient client.Client, name, namespace string) *corev1.Service
- func Int32Ptr(i int32) *int32
- func IsSystemConfigMap(name string) bool
- func ReconcileAndExpectSuccess(ctx context.Context, reconciler interface{ ... }, name, namespace string)
- func SetAgentUrl(ctx context.Context, k8sClient client.Client, ...)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CleanupAllResources ¶
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 ¶
Int32Ptr returns a pointer to an int32 value. Useful for setting optional int32 fields in Kubernetes resources.
func IsSystemConfigMap ¶
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.