mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-11-04 04:08:16 +00:00 
			
		
		
		
	Merge pull request #98797 from sxllwx/fix/issue98606
(integration) adjust the test's client-side detection of a successful timeout case to include the connection reset
This commit is contained in:
		@@ -80,7 +80,7 @@ func testWebhookTimeout(t *testing.T, watchCache bool) {
 | 
				
			|||||||
		validatingWebhooks []testWebhook
 | 
							validatingWebhooks []testWebhook
 | 
				
			||||||
		expectInvocations  []invocation
 | 
							expectInvocations  []invocation
 | 
				
			||||||
		expectError        bool
 | 
							expectError        bool
 | 
				
			||||||
		errorContains      string
 | 
							errorContainsAnyOf []string
 | 
				
			||||||
	}{
 | 
						}{
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			name:           "minimum of request timeout or webhook timeout propagated",
 | 
								name:           "minimum of request timeout or webhook timeout propagated",
 | 
				
			||||||
@@ -133,8 +133,13 @@ func testWebhookTimeout(t *testing.T, watchCache bool) {
 | 
				
			|||||||
			expectInvocations: []invocation{
 | 
								expectInvocations: []invocation{
 | 
				
			||||||
				{path: "/mutating/1/5s", timeoutSeconds: 3}, // from request
 | 
									{path: "/mutating/1/5s", timeoutSeconds: 3}, // from request
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
			expectError:   true,
 | 
								expectError: true,
 | 
				
			||||||
			errorContains: "the server was unable to return a response in the time allotted",
 | 
								errorContainsAnyOf: []string{
 | 
				
			||||||
 | 
									// refer to https://github.com/kubernetes/kubernetes/issues/98606#issuecomment-774832633
 | 
				
			||||||
 | 
									// for the reason for triggering this scenario
 | 
				
			||||||
 | 
									"stream error",
 | 
				
			||||||
 | 
									"the server was unable to return a response in the time allotted",
 | 
				
			||||||
 | 
								},
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -305,11 +310,19 @@ func testWebhookTimeout(t *testing.T, watchCache bool) {
 | 
				
			|||||||
				if err == nil {
 | 
									if err == nil {
 | 
				
			||||||
					t.Fatalf("expected error but got none")
 | 
										t.Fatalf("expected error but got none")
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
				if tt.errorContains != "" {
 | 
					
 | 
				
			||||||
					if !strings.Contains(err.Error(), tt.errorContains) {
 | 
									expected := false
 | 
				
			||||||
						t.Errorf("expected an error saying %q, but got: %v", tt.errorContains, err)
 | 
									if len(tt.errorContainsAnyOf) != 0 {
 | 
				
			||||||
 | 
										for _, errStr := range tt.errorContainsAnyOf {
 | 
				
			||||||
 | 
											if strings.Contains(err.Error(), errStr) {
 | 
				
			||||||
 | 
												expected = true
 | 
				
			||||||
 | 
												break
 | 
				
			||||||
 | 
											}
 | 
				
			||||||
					}
 | 
										}
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
 | 
									if !expected {
 | 
				
			||||||
 | 
										t.Errorf("expected the error to be any of %q, but got: %v", tt.errorContainsAnyOf, err)
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
				return
 | 
									return
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user