(ctx context.Context, peer *peerUnderTest, bindAddr string)
| 683 | } |
| 684 | |
| 685 | func runSyncAPIWithCtx(ctx context.Context, peer *peerUnderTest, bindAddr string) { |
| 686 | mux := http.NewServeMux() |
| 687 | syncHandler := NewBackrestSyncHandler(peer.manager) |
| 688 | mux.Handle(v1syncconnect.NewBackrestSyncServiceHandler(syncHandler)) |
| 689 | |
| 690 | server := &http.Server{ |
| 691 | Addr: bindAddr, |
| 692 | Handler: h2c.NewHandler(mux, &http2.Server{}), // h2c is HTTP/2 without TLS for grpc-connect support. |
| 693 | } |
| 694 | |
| 695 | var wg sync.WaitGroup |
| 696 | |
| 697 | go func() { |
| 698 | <-ctx.Done() |
| 699 | server.Shutdown(context.Background()) |
| 700 | }() |
| 701 | |
| 702 | wg.Add(1) |
| 703 | go func() { |
| 704 | if err := server.ListenAndServe(); err != nil && err != http.ErrServerClosed { |
| 705 | panic(err) |
| 706 | } |
| 707 | wg.Done() |
| 708 | }() |
| 709 | |
| 710 | wg.Add(1) |
| 711 | go func() { |
| 712 | peer.manager.RunSync(ctx) |
| 713 | wg.Done() |
| 714 | }() |
| 715 | |
| 716 | wg.Wait() |
| 717 | } |
| 718 | |
| 719 | func startRunningSyncAPI(t *testing.T, peer *peerUnderTest, bindAddr string) { |
| 720 | t.Helper() |
no test coverage detected