MCPcopy
hub / github.com/kubernetes/node-problem-detector / TestTimeoutDialer

Function TestTimeoutDialer

test/e2e/lib/ssh/lib_test.go:333–357  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

331}
332
333func TestTimeoutDialer(t *testing.T) {
334 listener, err := net.Listen("tcp", "127.0.0.1:0")
335 if err != nil {
336 t.Errorf("unexpected error: %v", err)
337 t.FailNow()
338 }
339
340 testCases := []struct {
341 timeout time.Duration
342 expectedErrString string
343 }{
344 // delay > timeout should cause ssh.Dial to timeout.
345 {1, "i/o timeout"},
346 }
347 for _, tc := range testCases {
348 dialer := &timeoutDialer{&realSSHDialer{}, tc.timeout}
349 _, err := dialer.Dial("tcp", listener.Addr().String(), &ssh.ClientConfig{})
350 if len(tc.expectedErrString) == 0 && err != nil ||
351 !strings.Contains(fmt.Sprint(err), tc.expectedErrString) {
352 t.Errorf("Expected error to contain %q; got %v", tc.expectedErrString, err)
353 }
354 }
355
356 listener.Close()
357}
358
359func newSSHTunnelFromBytes(user string, privateKey []byte, host string) (*sshTunnel, error) {
360 signer, err := MakePrivateKeySignerFromBytes(privateKey)

Callers

nothing calls this directly

Calls 3

DialMethod · 0.95
StringMethod · 0.65
CloseMethod · 0.65

Tested by

no test coverage detected