Documentation ¶
Overview ¶
Copyright 2018 The Knative Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
util.go provides shared utilities methods across knative serving test
Index ¶
- Constants
- Variables
- func AllRouteTrafficAtRevision(names ResourceNames) func(r *v1alpha1.Route) (bool, error)
- func AppendRandomString(prefix string, logger *logging.BaseLogger) string
- 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 CheckServiceState(client *ServingClients, name string, ...) error
- func CleanupOnInterrupt(cleanup func(), logger *logging.BaseLogger)
- func Configuration(namespace string, names ResourceNames, imagePath string, options *Options) *v1alpha1.Configuration
- func ConfigurationHasCreatedRevision(c *v1alpha1.Configuration) (bool, error)
- func ConfigurationWithBuild(namespace string, names ResourceNames, build *v1alpha1.RawExtension, ...) *v1alpha1.Configuration
- func CreateBlueGreenRoute(logger *logging.BaseLogger, clients *Clients, names, blue, green ResourceNames) error
- func CreateConfiguration(logger *logging.BaseLogger, clients *Clients, names ResourceNames, ...) error
- func CreateLatestService(logger *logging.BaseLogger, clients *Clients, names ResourceNames, ...) (*v1alpha1.Service, error)
- func CreateRoute(logger *logging.BaseLogger, clients *Clients, names ResourceNames) error
- func GetConfigMap(client *pkgTest.KubeClient) k8styped.ConfigMapInterface
- func GetRouteProberError(errorChan <-chan error, logger *logging.BaseLogger) error
- 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, imagePath string) *v1alpha1.Service
- func LogResourceObject(logger *logging.BaseLogger, value ResourceObjects)
- func ManualService(svc *v1alpha1.Service) *v1alpha1.Service
- func ProbeDomain(logger *logging.BaseLogger, clients *Clients, domain string) error
- func ReleaseService(svc *v1alpha1.Service, revisions []string, rolloutPercent int) *v1alpha1.Service
- func Route(namespace string, names ResourceNames) *v1alpha1.Route
- func RunRouteProber(logger *logging.BaseLogger, clients *Clients, domain string) <-chan error
- func TODO_RouteTrafficToRevisionWithInClusterDNS(r *v1alpha1.Route) (bool, error)
- func TODO_ServiceTrafficToRevisionWithInClusterDNS(s *v1alpha1.Service) (bool, error)
- func UpdateBlueGreenRoute(logger *logging.BaseLogger, clients *Clients, names, blue, green ResourceNames) (*v1alpha1.Route, error)
- func UpdateManualService(logger *logging.BaseLogger, clients *Clients, svc *v1alpha1.Service) (*v1alpha1.Service, error)
- func UpdateReleaseService(logger *logging.BaseLogger, clients *Clients, svc *v1alpha1.Service, ...) (*v1alpha1.Service, error)
- func UpdateServiceImage(clients *Clients, svc *v1alpha1.Service, imagePath string) (*v1alpha1.Service, error)
- func UpdateServiceRevisionTemplateMetadata(logger *logging.BaseLogger, clients *Clients, svc *v1alpha1.Service, ...) (*v1alpha1.Service, error)
- func WaitForConfigurationState(client *ServingClients, name string, ...) error
- func WaitForDeploymentState(client *pkgTest.KubeClient, name string, ...) error
- func WaitForPodListState(client *pkgTest.KubeClient, inState func(p *corev1.PodList) (bool, error), ...) error
- func WaitForRevisionState(client *ServingClients, name string, ...) error
- func WaitForRouteState(client *ServingClients, name string, ...) error
- func WaitForServiceState(client *ServingClients, name string, ...) error
- type BuildClient
- type Clients
- type Options
- type ResourceNames
- type ResourceObjects
- type ServingClients
- type ServingEnvironmentFlags
Constants ¶
const (
// ServingNamespace is the default namespace for serving e2e tests
ServingNamespace = "serving-tests"
)
Variables ¶
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 AppendRandomString ¶
func AppendRandomString(prefix string, logger *logging.BaseLogger) string
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.
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(), logger *logging.BaseLogger)
CleanupOnInterrupt will execute the function cleanup if an interrupt signal is caught
func Configuration ¶
func Configuration(namespace string, names ResourceNames, imagePath string, options *Options) *v1alpha1.Configuration
Configuration returns a Configuration object in namespace with the name names.Config that uses the image specified by imagePath.
func ConfigurationHasCreatedRevision ¶ added in v0.2.0
func ConfigurationHasCreatedRevision(c *v1alpha1.Configuration) (bool, error)
ConfigurationHasCreatedRevision returns whether the Configuration has created a Revision.
func ConfigurationWithBuild ¶ added in v0.2.0
func ConfigurationWithBuild(namespace string, names ResourceNames, build *v1alpha1.RawExtension, imagePath string) *v1alpha1.Configuration
func CreateBlueGreenRoute ¶ added in v0.2.0
func CreateBlueGreenRoute(logger *logging.BaseLogger, 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 ¶ added in v0.2.0
func CreateConfiguration(logger *logging.BaseLogger, clients *Clients, names ResourceNames, imagePath string, options *Options) error
CreateConfiguration create a configuration resource in namespace with the name names.Config that uses the image specified by imagePath.
func CreateLatestService ¶ added in v0.2.0
func CreateLatestService(logger *logging.BaseLogger, clients *Clients, names ResourceNames, imagePath string) (*v1alpha1.Service, error)
CreateLatestService creates a service in namespace with the name names.Service that uses the image specified by imagePath
func CreateRoute ¶ added in v0.2.0
func CreateRoute(logger *logging.BaseLogger, clients *Clients, names ResourceNames) error
CreateRoute creates a route in the given namespace using the route name in names
func GetConfigMap ¶ added in v0.2.0
func GetConfigMap(client *pkgTest.KubeClient) k8styped.ConfigMapInterface
GetConfigMap gets the knative serving config map.
func GetRouteProberError ¶ added in v0.2.0
func GetRouteProberError(errorChan <-chan error, logger *logging.BaseLogger) error
GetRouteProberError gets the error of route prober.
func ImagePath ¶ added in v0.2.0
ImagePath is a helper function to prefix image name with repo and suffix with tag
func IsConfigRevisionCreationFailed ¶ added in v0.2.0
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 ¶ added in v0.2.0
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 ¶ added in v0.2.0
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, imagePath string) *v1alpha1.Service
LatestService returns a RunLatest Service object in namespace with the name names.Service that uses the image specified by imagePath.
func LogResourceObject ¶ added in v0.2.0
func LogResourceObject(logger *logging.BaseLogger, value ResourceObjects)
LogResourceObject logs the resource object with the resource name and value
func ManualService ¶ added in v0.2.0
ManualService returns a Manual Service object in namespace with the name names.Service
func ProbeDomain ¶ added in v0.2.0
func ProbeDomain(logger *logging.BaseLogger, clients *Clients, domain string) error
ProbeDomain sends requests to a domain until we get a successful response. This ensures the domain is routable before we send it a bunch of traffic.
func ReleaseService ¶ added in v0.2.0
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 specifeid by imagePath. 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) *v1alpha1.Route
Route returns a Route object in namespace using the route and configuration names in names.
func RunRouteProber ¶ added in v0.2.0
func RunRouteProber(logger *logging.BaseLogger, clients *Clients, domain string) <-chan error
RunRouteProber creates and runs a prober as background goroutine to keep polling Route. It stops when getting an error response from Route.
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 UpdateBlueGreenRoute ¶ added in v0.2.0
func UpdateBlueGreenRoute(logger *logging.BaseLogger, clients *Clients, names, blue, green ResourceNames) (*v1alpha1.Route, error)
UpdateRoute updates a route in the given namespace using the route name in names
func UpdateManualService ¶ added in v0.2.0
func UpdateManualService(logger *logging.BaseLogger, clients *Clients, svc *v1alpha1.Service) (*v1alpha1.Service, error)
UpdateManualService updates an existing service in namespace with the name names.Service
func UpdateReleaseService ¶ added in v0.2.0
func UpdateReleaseService(logger *logging.BaseLogger, clients *Clients, svc *v1alpha1.Service, revisions []string, rolloutPercent int) (*v1alpha1.Service, error)
UpdateReleaseService updates an existing service in namespace with the name names.Service
func UpdateServiceImage ¶ added in v0.2.0
func UpdateServiceRevisionTemplateMetadata ¶ added in v0.2.0
func UpdateServiceRevisionTemplateMetadata(logger *logging.BaseLogger, clients *Clients, svc *v1alpha1.Service, metadata metav1.ObjectMeta) (*v1alpha1.Service, error)
Updates an existing service by adding metadata to the service's RevisionTemplateSpec.
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 WaitForDeploymentState ¶
func WaitForDeploymentState(client *pkgTest.KubeClient, name string, inState func(d *apiv1beta1.Deployment) (bool, error), desc string, timeout time.Duration) error
WaitForDeploymentState polls the status of the Deployment 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 WaitForPodListState ¶
func WaitForPodListState(client *pkgTest.KubeClient, inState func(p *corev1.PodList) (bool, error), desc string) error
WaitForPodListState polls the status of the PodList 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 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 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 ¶ added in v0.2.0
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 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 ResourceNames ¶
type ResourceNames struct { Config string Route string Revision string Service string TrafficTarget string }
ResourceNames holds names of various resources.
type ResourceObjects ¶ added in v0.2.0
type ResourceObjects struct { Route *v1alpha1.Route Configuration *v1alpha1.Configuration Service *v1alpha1.Service }
ResourceObjects holds types of the resource objects.
type ServingClients ¶ added in v0.2.0
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 ¶ added in v0.2.0
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
|
|
performance
|
|
reconciler
|
|
test_images
|
|
singlethreaded
The singlethreaded program
|
The singlethreaded program |