testing

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2019 License: Apache-2.0 Imports: 44 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HookComplete   = testing.HookComplete
	HookIncomplete = testing.HookIncomplete
)

Variables

View Source
var (
	InduceFailure             = testing.InduceFailure
	KeyOrDie                  = testing.KeyOrDie
	NewHooks                  = testing.NewHooks
	ExpectNormalEventDelivery = testing.ExpectNormalEventDelivery
	ValidateCreates           = testing.ValidateCreates
	ValidateUpdates           = testing.ValidateUpdates
	ConfigMapFromTestFile     = testing.ConfigMapFromTestFile
	Eventf                    = testing.Eventf

	PrependGenerateNameReactor = testing.PrependGenerateNameReactor

	TestLogger = logtesting.TestLogger

	// ClearAllLoggers removes all the registered test loggers.
	ClearAllLoggers = logtesting.ClearAll
)

Functions

func MarkActive

func MarkActive(r *v1alpha1.Revision)

MarkActive calls .Status.MarkActive on the Revision.

func MarkConfigurationNotOwned

func MarkConfigurationNotOwned(service *v1alpha1.Service)

MarkConfigurationNotOwned calls the function of the same name on the Service's status.

func MarkContainerMissing

func MarkContainerMissing(rev *v1alpha1.Revision)

MarkContainerMissing calls .Status.MarkContainerMissing on the Revision.

func MarkIngressReady

func MarkIngressReady(r *v1alpha1.Route)

MarkIngressReady propagates a Ready=True ClusterIngress status to the Route.

func MarkProgressDeadlineExceeded

func MarkProgressDeadlineExceeded(r *v1alpha1.Revision)

MarkProgressDeadlineExceeded calls the method of the same name on the Revision with the message we expect the Revision Reconciler to pass.

func MarkRevisionReady

func MarkRevisionReady(r *v1alpha1.Revision)

MarkRevisionReady calls the necessary helpers to make the Revision Ready=True.

func MarkRouteNotOwned

func MarkRouteNotOwned(service *v1alpha1.Service)

MarkRouteNotOwned calls the function of the same name on the Service's status.

func MarkServiceNotOwned

func MarkServiceNotOwned(r *v1alpha1.Route)

MarkServiceNotOwned calls the function of the same name on the Service's status.

func MarkServiceTimeout

func MarkServiceTimeout(r *v1alpha1.Revision)

MarkServiceTimeout calls .Status.MarkServiceTimeout on the Revision.

func MarkTrafficAssigned

func MarkTrafficAssigned(r *v1alpha1.Route)

MarkTrafficAssigned calls the method of the same name on .Status

func MutateK8sService

func MutateK8sService(svc *corev1.Service)

MutateK8sService changes the service in a way that must be reconciled.

func Service

func Service(name, namespace string, so ...ServiceOption) *v1alpha1.Service

Service creates a service with ServiceOptions

func WithAddress

func WithAddress(r *v1alpha1.Route)

WithAddress sets the .Status.Address field to the prototypical internal hostname.

func WithAnotherDomain

func WithAnotherDomain(r *v1alpha1.Route)

WithAnotherDomain sets the .Status.Domain field to an atypical domain.

func WithAnotherRouteFinalizer

func WithAnotherRouteFinalizer(r *v1alpha1.Route)

WithAnotherRouteFinalizer adds a non-Route finalizer to the Route.

func WithBuild

func WithBuild(cfg *v1alpha1.Configuration)

WithBuild adds a Build to the provided Configuration.

func WithConfigDeletionTimestamp

func WithConfigDeletionTimestamp(r *v1alpha1.Configuration)

WithConfigDeletionTimestamp will set the DeletionTimestamp on the Config.

func WithConfigOwnersRemoved

func WithConfigOwnersRemoved(cfg *v1alpha1.Configuration)

WithConfigOwnersRemoved clears the owner references of this Configuration.

func WithDomain

func WithDomain(r *v1alpha1.Route)

WithDomain sets the .Status.Domain field to the prototypical domain.

