kubernetes

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2024 License: Apache-2.0 Imports: 36 Imported by: 1

Documentation

Index

Constants

View Source
const GatewayExcludedFromReadinessChecks = "gateway-api/skip-this-for-readiness"

GatewayExcludedFromReadinessChecks is an annotation that can be placed on a Gateway provided via the tests to indicate that it is NOT expected to be Accepted or Provisioned in its default state. This is generally helpful for tests which validate fixing broken Gateways, e.t.c.

Variables

This section is empty.

Functions

func ConditionsHaveLatestObservedGeneration added in v0.6.0

func ConditionsHaveLatestObservedGeneration(obj metav1.Object, conditions []metav1.Condition) error

func DumpEchoLogs added in v0.7.1

func DumpEchoLogs(ns, name string, c client.Client, cs clientset.Interface) ([][]byte, error)

DumpEchoLogs returns logs of the echoserver pod in in the given namespace and with the given name.

func FilterStaleConditions added in v0.6.0

func FilterStaleConditions(obj metav1.Object, conditions []metav1.Condition) []metav1.Condition

FilterStaleConditions returns the list of status condition whose observedGeneration does not match the object's metadata.Generation

func GWCMustHaveAcceptedConditionAny added in v0.6.1

func GWCMustHaveAcceptedConditionAny(t *testing.T, c client.Client, timeoutConfig config.TimeoutConfig, gwcName string) string

GWCMustHaveAcceptedConditionAny waits until the specified GatewayClass has an Accepted condition set with a status set to any value.

func GWCMustHaveAcceptedConditionTrue added in v0.6.1

func GWCMustHaveAcceptedConditionTrue(t *testing.T, c client.Client, timeoutConfig config.TimeoutConfig, gwcName string) string

GWCMustHaveAcceptedConditionTrue waits until the specified GatewayClass has an Accepted condition set with a status value equal to True.

func GatewayAndHTTPRoutesMustBeAccepted added in v0.6.0

func GatewayAndHTTPRoutesMustBeAccepted(t *testing.T, c client.Client, timeoutConfig config.TimeoutConfig, controllerName string, gw GatewayRef, routeNNs ...types.NamespacedName) string

GatewayAndHTTPRoutesMustBeAccepted waits until:

  1. The specified Gateway has an IP address assigned to it.
  2. The route has a ParentRef referring to the Gateway.
  3. All the gateway's listeners have the following conditions set to true: - ListenerConditionResolvedRefs - ListenerConditionAccepted - ListenerConditionProgrammed

The test will fail if these conditions are not met before the timeouts.

func GatewayAndRoutesMustBeAccepted added in v1.1.0

func GatewayAndRoutesMustBeAccepted(t *testing.T, c client.Client, timeoutConfig config.TimeoutConfig, controllerName string, gw GatewayRef, routeType any, routeNNs ...types.NamespacedName) string

GatewayAndRoutesMustBeAccepted waits until:

  1. The specified Gateway has an IP address assigned to it.
  2. The route has a ParentRef referring to the Gateway.
  3. All the gateway's listeners have the following conditions set to true: - ListenerConditionResolvedRefs - ListenerConditionAccepted - ListenerConditionProgrammed

The test will fail if these conditions are not met before the timeouts.

func GatewayAndTLSRoutesMustBeAccepted added in v0.6.1

func GatewayAndTLSRoutesMustBeAccepted(t *testing.T, c client.Client, timeoutConfig config.TimeoutConfig, controllerName string, gw GatewayRef, routeNNs ...types.NamespacedName) (string, []gatewayv1.Hostname)

GatewayAndTLSRoutesMustBeAccepted waits until the specified Gateway has an IP address assigned to it and the TLSRoute has a ParentRef referring to the Gateway. The test will fail if these conditions are not met before the timeouts.

func GatewayAndUDPRoutesMustBeAccepted added in v1.1.0

func GatewayAndUDPRoutesMustBeAccepted(t *testing.T, c client.Client, timeoutConfig config.TimeoutConfig, controllerName string, gw GatewayRef, routeNNs ...types.NamespacedName) string

GatewayAndUDPRoutesMustBeAccepted waits until the specified Gateway has an IP address assigned to it and the UDPRoute has a ParentRef referring to the Gateway. The test will fail if these conditions are not met before the timeouts.

func GatewayClassMustHaveLatestConditions added in v0.6.0

func GatewayClassMustHaveLatestConditions(t *testing.T, gwc *gatewayv1.GatewayClass)

