...

Package kubernetes

import "sigs.k8s.io/gateway-api/conformance/utils/kubernetes"
Overview
Index

Overview ▾

Index ▾

Constants
func ConditionsHaveLatestObservedGeneration(obj metav1.Object, conditions []metav1.Condition) error
func DumpEchoLogs(ns, name string, c client.Client, cs clientset.Interface) ([][]byte, error)
func FilterStaleConditions(obj metav1.Object, conditions []metav1.Condition) []metav1.Condition
func GWCMustHaveAcceptedConditionAny(t *testing.T, c client.Client, timeoutConfig config.TimeoutConfig, gwcName string) string
func GWCMustHaveAcceptedConditionTrue(t *testing.T, c client.Client, timeoutConfig config.TimeoutConfig, gwcName string) string
func GatewayAndHTTPRoutesMustBeAccepted(t *testing.T, c client.Client, timeoutConfig config.TimeoutConfig, controllerName string, gw GatewayRef, routeNNs ...types.NamespacedName) string
func GatewayAndTLSRoutesMustBeAccepted(t *testing.T, c client.Client, timeoutConfig config.TimeoutConfig, controllerName string, gw GatewayRef, routeNNs ...types.NamespacedName) (string, []gatewayv1.Hostname)
func GatewayClassMustHaveLatestConditions(t *testing.T, gwc *gatewayv1.GatewayClass)
func GatewayListenersMustHaveConditions(t *testing.T, client client.Client, timeoutConfig config.TimeoutConfig, gwName types.NamespacedName, conditions []metav1.Condition)
func GatewayMustHaveCondition(t *testing.T, client client.Client, timeoutConfig config.TimeoutConfig, gwNN types.NamespacedName, expectedCondition metav1.Condition)
func GatewayMustHaveLatestConditions(t *testing.T, c client.Client, timeoutConfig config.TimeoutConfig, gwNN types.NamespacedName)
func GatewayMustHaveZeroRoutes(t *testing.T, client client.Client, timeoutConfig config.TimeoutConfig, gwName types.NamespacedName)
func GatewayStatusMustHaveListeners(t *testing.T, client client.Client, timeoutConfig config.TimeoutConfig, gwNN types.NamespacedName, listeners []gatewayv1.ListenerStatus)
func HTTPRouteMustHaveCondition(t *testing.T, client client.Client, timeoutConfig config.TimeoutConfig, routeNN types.NamespacedName, gwNN types.NamespacedName, condition metav1.Condition)
func HTTPRouteMustHaveLatestConditions(t *testing.T, r *gatewayv1.HTTPRoute)
func HTTPRouteMustHaveNoAcceptedParents(t *testing.T, client client.Client, timeoutConfig config.TimeoutConfig, routeName types.NamespacedName)
func HTTPRouteMustHaveParents(t *testing.T, client client.Client, timeoutConfig config.TimeoutConfig, routeName types.NamespacedName, parents []gatewayv1.RouteParentStatus, namespaceRequired bool)
func HTTPRouteMustHaveResolvedRefsConditionsTrue(t *testing.T, client client.Client, timeoutConfig config.TimeoutConfig, routeNN types.NamespacedName, gwNN types.NamespacedName)
func MeshNamespacesMustBeReady(t *testing.T, c client.Client, timeoutConfig config.TimeoutConfig, namespaces []string)
func MustCreateSelfSignedCertSecret(t *testing.T, namespace, secretName string, hosts []string) *corev1.Secret
func NamespacesMustBeReady(t *testing.T, c client.Client, timeoutConfig config.TimeoutConfig, namespaces []string)
func TLSRouteMustHaveCondition(t *testing.T, client client.Client, timeoutConfig config.TimeoutConfig, routeNN types.NamespacedName, gwNN types.NamespacedName, condition metav1.Condition)
func TLSRouteMustHaveParents(t *testing.T, client client.Client, timeoutConfig config.TimeoutConfig, routeName types.NamespacedName, parents []v1alpha2.RouteParentStatus, namespaceRequired bool) v1alpha2.TLSRoute
func WaitForGatewayAddress(t *testing.T, client client.Client, timeoutConfig config.TimeoutConfig, gwName types.NamespacedName) (string, error)
type Applier
    func (a Applier) MustApplyObjectsWithCleanup(t *testing.T, c client.Client, timeoutConfig config.TimeoutConfig, resources []client.Object, cleanup bool)
    func (a Applier) MustApplyWithCleanup(t *testing.T, c client.Client, timeoutConfig config.TimeoutConfig, location string, cleanup bool)
type GatewayRef
    func NewGatewayRef(nn types.NamespacedName, listenerNames ...string) GatewayRef

Package files

apply.go certificate.go helpers.go logs.go

Constants

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.

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

func ConditionsHaveLatestObservedGeneration

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

func DumpEchoLogs

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

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

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

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

func GWCMustHaveAcceptedConditionTrue

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

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

func GatewayAndHTTPRoutesMustBeAccepted

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 GatewayAndTLSRoutesMustBeAccepted

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 GatewayClassMustHaveLatestConditions

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

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

func GatewayListenersMustHaveConditions

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

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

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

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, client 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

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

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

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 TLSRouteMustHaveCondition

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

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 WaitForGatewayAddress

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

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

type Applier

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

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

    // FS is the filesystem to use when reading manifests.
    FS embed.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
}

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

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

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

func NewGatewayRef

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

NewGatewayRef creates a GatewayRef resource. ListenerNames are optional.