Skip to content

Commit

Permalink
tabletbalancer test coverage for tablet replaced
Browse files Browse the repository at this point in the history
Signed-off-by: Venkatraju V <venkatraju@slack-corp.com>
  • Loading branch information
venkatraju committed Jul 9, 2024
1 parent 6f47d9d commit e10b474
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions go/vt/vtgate/balancer/balancer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -384,4 +384,26 @@ func TestTopologyChanged(t *testing.T) {
t.Errorf("shuffle promoted wrong tablet from cell %s", allTablets[0].Tablet.Alias.Cell)
}
}

// Run again with a node in the topology replaced.
newTablet := createTestTablet("b")
allTablets[2] = newTablet
for i := 0; i < N; i++ {
th := b.Pick(target, allTablets)

allocation, totalAllocation := b.getAllocation(target, allTablets)

if totalAllocation != ALLOCATION/2 {
t.Errorf("totalAllocation mismatch %s", b.print())
}

if allocation[th.Tablet.Alias.Uid] != ALLOCATION/4 {
t.Errorf("allocation mismatch %s, cell %s", b.print(), allTablets[0].Tablet.Alias.Cell)
}

if th.Tablet.Alias.Cell != "b" {
t.Errorf("shuffle promoted wrong tablet from cell %s", allTablets[0].Tablet.Alias.Cell)
}
}

}

0 comments on commit e10b474

Please sign in to comment.