GatewayClassMustHaveLatestConditions will fail the test if there are conditions that were not updated

func GatewayListenersMustHaveConditions added in v1.0.0

func GatewayListenersMustHaveConditions(t *testing.T, client client.Client, timeoutConfig config.TimeoutConfig, gwName types.NamespacedName, conditions []metav1.Condition)

GatewayListenersMustHaveConditions checks if every listener of the specified gateway has all the specified conditions.

func GatewayMustHaveCondition added in v1.0.0

func GatewayMustHaveCondition(
	t *testing.T,
	client client.Client,
	timeoutConfig config.TimeoutConfig,
	gwNN types.NamespacedName,
	expectedCondition metav1.Condition,
)

GatewayMustHaveCondition checks that the supplied Gateway has the supplied Condition, halting after the specified timeout is exceeded.

func GatewayMustHaveLatestConditions added in v0.6.0

func GatewayMustHaveLatestConditions(t *testing.T, c client.Client, timeoutConfig config.TimeoutConfig, gwNN types.NamespacedName)

GatewayMustHaveLatestConditions waits until the specified Gateway has all conditions updated with the latest observed generation.

func GatewayMustHaveZeroRoutes added in v0.6.0

func GatewayMustHaveZeroRoutes(t *testing.T, client client.Client, timeoutConfig config.TimeoutConfig, gwName types.NamespacedName)

GatewayMustHaveZeroRoutes validates that the gateway has zero routes attached. The status may indicate a single listener with zero attached routes or no listeners.

func GatewayStatusMustHaveListeners

func GatewayStatusMustHaveListeners(t *testing.T, cl client.Client, timeoutConfig config.TimeoutConfig, gwNN types.NamespacedName, listeners []gatewayv1.ListenerStatus)

GatewayStatusMustHaveListeners waits for the specified Gateway to have listeners in status that match the expected listeners. This will cause the test to halt if the specified timeout is exceeded.

func HTTPRouteMustHaveCondition

func HTTPRouteMustHaveCondition(t *testing.T, client client.Client, timeoutConfig config.TimeoutConfig, routeNN types.NamespacedName, gwNN types.NamespacedName, condition metav1.Condition)

HTTPRouteMustHaveCondition checks that the supplied HTTPRoute has the supplied Condition, halting after the specified timeout is exceeded.

func HTTPRouteMustHaveLatestConditions added in v0.6.0

func HTTPRouteMustHaveLatestConditions(t *testing.T, r *gatewayv1.HTTPRoute)

HTTPRouteMustHaveLatestConditions will fail the test if there are conditions that were not updated

func HTTPRouteMustHaveNoAcceptedParents

func HTTPRouteMustHaveNoAcceptedParents(t *testing.T, client client.Client, timeoutConfig config.TimeoutConfig, routeName types.NamespacedName)

HTTPRouteMustHaveNoAcceptedParents waits for the specified HTTPRoute to have either no parents or a single parent that is not accepted. This is used to validate HTTPRoute errors.

func HTTPRouteMustHaveParents

func HTTPRouteMustHaveParents(t *testing.T, client client.Client, timeoutConfig config.TimeoutConfig, routeName types.NamespacedName, parents []gatewayv1.RouteParentStatus, namespaceRequired bool)

HTTPRouteMustHaveParents waits for the specified HTTPRoute to have parents in status that match the expected parents. This will cause the test to halt if the specified timeout is exceeded.

func HTTPRouteMustHaveResolvedRefsConditionsTrue added in v0.6.2

func HTTPRouteMustHaveResolvedRefsConditionsTrue(t *testing.T, client client.Client, timeoutConfig config.TimeoutConfig, routeNN types.NamespacedName, gwNN types.NamespacedName)

HTTPRouteMustHaveResolvedRefsConditionsTrue checks that the supplied HTTPRoute has the resolvedRefsCondition set to true.

func MeshNamespacesMustBeReady added in v0.8.0

func MeshNamespacesMustBeReady(t *testing.T, c client.Client, timeoutConfig config.TimeoutConfig, namespaces []string)

MeshNamespacesMustBeReady waits until all Pods are marked Ready. This is intended to be used for mesh tests and does not require any Gateways to exist. This will cause the test to halt if the specified timeout is exceeded.

func MustCreateSelfSignedCertSecret

func MustCreateSelfSignedCertSecret(t *testing.T, namespace, secretName string, hosts []string) *corev1.Secret

MustCreateSelfSignedCertSecret creates a self-signed SSL certificate and stores it in a secret

