Skip to content

Commit

Permalink
PR suggestions
Browse files Browse the repository at this point in the history
Signed-off-by: Tim Vaillancourt <[email protected]>
  • Loading branch information
timvaillancourt committed Oct 4, 2024
1 parent df59fcf commit 1da308b
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions go/vt/throttler/throttler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ import (
"vitess.io/vitess/go/vt/proto/topodata"
)

// testTabletTypes is the list of tablet types to test.
var testTabletTypes = []topodata.TabletType{
topodata.TabletType_REPLICA,
topodata.TabletType_RDONLY,
}

// The main purpose of the benchmarks below is to demonstrate the functionality
// of the throttler in the real-world (using a non-faked time.Now).
// The benchmark values should be as close as possible to the request interval
Expand Down Expand Up @@ -425,10 +431,7 @@ func TestThrottlerMaxLag(t *testing.T) {
var wg sync.WaitGroup

// run .add() and .MaxLag() concurrently to detect races
for _, tabletType := range []topodata.TabletType{
topodata.TabletType_REPLICA,
topodata.TabletType_RDONLY,
} {
for _, tabletType := range testTabletTypes {
wg.Add(1)
go func() {
defer wg.Done()
Expand All @@ -443,7 +446,7 @@ func TestThrottlerMaxLag(t *testing.T) {
}()

wg.Add(1)
go func(wg *sync.WaitGroup, ctx context.Context, throttler *ThrottlerImpl, tabletType topodata.TabletType) {
go func() {
defer wg.Done()
for {
select {
Expand All @@ -470,17 +473,14 @@ func TestThrottlerMaxLag(t *testing.T) {
})
}
}
}(&wg, ctx, throttler, tabletType)
}()
}
time.Sleep(time.Second)
cancel()
wg.Wait()

// check .MaxLag()
for _, tabletType := range []topodata.TabletType{
topodata.TabletType_REPLICA,
topodata.TabletType_RDONLY,
} {
for _, tabletType := range testTabletTypes {
require.Equal(t, uint32(5), throttler.MaxLag(tabletType))
}
}

0 comments on commit 1da308b

Please sign in to comment.