Documentation ¶
Index ¶
- Constants
- func BuildEnvironment(ctx context.Context, existingCluster string, builderOpts ...BuilderOpt) (environments.Environment, error)
- func BuildMTLSCredentials(ctx context.Context, k8sClient *kubernetes.Clientset, httpc *http.Client) error
- func ControlPlaneCRBContainsCRAndSA(t *testing.T, ctx context.Context, controlplane *operatorv1beta1.ControlPlane, ...) func() bool
- func ControlPlaneDetectedNoDataPlane(t *testing.T, ctx context.Context, controlPlane types.NamespacedName, ...) func() bool
- func ControlPlaneHasActiveDeployment(t *testing.T, ctx context.Context, controlplaneName types.NamespacedName, ...) func() bool
- func ControlPlaneHasAdmissionWebhookCertificateSecret(t *testing.T, ctx context.Context, cp *operatorv1beta1.ControlPlane, ...) func() bool
- func ControlPlaneHasAdmissionWebhookConfiguration(t *testing.T, ctx context.Context, cp *operatorv1beta1.ControlPlane, ...) func() bool
- func ControlPlaneHasAdmissionWebhookService(t *testing.T, ctx context.Context, cp *operatorv1beta1.ControlPlane, ...) func() bool
- func ControlPlaneHasClusterRole(t *testing.T, ctx context.Context, controlplane *operatorv1beta1.ControlPlane, ...) func() bool
- func ControlPlaneHasClusterRoleBinding(t *testing.T, ctx context.Context, controlplane *operatorv1beta1.ControlPlane, ...) func() bool
- func ControlPlaneHasNReadyPods(t *testing.T, ctx context.Context, controlplaneName types.NamespacedName, ...) func() bool
- func ControlPlaneIsNotReady(t *testing.T, ctx context.Context, controlplane types.NamespacedName, ...) func() bool
- func ControlPlaneIsProvisioned(t *testing.T, ctx context.Context, controlPlane types.NamespacedName, ...) func() bool
- func ControlPlaneIsReady(t *testing.T, ctx context.Context, controlplane types.NamespacedName, ...) func() bool
- func ControlPlaneIsScheduled(t *testing.T, ctx context.Context, controlPlane types.NamespacedName, ...) func() bool
- func ControlPlaneUpdateEventually(t *testing.T, ctx context.Context, controlplaneNN types.NamespacedName, ...) func() bool
- func ControlPlanesClusterRoleBindingHasSubject(t *testing.T, ctx context.Context, controlplane *operatorv1beta1.ControlPlane, ...) func() bool
- func ControlPlanesClusterRoleHasPolicyRule(t *testing.T, ctx context.Context, controlplane *operatorv1beta1.ControlPlane, ...) func() bool
- func DataPlaneHasActiveDeployment(t *testing.T, ctx context.Context, dataplaneNN types.NamespacedName, ...) func() bool
- func DataPlaneHasActiveService(t *testing.T, ctx context.Context, dataplaneName types.NamespacedName, ...) func() bool
- func DataPlaneHasDeployment(t *testing.T, ctx context.Context, dataplaneName types.NamespacedName, ...) func() bool
- func DataPlaneHasHPA(t *testing.T, ctx context.Context, dataplane *operatorv1beta1.DataPlane, ...) func() bool
- func DataPlaneHasNReadyPods(t *testing.T, ctx context.Context, dataplaneName types.NamespacedName, ...) func() bool
- func DataPlaneHasPodDisruptionBudget(t *testing.T, ctx context.Context, dataplane *operatorv1beta1.DataPlane, ...) func() bool
- func DataPlaneHasService(t *testing.T, ctx context.Context, dataplaneName types.NamespacedName, ...) func() bool
- func DataPlaneHasServiceAndAddressesInStatus(t *testing.T, ctx context.Context, dataplaneName types.NamespacedName, ...) func() bool
- func DataPlaneHasServiceSecret(t *testing.T, ctx context.Context, dpNN, usingSvc types.NamespacedName, ...) func() bool
- func DataPlaneIsReady(t *testing.T, ctx context.Context, dataplane types.NamespacedName, ...) func() bool
- func DataPlanePredicate(t *testing.T, ctx context.Context, dataplaneName types.NamespacedName, ...) func() bool
- func DataPlaneServiceHasNActiveEndpoints(t *testing.T, ctx context.Context, serviceName types.NamespacedName, ...) func() bool
- func DataPlaneUpdateEventually(t *testing.T, ctx context.Context, dataplaneNN types.NamespacedName, ...) func() bool
- func DeployCRDs(ctx context.Context, crdPath string, operatorClient *operatorclient.Clientset, ...) error
- func ExtractModuleVersion(moduleName string) (string, error)
- func GatewayClassIsAccepted(t *testing.T, ctx context.Context, gatewayClassName string, clients K8sClients) func() bool
- func GatewayControlPlaneIsProvisioned(t *testing.T, ctx context.Context, gateway *gwtypes.Gateway, ...) func() bool
- func GatewayDataPlaneIsReady(t *testing.T, ctx context.Context, gateway *gwtypes.Gateway, ...) func() bool
- func GatewayIPAddressExist(t *testing.T, ctx context.Context, gatewayNSN types.NamespacedName, ...) func() bool
- func GatewayIsAccepted(t *testing.T, ctx context.Context, gatewayNSN types.NamespacedName, ...) func() bool
- func GatewayIsProgrammed(t *testing.T, ctx context.Context, gatewayNSN types.NamespacedName, ...) func() bool
- func GatewayListenersAreProgrammed(t *testing.T, ctx context.Context, gatewayNSN types.NamespacedName, ...) func() bool
- func GatewayNetworkPoliciesExist(t *testing.T, ctx context.Context, gateway *gwtypes.Gateway, ...) func() bool
- func GatewayNetworkPolicyForGatewayContainsRules[T ingressRuleT](t *testing.T, ctx context.Context, gateway *gwtypes.Gateway, ...) func() bool
- func GatewayNotExist(t *testing.T, ctx context.Context, gatewayNSN types.NamespacedName, ...) func() bool
- func GetResponseBodyContains(t *testing.T, clients K8sClients, httpc *http.Client, request *http.Request, ...) func() bool
- func HPAPredicate(t *testing.T, ctx context.Context, hpaName types.NamespacedName, ...) func() bool
- func HTTPRouteUpdateEventually(t *testing.T, ctx context.Context, httpRouteNN types.NamespacedName, ...) func() bool
- func MustGetGateway(t *testing.T, ctx context.Context, gatewayNSN types.NamespacedName, ...) *gwtypes.Gateway
- func MustListControlPlaneClusterRoleBindings(t *testing.T, ctx context.Context, controlplane *operatorv1beta1.ControlPlane, ...) []rbacv1.ClusterRoleBinding
- func MustListControlPlaneClusterRoles(t *testing.T, ctx context.Context, controlplane *operatorv1beta1.ControlPlane, ...) []rbacv1.ClusterRole
- func MustListControlPlaneDeployments(t *testing.T, ctx context.Context, controlplane *operatorv1beta1.ControlPlane, ...) []appsv1.Deployment
- func MustListControlPlanesForGateway(t *testing.T, ctx context.Context, gateway *gwtypes.Gateway, ...) []operatorv1beta1.ControlPlane
- func MustListDataPlaneDeployments(t *testing.T, ctx context.Context, dataplane *operatorv1beta1.DataPlane, ...) []appsv1.Deployment
- func MustListDataPlaneHPAs(t *testing.T, ctx context.Context, dataplane *operatorv1beta1.DataPlane, ...) []autoscalingv2.HorizontalPodAutoscaler
- func MustListDataPlanePodDisruptionBudgets(t *testing.T, ctx context.Context, dataplane *operatorv1beta1.DataPlane, ...) []policyv1.PodDisruptionBudget
- func MustListDataPlaneServices(t *testing.T, ctx context.Context, dataplane *operatorv1beta1.DataPlane, ...) []corev1.Service
- func MustListDataPlanesForGateway(t *testing.T, ctx context.Context, gateway *gwtypes.Gateway, ...) []operatorv1beta1.DataPlane
- func MustListNetworkPoliciesForGateway(t *testing.T, ctx context.Context, gateway *gwtypes.Gateway, ...) []networkingv1.NetworkPolicy
- func MustListServiceEndpointSlices(t *testing.T, ctx context.Context, serviceName types.NamespacedName, ...) []discoveryv1.EndpointSlice
- func Not(predicate func() bool) func() bool
- func ProjectRootPath() string
- func SetupControllerLogger(controllerManagerOut string) (func() error, error)
- type BuilderOpt
- type K8sClients
- type PodDisruptionBudgetRequirement
Constants ¶
const ( // GatewayClassAcceptanceTimeLimit is the amount of time that the operator // will wait for a GatewayClass to be accepted. GatewayClassAcceptanceTimeLimit = time.Second * 7 // GatewaySchedulingTimeLimit is the maximum amount of time to wait for // a supported Gateway to be marked as Scheduled by the gateway controller. GatewaySchedulingTimeLimit = time.Second * 7 // GatewayReadyTimeLimit is the maximum amount of time to wait for a // supported Gateway to be fully provisioned and marked as Ready by the // gateway controller. GatewayReadyTimeLimit = time.Minute * 3 )
const ( // ControlPlaneCondDeadline is the default timeout for checking on controlplane resources. ControlPlaneCondDeadline = time.Minute // ControlPlaneCondTick is the default tick for checking on controlplane resources. ControlPlaneCondTick = 250 * time.Millisecond // ControlPlaneSchedulingTimeLimit is the maximum amount of time to wait for // a supported ControlPlane to be created after a Gateway resource is // created ControlPlaneSchedulingTimeLimit = time.Minute * 3 // DataPlaneCondDeadline is the default timeout for checking on dataplane resources. DataPlaneCondDeadline = 1 * time.Minute // DataPlaneCondTick is the default tick for checking on dataplane resources. DataPlaneCondTick = 2 * time.Second )
const ( // WaitIngressTick is the default timeout tick interval for checking on ingress resources. WaitIngressTick = time.Second * 1 // DefaultIngressWait is the default timeout for checking on ingress resources. DefaultIngressWait = time.Minute * 3 )
const ( // httpBinImage is the container image name we use for deploying the "httpbin" HTTP testing tool. // if you need a simple HTTP server for tests you're writing, use this and check the documentation. // See: https://github.com/kong/httpbin HTTPBinImage = "kong/httpbin:0.1.0" // tcpEchoImage echoes TCP text sent to it after printing out basic information about its environment, e.g. // Welcome, you are connected to node kind-control-plane. // Running on Pod tcp-echo-58ccd6b78d-hn9t8. // In namespace foo. // With IP address 10.244.0.13. TCPEchoImage = "kong/go-echo:0.1.0" )
const ( // ObjectUpdateTimeout is the amount of time that will be allowed for // conflicts to be resolved before an object update will be considered failed. ObjectUpdateTimeout = time.Second * 30 // ObjectUpdateTick is the time duration between checks for object updates. ObjectUpdateTick = 100 * time.Millisecond // SubresourceReadinessWait is the maximum amount of time allowed for // sub-resources to become "Ready" after being created on behalf of a // parent resource. SubresourceReadinessWait = time.Second * 30 // DefaultHTTPPort is the default HTTP port. DefaultHTTPPort = 80 // AIGatewayCRDPath points to the CRD descriptor for AI Gateways, for use // throughout tests. AIGatewayCRDPath = "/bases/gateway-operator.konghq.com_aigateways.yaml" )
const ( // GatewayStandardCRDsKustomizeURL is a URL that provides standard Gateway API CRDs. GatewayStandardCRDsKustomizeURL = "github.com/kubernetes-sigs/gateway-api/config/crd?ref=v1.2.1" // GatewayExperimentalCRDsKustomizeURL is a URL that provides experimental Gateway API CRDs. GatewayExperimentalCRDsKustomizeURL = "github.com/kubernetes-sigs/gateway-api/config/crd/experimental?ref=v1.2.1" // GatewayRawRepoURL is the base URL to the raw Gateway API repository. GatewayRawRepoURL = "https://raw.githubusercontent.com/kubernetes-sigs/gateway-api/v1.2.1" )
const (
// KubernetesConfigurationModuleName is the name of the module where we import and install Kong configuration CRDs from.
KubernetesConfigurationModuleName = "github.com/kong/kubernetes-configuration"
)
Variables ¶
This section is empty.
Functions ¶
func BuildEnvironment ¶
func BuildEnvironment(ctx context.Context, existingCluster string, builderOpts ...BuilderOpt) (environments.Environment, error)
BuildEnvironment builds the k8s environment for the tests. Args:
- ctx: the context to use for the environment build.
- existingCluster: the name of the existing cluster to use for the tests. If empty, a new kind cluster will be created.
- builderOpts: accept a list of builder options that will be applied to the builder before buildling the environment.
Returns the environment on success and an error on failure.
func BuildMTLSCredentials ¶
func BuildMTLSCredentials(ctx context.Context, k8sClient *kubernetes.Clientset, httpc *http.Client) error
BuildMTLSCredentials builds the mTLS credentials for the tests. Args:
- ctx: the context to use.
- k8sClient: the k8s client to use.
- httpc: the http client to configure with the mTLS credentials.
func ControlPlaneCRBContainsCRAndSA ¶
func ControlPlaneCRBContainsCRAndSA(t *testing.T, ctx context.Context, controlplane *operatorv1beta1.ControlPlane, clients K8sClients) func() bool
ControlPlaneCRBContainsCRAndSA is a helper function for tests that returns a function that can be used to check if the ClusterRoleBinding of a ControPlane has the reference of ClusterRole belonging to the ControlPlane and contains the service account used by the Deployment of the ControlPlane.
func ControlPlaneDetectedNoDataPlane ¶
func ControlPlaneDetectedNoDataPlane(t *testing.T, ctx context.Context, controlPlane types.NamespacedName, clients K8sClients) func() bool
ControlPlaneDetectedNoDataPlane is a helper function for tests that returns a function that can be used to check if a ControlPlane detected unset dataplane. Should be used in conjunction with require.Eventually or assert.Eventually.
func ControlPlaneHasActiveDeployment ¶
func ControlPlaneHasActiveDeployment(t *testing.T, ctx context.Context, controlplaneName types.NamespacedName, clients K8sClients) func() bool
ControlPlaneHasActiveDeployment is a helper function for tests that returns a function that can be used to check if a ControlPlane has an active deployment. Should be used in conjunction with require.Eventually or assert.Eventually.
func ControlPlaneHasAdmissionWebhookCertificateSecret ¶
func ControlPlaneHasAdmissionWebhookCertificateSecret(t *testing.T, ctx context.Context, cp *operatorv1beta1.ControlPlane, clients K8sClients) func() bool
ControlPlaneHasAdmissionWebhookCertificateSecret is a helper function for tests that returns a function that can be used to check if a ControlPlane has an admission webhook certificate Secret. Should be used in conjunction with require.Eventually or assert.Eventually.
func ControlPlaneHasAdmissionWebhookConfiguration ¶
func ControlPlaneHasAdmissionWebhookConfiguration(t *testing.T, ctx context.Context, cp *operatorv1beta1.ControlPlane, clients K8sClients) func() bool
ControlPlaneHasAdmissionWebhookConfiguration is a helper function for tests that returns a function that can be used to check if a ControlPlane has an admission webhook configuration.
func ControlPlaneHasAdmissionWebhookService ¶
func ControlPlaneHasAdmissionWebhookService(t *testing.T, ctx context.Context, cp *operatorv1beta1.ControlPlane, clients K8sClients) func() bool
ControlPlaneHasAdmissionWebhookService is a helper function for tests that returns a function that can be used to check if a ControlPlane has an admission webhook Service. Should be used in conjunction with require.Eventually or assert.Eventually.
func ControlPlaneHasClusterRole ¶
func ControlPlaneHasClusterRole(t *testing.T, ctx context.Context, controlplane *operatorv1beta1.ControlPlane, clients K8sClients) func() bool
ControlPlaneHasClusterRole is a helper function for tests that returns a function that can be used to check if a ControlPlane has a ClusterRole. Should be used in conjunction with require.Eventually or assert.Eventually.
func ControlPlaneHasClusterRoleBinding ¶
func ControlPlaneHasClusterRoleBinding(t *testing.T, ctx context.Context, controlplane *operatorv1beta1.ControlPlane, clients K8sClients) func() bool
ControlPlaneHasClusterRoleBinding is a helper function for tests that returns a function that can be used to check if a ControlPlane has a ClusterRoleBinding. Should be used in conjunction with require.Eventually or assert.Eventually.
func ControlPlaneHasNReadyPods ¶
func ControlPlaneHasNReadyPods(t *testing.T, ctx context.Context, controlplaneName types.NamespacedName, clients K8sClients, n int32) func() bool
ControlPlaneHasNReadyPods checks if a ControlPlane has at least N ready Pods.
func ControlPlaneIsNotReady ¶
func ControlPlaneIsNotReady(t *testing.T, ctx context.Context, controlplane types.NamespacedName, clients K8sClients) func() bool
ControlPlaneIsNotReady is a helper function for tests. It returns a function that can be used to check if a ControlPlane is marked as not Ready. Should be used in conjunction with require.Eventually or assert.Eventually.
func ControlPlaneIsProvisioned ¶
func ControlPlaneIsProvisioned(t *testing.T, ctx context.Context, controlPlane types.NamespacedName, clients K8sClients) func() bool
ControlPlaneIsProvisioned is a helper function for tests that returns a function that can be used to check if a ControlPlane was provisioned. Should be used in conjunction with require.Eventually or assert.Eventually.
func ControlPlaneIsReady ¶
func ControlPlaneIsReady(t *testing.T, ctx context.Context, controlplane types.NamespacedName, clients K8sClients) func() bool
ControlPlaneIsReady is a helper function for tests. It returns a function that can be used to check if a ControlPlane is marked as Ready. Should be used in conjunction with require.Eventually or assert.Eventually.
func ControlPlaneIsScheduled ¶
func ControlPlaneIsScheduled(t *testing.T, ctx context.Context, controlPlane types.NamespacedName, operatorClient *clientset.Clientset) func() bool
ControlPlaneIsScheduled is a helper function for tests that returns a function that can be used to check if a ControlPlane was scheduled. Should be used in conjunction with require.Eventually or assert.Eventually.
func ControlPlaneUpdateEventually ¶
func ControlPlaneUpdateEventually(t *testing.T, ctx context.Context, controlplaneNN types.NamespacedName, clients K8sClients, updateFunc func(*operatorv1beta1.ControlPlane)) func() bool
ControlPlaneUpdateEventually is a helper function for tests that returns a function that can be used to update the ControlPlane. Should be used in conjunction with require.Eventually or assert.Eventually.
func ControlPlanesClusterRoleBindingHasSubject ¶
func ControlPlanesClusterRoleBindingHasSubject(t *testing.T, ctx context.Context, controlplane *operatorv1beta1.ControlPlane, clients K8sClients, subject rbacv1.Subject) func() bool
ControlPlanesClusterRoleBindingHasSubject is a helper function for tests that returns a function that can be used to check if ControlPlane's ClusterRoleBinding contains the provided Subject. Should be used in conjunction with require.Eventually or assert.Eventually.
func ControlPlanesClusterRoleHasPolicyRule ¶
func ControlPlanesClusterRoleHasPolicyRule(t *testing.T, ctx context.Context, controlplane *operatorv1beta1.ControlPlane, clients K8sClients, pr rbacv1.PolicyRule) func() bool
ControlPlanesClusterRoleHasPolicyRule is a helper function for tests that returns a function that can be used to check if ControlPlane's ClusterRole contains the provided PolicyRule. Should be used in conjunction with require.Eventually or assert.Eventually.
func DataPlaneHasActiveDeployment ¶
func DataPlaneHasActiveDeployment( t *testing.T, ctx context.Context, dataplaneNN types.NamespacedName, ret *appsv1.Deployment, matchingLabels client.MatchingLabels, clients K8sClients, ) func() bool
DataPlaneHasActiveDeployment is a helper function for tests that returns a function that can be used to check if a DataPlane has an active deployment (that is, a Deployment that has at least 1 Replica and that all Replicas as marked as Available). Should be used in conjunction with require.Eventually or assert.Eventually.
func DataPlaneHasActiveService ¶
func DataPlaneHasActiveService(t *testing.T, ctx context.Context, dataplaneName types.NamespacedName, ret *corev1.Service, clients K8sClients, matchingLabels client.MatchingLabels) func() bool
DataPlaneHasActiveService is a helper function for tests that returns a function that can be used to check if a DataPlane has an active proxy service. Should be used in conjunction with require.Eventually or assert.Eventually.
func DataPlaneHasDeployment ¶
func DataPlaneHasDeployment( t *testing.T, ctx context.Context, dataplaneName types.NamespacedName, ret *appsv1.Deployment, clients K8sClients, matchingLabels client.MatchingLabels, asserts ...func(appsv1.Deployment) bool, ) func() bool
DataPlaneHasDeployment is a helper function for tests that returns a function that can be used to check if a DataPlane has a Deployment. Optionally the caller can provide a list of assertions that will be checked against the found Deployment. Should be used in conjunction with require.Eventually or assert.Eventually.
func DataPlaneHasHPA ¶
func DataPlaneHasHPA( t *testing.T, ctx context.Context, dataplane *operatorv1beta1.DataPlane, ret *autoscalingv2.HorizontalPodAutoscaler, clients K8sClients, ) func() bool
DataPlaneHasHPA is a helper function for tests that returns a function that can be used to check if a DataPlane has an active HPA. Should be used in conjunction with require.Eventually or assert.Eventually.
func DataPlaneHasNReadyPods ¶
func DataPlaneHasNReadyPods(t *testing.T, ctx context.Context, dataplaneName types.NamespacedName, clients K8sClients, n int32) func() bool
DataPlaneHasNReadyPods checks if a DataPlane has at least N ready Pods.
func DataPlaneHasPodDisruptionBudget ¶ added in v1.4.0
func DataPlaneHasPodDisruptionBudget( t *testing.T, ctx context.Context, dataplane *operatorv1beta1.DataPlane, ret *policyv1.PodDisruptionBudget, clients K8sClients, req PodDisruptionBudgetRequirement, ) func() bool
DataPlaneHasPodDisruptionBudget is a helper function for tests that returns a function that can be used to check if a DataPlane has a PodDisruptionBudget. It expects there is only a single PodDisruptionBudget for the DataPlane with the following requirements: - it is owned by the DataPlane, - its `app` label matches the DP name, - its `gateway-operator.konghq.com/managed-by` label is set to `dataplane`. Additionally, the caller can provide a requirement function that will be used to verify the PodDisruptionBudget (e.g. to check if it has an expected status). Should be used in conjunction with require.Eventually or assert.Eventually.
func DataPlaneHasService ¶
func DataPlaneHasService( t *testing.T, ctx context.Context, dataplaneName types.NamespacedName, clients K8sClients, matchingLabels client.MatchingLabels, asserts ...func(corev1.Service) bool, ) func() bool
DataPlaneHasService is a helper function for tests that returns a function that can be used to check if a DataPlane has a service created. Should be used in conjunction with require.Eventually or assert.Eventually.
func DataPlaneHasServiceAndAddressesInStatus ¶
func DataPlaneHasServiceAndAddressesInStatus(t *testing.T, ctx context.Context, dataplaneName types.NamespacedName, clients K8sClients) func() bool
DataPlaneHasServiceAndAddressesInStatus is a helper function for tests that returns a function that can be used to check if a DataPlane has: - a backing service name in its .Service status field - a list of addreses of its backing service in its .Addresses status field Should be used in conjunction with require.Eventually or assert.Eventually.
func DataPlaneHasServiceSecret ¶
func DataPlaneHasServiceSecret(t *testing.T, ctx context.Context, dpNN, usingSvc types.NamespacedName, ret *corev1.Secret, clients K8sClients) func() bool
DataPlaneHasServiceSecret checks if a DataPlane's Service has one owned Secret.
func DataPlaneIsReady ¶
func DataPlaneIsReady(t *testing.T, ctx context.Context, dataplane types.NamespacedName, operatorClient *clientset.Clientset) func() bool
DataPlaneIsReady is a helper function for tests that returns a function that can be used to check if a DataPlane is ready. Should be used in conjunction with require.Eventually or assert.Eventually.
func DataPlanePredicate ¶
func DataPlanePredicate( t *testing.T, ctx context.Context, dataplaneName types.NamespacedName, predicate func(dataplane *operatorv1beta1.DataPlane) bool, operatorClient *clientset.Clientset, ) func() bool
DataPlanePredicate is a helper function for tests that returns a function that can be used to check if a DataPlane has a certain state.
func DataPlaneServiceHasNActiveEndpoints ¶
func DataPlaneServiceHasNActiveEndpoints(t *testing.T, ctx context.Context, serviceName types.NamespacedName, clients K8sClients, n int) func() bool
DataPlaneServiceHasNActiveEndpoints is a helper function for tests that returns a function that can be used to check if a Service has active endpoints. Should be used in conjunction with require.Eventually or assert.Eventually.
func DataPlaneUpdateEventually ¶
func DataPlaneUpdateEventually(t *testing.T, ctx context.Context, dataplaneNN types.NamespacedName, clients K8sClients, updateFunc func(*operatorv1beta1.DataPlane)) func() bool
DataPlaneUpdateEventually is a helper function for tests that returns a function that can be used to update the DataPlane. Should be used in conjunction with require.Eventually or assert.Eventually.
func DeployCRDs ¶
func DeployCRDs(ctx context.Context, crdPath string, operatorClient *operatorclient.Clientset, env environments.Environment) error
DeployCRDs deploys the CRDs commonly used in tests.
func ExtractModuleVersion ¶ added in v1.4.0
ExtractModuleVersion extracts version of an imported module in go.mod. If the module is not found, or we failed to parse the module version, it will return an error.
func GatewayClassIsAccepted ¶
func GatewayClassIsAccepted(t *testing.T, ctx context.Context, gatewayClassName string, clients K8sClients) func() bool
GatewayClassIsAccepted is a helper function for tests that returns a function that can be used to check if a GatewayClass is accepted. Should be used in conjunction with require.Eventually or assert.Eventually.
func GatewayControlPlaneIsProvisioned ¶
func GatewayControlPlaneIsProvisioned(t *testing.T, ctx context.Context, gateway *gwtypes.Gateway, clients K8sClients) func() bool
GatewayControlPlaneIsProvisioned returns a function that checks if a Gateway's ControlPlane is provisioned.
func GatewayDataPlaneIsReady ¶
func GatewayDataPlaneIsReady(t *testing.T, ctx context.Context, gateway *gwtypes.Gateway, clients K8sClients) func() bool
GatewayDataPlaneIsReady returns a function that checks if a Gateway's DataPlane is ready.
func GatewayIPAddressExist ¶
func GatewayIPAddressExist(t *testing.T, ctx context.Context, gatewayNSN types.NamespacedName, clients K8sClients) func() bool
GatewayIPAddressExist checks if a Gateway has IP addresses.
func GatewayIsAccepted ¶ added in v1.2.2
func GatewayIsAccepted(t *testing.T, ctx context.Context, gatewayNSN types.NamespacedName, clients K8sClients) func() bool
GatewayIsAccepted returns a function that checks if a Gateway is scheduled.
func GatewayIsProgrammed ¶
func GatewayIsProgrammed(t *testing.T, ctx context.Context, gatewayNSN types.NamespacedName, clients K8sClients) func() bool
GatewayIsProgrammed returns a function that checks if a Gateway is programmed.
func GatewayListenersAreProgrammed ¶
func GatewayListenersAreProgrammed(t *testing.T, ctx context.Context, gatewayNSN types.NamespacedName, clients K8sClients) func() bool
GatewayListenersAreProgrammed returns a function that checks if a Gateway's listeners are programmed.
func GatewayNetworkPoliciesExist ¶
func GatewayNetworkPoliciesExist(t *testing.T, ctx context.Context, gateway *gwtypes.Gateway, clients K8sClients) func() bool
GatewayNetworkPoliciesExist is a helper function for tests that returns a function that can be used to check if a Gateway owns a networkpolicy. Should be used in conjunction with require.Eventually or assert.Eventually. Gateway object argument does need to exist in the cluster, thus, the function may be used with Not after the gateway has been deleted, to verify that the networkpolicy has been deleted too.
func GatewayNetworkPolicyForGatewayContainsRules ¶
func GatewayNetworkPolicyForGatewayContainsRules[T ingressRuleT](t *testing.T, ctx context.Context, gateway *gwtypes.Gateway, clients K8sClients, rules ...T) func() bool
GatewayNetworkPolicyForGatewayContainsRules is a helper function for tets that returns a function that can be used to check if exactly 1 NetworkPolicy exist for Gateway and if it contains all the provided rules.
func GatewayNotExist ¶
func GatewayNotExist(t *testing.T, ctx context.Context, gatewayNSN types.NamespacedName, clients K8sClients) func() bool
GatewayNotExist is a helper function for tests that returns a function to check a if gateway(with specified namespace and name) does not exist.
Should be used in conjunction with require.Eventually or assert.Eventually.
func GetResponseBodyContains ¶
func GetResponseBodyContains(t *testing.T, clients K8sClients, httpc *http.Client, request *http.Request, responseContains string) func() bool
GetResponseBodyContains issues an HTTP request and checks if a response body contains a string.
func HPAPredicate ¶
func HPAPredicate( t *testing.T, ctx context.Context, hpaName types.NamespacedName, predicate func(hpa *autoscalingv2.HorizontalPodAutoscaler) bool, client client.Client, ) func() bool
HPAPredicate is a helper function for tests that returns a function that can be used to check if an HPA has a certain state.
func HTTPRouteUpdateEventually ¶ added in v1.4.0
func HTTPRouteUpdateEventually(t *testing.T, ctx context.Context, httpRouteNN types.NamespacedName, clients K8sClients, updateFunc func(*gatewayv1.HTTPRoute)) func() bool
HTTPRouteUpdateEventually is a helper function for tests that returns a function that can be used to update the HTTPRoute. Should be used in conjunction with require.Eventually or assert.Eventually.
func MustGetGateway ¶
func MustGetGateway(t *testing.T, ctx context.Context, gatewayNSN types.NamespacedName, clients K8sClients) *gwtypes.Gateway
MustGetGateway is a helper function for tests that conveniently gets a gateway by name. It will fail the test if getting the gateway fails.
func MustListControlPlaneClusterRoleBindings ¶
func MustListControlPlaneClusterRoleBindings(t *testing.T, ctx context.Context, controlplane *operatorv1beta1.ControlPlane, clients K8sClients) []rbacv1.ClusterRoleBinding
MustListControlPlaneClusterRoleBindings is a helper function for tests that conveniently lists all clusterrolebindings owned by a given controlplane.
func MustListControlPlaneClusterRoles ¶
func MustListControlPlaneClusterRoles(t *testing.T, ctx context.Context, controlplane *operatorv1beta1.ControlPlane, clients K8sClients) []rbacv1.ClusterRole
MustListControlPlaneClusterRoles is a helper function for tests that conveniently lists all clusterroles owned by a given controlplane.
func MustListControlPlaneDeployments ¶
func MustListControlPlaneDeployments(t *testing.T, ctx context.Context, controlplane *operatorv1beta1.ControlPlane, clients K8sClients) []appsv1.Deployment
mustListControlPlaneDeployments is a helper function for tests that conveniently lists all deployments managed by a given controlplane.
func MustListControlPlanesForGateway ¶
func MustListControlPlanesForGateway(t *testing.T, ctx context.Context, gateway *gwtypes.Gateway, clients K8sClients) []operatorv1beta1.ControlPlane
MustListControlPlanesForGateway is a helper function for tests that conveniently lists all controlplanes managed by a given gateway.
func MustListDataPlaneDeployments ¶
func MustListDataPlaneDeployments(t *testing.T, ctx context.Context, dataplane *operatorv1beta1.DataPlane, clients K8sClients, matchinglabels client.MatchingLabels) []appsv1.Deployment
MustListDataPlaneDeployments is a helper function for tests that conveniently lists all deployments managed by a given dataplane.
func MustListDataPlaneHPAs ¶
func MustListDataPlaneHPAs(t *testing.T, ctx context.Context, dataplane *operatorv1beta1.DataPlane, clients K8sClients, matchinglabels client.MatchingLabels) []autoscalingv2.HorizontalPodAutoscaler
MustListDataPlaneHPAs is a helper function for tests that conveniently lists all HPAs managed by a given dataplane.
func MustListDataPlanePodDisruptionBudgets ¶ added in v1.4.0
func MustListDataPlanePodDisruptionBudgets( t *testing.T, ctx context.Context, dataplane *operatorv1beta1.DataPlane, clients K8sClients, matchinglabels client.MatchingLabels, ) []policyv1.PodDisruptionBudget
MustListDataPlanePodDisruptionBudgets is a helper function for tests that conveniently lists all PDBs managed by a given dataplane.
func MustListDataPlaneServices ¶
func MustListDataPlaneServices(t *testing.T, ctx context.Context, dataplane *operatorv1beta1.DataPlane, mgrClient client.Client, matchingLabels client.MatchingLabels) []corev1.Service
MustListDataPlaneServices is a helper function for tests that conveniently lists all proxy services managed by a given dataplane.
func MustListDataPlanesForGateway ¶
func MustListDataPlanesForGateway(t *testing.T, ctx context.Context, gateway *gwtypes.Gateway, clients K8sClients) []operatorv1beta1.DataPlane
MustListDataPlanesForGateway is a helper function for tests that conveniently lists all dataplanes managed by a given gateway.
func MustListNetworkPoliciesForGateway ¶
func MustListNetworkPoliciesForGateway(t *testing.T, ctx context.Context, gateway *gwtypes.Gateway, clients K8sClients) []networkingv1.NetworkPolicy
MustListNetworkPoliciesForGateway is a helper function for tests that conveniently lists all NetworkPolicies managed by a given gateway.
func MustListServiceEndpointSlices ¶
func MustListServiceEndpointSlices(t *testing.T, ctx context.Context, serviceName types.NamespacedName, mgrClient client.Client) []discoveryv1.EndpointSlice
MustListServiceEndpointSlices is a helper function for tests that conveniently lists all endpointSlices related to a specific service.
func ProjectRootPath ¶ added in v1.4.0
func ProjectRootPath() string
ProjectRootPath returns the root directory of this project.
func SetupControllerLogger ¶
SetupControllerLogger sets up the controller logger. This functions needs to be called before 30sec after the controller packages is loaded, otherwise the logger will not be initialized. Args:
- controllerManagerOut: the path to the file where the controller logs should be written to or "stdout".
Returns:
- The close function, that will close the log file if one was created. Should be called after the tests are done.
- An error on failure.
Types ¶
type BuilderOpt ¶
type BuilderOpt func(*environments.Builder, clusters.Type)
BuilderOpt is an option function for an environment builder.
type K8sClients ¶
type K8sClients struct { K8sClient *kubernetesclient.Clientset OperatorClient *operatorclient.Clientset GatewayClient *gatewayclient.Clientset ConfigurationClient *configurationclient.Clientset MgrClient ctrlruntimeclient.Client }
K8sClients is a struct that contains all the Kubernetes clients needed by the tests.
func NewK8sClients ¶
func NewK8sClients(env environments.Environment) (K8sClients, error)
NewK8sClients returns a new K8sClients struct with all the clients needed by the tests.
type PodDisruptionBudgetRequirement ¶ added in v1.4.0
type PodDisruptionBudgetRequirement func(policyv1.PodDisruptionBudget) bool
PodDisruptionBudgetRequirement is a function type used to check if a PodDisruptionBudget meets a certain requirement.
func AnyPodDisruptionBudget ¶ added in v1.4.0
func AnyPodDisruptionBudget() PodDisruptionBudgetRequirement
AnyPodDisruptionBudget returns a function that accepts any PodDisruptionBudget.