Documentation ¶
Index ¶
- Constants
- Variables
- func TestUnderTemporaryNetworkFailure(c clientset.Interface, ns string, node *v1.Node, testFunc func())
- type HTTPPokeParams
- type HTTPPokeResult
- type HTTPPokeStatus
- type NetworkingTestConfig
- func (config *NetworkingTestConfig) DeleteNetProxyPod()
- func (config *NetworkingTestConfig) DeleteNodePortService()
- func (config *NetworkingTestConfig) DialEchoFromTestContainer(protocol, targetIP string, targetPort, maxTries, minTries int, ...)
- func (config *NetworkingTestConfig) DialFromContainer(protocol, dialCommand, containerIP, targetIP string, ...)
- func (config *NetworkingTestConfig) DialFromEndpointContainer(protocol, targetIP string, targetPort, maxTries, minTries int, ...)
- func (config *NetworkingTestConfig) DialFromNode(protocol, targetIP string, targetPort, maxTries, minTries int, ...)
- func (config *NetworkingTestConfig) DialFromTestContainer(protocol, targetIP string, targetPort, maxTries, minTries int, ...)
- func (config *NetworkingTestConfig) EndpointHostnames() sets.String
- func (config *NetworkingTestConfig) GetEndpointsFromContainer(protocol, containerIP, targetIP string, ...) (sets.String, error)
- func (config *NetworkingTestConfig) GetEndpointsFromTestContainer(protocol, targetIP string, targetPort, tries int) (sets.String, error)
- func (config *NetworkingTestConfig) GetSelfURL(port int32, path string, expected string)
- func (config *NetworkingTestConfig) GetSelfURLStatusCode(port int32, path string, expected string)
Constants ¶
const ( // EndpointHTTPPort is an endpoint HTTP port for testing. EndpointHTTPPort = 8080 // EndpointUDPPort is an endpoint UDP port for testing. EndpointUDPPort = 8081 // ClusterHTTPPort is a cluster HTTP port for testing. ClusterHTTPPort = 80 // ClusterUDPPort is a cluster UDP port for testing. ClusterUDPPort = 90 // SessionAffinityChecks is number of checks to hit a given set of endpoints when enable session affinity. SessionAffinityChecks = 10 // RegexIPv4 is a regex to match IPv4 addresses RegexIPv4 = "(?:\\d+)\\.(?:\\d+)\\.(?:\\d+)\\.(?:\\d+)" // RegexIPv6 is a regex to match IPv6 addresses RegexIPv6 = "" /* 1910-byte string literal not displayed */ )
Variables ¶
var NetexecImageName = imageutils.GetE2EImage(imageutils.Agnhost)
NetexecImageName is the image name for agnhost.
Functions ¶
func TestUnderTemporaryNetworkFailure ¶
func TestUnderTemporaryNetworkFailure(c clientset.Interface, ns string, node *v1.Node, testFunc func())
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.
Types ¶
type HTTPPokeParams ¶
type HTTPPokeParams struct { Timeout time.Duration ExpectCode int // default = 200 BodyContains string RetriableCodes []int }
HTTPPokeParams is a struct for HTTP poke parameters.
type HTTPPokeResult ¶
type HTTPPokeResult struct { Status HTTPPokeStatus Code int // HTTP code: 0 if the connection was not made Error error // if there was any error Body []byte // if code != 0 }
HTTPPokeResult is a struct for HTTP poke result.
func PokeHTTP ¶
func PokeHTTP(host string, port int, path string, params *HTTPPokeParams) HTTPPokeResult
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).
type HTTPPokeStatus ¶
type HTTPPokeStatus string
HTTPPokeStatus is string for representing HTTP poke status.
const ( // HTTPSuccess is HTTP poke status which is success. HTTPSuccess HTTPPokeStatus = "Success" // HTTPError is HTTP poke status which is error. HTTPError HTTPPokeStatus = "UnknownError" // HTTPTimeout is HTTP poke status which is timeout. HTTPTimeout HTTPPokeStatus = "TimedOut" // HTTPRefused is HTTP poke status which is connection refused. HTTPRefused HTTPPokeStatus = "ConnectionRefused" // HTTPRetryCode is HTTP poke status which is retry code. HTTPRetryCode HTTPPokeStatus = "RetryCode" // HTTPWrongCode is HTTP poke status which is wrong code. HTTPWrongCode HTTPPokeStatus = "WrongCode" // HTTPBadResponse is HTTP poke status which is bad response. HTTPBadResponse HTTPPokeStatus = "BadResponse" )
type NetworkingTestConfig ¶
type NetworkingTestConfig struct { // TestContaienrPod is a test pod running the netexec image. It is capable // of executing tcp/udp requests against ip:port. TestContainerPod *v1.Pod // HostTestContainerPod is a pod running using the hostexec image. HostTestContainerPod *v1.Pod // if the HostTestContainerPod is running with HostNetwork=true. HostNetwork bool // EndpointPods are the pods belonging to the Service created by this // test config. Each invocation of `setup` creates a service with // 1 pod per node running the netexecImage. EndpointPods []*v1.Pod // NodePortService is a Service with Type=NodePort spanning over all // endpointPods. NodePortService *v1.Service // SessionAffinityService is a Service with SessionAffinity=ClientIP // spanning over all endpointPods. SessionAffinityService *v1.Service // ExternalAddrs is a list of external IPs of nodes in the cluster. ExternalAddr string // Nodes is a list of nodes in the cluster. Nodes []v1.Node // MaxTries is the number of retries tolerated for tests run against // endpoints and services created by this config. MaxTries int // The ClusterIP of the Service reated by this test config. ClusterIP string // External ip of first node for use in nodePort testing. NodeIP string // The http/udp nodePorts of the Service. NodeHTTPPort int NodeUDPPort int // The kubernetes namespace within which all resources for this // config are created Namespace string // contains filtered or unexported fields }
NetworkingTestConfig is a convenience class around some utility methods for testing kubeproxy/networking/services/endpoints.
func NewCoreNetworkingTestConfig ¶
func NewCoreNetworkingTestConfig(f *framework.Framework, hostNetwork bool) *NetworkingTestConfig
NewCoreNetworkingTestConfig creates and sets up a new test config helper for Node E2E.
func NewNetworkingTestConfig ¶
func NewNetworkingTestConfig(f *framework.Framework, hostNetwork bool) *NetworkingTestConfig
NewNetworkingTestConfig creates and sets up a new test config helper.
func (*NetworkingTestConfig) DeleteNetProxyPod ¶
func (config *NetworkingTestConfig) DeleteNetProxyPod()
DeleteNetProxyPod deletes the first endpoint pod and waits for it being removed.
func (*NetworkingTestConfig) DeleteNodePortService ¶
func (config *NetworkingTestConfig) DeleteNodePortService()
DeleteNodePortService deletes NodePort service.
func (*NetworkingTestConfig) DialEchoFromTestContainer ¶
func (config *NetworkingTestConfig) DialEchoFromTestContainer(protocol, targetIP string, targetPort, maxTries, minTries int, echoMessage string)
DialEchoFromTestContainer executes a curl via kubectl exec in a test container. The response is expected to match the echoMessage.
func (*NetworkingTestConfig) DialFromContainer ¶
func (config *NetworkingTestConfig) DialFromContainer(protocol, dialCommand, containerIP, targetIP string, containerHTTPPort, targetPort, maxTries, minTries int, expectedResponses sets.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.
func (*NetworkingTestConfig) DialFromEndpointContainer ¶
func (config *NetworkingTestConfig) DialFromEndpointContainer(protocol, targetIP string, targetPort, maxTries, minTries int, expectedEps sets.String)
DialFromEndpointContainer executes a curl via kubectl exec in an endpoint container.
func (*NetworkingTestConfig) DialFromNode ¶
func (config *NetworkingTestConfig) DialFromNode(protocol, targetIP string, targetPort, maxTries, minTries int, expectedEps sets.String)
DialFromNode executes a tcp or udp request based on protocol via kubectl exec in a test container running with host networking.
- 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.
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.
func (*NetworkingTestConfig) DialFromTestContainer ¶
func (config *NetworkingTestConfig) DialFromTestContainer(protocol, targetIP string, targetPort, maxTries, minTries int, expectedEps sets.String)
DialFromTestContainer executes a curl via kubectl exec in a test container.
func (*NetworkingTestConfig) EndpointHostnames ¶
func (config *NetworkingTestConfig) EndpointHostnames() sets.String
EndpointHostnames returns a set of hostnames for existing endpoints.
func (*NetworkingTestConfig) GetEndpointsFromContainer ¶
func (config *NetworkingTestConfig) GetEndpointsFromContainer(protocol, containerIP, targetIP string, containerHTTPPort, 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 (*NetworkingTestConfig) GetEndpointsFromTestContainer ¶
func (config *NetworkingTestConfig) GetEndpointsFromTestContainer(protocol, targetIP string, targetPort, tries int) (sets.String, error)
GetEndpointsFromTestContainer executes a curl via kubectl exec in a test container.
func (*NetworkingTestConfig) GetSelfURL ¶
func (config *NetworkingTestConfig) GetSelfURL(port int32, path string, expected string)
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 (*NetworkingTestConfig) GetSelfURLStatusCode ¶
func (config *NetworkingTestConfig) GetSelfURLStatusCode(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.