import "k8s.io/kubernetes/test/e2e/framework/service"
const.go jig.go resource.go util.go wait.go
const ( // RespondingTimeout is how long to wait for a service to be responding. RespondingTimeout = 2 * time.Minute // MaxNodesForEndpointsTests is the max number for testing endpoints. // Don't test with more than 3 nodes. // Many tests create an endpoint per node, in large clusters, this is // resource and time intensive. MaxNodesForEndpointsTests = 3 // KubeProxyLagTimeout is the maximum time a kube-proxy daemon on a node is allowed // to not notice a Service update, such as type=NodePort. // TODO: This timeout should be O(10s), observed values are O(1m), 5m is very // liberal. Fix tracked in #20567. KubeProxyLagTimeout = 5 * time.Minute // KubeProxyEndpointLagTimeout is the maximum time a kube-proxy daemon on a node is allowed // to not notice an Endpoint update. KubeProxyEndpointLagTimeout = 30 * time.Second // LoadBalancerLagTimeoutDefault is the maximum time a load balancer is allowed to // not respond after creation. LoadBalancerLagTimeoutDefault = 2 * time.Minute // LoadBalancerLagTimeoutAWS is the delay between ELB creation and serving traffic // on AWS. A few minutes is typical, so use 10m. LoadBalancerLagTimeoutAWS = 10 * time.Minute // LoadBalancerCleanupTimeout is the time required by the loadbalancer to cleanup, proportional to numApps/Ing. // Bring the cleanup timeout back down to 5m once b/33588344 is resolved. LoadBalancerCleanupTimeout = 15 * time.Minute // LoadBalancerPollInterval is the interval value in which the loadbalancer polls. LoadBalancerPollInterval = 30 * time.Second // LargeClusterMinNodesNumber is the number of nodes which a large cluster consists of. LargeClusterMinNodesNumber = 100 // TestTimeout is used for most polling/waiting activities TestTimeout = 60 * time.Second // ServiceEndpointsTimeout is the maximum time in which endpoints for the service should be created. ServiceEndpointsTimeout = 2 * time.Minute // ServiceReachabilityShortPollTimeout is the maximum time in which service must be reachable during polling. ServiceReachabilityShortPollTimeout = 2 * time.Minute )
NodePortRange should match whatever the default/configured range is
CleanupServiceResources cleans up service Type=LoadBalancer resources.
func CreateServiceForSimpleApp(c clientset.Interface, contPort, svcPort int, namespace, appName string) *v1.Service
CreateServiceForSimpleApp returns a service that selects/exposes pods (send -1 ports if no exposure needed) with an app label.
func CreateServiceForSimpleAppWithPods(c clientset.Interface, contPort int, svcPort int, namespace, appName string, podSpec func(n v1.Node) v1.PodSpec, count int, block bool) (*v1.Service, error)
CreateServiceForSimpleAppWithPods is a convenience wrapper to create a service and its matching pods all at once.
func CreateServiceSpec(serviceName, externalName string, isHeadless bool, selector map[string]string) *v1.Service
CreateServiceSpec returns a Service object for testing.
func GetIngressPoint(ing *v1.LoadBalancerIngress) string
GetIngressPoint returns a host on which ingress serves.
GetServiceLoadBalancerCreationTimeout returns a timeout value for creating a load balancer of a service.
GetServiceLoadBalancerPropagationTimeout returns a timeout value for propagating a load balancer of a service.
func GetServicesProxyRequest(c clientset.Interface, request *restclient.Request) (*restclient.Request, error)
GetServicesProxyRequest returns a request for a service proxy.
TestReachableHTTP tests that the given host serves HTTP on the given port.
func TestReachableHTTPWithRetriableErrorCodes(host string, port int, retriableErrCodes []int, timeout time.Duration)
TestReachableHTTPWithRetriableErrorCodes tests that the given host serves HTTP on the given port with the given retriableErrCodes.
func UpdateService(c clientset.Interface, namespace, serviceName string, update func(*v1.Service)) (*v1.Service, error)
UpdateService fetches a service, calls the update function on it, and then attempts to send the updated service. It retries up to 2 times in the face of timeouts and conflicts.
WaitForServiceDeletedWithFinalizer waits for the service with finalizer to be deleted.
func WaitForServiceUpdatedWithFinalizer(cs clientset.Interface, namespace, name string, hasFinalizer bool)
WaitForServiceUpdatedWithFinalizer waits for the service to be updated to have or don't have a finalizer.
type TestJig struct { Client clientset.Interface Namespace string Name string ID string Labels map[string]string }
TestJig is a test jig to help service testing.
NewTestJig allocates and inits a new TestJig.
func (j *TestJig) AddRCAntiAffinity(rc *v1.ReplicationController)
AddRCAntiAffinity adds AntiAffinity to the given ReplicationController.
ChangeServiceNodePort changes node ports of the given service.
ChangeServiceType updates the given service's ServiceType to the given newType.
CheckServiceReachability ensures that request are served by the services. Only supports Services with type ClusterIP, NodePort and ExternalName.
CreateExternalNameService creates a new ExternalName type Service based on the j's defaults. Callers can provide a function to tweak the Service object before it is created.
func (j *TestJig) CreateLoadBalancerService(timeout time.Duration, tweak func(svc *v1.Service)) (*v1.Service, error)
CreateLoadBalancerService creates a loadbalancer service and waits for it to acquire an ingress IP.
func (j *TestJig) CreateOnlyLocalLoadBalancerService(timeout time.Duration, createPod bool, tweak func(svc *v1.Service)) (*v1.Service, error)
CreateOnlyLocalLoadBalancerService creates a loadbalancer service with ExternalTrafficPolicy set to Local and waits for it to acquire an ingress IP. If createPod is true, it also creates an RC with 1 replica of the standard netexec container used everywhere in this test.
CreateOnlyLocalNodePortService creates a NodePort service with ExternalTrafficPolicy set to Local and sanity checks its nodePort. If createPod is true, it also creates an RC with 1 replica of the standard netexec container used everywhere in this test.
func (j *TestJig) CreatePDB(rc *v1.ReplicationController) (*policyv1beta1.PodDisruptionBudget, error)
CreatePDB returns a PodDisruptionBudget for the given ReplicationController, or returns an error if a PodDisruptionBudget isn't ready
func (j *TestJig) CreateSCTPServiceWithPort(tweak func(svc *v1.Service), port int32) (*v1.Service, error)
CreateSCTPServiceWithPort creates a new SCTP Service with given port based on the j's defaults. Callers can provide a function to tweak the Service object before it is created.
CreateServicePods creates a replication controller with the label same as service. Service listens to HTTP.
CreateTCPService creates a new TCP Service based on the j's defaults. Callers can provide a function to tweak the Service object before it is created.
func (j *TestJig) CreateTCPServiceWithPort(tweak func(svc *v1.Service), port int32) (*v1.Service, error)
CreateTCPServiceWithPort creates a new TCP Service with given port based on the j's defaults. Callers can provide a function to tweak the Service object before it is created.
CreateTCPUDPServicePods creates a replication controller with the label same as service. Service listens to TCP and UDP.
CreateUDPService creates a new UDP Service based on the j's defaults. Callers can provide a function to tweak the Service object before it is created.
GetEndpointNodeNames returns a string set of node names on which the endpoints of the given Service are running.
GetEndpointNodes returns a map of nodenames:external-ip on which the endpoints of the Service are running.
func (j *TestJig) GetEndpointNodesWithIP(addressType v1.NodeAddressType) (map[string][]string, error)
GetEndpointNodesWithIP returns a map of nodenames:<ip of given type> on which the endpoints of the Service are running.
ListNodesWithEndpoint returns a list of nodes on which the endpoints of the given Service are running.
func (j *TestJig) Run(tweak func(rc *v1.ReplicationController)) (*v1.ReplicationController, error)
Run creates a ReplicationController and Pod(s) and waits for the Pod(s) to be running. Callers can provide a function to tweak the RC object before it is created.
Scale scales pods to the given replicas
UpdateService fetches a service, calls the update function on it, and then attempts to send the updated service. It tries up to 3 times in the face of timeouts and conflicts.
WaitForEndpointOnNode waits for a service endpoint on the given node.
WaitForLoadBalancer waits the given service to have a LoadBalancer, or returns an error after the given timeout
func (j *TestJig) WaitForLoadBalancerDestroy(ip string, port int, timeout time.Duration) (*v1.Service, error)
WaitForLoadBalancerDestroy waits the given service to destroy a LoadBalancer, or returns an error after the given timeout
func (j *TestJig) WaitForNewIngressIP(existingIP string, timeout time.Duration) (*v1.Service, error)
WaitForNewIngressIP waits for the given service to get a new ingress IP, or returns an error after the given timeout
Package service imports 34 packages (graph) and is imported by 251 packages. Updated 2021-01-20. Refresh now. Tools for package owners.