Skip to content

Commit

Permalink
test: add a failing test to see the panic
Browse files Browse the repository at this point in the history
Signed-off-by: Manan Gupta <[email protected]>
  • Loading branch information
GuptaManan100 committed Jan 10, 2024
1 parent 9df71e0 commit 001fa3f
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions go/vt/vttablet/tabletserver/state_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -701,6 +701,29 @@ func TestRefreshReplHealthLocked(t *testing.T) {
assert.False(t, sm.replHealthy)
}

func TestPanicInWait(t *testing.T) {
sm := newTestStateManager(t)
sm.wantState = StateServing
sm.state = StateServing
sm.replHealthy = true
ctx := context.Background()
// Simulate an Execute RPC running
err := sm.StartRequest(ctx, sm.target, false)
require.NoError(t, err)
go func() {
time.Sleep(100 * time.Millisecond)
// Simulate the previous RPC finishing after some delay
sm.EndRequest()
// Simulate a COMMIT call arriving right afterwards
err = sm.StartRequest(ctx, sm.target, true)
require.NoError(t, err)
}()

// Simulate going to a not serving state and calling unserveCommon that waits on requests.
sm.wantState = StateNotServing
sm.requests.Wait()
}

func verifySubcomponent(t *testing.T, order int64, component any, state testState) {
tos := component.(orderState)
assert.Equal(t, order, tos.Order())
Expand Down

0 comments on commit 001fa3f

Please sign in to comment.