Commit cd11938a authored by Francis Li's avatar Francis Li Committed by GitHub

Queue an action after conductor start (#10772)

parent e61a5cd3
...@@ -96,7 +96,6 @@ func NewOpConductor( ...@@ -96,7 +96,6 @@ func NewOpConductor(
} }
return nil, err return nil, err
} }
oc.prevState = NewState(oc.leader.Load(), oc.healthy.Load(), oc.seqActive.Load())
return oc, nil return oc, nil
} }
...@@ -341,6 +340,10 @@ func (oc *OpConductor) Start(ctx context.Context) error { ...@@ -341,6 +340,10 @@ func (oc *OpConductor) Start(ctx context.Context) error {
oc.metrics.RecordUp() oc.metrics.RecordUp()
oc.log.Info("OpConductor started") oc.log.Info("OpConductor started")
// queue an action in case sequencer is not in the desired state.
oc.prevState = NewState(oc.leader.Load(), oc.healthy.Load(), oc.seqActive.Load())
oc.queueAction()
return nil return nil
} }
......
...@@ -160,6 +160,7 @@ func (s *OpConductorTestSuite) enableSynchronization() { ...@@ -160,6 +160,7 @@ func (s *OpConductorTestSuite) enableSynchronization() {
s.wg.Done() s.wg.Done()
} }
s.startConductor() s.startConductor()
s.executeAction()
} }
func (s *OpConductorTestSuite) disableSynchronization() { func (s *OpConductorTestSuite) disableSynchronization() {
...@@ -850,6 +851,22 @@ func (s *OpConductorTestSuite) TestFailureAndRetry4() { ...@@ -850,6 +851,22 @@ func (s *OpConductorTestSuite) TestFailureAndRetry4() {
}, 2*time.Second, 100*time.Millisecond) }, 2*time.Second, 100*time.Millisecond)
} }
func (s *OpConductorTestSuite) TestConductorRestart() {
// set initial state
s.conductor.leader.Store(false)
s.conductor.healthy.Store(true)
s.conductor.seqActive.Store(true)
s.ctrl.EXPECT().StopSequencer(mock.Anything).Return(common.Hash{}, nil).Times(1)
s.enableSynchronization()
// expect to stay as follower, go to [follower, healthy, not sequencing]
s.False(s.conductor.leader.Load())
s.True(s.conductor.healthy.Load())
s.False(s.conductor.seqActive.Load())
s.ctrl.AssertCalled(s.T(), "StopSequencer", mock.Anything)
}
func (s *OpConductorTestSuite) TestHandleInitError() { func (s *OpConductorTestSuite) TestHandleInitError() {
// This will cause an error in the init function, which should cause the conductor to stop successfully without issues. // This will cause an error in the init function, which should cause the conductor to stop successfully without issues.
_, err := New(s.ctx, &s.cfg, s.log, s.version) _, err := New(s.ctx, &s.cfg, s.log, s.version)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment