Skip to content

Commit 4a5e66f

Browse files
ninedraftAlexVulaj
authored andcommitted
make tests parallel
1 parent 871f6bb commit 4a5e66f

File tree

10 files changed

+59
-1
lines changed

10 files changed

+59
-1
lines changed

client_server_test.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ func sendRecv(t *testing.T, ws *Conn) {
142142
}
143143

144144
func TestProxyDial(t *testing.T) {
145+
t.Parallel()
145146

146147
s := newServer(t)
147148
defer s.Close()
@@ -180,6 +181,7 @@ func TestProxyDial(t *testing.T) {
180181
}
181182

182183
func TestProxyAuthorizationDial(t *testing.T) {
184+
t.Parallel()
183185
s := newServer(t)
184186
defer s.Close()
185187

@@ -220,6 +222,7 @@ func TestProxyAuthorizationDial(t *testing.T) {
220222
}
221223

222224
func TestDial(t *testing.T) {
225+
t.Parallel()
223226
s := newServer(t)
224227
defer s.Close()
225228

@@ -232,6 +235,7 @@ func TestDial(t *testing.T) {
232235
}
233236

234237
func TestDialCookieJar(t *testing.T) {
238+
t.Parallel()
235239
s := newServer(t)
236240
defer s.Close()
237241

@@ -294,6 +298,7 @@ func rootCAs(t *testing.T, s *httptest.Server) *x509.CertPool {
294298
}
295299

296300
func TestDialTLS(t *testing.T) {
301+
t.Parallel()
297302
s := newTLSServer(t)
298303
defer s.Close()
299304

@@ -308,6 +313,7 @@ func TestDialTLS(t *testing.T) {
308313
}
309314

310315
func TestDialTimeout(t *testing.T) {
316+
t.Parallel()
311317
s := newServer(t)
312318
defer s.Close()
313319

@@ -364,6 +370,7 @@ func (c *requireDeadlineNetConn) LocalAddr() net.Addr { return c.c.LocalAddr()
364370
func (c *requireDeadlineNetConn) RemoteAddr() net.Addr { return c.c.RemoteAddr() }
365371

366372
func TestHandshakeTimeout(t *testing.T) {
373+
t.Parallel()
367374
s := newServer(t)
368375
defer s.Close()
369376

@@ -380,6 +387,7 @@ func TestHandshakeTimeout(t *testing.T) {
380387
}
381388

382389
func TestHandshakeTimeoutInContext(t *testing.T) {
390+
t.Parallel()
383391
s := newServer(t)
384392
defer s.Close()
385393

@@ -401,6 +409,7 @@ func TestHandshakeTimeoutInContext(t *testing.T) {
401409
}
402410

403411
func TestDialBadScheme(t *testing.T) {
412+
t.Parallel()
404413
s := newServer(t)
405414
defer s.Close()
406415

@@ -412,6 +421,7 @@ func TestDialBadScheme(t *testing.T) {
412421
}
413422

414423
func TestDialBadOrigin(t *testing.T) {
424+
t.Parallel()
415425
s := newServer(t)
416426
defer s.Close()
417427

@@ -429,6 +439,7 @@ func TestDialBadOrigin(t *testing.T) {
429439
}
430440

431441
func TestDialBadHeader(t *testing.T) {
442+
t.Parallel()
432443
s := newServer(t)
433444
defer s.Close()
434445

@@ -448,6 +459,7 @@ func TestDialBadHeader(t *testing.T) {
448459
}
449460

450461
func TestBadMethod(t *testing.T) {
462+
t.Parallel()
451463
s := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
452464
ws, err := cstUpgrader.Upgrade(w, r, nil)
453465
if err == nil {
@@ -476,6 +488,7 @@ func TestBadMethod(t *testing.T) {
476488
}
477489

478490
func TestDialExtraTokensInRespHeaders(t *testing.T) {
491+
t.Parallel()
479492
s := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
480493
challengeKey := r.Header.Get("Sec-Websocket-Key")
481494
w.Header().Set("Upgrade", "foo, websocket")
@@ -493,6 +506,7 @@ func TestDialExtraTokensInRespHeaders(t *testing.T) {
493506
}
494507

495508
func TestHandshake(t *testing.T) {
509+
t.Parallel()
496510
s := newServer(t)
497511
defer s.Close()
498512

@@ -519,6 +533,7 @@ func TestHandshake(t *testing.T) {
519533
}
520534

521535
func TestRespOnBadHandshake(t *testing.T) {
536+
t.Parallel()
522537
const expectedStatus = http.StatusGone
523538
const expectedBody = "This is the response body."
524539

@@ -564,6 +579,7 @@ func (w testLogWriter) Write(p []byte) (int, error) {
564579

565580
// TestHost tests handling of host names and confirms that it matches net/http.
566581
func TestHost(t *testing.T) {
582+
t.Parallel()
567583

568584
upgrader := Upgrader{}
569585
handler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
@@ -745,6 +761,7 @@ func TestHost(t *testing.T) {
745761
}
746762

747763
func TestDialCompression(t *testing.T) {
764+
t.Parallel()
748765
s := newServer(t)
749766
defer s.Close()
750767

@@ -759,6 +776,7 @@ func TestDialCompression(t *testing.T) {
759776
}
760777

761778
func TestSocksProxyDial(t *testing.T) {
779+
t.Parallel()
762780
s := newServer(t)
763781
defer s.Close()
764782

@@ -846,6 +864,7 @@ func TestSocksProxyDial(t *testing.T) {
846864
}
847865

848866
func TestTracingDialWithContext(t *testing.T) {
867+
t.Parallel()
849868

850869
var headersWrote, requestWrote, getConn, gotConn, connectDone, gotFirstResponseByte bool
851870
trace := &httptrace.ClientTrace{
@@ -905,6 +924,7 @@ func TestTracingDialWithContext(t *testing.T) {
905924
}
906925

907926
func TestEmptyTracingDialWithContext(t *testing.T) {
927+
t.Parallel()
908928

909929
trace := &httptrace.ClientTrace{}
910930
ctx := httptrace.WithClientTrace(context.Background(), trace)
@@ -926,6 +946,7 @@ func TestEmptyTracingDialWithContext(t *testing.T) {
926946

927947
// TestNetDialConnect tests selection of dial method between NetDial, NetDialContext, NetDialTLS or NetDialTLSContext
928948
func TestNetDialConnect(t *testing.T) {
949+
t.Parallel()
929950

930951
upgrader := Upgrader{}
931952
handler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
@@ -1101,6 +1122,7 @@ func TestNetDialConnect(t *testing.T) {
11011122
}
11021123
}
11031124
func TestNextProtos(t *testing.T) {
1125+
t.Parallel()
11041126
ts := httptest.NewUnstartedServer(
11051127
http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {}),
11061128
)

client_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ var hostPortNoPortTests = []struct {
2020
}
2121

2222
func TestHostPortNoPort(t *testing.T) {
23+
t.Parallel()
2324
for _, tt := range hostPortNoPortTests {
2425
hostPort, hostNoPort := hostPortNoPort(tt.u)
2526
if hostPort != tt.hostPort {

compression_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ type nopCloser struct{ io.Writer }
1212
func (nopCloser) Close() error { return nil }
1313

1414
func TestTruncWriter(t *testing.T) {
15+
t.Parallel()
1516
const data = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijlkmnopqrstuvwxyz987654321"
1617
for n := 1; n <= 10; n++ {
1718
var b bytes.Buffer
@@ -71,6 +72,7 @@ func BenchmarkWriteWithCompression(b *testing.B) {
7172
}
7273

7374
func TestValidCompressionLevel(t *testing.T) {
75+
t.Parallel()
7476
c := newTestConn(nil, nil, false)
7577
for _, level := range []int{minCompressionLevel - 1, maxCompressionLevel + 1} {
7678
if err := c.SetCompressionLevel(level); err == nil {

conn_test.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ func newTestConn(r io.Reader, w io.Writer, isServer bool) *Conn {
5454
}
5555

5656
func TestFraming(t *testing.T) {
57+
t.Parallel()
5758
frameSizes := []int{
5859
0, 1, 2, 124, 125, 126, 127, 128, 129, 65534, 65535,
5960
// 65536, 65537
@@ -148,6 +149,7 @@ func TestFraming(t *testing.T) {
148149
}
149150

150151
func TestControl(t *testing.T) {
152+
t.Parallel()
151153
const message = "this is a ping/pong messsage"
152154
for _, isServer := range []bool{true, false} {
153155
for _, isWriteControl := range []bool{true, false} {
@@ -204,6 +206,7 @@ func (p *simpleBufferPool) Put(v interface{}) {
204206
}
205207

206208
func TestWriteBufferPool(t *testing.T) {
209+
t.Parallel()
207210
const message = "Now is the time for all good people to come to the aid of the party."
208211

209212
var buf bytes.Buffer
@@ -282,6 +285,7 @@ func TestWriteBufferPool(t *testing.T) {
282285

283286
// TestWriteBufferPoolSync ensures that *sync.Pool works as a buffer pool.
284287
func TestWriteBufferPoolSync(t *testing.T) {
288+
t.Parallel()
285289
var buf bytes.Buffer
286290
var pool sync.Pool
287291
wc := newConn(fakeNetConn{Writer: &buf}, true, 1024, 1024, &pool, nil, nil)
@@ -310,6 +314,7 @@ func (ew errorWriter) Write(p []byte) (int, error) { return 0, errors.New("error
310314
// TestWriteBufferPoolError ensures that buffer is returned to pool after error
311315
// on write.
312316
func TestWriteBufferPoolError(t *testing.T) {
317+
t.Parallel()
313318

314319
// Part 1: Test NextWriter/Write/Close
315320

@@ -353,6 +358,7 @@ func TestWriteBufferPoolError(t *testing.T) {
353358
}
354359

355360
func TestCloseFrameBeforeFinalMessageFrame(t *testing.T) {
361+
t.Parallel()
356362
const bufSize = 512
357363

358364
expectedErr := &CloseError{Code: CloseNormalClosure, Text: "hello"}
@@ -385,6 +391,7 @@ func TestCloseFrameBeforeFinalMessageFrame(t *testing.T) {
385391
}
386392

387393
func TestEOFWithinFrame(t *testing.T) {
394+
t.Parallel()
388395
const bufSize = 64
389396

390397
for n := 0; ; n++ {
@@ -422,6 +429,7 @@ func TestEOFWithinFrame(t *testing.T) {
422429
}
423430

424431
func TestEOFBeforeFinalFrame(t *testing.T) {
432+
t.Parallel()
425433
const bufSize = 512
426434

427435
var b1, b2 bytes.Buffer
@@ -448,6 +456,7 @@ func TestEOFBeforeFinalFrame(t *testing.T) {
448456
}
449457

450458
func TestWriteAfterMessageWriterClose(t *testing.T) {
459+
t.Parallel()
451460
wc := newTestConn(nil, &bytes.Buffer{}, false)
452461
w, _ := wc.NextWriter(BinaryMessage)
453462
if _, err := io.WriteString(w, "hello"); err != nil {
@@ -478,6 +487,7 @@ func TestWriteAfterMessageWriterClose(t *testing.T) {
478487
}
479488

480489
func TestWriteHandlerDoesNotReturnErrCloseSent(t *testing.T) {
490+
t.Parallel()
481491
var b1, b2 bytes.Buffer
482492

483493
client := newTestConn(&b2, &b1, false)
@@ -498,6 +508,7 @@ func TestWriteHandlerDoesNotReturnErrCloseSent(t *testing.T) {
498508
}
499509

500510
func TestReadLimit(t *testing.T) {
511+
t.Parallel()
501512
t.Run("Test ReadLimit is enforced", func(t *testing.T) {
502513
const readLimit = 512
503514
message := make([]byte, readLimit+1)
@@ -596,6 +607,7 @@ func TestReadLimit(t *testing.T) {
596607
}
597608

598609
func TestAddrs(t *testing.T) {
610+
t.Parallel()
599611
c := newTestConn(nil, nil, true)
600612
if c.LocalAddr() != localAddr {
601613
t.Errorf("LocalAddr = %v, want %v", c.LocalAddr(), localAddr)
@@ -606,6 +618,7 @@ func TestAddrs(t *testing.T) {
606618
}
607619

608620
func TestDeprecatedUnderlyingConn(t *testing.T) {
621+
t.Parallel()
609622
var b1, b2 bytes.Buffer
610623
fc := fakeNetConn{Reader: &b1, Writer: &b2}
611624
c := newConn(fc, true, 1024, 1024, nil, nil, nil)
@@ -616,6 +629,7 @@ func TestDeprecatedUnderlyingConn(t *testing.T) {
616629
}
617630

618631
func TestNetConn(t *testing.T) {
632+
t.Parallel()
619633
var b1, b2 bytes.Buffer
620634
fc := fakeNetConn{Reader: &b1, Writer: &b2}
621635
c := newConn(fc, true, 1024, 1024, nil, nil, nil)
@@ -626,6 +640,7 @@ func TestNetConn(t *testing.T) {
626640
}
627641

628642
func TestBufioReadBytes(t *testing.T) {
643+
t.Parallel()
629644
// Test calling bufio.ReadBytes for value longer than read buffer size.
630645

631646
m := make([]byte, 512)
@@ -668,6 +683,7 @@ var closeErrorTests = []struct {
668683
}
669684

670685
func TestCloseError(t *testing.T) {
686+
t.Parallel()
671687
for _, tt := range closeErrorTests {
672688
ok := IsCloseError(tt.err, tt.codes...)
673689
if ok != tt.ok {
@@ -688,6 +704,7 @@ var unexpectedCloseErrorTests = []struct {
688704
}
689705

690706
func TestUnexpectedCloseErrors(t *testing.T) {
707+
t.Parallel()
691708
for _, tt := range unexpectedCloseErrorTests {
692709
ok := IsUnexpectedCloseError(tt.err, tt.codes...)
693710
if ok != tt.ok {
@@ -709,6 +726,7 @@ func (w blockingWriter) Write(p []byte) (int, error) {
709726
}
710727

711728
func TestConcurrentWritePanic(t *testing.T) {
729+
t.Parallel()
712730
w := blockingWriter{make(chan struct{}), make(chan struct{})}
713731
c := newTestConn(nil, w, false)
714732
go func() {
@@ -740,6 +758,7 @@ func (r failingReader) Read(p []byte) (int, error) {
740758
}
741759

742760
func TestFailedConnectionReadPanic(t *testing.T) {
761+
t.Parallel()
743762
c := newTestConn(failingReader{}, nil, false)
744763

745764
defer func() {

example_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,4 @@ func processMessage(mt int, p []byte) {}
4242

4343
// TestX prevents godoc from showing this entire file in the example. Remove
4444
// this function when a second example is added.
45-
func TestX(t *testing.T) {}
45+
func TestX(t *testing.T) { t.Parallel() }

join_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
)
1313

1414
func TestJoinMessages(t *testing.T) {
15+
t.Parallel()
1516
messages := []string{"a", "bc", "def", "ghij", "klmno", "0", "12", "345", "6789"}
1617
for _, readChunk := range []int{1, 2, 3, 4, 5, 6, 7} {
1718
for _, term := range []string{"", ","} {

json_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
)
1414

1515
func TestJSON(t *testing.T) {
16+
t.Parallel()
1617
var buf bytes.Buffer
1718
wc := newTestConn(nil, &buf, true)
1819
rc := newTestConn(&buf, nil, false)
@@ -38,6 +39,7 @@ func TestJSON(t *testing.T) {
3839
}
3940

4041
func TestPartialJSONRead(t *testing.T) {
42+
t.Parallel()
4143
var buf0, buf1 bytes.Buffer
4244
wc := newTestConn(nil, &buf0, true)
4345
rc := newTestConn(&buf0, &buf1, false)
@@ -91,6 +93,7 @@ func TestPartialJSONRead(t *testing.T) {
9193
}
9294

9395
func TestDeprecatedJSON(t *testing.T) {
96+
t.Parallel()
9497
var buf bytes.Buffer
9598
wc := newTestConn(nil, &buf, true)
9699
rc := newTestConn(&buf, nil, false)

mask_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ func notzero(b []byte) int {
2929
}
3030

3131
func TestMaskBytes(t *testing.T) {
32+
t.Parallel()
3233
key := [4]byte{1, 2, 3, 4}
3334
for size := 1; size <= 1024; size++ {
3435
for align := 0; align < wordSize; align++ {

0 commit comments

Comments
 (0)