mirror of
https://github.com/kemko/nomad.git
synced 2026-01-05 09:55:44 +03:00
tweak bootstrap testing
This commit is contained in:
@@ -91,6 +91,12 @@ func (s *Server) nodeJoin(me serf.MemberEvent) {
|
||||
|
||||
// maybeBootstrap is used to handle bootstrapping when a new server joins
|
||||
func (s *Server) maybeBootstrap() {
|
||||
|
||||
// redundant check to ease testing
|
||||
if s.config.BootstrapExpect == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
// Bootstrap can only be done if there are no committed logs, remove our
|
||||
// expectations of bootstrapping. This is slightly cheaper than the full
|
||||
// check that BootstrapCluster will do, so this is a good pre-filter.
|
||||
|
||||
@@ -473,7 +473,10 @@ func TestNomad_NonBootstraping_ShouldntBootstap(t *testing.T) {
|
||||
t.Fatalf("expected 1 local peer: %v", err)
|
||||
})
|
||||
|
||||
time.Sleep(500 * time.Millisecond)
|
||||
// as non-bootstrap mode is the initial state, we must wait long enough to assert that
|
||||
// we don't bootstrap even if enough time has elapsed. Also, explicitly attempt bootstrap.
|
||||
s1.maybeBootstrap()
|
||||
time.Sleep(100 * time.Millisecond)
|
||||
|
||||
bootstrapped := atomic.LoadInt32(&s1.config.Bootstrapped)
|
||||
require.Zero(t, bootstrapped, "expecting non-bootstrapped servers")
|
||||
|
||||
Reference in New Issue
Block a user