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
Hide 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,9 +26,11 @@ describe "Events channel" do
...
@@ -26,9 +26,11 @@ describe "Events channel" do
EventMachine
.
stop
EventMachine
.
stop
end
end
pub_1
=
EventMachine
::
HttpRequest
.
new
(
"
#{
nginx_address
}
/pub?id=
#{
channel
}
"
).
post
head:
headers
,
body:
body
EM
.
add_timer
(
0.5
)
do
pub_1
.
callback
do
pub_1
=
EventMachine
::
HttpRequest
.
new
(
"
#{
nginx_address
}
/pub?id=
#{
channel
}
"
).
post
head:
headers
,
body:
body
expect
(
pub_1
).
to
be_http_status
(
200
).
with_body
pub_1
.
callback
do
expect
(
pub_1
).
to
be_http_status
(
200
).
with_body
end
end
end
end
end
end
end
...
@@ -43,17 +45,19 @@ describe "Events channel" do
...
@@ -43,17 +45,19 @@ describe "Events channel" do
pub_1
=
EventMachine
::
HttpRequest
.
new
(
"
#{
nginx_address
}
/pub?id=
#{
channel
}
"
).
post
head:
headers
,
body:
body
pub_1
=
EventMachine
::
HttpRequest
.
new
(
"
#{
nginx_address
}
/pub?id=
#{
channel
}
"
).
post
head:
headers
,
body:
body
pub_1
.
callback
do
pub_1
.
callback
do
expect
(
pub_1
).
to
be_http_status
(
200
).
with_body
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
=
EventMachine
::
HttpRequest
.
new
(
"
#{
nginx_address
}
/sub/
#{
conf
.
events_channel_id
}
"
).
get
head:
headers
sub_1
.
stream
do
|
chunk
|
sub_1
.
stream
do
|
chunk
|
expect
(
chunk
).
to
eql
(
%(text: {"type": "channel_destroyed", "channel": "#{channel}"}\nchannel: #{conf.events_channel_id})
)
expect
(
chunk
).
to
eql
(
%(text: {"type": "channel_destroyed", "channel": "#{channel}"}\nchannel: #{conf.events_channel_id})
)
EventMachine
.
stop
EventMachine
.
stop
end
end
pub_2
=
EventMachine
::
HttpRequest
.
new
(
"
#{
nginx_address
}
/pub?id=
#{
channel
}
"
).
delete
head:
headers
EM
.
add_timer
(
0.5
)
do
pub_2
.
callback
do
pub_2
=
EventMachine
::
HttpRequest
.
new
(
"
#{
nginx_address
}
/pub?id=
#{
channel
}
"
).
delete
head:
headers
expect
(
pub_2
).
to
be_http_status
(
200
).
without_body
pub_2
.
callback
do
expect
(
pub_2
).
to
be_http_status
(
200
).
without_body
end
end
end
end
end
end
end
end
...
@@ -68,12 +72,12 @@ describe "Events channel" do
...
@@ -68,12 +72,12 @@ describe "Events channel" do
pub_1
=
EventMachine
::
HttpRequest
.
new
(
"
#{
nginx_address
}
/pub?id=
#{
channel
}
"
).
post
head:
headers
,
body:
body
pub_1
=
EventMachine
::
HttpRequest
.
new
(
"
#{
nginx_address
}
/pub?id=
#{
channel
}
"
).
post
head:
headers
,
body:
body
pub_1
.
callback
do
pub_1
.
callback
do
expect
(
pub_1
).
to
be_http_status
(
200
).
with_body
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
=
EventMachine
::
HttpRequest
.
new
(
"
#{
nginx_address
}
/sub/
#{
conf
.
events_channel_id
}
"
,
inactivity_timeout:
40
).
get
head:
headers
sub_1
.
stream
do
|
chunk
|
sub_1
.
stream
do
|
chunk
|
expect
(
chunk
).
to
eql
(
%(text: {"type": "channel_destroyed", "channel": "#{channel}"}\nchannel: #{conf.events_channel_id})
)
expect
(
chunk
).
to
eql
(
%(text: {"type": "channel_destroyed", "channel": "#{channel}"}\nchannel: #{conf.events_channel_id})
)
EventMachine
.
stop
EventMachine
.
stop
end
end
end
end
end
end
end
...
@@ -88,15 +92,17 @@ describe "Events channel" do
...
@@ -88,15 +92,17 @@ describe "Events channel" do
pub_1
=
EventMachine
::
HttpRequest
.
new
(
"
#{
nginx_address
}
/pub?id=
#{
channel
}
"
).
post
head:
headers
,
body:
body
pub_1
=
EventMachine
::
HttpRequest
.
new
(
"
#{
nginx_address
}
/pub?id=
#{
channel
}
"
).
post
head:
headers
,
body:
body
pub_1
.
callback
do
pub_1
.
callback
do
expect
(
pub_1
).
to
be_http_status
(
200
).
with_body
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
=
EventMachine
::
HttpRequest
.
new
(
"
#{
nginx_address
}
/sub/
#{
conf
.
events_channel_id
}
"
).
get
head:
headers
sub_1
.
stream
do
|
chunk
|
sub_1
.
stream
do
|
chunk
|
expect
(
chunk
).
to
eql
(
%(text: {"type": "client_subscribed", "channel": "#{channel}"}\nchannel: #{conf.events_channel_id})
)
expect
(
chunk
).
to
eql
(
%(text: {"type": "client_subscribed", "channel": "#{channel}"}\nchannel: #{conf.events_channel_id})
)
EventMachine
.
stop
EventMachine
.
stop
end
end
sub_2
=
EventMachine
::
HttpRequest
.
new
(
"
#{
nginx_address
}
/sub/
#{
channel
}
"
).
get
head:
headers
EM
.
add_timer
(
0.5
)
do
sub_2
=
EventMachine
::
HttpRequest
.
new
(
"
#{
nginx_address
}
/sub/
#{
channel
}
"
).
get
head:
headers
end
end
end
end
end
end
end
end
...
@@ -110,15 +116,17 @@ describe "Events channel" do
...
@@ -110,15 +116,17 @@ describe "Events channel" do
pub_1
=
EventMachine
::
HttpRequest
.
new
(
"
#{
nginx_address
}
/pub?id=
#{
channel
}
"
).
post
head:
headers
,
body:
body
pub_1
=
EventMachine
::
HttpRequest
.
new
(
"
#{
nginx_address
}
/pub?id=
#{
channel
}
"
).
post
head:
headers
,
body:
body
pub_1
.
callback
do
pub_1
.
callback
do
expect
(
pub_1
).
to
be_http_status
(
200
).
with_body
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
=
WebSocket
::
EventMachine
::
Client
.
connect
(
uri:
"ws://
#{
nginx_host
}
:
#{
nginx_port
}
/sub/
#{
conf
.
events_channel_id
}
"
)
sub_1
.
onmessage
do
|
text
,
type
|
sub_1
.
onmessage
do
|
text
,
type
|
expect
(
text
).
to
eql
(
%(text: {"type": "client_subscribed", "channel": "#{channel}"}\nchannel: #{conf.events_channel_id})
)
expect
(
text
).
to
eql
(
%(text: {"type": "client_subscribed", "channel": "#{channel}"}\nchannel: #{conf.events_channel_id})
)
EventMachine
.
stop
EventMachine
.
stop
end
end
ws
=
WebSocket
::
EventMachine
::
Client
.
connect
(
uri:
"ws://
#{
nginx_host
}
:
#{
nginx_port
}
/sub/
#{
channel
}
"
)
EM
.
add_timer
(
0.5
)
do
ws
=
WebSocket
::
EventMachine
::
Client
.
connect
(
uri:
"ws://
#{
nginx_host
}
:
#{
nginx_port
}
/sub/
#{
channel
}
"
)
end
end
end
end
end
end
end
end
...
@@ -132,17 +140,19 @@ describe "Events channel" do
...
@@ -132,17 +140,19 @@ describe "Events channel" do
pub_1
=
EventMachine
::
HttpRequest
.
new
(
"
#{
nginx_address
}
/pub?id=
#{
channel
}
"
).
post
head:
headers
,
body:
body
pub_1
=
EventMachine
::
HttpRequest
.
new
(
"
#{
nginx_address
}
/pub?id=
#{
channel
}
"
).
post
head:
headers
,
body:
body
pub_1
.
callback
do
pub_1
.
callback
do
expect
(
pub_1
).
to
be_http_status
(
200
).
with_body
expect
(
pub_1
).
to
be_http_status
(
200
).
with_body
end
response
=
''
response
=
''
sub_1
=
EventMachine
::
HttpRequest
.
new
(
"
#{
nginx_address
}
/sub/
#{
conf
.
events_channel_id
}
"
).
get
head:
headers
sub_1
=
EventMachine
::
HttpRequest
.
new
(
"
#{
nginx_address
}
/sub/
#{
conf
.
events_channel_id
}
"
).
get
head:
headers
sub_1
.
stream
{
|
chunk
|
response
+=
chunk
}
sub_1
.
stream
{
|
chunk
|
response
+=
chunk
}
sub_1
.
callback
do
sub_1
.
callback
do
expect
(
response
).
to
eql
(
%(text: {"type": "client_subscribed", "channel": "#{channel}"}\nchannel: #{conf.events_channel_id})
)
expect
(
response
).
to
eql
(
%(text: {"type": "client_subscribed", "channel": "#{channel}"}\nchannel: #{conf.events_channel_id})
)
EventMachine
.
stop
EventMachine
.
stop
end
end
sub_2
=
EventMachine
::
HttpRequest
.
new
(
"
#{
nginx_address
}
/sub/
#{
channel
}
"
).
get
head:
headers
EM
.
add_timer
(
0.5
)
do
sub_2
=
EventMachine
::
HttpRequest
.
new
(
"
#{
nginx_address
}
/sub/
#{
channel
}
"
).
get
head:
headers
end
end
end
end
end
end
end
end
...
@@ -174,15 +184,19 @@ describe "Events channel" do
...
@@ -174,15 +184,19 @@ describe "Events channel" do
EventMachine
.
run
do
EventMachine
.
run
do
sub_1
=
EventMachine
::
HttpRequest
.
new
(
"
#{
nginx_address
}
/sub/
#{
channel
}
"
).
get
head:
headers
sub_1
=
EventMachine
::
HttpRequest
.
new
(
"
#{
nginx_address
}
/sub/
#{
channel
}
"
).
get
head:
headers
sub_2
=
EventMachine
::
HttpRequest
.
new
(
"
#{
nginx_address
}
/sub/
#{
conf
.
events_channel_id
}
"
).
get
head:
headers
EM
.
add_timer
(
0.5
)
do
sub_2
.
stream
do
|
chunk
|
sub_2
=
EventMachine
::
HttpRequest
.
new
(
"
#{
nginx_address
}
/sub/
#{
conf
.
events_channel_id
}
"
).
get
head:
headers
expect
(
chunk
).
to
eql
(
%(text: {"type": "client_unsubscribed", "channel": "#{channel}"}\nchannel: #{conf.events_channel_id})
)
sub_2
.
stream
do
|
chunk
|
EventMachine
.
stop
expect
(
chunk
).
to
eql
(
%(text: {"type": "client_unsubscribed", "channel": "#{channel}"}\nchannel: #{conf.events_channel_id})
)
EventMachine
.
stop
end
end
end
pub_1
=
EventMachine
::
HttpRequest
.
new
(
"
#{
nginx_address
}
/pub?id=
#{
channel
}
"
).
delete
head:
headers
EM
.
add_timer
(
1
)
do
pub_1
.
callback
do
pub_1
=
EventMachine
::
HttpRequest
.
new
(
"
#{
nginx_address
}
/pub?id=
#{
channel
}
"
).
delete
head:
headers
expect
(
pub_1
).
to
be_http_status
(
200
).
without_body
pub_1
.
callback
do
expect
(
pub_1
).
to
be_http_status
(
200
).
without_body
end
end
end
end
end
end
end
...
@@ -197,42 +211,42 @@ describe "Events channel" do
...
@@ -197,42 +211,42 @@ describe "Events channel" do
pub_1
=
EventMachine
::
HttpRequest
.
new
(
"
#{
nginx_address
}
/pub?id=
#{
channel
}
"
).
post
head:
headers
,
body:
body
pub_1
=
EventMachine
::
HttpRequest
.
new
(
"
#{
nginx_address
}
/pub?id=
#{
channel
}
"
).
post
head:
headers
,
body:
body
pub_1
.
callback
do
pub_1
.
callback
do
expect
(
pub_1
).
to
be_http_status
(
200
).
with_body
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
=
EventMachine
::
HttpRequest
.
new
(
"
#{
nginx_address
}
/pub?id=
#{
channel
}
"
).
get
head:
headers
pub_2
.
callback
do
pub_2
.
callback
do
expect
(
pub_2
).
to
be_http_status
(
200
).
with_body
expect
(
pub_2
).
to
be_http_status
(
200
).
with_body
response
=
JSON
.
parse
(
pub_2
.
response
)
response
=
JSON
.
parse
(
pub_2
.
response
)
expect
(
response
[
"channel"
].
to_s
).
to
eql
(
channel
)
expect
(
response
[
"channel"
].
to_s
).
to
eql
(
channel
)
expect
(
response
[
"published_messages"
].
to_i
).
to
eql
(
1
)
expect
(
response
[
"published_messages"
].
to_i
).
to
eql
(
1
)
expect
(
response
[
"stored_messages"
].
to_i
).
to
eql
(
1
)
expect
(
response
[
"stored_messages"
].
to_i
).
to
eql
(
1
)
expect
(
response
[
"subscribers"
].
to_i
).
to
eql
(
0
)
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
=
EventMachine
::
HttpRequest
.
new
(
"
#{
nginx_address
}
/pub?id=
#{
conf
.
events_channel_id
}
"
).
get
head:
headers
pub_3
.
callback
do
pub_3
.
callback
do
expect
(
pub_3
).
to
be_http_status
(
200
).
with_body
expect
(
pub_3
).
to
be_http_status
(
200
).
with_body
response
=
JSON
.
parse
(
pub_3
.
response
)
response
=
JSON
.
parse
(
pub_3
.
response
)
expect
(
response
[
"channel"
].
to_s
).
to
eql
(
conf
.
events_channel_id
)
expect
(
response
[
"channel"
].
to_s
).
to
eql
(
conf
.
events_channel_id
)
expect
(
response
[
"published_messages"
].
to_i
).
to
eql
(
1
)
expect
(
response
[
"published_messages"
].
to_i
).
to
eql
(
1
)
expect
(
response
[
"stored_messages"
].
to_i
).
to
eql
(
1
)
expect
(
response
[
"stored_messages"
].
to_i
).
to
eql
(
1
)
expect
(
response
[
"subscribers"
].
to_i
).
to
eql
(
0
)
expect
(
response
[
"subscribers"
].
to_i
).
to
eql
(
0
)
end
end
end
end
EM
.
add_timer
(
35
)
do
EM
.
add_timer
(
35
)
do
pub_4
=
EventMachine
::
HttpRequest
.
new
(
"
#{
nginx_address
}
/pub?id=
#{
channel
}
"
).
get
head:
headers
pub_4
=
EventMachine
::
HttpRequest
.
new
(
"
#{
nginx_address
}
/pub?id=
#{
channel
}
"
).
get
head:
headers
pub_4
.
callback
do
pub_4
.
callback
do
expect
(
pub_4
).
to
be_http_status
(
404
).
without_body
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
=
EventMachine
::
HttpRequest
.
new
(
"
#{
nginx_address
}
/pub?id=
#{
conf
.
events_channel_id
}
"
).
get
head:
headers
pub_5
.
callback
do
pub_5
.
callback
do
expect
(
pub_5
).
to
be_http_status
(
200
).
with_body
expect
(
pub_5
).
to
be_http_status
(
200
).
with_body
response
=
JSON
.
parse
(
pub_5
.
response
)
response
=
JSON
.
parse
(
pub_5
.
response
)
expect
(
response
[
"channel"
].
to_s
).
to
eql
(
conf
.
events_channel_id
)
expect
(
response
[
"channel"
].
to_s
).
to
eql
(
conf
.
events_channel_id
)
expect
(
response
[
"published_messages"
].
to_i
).
to
eql
(
2
)
expect
(
response
[
"published_messages"
].
to_i
).
to
eql
(
2
)
expect
(
response
[
"stored_messages"
].
to_i
).
to
eql
(
1
)
expect
(
response
[
"stored_messages"
].
to_i
).
to
eql
(
1
)
expect
(
response
[
"subscribers"
].
to_i
).
to
eql
(
0
)
expect
(
response
[
"subscribers"
].
to_i
).
to
eql
(
0
)
end
end
end
EM
.
add_timer
(
35
)
do
EM
.
add_timer
(
35
)
do
...
@@ -457,4 +471,3 @@ describe "Events channel" do
...
@@ -457,4 +471,3 @@ describe "Events channel" do
end
end
end
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