Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
Signed-off-by: Tim Vaillancourt <[email protected]>
  • Loading branch information
timvaillancourt committed Aug 20, 2024
1 parent 32ae433 commit e33c8ae
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 19 deletions.
2 changes: 1 addition & 1 deletion go/vt/vttablet/tabletserver/state_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ func (sm *stateManager) unservePrimary() error {
sm.se.MakePrimary(false)
sm.hs.MakePrimary(false)
sm.rt.MakePrimary()
sm.txThrottler.MakeNonPrimary()
sm.txThrottler.MakePrimary()
sm.setState(topodatapb.TabletType_PRIMARY, StateNotServing)
return nil
}
Expand Down
45 changes: 27 additions & 18 deletions go/vt/vttablet/tabletserver/state_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,18 +77,17 @@ func TestStateManagerServePrimary(t *testing.T) {
assert.Equal(t, testNow, sm.ptsTimestamp)

verifySubcomponent(t, 1, sm.watcher, testStateClosed)

verifySubcomponent(t, 2, sm.se, testStateOpen)
verifySubcomponent(t, 3, sm.vstreamer, testStateOpen)
verifySubcomponent(t, 4, sm.qe, testStateOpen)
verifySubcomponent(t, 5, sm.txThrottler, testStateOpen)
verifySubcomponent(t, 6, sm.rt, testStatePrimary)
verifySubcomponent(t, 7, sm.tracker, testStateOpen)
verifySubcomponent(t, 8, sm.te, testStatePrimary)
verifySubcomponent(t, 9, sm.messager, testStateOpen)
verifySubcomponent(t, 10, sm.throttler, testStateOpen)
verifySubcomponent(t, 11, sm.tableGC, testStateOpen)
verifySubcomponent(t, 12, sm.ddle, testStateOpen)
verifySubcomponent(t, 7, sm.txThrottler, testStatePrimary)
verifySubcomponent(t, 8, sm.tracker, testStateOpen)
verifySubcomponent(t, 9, sm.te, testStatePrimary)
verifySubcomponent(t, 10, sm.messager, testStateOpen)
verifySubcomponent(t, 11, sm.throttler, testStateOpen)
verifySubcomponent(t, 12, sm.tableGC, testStateOpen)
verifySubcomponent(t, 13, sm.ddle, testStateOpen)

assert.False(t, sm.se.(*testSchemaEngine).nonPrimary)
assert.True(t, sm.se.(*testSchemaEngine).ensureCalled)
Expand All @@ -109,14 +108,14 @@ func TestStateManagerServeNonPrimary(t *testing.T) {
verifySubcomponent(t, 4, sm.tracker, testStateClosed)
assert.True(t, sm.se.(*testSchemaEngine).nonPrimary)

verifySubcomponent(t, 5, sm.se, testStateOpen)
verifySubcomponent(t, 6, sm.vstreamer, testStateOpen)
verifySubcomponent(t, 7, sm.qe, testStateOpen)
verifySubcomponent(t, 8, sm.txThrottler, testStateOpen)
verifySubcomponent(t, 9, sm.te, testStateNonPrimary)
verifySubcomponent(t, 10, sm.rt, testStateNonPrimary)
verifySubcomponent(t, 11, sm.watcher, testStateOpen)
verifySubcomponent(t, 12, sm.throttler, testStateOpen)
verifySubcomponent(t, 6, sm.se, testStateOpen)
verifySubcomponent(t, 7, sm.vstreamer, testStateOpen)
verifySubcomponent(t, 8, sm.qe, testStateOpen)
verifySubcomponent(t, 9, sm.txThrottler, testStateOpen)
verifySubcomponent(t, 10, sm.te, testStateNonPrimary)
verifySubcomponent(t, 11, sm.rt, testStateNonPrimary)
verifySubcomponent(t, 12, sm.watcher, testStateOpen)
verifySubcomponent(t, 13, sm.throttler, testStateOpen)

assert.Equal(t, topodatapb.TabletType_REPLICA, sm.target.TabletType)
assert.Equal(t, StateServing, sm.state)
Expand All @@ -139,9 +138,9 @@ func TestStateManagerUnservePrimary(t *testing.T) {
verifySubcomponent(t, 8, sm.se, testStateOpen)
verifySubcomponent(t, 9, sm.vstreamer, testStateOpen)
verifySubcomponent(t, 10, sm.qe, testStateOpen)
verifySubcomponent(t, 11, sm.txThrottler, testStateOpen)

verifySubcomponent(t, 12, sm.rt, testStatePrimary)
verifySubcomponent(t, 13, sm.txThrottler, testStatePrimary)

assert.Equal(t, topodatapb.TabletType_PRIMARY, sm.target.TabletType)
assert.Equal(t, StateNotServing, sm.state)
Expand All @@ -165,7 +164,7 @@ func TestStateManagerUnserveNonPrimary(t *testing.T) {
verifySubcomponent(t, 7, sm.se, testStateOpen)
verifySubcomponent(t, 8, sm.vstreamer, testStateOpen)
verifySubcomponent(t, 9, sm.qe, testStateOpen)
verifySubcomponent(t, 10, sm.txThrottler, testStateOpen)
verifySubcomponent(t, 10, sm.txThrottler, testStateNonPrimary)

verifySubcomponent(t, 11, sm.rt, testStateNonPrimary)
verifySubcomponent(t, 12, sm.watcher, testStateOpen)
Expand Down Expand Up @@ -932,6 +931,16 @@ func (te *testTxThrottler) Close() {
te.state = testStateClosed
}

func (te *testTxThrottler) MakePrimary() {
te.order = order.Add(1)
te.state = testStatePrimary
}

func (te *testTxThrottler) MakeNonPrimary() {
te.order = order.Add(1)
te.state = testStateNonPrimary
}

type testOnlineDDLExecutor struct {
testOrderState
}
Expand Down

0 comments on commit e33c8ae

Please sign in to comment.