Skip to content

Commit af246a4

Browse files
authored
Run tests in parallel. (#98)
In #93 @storozhukBM adds test parallization, which is unrelated to the actual change. I'd rather have this as a separate PR. The test currently take ~12 seconds on my laptop, so I see why we might want to run them in parallel. There are other parallelization opportunities (we could paralelize each of the subtests for each of the rate-limiters), but this is a good start. Before: ``` > go test ./... -race -count 1 ok go.uber.org/ratelimit 12.739s ``` After: ``` > go test ./... -race -count 1 ok go.uber.org/ratelimit 6.178s ```
1 parent 29ac3a2 commit af246a4

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

ratelimit_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ func (r *runnerImpl) goWait(fn func()) {
143143
}
144144

145145
func TestUnlimited(t *testing.T) {
146+
t.Parallel()
146147
now := time.Now()
147148
rl := NewUnlimited()
148149
for i := 0; i < 1000; i++ {
@@ -152,6 +153,7 @@ func TestUnlimited(t *testing.T) {
152153
}
153154

154155
func TestRateLimiter(t *testing.T) {
156+
t.Parallel()
155157
runTest(t, func(r testRunner) {
156158
rl := r.createLimiter(100, WithoutSlack)
157159

@@ -168,6 +170,7 @@ func TestRateLimiter(t *testing.T) {
168170
}
169171

170172
func TestDelayedRateLimiter(t *testing.T) {
173+
t.Parallel()
171174
runTest(t, func(r testRunner) {
172175
slow := r.createLimiter(10, WithoutSlack)
173176
fast := r.createLimiter(100, WithoutSlack)
@@ -186,6 +189,7 @@ func TestDelayedRateLimiter(t *testing.T) {
186189
}
187190

188191
func TestPer(t *testing.T) {
192+
t.Parallel()
189193
runTest(t, func(r testRunner) {
190194
rl := r.createLimiter(7, WithoutSlack, Per(time.Minute))
191195

@@ -199,6 +203,7 @@ func TestPer(t *testing.T) {
199203
}
200204

201205
func TestSlack(t *testing.T) {
206+
t.Parallel()
202207
// To simulate slack, we combine two limiters.
203208
// - First, we start a single goroutine with both of them,
204209
// during this time the slow limiter will dominate,

0 commit comments

Comments
 (0)