Skip to content

Commit

Permalink
util/ring: Reduce the time cost by TestRingBuffer
Browse files Browse the repository at this point in the history
Use t.Parallel to speed up tests by running tests in parallel,
reduce `maxCount` from 1000 to 100, and, revert the change of #63388.

Release note: None
  • Loading branch information
XuanYang-cn authored and yuzefovich committed May 20, 2021
1 parent 1bb8ec9 commit b940c2d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pkg/util/ring/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ go_library(

go_test(
name = "ring_test",
size = "medium",
size = "small",
srcs = ["ring_buffer_test.go"],
embed = [":ring"],
deps = ["@com_github_stretchr_testify//require"],
Expand Down
7 changes: 5 additions & 2 deletions pkg/util/ring/ring_buffer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
"github.com/stretchr/testify/require"
)

const maxCount = 1000
const maxCount = 100

func testRingBuffer(t *testing.T, count int) {
var buffer Buffer
Expand Down Expand Up @@ -60,7 +60,10 @@ func testRingBuffer(t *testing.T, count int) {

func TestRingBuffer(t *testing.T) {
for count := 1; count <= maxCount; count++ {
testRingBuffer(t, count)
t.Run("Parallel", func(t *testing.T) {
t.Parallel() // SAFE FOR TESTING
testRingBuffer(t, count)
})
}
}

Expand Down

0 comments on commit b940c2d

Please sign in to comment.