mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-22 19:31:44 +00:00
e2e test intra-pod breadth first logging and summary
gofmt
This commit is contained in:
parent
7db8a431da
commit
84f7d1e636
@ -39,8 +39,23 @@ var _ = ginkgo.Describe("[sig-network] Networking", func() {
|
||||
*/
|
||||
framework.ConformanceIt("should function for intra-pod communication: http [NodeConformance]", func() {
|
||||
config := e2enetwork.NewCoreNetworkingTestConfig(f, false)
|
||||
|
||||
// Extra debugging info since this is the most common diagnostic for failing clusters, and is a Conformance test.
|
||||
errors := []error{}
|
||||
for _, endpointPod := range config.EndpointPods {
|
||||
config.DialFromTestContainer("http", endpointPod.Status.PodIP, e2enetwork.EndpointHTTPPort, config.MaxTries, 0, sets.NewString(endpointPod.Name))
|
||||
if err := config.DialFromTestContainer("http", endpointPod.Status.PodIP, e2enetwork.EndpointHTTPPort, config.MaxTries, 0, sets.NewString(endpointPod.Name)); err != nil {
|
||||
errors = append(errors, err)
|
||||
framework.Logf("Was able to reach %v on %v ", endpointPod.Status.PodIP, endpointPod.Status.HostIP)
|
||||
} else {
|
||||
framework.Logf("Warning: Test failure (%v) will occur due to %v", len(errors)+1, err) // convenient error message for diagnosis... how many pods failed, and on what hosts?
|
||||
}
|
||||
}
|
||||
if len(errors) == 0 {
|
||||
framework.Logf("Pod polling failure summary:")
|
||||
for _, e := range errors {
|
||||
framework.Logf("%v", e)
|
||||
}
|
||||
framework.Failf("Failed due to %v errors polling %v pods", errors, len(config.EndpointPods))
|
||||
}
|
||||
})
|
||||
|
||||
|
@ -167,17 +167,17 @@ type NetexecDialResponse struct {
|
||||
}
|
||||
|
||||
// DialFromEndpointContainer executes a curl via kubectl exec in an endpoint container.
|
||||
func (config *NetworkingTestConfig) DialFromEndpointContainer(protocol, targetIP string, targetPort, maxTries, minTries int, expectedEps sets.String) {
|
||||
config.DialFromContainer(protocol, echoHostname, config.EndpointPods[0].Status.PodIP, targetIP, EndpointHTTPPort, targetPort, maxTries, minTries, expectedEps)
|
||||
func (config *NetworkingTestConfig) DialFromEndpointContainer(protocol, targetIP string, targetPort, maxTries, minTries int, expectedEps sets.String) error {
|
||||
return config.DialFromContainer(protocol, echoHostname, config.EndpointPods[0].Status.PodIP, targetIP, EndpointHTTPPort, targetPort, maxTries, minTries, expectedEps)
|
||||
}
|
||||
|
||||
// DialFromTestContainer executes a curl via kubectl exec in a test container.
|
||||
func (config *NetworkingTestConfig) DialFromTestContainer(protocol, targetIP string, targetPort, maxTries, minTries int, expectedEps sets.String) {
|
||||
config.DialFromContainer(protocol, echoHostname, config.TestContainerPod.Status.PodIP, targetIP, testContainerHTTPPort, targetPort, maxTries, minTries, expectedEps)
|
||||
func (config *NetworkingTestConfig) DialFromTestContainer(protocol, targetIP string, targetPort, maxTries, minTries int, expectedEps sets.String) error {
|
||||
return config.DialFromContainer(protocol, echoHostname, config.TestContainerPod.Status.PodIP, targetIP, testContainerHTTPPort, targetPort, maxTries, minTries, expectedEps)
|
||||
}
|
||||
|
||||
// DialEchoFromTestContainer executes a curl via kubectl exec in a test container. The response is expected to match the echoMessage.
|
||||
func (config *NetworkingTestConfig) DialEchoFromTestContainer(protocol, targetIP string, targetPort, maxTries, minTries int, echoMessage string) {
|
||||
func (config *NetworkingTestConfig) DialEchoFromTestContainer(protocol, targetIP string, targetPort, maxTries, minTries int, echoMessage string) error {
|
||||
expectedResponse := sets.NewString()
|
||||
expectedResponse.Insert(echoMessage)
|
||||
var dialCommand string
|
||||
@ -191,7 +191,7 @@ func (config *NetworkingTestConfig) DialEchoFromTestContainer(protocol, targetIP
|
||||
} else {
|
||||
dialCommand = fmt.Sprintf("echo%%20%s", echoMessage)
|
||||
}
|
||||
config.DialFromContainer(protocol, dialCommand, config.TestContainerPod.Status.PodIP, targetIP, testContainerHTTPPort, targetPort, maxTries, minTries, expectedResponse)
|
||||
return config.DialFromContainer(protocol, dialCommand, config.TestContainerPod.Status.PodIP, targetIP, testContainerHTTPPort, targetPort, maxTries, minTries, expectedResponse)
|
||||
}
|
||||
|
||||
// diagnoseMissingEndpoints prints debug information about the endpoints that
|
||||
@ -248,7 +248,9 @@ func makeCURLDialCommand(ipPort, dialCmd, protocol, targetIP string, targetPort
|
||||
// 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 (config *NetworkingTestConfig) DialFromContainer(protocol, dialCommand, containerIP, targetIP string, containerHTTPPort, targetPort, maxTries, minTries int, expectedResponses sets.String) {
|
||||
//
|
||||
// returns nil if no error, or error message if failed after trying maxTries.
|
||||
func (config *NetworkingTestConfig) DialFromContainer(protocol, dialCommand, containerIP, targetIP string, containerHTTPPort, targetPort, maxTries, minTries int, expectedResponses sets.String) error {
|
||||
ipPort := net.JoinHostPort(containerIP, strconv.Itoa(containerHTTPPort))
|
||||
cmd := makeCURLDialCommand(ipPort, dialCommand, protocol, targetIP, targetPort)
|
||||
|
||||
@ -273,7 +275,7 @@ func (config *NetworkingTestConfig) DialFromContainer(protocol, dialCommand, con
|
||||
|
||||
// Check against i+1 so we exit if minTries == maxTries.
|
||||
if (responses.Equal(expectedResponses) || responses.Len() == 0 && expectedResponses.Len() == 0) && i+1 >= minTries {
|
||||
return
|
||||
return nil
|
||||
}
|
||||
// TODO: get rid of this delay #36281
|
||||
time.Sleep(hitEndpointRetryDelay)
|
||||
@ -282,7 +284,7 @@ func (config *NetworkingTestConfig) DialFromContainer(protocol, dialCommand, con
|
||||
if dialCommand == echoHostname {
|
||||
config.diagnoseMissingEndpoints(responses)
|
||||
}
|
||||
framework.Failf("Failed to find expected responses:\nTries %d\nCommand %v\nretrieved %v\nexpected %v\n", maxTries, cmd, responses, expectedResponses)
|
||||
return fmt.Errorf("Did not find expected responses... \nTries %d\nCommand %v\nretrieved %v\nexpected %v\n", maxTries, cmd, responses, expectedResponses)
|
||||
}
|
||||
|
||||
// GetEndpointsFromTestContainer executes a curl via kubectl exec in a test container.
|
||||
|
Loading…
Reference in New Issue
Block a user