debug e2e fail cases

This commit is contained in:
m1093782566 2017-10-27 16:45:53 +08:00
parent d945927077
commit 5210793802
2 changed files with 22 additions and 34 deletions

View File

@ -226,8 +226,8 @@ func (config *NetworkingTestConfig) GetEndpointsFromTestContainer(protocol, targ
// 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.
// - tries is the maximum number of curl attempts. If this many attempts pass and
// 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(protocol, containerIP, targetIP string, containerHttpPort, targetPort, tries int) (sets.String, error) {
cmd := fmt.Sprintf("curl -q -s 'http://%s:%d/dial?request=hostName&protocol=%s&host=%s&port=%d&tries=1'",
@ -247,7 +247,7 @@ func (config *NetworkingTestConfig) GetEndpointsFromContainer(protocol, containe
// we confirm unreachability.
Logf("Failed to execute %q: %v, stdout: %q, stderr: %q", cmd, err, stdout, stderr)
} else {
Logf("maxTries: %d, in try: %d, stdout: %v, stderr: %v", tries, i, stdout, stderr)
Logf("Tries: %d, in try: %d, stdout: %v, stderr: %v, command run in: %#v", tries, i, stdout, stderr, config.HostTestContainerPod)
var output map[string][]string
if err := json.Unmarshal([]byte(stdout), &output); err != nil {
Logf("WARNING: Failed to unmarshal curl response. Cmd %v run in %v, output: %s, err: %v",
@ -261,15 +261,11 @@ func (config *NetworkingTestConfig) GetEndpointsFromContainer(protocol, containe
eps.Insert(trimmed)
}
}
// Return immediately when we successfully fetch endpoints
if len(eps) > 0 {
return eps, nil
}
// TODO: get rid of this delay #36281
time.Sleep(hitEndpointRetryDelay)
}
}
return nil, fmt.Errorf("error getting endpoints:\nTries %d\nCommand %v\n", tries, cmd)
return eps, nil
}
// DialFromNode executes a tcp or udp request based on protocol via kubectl exec

View File

@ -201,7 +201,7 @@ var _ = SIGDescribe("Networking", func() {
config.DialFromNode("udp", config.NodeIP, config.NodeUdpPort, config.MaxTries, config.MaxTries, sets.NewString())
})
It("should function for client IP based session affinity: http", func() {
It("should function for client IP based session affinity: http [Slow]", func() {
config := framework.NewNetworkingTestConfig(f)
By(fmt.Sprintf("dialing(http) %v --> %v:%v (config.clusterIP)", config.TestContainerPod.Name, config.ClusterIP, framework.ClusterHttpPort))
updateSessionAffinity := func(svc *v1.Service) {
@ -212,24 +212,20 @@ var _ = SIGDescribe("Networking", func() {
framework.Failf("Failed to update service session affinity, error: %v", err)
}
// Fetch first endpoints when visiting service
firstEndpoints, err := config.GetEndpointsFromTestContainer("http", config.ClusterIP, framework.ClusterHttpPort, config.MaxTries)
// Check if number of endpoints returned are exactly one.
eps, err := config.GetEndpointsFromTestContainer("http", config.ClusterIP, framework.ClusterHttpPort, framework.SessionAffinityChecks)
if err != nil {
framework.Failf("Unable to get endpoints from test container: %v", err)
framework.Failf("Failed to get endpoints from test container, error: %v", err)
}
// Check if first endpoints are equal to endpoints which are fetched later
for i := 0; i < framework.SessionAffinityChecks; i++ {
eps, err := config.GetEndpointsFromTestContainer("http", config.ClusterIP, framework.ClusterHttpPort, config.MaxTries)
if err != nil {
framework.Failf("Unable to get endpoints from test container: %v", err)
}
if !eps.Equal(firstEndpoints) {
framework.Failf("Expect endpoints: %v, got: %v", firstEndpoints, eps)
}
if len(eps) == 0 {
framework.Failf("Unexpected no endpoints return")
}
if len(eps) > 1 {
framework.Failf("Unexpected endpoints return: %v, expect 1 endpoints", eps)
}
})
It("should function for client IP based session affinity: udp", func() {
It("should function for client IP based session affinity: udp [Slow]", func() {
config := framework.NewNetworkingTestConfig(f)
By(fmt.Sprintf("dialing(udp) %v --> %v:%v (config.clusterIP)", config.TestContainerPod.Name, config.ClusterIP, framework.ClusterUdpPort))
updateSessionAffinity := func(svc *v1.Service) {
@ -240,20 +236,16 @@ var _ = SIGDescribe("Networking", func() {
framework.Failf("Failed to update service session affinity, error: %v", err)
}
// Fetch first endpoints when visiting service
firstEndpoints, err := config.GetEndpointsFromTestContainer("udp", config.ClusterIP, framework.ClusterUdpPort, config.MaxTries)
// Check if number of endpoints returned are exactly one.
eps, err := config.GetEndpointsFromTestContainer("udp", config.ClusterIP, framework.ClusterUdpPort, framework.SessionAffinityChecks)
if err != nil {
framework.Failf("Unable to get endpoints from test containers: %v", err)
framework.Failf("Failed to get endpoints from test container, error: %v", err)
}
// Check if first endpoints are equal to endpoints which are fetched later
for i := 0; i < framework.SessionAffinityChecks; i++ {
eps, err := config.GetEndpointsFromTestContainer("udp", config.ClusterIP, framework.ClusterUdpPort, config.MaxTries)
if err != nil {
framework.Failf("Unable to get endpoints from test containers: %v", err)
}
if !eps.Equal(firstEndpoints) {
framework.Failf("Expect endpoints: %v, got: %v", firstEndpoints, eps)
}
if len(eps) == 0 {
framework.Failf("Unexpected no endpoints return")
}
if len(eps) > 1 {
framework.Failf("Unexpected endpoints return: %v, expect 1 endpoints", eps)
}
})
})