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
3c65a1df
Commit
3c65a1df
authored
Jul 06, 2015
by
Wandenberg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
try to make the test more stable
parent
4516ca59
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
88 additions
and
75 deletions
+88
-75
events_channel_spec.rb
misc/spec/mix/events_channel_spec.rb
+88
-75
No files found.
misc/spec/mix/events_channel_spec.rb
View file @
3c65a1df
...
...
@@ -26,6 +26,7 @@ describe "Events channel" do
EventMachine
.
stop
end
EM
.
add_timer
(
0.5
)
do
pub_1
=
EventMachine
::
HttpRequest
.
new
(
"
#{
nginx_address
}
/pub?id=
#{
channel
}
"
).
post
head:
headers
,
body:
body
pub_1
.
callback
do
expect
(
pub_1
).
to
be_http_status
(
200
).
with_body
...
...
@@ -33,6 +34,7 @@ describe "Events channel" do
end
end
end
end
it
"should send an event when a channel is deleted"
do
channel
=
'ch_test_send_event_channel_deleted'
...
...
@@ -43,7 +45,6 @@ describe "Events channel" do
pub_1
=
EventMachine
::
HttpRequest
.
new
(
"
#{
nginx_address
}
/pub?id=
#{
channel
}
"
).
post
head:
headers
,
body:
body
pub_1
.
callback
do
expect
(
pub_1
).
to
be_http_status
(
200
).
with_body
end
sub_1
=
EventMachine
::
HttpRequest
.
new
(
"
#{
nginx_address
}
/sub/
#{
conf
.
events_channel_id
}
"
).
get
head:
headers
sub_1
.
stream
do
|
chunk
|
...
...
@@ -51,6 +52,7 @@ describe "Events channel" do
EventMachine
.
stop
end
EM
.
add_timer
(
0.5
)
do
pub_2
=
EventMachine
::
HttpRequest
.
new
(
"
#{
nginx_address
}
/pub?id=
#{
channel
}
"
).
delete
head:
headers
pub_2
.
callback
do
expect
(
pub_2
).
to
be_http_status
(
200
).
without_body
...
...
@@ -58,6 +60,8 @@ describe "Events channel" do
end
end
end
end
end
it
"should send an event when a channel is collected by inactivity"
do
channel
=
'ch_test_send_event_channel_collected'
...
...
@@ -68,7 +72,6 @@ describe "Events channel" do
pub_1
=
EventMachine
::
HttpRequest
.
new
(
"
#{
nginx_address
}
/pub?id=
#{
channel
}
"
).
post
head:
headers
,
body:
body
pub_1
.
callback
do
expect
(
pub_1
).
to
be_http_status
(
200
).
with_body
end
sub_1
=
EventMachine
::
HttpRequest
.
new
(
"
#{
nginx_address
}
/sub/
#{
conf
.
events_channel_id
}
"
,
inactivity_timeout:
40
).
get
head:
headers
sub_1
.
stream
do
|
chunk
|
...
...
@@ -78,6 +81,7 @@ describe "Events channel" do
end
end
end
end
it
"should send an event when a client subscribe to a channel"
do
channel
=
'ch_test_send_event_client_subscribed'
...
...
@@ -88,7 +92,6 @@ describe "Events channel" do
pub_1
=
EventMachine
::
HttpRequest
.
new
(
"
#{
nginx_address
}
/pub?id=
#{
channel
}
"
).
post
head:
headers
,
body:
body
pub_1
.
callback
do
expect
(
pub_1
).
to
be_http_status
(
200
).
with_body
end
sub_1
=
EventMachine
::
HttpRequest
.
new
(
"
#{
nginx_address
}
/sub/
#{
conf
.
events_channel_id
}
"
).
get
head:
headers
sub_1
.
stream
do
|
chunk
|
...
...
@@ -96,10 +99,13 @@ describe "Events channel" do
EventMachine
.
stop
end
EM
.
add_timer
(
0.5
)
do
sub_2
=
EventMachine
::
HttpRequest
.
new
(
"
#{
nginx_address
}
/sub/
#{
channel
}
"
).
get
head:
headers
end
end
end
end
end
it
"should send an event when a websocket client subscribe to a channel"
do
channel
=
'ch_test_send_event_websocket_client_subscribed'
...
...
@@ -110,7 +116,6 @@ describe "Events channel" do
pub_1
=
EventMachine
::
HttpRequest
.
new
(
"
#{
nginx_address
}
/pub?id=
#{
channel
}
"
).
post
head:
headers
,
body:
body
pub_1
.
callback
do
expect
(
pub_1
).
to
be_http_status
(
200
).
with_body
end
sub_1
=
WebSocket
::
EventMachine
::
Client
.
connect
(
uri:
"ws://
#{
nginx_host
}
:
#{
nginx_port
}
/sub/
#{
conf
.
events_channel_id
}
"
)
sub_1
.
onmessage
do
|
text
,
type
|
...
...
@@ -118,10 +123,13 @@ describe "Events channel" do
EventMachine
.
stop
end
EM
.
add_timer
(
0.5
)
do
ws
=
WebSocket
::
EventMachine
::
Client
.
connect
(
uri:
"ws://
#{
nginx_host
}
:
#{
nginx_port
}
/sub/
#{
channel
}
"
)
end
end
end
end
end
it
"should send an event when a long-polling client subscribe to a channel"
do
channel
=
'ch_test_send_event_client_subscribed'
...
...
@@ -132,7 +140,6 @@ describe "Events channel" do
pub_1
=
EventMachine
::
HttpRequest
.
new
(
"
#{
nginx_address
}
/pub?id=
#{
channel
}
"
).
post
head:
headers
,
body:
body
pub_1
.
callback
do
expect
(
pub_1
).
to
be_http_status
(
200
).
with_body
end
response
=
''
sub_1
=
EventMachine
::
HttpRequest
.
new
(
"
#{
nginx_address
}
/sub/
#{
conf
.
events_channel_id
}
"
).
get
head:
headers
...
...
@@ -142,10 +149,13 @@ describe "Events channel" do
EventMachine
.
stop
end
EM
.
add_timer
(
0.5
)
do
sub_2
=
EventMachine
::
HttpRequest
.
new
(
"
#{
nginx_address
}
/sub/
#{
channel
}
"
).
get
head:
headers
end
end
end
end
end
it
"should send an event when a client unsubscribe to a channel by timeout"
do
channel
=
'ch_test_send_event_client_unsubscribed'
...
...
@@ -174,12 +184,15 @@ describe "Events channel" do
EventMachine
.
run
do
sub_1
=
EventMachine
::
HttpRequest
.
new
(
"
#{
nginx_address
}
/sub/
#{
channel
}
"
).
get
head:
headers
EM
.
add_timer
(
0.5
)
do
sub_2
=
EventMachine
::
HttpRequest
.
new
(
"
#{
nginx_address
}
/sub/
#{
conf
.
events_channel_id
}
"
).
get
head:
headers
sub_2
.
stream
do
|
chunk
|
expect
(
chunk
).
to
eql
(
%(text: {"type": "client_unsubscribed", "channel": "#{channel}"}\nchannel: #{conf.events_channel_id})
)
EventMachine
.
stop
end
end
EM
.
add_timer
(
1
)
do
pub_1
=
EventMachine
::
HttpRequest
.
new
(
"
#{
nginx_address
}
/pub?id=
#{
channel
}
"
).
delete
head:
headers
pub_1
.
callback
do
expect
(
pub_1
).
to
be_http_status
(
200
).
without_body
...
...
@@ -187,6 +200,7 @@ describe "Events channel" do
end
end
end
end
it
"should never collect the events channel by inactivity"
do
channel
=
'ch_test_not_collect_events_channel'
...
...
@@ -197,7 +211,6 @@ describe "Events channel" do
pub_1
=
EventMachine
::
HttpRequest
.
new
(
"
#{
nginx_address
}
/pub?id=
#{
channel
}
"
).
post
head:
headers
,
body:
body
pub_1
.
callback
do
expect
(
pub_1
).
to
be_http_status
(
200
).
with_body
end
pub_2
=
EventMachine
::
HttpRequest
.
new
(
"
#{
nginx_address
}
/pub?id=
#{
channel
}
"
).
get
head:
headers
pub_2
.
callback
do
...
...
@@ -207,7 +220,6 @@ describe "Events channel" do
expect
(
response
[
"published_messages"
].
to_i
).
to
eql
(
1
)
expect
(
response
[
"stored_messages"
].
to_i
).
to
eql
(
1
)
expect
(
response
[
"subscribers"
].
to_i
).
to
eql
(
0
)
end
pub_3
=
EventMachine
::
HttpRequest
.
new
(
"
#{
nginx_address
}
/pub?id=
#{
conf
.
events_channel_id
}
"
).
get
head:
headers
pub_3
.
callback
do
...
...
@@ -218,12 +230,13 @@ describe "Events channel" do
expect
(
response
[
"stored_messages"
].
to_i
).
to
eql
(
1
)
expect
(
response
[
"subscribers"
].
to_i
).
to
eql
(
0
)
end
end
end
EM
.
add_timer
(
35
)
do
pub_4
=
EventMachine
::
HttpRequest
.
new
(
"
#{
nginx_address
}
/pub?id=
#{
channel
}
"
).
get
head:
headers
pub_4
.
callback
do
expect
(
pub_4
).
to
be_http_status
(
404
).
without_body
end
pub_5
=
EventMachine
::
HttpRequest
.
new
(
"
#{
nginx_address
}
/pub?id=
#{
conf
.
events_channel_id
}
"
).
get
head:
headers
pub_5
.
callback
do
...
...
@@ -234,6 +247,7 @@ describe "Events channel" do
expect
(
response
[
"stored_messages"
].
to_i
).
to
eql
(
1
)
expect
(
response
[
"subscribers"
].
to_i
).
to
eql
(
0
)
end
end
EM
.
add_timer
(
35
)
do
pub_6
=
EventMachine
::
HttpRequest
.
new
(
"
#{
nginx_address
}
/pub?id=
#{
conf
.
events_channel_id
}
"
).
get
head:
headers
...
...
@@ -457,4 +471,3 @@ describe "Events channel" do
end
end
end
#TODO add docs
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