Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
caddy
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
caddy
Commits
958abcfa
Commit
958abcfa
authored
May 08, 2017
by
Tw
Committed by
Matt Holt
May 08, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
proxy: synchronize websocket test (#1654)
fix issue #1652 Signed-off-by:
Tw
<
tw19881113@gmail.com
>
parent
ea24744b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
4 deletions
+10
-4
caddyhttp/proxy/proxy_test.go
caddyhttp/proxy/proxy_test.go
+10
-4
No files found.
caddyhttp/proxy/proxy_test.go
View file @
958abcfa
...
@@ -247,8 +247,8 @@ func TestWebSocketReverseProxyNonHijackerPanic(t *testing.T) {
...
@@ -247,8 +247,8 @@ func TestWebSocketReverseProxyNonHijackerPanic(t *testing.T) {
func
TestWebSocketReverseProxyServeHTTPHandler
(
t
*
testing
.
T
)
{
func
TestWebSocketReverseProxyServeHTTPHandler
(
t
*
testing
.
T
)
{
// No-op websocket backend simply allows the WS connection to be
// No-op websocket backend simply allows the WS connection to be
// accepted then it will be immediately closed. Perfect for testing.
// accepted then it will be immediately closed. Perfect for testing.
var
connCount
int32
accepted
:=
make
(
chan
struct
{})
wsNop
:=
httptest
.
NewServer
(
websocket
.
Handler
(
func
(
ws
*
websocket
.
Conn
)
{
atomic
.
AddInt32
(
&
connCount
,
1
)
}))
wsNop
:=
httptest
.
NewServer
(
websocket
.
Handler
(
func
(
ws
*
websocket
.
Conn
)
{
close
(
accepted
)
}))
defer
wsNop
.
Close
()
defer
wsNop
.
Close
()
// Get proxy to use for the test
// Get proxy to use for the test
...
@@ -279,8 +279,14 @@ func TestWebSocketReverseProxyServeHTTPHandler(t *testing.T) {
...
@@ -279,8 +279,14 @@ func TestWebSocketReverseProxyServeHTTPHandler(t *testing.T) {
if
!
bytes
.
Equal
(
actual
,
expected
)
{
if
!
bytes
.
Equal
(
actual
,
expected
)
{
t
.
Errorf
(
"Expected backend to accept response:
\n
'%s'
\n
Actually got:
\n
'%s'"
,
expected
,
actual
)
t
.
Errorf
(
"Expected backend to accept response:
\n
'%s'
\n
Actually got:
\n
'%s'"
,
expected
,
actual
)
}
}
if
got
,
want
:=
atomic
.
LoadInt32
(
&
connCount
),
int32
(
1
);
got
!=
want
{
t
.
Errorf
(
"Expected %d websocket connection, got %d"
,
want
,
got
)
// wait a minute for backend handling, see issue 1654.
time
.
Sleep
(
10
*
time
.
Millisecond
)
select
{
case
<-
accepted
:
default
:
t
.
Error
(
"Expect a accepted websocket connection, but not"
)
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment