Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(das): make WaitCatchUp public #1380

Merged
merged 1 commit into from
Nov 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions das/daser.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,3 +169,8 @@ func (d *DASer) sample(ctx context.Context, h *header.ExtendedHeader) error {
func (d *DASer) SamplingStats(ctx context.Context) (SamplingStats, error) {
return d.sampler.stats(ctx)
}

// WaitCatchUp waits for DASer to indicate catchup is done
func (d *DASer) WaitCatchUp(ctx context.Context) error {
return d.sampler.state.waitCatchUp(ctx)
}
12 changes: 10 additions & 2 deletions das/daser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,17 @@ func TestDASerLifecycle(t *testing.T) {
// ensure checkpoint is stored at 30
assert.EqualValues(t, 30, checkpoint.SampleFrom-1)
}()
// wait for dasing catch-up routine to indicateDone

// wait for mock to indicate that catchup is done
select {
case <-ctx.Done():
t.Fatal(ctx.Err())
case <-mockGet.doneCh:
}

// wait for DASer to indicate done
assert.NoError(t, daser.WaitCatchUp(ctx))

// give catch-up routine a second to finish up sampling last header
assert.NoError(t, daser.sampler.state.waitCatchUp(ctx))
}
Expand All @@ -80,13 +85,16 @@ func TestDASer_Restart(t *testing.T) {
err = daser.Start(ctx)
require.NoError(t, err)

// wait for dasing catch-up routine to indicateDone
// wait for mock to indicate that catchup is done
select {
case <-ctx.Done():
t.Fatal(ctx.Err())
case <-mockGet.doneCh:
}

// wait for DASer to indicate done
assert.NoError(t, daser.WaitCatchUp(ctx))

err = daser.Stop(ctx)
require.NoError(t, err)

Expand Down
2 changes: 1 addition & 1 deletion das/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ func (s *coordinatorState) checkDone() {
}
}

// waitCatchUp waits for sampling process to indicateDone catchup
// waitCatchUp waits for sampling process to indicate catchup is done
func (s *coordinatorState) waitCatchUp(ctx context.Context) error {
select {
case <-s.catchUpDoneCh:
Expand Down