Skip to content

Commit

Permalink
router: fix unstable test TestConnBalanced (pingcap#82)
Browse files Browse the repository at this point in the history
  • Loading branch information
djshow832 authored and xhebox committed Mar 7, 2023
1 parent 672e724 commit 60e0568
Showing 1 changed file with 21 additions and 18 deletions.
39 changes: 21 additions & 18 deletions pkg/manager/router/router_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -326,25 +326,28 @@ func TestConnBalanced(t *testing.T) {
tester.addConnections(100)
tester.checkBalanced()

// balanced after scale in
tester.killBackends(1)
tester.rebalance(100)
tester.redirectFinish(100, true)
tester.checkBalanced()
tester.checkBackendConnMetrics()

// balanced after scale out
tester.addBackends(1)
tester.rebalance(100)
tester.redirectFinish(100, true)
tester.checkBalanced()
tester.checkBackendConnMetrics()
tests := []func(){
func() {
// balanced after scale in
tester.killBackends(1)
},
func() {
// balanced after scale out
tester.addBackends(1)
},
func() {
// balanced after closing connections
tester.closeConnections(10, false)
},
}

// balanced after closing connections
tester.closeConnections(10, false)
tester.rebalance(100)
tester.checkBalanced()
tester.checkBackendConnMetrics()
for _, tt := range tests {
tt()
tester.rebalance(100)
tester.redirectFinish(100, true)
tester.checkBalanced()
tester.checkBackendConnMetrics()
}
}

// Test that routing fails when there's no healthy backends.
Expand Down

0 comments on commit 60e0568

Please sign in to comment.