good morning!!!!
Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
W
websocket
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
github
nhooyr
websocket
Commits
6975801d
Unverified
Commit
6975801d
authored
5 years ago
by
Anmol Sethi
Browse files
Options
Downloads
Patches
Plain Diff
Fix race in tests
parent
d0926864
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
assert_test.go
+1
-1
1 addition, 1 deletion
assert_test.go
autobahn_test.go
+5
-0
5 additions, 0 deletions
autobahn_test.go
conn_test.go
+5
-10
5 additions, 10 deletions
conn_test.go
with
11 additions
and
11 deletions
assert_test.go
+
1
−
1
View file @
6975801d
...
...
@@ -28,7 +28,7 @@ func echoJSON(t *testing.T, c *websocket.Conn, n int) {
slog
.
Helper
()
s
:=
randString
(
t
,
n
)
writeJSON
(
t
,
c
,
s
)
go
writeJSON
(
t
,
c
,
s
)
readJSON
(
t
,
c
,
s
)
}
...
...
This diff is collapsed.
Click to expand it.
autobahn_test.go
+
5
−
0
View file @
6975801d
...
...
@@ -8,6 +8,7 @@ import (
"fmt"
"io/ioutil"
"net"
"os"
"os/exec"
"strconv"
"strings"
...
...
@@ -36,6 +37,10 @@ var autobahnCases = []string{"*"}
func
TestAutobahn
(
t
*
testing
.
T
)
{
t
.
Parallel
()
if
os
.
Getenv
(
"AUTOBAHN_TEST"
)
==
""
{
t
.
SkipNow
()
}
ctx
,
cancel
:=
context
.
WithTimeout
(
context
.
Background
(),
time
.
Minute
*
15
)
defer
cancel
()
...
...
This diff is collapsed.
Click to expand it.
conn_test.go
+
5
−
10
View file @
6975801d
...
...
@@ -39,7 +39,7 @@ func TestConn(t *testing.T) {
for
i
:=
0
;
i
<
1
;
i
++
{
t
.
Run
(
""
,
func
(
t
*
testing
.
T
)
{
ctx
,
cancel
:=
context
.
WithTimeout
(
context
.
Background
(),
time
.
Second
)
ctx
,
cancel
:=
context
.
WithTimeout
(
context
.
Background
(),
time
.
Second
*
5
)
defer
cancel
()
c1
,
c2
:=
websocketPipe
(
t
)
...
...
@@ -49,6 +49,7 @@ func TestConn(t *testing.T) {
assertCloseStatus
(
t
,
websocket
.
StatusNormalClosure
,
err
)
})
defer
wait
()
defer
cancel
()
c2
.
SetReadLimit
(
1
<<
30
)
...
...
@@ -63,12 +64,6 @@ func TestConn(t *testing.T) {
})
}
type
writerFunc
func
(
p
[]
byte
)
(
int
,
error
)
func
(
f
writerFunc
)
Write
(
p
[]
byte
)
(
int
,
error
)
{
return
f
(
p
)
}
// echoLoop echos every msg received from c until an error
// occurs or the context expires.
// The read limit is set to 1 << 30.
...
...
@@ -104,7 +99,7 @@ func echoLoop(ctx context.Context, c *websocket.Conn) error {
}
}
func
randBool
(
t
testing
.
TB
)
bool
{
func
randBool
(
t
testing
.
TB
)
bool
{
return
randInt
(
t
,
2
)
==
1
}
...
...
@@ -117,7 +112,7 @@ func randInt(t testing.TB, max int) int {
type
testHijacker
struct
{
*
httptest
.
ResponseRecorder
serverConn
net
.
Conn
hijacked
chan
struct
{}
hijacked
chan
struct
{}
}
var
_
http
.
Hijacker
=
testHijacker
{}
...
...
@@ -154,7 +149,7 @@ type testTransport struct {
h
http
.
HandlerFunc
}
func
(
t
testTransport
)
RoundTrip
(
r
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
func
(
t
testTransport
)
RoundTrip
(
r
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
clientConn
,
serverConn
:=
net
.
Pipe
()
hj
:=
testHijacker
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment