Skip to content

Commit

Permalink
testing: shut down syncer
Browse files Browse the repository at this point in the history
  • Loading branch information
peterjan committed Aug 15, 2024
1 parent 81111c0 commit e3c9f37
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion internal/test/e2e/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,23 @@ func newTestBus(ctx context.Context, dir string, cfg config.Bus, cfgDb dbConfig,

// create the syncer
s := syncer.New(l, cm, sqlStore, header, syncer.WithLogger(logger.Named("syncer")), syncer.WithSendBlocksTimeout(time.Minute))
go s.Run(context.Background())

// start syncer
errChan := make(chan error, 1)
go func() {
errChan <- s.Run(context.Background())
close(errChan)
}()

// create a helper function to wait for syncer to wind down on shutdown
syncerShutdown := func(ctx context.Context) error {
select {
case err := <-errChan:
return err
case <-ctx.Done():
return context.Cause(ctx)
}
}

// create bus
announcementMaxAgeHours := time.Duration(cfg.AnnouncementMaxAgeHours) * time.Hour
Expand All @@ -570,6 +586,7 @@ func newTestBus(ctx context.Context, dir string, cfg config.Bus, cfgDb dbConfig,
b.Shutdown(ctx),
sqlStore.Close(),
bdb.Close(),
syncerShutdown(ctx),
)
}
return b, shutdownFn, cm, nil
Expand Down

0 comments on commit e3c9f37

Please sign in to comment.