test: prove native reconnect recovery
This commit is contained in:
@@ -72,6 +72,36 @@ func TestRunnerOptionsRejectMissingJitter_HP_RUNTIME_02(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestRunReportsRetryableSessionError_HP_RUNTIME_04(t *testing.T) {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
store, err := spool.Open(ctx, spool.Options{DataDir: filepath.Join(t.TempDir(), "spool"), BusyTimeout: time.Second})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Cleanup(func() { _ = store.Close() })
|
||||
want := errors.New("dial refused")
|
||||
reported := make(chan error, 1)
|
||||
hello := &rvboxv1.ClientHello{ClientId: "runner-client", SupportedProtocol: &rvboxv1.ProtocolRange{Major: 1, MinMinor: 0, MaxMinor: 0}, DaemonVersion: "test", Platform: rvboxv1.Platform_PLATFORM_WINDOWS, Architecture: "amd64", DaemonCwd: `C:\\`, SupportedShells: []rvboxv1.ShellType{rvboxv1.ShellType_SHELL_POWERSHELL}, ClientInstanceId: store.ClientInstanceID().String(), MaxRunningCommands: 1, MaxQueuedCommands: 1, SentAt: timestamppb.Now()}
|
||||
err = Run(ctx, RunnerOptions{
|
||||
Store: store, Dial: func(context.Context) (Transport, error) { return nil, want }, Hello: hello,
|
||||
Limits: agentproto.DefaultLimits(), Backoff: BackoffOptions{Initial: time.Millisecond, Maximum: time.Millisecond, StableReset: time.Second},
|
||||
Jitter: func(time.Duration) time.Duration { return 0 }, Now: func() time.Time { return time.Now().UTC() },
|
||||
OnSessionError: func(got error) { reported <- got; cancel() },
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("Run error = %v, want graceful cancellation", err)
|
||||
}
|
||||
select {
|
||||
case got := <-reported:
|
||||
if !errors.Is(got, want) {
|
||||
t.Fatalf("reported error = %v, want %v", got, want)
|
||||
}
|
||||
default:
|
||||
t.Fatal("retryable session error was not reported")
|
||||
}
|
||||
}
|
||||
|
||||
func TestFlushEventsAssignsAndSendsOnlyUnacknowledgedRows_HP_RUNTIME_03(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
store, err := spool.Open(ctx, spool.Options{DataDir: filepath.Join(t.TempDir(), "spool"), BusyTimeout: time.Second})
|
||||
|
||||
Reference in New Issue
Block a user