Skip to content

Commit

Permalink
Fix flaky test failure in concurrent streams test (#624)
Browse files Browse the repository at this point in the history
Using a fixed level of parallelism means the test takes too long
when run on a machine with fewer resources/CPUs. So it would
occasionally encounter a timeout-related issue in CI. Fixed by
tying the level of parallelism to GOMAXPROCS (whose default
value comes from the number of CPIs).
  • Loading branch information
emcfarlane authored Nov 9, 2023
1 parent 8292c67 commit 67dceff
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion connect_ext_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"math"
"math/rand"
"net/http"
"runtime"
"strings"
"sync"
"testing"
Expand Down Expand Up @@ -475,7 +476,7 @@ func TestConcurrentStreams(t *testing.T) {
server := memhttptest.NewServer(t, mux)
var done, start sync.WaitGroup
start.Add(1)
for i := 0; i < 100; i++ {
for i := 0; i < runtime.GOMAXPROCS(0)*8; i++ {
done.Add(1)
go func() {
defer done.Done()
Expand Down
3 changes: 2 additions & 1 deletion internal/memhttp/memhttp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"fmt"
"io"
"net/http"
"runtime"
"sync"
"testing"
"time"
Expand All @@ -30,7 +31,7 @@ import (

func TestServerTransport(t *testing.T) {
t.Parallel()
const concurrency = 100
concurrency := runtime.GOMAXPROCS(0) * 8
const greeting = "Hello, world!"

handler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
Expand Down

0 comments on commit 67dceff

Please sign in to comment.