Documentation ¶
Index ¶
- Constants
- Variables
- func AllRouteTrafficAtRevision(names ResourceNames) func(r *v1alpha1.Route) (bool, error)
- func AssertProberDefault(t *testing.T, p Prober)
- func BlueGreenRoute(namespace string, names, blue, green ResourceNames) *v1alpha1.Route
- func CheckConfigurationState(client *ServingClients, name string, ...) error
- func CheckRevisionState(client *ServingClients, name string, ...) error
- func CheckRouteState(client *ServingClients, name string, ...) error
- func CheckSLO(slo float64, name string, p Prober) error
- func CheckServiceState(client *ServingClients, name string, ...) error
- func CleanupOnInterrupt(cleanup func())
- func Configuration(namespace string, names ResourceNames, options *Options, ...) *v1alpha1.Configuration
- func ConfigurationHasCreatedRevision(c *v1alpha1.Configuration) (bool, error)
- func ConfigurationSpec(imagePath string, options *Options) *v1alpha1.ConfigurationSpec
- func ConfigurationWithBuild(namespace string, names ResourceNames, build *v1alpha1.RawExtension) *v1alpha1.Configuration
- func CreateBlueGreenRoute(t *testing.T, clients *Clients, names, blue, green ResourceNames) error
- func CreateConfiguration(t *testing.T, clients *Clients, names ResourceNames, options *Options, ...) (*v1alpha1.Configuration, error)
- func CreateLatestService(t *testing.T, clients *Clients, names ResourceNames, options *Options, ...) (*v1alpha1.Service, error)
- func CreateReleaseService(t *testing.T, clients *Clients, names ResourceNames, options *Options, ...) (*v1alpha1.Service, error)
- func CreateRoute(t *testing.T, clients *Clients, names ResourceNames, ...) (*v1alpha1.Route, error)
- func DeploymentScaledToZeroFunc(d *apiv1beta1.Deployment) (bool, error)
- func GetConfigMap(client *pkgTest.KubeClient) k8styped.ConfigMapInterface
- func ImagePath(name string) string
- func IsConfigRevisionCreationFailed(c *v1alpha1.Configuration) (bool, error)
- func IsRevisionAtExpectedGeneration(expectedGeneration string) func(r *v1alpha1.Revision) (bool, error)
- func IsRevisionBuildFailed(r *v1alpha1.Revision) (bool, error)
- func IsRevisionReady(r *v1alpha1.Revision) (bool, error)
- func IsRouteReady(r *v1alpha1.Route) (bool, error)
- func IsServiceReady(s *v1alpha1.Service) (bool, error)
- func LatestService(namespace string, names ResourceNames, options *Options, ...) *v1alpha1.Service
- func ListenAndServeGracefully(addr string, handler func(w http.ResponseWriter, r *http.Request))
- func ListenAndServeGracefullyWithPattern(addr string, handlers map[string]func(w http.ResponseWriter, r *http.Request))
- func LogResourceObject(t *testing.T, value ResourceObjects)
- func ManualService(svc *v1alpha1.Service) *v1alpha1.Service
- func ObjectNameForTest(t *testing.T) string
- func PatchConfigImage(clients *Clients, cfg *v1alpha1.Configuration, imagePath string) (*v1alpha1.Configuration, error)
- func PatchManualService(t *testing.T, clients *Clients, svc *v1alpha1.Service) (*v1alpha1.Service, error)
- func PatchReleaseService(t *testing.T, clients *Clients, svc *v1alpha1.Service, revisions []string, ...) (*v1alpha1.Service, error)
- func PatchService(t *testing.T, clients *Clients, curSvc *v1alpha1.Service, ...) (*v1alpha1.Service, error)
- func PatchServiceImage(t *testing.T, clients *Clients, svc *v1alpha1.Service, imagePath string) (*v1alpha1.Service, error)
- func PatchServiceRevisionTemplateMetadata(t *testing.T, clients *Clients, svc *v1alpha1.Service, ...) (*v1alpha1.Service, error)
- func ReleaseLatestService(namespace string, names ResourceNames, options *Options, ...) *v1alpha1.Service
- func ReleaseService(svc *v1alpha1.Service, revisions []string, rolloutPercent int) *v1alpha1.Service
- func Route(namespace string, names ResourceNames, fopt ...v1alpha1testing.RouteOption) *v1alpha1.Route
- func SubServiceNameForTest(t *testing.T, subsvc string) string
- func TODO_RouteTrafficToRevisionWithInClusterDNS(r *v1alpha1.Route) (bool, error)
- func TODO_ServiceTrafficToRevisionWithInClusterDNS(s *v1alpha1.Service) (bool, error)
- func TearDown(clients *Clients, names ResourceNames)
- func UpdateBlueGreenRoute(t *testing.T, clients *Clients, names, blue, green ResourceNames) (*v1alpha1.Route, error)
- func WaitForConfigLatestRevision(clients *Clients, names ResourceNames) (string, error)
- func WaitForConfigurationState(client *ServingClients, name string, ...) error
- func WaitForRevisionState(client *ServingClients, name string, ...) error
- func WaitForRouteState(client *ServingClients, name string, ...) error
- func WaitForServiceLatestRevision(clients *Clients, names ResourceNames) (string, error)
- func WaitForServiceState(client *ServingClients, name string, ...) error
- type BuildClient
- type Clients
- type Options
- type PipelineClient
- type Prober
- type ProberManager
- type ResourceNames
- type ResourceObjects
- func CreateReleaseServiceWithLatest(t *testing.T, clients *Clients, names *ResourceNames, options *Options) (*ResourceObjects, error)
- func CreateRunLatestServiceReady(t *testing.T, clients *Clients, names *ResourceNames, options *Options, ...) (*ResourceObjects, error)
- func GetResourceObjects(clients *Clients, names ResourceNames) (*ResourceObjects, error)
- type ServingClients
- type ServingEnvironmentFlags
Constants ¶
const EnvImageEnvVarsPath = "/envvars"
EnvImageEnvVarsPath path exposed by environment test-image to fetch environment variables.
const EnvImageFilePathInfoPath = "/filepath"
EnvImageFilePathInfoPath path exposed by environment test-image to fetch information for filepaths
const EnvImageFilePathQueryParam = "path"
EnvImageFilePathQueryParam query param to be used with EnvImageFilePathInfoPath to specify filepath
const EnvImageServerPort = 8080
EnvImageServerPort is the port on which the environment test-image server starts. TODO: Modify this port number after https://github.com/knative/serving/issues/2258 is fixed for a stricter verification.
const (
HelloVolumePath = "/hello/world"
)
const (
// ServingNamespace is the default namespace for serving e2e tests
ServingNamespace = "serving-tests"
)
Variables ¶
var AppendRandomString = helpers.AppendRandomString
AppendRandomString will generate a random string that begins with prefix. This is useful if you want to make sure that your tests can run at the same time against the same environment without conflicting. This method will seed rand with the current time when called for the first time.
var ServingFlags = initializeServingFlags()
ServingFlags holds the flags or defaults for knative/serving settings in the user's environment.
Functions ¶
func AllRouteTrafficAtRevision ¶
func AllRouteTrafficAtRevision(names ResourceNames) func(r *v1alpha1.Route) (bool, error)
AllRouteTrafficAtRevision will check the revision that route r is routing traffic to and return true if 100% of the traffic is routing to revisionName.
func AssertProberDefault ¶
AssertProberDefault is a helper for stopping the Prober and checking its SLI against the default SLO, which requires perfect responses. This takes `testing.T` so that it may be used in `defer`.
func BlueGreenRoute ¶
func BlueGreenRoute(namespace string, names, blue, green ResourceNames) *v1alpha1.Route
BlueGreenRoute returns a Route object in namespace using the route and configuration names in names. Traffic is split evenly between blue and green.
func CheckConfigurationState ¶
func CheckConfigurationState(client *ServingClients, name string, inState func(r *v1alpha1.Configuration) (bool, error)) error
CheckConfigurationState verifies the status of the Configuration called name from client is in a particular state by calling `inState` and expecting `true`. This is the non-polling variety of WaitForConfigurationState
func CheckRevisionState ¶
func CheckRevisionState(client *ServingClients, name string, inState func(r *v1alpha1.Revision) (bool, error)) error
CheckRevisionState verifies the status of the Revision called name from client is in a particular state by calling `inState` and expecting `true`. This is the non-polling variety of WaitForRevisionState
func CheckRouteState ¶
func CheckRouteState(client *ServingClients, name string, inState func(r *v1alpha1.Route) (bool, error)) error
CheckRouteState verifies the status of the Route called name from client is in a particular state by calling `inState` and expecting `true`. This is the non-polling variety of WaitForRouteState
func CheckServiceState ¶
func CheckServiceState(client *ServingClients, name string, inState func(s *v1alpha1.Service) (bool, error)) error
CheckServiceState verifies the status of the Service called name from client is in a particular state by calling `inState` and expecting `true`. This is the non-polling variety of WaitForServiceState.
func CleanupOnInterrupt ¶
func CleanupOnInterrupt(cleanup func())
CleanupOnInterrupt will execute the function cleanup if an interrupt signal is caught
func Configuration ¶
func Configuration(namespace string, names ResourceNames, options *Options, fopt ...v1alpha1testing.ConfigOption) *v1alpha1.Configuration
Configuration returns a Configuration object in namespace with the name names.Config that uses the image specified by names.Image
func ConfigurationHasCreatedRevision ¶
func ConfigurationHasCreatedRevision(c *v1alpha1.Configuration) (bool, error)
ConfigurationHasCreatedRevision returns whether the Configuration has created a Revision.
func ConfigurationSpec ¶
func ConfigurationSpec(imagePath string, options *Options) *v1alpha1.ConfigurationSpec
ConfigurationSpec returns the spec of a configuration to be used throughout different CRD helpers.
func ConfigurationWithBuild ¶
func ConfigurationWithBuild(namespace string, names ResourceNames, build *v1alpha1.RawExtension) *v1alpha1.Configuration
ConfigurationWithBuild returns a Configuration object in the `namespace` with the name `names.Config` that uses the provided Build spec `build` and image specified by `names.Image`.
func CreateBlueGreenRoute ¶
func CreateBlueGreenRoute(t *testing.T, clients *Clients, names, blue, green ResourceNames) error
CreateBlueGreenRoute creates a route in the given namespace using the route name in names. Traffic is evenly split between the two routes specified by blue and green.
func CreateConfiguration ¶
func CreateConfiguration(t *testing.T, clients *Clients, names ResourceNames, options *Options, fopt ...rtesting.ConfigOption) (*v1alpha1.Configuration, error)
CreateConfiguration create a configuration resource in namespace with the name names.Config that uses the image specified by names.Image.
func CreateLatestService ¶
func CreateLatestService(t *testing.T, clients *Clients, names ResourceNames, options *Options, fopt ...rtesting.ServiceOption) (*v1alpha1.Service, error)
CreateLatestService creates a service in namespace with the name names.Service and names.Image
func CreateReleaseService ¶
func CreateReleaseService(t *testing.T, clients *Clients, names ResourceNames, options *Options, fopt ...rtesting.ServiceOption) (*v1alpha1.Service, error)
CreateReleaseService creates a service in namespace with the name names.Service and names.Image, configured with `@latest` revision.
func CreateRoute ¶
func CreateRoute(t *testing.T, clients *Clients, names ResourceNames, fopt ...rtesting.RouteOption) (*v1alpha1.Route, error)
CreateRoute creates a route in the given namespace using the route name in names
func DeploymentScaledToZeroFunc ¶
func DeploymentScaledToZeroFunc(d *apiv1beta1.Deployment) (bool, error)
DeploymentScaledToZeroFunc returns a func that evaluates if a deployment has scaled to 0 pods.
func GetConfigMap ¶
func GetConfigMap(client *pkgTest.KubeClient) k8styped.ConfigMapInterface
GetConfigMap gets the knative serving config map.
func IsConfigRevisionCreationFailed ¶
func IsConfigRevisionCreationFailed(c *v1alpha1.Configuration) (bool, error)
IsConfigRevisionCreationFailed will check the status conditions of the configuration and return true if the configuration's revision failed to create.
func IsRevisionAtExpectedGeneration ¶
func IsRevisionAtExpectedGeneration(expectedGeneration string) func(r *v1alpha1.Revision) (bool, error)
IsRevisionAtExpectedGeneration returns a function that will check if the annotations on the revision include an annotation for the generation and that the annotation is set to the expected value.
func IsRevisionBuildFailed ¶
IsRevisionBuildFailed will check the status conditions of the revision and return true if the revision's build failed.
func IsRevisionReady ¶
IsRevisionReady will check the status conditions of the revision and return true if the revision is ready to serve traffic. It will return false if the status indicates a state other than deploying or being ready. It will also return false if the type of the condition is unexpected.
func IsRouteReady ¶
IsRouteReady will check the status conditions of the route and return true if the route is ready.
func IsServiceReady ¶
IsServiceReady will check the status conditions of the service and return true if the service is ready. This means that its configurations and routes have all reported ready.
func LatestService ¶
func LatestService(namespace string, names ResourceNames, options *Options, fopt ...v1alpha1testing.ServiceOption) *v1alpha1.Service
LatestService returns a RunLatest Service object in namespace with the name names.Service that uses the image specified by names.Image.
func ListenAndServeGracefully ¶
func ListenAndServeGracefully(addr string, handler func(w http.ResponseWriter, r *http.Request))
ListenAndServeGracefully calls into ListenAndServeGracefullyWithPattern by passing handler to handle requests for "/"
func ListenAndServeGracefullyWithPattern ¶
func ListenAndServeGracefullyWithPattern(addr string, handlers map[string]func(w http.ResponseWriter, r *http.Request))
ListenAndServeGracefullyWithPattern creates an HTTP server, listens on the defined address and handles incoming requests specified on pattern(path) with the given handlers. It blocks until SIGTERM is received and the underlying server has shutdown gracefully.
func LogResourceObject ¶
func LogResourceObject(t *testing.T, value ResourceObjects)
LogResourceObject logs the resource object with the resource name and value
func ManualService ¶
ManualService returns a Manual Service object in namespace with the name names.Service
func ObjectNameForTest ¶
ObjectNameForTest generates a random object name based on the test name.
func PatchConfigImage ¶
func PatchConfigImage(clients *Clients, cfg *v1alpha1.Configuration, imagePath string) (*v1alpha1.Configuration, error)
PatchConfigImage patches the existing config passed in with a new imagePath. Returns the latest Configuration object
func PatchManualService ¶
func PatchManualService(t *testing.T, clients *Clients, svc *v1alpha1.Service) (*v1alpha1.Service, error)
PatchManualService patches an existing service in namespace with the name names.Service
func PatchReleaseService ¶
func PatchReleaseService(t *testing.T, clients *Clients, svc *v1alpha1.Service, revisions []string, rolloutPercent int) (*v1alpha1.Service, error)
PatchReleaseService patches an existing service in namespace with the name names.Service
func PatchService ¶
func PatchService(t *testing.T, clients *Clients, curSvc *v1alpha1.Service, desiredSvc *v1alpha1.Service) (*v1alpha1.Service, error)
PatchService creates and applies a patch from the diff between curSvc and desiredSvc. Returns the latest service object.
func PatchServiceImage ¶
func PatchServiceImage(t *testing.T, clients *Clients, svc *v1alpha1.Service, imagePath string) (*v1alpha1.Service, error)
PatchServiceImage patches the existing service passed in with a new imagePath. Returns the latest service object
func PatchServiceRevisionTemplateMetadata ¶
func PatchServiceRevisionTemplateMetadata(t *testing.T, clients *Clients, svc *v1alpha1.Service, metadata metav1.ObjectMeta) (*v1alpha1.Service, error)
PatchServiceRevisionTemplateMetadata patches an existing service by adding metadata to the service's RevisionTemplateSpec.
func ReleaseLatestService ¶
func ReleaseLatestService(namespace string, names ResourceNames, options *Options, fopt ...v1alpha1testing.ServiceOption) *v1alpha1.Service
ReleaseLatestService returns a Release Service object in namespace with the name names.Service that uses the image specified by names.Image and `@latest` as the only revision.
func ReleaseService ¶
func ReleaseService(svc *v1alpha1.Service, revisions []string, rolloutPercent int) *v1alpha1.Service
ReleaseService returns a Release Service object in namespace with the name names.Service that uses the image specified by names.Image. It also takes a list of 1-2 revisons and a rolloutPercent to be used to configure routing
func Route ¶
func Route(namespace string, names ResourceNames, fopt ...v1alpha1testing.RouteOption) *v1alpha1.Route
Route returns a Route object in namespace using the route and configuration names in names.
func SubServiceNameForTest ¶
SubServiceNameForTest generates a random service name based on the test name and the given subservice name.
func TODO_RouteTrafficToRevisionWithInClusterDNS ¶
RouteTrafficToRevisionWithInClusterDNS will check the revision that route r is routing traffic using in cluster DNS and return true if the revision received the request.
func TODO_ServiceTrafficToRevisionWithInClusterDNS ¶
ServiceTrafficToRevisionWithInClusterDNS will check the revision that route r is routing traffic using in cluster DNS and return true if the revision received the request.
func TearDown ¶
func TearDown(clients *Clients, names ResourceNames)
TearDown will delete created names using clients.
func UpdateBlueGreenRoute ¶
func UpdateBlueGreenRoute(t *testing.T, clients *Clients, names, blue, green ResourceNames) (*v1alpha1.Route, error)
UpdateRoute updates a route in the given namespace using the route name in names
func WaitForConfigLatestRevision ¶
func WaitForConfigLatestRevision(clients *Clients, names ResourceNames) (string, error)
WaitForConfigLatestRevision takes a revision in through names and compares it to the current state of LatestCreatedRevisionName in Configuration. Once an update is detected in the LatestCreatedRevisionName, the function waits for the created revision to be set in LatestReadyRevisionName before returning the name of the revision.
func WaitForConfigurationState ¶
func WaitForConfigurationState(client *ServingClients, name string, inState func(c *v1alpha1.Configuration) (bool, error), desc string) error
WaitForConfigurationState polls the status of the Configuration called name from client every interval until inState returns `true` indicating it is done, returns an error or timeout. desc will be used to name the metric that is emitted to track how long it took for name to get into the state checked by inState.
func WaitForRevisionState ¶
func WaitForRevisionState(client *ServingClients, name string, inState func(r *v1alpha1.Revision) (bool, error), desc string) error
WaitForRevisionState polls the status of the Revision called name from client every `interval` until `inState` returns `true` indicating it is done, returns an error or timeout. desc will be used to name the metric that is emitted to track how long it took for name to get into the state checked by inState.
func WaitForRouteState ¶
func WaitForRouteState(client *ServingClients, name string, inState func(r *v1alpha1.Route) (bool, error), desc string) error
WaitForRouteState polls the status of the Route called name from client every interval until inState returns `true` indicating it is done, returns an error or timeout. desc will be used to name the metric that is emitted to track how long it took for name to get into the state checked by inState.
func WaitForServiceLatestRevision ¶
func WaitForServiceLatestRevision(clients *Clients, names ResourceNames) (string, error)
WaitForServiceLatestRevision takes a revision in through names and compares it to the current state of LatestCreatedRevisionName in Service. Once an update is detected in the LatestCreatedRevisionName, the function waits for the created revision to be set in LatestReadyRevisionName before returning the name of the revision.
func WaitForServiceState ¶
func WaitForServiceState(client *ServingClients, name string, inState func(s *v1alpha1.Service) (bool, error), desc string) error
WaitForServiceState polls the status of the Service called name from client every `interval` until `inState` returns `true` indicating it is done, returns an error or timeout. desc will be used to name the metric that is emitted to track how long it took for name to get into the state checked by inState.
Types ¶
type BuildClient ¶
type BuildClient struct {
TestBuilds testbuildtyped.BuildInterface
}
BuildClient holds instances of interfaces for making requests to build client.
type Clients ¶
type Clients struct { KubeClient *test.KubeClient ServingClient *ServingClients BuildClient *BuildClient PipelineClient *PipelineClient Dynamic dynamic.Interface }
Clients holds instances of interfaces for making requests to Knative Serving.
func NewClients ¶
NewClients instantiates and returns several clientsets required for making request to the Knative Serving cluster specified by the combination of clusterName and configPath. Clients can make requests within namespace.
type Options ¶
type Options struct { EnvVars []corev1.EnvVar ContainerPorts []corev1.ContainerPort ContainerConcurrency int RevisionTimeoutSeconds int64 ContainerResources corev1.ResourceRequirements ReadinessProbe *corev1.Probe }
Options are test setup parameters.
type PipelineClient ¶
type PipelineClient struct { Pipeline pipelinev1alpha1.PipelineInterface Task pipelinev1alpha1.TaskInterface TaskRun pipelinev1alpha1.TaskRunInterface PipelineRun pipelinev1alpha1.PipelineRunInterface PipelineResource pipelinev1alpha1.PipelineResourceInterface }
PipelineClient holds instances of interfaces for making requests to pipeline client.
type Prober ¶
type Prober interface { // SLI returns the "service level indicator" for the prober, which is the observed // success rate of the probes. This will panic if the prober has not been stopped. SLI() (total int64, failures int64) // Stop terminates the prober, returning any observed errors. // Implementations may choose to put additional requirements on // the prober, which may cause this to block (e.g. a minimum number // of probes to achieve a population suitable for SLI measurement). Stop() error }
Prober is the interface for a prober, which checks the result of the probes when stopped.
type ProberManager ¶
type ProberManager interface { // The ProberManager should expose a way to collectively reason about spawned // probes as a sort of aggregating Prober. Prober // Spawn creates a new Prober Spawn(domain string) Prober // Foreach iterates over the probers spawned by this ProberManager. Foreach(func(domain string, p Prober)) }
ProberManager is the interface for spawning probers, and checking their results.
func NewProberManager ¶
func NewProberManager(t *testing.T, clients *Clients, minProbes int64) ProberManager
type ResourceNames ¶
type ResourceNames struct { Config string Route string Revision string Service string TrafficTarget string Domain string Image string }
ResourceNames holds names of various resources.
type ResourceObjects ¶
type ResourceObjects struct { Route *v1alpha1.Route Config *v1alpha1.Configuration Service *v1alpha1.Service Revision *v1alpha1.Revision }
ResourceObjects holds types of the resource objects.
func CreateReleaseServiceWithLatest ¶
func CreateReleaseServiceWithLatest( t *testing.T, clients *Clients, names *ResourceNames, options *Options) (*ResourceObjects, error)
CreateReleaseServiceWithLatest creates a `Release` service using `@latest` as the only revision. This function expects `Service` and `Image` name passed in through `names`. Names is updated with the `Route` and `Configuration` created by the Service and `ResourceObjects` is returned with the `Service`, `Route`, and `Configuration` objects. Returns an error if the service does not come up correctly.
func CreateRunLatestServiceReady ¶
func CreateRunLatestServiceReady(t *testing.T, clients *Clients, names *ResourceNames, options *Options, fopt ...rtesting.ServiceOption) (*ResourceObjects, error)
CreateRunLatestServiceReady creates a new RunLatest Service in state 'Ready'. This function expects Service and Image name passed in through 'names'. Names is updated with the Route and Configuration created by the Service and ResourceObjects is returned with the Service, Route, and Configuration objects. Returns error if the service does not come up correctly.
func GetResourceObjects ¶
func GetResourceObjects(clients *Clients, names ResourceNames) (*ResourceObjects, error)
GetResourceObjects obtains the services resources from the k8s API server.
type ServingClients ¶
type ServingClients struct { Routes servingtyped.RouteInterface Configs servingtyped.ConfigurationInterface Revisions servingtyped.RevisionInterface Services servingtyped.ServiceInterface }
ServingClients holds instances of interfaces for making requests to knative serving clients
type ServingEnvironmentFlags ¶
type ServingEnvironmentFlags struct { ResolvableDomain bool // Resolve Route controller's `domainSuffix` DockerRepo string // Docker repo (defaults to $DOCKER_REPO_OVERRIDE) Tag string // Test images version tag }
ServingEnvironmentFlags holds the e2e flags needed only by the serving repo.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
+k8s:deepcopy-gen=package
|
+k8s:deepcopy-gen=package |
testing/v1alpha1
+k8s:deepcopy-gen=package +groupName=testing.internal.knative.dev
|
+k8s:deepcopy-gen=package +groupName=testing.internal.knative.dev |
client
|
|
reconciler
|
|
test_images
|
|
singlethreaded
The singlethreaded program
|
The singlethreaded program |