(t *testing.T)
| 319 | } |
| 320 | |
| 321 | func TestServer_ForwarderContinuesAfterError(t *testing.T) { |
| 322 | t.Parallel() |
| 323 | |
| 324 | socketPath := filepath.Join(testutil.TempDirUnixSocket(t), "boundary.sock") |
| 325 | srv := boundarylogproxy.NewServer(testutil.Logger(t), socketPath, prometheus.NewRegistry()) |
| 326 | |
| 327 | err := srv.Start() |
| 328 | require.NoError(t, err) |
| 329 | t.Cleanup(func() { require.NoError(t, srv.Close()) }) |
| 330 | |
| 331 | reportNotify := make(chan struct{}, 1) |
| 332 | reporter := &fakeReporter{ |
| 333 | // Simulate an error on the first call. |
| 334 | err: context.DeadlineExceeded, |
| 335 | errOnce: true, |
| 336 | reportCb: func() { |
| 337 | reportNotify <- struct{}{} |
| 338 | }, |
| 339 | } |
| 340 | |
| 341 | ctx, cancel := context.WithCancel(context.Background()) |
| 342 | defer cancel() |
| 343 | forwarderDone := make(chan error, 1) |
| 344 | go func() { |
| 345 | forwarderDone <- srv.RunForwarder(ctx, reporter) |
| 346 | }() |
| 347 | |
| 348 | conn, err := net.Dial("unix", socketPath) |
| 349 | require.NoError(t, err) |
| 350 | defer conn.Close() |
| 351 | |
| 352 | // Send the first message to be processed and wait for failure. |
| 353 | req1 := &agentproto.ReportBoundaryLogsRequest{ |
| 354 | Logs: []*agentproto.BoundaryLog{ |
| 355 | { |
| 356 | Allowed: true, |
| 357 | Time: timestamppb.Now(), |
| 358 | Resource: &agentproto.BoundaryLog_HttpRequest_{ |
| 359 | HttpRequest: &agentproto.BoundaryLog_HttpRequest{ |
| 360 | Method: "GET", |
| 361 | Url: "https://example.com/first", |
| 362 | }, |
| 363 | }, |
| 364 | }, |
| 365 | }, |
| 366 | } |
| 367 | sendLogs(t, conn, req1) |
| 368 | |
| 369 | select { |
| 370 | case <-reportNotify: |
| 371 | case <-time.After(testutil.WaitShort): |
| 372 | t.Fatal("timed out waiting for first message to be processed") |
| 373 | } |
| 374 | |
| 375 | // Send the second message, which should succeed. |
| 376 | req2 := &agentproto.ReportBoundaryLogsRequest{ |
| 377 | Logs: []*agentproto.BoundaryLog{ |
| 378 | { |
nothing calls this directly
no test coverage detected