func WithDomainInternal

func WithDomainInternal(r *v1alpha1.Route)

WithDomainInternal sets the .Status.DomainInternal field to the prototypical internal domain.

func WithEmptyLTTs

func WithEmptyLTTs(r *v1alpha1.Revision)

WithEmptyLTTs clears the LastTransitionTime fields on all of the conditions of the provided Revision.

func WithHPAClass

func WithHPAClass(pa *autoscalingv1alpha1.PodAutoscaler)

WithHPAClass updates the PA to add the hpa class annotation.

func WithInitRevConditions

func WithInitRevConditions(r *v1alpha1.Revision)

WithInitRevConditions calls .Status.InitializeConditions() on a Revision.

func WithInitRouteConditions

func WithInitRouteConditions(rt *v1alpha1.Route)

WithInitRouteConditions initializes the Service's conditions.

func WithInitSvcConditions

func WithInitSvcConditions(s *v1alpha1.Service)

WithInitSvcConditions initializes the Service's conditions.

func WithK8sSvcOwnersRemoved

func WithK8sSvcOwnersRemoved(svc *corev1.Service)

WithK8sSvcOwnersRemoved clears the owner references of this Route.

func WithKPAClass

func WithKPAClass(pa *autoscalingv1alpha1.PodAutoscaler)

WithKPAClass updates the PA to add the kpa class annotation.

func WithLocalDomain

func WithLocalDomain(r *v1alpha1.Route)

WithLocalDomain sets the .Status.Domain field to use `svc.cluster.local` suffix.

func WithLogURL

func WithLogURL(r *v1alpha1.Revision)

WithLogURL sets the .Status.LogURL to the expected value.

func WithManualRollout

func WithManualRollout(s *v1alpha1.Service)

WithManualRollout configures the Service to use a "manual" rollout.

func WithManualStatus

func WithManualStatus(s *v1alpha1.Service)

WithManualStatus configures the Service to have the appropriate status for a "manual" rollout type.

func WithNoBuild

func WithNoBuild(r *v1alpha1.Revision)

WithNoBuild updates the status conditions to propagate a Build status as-if no BuildRef was specified.

func WithObservedGen

func WithObservedGen(cfg *v1alpha1.Configuration)

WithObservedGen sets the observed generation of the Configuration.

func WithOngoingBuild

func WithOngoingBuild(r *v1alpha1.Revision)

WithOngoingBuild propagates the status of an in-progress Build to the Revision's status.

func WithPADeletionTimestamp

func WithPADeletionTimestamp(r *autoscalingv1alpha1.PodAutoscaler)

WithPADeletionTimestamp will set the DeletionTimestamp on the PodAutoscaler.

func WithPodAutoscalerOwnersRemoved

func WithPodAutoscalerOwnersRemoved(r *autoscalingv1alpha1.PodAutoscaler)

WithPodAutoscalerOwnersRemoved clears the owner references of this PodAutoscaler.

func WithReadyRoute

func WithReadyRoute(s *v1alpha1.Service)

WithReadyRoute reflects the Route's readiness in the Service resource.

func WithRevisionDeletionTimestamp

func WithRevisionDeletionTimestamp(r *v1alpha1.Revision)

WithRevisionDeletionTimestamp will set the DeletionTimestamp on the Revision.

func WithRouteDeletionTimestamp

func WithRouteDeletionTimestamp(r *v1alpha1.Route)

WithRouteDeletionTimestamp will set the DeletionTimestamp on the Route.

func WithRouteFinalizer

func WithRouteFinalizer(r *v1alpha1.Route)

WithRouteFinalizer adds the Route finalizer to the Route.

func WithRouteOwnersRemoved

func WithRouteOwnersRemoved(r *v1alpha1.Route)

WithRouteOwnersRemoved clears the owner references of this Route.

func WithRunLatestRollout

func WithRunLatestRollout(s *v1alpha1.Service)

WithRunLatestRollout configures the Service to use a "runLatest" rollout.

func WithServiceDeletionTimestamp