func NamespacesMustBeReady

func NamespacesMustBeReady(t *testing.T, c client.Client, timeoutConfig config.TimeoutConfig, namespaces []string)

NamespacesMustBeReady waits until all Pods are marked Ready and all Gateways are marked Accepted and Programmed in the specified namespace(s). This will cause the test to halt if the specified timeout is exceeded.

func RouteMustHaveParents added in v1.1.0

func RouteMustHaveParents(t *testing.T, cli client.Client, timeoutConfig config.TimeoutConfig, routeName types.NamespacedName, parents []gatewayv1.RouteParentStatus, namespaceRequired bool, routeType any)

func RouteTypeMustHaveParentsField added in v1.1.0

func RouteTypeMustHaveParentsField(t *testing.T, routeType any) string

RouteTypeMustHaveParentsField ensures the provided routeType has a routeType.Status.Parents field of type []v1alpha2.RouteParentStatus.

func TLSRouteMustHaveCondition added in v0.8.0

func TLSRouteMustHaveCondition(t *testing.T, client client.Client, timeoutConfig config.TimeoutConfig, routeNN types.NamespacedName, gwNN types.NamespacedName, condition metav1.Condition)

TLSRouteMustHaveCondition checks that the supplied TLSRoute has the supplied Condition, halting after the specified timeout is exceeded.

func TLSRouteMustHaveParents added in v0.6.1

func TLSRouteMustHaveParents(t *testing.T, client client.Client, timeoutConfig config.TimeoutConfig, routeName types.NamespacedName, parents []v1alpha2.RouteParentStatus, namespaceRequired bool) v1alpha2.TLSRoute

TLSRouteMustHaveParents waits for the specified TLSRoute to have parents in status that match the expected parents, and also returns the TLSRoute. This will cause the test to halt if the specified timeout is exceeded.

func UDPRouteMustHaveParents added in v1.1.0

func UDPRouteMustHaveParents(t *testing.T, client client.Client, timeoutConfig config.TimeoutConfig, routeName types.NamespacedName, parents []gatewayv1.RouteParentStatus, namespaceRequired bool)

UDPRouteMustHaveParents waits for the specified UDPRoute to have parents in status that match the expected parents. This will cause the test to halt if the specified timeout is exceeded.

func WaitForGatewayAddress

func WaitForGatewayAddress(t *testing.T, client client.Client, timeoutConfig config.TimeoutConfig, gwRef GatewayRef) (string, error)

WaitForGatewayAddress waits until at least one IP Address has been set in the status of the specified Gateway.

Types

type Applier

type Applier struct {
	NamespaceLabels      map[string]string
	NamespaceAnnotations map[string]string

	// GatewayClass will be used as the spec.gatewayClassName when applying Gateway resources
	GatewayClass string

	// ControllerName will be used as the spec.controllerName when applying GatewayClass resources
	ControllerName string

	// ManifestFS is the filesystem to use when reading manifests.
	ManifestFS []fs.FS

	// UsableNetworkAddresses is a list of addresses that are expected to be
	// supported AND usable for Gateways in the underlying implementation.
	UsableNetworkAddresses []v1beta1.GatewayAddress

	// UnusableNetworkAddresses is a list of addresses that are expected to be
	// supported, but not usable for Gateways in the underlying implementation.
	UnusableNetworkAddresses []v1beta1.GatewayAddress
}

Applier prepares manifests depending on the available options and applies them to the Kubernetes cluster.

func (Applier) MustApplyObjectsWithCleanup

func (a Applier) MustApplyObjectsWithCleanup(t *testing.T, c client.Client, timeoutConfig config.TimeoutConfig, resources []client.Object, cleanup bool)

func (Applier) MustApplyWithCleanup

func (a Applier) MustApplyWithCleanup(t *testing.T, c client.Client, timeoutConfig config.TimeoutConfig, location string, cleanup bool)

MustApplyWithCleanup creates or updates Kubernetes resources defined with the provided YAML file and registers a cleanup function for resources it created. Note that this does not remove resources that already existed in the cluster.

type GatewayRef

type GatewayRef struct {
	types.NamespacedName
	// contains filtered or unexported fields
}

GatewayRef is a tiny type for specifying an HTTP Route ParentRef without relying on a specific api version.

func NewGatewayRef

func NewGatewayRef(nn types.NamespacedName, listenerNames ...string) GatewayRef

NewGatewayRef creates a GatewayRef resource. ListenerNames are optional.

Jump to

Keyboard shortcuts

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