MCPcopy Index your code
hub / github.com/coder/coder / TestController_RetriesWrappedDeadlineExceeded

Function TestController_RetriesWrappedDeadlineExceeded

tailnet/controllers_test.go:1078–1115  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1076}
1077
1078func TestController_RetriesWrappedDeadlineExceeded(t *testing.T) {
1079 t.Parallel()
1080 testCtx := testutil.Context(t, testutil.WaitShort)
1081 ctx, cancel := context.WithCancel(testCtx)
1082 defer cancel()
1083
1084 logger := testutil.Logger(t)
1085 dialer := &scriptedDialer{
1086 attempts: make(chan int, 10),
1087 dialFn: func(ctx context.Context, attempt int) (tailnet.ControlProtocolClients, error) {
1088 if attempt == 1 {
1089 return tailnet.ControlProtocolClients{}, &net.OpError{
1090 Op: "dial",
1091 Net: "tcp",
1092 Err: context.DeadlineExceeded,
1093 }
1094 }
1095
1096 <-ctx.Done()
1097 return tailnet.ControlProtocolClients{}, ctx.Err()
1098 },
1099 }
1100
1101 uut := tailnet.NewController(logger.Named("ctrl"), dialer)
1102 uut.Run(ctx)
1103
1104 require.Equal(t, 1, testutil.TryReceive(testCtx, t, dialer.attempts))
1105 require.Equal(t, 2, testutil.TryReceive(testCtx, t, dialer.attempts))
1106
1107 select {
1108 case <-uut.Closed():
1109 t.Fatal("controller exited after wrapped deadline exceeded")
1110 default:
1111 }
1112
1113 cancel()
1114 _ = testutil.TryReceive(testCtx, t, uut.Closed())
1115}
1116
1117func TestController_DoesNotRedialAfterCancel(t *testing.T) {
1118 t.Parallel()

Callers

nothing calls this directly

Calls 11

RunMethod · 0.95
ClosedMethod · 0.95
ContextFunction · 0.92
LoggerFunction · 0.92
NewControllerFunction · 0.92
TryReceiveFunction · 0.92
ErrMethod · 0.80
NamedMethod · 0.80
FatalMethod · 0.80
DoneMethod · 0.45
EqualMethod · 0.45

Tested by

no test coverage detected