const EndpointHTTPPort … const EndpointUDPPort … const EndpointSCTPPort … const testContainerHTTPPort … const ClusterHTTPPort … const ClusterUDPPort … const ClusterSCTPPort … const testPodName … const hostTestPodName … const nodePortServiceName … const sessionAffinityServiceName … const hitEndpointRetryDelay … const testTries … const maxNetProxyPodsCount … const SessionAffinityChecks … const RegexIPv4 … const RegexIPv6 … const resizeNodeReadyTimeout … const resizeNodeNotReadyTimeout … const echoHostname … type Option … // EnableSCTP listen on SCTP ports on the endpoints func EnableSCTP(config *NetworkingTestConfig) { … } // EnableDualStack create Dual Stack services func EnableDualStack(config *NetworkingTestConfig) { … } // UseHostNetwork run the test container with HostNetwork=true. func UseHostNetwork(config *NetworkingTestConfig) { … } // EndpointsUseHostNetwork run the endpoints pods with HostNetwork=true. func EndpointsUseHostNetwork(config *NetworkingTestConfig) { … } // PreferExternalAddresses prefer node External Addresses for the tests func PreferExternalAddresses(config *NetworkingTestConfig) { … } // NewNetworkingTestConfig creates and sets up a new test config helper. func NewNetworkingTestConfig(ctx context.Context, f *framework.Framework, setters ...Option) *NetworkingTestConfig { … } // NewCoreNetworkingTestConfig creates and sets up a new test config helper for Node E2E. func NewCoreNetworkingTestConfig(ctx context.Context, f *framework.Framework, hostNetwork bool) *NetworkingTestConfig { … } func getServiceSelector() map[string]string { … } type NetworkingTestConfig … type NetexecDialResponse … // DialFromEndpointContainer executes a curl via kubectl exec in an endpoint container. Returns an error to be handled by the caller. func (config *NetworkingTestConfig) DialFromEndpointContainer(ctx context.Context, protocol, targetIP string, targetPort, maxTries, minTries int, expectedEps sets.String) error { … } // DialFromTestContainer executes a curl via kubectl exec in a test container. Returns an error to be handled by the caller. func (config *NetworkingTestConfig) DialFromTestContainer(ctx context.Context, protocol, targetIP string, targetPort, maxTries, minTries int, expectedEps sets.String) error { … } // DialEchoFromTestContainer executes a curl via kubectl exec in a test container. The response is expected to match the echoMessage, Returns an error to be handled by the caller. func (config *NetworkingTestConfig) DialEchoFromTestContainer(ctx context.Context, protocol, targetIP string, targetPort, maxTries, minTries int, echoMessage string) error { … } // diagnoseMissingEndpoints prints debug information about the endpoints that // are NOT in the given list of foundEndpoints. These are the endpoints we // expected a response from. func (config *NetworkingTestConfig) diagnoseMissingEndpoints(foundEndpoints sets.String) { … } // EndpointHostnames returns a set of hostnames for existing endpoints. func (config *NetworkingTestConfig) EndpointHostnames() sets.String { … } func makeCURLDialCommand(ipPort, dialCmd, protocol, targetIP string, targetPort int) string { … } // DialFromContainer executes a curl via kubectl exec in a test container, // which might then translate to a tcp or udp request based on the protocol // argument in the url. // - minTries is the minimum number of curl attempts required before declaring // success. Set to 0 if you'd like to return as soon as all endpoints respond // at least once. // - maxTries is the maximum number of curl attempts. If this many attempts pass // and we don't see all expected endpoints, the test fails. // - targetIP is the source Pod IP that will dial the given dialCommand using the given protocol. // - dialCommand is the command that the targetIP will send to the targetIP using the given protocol. // the dialCommand should be formatted properly for the protocol (http: URL path+parameters, // udp: command%20parameters, where parameters are optional) // - expectedResponses is the unordered set of responses to wait for. The responses are based on // the dialCommand; for example, for the dialCommand "hostname", the expectedResponses // should contain the hostnames reported by each pod in the service through /hostName. // // maxTries == minTries will confirm that we see the expected endpoints and no // more for maxTries. Use this if you want to eg: fail a readiness check on a // pod and confirm it doesn't show up as an endpoint. // Returns nil if no error, or error message if failed after trying maxTries. func (config *NetworkingTestConfig) DialFromContainer(ctx context.Context, protocol, dialCommand, containerIP, targetIP string, containerHTTPPort, targetPort, maxTries, minTries int, expectedResponses sets.String) error { … } // GetEndpointsFromTestContainer executes a curl via kubectl exec in a test container. func (config *NetworkingTestConfig) GetEndpointsFromTestContainer(ctx context.Context, protocol, targetIP string, targetPort, tries int) (sets.String, error) { … } // GetEndpointsFromContainer executes a curl via kubectl exec in a test container, // which might then translate to a tcp or udp request based on the protocol argument // in the url. It returns all different endpoints from multiple retries. // - tries is the number of curl attempts. If this many attempts pass and // we don't see any endpoints, the test fails. func (config *NetworkingTestConfig) GetEndpointsFromContainer(ctx context.Context, protocol, containerIP, targetIP string, containerHTTPPort, targetPort, tries int) (sets.String, error) { … } // GetResponseFromContainer executes a curl via kubectl exec in a container. func (config *NetworkingTestConfig) GetResponseFromContainer(ctx context.Context, protocol, dialCommand, containerIP, targetIP string, containerHTTPPort, targetPort int) (NetexecDialResponse, error) { … } // GetResponseFromTestContainer executes a curl via kubectl exec in a test container. func (config *NetworkingTestConfig) GetResponseFromTestContainer(ctx context.Context, protocol, dialCommand, targetIP string, targetPort int) (NetexecDialResponse, error) { … } // GetHTTPCodeFromTestContainer executes a curl via kubectl exec in a test container and returns the status code. func (config *NetworkingTestConfig) GetHTTPCodeFromTestContainer(ctx context.Context, path, targetIP string, targetPort int) (int, error) { … } // DialFromNode executes a tcp/udp curl/nc request based on protocol via kubectl exec // in a test container running with host networking. // - minTries is the minimum number of curl/nc attempts required before declaring // success. If 0, then we return as soon as all endpoints succeed. // - There is no logical change to test results if faillures happen AFTER endpoints have succeeded, // hence over-padding minTries will NOT reverse a successful result and is thus not very useful yet // (See the TODO about checking probability, which isn't implemented yet). // - maxTries is the maximum number of curl/echo attempts before an error is returned. The // smaller this number is, the less 'slack' there is for declaring success. // - if maxTries < expectedEps, this test is guaranteed to return an error, because all endpoints won't be hit. // - maxTries == minTries will return as soon as all endpoints succeed (or fail once maxTries is reached without // success on all endpoints). // In general its prudent to have a high enough level of minTries to guarantee that all pods get a fair chance at receiving traffic. func (config *NetworkingTestConfig) DialFromNode(ctx context.Context, protocol, targetIP string, targetPort, maxTries, minTries int, expectedEps sets.String) error { … } // GetSelfURL executes a curl against the given path via kubectl exec into a // test container running with host networking, and fails if the output // doesn't match the expected string. func (config *NetworkingTestConfig) GetSelfURL(ctx context.Context, port int32, path string, expected string) { … } // GetSelfURLStatusCode executes a curl against the given path via kubectl exec into a // test container running with host networking, and fails if the returned status // code doesn't match the expected string. func (config *NetworkingTestConfig) GetSelfURLStatusCode(ctx context.Context, port int32, path string, expected string) { … } func (config *NetworkingTestConfig) executeCurlCmd(ctx context.Context, cmd string, expected string) { … } func (config *NetworkingTestConfig) createNetShellPodSpec(podName, hostname string) *v1.Pod { … } func (config *NetworkingTestConfig) createTestPodSpec() *v1.Pod { … } func (config *NetworkingTestConfig) createNodePortServiceSpec(svcName string, selector map[string]string, enableSessionAffinity bool) *v1.Service { … } func (config *NetworkingTestConfig) createNodePortService(ctx context.Context, selector map[string]string) { … } func (config *NetworkingTestConfig) createSessionAffinityService(ctx context.Context, selector map[string]string) { … } // DeleteNodePortService deletes NodePort service. func (config *NetworkingTestConfig) DeleteNodePortService(ctx context.Context) { … } func (config *NetworkingTestConfig) createTestPods(ctx context.Context) { … } // CreateService creates the provided service in config.Namespace and returns created service func (config *NetworkingTestConfig) CreateService(ctx context.Context, serviceSpec *v1.Service) *v1.Service { … } // setupCore sets up the pods and core test config // mainly for simplified node e2e setup func (config *NetworkingTestConfig) setupCore(ctx context.Context, selector map[string]string) { … } // setup includes setupCore and also sets up services func (config *NetworkingTestConfig) setup(ctx context.Context, selector map[string]string) { … } func (config *NetworkingTestConfig) createNetProxyPods(ctx context.Context, podName string, selector map[string]string) []*v1.Pod { … } // DeleteNetProxyPod deletes the first endpoint pod and waits for it being removed. func (config *NetworkingTestConfig) DeleteNetProxyPod(ctx context.Context) { … } func (config *NetworkingTestConfig) createPod(ctx context.Context, pod *v1.Pod) *v1.Pod { … } func (config *NetworkingTestConfig) getPodClient() *e2epod.PodClient { … } func (config *NetworkingTestConfig) getServiceClient() coreclientset.ServiceInterface { … } type HTTPPokeParams … type HTTPPokeResult … type HTTPPokeStatus … const HTTPSuccess … const HTTPError … const HTTPTimeout … const HTTPRefused … const HTTPRetryCode … const HTTPWrongCode … const HTTPBadResponse … // PokeHTTP tries to connect to a host on a port for a given URL path. Callers // can specify additional success parameters, if desired. // // The result status will be characterized as precisely as possible, given the // known users of this. // // The result code will be zero in case of any failure to connect, or non-zero // if the HTTP transaction completed (even if the other test params make this a // failure). // // The result error will be populated for any status other than Success. // // The result body will be populated if the HTTP transaction was completed, even // if the other test params make this a failure). func PokeHTTP(host string, port int, path string, params *HTTPPokeParams) HTTPPokeResult { … } // Does an HTTP GET, but does not reuse TCP connections // This masks problems where the iptables rule has changed, but we don't see it func httpGetNoConnectionPoolTimeout(url string, timeout time.Duration) (*http.Response, error) { … } // TestUnderTemporaryNetworkFailure blocks outgoing network traffic on 'node'. Then runs testFunc and returns its status. // At the end (even in case of errors), the network traffic is brought back to normal. // This function executes commands on a node so it will work only for some // environments. func TestUnderTemporaryNetworkFailure(ctx context.Context, c clientset.Interface, ns string, node *v1.Node, testFunc func(ctx context.Context)) { … } // BlockNetwork blocks network between the given from value and the given to value. // The following helper functions can block/unblock network from source // host to destination host by manipulating iptable rules. // This function assumes it can ssh to the source host. // // Caution: // Recommend to input IP instead of hostnames. Using hostnames will cause iptables to // do a DNS lookup to resolve the name to an IP address, which will // slow down the test and cause it to fail if DNS is absent or broken. // // Suggested usage pattern: // // func foo() { // ... // defer UnblockNetwork(from, to) // BlockNetwork(from, to) // ... // } func BlockNetwork(ctx context.Context, from string, to string) { … } // UnblockNetwork unblocks network between the given from value and the given to value. func UnblockNetwork(ctx context.Context, from string, to string) { … } // WaitForService waits until the service appears (exist == true), or disappears (exist == false) func WaitForService(ctx context.Context, c clientset.Interface, namespace, name string, exist bool, interval, timeout time.Duration) error { … }