Skip to content

Commit

Permalink
advance clock during bootstrapper run
Browse files Browse the repository at this point in the history
  • Loading branch information
vpranckaitis committed Mar 5, 2021
1 parent 5afa0b4 commit 4181359
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/dbnode/integration/bootstrap_retries_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ func TestBootstrapRetriesDueToObsoleteRanges(t *testing.T) {
namespaces bootstrap.Namespaces,
cache bootstrap.Cache,
) (bootstrap.NamespaceResults, error) {
// read from signalCh twice so we could advance the clock exactly in between of those signals
<-signalCh
<-signalCh
noopNone := bootstrapper.NewNoOpAllBootstrapperProvider()
bs, err := noopNone.Provide()
Expand All @@ -109,18 +111,24 @@ func TestBootstrapRetriesDueToObsoleteRanges(t *testing.T) {
// First bootstrap pass, persist ranges. Check if DB is not marked bootstrapped.
signalCh <- struct{}{}
assert.False(t, setup.DB().IsBootstrapped(), "database should not yet be bootstrapped")
// Still first bootstrap pass, in-memory ranges. Shift clock to make previously calculated
// ranges obsolete. Check if DB is not marked bootstrapped.
setup.SetNowFn(setup.NowFn()().Add(2 * time.Hour))
signalCh <- struct{}{}

// Still first bootstrap pass, in-memory ranges. Due to advanced clock previously calculated
// ranges are obsolete. Check if DB is not marked bootstrapped.
signalCh <- struct{}{}
assert.False(t, setup.DB().IsBootstrapped(), "database should not yet be bootstrapped")
signalCh <- struct{}{}

// Bootstrap retry, persist ranges. Check if DB isn't marked as bootstrapped on the second pass.
signalCh <- struct{}{}
assert.False(t, setup.DB().IsBootstrapped(), "database should not yet be bootstrapped")
signalCh <- struct{}{}

// Still bootstrap retry, in-memory ranges. DB finishes bootstrapping.
signalCh <- struct{}{}
assert.False(t, setup.DB().IsBootstrapped(), "database should not yet be bootstrapped")
signalCh <- struct{}{}
}()

require.NoError(t, setup.StartServer()) // Blocks until bootstrap is complete
Expand Down

0 comments on commit 4181359

Please sign in to comment.