func WithServiceDeletionTimestamp(r *v1alpha1.Service)

WithServiceDeletionTimestamp will set the DeletionTimestamp on the Service.

func WithServiceStatusRouteNotReady

func WithServiceStatusRouteNotReady(s *v1alpha1.Service)

WithServiceStatusRouteNotReady sets the `RoutesReady` condition on the service to `Unknown`.

func WithSubsets

func WithSubsets(ep *corev1.Endpoints)

WithSubsets adds subsets to the body of a Revision, enabling us to refer readiness.

func WithSucceededTrue

func WithSucceededTrue(orig *unstructured.Unstructured)

WithSucceededTrue updates the status of the provided unstructured Build object with the expected success condition.

func WithSuccessfulBuild

func WithSuccessfulBuild(r *v1alpha1.Revision)

WithSuccessfulBuild propagates the status of a successful Build to the Revision's status.

func WithSvcStatusAddress

func WithSvcStatusAddress(s *v1alpha1.Service)

WithSvcStatusAddress updates the service's status with the address.

func WithSvcStatusDomain

func WithSvcStatusDomain(s *v1alpha1.Service)

WithSvcStatusDomain propagates the domain name to the status of the Service.

func WithTraffic

func WithTraffic(pa *autoscalingv1alpha1.PodAutoscaler)

WithTraffic updates the PA to reflect it receiving traffic.

Types

type ActionRecorder

type ActionRecorder = testing.ActionRecorder

type ActionRecorderList

type ActionRecorderList = testing.ActionRecorderList

type BuildOption

type BuildOption func(*unstructured.Unstructured)

BuildOption enables further configuration of a Build.

func WithSucceededFalse

func WithSucceededFalse(reason, message string) BuildOption

WithSucceededFalse updates the status of the provided unstructured Build object with the expected failure condition.

func WithSucceededUnknown

func WithSucceededUnknown(reason, message string) BuildOption

WithSucceededUnknown updates the status of the provided unstructured Build object with the expected in-flight condition.

type ConfigOption

type ConfigOption func(*v1alpha1.Configuration)

ConfigOption enables further configuration of a Configuration.

func MarkLatestCreatedFailed

func MarkLatestCreatedFailed(msg string) ConfigOption

MarkLatestCreatedFailed calls .Status.MarkLatestCreatedFailed.

func MarkRevisionCreationFailed

func MarkRevisionCreationFailed(msg string) ConfigOption

MarkRevisionCreationFailed calls .Status.MarkRevisionCreationFailed.

func WithConfigConcurrencyModel

func WithConfigConcurrencyModel(ss v1alpha1.RevisionRequestConcurrencyModelType) ConfigOption

WithConfigConcurrencyModel sets the given Configuration's concurrency model.

func WithConfigLabel

func WithConfigLabel(key, value string) ConfigOption

WithConfigLabel attaches a particular label to the configuration.

func WithCreatedAndReady

func WithCreatedAndReady(created, ready string) ConfigOption

WithCreatedAndReady sets the latest{Created,Ready}RevisionName on the Configuration.

func WithGeneration

func WithGeneration(gen int64) ConfigOption

WithGeneration sets the generation of the Configuration.

func WithLatestCreated

func WithLatestCreated(name string) ConfigOption

WithLatestCreated initializes the .status.latestCreatedRevisionName to be the name of the latest revision that the Configuration would have created.

func WithLatestReady

func WithLatestReady(name string) ConfigOption

WithLatestReady initializes the .status.latestReadyRevisionName to be the name of the latest revision that the Configuration would have created.

type Ctor

Ctor functions create a k8s controller with given params.

type EndpointsOption

type EndpointsOption func(*corev1.Endpoints)

EndpointsOption enables further configuration of the Kubernetes Endpoints.

type EventList

type EventList = testing.EventList

type Factory

type Factory = testing.Factory

func MakeFactory

func MakeFactory(ctor Ctor) Factory

MakeFactory creates a reconciler factory with fake clients and controller created by `ctor`.

