Skip to content

Commit

Permalink
tests/api: reduce TestRegionsWithKillRequest test time (#7953)
Browse files Browse the repository at this point in the history
ref #7930

Signed-off-by: lhy1024 <admin@liudos.us>

Co-authored-by: disksing <i@disksing.com>
  • Loading branch information
lhy1024 and disksing committed Mar 21, 2024
1 parent c00c42e commit bb8ba31
Showing 1 changed file with 21 additions and 5 deletions.
26 changes: 21 additions & 5 deletions server/api/region_test.go
Expand Up @@ -23,6 +23,7 @@ import (
"net/http"
"net/url"
"sort"
"sync"
"testing"
"time"

Expand Down Expand Up @@ -333,13 +334,28 @@ func TestRegionsWithKillRequest(t *testing.T) {
url := fmt.Sprintf("%s%s/api/v1/regions", addr, apiPrefix)
mustBootstrapCluster(re, svr)
regionCount := 100000

// create data
var wg sync.WaitGroup
tasks := make(chan int, regionCount)
for w := 0; w < 16; w++ {
wg.Add(1)
go func() {
defer wg.Done()
for i := range tasks {
r := core.NewTestRegionInfo(uint64(i+2), 1,
[]byte(fmt.Sprintf("%09d", i)),
[]byte(fmt.Sprintf("%09d", i+1)),
core.SetApproximateKeys(10), core.SetApproximateSize(10))
mustRegionHeartbeat(re, svr, r)
}
}()
}
for i := 0; i < regionCount; i++ {
r := core.NewTestRegionInfo(uint64(i+2), 1,
[]byte(fmt.Sprintf("%09d", i)),
[]byte(fmt.Sprintf("%09d", i+1)),
core.SetApproximateKeys(10), core.SetApproximateSize(10))
mustRegionHeartbeat(re, svr, r)
tasks <- i
}
close(tasks)
wg.Wait()

ctx, cancel := context.WithCancel(context.Background())
req, err := http.NewRequestWithContext(ctx, http.MethodGet, url, http.NoBody)
Expand Down

0 comments on commit bb8ba31

Please sign in to comment.