Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nginx-push-stream-module
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
nginx-push-stream-module
Commits
f14dba7c
Commit
f14dba7c
authored
Jul 05, 2015
by
Wandenberg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
simplify some test configuration
parent
47ec083e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
41 deletions
+7
-41
websocket_spec.rb
misc/spec/subscriber/websocket_spec.rb
+7
-41
No files found.
misc/spec/subscriber/websocket_spec.rb
View file @
f14dba7c
...
@@ -14,6 +14,11 @@ describe "Subscriber WebSocket" do
...
@@ -14,6 +14,11 @@ describe "Subscriber WebSocket" do
# positional channel path
# positional channel path
push_stream_channels_path $1;
push_stream_channels_path $1;
# allow subscriber to publish
push_stream_websocket_allow_publish on;
# store messages
push_stream_store_messages on;
}
}
}
}
}
}
...
@@ -304,29 +309,11 @@ describe "Subscriber WebSocket" do
...
@@ -304,29 +309,11 @@ describe "Subscriber WebSocket" do
end
end
it
"should publish message to all subscribed channels using the same stream"
do
it
"should publish message to all subscribed channels using the same stream"
do
configuration
=
config
.
merge
({
:message_template
=>
'{\"channel\":\"~channel~\", \"id\":\"~id~\", \"message\":\"~text~\"}'
,
:extra_location
=>
%q{
location ~ /ws/(.*)? {
# activate websocket mode for this location
push_stream_subscriber websocket;
# positional channel path
push_stream_channels_path $1;
# allow subscriber to publish
push_stream_websocket_allow_publish on;
# store messages
push_stream_store_messages on;
}
}
})
frame
=
"%c%c%c%c%c%c%c%c%c%c%c"
%
[
0x81
,
0x85
,
0xBD
,
0xD0
,
0xE5
,
0x2A
,
0xD5
,
0xB5
,
0x89
,
0x46
,
0xD2
]
#send 'hello' text
frame
=
"%c%c%c%c%c%c%c%c%c%c%c"
%
[
0x81
,
0x85
,
0xBD
,
0xD0
,
0xE5
,
0x2A
,
0xD5
,
0xB5
,
0x89
,
0x46
,
0xD2
]
#send 'hello' text
request
=
"GET /ws/ch2/ch1 HTTP/1.0
\r\n
Connection: Upgrade
\r\n
Sec-WebSocket-Key: /mQoZf6pRiv8+6o72GncLQ==
\r\n
Upgrade: websocket
\r\n
Sec-WebSocket-Version: 8
\r\n
"
request
=
"GET /ws/ch2/ch1 HTTP/1.0
\r\n
Connection: Upgrade
\r\n
Sec-WebSocket-Key: /mQoZf6pRiv8+6o72GncLQ==
\r\n
Upgrade: websocket
\r\n
Sec-WebSocket-Version: 8
\r\n
"
nginx_run_server
(
config
uration
)
do
|
conf
|
nginx_run_server
(
config
.
merge
({
message_template:
'{\"channel\":\"~channel~\", \"id\":\"~id~\", \"message\":\"~text~\"}'
})
)
do
|
conf
|
socket
=
open_socket
(
nginx_host
,
nginx_port
)
socket
=
open_socket
(
nginx_host
,
nginx_port
)
socket
.
print
(
"
#{
request
}
\r\n
"
)
socket
.
print
(
"
#{
request
}
\r\n
"
)
headers
,
body
=
read_response_on_socket
(
socket
)
headers
,
body
=
read_response_on_socket
(
socket
)
...
@@ -380,30 +367,11 @@ describe "Subscriber WebSocket" do
...
@@ -380,30 +367,11 @@ describe "Subscriber WebSocket" do
it
"should publish large message"
do
it
"should publish large message"
do
channel
=
'ch_test_publish_large_message'
channel
=
'ch_test_publish_large_message'
configuration
=
config
.
merge
({
:shared_memory_size
=>
'15m'
,
:message_template
=>
'{\"channel\":\"~channel~\", \"id\":\"~id~\", \"message\":\"~text~\"}'
,
:extra_location
=>
%q{
location ~ /ws/(.*)? {
# activate websocket mode for this location
push_stream_subscriber websocket;
# positional channel path
push_stream_channels_path $1;
# allow subscriber to publish
push_stream_websocket_allow_publish on;
# store messages
push_stream_store_messages on;
}
}
})
small_message
=
"^|"
+
(
"0123456789"
*
1020
)
+
"|$"
small_message
=
"^|"
+
(
"0123456789"
*
1020
)
+
"|$"
large_message
=
"^|"
+
(
"0123456789"
*
419430
)
+
"|$"
large_message
=
"^|"
+
(
"0123456789"
*
419430
)
+
"|$"
received_messages
=
0
;
received_messages
=
0
;
nginx_run_server
(
config
uration
,
timeout:
10
)
do
|
conf
|
nginx_run_server
(
config
.
merge
({
shared_memory_size:
'15m'
,
message_template:
'{\"channel\":\"~channel~\", \"id\":\"~id~\", \"message\":\"~text~\"}'
})
,
timeout:
10
)
do
|
conf
|
EventMachine
.
run
do
EventMachine
.
run
do
ws
=
WebSocket
::
EventMachine
::
Client
.
connect
(
:uri
=>
"ws://
#{
nginx_host
}
:
#{
nginx_port
}
/ws/
#{
channel
}
"
)
ws
=
WebSocket
::
EventMachine
::
Client
.
connect
(
:uri
=>
"ws://
#{
nginx_host
}
:
#{
nginx_port
}
/ws/
#{
channel
}
"
)
ws
.
onmessage
do
|
text
,
type
|
ws
.
onmessage
do
|
text
,
type
|
...
@@ -597,8 +565,6 @@ describe "Subscriber WebSocket" do
...
@@ -597,8 +565,6 @@ describe "Subscriber WebSocket" do
channel
=
'ch_test_data_after_close_frame_parse_request_line'
channel
=
'ch_test_data_after_close_frame_parse_request_line'
pid
=
pid2
=
0
pid
=
pid2
=
0
frame
=
"%c%c%c%c%c%c"
%
[
0x8A
,
0x80
,
0xBD
,
0xD0
,
0xE5
,
0x2A
]
#send 'pong' frame
request
=
"GET /ws/
#{
channel
}
.b1 HTTP/1.1
\r\n
Host: localhost
\r\n
Connection: Upgrade
\r\n
Sec-WebSocket-Key: /mQoZf6pRiv8+6o72GncLQ==
\r\n
Upgrade: websocket
\r\n
Sec-WebSocket-Version: 8
\r\n
"
request
=
"GET /ws/
#{
channel
}
.b1 HTTP/1.1
\r\n
Host: localhost
\r\n
Connection: Upgrade
\r\n
Sec-WebSocket-Key: /mQoZf6pRiv8+6o72GncLQ==
\r\n
Upgrade: websocket
\r\n
Sec-WebSocket-Version: 8
\r\n
"
nginx_run_server
(
config
.
merge
(
:subscriber_connection_ttl
=>
'1s'
))
do
|
conf
|
nginx_run_server
(
config
.
merge
(
:subscriber_connection_ttl
=>
'1s'
))
do
|
conf
|
...
...
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