type FakeClock

type FakeClock struct {
	Time time.Time
}

func (FakeClock) Now

func (c FakeClock) Now() time.Time

type FakeStatsReporter

type FakeStatsReporter = testing.FakeStatsReporter

type HookResult

type HookResult = testing.HookResult

type K8sServiceOption

type K8sServiceOption func(*corev1.Service)

K8sServiceOption enables further configuration of the Kubernetes Service.

func WithClusterIP

func WithClusterIP(ip string) K8sServiceOption

func WithExternalName

func WithExternalName(name string) K8sServiceOption

type Listers

type Listers struct {
	// contains filtered or unexported fields
}

func NewListers

func NewListers(objs []runtime.Object) Listers

func (*Listers) GetBuildObjects

func (l *Listers) GetBuildObjects() []runtime.Object

func (*Listers) GetCachingObjects

func (l *Listers) GetCachingObjects() []runtime.Object

func (*Listers) GetClusterIngressLister

func (l *Listers) GetClusterIngressLister() networkinglisters.ClusterIngressLister

GetClusterIngressLister get lister for ClusterIngress resource.

func (*Listers) GetConfigMapLister

func (l *Listers) GetConfigMapLister() corev1listers.ConfigMapLister

func (*Listers) GetConfigurationLister

func (l *Listers) GetConfigurationLister() servinglisters.ConfigurationLister

func (*Listers) GetDeploymentLister

func (l *Listers) GetDeploymentLister() appsv1listers.DeploymentLister

func (*Listers) GetEndpointsLister

func (l *Listers) GetEndpointsLister() corev1listers.EndpointsLister

func (*Listers) GetGatewayLister

func (l *Listers) GetGatewayLister() istiolisters.GatewayLister

GetGatewayLister gets lister for Istio Gateway resource.

func (*Listers) GetHorizontalPodAutoscalerLister

func (l *Listers) GetHorizontalPodAutoscalerLister() autoscalingv1listers.HorizontalPodAutoscalerLister

func (*Listers) GetImageLister

func (l *Listers) GetImageLister() cachinglisters.ImageLister

func (*Listers) GetK8sServiceLister

func (l *Listers) GetK8sServiceLister() corev1listers.ServiceLister

func (*Listers) GetKubeObjects

func (l *Listers) GetKubeObjects() []runtime.Object

func (*Listers) GetPodAutoscalerLister

func (l *Listers) GetPodAutoscalerLister() kpalisters.PodAutoscalerLister

func (*Listers) GetRevisionLister

func (l *Listers) GetRevisionLister() servinglisters.RevisionLister

func (*Listers) GetRouteLister

func (l *Listers) GetRouteLister() servinglisters.RouteLister

func (*Listers) GetServiceLister

func (l *Listers) GetServiceLister() servinglisters.ServiceLister

func (*Listers) GetServingObjects

func (l *Listers) GetServingObjects() []runtime.Object

func (*Listers) GetSharedObjects

func (l *Listers) GetSharedObjects() []runtime.Object

func (*Listers) GetVirtualServiceLister

func (l *Listers) GetVirtualServiceLister() istiolisters.VirtualServiceLister

type PodAutoscalerOption

type PodAutoscalerOption func(*autoscalingv1alpha1.PodAutoscaler)

func WithBufferedTraffic

func WithBufferedTraffic(reason, message string) PodAutoscalerOption

WithBufferedTraffic updates the PA to reflect that it has received and buffered traffic while it is being activated.

func WithContainerConcurrency

func WithContainerConcurrency(cc int32) PodAutoscalerOption

WithContainerConcurrency returns a PodAutoscalerOption which sets the PodAutoscaler containerConcurrency to the provided value.

func WithMetricAnnotation

func WithMetricAnnotation(metric string) PodAutoscalerOption

WithMetricAnnotation adds a metric annotation to the PA.

func WithNoTraffic

func WithNoTraffic(reason, message string) PodAutoscalerOption

WithNoTraffic updates the PA to reflect the fact that it is not receiving traffic.

func WithTargetAnnotation

func WithTargetAnnotation(target string) PodAutoscalerOption

WithTargetAnnotation returns a PodAutoscalerOption which sets the PodAutoscaler autoscaling.knative.dev/target to the provided value.

type PodOption

type PodOption func(*corev1.Pod)

PodOption enables further configuration of a Pod.

func WithFailingContainer

func WithFailingContainer(name string, exitCode int, message string) PodOption

WithFailingContainer sets the .Status.ContainerStatuses on the pod to include a container named accordingly to fail with the given state.

type RevisionOption

type RevisionOption func(*v1alpha1.Revision)

RevisionOption enables further configuration of a Revision.

func MarkActivating

func MarkActivating(reason, message string) RevisionOption

MarkActivating calls .Status.MarkActivating on the Revision.

func MarkContainerExiting

func MarkContainerExiting(exitCode int32, message string) RevisionOption

MarkContainerExiting calls .Status.MarkContainerExiting on the Revision.

func MarkDeploying

func MarkDeploying(reason string) RevisionOption

MarkDeploying calls .Status.MarkDeploying on the Revision.

func MarkInactive

func MarkInactive(reason, message string) RevisionOption

MarkInactive calls .Status.MarkInactive on the Revision.

func MarkResourceNotOwned

func MarkResourceNotOwned(kind, name string) RevisionOption

MarkResourceNotOwned calls the function of the same name on the Revision's status.

func WithBuildRef

func WithBuildRef(name string) RevisionOption

WithBuildRef sets the .Spec.BuildRef on the Revision to match what we'd get using WithBuild(name).

func WithCreationTimestamp

func WithCreationTimestamp(t time.Time) RevisionOption

WithCreationTimestamp sets the Revision's timestamp to the provided time. TODO(mattmoor): Ideally this could be a more generic Option and use meta.Accessor, but unfortunately Go's type system cannot support that.

func WithFailedBuild

func WithFailedBuild(reason, message string) RevisionOption

WithFailedBuild propagates the status of a failed Build to the Revision's status.

func WithLastPinned

func WithLastPinned(t time.Time) RevisionOption

WithLastPinned updates the "last pinned" annotation to the provided timestamp.

func WithRevConcurrencyModel

WithRevConcurrencyModel sets the concurrency model on the Revision.

func WithRevName

func WithRevName(name string) RevisionOption

WithRevName sets the name of the revision

func WithRevStatus

func WithRevStatus(st v1alpha1.RevisionStatus) RevisionOption

WithRevStatus is a generic escape hatch for creating hard-to-craft status orientations.

type RouteOption

type RouteOption func(*v1alpha1.Route)

RouteOption enables further configuration of a Route.

func MarkConfigurationFailed

func MarkConfigurationFailed(name string) RouteOption

MarkConfigurationFailed calls the method of the same name on .Status

func MarkConfigurationNotReady

func MarkConfigurationNotReady(name string) RouteOption

MarkConfigurationNotReady calls the method of the same name on .Status

func MarkMissingTrafficTarget

func MarkMissingTrafficTarget(kind, revision string) RouteOption

MarkMissingTrafficTarget calls the method of the same name on .Status

func WithConfigTarget

func WithConfigTarget(config string) RouteOption

WithConfigTarget sets the Route's traffic block to point at a particular Configuration.

func WithIngressClass

func WithIngressClass(ingressClass string) RouteOption

WithIngressClass sets the ingress class annotation on the Route.

func WithRevTarget

func WithRevTarget(revision string) RouteOption

WithRevTarget sets the Route's traffic block to point at a particular Revision.

func WithRouteLabel

func WithRouteLabel(key, value string) RouteOption

WithRouteLabel sets the specified label on the Route.

func WithRouteUID

func WithRouteUID(uid types.UID) RouteOption

WithRouteUID sets the Route's UID

func WithSpecTraffic

func WithSpecTraffic(traffic ...v1alpha1.TrafficTarget) RouteOption

WithSpecTraffic sets the Route's traffic block to the specified traffic targets.

func WithStatusTraffic

func WithStatusTraffic(traffic ...v1alpha1.TrafficTarget) RouteOption

WithStatusTraffic sets the Route's status traffic block to the specified traffic targets.

type ServiceOption

type ServiceOption func(*v1alpha1.Service)

ServiceOption enables further configuration of a Service.

func WithConfigAnnotations

func WithConfigAnnotations(annotations map[string]string) ServiceOption

WithConfigAnnotations assigns config annotations to a service

func WithFailedConfig

func WithFailedConfig(name, reason, message string) ServiceOption

WithFailedConfig reflects the Configuration's failure in the Service resource. The failing revision's name is reflected in LatestCreated.

func WithFailedRoute

func WithFailedRoute(reason, message string) ServiceOption

WithFailedRoute reflects a Route's failure in the Service resource.

func WithPinnedRollout

func WithPinnedRollout(name string) ServiceOption

WithPinnedRollout configures the Service to use a "pinned" rollout, which is pinned to the named revision. Deprecated, since PinnedType is deprecated.

func WithPinnedRolloutConfigSpec

func WithPinnedRolloutConfigSpec(name string, config v1alpha1.ConfigurationSpec) ServiceOption

WithPinnedRolloutConfigSpec WithPinnedRollout2

func WithReadyConfig

func WithReadyConfig(name string) ServiceOption

WithReadyConfig reflects the Configuration's readiness in the Service resource. This must coincide with the setting of Latest{Created,Ready} to the provided revision name.

func WithReleaseRollout

func WithReleaseRollout(names ...string) ServiceOption

WithReleaseRollout configures the Service to use a "release" rollout, which spans the provided revisions.

func WithReleaseRolloutAndPercentage

func WithReleaseRolloutAndPercentage(percentage int, names ...string) ServiceOption

WithReleaseRolloutAndPercentage configures the Service to use a "release" rollout, which spans the provided revisions.

func WithReleaseRolloutAndPercentageConfigSpec

func WithReleaseRolloutAndPercentageConfigSpec(percentage int, config v1alpha1.ConfigurationSpec, names ...string) ServiceOption

WithReleaseRolloutAndPercentageConfigSpec configures the Service to use a "release" rollout, which spans the provided revisions.

func WithReleaseRolloutConfigSpec

func WithReleaseRolloutConfigSpec(config v1alpha1.ConfigurationSpec, names ...string) ServiceOption

WithReleaseRolloutConfigSpec configures the Service to use a "release" rollout, which spans the provided revisions.

func WithResourceRequirements

func WithResourceRequirements(resourceRequirements corev1.ResourceRequirements) ServiceOption

WithResourceRequirements attaches resource requirements to the service

func WithRevisionTimeoutSeconds

func WithRevisionTimeoutSeconds(revisionTimeoutSeconds int64) ServiceOption

WithRevisionTimeoutSeconds sets revision timeout

func WithRunLatestConfigSpec

func WithRunLatestConfigSpec(config v1alpha1.ConfigurationSpec) ServiceOption

WithRunLatestConfigSpec confgures the Service to use a "runLastest" configuration

func WithServiceLabel

func WithServiceLabel(key, value string) ServiceOption

WithServiceLabel attaches a particular label to the service.

func WithServiceLatestReadyRevision

func WithServiceLatestReadyRevision(lrr string) ServiceOption

WithServiceLatestReadyRevision sets the latest ready revision on the Service's status.

func WithSvcStatusTraffic

func WithSvcStatusTraffic(targets ...v1alpha1.TrafficTarget) ServiceOption

WithSvcStatusTraffic sets the Service's status traffic block to the specified traffic targets.

func WithVolume

func WithVolume(name, mountPath string, volumeSource corev1.VolumeSource) ServiceOption

WithVolume adds a volume to the service

type TableRow

type TableRow = testing.TableRow

type TableTest

type TableTest = testing.TableTest

Jump to

Keyboard shortcuts

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