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
9f95e062
Commit
9f95e062
authored
Feb 26, 2013
by
Wandenberg Peixoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
removing unused timeout parameter from EventMachine::HttpRequest calls
parent
49d9345e
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
178 additions
and
178 deletions
+178
-178
broadcast_properties_spec.rb
misc/spec/mix/broadcast_properties_spec.rb
+6
-6
channel_statistics_spec.rb
misc/spec/mix/channel_statistics_spec.rb
+22
-22
cleanup_memory_spec.rb
misc/spec/mix/cleanup_memory_spec.rb
+38
-38
send_signals_spec.rb
misc/spec/mix/send_signals_spec.rb
+8
-8
channel_id_collision_spec.rb
misc/spec/publisher/channel_id_collision_spec.rb
+1
-1
properties_spec.rb
misc/spec/publisher/properties_spec.rb
+26
-26
publish_messages_spec.rb
misc/spec/publisher/publish_messages_spec.rb
+10
-10
spec_helper.rb
misc/spec/spec_helper.rb
+2
-2
comunication_properties_spec.rb
misc/spec/subscriber/comunication_properties_spec.rb
+10
-10
padding_by_user_agent_spec.rb
misc/spec/subscriber/padding_by_user_agent_spec.rb
+15
-15
properties_spec.rb
misc/spec/subscriber/properties_spec.rb
+40
-40
No files found.
misc/spec/mix/broadcast_properties_spec.rb
View file @
9f95e062
...
...
@@ -18,13 +18,13 @@ describe "Broadcast Properties" do
nginx_run_server
(
config
,
:timeout
=>
5
)
do
|
conf
|
EventMachine
.
run
do
pub
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/pub?id='
+
channel
.
to_s
).
post
:head
=>
headers
,
:body
=>
body
,
:timeout
=>
30
pub
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/pub?id='
+
channel
.
to_s
).
post
:head
=>
headers
,
:body
=>
body
pub
.
callback
do
sub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
+
'/'
+
channel_broad_fail
).
get
:head
=>
headers
,
:timeout
=>
60
sub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
+
'/'
+
channel_broad_fail
).
get
:head
=>
headers
sub_1
.
callback
do
|
chunk
|
sub_1
.
response_header
.
status
.
should
eql
(
403
)
sub_2
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
+
'/'
+
channel_broad
).
get
:head
=>
headers
,
:timeout
=>
60
sub_2
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
+
'/'
+
channel_broad
).
get
:head
=>
headers
sub_2
.
stream
do
|
chunk2
|
chunk2
.
should
eql
(
"
#{
conf
.
header_template
}
\r\n
"
)
EventMachine
.
stop
...
...
@@ -44,12 +44,12 @@ describe "Broadcast Properties" do
nginx_run_server
(
config
.
merge
(
:broadcast_channel_max_qtd
=>
2
),
:timeout
=>
5
)
do
|
conf
|
EventMachine
.
run
do
pub
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/pub?id='
+
channel
.
to_s
).
post
:head
=>
headers
,
:body
=>
body
,
:timeout
=>
30
pub
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/pub?id='
+
channel
.
to_s
).
post
:head
=>
headers
,
:body
=>
body
pub
.
callback
do
sub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
+
'/'
+
channel_broad1
+
'/'
+
channel_broad2
+
'/'
+
channel_broad3
).
get
:head
=>
headers
,
:timeout
=>
60
sub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
+
'/'
+
channel_broad1
+
'/'
+
channel_broad2
+
'/'
+
channel_broad3
).
get
:head
=>
headers
sub_1
.
callback
do
|
chunk
|
sub_1
.
response_header
.
status
.
should
eql
(
403
)
sub_2
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
+
'/'
+
channel_broad1
+
'/'
+
channel_broad2
).
get
:head
=>
headers
,
:timeout
=>
60
sub_2
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
+
'/'
+
channel_broad1
+
'/'
+
channel_broad2
).
get
:head
=>
headers
sub_2
.
stream
do
EventMachine
.
stop
end
...
...
misc/spec/mix/channel_statistics_spec.rb
View file @
9f95e062
...
...
@@ -10,7 +10,7 @@ describe "Channel Statistics" do
nginx_run_server
(
config
,
:timeout
=>
5
)
do
|
conf
|
EventMachine
.
run
do
pub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/channels-stats?id='
+
channel
.
to_s
).
get
:head
=>
headers
,
:timeout
=>
30
pub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/channels-stats?id='
+
channel
.
to_s
).
get
:head
=>
headers
pub_1
.
callback
do
pub_1
.
response_header
.
status
.
should
eql
(
404
)
pub_1
.
response_header
.
content_length
.
should
eql
(
0
)
...
...
@@ -29,7 +29,7 @@ describe "Channel Statistics" do
publish_message
(
channel
,
headers
,
body
)
EventMachine
.
run
do
pub_2
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/channels-stats?id='
+
channel
.
to_s
).
get
:head
=>
headers
,
:timeout
=>
30
pub_2
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/channels-stats?id='
+
channel
.
to_s
).
get
:head
=>
headers
pub_2
.
callback
do
pub_2
.
response_header
.
status
.
should
eql
(
200
)
pub_2
.
response_header
.
content_length
.
should_not
eql
(
0
)
...
...
@@ -50,7 +50,7 @@ describe "Channel Statistics" do
nginx_run_server
(
config
,
:timeout
=>
5
)
do
|
conf
|
create_channel_by_subscribe
(
channel
,
headers
)
do
pub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/channels-stats?id='
+
channel
.
to_s
).
get
:head
=>
headers
,
:timeout
=>
30
pub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/channels-stats?id='
+
channel
.
to_s
).
get
:head
=>
headers
pub_1
.
callback
do
pub_1
.
response_header
.
status
.
should
eql
(
200
)
pub_1
.
response_header
.
content_length
.
should_not
eql
(
0
)
...
...
@@ -68,7 +68,7 @@ describe "Channel Statistics" do
it
"should return detailed channels statistics without existing channels"
do
nginx_run_server
(
config
,
:timeout
=>
5
)
do
|
conf
|
EventMachine
.
run
do
pub_2
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/channels-stats?id=ALL'
).
get
:head
=>
headers
,
:timeout
=>
30
pub_2
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/channels-stats?id=ALL'
).
get
:head
=>
headers
pub_2
.
callback
do
pub_2
.
response_header
.
status
.
should
eql
(
200
)
pub_2
.
response_header
.
content_length
.
should_not
eql
(
0
)
...
...
@@ -89,7 +89,7 @@ describe "Channel Statistics" do
publish_message
(
channel
,
headers
,
body
)
EventMachine
.
run
do
pub_2
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/channels-stats?id=ALL'
).
get
:head
=>
headers
,
:timeout
=>
30
pub_2
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/channels-stats?id=ALL'
).
get
:head
=>
headers
pub_2
.
callback
do
pub_2
.
response_header
.
status
.
should
eql
(
200
)
pub_2
.
response_header
.
content_length
.
should_not
eql
(
0
)
...
...
@@ -114,7 +114,7 @@ describe "Channel Statistics" do
publish_message
(
channel
,
headers
,
body
)
EventMachine
.
run
do
pub_2
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/channels-stats?id=ALL'
).
get
:head
=>
headers
,
:timeout
=>
30
pub_2
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/channels-stats?id=ALL'
).
get
:head
=>
headers
pub_2
.
callback
do
pub_2
.
response_header
.
status
.
should
eql
(
200
)
pub_2
.
response_header
.
content_length
.
should_not
eql
(
0
)
...
...
@@ -138,7 +138,7 @@ describe "Channel Statistics" do
nginx_run_server
(
config
,
:timeout
=>
5
)
do
|
conf
|
create_channel_by_subscribe
(
channel
,
headers
)
do
pub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/channels-stats?id=ALL'
).
get
:head
=>
headers
,
:timeout
=>
30
pub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/channels-stats?id=ALL'
).
get
:head
=>
headers
pub_1
.
callback
do
pub_1
.
response_header
.
status
.
should
eql
(
200
)
pub_1
.
response_header
.
content_length
.
should_not
eql
(
0
)
...
...
@@ -157,7 +157,7 @@ describe "Channel Statistics" do
it
"should return summarized channels statistics for a nonexistent channel"
do
nginx_run_server
(
config
,
:timeout
=>
5
)
do
|
conf
|
EventMachine
.
run
do
pub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/channels-stats'
).
get
:head
=>
headers
,
:timeout
=>
30
pub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/channels-stats'
).
get
:head
=>
headers
pub_1
.
callback
do
pub_1
.
response_header
.
status
.
should
eql
(
200
)
pub_1
.
response_header
.
content_length
.
should_not
eql
(
0
)
...
...
@@ -179,7 +179,7 @@ describe "Channel Statistics" do
publish_message
(
channel
,
headers
,
body
)
EventMachine
.
run
do
pub_2
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/channels-stats'
).
get
:head
=>
headers
,
:timeout
=>
30
pub_2
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/channels-stats'
).
get
:head
=>
headers
pub_2
.
callback
do
pub_2
.
response_header
.
status
.
should
eql
(
200
)
pub_2
.
response_header
.
content_length
.
should_not
eql
(
0
)
...
...
@@ -203,7 +203,7 @@ describe "Channel Statistics" do
publish_message
(
channel
,
headers
,
body
)
EventMachine
.
run
do
pub_2
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/channels-stats'
).
get
:head
=>
headers
,
:timeout
=>
30
pub_2
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/channels-stats'
).
get
:head
=>
headers
pub_2
.
callback
do
pub_2
.
response_header
.
status
.
should
eql
(
200
)
pub_2
.
response_header
.
content_length
.
should_not
eql
(
0
)
...
...
@@ -225,7 +225,7 @@ describe "Channel Statistics" do
nginx_run_server
(
config
,
:timeout
=>
5
)
do
|
conf
|
create_channel_by_subscribe
(
channel
,
headers
)
do
pub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/channels-stats'
).
get
:head
=>
headers
,
:timeout
=>
30
pub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/channels-stats'
).
get
:head
=>
headers
pub_1
.
callback
do
pub_1
.
response_header
.
status
.
should
eql
(
200
)
pub_1
.
response_header
.
content_length
.
should_not
eql
(
0
)
...
...
@@ -348,7 +348,7 @@ describe "Channel Statistics" do
end
EventMachine
.
run
do
pub_2
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/channels-stats?id=ALL'
).
get
:head
=>
headers
,
:timeout
=>
30
pub_2
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/channels-stats?id=ALL'
).
get
:head
=>
headers
pub_2
.
callback
do
pub_2
.
response_header
.
status
.
should
eql
(
200
)
pub_2
.
response_header
.
content_length
.
should_not
eql
(
0
)
...
...
@@ -363,7 +363,7 @@ describe "Channel Statistics" do
it
"should return detailed channels statistics for a nonexistent channel using prefix id"
do
nginx_run_server
(
config
,
:timeout
=>
5
)
do
|
conf
|
EventMachine
.
run
do
pub_2
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/channels-stats?id=prefix_*'
).
get
:head
=>
headers
,
:timeout
=>
30
pub_2
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/channels-stats?id=prefix_*'
).
get
:head
=>
headers
pub_2
.
callback
do
pub_2
.
response_header
.
status
.
should
eql
(
200
)
pub_2
.
response_header
.
content_length
.
should_not
eql
(
0
)
...
...
@@ -386,7 +386,7 @@ describe "Channel Statistics" do
publish_message
(
channel_1
,
headers
,
body
)
EventMachine
.
run
do
pub_2
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/channels-stats?id=ch_test_*'
).
get
:head
=>
headers
,
:timeout
=>
30
pub_2
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/channels-stats?id=ch_test_*'
).
get
:head
=>
headers
pub_2
.
callback
do
pub_2
.
response_header
.
status
.
should
eql
(
200
)
pub_2
.
response_header
.
content_length
.
should_not
eql
(
0
)
...
...
@@ -413,7 +413,7 @@ describe "Channel Statistics" do
publish_message
(
channel_1
,
headers
,
body
)
EventMachine
.
run
do
pub_2
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/channels-stats?id=*'
).
get
:head
=>
headers
,
:timeout
=>
30
pub_2
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/channels-stats?id=*'
).
get
:head
=>
headers
pub_2
.
callback
do
pub_2
.
response_header
.
status
.
should
eql
(
200
)
pub_2
.
response_header
.
content_length
.
should_not
eql
(
0
)
...
...
@@ -442,7 +442,7 @@ describe "Channel Statistics" do
publish_message
(
channel
,
headers
,
body
)
EventMachine
.
run
do
pub_2
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/channels-stats?id=bd_test_*'
).
get
:head
=>
headers
,
:timeout
=>
30
pub_2
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/channels-stats?id=bd_test_*'
).
get
:head
=>
headers
pub_2
.
callback
do
pub_2
.
response_header
.
status
.
should
eql
(
200
)
pub_2
.
response_header
.
content_length
.
should_not
eql
(
0
)
...
...
@@ -466,7 +466,7 @@ describe "Channel Statistics" do
nginx_run_server
(
config
,
:timeout
=>
5
)
do
|
conf
|
create_channel_by_subscribe
(
channel
,
headers
)
do
pub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/channels-stats?id=ch_test_*'
).
get
:head
=>
headers
,
:timeout
=>
30
pub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/channels-stats?id=ch_test_*'
).
get
:head
=>
headers
pub_1
.
callback
do
pub_1
.
response_header
.
status
.
should
eql
(
200
)
pub_1
.
response_header
.
content_length
.
should_not
eql
(
0
)
...
...
@@ -499,7 +499,7 @@ describe "Channel Statistics" do
end
EventMachine
.
run
do
pub_2
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/channels-stats?id=ch_test_get_detailed_channels_statistics_to_many_channels_using_prefix_10*'
).
get
:head
=>
headers
,
:timeout
=>
30
pub_2
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/channels-stats?id=ch_test_get_detailed_channels_statistics_to_many_channels_using_prefix_10*'
).
get
:head
=>
headers
pub_2
.
callback
do
pub_2
.
response_header
.
status
.
should
eql
(
200
)
pub_2
.
response_header
.
content_length
.
should_not
eql
(
0
)
...
...
@@ -520,7 +520,7 @@ describe "Channel Statistics" do
publish_message
(
channel
,
headers
,
body
)
EventMachine
.
run
do
pub_2
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/channels-stats?id=ALL'
).
get
:head
=>
headers
,
:timeout
=>
30
pub_2
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/channels-stats?id=ALL'
).
get
:head
=>
headers
pub_2
.
callback
do
pub_2
.
response_header
.
status
.
should
eql
(
200
)
pub_2
.
response_header
.
content_length
.
should_not
eql
(
0
)
...
...
@@ -533,7 +533,7 @@ describe "Channel Statistics" do
response
[
"infos"
].
to_s
.
should_not
be_empty
sleep
(
2
)
pub_3
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/channels-stats?id=ALL'
).
get
:head
=>
headers
,
:timeout
=>
30
pub_3
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/channels-stats?id=ALL'
).
get
:head
=>
headers
pub_3
.
callback
do
pub_3
.
response_header
.
status
.
should
eql
(
200
)
pub_3
.
response_header
.
content_length
.
should_not
eql
(
0
)
...
...
@@ -555,7 +555,7 @@ describe "Channel Statistics" do
publish_message
(
channel
,
headers
,
body
)
EventMachine
.
run
do
pub_2
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/channels-stats'
).
get
:head
=>
headers
,
:timeout
=>
30
pub_2
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/channels-stats'
).
get
:head
=>
headers
pub_2
.
callback
do
pub_2
.
response_header
.
status
.
should
eql
(
200
)
pub_2
.
response_header
.
content_length
.
should_not
eql
(
0
)
...
...
@@ -572,7 +572,7 @@ describe "Channel Statistics" do
response
[
"by_worker"
][
0
][
"uptime"
].
to_s
.
should_not
be_empty
sleep
(
2
)
pub_3
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/channels-stats'
).
get
:head
=>
headers
,
:timeout
=>
30
pub_3
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/channels-stats'
).
get
:head
=>
headers
pub_3
.
callback
do
pub_3
.
response_header
.
status
.
should
eql
(
200
)
pub_3
.
response_header
.
content_length
.
should_not
eql
(
0
)
...
...
misc/spec/mix/cleanup_memory_spec.rb
View file @
9f95e062
...
...
@@ -27,13 +27,13 @@ describe "Cleanup Memory" do
EventMachine
.
run
do
# ensure channel will not be cleaned up
sub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
).
get
:head
=>
headers
,
:timeout
=>
60
sub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
).
get
:head
=>
headers
fill_memory_timer
=
EventMachine
::
PeriodicTimer
.
new
(
0.001
)
do
publish_message_inline_with_callbacks
(
channel
,
headers
,
body
,
{
:error
=>
Proc
.
new
do
|
status
,
content
|
fill_memory_timer
.
cancel
pub_2
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/channels-stats?id='
+
channel
.
to_s
).
get
:head
=>
headers
,
:timeout
=>
60
pub_2
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/channels-stats?id='
+
channel
.
to_s
).
get
:head
=>
headers
pub_2
.
callback
do
fail
(
"Don't received the stats"
)
if
(
pub_2
.
response_header
.
status
!=
200
)
||
(
pub_2
.
response_header
.
content_length
==
0
)
result
=
JSON
.
parse
(
pub_2
.
response
)
...
...
@@ -44,28 +44,28 @@ describe "Cleanup Memory" do
published_messages_setp_1
.
should
be
>
(
conf
.
max_messages_stored_per_channel
)
stored_messages_setp_1
.
should_not
eql
(
0
)
EM
.
add_timer
(
45
)
do
pub_3
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/channels-stats?id='
+
channel
.
to_s
).
get
:head
=>
headers
,
:timeout
=>
60
pub_3
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/channels-stats?id='
+
channel
.
to_s
).
get
:head
=>
headers
pub_3
.
callback
do
fail
(
"Don't received the stats"
)
if
(
pub_3
.
response_header
.
status
!=
200
)
||
(
pub_3
.
response_header
.
content_length
==
0
)
JSON
.
parse
(
pub_3
.
response
)[
"stored_messages"
].
to_i
.
should
eql
(
0
)
execute_changes_on_environment
(
conf
)
do
# connect a subscriber on new worker
sub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
).
get
:head
=>
headers
,
:timeout
=>
60
sub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
).
get
:head
=>
headers
EM
.
add_timer
(
35
)
do
fill_memory_timer
=
EventMachine
::
PeriodicTimer
.
new
(
0.001
)
do
publish_message_inline_with_callbacks
(
channel
,
headers
,
body
,
{
:error
=>
Proc
.
new
do
|
status2
,
content2
|
fill_memory_timer
.
cancel
pub_2
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/channels-stats?id='
+
channel
.
to_s
).
get
:head
=>
headers
,
:timeout
=>
60
pub_2
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/channels-stats?id='
+
channel
.
to_s
).
get
:head
=>
headers
pub_2
.
callback
do
fail
(
"Don't received the stats"
)
if
(
pub_2
.
response_header
.
status
!=
200
)
||
(
pub_2
.
response_header
.
content_length
==
0
)
published_messages_setp_2
=
JSON
.
parse
(
pub_2
.
response
)[
"published_messages"
].
to_i
fail
(
"Don't publish more messages"
)
if
published_messages_setp_1
==
published_messages_setp_2
EM
.
add_timer
(
50
)
do
pub_3
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/channels-stats?id='
+
channel
.
to_s
).
get
:head
=>
headers
,
:timeout
=>
60
pub_3
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/channels-stats?id='
+
channel
.
to_s
).
get
:head
=>
headers
pub_3
.
callback
do
fail
(
"Don't received the stats"
)
if
(
pub_3
.
response_header
.
status
!=
200
)
||
(
pub_3
.
response_header
.
content_length
==
0
)
JSON
.
parse
(
pub_3
.
response
)[
"stored_messages"
].
to_i
.
should
eql
(
0
)
...
...
@@ -74,7 +74,7 @@ describe "Cleanup Memory" do
publish_message_inline_with_callbacks
(
channel
,
headers
,
body
,
{
:error
=>
Proc
.
new
do
|
status3
,
content3
|
fill_memory_timer
.
cancel
pub_4
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/channels-stats?id='
+
channel
.
to_s
).
get
:head
=>
headers
,
:timeout
=>
60
pub_4
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/channels-stats?id='
+
channel
.
to_s
).
get
:head
=>
headers
pub_4
.
callback
do
fail
(
"Don't received the stats"
)
if
(
pub_4
.
response_header
.
status
!=
200
)
||
(
pub_4
.
response_header
.
content_length
==
0
)
result
=
JSON
.
parse
(
pub_4
.
response
)
...
...
@@ -116,7 +116,7 @@ describe "Cleanup Memory" do
if
(
count
<
messages_to_publish
)
publish_message_inline
(
channel
,
headers
,
body
)
elsif
(
count
==
messages_to_publish
)
pub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/channels-stats?id='
+
channel
.
to_s
).
get
:head
=>
headers
,
:timeout
=>
60
pub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/channels-stats?id='
+
channel
.
to_s
).
get
:head
=>
headers
pub_1
.
callback
do
fill_memory_timer
.
cancel
fail
(
"Don't received the stats"
)
if
(
pub_1
.
response_header
.
status
!=
200
)
||
(
pub_1
.
response_header
.
content_length
==
0
)
...
...
@@ -125,7 +125,7 @@ describe "Cleanup Memory" do
execute_changes_on_environment
(
conf
)
do
EM
.
add_timer
(
5
)
do
# wait cleanup timer to be executed one time
pub_2
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/channels-stats?id='
+
channel
.
to_s
).
get
:head
=>
headers
,
:timeout
=>
60
pub_2
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/channels-stats?id='
+
channel
.
to_s
).
get
:head
=>
headers
pub_2
.
callback
do
fail
(
"Don't received the stats"
)
if
(
pub_2
.
response_header
.
status
!=
200
)
||
(
pub_2
.
response_header
.
content_length
==
0
)
stored_messages_setp_2
=
JSON
.
parse
(
pub_2
.
response
)[
"stored_messages"
].
to_i
...
...
@@ -155,13 +155,13 @@ describe "Cleanup Memory" do
EventMachine
.
run
do
# ensure channel will not be cleaned up
sub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
).
get
:head
=>
headers
,
:timeout
=>
60
sub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
).
get
:head
=>
headers
fill_memory_timer
=
EventMachine
::
PeriodicTimer
.
new
(
0.001
)
do
publish_message_inline_with_callbacks
(
channel
,
headers
,
body
,
{
:error
=>
Proc
.
new
do
|
status
,
content
|
fill_memory_timer
.
cancel
pub_2
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/channels-stats?id='
+
channel
.
to_s
).
get
:head
=>
headers
,
:timeout
=>
60
pub_2
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/channels-stats?id='
+
channel
.
to_s
).
get
:head
=>
headers
pub_2
.
callback
do
fail
(
"Don't received the stats"
)
if
(
pub_2
.
response_header
.
status
!=
200
)
||
(
pub_2
.
response_header
.
content_length
==
0
)
result
=
JSON
.
parse
(
pub_2
.
response
)
...
...
@@ -172,21 +172,21 @@ describe "Cleanup Memory" do
execute_changes_on_environment
(
conf
)
do
# connect a subscriber on new worker
sub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
).
get
:head
=>
headers
,
:timeout
=>
60
sub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
).
get
:head
=>
headers
EM
.
add_timer
(
50
)
do
fill_memory_timer
=
EventMachine
::
PeriodicTimer
.
new
(
0.001
)
do
publish_message_inline_with_callbacks
(
channel
,
headers
,
body
,
{
:error
=>
Proc
.
new
do
|
status2
,
content2
|
fill_memory_timer
.
cancel
pub_2
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/channels-stats?id='
+
channel
.
to_s
).
get
:head
=>
headers
,
:timeout
=>
60
pub_2
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/channels-stats?id='
+
channel
.
to_s
).
get
:head
=>
headers
pub_2
.
callback
do
fail
(
"Don't received the stats"
)
if
(
pub_2
.
response_header
.
status
!=
200
)
||
(
pub_2
.
response_header
.
content_length
==
0
)
published_messages_setp_2
=
JSON
.
parse
(
pub_2
.
response
)[
"published_messages"
].
to_i
fail
(
"Don't publish more messages"
)
if
published_messages_setp_1
==
published_messages_setp_2
EM
.
add_timer
(
60
)
do
pub_3
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/channels-stats?id='
+
channel
.
to_s
).
get
:head
=>
headers
,
:timeout
=>
60
pub_3
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/channels-stats?id='
+
channel
.
to_s
).
get
:head
=>
headers
pub_3
.
callback
do
fail
(
"Don't received the stats"
)
if
(
pub_3
.
response_header
.
status
!=
200
)
||
(
pub_3
.
response_header
.
content_length
==
0
)
JSON
.
parse
(
pub_3
.
response
)[
"stored_messages"
].
to_i
.
should
eql
(
0
)
...
...
@@ -194,7 +194,7 @@ describe "Cleanup Memory" do
fill_memory_timer
=
EventMachine
::
PeriodicTimer
.
new
(
0.001
)
do
publish_message_inline_with_callbacks
(
channel
,
headers
,
body
,
{
:error
=>
Proc
.
new
do
|
status3
,
content3
|
pub_4
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/channels-stats?id='
+
channel
.
to_s
).
get
:head
=>
headers
,
:timeout
=>
60
pub_4
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/channels-stats?id='
+
channel
.
to_s
).
get
:head
=>
headers
pub_4
.
callback
do
fail
(
"Don't received the stats"
)
if
(
pub_4
.
response_header
.
status
!=
200
)
||
(
pub_4
.
response_header
.
content_length
==
0
)
result
=
JSON
.
parse
(
pub_4
.
response
)
...
...
@@ -236,7 +236,7 @@ describe "Cleanup Memory" do
publish_message_inline_with_callbacks
(
channel
+
i
.
to_s
,
headers
,
body
,
{
:error
=>
Proc
.
new
do
|
status
,
content
|
fill_memory_timer
.
cancel
pub_2
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/channels-stats'
).
get
:head
=>
headers
,
:timeout
=>
60
pub_2
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/channels-stats'
).
get
:head
=>
headers
pub_2
.
callback
do
fail
(
"Don't received the stats"
)
if
(
pub_2
.
response_header
.
status
!=
200
)
||
(
pub_2
.
response_header
.
content_length
==
0
)
channels_setp_1
=
JSON
.
parse
(
pub_2
.
response
)[
"channels"
].
to_i
...
...
@@ -249,13 +249,13 @@ describe "Cleanup Memory" do
publish_message_inline_with_callbacks
(
channel
+
j
.
to_s
,
headers
,
body
,
{
:error
=>
Proc
.
new
do
|
status2
,
content2
|
fill_memory_timer
.
cancel
pub_2
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/channels-stats'
).
get
:head
=>
headers
,
:timeout
=>
60
pub_2
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/channels-stats'
).
get
:head
=>
headers
pub_2
.
callback
do
fail
(
"Don't received the stats"
)
if
(
pub_2
.
response_header
.
status
!=
200
)
||
(
pub_2
.
response_header
.
content_length
==
0
)
fail
(
"Don't create more channel"
)
if
published_messages_setp_1
==
JSON
.
parse
(
pub_2
.
response
)[
"published_messages"
].
to_i
EM
.
add_timer
(
40
)
do
pub_3
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/channels-stats'
).
get
:head
=>
headers
,
:timeout
=>
60
pub_3
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/channels-stats'
).
get
:head
=>
headers
pub_3
.
callback
do
fail
(
"Don't received the stats"
)
if
(
pub_3
.
response_header
.
status
!=
200
)
||
(
pub_3
.
response_header
.
content_length
==
0
)
channels
=
JSON
.
parse
(
pub_3
.
response
)[
"channels"
].
to_i
...
...
@@ -268,7 +268,7 @@ describe "Cleanup Memory" do
publish_message_inline_with_callbacks
(
channel
+
i
.
to_s
,
headers
,
body
,
{
:error
=>
Proc
.
new
do
|
status3
,
content3
|
fill_memory_timer
.
cancel
pub_4
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/channels-stats'
).
get
:head
=>
headers
,
:timeout
=>
60
pub_4
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/channels-stats'
).
get
:head
=>
headers
pub_4
.
callback
do
fail
(
"Don't received the stats"
)
if
(
pub_4
.
response_header
.
status
!=
200
)
||
(
pub_4
.
response_header
.
content_length
==
0
)
channels_setp_2
=
JSON
.
parse
(
pub_4
.
response
)[
"channels"
].
to_i
...
...
@@ -309,13 +309,13 @@ describe "Cleanup Memory" do
EventMachine
.
run
do
# ensure channel will not be cleaned up
sub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
).
get
:head
=>
headers
,
:timeout
=>
60
sub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
).
get
:head
=>
headers
fill_memory_timer
=
EventMachine
::
PeriodicTimer
.
new
(
0.001
)
do
publish_message_inline_with_callbacks
(
channel
,
headers
,
body
,
{
:error
=>
Proc
.
new
do
|
status
,
content
|
fill_memory_timer
.
cancel
pub_2
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/channels-stats?id='
+
channel
.
to_s
).
get
:head
=>
headers
,
:timeout
=>
60
pub_2
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/channels-stats?id='
+
channel
.
to_s
).
get
:head
=>
headers
pub_2
.
callback
do
fail
(
"Don't received the stats"
)
if
(
pub_2
.
response_header
.
status
!=
200
)
||
(
pub_2
.
response_header
.
content_length
==
0
)
result
=
JSON
.
parse
(
pub_2
.
response
)
...
...
@@ -323,21 +323,21 @@ describe "Cleanup Memory" do
execute_changes_on_environment
(
conf
)
do
# connect a subscriber on new worker
sub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
).
get
:head
=>
headers
,
:timeout
=>
60
sub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
).
get
:head
=>
headers
EM
.
add_timer
(
35
)
do
fill_memory_timer
=
EventMachine
::
PeriodicTimer
.
new
(
0.001
)
do
publish_message_inline_with_callbacks
(
channel
,
headers
,
body
,
{
:error
=>
Proc
.
new
do
|
status2
,
content2
|
fill_memory_timer
.
cancel
pub_2
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/channels-stats?id='
+
channel
.
to_s
).
get
:head
=>
headers
,
:timeout
=>
60
pub_2
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/channels-stats?id='
+
channel
.
to_s
).
get
:head
=>
headers
pub_2
.
callback
do
fail
(
"Don't received the stats"
)
if
(
pub_2
.
response_header
.
status
!=
200
)
||
(
pub_2
.
response_header
.
content_length
==
0
)
published_messages_setp_2
=
JSON
.
parse
(
pub_2
.
response
)[
"published_messages"
].
to_i
published_messages_setp_2
.
should_not
eql
(
published_messages_setp_1
)
EM
.
add_timer
(
35
)
do
pub_3
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/channels-stats?id='
+
channel
.
to_s
).
get
:head
=>
headers
,
:timeout
=>
60
pub_3
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/channels-stats?id='
+
channel
.
to_s
).
get
:head
=>
headers
pub_3
.
callback
do
fail
(
"Don't received the stats"
)
if
(
pub_3
.
response_header
.
status
!=
200
)
||
(
pub_3
.
response_header
.
content_length
==
0
)
JSON
.
parse
(
pub_3
.
response
)[
"channels"
].
to_i
.
should
eql
(
0
)
...
...
@@ -345,7 +345,7 @@ describe "Cleanup Memory" do
fill_memory_timer
=
EventMachine
::
PeriodicTimer
.
new
(
0.001
)
do
publish_message_inline_with_callbacks
(
channel
,
headers
,
body
,
{
:error
=>
Proc
.
new
do
|
status3
,
content3
|
pub_4
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/channels-stats?id='
+
channel
.
to_s
).
get
:head
=>
headers
,
:timeout
=>
60
pub_4
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/channels-stats?id='
+
channel
.
to_s
).
get
:head
=>
headers
pub_4
.
callback
do
fail
(
"Don't received the stats"
)
if
(
pub_4
.
response_header
.
status
!=
200
)
||
(
pub_4
.
response_header
.
content_length
==
0
)
result
=
JSON
.
parse
(
pub_4
.
response
)
...
...
@@ -385,7 +385,7 @@ describe "Cleanup Memory" do
publish_message_inline_with_callbacks
(
channel
+
i
.
to_s
,
headers
,
body
,
{
:error
=>
Proc
.
new
do
|
status
,
content
|
fill_memory_timer
.
cancel
pub_2
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/channels-stats'
).
get
:head
=>
headers
,
:timeout
=>
60
pub_2
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/channels-stats'
).
get
:head
=>
headers
pub_2
.
callback
do
fail
(
"Don't received the stats"
)
if
(
pub_2
.
response_header
.
status
!=
200
)
||
(
pub_2
.
response_header
.
content_length
==
0
)
result
=
JSON
.
parse
(
pub_2
.
response
)
...
...
@@ -398,14 +398,14 @@ describe "Cleanup Memory" do
publish_message_inline_with_callbacks
(
channel
+
j
.
to_s
,
headers
,
body
,
{
:error
=>
Proc
.
new
do
|
status2
,
content2
|
fill_memory_timer
.
cancel
pub_2
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/channels-stats'
).
get
:head
=>
headers
,
:timeout
=>
60
pub_2
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/channels-stats'
).
get
:head
=>
headers
pub_2
.
callback
do
fail
(
"Don't received the stats"
)
if
(
pub_2
.
response_header
.
status
!=
200
)
||
(
pub_2
.
response_header
.
content_length
==
0
)
published_messages_setp_2
=
JSON
.
parse
(
pub_2
.
response
)[
"published_messages"
].
to_i
fail
(
"Don't create more channel"
)
if
published_messages_setp_1
==
published_messages_setp_2
EM
.
add_timer
(
35
)
do
pub_3
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/channels-stats'
).
get
:head
=>
headers
,
:timeout
=>
60
pub_3
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/channels-stats'
).
get
:head
=>
headers
pub_3
.
callback
do
fail
(
"Don't received the stats"
)
if
(
pub_3
.
response_header
.
status
!=
200
)
||
(
pub_3
.
response_header
.
content_length
==
0
)
JSON
.
parse
(
pub_3
.
response
)[
"channels"
].
to_i
.
should
eql
(
0
)
...
...
@@ -414,7 +414,7 @@ describe "Cleanup Memory" do
fill_memory_timer
=
EventMachine
::
PeriodicTimer
.
new
(
0.001
)
do
publish_message_inline_with_callbacks
(
channel
+
i
.
to_s
,
headers
,
body
,
{
:error
=>
Proc
.
new
do
|
status3
,
content3
|
pub_4
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/channels-stats'
).
get
:head
=>
headers
,
:timeout
=>
60
pub_4
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/channels-stats'
).
get
:head
=>
headers
pub_4
.
callback
do
fail
(
"Don't received the stats"
)
if
(
pub_4
.
response_header
.
status
!=
200
)
||
(
pub_4
.
response_header
.
content_length
==
0
)
result
=
JSON
.
parse
(
pub_4
.
response
)
...
...
@@ -454,14 +454,14 @@ describe "Cleanup Memory" do
EventMachine
.
run
do
i
=
0
fill_memory_timer
=
EventMachine
::
PeriodicTimer
.
new
(
0.001
)
do
pub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/pub?id='
+
channel
.
to_s
+
i
.
to_s
).
post
:body
=>
body
,
:head
=>
headers
,
:timeout
=>
30
pub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/pub?id='
+
channel
.
to_s
+
i
.
to_s
).
post
:body
=>
body
,
:head
=>
headers
pub_1
.
callback
do
if
pub_1
.
response_header
.
status
==
500
fill_memory_timer
.
cancel
i
.
times
do
|
j
|
pub
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/pub?id='
+
channel
.
to_s
+
j
.
to_s
).
delete
:head
=>
headers
,
:timeout
=>
30
pub
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/pub?id='
+
channel
.
to_s
+
j
.
to_s
).
delete
:head
=>
headers
end
pub_2
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/channels-stats'
).
get
:head
=>
headers
,
:timeout
=>
60
pub_2
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/channels-stats'
).
get
:head
=>
headers
pub_2
.
callback
do
fail
(
"Don't received the stats"
)
if
(
pub_2
.
response_header
.
status
!=
200
)
||
(
pub_2
.
response_header
.
content_length
==
0
)
result
=
JSON
.
parse
(
pub_2
.
response
)
...
...
@@ -472,11 +472,11 @@ describe "Cleanup Memory" do
EM
.
add_timer
(
45
)
do
i
=
0
fill_memory_timer
=
EventMachine
::
PeriodicTimer
.
new
(
0.001
)
do
pub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/pub?id='
+
channel
.
to_s
+
i
.
to_s
).
post
:body
=>
body
,
:head
=>
headers
,
:timeout
=>
30
pub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/pub?id='
+
channel
.
to_s
+
i
.
to_s
).
post
:body
=>
body
,
:head
=>
headers
pub_1
.
callback
do
if
pub_1
.
response_header
.
status
==
500
fill_memory_timer
.
cancel
pub_2
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/channels-stats'
).
get
:head
=>
headers
,
:timeout
=>
60
pub_2
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/channels-stats'
).
get
:head
=>
headers
pub_2
.
callback
do
fail
(
"Don't received the stats"
)
if
(
pub_2
.
response_header
.
status
!=
200
)
||
(
pub_2
.
response_header
.
content_length
==
0
)
result
=
JSON
.
parse
(
pub_2
.
response
)
...
...
@@ -507,7 +507,7 @@ describe "Cleanup Memory" do
EventMachine
.
run
do
create_and_delete_channel_in_loop
(
channel
,
body
,
headers
)
do
pub_2
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/channels-stats'
).
get
:head
=>
headers
,
:timeout
=>
60
pub_2
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/channels-stats'
).
get
:head
=>
headers
pub_2
.
callback
do
fail
(
"Don't received the stats"
)
if
(
pub_2
.
response_header
.
status
!=
200
)
||
(
pub_2
.
response_header
.
content_length
==
0
)
result
=
JSON
.
parse
(
pub_2
.
response
)
...
...
@@ -517,7 +517,7 @@ describe "Cleanup Memory" do
execute_changes_on_environment
(
conf
)
do
EM
.
add_timer
(
40
)
do
create_and_delete_channel_in_loop
(
channel
,
body
,
headers
)
do
pub_2
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/channels-stats'
).
get
:head
=>
headers
,
:timeout
=>
60
pub_2
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/channels-stats'
).
get
:head
=>
headers
pub_2
.
callback
do
fail
(
"Don't received the stats"
)
if
(
pub_2
.
response_header
.
status
!=
200
)
||
(
pub_2
.
response_header
.
content_length
==
0
)
result
=
JSON
.
parse
(
pub_2
.
response
)
...
...
@@ -536,10 +536,10 @@ describe "Cleanup Memory" do
end
def
create_and_delete_channel
(
channel
,
body
,
headers
,
&
block
)
pub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/pub?id='
+
channel
.
to_s
).
post
:body
=>
body
,
:head
=>
headers
,
:timeout
=>
30
pub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/pub?id='
+
channel
.
to_s
).
post
:body
=>
body
,
:head
=>
headers
pub_1
.
callback
do
if
pub_1
.
response_header
.
status
==
200
pub
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/pub?id='
+
channel
.
to_s
).
delete
:head
=>
headers
,
:timeout
=>
30
pub
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/pub?id='
+
channel
.
to_s
).
delete
:head
=>
headers
pub
.
callback
do
block
.
call
((
pub
.
response_header
.
status
==
200
)
?
:
success
:
:error
)
end
...
...
misc/spec/mix/send_signals_spec.rb
View file @
9f95e062
...
...
@@ -34,12 +34,12 @@ describe "Send Signals" do
nginx_run_server
(
config
,
:timeout
=>
60
)
do
|
conf
|
EventMachine
.
run
do
# create subscriber
sub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
).
get
:head
=>
headers
,
:timeout
=>
30
sub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
).
get
:head
=>
headers
sub_1
.
stream
do
|
chunk
|
response
=
response
+
chunk
if
response
.
strip
==
conf
.
header_template
# check statistics
pub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/channels-stats'
).
get
:head
=>
headers
,
:timeout
=>
30
pub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/channels-stats'
).
get
:head
=>
headers
pub_1
.
callback
do
pub_1
.
response_header
.
status
.
should
eql
(
200
)
pub_1
.
response_header
.
content_length
.
should_not
eql
(
0
)
...
...
@@ -61,7 +61,7 @@ describe "Send Signals" do
EM
.
add_periodic_timer
(
0.5
)
do
# check statistics again
pub_4
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/channels-stats'
).
get
:head
=>
headers
,
:timeout
=>
30
pub_4
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/channels-stats'
).
get
:head
=>
headers
pub_4
.
callback
do
resp_3
=
JSON
.
parse
(
pub_4
.
response
)
resp_3
.
has_key?
(
"by_worker"
).
should
be_true
...
...
@@ -70,15 +70,15 @@ describe "Send Signals" do
conectted_after_reloaded
=
true
# publish a message
pub_2
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/pub?id='
+
channel
.
to_s
).
post
:head
=>
headers
,
:body
=>
body
,
:timeout
=>
30
pub_2
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/pub?id='
+
channel
.
to_s
).
post
:head
=>
headers
,
:body
=>
body
pub_2
.
callback
do
# add new subscriber
sub_2
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
+
'.b1'
).
get
:head
=>
headers
,
:timeout
=>
30
sub_2
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
+
'.b1'
).
get
:head
=>
headers
sub_2
.
stream
do
|
chunk
|
response2
=
response2
+
chunk
if
response2
.
strip
==
conf
.
header_template
# check statistics again
pub_3
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/channels-stats'
).
get
:head
=>
headers
,
:timeout
=>
30
pub_3
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/channels-stats'
).
get
:head
=>
headers
pub_3
.
callback
do
resp_2
=
JSON
.
parse
(
pub_3
.
response
)
...
...
@@ -125,7 +125,7 @@ describe "Send Signals" do
EventMachine
.
run
do
publish_message_inline
(
channel
,
{},
body
)
# check statistics
pub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/channels-stats'
).
get
:head
=>
headers
,
:timeout
=>
30
pub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/channels-stats'
).
get
:head
=>
headers
pub_1
.
callback
do
pub_1
.
response_header
.
status
.
should
eql
(
200
)
pub_1
.
response_header
.
content_length
.
should_not
eql
(
0
)
...
...
@@ -142,7 +142,7 @@ describe "Send Signals" do
sleep
5
pub_2
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/channels-stats'
).
get
:head
=>
headers
,
:timeout
=>
30
pub_2
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/channels-stats'
).
get
:head
=>
headers
pub_2
.
callback
do
pub_2
.
response_header
.
status
.
should
eql
(
200
)
pub_2
.
response_header
.
content_length
.
should_not
eql
(
0
)
...
...
misc/spec/publisher/channel_id_collision_spec.rb
View file @
9f95e062
...
...
@@ -8,7 +8,7 @@ describe "Publisher Channel id collision" do
nginx_run_server
do
|
conf
|
channels
.
each
do
|
channel
|
EventMachine
.
run
do
pub
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/pub?id='
+
channel
).
post
:body
=>
'x'
,
:timeout
=>
30
pub
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/pub?id='
+
channel
).
post
:body
=>
'x'
pub
.
callback
do
pub
.
response_header
.
status
.
should
eql
(
200
)
EventMachine
.
stop
...
...
misc/spec/publisher/properties_spec.rb
View file @
9f95e062
...
...
@@ -419,13 +419,13 @@ describe "Publisher Properties" do
publish_message
(
channel
,
headers
,
body
)
EventMachine
.
run
do
pub
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/pub?id='
+
channel
.
to_s
).
delete
:head
=>
headers
,
:timeout
=>
30
pub
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/pub?id='
+
channel
.
to_s
).
delete
:head
=>
headers
pub
.
callback
do
pub
.
response_header
.
status
.
should
eql
(
200
)
pub
.
response_header
.
content_length
.
should
eql
(
0
)
pub
.
response_header
[
'X_NGINX_PUSHSTREAM_EXPLAIN'
].
should
eql
(
"Channel deleted."
)
stats
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/channels-stats'
).
get
:head
=>
headers
,
:timeout
=>
30
stats
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/channels-stats'
).
get
:head
=>
headers
stats
.
callback
do
stats
.
response_header
.
status
.
should
eql
(
200
)
stats
.
response_header
.
content_length
.
should_not
eql
(
0
)
...
...
@@ -453,19 +453,19 @@ describe "Publisher Properties" do
resp
=
""
nginx_run_server
(
configuration
,
:timeout
=>
5
)
do
|
conf
|
EventMachine
.
run
do
sub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
).
get
:head
=>
headers
,
:timeout
=>
30
sub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
).
get
:head
=>
headers
sub_1
.
stream
do
|
chunk
|
resp
=
resp
+
chunk
if
resp
.
strip
.
empty?
stats
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/channels-stats'
).
get
:head
=>
{
'accept'
=>
'application/json'
}
,
:timeout
=>
30
stats
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/channels-stats'
).
get
:head
=>
{
'accept'
=>
'application/json'
}
stats
.
callback
do
stats
.
response_header
.
status
.
should
eql
(
200
)
stats
.
response_header
.
content_length
.
should_not
eql
(
0
)
response
=
JSON
.
parse
(
stats
.
response
)
response
[
"subscribers"
].
to_i
.
should
eql
(
1
)
response
[
"channels"
].
to_i
.
should
eql
(
1
)
pub
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/pub?id='
+
channel
.
to_s
).
delete
:head
=>
headers
,
:timeout
=>
30
pub
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/pub?id='
+
channel
.
to_s
).
delete
:head
=>
headers
pub
.
callback
do
pub
.
response_header
.
status
.
should
eql
(
200
)
pub
.
response_header
.
content_length
.
should
eql
(
0
)
...
...
@@ -478,7 +478,7 @@ describe "Publisher Properties" do
response
[
"id"
].
to_i
.
should
eql
(
-
2
)
response
[
"text"
].
should
eql
(
"Channel deleted"
)
stats
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/channels-stats'
).
get
:head
=>
{
'accept'
=>
'application/json'
}
,
:timeout
=>
30
stats
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/channels-stats'
).
get
:head
=>
{
'accept'
=>
'application/json'
}
stats
.
callback
do
stats
.
response_header
.
status
.
should
eql
(
200
)
stats
.
response_header
.
content_length
.
should_not
eql
(
0
)
...
...
@@ -509,12 +509,12 @@ describe "Publisher Properties" do
resp
=
""
nginx_run_server
(
configuration
,
:timeout
=>
5
)
do
|
conf
|
EventMachine
.
run
do
sub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel_1
.
to_s
+
'/'
+
channel_2
.
to_s
).
get
:head
=>
headers
,
:timeout
=>
30
sub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel_1
.
to_s
+
'/'
+
channel_2
.
to_s
).
get
:head
=>
headers
sub_1
.
stream
do
|
chunk
|
resp
=
resp
+
chunk
if
resp
.
strip
.
empty?
stats
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/channels-stats'
).
get
:head
=>
{
'accept'
=>
'application/json'
}
,
:timeout
=>
30
stats
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/channels-stats'
).
get
:head
=>
{
'accept'
=>
'application/json'
}
stats
.
callback
do
stats
.
response_header
.
status
.
should
eql
(
200
)
stats
.
response_header
.
content_length
.
should_not
eql
(
0
)
...
...
@@ -522,7 +522,7 @@ describe "Publisher Properties" do
response
[
"subscribers"
].
to_i
.
should
eql
(
1
)
response
[
"channels"
].
to_i
.
should
eql
(
2
)
pub
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/pub?id='
+
channel_1
.
to_s
).
delete
:head
=>
headers
,
:timeout
=>
30
pub
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/pub?id='
+
channel_1
.
to_s
).
delete
:head
=>
headers
pub
.
callback
do
pub
.
response_header
.
status
.
should
eql
(
200
)
pub
.
response_header
.
content_length
.
should
eql
(
0
)
...
...
@@ -537,7 +537,7 @@ describe "Publisher Properties" do
response
[
"id"
].
to_i
.
should
eql
(
-
2
)
response
[
"text"
].
should
eql
(
"Channel deleted"
)
stats
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/channels-stats'
).
get
:head
=>
{
'accept'
=>
'application/json'
}
,
:timeout
=>
30
stats
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/channels-stats'
).
get
:head
=>
{
'accept'
=>
'application/json'
}
stats
.
callback
do
stats
.
response_header
.
status
.
should
eql
(
200
)
stats
.
response_header
.
content_length
.
should_not
eql
(
0
)
...
...
@@ -545,7 +545,7 @@ describe "Publisher Properties" do
response
[
"subscribers"
].
to_i
.
should
eql
(
1
)
response
[
"channels"
].
to_i
.
should
eql
(
1
)
pub
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/pub?id='
+
channel_2
.
to_s
).
post
:head
=>
headers
,
:body
=>
body
,
:timeout
=>
30
pub
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/pub?id='
+
channel_2
.
to_s
).
post
:head
=>
headers
,
:body
=>
body
pub
.
callback
do
pub
.
response_header
.
status
.
should
eql
(
200
)
end
...
...
@@ -557,7 +557,7 @@ describe "Publisher Properties" do
response
[
"id"
].
to_i
.
should
eql
(
1
)
response
[
"text"
].
should
eql
(
body
)
pub
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/pub?id='
+
channel_2
.
to_s
).
delete
:head
=>
headers
,
:timeout
=>
30
pub
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/pub?id='
+
channel_2
.
to_s
).
delete
:head
=>
headers
pub
.
callback
do
pub
.
response_header
.
status
.
should
eql
(
200
)
pub
.
response_header
.
content_length
.
should
eql
(
0
)
...
...
@@ -569,7 +569,7 @@ describe "Publisher Properties" do
response
[
"id"
].
to_i
.
should
eql
(
-
2
)
response
[
"text"
].
should
eql
(
"Channel deleted"
)
stats
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/channels-stats'
).
get
:head
=>
{
'accept'
=>
'application/json'
}
,
:timeout
=>
30
stats
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/channels-stats'
).
get
:head
=>
{
'accept'
=>
'application/json'
}
stats
.
callback
do
stats
.
response_header
.
status
.
should
eql
(
200
)
stats
.
response_header
.
content_length
.
should_not
eql
(
0
)
...
...
@@ -601,7 +601,7 @@ describe "Publisher Properties" do
nginx_run_server
(
configuration
,
:timeout
=>
10
)
do
|
conf
|
EventMachine
.
run
do
resp_1
=
""
sub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel_1
.
to_s
).
get
:head
=>
headers
,
:timeout
=>
30
sub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel_1
.
to_s
).
get
:head
=>
headers
sub_1
.
stream
do
|
chunk
|
resp_1
+=
chunk
end
...
...
@@ -610,7 +610,7 @@ describe "Publisher Properties" do
end
resp_2
=
""
sub_2
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel_2
.
to_s
).
get
:head
=>
headers
,
:timeout
=>
30
sub_2
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel_2
.
to_s
).
get
:head
=>
headers
sub_2
.
stream
do
|
chunk
|
resp_2
+=
chunk
end
...
...
@@ -618,7 +618,7 @@ describe "Publisher Properties" do
resp_2
.
should
eql
(
"{
\"
id
\"
:
\"
-2
\"
,
\"
channel
\"
:
\"
test_delete_channels_whith_subscribers_2
\"
,
\"
text
\"
:
\"
Channel deleted
\"
}
\r\n
FOOTER
\r\n
"
)
end
stats
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/channels-stats'
).
get
:head
=>
{
'accept'
=>
'application/json'
}
,
:timeout
=>
30
stats
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/channels-stats'
).
get
:head
=>
{
'accept'
=>
'application/json'
}
stats
.
callback
do
stats
.
response_header
.
status
.
should
eql
(
200
)
stats
.
response_header
.
content_length
.
should_not
eql
(
0
)
...
...
@@ -627,14 +627,14 @@ describe "Publisher Properties" do
response
[
"channels"
].
to_i
.
should
eql
(
2
)
end
pub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/pub?id='
+
channel_1
.
to_s
).
delete
:head
=>
headers
,
:timeout
=>
30
pub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/pub?id='
+
channel_1
.
to_s
).
delete
:head
=>
headers
pub_1
.
callback
do
pub_1
.
response_header
.
status
.
should
eql
(
200
)
pub_1
.
response_header
.
content_length
.
should
eql
(
0
)
pub_1
.
response_header
[
'X_NGINX_PUSHSTREAM_EXPLAIN'
].
should
eql
(
"Channel deleted."
)
end
pub_2
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/pub?id='
+
channel_2
.
to_s
).
delete
:head
=>
headers
,
:timeout
=>
30
pub_2
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/pub?id='
+
channel_2
.
to_s
).
delete
:head
=>
headers
pub_2
.
callback
do
pub_2
.
response_header
.
status
.
should
eql
(
200
)
pub_2
.
response_header
.
content_length
.
should
eql
(
0
)
...
...
@@ -642,7 +642,7 @@ describe "Publisher Properties" do
end
EM
.
add_timer
(
5
)
do
stats_2
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/channels-stats'
).
get
:head
=>
{
'accept'
=>
'application/json'
}
,
:timeout
=>
30
stats_2
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/channels-stats'
).
get
:head
=>
{
'accept'
=>
'application/json'
}
stats_2
.
callback
do
stats_2
.
response_header
.
status
.
should
eql
(
200
)
stats_2
.
response_header
.
content_length
.
should_not
eql
(
0
)
...
...
@@ -670,12 +670,12 @@ describe "Publisher Properties" do
resp
=
""
nginx_run_server
(
configuration
,
:timeout
=>
5
)
do
|
conf
|
EventMachine
.
run
do
sub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
).
get
:head
=>
headers
,
:timeout
=>
30
sub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
).
get
:head
=>
headers
sub_1
.
stream
do
|
chunk
|
resp
=
resp
+
chunk
if
resp
==
"
#{
conf
.
header_template
}
\r\n
"
pub
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/pub?id='
+
channel
.
to_s
).
delete
:head
=>
headers
,
:timeout
=>
30
pub
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/pub?id='
+
channel
.
to_s
).
delete
:head
=>
headers
pub
.
callback
do
pub
.
response_header
.
status
.
should
eql
(
200
)
pub
.
response_header
.
content_length
.
should
eql
(
0
)
...
...
@@ -718,18 +718,18 @@ describe "Publisher Properties" do
resp2
=
""
nginx_run_server
(
configuration
,
:timeout
=>
5
)
do
|
conf
|
EventMachine
.
run
do
sub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
).
get
:head
=>
headers
,
:timeout
=>
30
sub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
).
get
:head
=>
headers
sub_1
.
stream
do
|
chunk
|
resp
=
resp
+
chunk
end
sub_2
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub2/'
+
channel
.
to_s
).
get
:head
=>
headers
,
:timeout
=>
30
sub_2
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub2/'
+
channel
.
to_s
).
get
:head
=>
headers
sub_2
.
stream
do
|
chunk
|
resp2
=
resp2
+
chunk
end
EM
.
add_timer
(
1
)
do
pub
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/pub?id='
+
channel
.
to_s
).
delete
:head
=>
headers
,
:timeout
=>
30
pub
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/pub?id='
+
channel
.
to_s
).
delete
:head
=>
headers
pub
.
callback
do
pub
.
response_header
.
status
.
should
eql
(
200
)
pub
.
response_header
.
content_length
.
should
eql
(
0
)
...
...
@@ -761,12 +761,12 @@ describe "Publisher Properties" do
resp
=
""
nginx_run_server
(
configuration
,
:timeout
=>
5
)
do
|
conf
|
EventMachine
.
run
do
sub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
).
get
:head
=>
headers
,
:timeout
=>
30
sub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
).
get
:head
=>
headers
sub_1
.
stream
do
|
chunk
|
resp
=
resp
+
chunk
if
resp
.
strip
.
empty?
pub
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/pub?id='
+
channel
.
to_s
).
delete
:head
=>
headers
,
:timeout
=>
30
pub
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/pub?id='
+
channel
.
to_s
).
delete
:head
=>
headers
pub
.
callback
do
pub
.
response_header
.
status
.
should
eql
(
200
)
pub
.
response_header
.
content_length
.
should
eql
(
0
)
...
...
misc/spec/publisher/publish_messages_spec.rb
View file @
9f95e062
...
...
@@ -22,7 +22,7 @@ describe "Publisher Publishing Messages" do
EventMachine
.
stop
end
pub
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/pub?id='
+
channel
.
to_s
).
post
:head
=>
headers
,
:body
=>
body
,
:timeout
=>
30
pub
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/pub?id='
+
channel
.
to_s
).
post
:head
=>
headers
,
:body
=>
body
end
end
end
...
...
@@ -54,7 +54,7 @@ describe "Publisher Publishing Messages" do
EventMachine
.
stop
end
pub
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/pub?id='
+
channel
.
to_s
).
post
:head
=>
headers
,
:body
=>
body
,
:timeout
=>
30
pub
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/pub?id='
+
channel
.
to_s
).
post
:head
=>
headers
,
:body
=>
body
end
end
end
...
...
@@ -89,7 +89,7 @@ describe "Publisher Publishing Messages" do
end
end
pub
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/pub?id='
+
channel
.
to_s
).
post
:head
=>
headers
,
:body
=>
body
,
:timeout
=>
30
pub
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/pub?id='
+
channel
.
to_s
).
post
:head
=>
headers
,
:body
=>
body
end
end
end
...
...
@@ -145,7 +145,7 @@ describe "Publisher Publishing Messages" do
EventMachine
.
stop
end
pub
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/pub?id='
+
channel
.
to_s
).
post
:head
=>
headers
.
merge
(
'Event-Id'
=>
event_id
),
:body
=>
body
,
:timeout
=>
30
pub
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/pub?id='
+
channel
.
to_s
).
post
:head
=>
headers
.
merge
(
'Event-Id'
=>
event_id
),
:body
=>
body
end
end
end
...
...
@@ -168,7 +168,7 @@ describe "Publisher Publishing Messages" do
EventMachine
.
stop
end
pub
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/pub?id='
+
channel
.
to_s
).
post
:head
=>
headers
.
merge
(
'Event-type'
=>
event_type
),
:body
=>
body
,
:timeout
=>
30
pub
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/pub?id='
+
channel
.
to_s
).
post
:head
=>
headers
.
merge
(
'Event-type'
=>
event_type
),
:body
=>
body
end
end
end
...
...
@@ -191,7 +191,7 @@ describe "Publisher Publishing Messages" do
EventMachine
.
stop
end
pub
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/pub?id='
+
channel
.
to_s
).
post
:head
=>
headers
.
merge
(
'Event-Ids'
=>
event_id
),
:body
=>
body
,
:timeout
=>
30
pub
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/pub?id='
+
channel
.
to_s
).
post
:head
=>
headers
.
merge
(
'Event-Ids'
=>
event_id
),
:body
=>
body
end
EventMachine
.
run
do
...
...
@@ -205,7 +205,7 @@ describe "Publisher Publishing Messages" do
EventMachine
.
stop
end
pub
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/pub?id='
+
channel
.
to_s
).
post
:head
=>
headers
.
merge
(
'Event-I'
=>
event_id
),
:body
=>
body
,
:timeout
=>
30
pub
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/pub?id='
+
channel
.
to_s
).
post
:head
=>
headers
.
merge
(
'Event-I'
=>
event_id
),
:body
=>
body
end
end
end
...
...
@@ -232,7 +232,7 @@ describe "Publisher Publishing Messages" do
end
now
=
Time
.
now
pub
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/pub?id='
+
channel
.
to_s
).
post
:head
=>
headers
,
:body
=>
body
,
:timeout
=>
30
pub
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/pub?id='
+
channel
.
to_s
).
post
:head
=>
headers
,
:body
=>
body
end
end
end
...
...
@@ -261,8 +261,8 @@ describe "Publisher Publishing Messages" do
EventMachine
.
stop
end
pub
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/pub?id='
+
channel
.
to_s
).
post
:head
=>
headers
,
:body
=>
body
,
:timeout
=>
30
pub
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/pub?id='
+
channel
.
to_s
).
post
:head
=>
headers
,
:body
=>
body
,
:timeout
=>
30
pub
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/pub?id='
+
channel
.
to_s
).
post
:head
=>
headers
,
:body
=>
body
pub
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/pub?id='
+
channel
.
to_s
).
post
:head
=>
headers
,
:body
=>
body
end
end
end
...
...
misc/spec/spec_helper.rb
View file @
9f95e062
...
...
@@ -16,7 +16,7 @@ RSpec.configure do |config|
end
def
publish_message_inline
(
channel
,
headers
,
body
,
&
block
)
pub
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/pub?id='
+
channel
.
to_s
).
post
:head
=>
headers
,
:body
=>
body
,
:timeout
=>
30
pub
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/pub?id='
+
channel
.
to_s
).
post
:head
=>
headers
,
:body
=>
body
pub
.
callback
do
fail
(
"Request was not accepted"
)
if
pub
.
response_header
.
status
!=
200
block
.
call
unless
block
.
nil?
...
...
@@ -49,7 +49,7 @@ def create_channel_by_subscribe(channel, headers, timeout=60, &block)
end
def
publish_message_inline_with_callbacks
(
channel
,
headers
,
body
,
callbacks
=
{})
pub
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/pub?id='
+
channel
.
to_s
).
post
:head
=>
headers
,
:body
=>
body
,
:timeout
=>
30
pub
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/pub?id='
+
channel
.
to_s
).
post
:head
=>
headers
,
:body
=>
body
pub
.
callback
do
if
pub
.
response_header
.
status
==
200
callbacks
[
:success
].
call
(
pub
.
response_header
.
status
,
pub
.
response
)
unless
callbacks
[
:success
].
nil?
...
...
misc/spec/subscriber/comunication_properties_spec.rb
View file @
9f95e062
...
...
@@ -16,7 +16,7 @@ describe "Comunication Properties" do
nginx_run_server
(
config
,
:timeout
=>
5
)
do
|
conf
|
EventMachine
.
run
do
sub
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
).
get
:head
=>
headers
,
:timeout
=>
60
sub
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
).
get
:head
=>
headers
sub
.
stream
do
|
chunk
|
chunk
.
should
eql
(
"
#{
conf
.
header_template
}
\r\n
"
)
EventMachine
.
stop
...
...
@@ -31,15 +31,15 @@ describe "Comunication Properties" do
nginx_run_server
(
config
.
merge
(
:authorized_channels_only
=>
"on"
),
:timeout
=>
5
)
do
|
conf
|
EventMachine
.
run
do
sub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
).
get
:head
=>
headers
,
:timeout
=>
60
sub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
).
get
:head
=>
headers
sub_1
.
callback
do
|
chunk
|
sub_1
.
response_header
.
status
.
should
eql
(
403
)
sub_1
.
response_header
.
content_length
.
should
eql
(
0
)
sub_1
.
response_header
[
'X_NGINX_PUSHSTREAM_EXPLAIN'
].
should
eql
(
"Subscriber could not create channels."
)
pub
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/pub?id='
+
channel
.
to_s
).
post
:head
=>
headers
,
:body
=>
body
,
:timeout
=>
30
pub
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/pub?id='
+
channel
.
to_s
).
post
:head
=>
headers
,
:body
=>
body
pub
.
callback
do
sub_2
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
).
get
:head
=>
headers
,
:timeout
=>
60
sub_2
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
).
get
:head
=>
headers
sub_2
.
stream
do
|
chunk2
|
chunk2
.
should
eql
(
"
#{
conf
.
header_template
}
\r\n
"
)
EventMachine
.
stop
...
...
@@ -58,9 +58,9 @@ describe "Comunication Properties" do
nginx_run_server
(
config
,
:timeout
=>
20
)
do
|
conf
|
EventMachine
.
run
do
pub
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/pub?id='
+
channel
.
to_s
).
post
:head
=>
headers
,
:body
=>
body
,
:timeout
=>
30
pub
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/pub?id='
+
channel
.
to_s
).
post
:head
=>
headers
,
:body
=>
body
time_2
=
EM
.
add_timer
(
2
)
do
sub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
+
'.b1'
).
get
:head
=>
headers
,
:timeout
=>
60
sub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
+
'.b1'
).
get
:head
=>
headers
sub_1
.
stream
do
|
chunk
|
response_1
+=
chunk
unless
response_1
.
include?
(
body
)
sub_1
.
close
if
response_1
.
include?
(
body
)
...
...
@@ -68,7 +68,7 @@ describe "Comunication Properties" do
end
EM
.
add_timer
(
6
)
do
sub_2
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
+
'.b1'
).
get
:head
=>
headers
,
:timeout
=>
60
sub_2
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
+
'.b1'
).
get
:head
=>
headers
sub_2
.
stream
do
|
chunk
|
response_2
+=
chunk
unless
response_2
.
include?
(
body
)
sub_2
.
close
if
response_2
.
include?
(
body
)
...
...
@@ -77,7 +77,7 @@ describe "Comunication Properties" do
#message will be certainly expired at 15 seconds
EM
.
add_timer
(
16
)
do
sub_3
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
+
'.b1'
).
get
:head
=>
headers
,
:timeout
=>
60
sub_3
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
+
'.b1'
).
get
:head
=>
headers
sub_3
.
stream
do
|
chunk
|
response_3
+=
chunk
unless
response_3
.
include?
(
body
)
sub_3
.
close
if
response_3
.
include?
(
body
)
...
...
@@ -103,7 +103,7 @@ describe "Comunication Properties" do
publish_message
(
channel
,
headers
,
body
)
EventMachine
.
run
do
sub
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
+
'.b1'
).
get
:head
=>
headers
,
:timeout
=>
60
sub
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
+
'.b1'
).
get
:head
=>
headers
sub
.
stream
do
|
chunk
|
response
+=
chunk
...
...
@@ -129,7 +129,7 @@ describe "Comunication Properties" do
publish_message
(
channel
,
headers
,
body
)
EventMachine
.
run
do
sub
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
+
'.b1'
).
get
:head
=>
headers
,
:timeout
=>
60
sub
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
+
'.b1'
).
get
:head
=>
headers
sub
.
stream
do
|
chunk
|
response
+=
chunk
...
...
misc/spec/subscriber/padding_by_user_agent_spec.rb
View file @
9f95e062
...
...
@@ -17,17 +17,17 @@ describe "Subscriber Padding by user agent" do
nginx_run_server
(
config
.
merge
(
:header_template
=>
"0123456789"
),
:timeout
=>
5
)
do
|
conf
|
EventMachine
.
run
do
sub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
).
get
:head
=>
headers
.
merge
(
"User-Agent"
=>
"Test 1"
)
,
:timeout
=>
30
sub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
).
get
:head
=>
headers
.
merge
(
"User-Agent"
=>
"Test 1"
)
sub_1
.
callback
do
sub_1
.
response_header
.
status
.
should
eql
(
200
)
sub_1
.
response
.
size
.
should
eql
(
1100
+
conf
.
header_template
.
size
+
4
)
sub_2
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
).
get
:head
=>
headers
.
merge
(
"User-Agent"
=>
"Test 2"
)
,
:timeout
=>
30
sub_2
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
).
get
:head
=>
headers
.
merge
(
"User-Agent"
=>
"Test 2"
)
sub_2
.
callback
do
sub_2
.
response_header
.
status
.
should
eql
(
200
)
sub_2
.
response
.
size
.
should
eql
(
4097
+
conf
.
header_template
.
size
+
4
)
sub_3
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
).
get
:head
=>
headers
.
merge
(
"User-Agent"
=>
"Test 3"
)
,
:timeout
=>
30
sub_3
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
).
get
:head
=>
headers
.
merge
(
"User-Agent"
=>
"Test 3"
)
sub_3
.
callback
do
sub_3
.
response_header
.
status
.
should
eql
(
200
)
sub_3
.
response
.
size
.
should
eql
(
conf
.
header_template
.
size
+
2
)
...
...
@@ -47,17 +47,17 @@ describe "Subscriber Padding by user agent" do
nginx_run_server
(
config
,
:timeout
=>
5
)
do
|
conf
|
EventMachine
.
run
do
sub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
).
get
:head
=>
headers
.
merge
(
"User-Agent"
=>
"Test 1"
)
,
:timeout
=>
30
sub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
).
get
:head
=>
headers
.
merge
(
"User-Agent"
=>
"Test 1"
)
sub_1
.
callback
{
sub_1
.
response_header
.
status
.
should
eql
(
200
)
sub_1
.
response
.
size
.
should
eql
(
500
+
body
.
size
+
4
)
sub_2
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
).
get
:head
=>
headers
.
merge
(
"User-Agent"
=>
"Test 2"
)
,
:timeout
=>
30
sub_2
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
).
get
:head
=>
headers
.
merge
(
"User-Agent"
=>
"Test 2"
)
sub_2
.
callback
{
sub_2
.
response_header
.
status
.
should
eql
(
200
)
sub_2
.
response
.
size
.
should
eql
(
body
.
size
+
2
)
sub_3
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
).
get
:head
=>
headers
.
merge
(
"User-Agent"
=>
"Test 3"
)
,
:timeout
=>
30
sub_3
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
).
get
:head
=>
headers
.
merge
(
"User-Agent"
=>
"Test 3"
)
sub_3
.
callback
{
sub_3
.
response_header
.
status
.
should
eql
(
200
)
sub_3
.
response
.
size
.
should
eql
(
body
.
size
+
2
)
...
...
@@ -81,7 +81,7 @@ describe "Subscriber Padding by user agent" do
i
=
1
expected_padding
=
545
sub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
).
get
:head
=>
headers
.
merge
(
"User-Agent"
=>
"Test 1"
)
,
:timeout
=>
30
sub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
).
get
:head
=>
headers
.
merge
(
"User-Agent"
=>
"Test 1"
)
sub_1
.
callback
do
sub_1
.
response_header
.
status
.
should
eql
(
200
)
sub_1
.
response
.
size
.
should
eql
(
expected_padding
+
i
+
4
)
...
...
@@ -89,7 +89,7 @@ describe "Subscriber Padding by user agent" do
i
=
105
expected_padding
=
600
-
((
i
/
100
).
to_i
*
100
)
sub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
).
get
:head
=>
headers
.
merge
(
"User-Agent"
=>
"Test 1"
)
,
:timeout
=>
30
sub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
).
get
:head
=>
headers
.
merge
(
"User-Agent"
=>
"Test 1"
)
sub_1
.
callback
do
sub_1
.
response_header
.
status
.
should
eql
(
200
)
sub_1
.
response
.
size
.
should
eql
(
expected_padding
+
i
+
4
)
...
...
@@ -97,7 +97,7 @@ describe "Subscriber Padding by user agent" do
i
=
221
expected_padding
=
600
-
((
i
/
100
).
to_i
*
100
)
sub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
).
get
:head
=>
headers
.
merge
(
"User-Agent"
=>
"Test 1"
)
,
:timeout
=>
30
sub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
).
get
:head
=>
headers
.
merge
(
"User-Agent"
=>
"Test 1"
)
sub_1
.
callback
do
sub_1
.
response_header
.
status
.
should
eql
(
200
)
sub_1
.
response
.
size
.
should
eql
(
expected_padding
+
i
+
4
)
...
...
@@ -105,7 +105,7 @@ describe "Subscriber Padding by user agent" do
i
=
331
expected_padding
=
600
-
((
i
/
100
).
to_i
*
100
)
sub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
).
get
:head
=>
headers
.
merge
(
"User-Agent"
=>
"Test 1"
)
,
:timeout
=>
30
sub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
).
get
:head
=>
headers
.
merge
(
"User-Agent"
=>
"Test 1"
)
sub_1
.
callback
do
sub_1
.
response_header
.
status
.
should
eql
(
200
)
sub_1
.
response
.
size
.
should
eql
(
expected_padding
+
i
+
4
)
...
...
@@ -113,7 +113,7 @@ describe "Subscriber Padding by user agent" do
i
=
435
expected_padding
=
600
-
((
i
/
100
).
to_i
*
100
)
sub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
).
get
:head
=>
headers
.
merge
(
"User-Agent"
=>
"Test 1"
)
,
:timeout
=>
30
sub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
).
get
:head
=>
headers
.
merge
(
"User-Agent"
=>
"Test 1"
)
sub_1
.
callback
do
sub_1
.
response_header
.
status
.
should
eql
(
200
)
sub_1
.
response
.
size
.
should
eql
(
expected_padding
+
i
+
4
)
...
...
@@ -121,14 +121,14 @@ describe "Subscriber Padding by user agent" do
i
=
502
expected_padding
=
600
-
((
i
/
100
).
to_i
*
100
)
sub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
).
get
:head
=>
headers
.
merge
(
"User-Agent"
=>
"Test 1"
)
,
:timeout
=>
30
sub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
).
get
:head
=>
headers
.
merge
(
"User-Agent"
=>
"Test 1"
)
sub_1
.
callback
do
sub_1
.
response_header
.
status
.
should
eql
(
200
)
sub_1
.
response
.
size
.
should
eql
(
expected_padding
+
i
+
4
)
i
=
550
sub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
).
get
:head
=>
headers
.
merge
(
"User-Agent"
=>
"Test 1"
)
,
:timeout
=>
30
sub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
).
get
:head
=>
headers
.
merge
(
"User-Agent"
=>
"Test 1"
)
sub_1
.
callback
do
sub_1
.
response_header
.
status
.
should
eql
(
200
)
sub_1
.
response
.
size
.
should
eql
(
i
+
2
)
...
...
@@ -157,12 +157,12 @@ describe "Subscriber Padding by user agent" do
nginx_run_server
(
config
.
merge
(
:padding_by_user_agent
=>
"[T|t]est 1,1024,512"
,
:user_agent
=>
"$arg_ua"
,
:header_template
=>
"0123456789"
),
:timeout
=>
10
)
do
|
conf
|
EventMachine
.
run
do
sub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
+
'?ua=test 1'
).
get
:head
=>
headers
,
:timeout
=>
30
sub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
+
'?ua=test 1'
).
get
:head
=>
headers
sub_1
.
callback
do
sub_1
.
response_header
.
status
.
should
eql
(
200
)
sub_1
.
response
.
size
.
should
eql
(
1024
+
conf
.
header_template
.
size
+
4
)
sub_2
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
+
'?ua=test 2'
).
get
:head
=>
headers
,
:timeout
=>
30
sub_2
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
+
'?ua=test 2'
).
get
:head
=>
headers
sub_2
.
callback
do
sub_2
.
response_header
.
status
.
should
eql
(
200
)
sub_2
.
response
.
size
.
should
eql
(
conf
.
header_template
.
size
+
2
)
...
...
misc/spec/subscriber/properties_spec.rb
View file @
9f95e062
...
...
@@ -14,7 +14,7 @@ describe "Subscriber Properties" do
it
"should not accept access without a channel path"
do
nginx_run_server
(
config
,
:timeout
=>
5
)
do
|
conf
|
EventMachine
.
run
do
sub
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
).
get
:head
=>
headers
,
:timeout
=>
30
sub
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
).
get
:head
=>
headers
sub
.
callback
do
sub
.
response_header
.
content_length
.
should
eql
(
0
)
sub
.
response_header
.
status
.
should
eql
(
400
)
...
...
@@ -76,7 +76,7 @@ describe "Subscriber Properties" do
nginx_run_server
(
config
,
:timeout
=>
5
)
do
|
conf
|
EventMachine
.
run
do
sub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
).
get
:head
=>
headers
,
:timeout
=>
30
sub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
).
get
:head
=>
headers
sub_1
.
callback
do
sub_1
.
response_header
.
status
.
should
eql
(
403
)
sub_1
.
response_header
.
content_length
.
should
eql
(
0
)
...
...
@@ -96,9 +96,9 @@ describe "Subscriber Properties" do
EventMachine
.
run
do
multi
=
EventMachine
::
MultiRequest
.
new
multi
.
add
(
:a
,
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel_1
).
get
(
:head
=>
headers
,
:timeout
=>
30
))
multi
.
add
(
:b
,
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel_2
).
get
(
:head
=>
headers
,
:timeout
=>
30
))
multi
.
add
(
:c
,
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel_3
).
get
(
:head
=>
headers
,
:timeout
=>
30
))
multi
.
add
(
:a
,
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel_1
).
get
(
:head
=>
headers
))
multi
.
add
(
:b
,
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel_2
).
get
(
:head
=>
headers
))
multi
.
add
(
:c
,
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel_3
).
get
(
:head
=>
headers
))
multi
.
callback
do
multi
.
responses
[
:callback
].
length
.
should
eql
(
3
)
multi
.
responses
[
:callback
].
each
do
|
name
,
response
|
...
...
@@ -143,7 +143,7 @@ describe "Subscriber Properties" do
nginx_run_server
(
config
.
merge
(
:max_channel_id_length
=>
5
),
:timeout
=>
5
)
do
|
conf
|
EventMachine
.
run
do
sub
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
).
get
:head
=>
headers
,
:timeout
=>
30
sub
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
).
get
:head
=>
headers
sub
.
callback
do
sub
.
response_header
.
content_length
.
should
eql
(
0
)
sub
.
response_header
.
status
.
should
eql
(
400
)
...
...
@@ -227,7 +227,7 @@ describe "Subscriber Properties" do
nginx_run_server
(
config
.
merge
(
:authorized_channels_only
=>
'on'
),
:timeout
=>
5
)
do
|
conf
|
EventMachine
.
run
do
sub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
).
get
:head
=>
headers
,
:timeout
=>
30
sub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
).
get
:head
=>
headers
sub_1
.
callback
do
sub_1
.
response_header
.
status
.
should
eql
(
403
)
sub_1
.
response_header
.
content_length
.
should
eql
(
0
)
...
...
@@ -247,7 +247,7 @@ describe "Subscriber Properties" do
publish_message
(
channel
,
headers
,
body
)
EventMachine
.
run
do
sub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
).
get
:head
=>
headers
,
:timeout
=>
30
sub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
).
get
:head
=>
headers
sub_1
.
callback
do
sub_1
.
response_header
.
status
.
should
eql
(
200
)
EventMachine
.
stop
...
...
@@ -267,7 +267,7 @@ describe "Subscriber Properties" do
publish_message
(
channel
,
headers
,
body
)
EventMachine
.
run
do
sub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
+
'/'
+
broadcast_channel
.
to_s
).
get
:head
=>
headers
,
:timeout
=>
30
sub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
+
'/'
+
broadcast_channel
.
to_s
).
get
:head
=>
headers
sub_1
.
callback
do
sub_1
.
response_header
.
status
.
should
eql
(
200
)
EventMachine
.
stop
...
...
@@ -287,7 +287,7 @@ describe "Subscriber Properties" do
sleep
(
5
)
#to ensure message was gone
EventMachine
.
run
do
sub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
).
get
:head
=>
headers
,
:timeout
=>
30
sub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
).
get
:head
=>
headers
sub_1
.
callback
do
sub_1
.
response_header
.
status
.
should
eql
(
403
)
sub_1
.
response_header
.
content_length
.
should
eql
(
0
)
...
...
@@ -310,7 +310,7 @@ describe "Subscriber Properties" do
sleep
(
5
)
#to ensure message was gone
EventMachine
.
run
do
sub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
+
'/'
+
broadcast_channel
.
to_s
).
get
:head
=>
headers
,
:timeout
=>
30
sub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
+
'/'
+
broadcast_channel
.
to_s
).
get
:head
=>
headers
sub_1
.
callback
do
sub_1
.
response_header
.
status
.
should
eql
(
403
)
sub_1
.
response_header
.
content_length
.
should
eql
(
0
)
...
...
@@ -338,7 +338,7 @@ describe "Subscriber Properties" do
end
EventMachine
.
run
do
sub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel_1
.
to_s
+
'/'
+
channel_2
.
to_s
+
'.b5'
+
'/'
+
channel_3
.
to_s
+
'.b2'
).
get
:head
=>
headers
,
:timeout
=>
30
sub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel_1
.
to_s
+
'/'
+
channel_2
.
to_s
+
'.b5'
+
'/'
+
channel_3
.
to_s
+
'.b2'
).
get
:head
=>
headers
sub_1
.
stream
do
|
chunk
|
response
+=
chunk
lines
=
response
.
split
(
"
\r\n
"
)
...
...
@@ -390,7 +390,7 @@ describe "Subscriber Properties" do
response
=
""
nginx_run_server
(
config
.
merge
(
:header_template
=>
nil
,
:message_template
=>
'{\"channel\":\"~channel~\", \"id\":\"~id~\", \"message\":\"~text~\"}'
),
:timeout
=>
5
)
do
|
conf
|
EventMachine
.
run
do
sub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel_1
.
to_s
+
'/'
+
channel_2
.
to_s
+
'/'
+
channel_3
.
to_s
+
'/'
+
channel_4
.
to_s
+
'/'
+
channel_5
.
to_s
+
'/'
+
channel_6
.
to_s
).
get
:head
=>
headers
,
:timeout
=>
30
sub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel_1
.
to_s
+
'/'
+
channel_2
.
to_s
+
'/'
+
channel_3
.
to_s
+
'/'
+
channel_4
.
to_s
+
'/'
+
channel_5
.
to_s
+
'/'
+
channel_6
.
to_s
).
get
:head
=>
headers
sub_1
.
stream
do
|
chunk
|
response
+=
chunk
lines
=
response
.
split
(
"
\r\n
"
)
...
...
@@ -466,7 +466,7 @@ describe "Subscriber Properties" do
response
=
""
EventMachine
.
run
do
sub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel_1
.
to_s
+
'/'
+
channel_2
.
to_s
+
'/'
+
channel_3
.
to_s
).
get
:head
=>
sent_headers
,
:timeout
=>
30
sub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel_1
.
to_s
+
'/'
+
channel_2
.
to_s
+
'/'
+
channel_3
.
to_s
).
get
:head
=>
sent_headers
sub_1
.
stream
do
|
chunk
|
response
+=
chunk
lines
=
response
.
split
(
"
\r\n
"
)
...
...
@@ -527,7 +527,7 @@ describe "Subscriber Properties" do
response
=
""
EventMachine
.
run
do
sub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel_1
.
to_s
+
'/'
+
channel_2
.
to_s
+
'.b5'
+
'/'
+
channel_3
.
to_s
).
get
:head
=>
sent_headers
,
:timeout
=>
30
sub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel_1
.
to_s
+
'/'
+
channel_2
.
to_s
+
'.b5'
+
'/'
+
channel_3
.
to_s
).
get
:head
=>
sent_headers
sub_1
.
stream
do
|
chunk
|
response
+=
chunk
lines
=
response
.
split
(
"
\r\n
"
)
...
...
@@ -577,12 +577,12 @@ describe "Subscriber Properties" do
nginx_run_server
(
config
.
merge
(
:max_number_of_channels
=>
1
),
:timeout
=>
5
)
do
|
conf
|
EventMachine
.
run
do
sub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
+
1
.
to_s
).
get
:head
=>
headers
,
:timeout
=>
30
sub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
+
1
.
to_s
).
get
:head
=>
headers
sub_1
.
stream
do
sub_1
.
response_header
.
status
.
should
eql
(
200
)
sub_1
.
response_header
.
content_length
.
should_not
eql
(
0
)
sub_2
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
+
2
.
to_s
).
get
:head
=>
headers
,
:timeout
=>
30
sub_2
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
+
2
.
to_s
).
get
:head
=>
headers
sub_2
.
callback
do
sub_2
.
response_header
.
status
.
should
eql
(
403
)
sub_2
.
response_header
.
content_length
.
should
eql
(
0
)
...
...
@@ -599,12 +599,12 @@ describe "Subscriber Properties" do
nginx_run_server
(
config
.
merge
(
:max_number_of_broadcast_channels
=>
1
,
:broadcast_channel_prefix
=>
'bd_'
,
:broadcast_channel_max_qtd
=>
1
),
:timeout
=>
5
)
do
|
conf
|
EventMachine
.
run
do
sub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/ch1/'
+
channel
.
to_s
+
1
.
to_s
).
get
:head
=>
headers
,
:timeout
=>
30
sub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/ch1/'
+
channel
.
to_s
+
1
.
to_s
).
get
:head
=>
headers
sub_1
.
stream
do
sub_1
.
response_header
.
status
.
should
eql
(
200
)
sub_1
.
response_header
.
content_length
.
should_not
eql
(
0
)
sub_2
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/ch1/'
+
channel
.
to_s
+
2
.
to_s
).
get
:head
=>
headers
,
:timeout
=>
30
sub_2
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/ch1/'
+
channel
.
to_s
+
2
.
to_s
).
get
:head
=>
headers
sub_2
.
callback
do
sub_2
.
response_header
.
status
.
should
eql
(
403
)
sub_2
.
response_header
.
content_length
.
should
eql
(
0
)
...
...
@@ -640,7 +640,7 @@ describe "Subscriber Properties" do
nginx_run_server
(
configuration
,
:timeout
=>
5
)
do
|
conf
|
EventMachine
.
run
do
sub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
).
get
:head
=>
headers
,
:timeout
=>
30
sub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
).
get
:head
=>
headers
sub_1
.
stream
do
|
chunk
|
response
=
JSON
.
parse
(
chunk
)
response
[
'msg'
].
should
be_nil
...
...
@@ -648,7 +648,7 @@ describe "Subscriber Properties" do
EventMachine
.
stop
end
sub_2
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub2/'
+
channel
.
to_s
+
'.b1'
).
get
:head
=>
headers
,
:timeout
=>
30
sub_2
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub2/'
+
channel
.
to_s
+
'.b1'
).
get
:head
=>
headers
sub_2
.
stream
do
|
chunk
|
response
=
JSON
.
parse
(
chunk
)
response
[
'text'
].
should
be_nil
...
...
@@ -661,7 +661,7 @@ describe "Subscriber Properties" do
end
EventMachine
.
run
do
sub_3
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
+
'.b1'
).
get
:head
=>
headers
,
:timeout
=>
30
sub_3
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
+
'.b1'
).
get
:head
=>
headers
sub_3
.
stream
do
|
chunk
|
response
=
JSON
.
parse
(
chunk
)
response
[
'msg'
].
should
be_nil
...
...
@@ -671,7 +671,7 @@ describe "Subscriber Properties" do
end
EventMachine
.
run
do
sub_4
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub2/'
+
channel
.
to_s
+
'.b1'
).
get
:head
=>
headers
,
:timeout
=>
30
sub_4
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub2/'
+
channel
.
to_s
+
'.b1'
).
get
:head
=>
headers
sub_4
.
stream
do
|
chunk
|
response
=
JSON
.
parse
(
chunk
)
response
[
'text'
].
should
be_nil
...
...
@@ -688,7 +688,7 @@ describe "Subscriber Properties" do
nginx_run_server
(
config
.
merge
(
:message_template
=>
nil
,
:header_template
=>
nil
),
:timeout
=>
5
)
do
|
conf
|
EventMachine
.
run
do
sub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
).
get
:head
=>
headers
,
:timeout
=>
30
sub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
).
get
:head
=>
headers
sub_1
.
stream
do
|
chunk
|
chunk
.
should
eql
(
"
#{
body
}
\r\n
"
)
EventMachine
.
stop
...
...
@@ -706,7 +706,7 @@ describe "Subscriber Properties" do
nginx_run_server
(
config
.
merge
(
:subscriber_connection_ttl
=>
nil
,
:message_template
=>
nil
,
:header_template
=>
nil
,
:ping_message_interval
=>
'1s'
,
:ping_message_text
=>
nil
),
:timeout
=>
5
)
do
|
conf
|
EventMachine
.
run
do
sub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
).
get
:head
=>
headers
,
:timeout
=>
30
sub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
).
get
:head
=>
headers
sub_1
.
stream
do
|
chunk
|
chunk
.
should
eql
(
"
\r\n
"
)
EventMachine
.
stop
...
...
@@ -721,7 +721,7 @@ describe "Subscriber Properties" do
nginx_run_server
(
config
.
merge
(
:subscriber_connection_ttl
=>
nil
,
:message_template
=>
nil
,
:header_template
=>
nil
,
:ping_message_interval
=>
'1s'
,
:ping_message_text
=>
"pinging you!!!"
),
:timeout
=>
5
)
do
|
conf
|
EventMachine
.
run
do
sub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
).
get
:head
=>
headers
,
:timeout
=>
30
sub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
).
get
:head
=>
headers
sub_1
.
stream
do
|
chunk
|
chunk
.
should
eql
(
"
#{
conf
.
ping_message_text
}
\r\n
"
)
EventMachine
.
stop
...
...
@@ -736,7 +736,7 @@ describe "Subscriber Properties" do
nginx_run_server
(
config
.
merge
(
:subscriber_connection_ttl
=>
nil
,
:message_template
=>
"~id~:~text~"
,
:header_template
=>
nil
,
:ping_message_interval
=>
'1s'
,
:ping_message_text
=>
nil
),
:timeout
=>
5
)
do
|
conf
|
EventMachine
.
run
do
sub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
).
get
:head
=>
headers
,
:timeout
=>
30
sub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
).
get
:head
=>
headers
sub_1
.
stream
do
|
chunk
|
chunk
.
should
eql
(
"-1:
\r\n
"
)
EventMachine
.
stop
...
...
@@ -751,7 +751,7 @@ describe "Subscriber Properties" do
nginx_run_server
(
config
.
merge
(
:subscriber_connection_ttl
=>
nil
,
:message_template
=>
"~id~:~text~"
,
:header_template
=>
nil
,
:ping_message_interval
=>
'1s'
,
:ping_message_text
=>
"pinging you!!!"
),
:timeout
=>
5
)
do
|
conf
|
EventMachine
.
run
do
sub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
).
get
:head
=>
headers
,
:timeout
=>
30
sub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
).
get
:head
=>
headers
sub_1
.
stream
do
|
chunk
|
chunk
.
should
eql
(
"-1:
#{
conf
.
ping_message_text
}
\r\n
"
)
EventMachine
.
stop
...
...
@@ -765,7 +765,7 @@ describe "Subscriber Properties" do
nginx_run_server
(
config
,
:timeout
=>
5
)
do
|
conf
|
EventMachine
.
run
do
sub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
).
get
:head
=>
headers
,
:timeout
=>
30
sub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
).
get
:head
=>
headers
sub_1
.
stream
do
|
chunk
|
sub_1
.
response_header
[
'TRANSFER_ENCODING'
].
should
eql
(
"chunked"
)
EventMachine
.
stop
...
...
@@ -780,17 +780,17 @@ describe "Subscriber Properties" do
nginx_run_server
(
config
.
merge
(
:max_subscribers_per_channel
=>
3
,
:subscriber_connection_ttl
=>
"3s"
),
:timeout
=>
5
)
do
|
conf
|
EventMachine
.
run
do
sub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
).
get
:head
=>
headers
,
:timeout
=>
30
sub_2
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
).
get
:head
=>
headers
,
:timeout
=>
30
sub_3
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
).
get
:head
=>
headers
,
:timeout
=>
30
sub_4
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
).
get
:head
=>
headers
,
:timeout
=>
30
sub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
).
get
:head
=>
headers
sub_2
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
).
get
:head
=>
headers
sub_3
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
).
get
:head
=>
headers
sub_4
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
).
get
:head
=>
headers
sub_4
.
callback
do
sub_4
.
response_header
.
status
.
should
eql
(
403
)
sub_4
.
response_header
.
content_length
.
should
eql
(
0
)
sub_4
.
response_header
[
'X_NGINX_PUSHSTREAM_EXPLAIN'
].
should
eql
(
"Subscribers limit per channel has been exceeded."
)
end
sub_5
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
other_channel
.
to_s
).
get
:head
=>
headers
,
:timeout
=>
30
sub_5
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
other_channel
.
to_s
).
get
:head
=>
headers
sub_5
.
callback
do
sub_5
.
response_header
.
status
.
should
eql
(
200
)
EventMachine
.
stop
...
...
@@ -839,7 +839,7 @@ describe "Subscriber Properties" do
nginx_run_server
(
config
,
:timeout
=>
5
)
do
|
conf
|
EventMachine
.
run
do
sub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
).
get
:head
=>
headers
,
:timeout
=>
30
sub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
).
get
:head
=>
headers
sub_1
.
stream
do
|
chunk
|
sub_1
.
response_header
[
'ACCESS_CONTROL_ALLOW_ORIGIN'
].
should
eql
(
"*"
)
sub_1
.
response_header
[
'ACCESS_CONTROL_ALLOW_METHODS'
].
should
eql
(
"GET"
)
...
...
@@ -856,7 +856,7 @@ describe "Subscriber Properties" do
nginx_run_server
(
config
,
:timeout
=>
5
)
do
|
conf
|
EventMachine
.
run
do
sub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
).
get
:head
=>
headers
,
:timeout
=>
30
sub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
).
get
:head
=>
headers
sub_1
.
stream
do
|
chunk
|
sub_1
.
response_header
[
'ACCESS_CONTROL_ALLOW_ORIGIN'
].
should
eql
(
"*"
)
...
...
@@ -871,7 +871,7 @@ describe "Subscriber Properties" do
nginx_run_server
(
config
.
merge
(
:allowed_origins
=>
"custom.domain.com"
),
:timeout
=>
5
)
do
|
conf
|
EventMachine
.
run
do
sub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
).
get
:head
=>
headers
,
:timeout
=>
30
sub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
).
get
:head
=>
headers
sub_1
.
stream
do
|
chunk
|
sub_1
.
response_header
[
'ACCESS_CONTROL_ALLOW_ORIGIN'
].
should
eql
(
"custom.domain.com"
)
EventMachine
.
stop
...
...
@@ -885,7 +885,7 @@ describe "Subscriber Properties" do
nginx_run_server
(
config
,
:timeout
=>
5
)
do
|
conf
|
EventMachine
.
run
do
sub
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
).
get
:head
=>
headers
,
:timeout
=>
60
sub
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
).
get
:head
=>
headers
sub
.
stream
do
|
chunk
|
chunk
.
should
eql
(
"
#{
conf
.
header_template
}
\r\n
"
)
EventMachine
.
stop
...
...
@@ -899,7 +899,7 @@ describe "Subscriber Properties" do
nginx_run_server
(
config
,
:timeout
=>
5
)
do
|
conf
|
EventMachine
.
run
do
sub
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
).
get
:head
=>
headers
,
:timeout
=>
60
sub
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
).
get
:head
=>
headers
sub
.
stream
do
|
chunk
|
sub
.
response_header
[
'CONTENT_TYPE'
].
should
eql
(
conf
.
content_type
)
EventMachine
.
stop
...
...
@@ -916,7 +916,7 @@ describe "Subscriber Properties" do
nginx_run_server
(
config
.
merge
(
:subscriber_connection_ttl
=>
nil
),
:timeout
=>
10
)
do
|
conf
|
EventMachine
.
run
do
sub
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
).
get
:head
=>
headers
,
:timeout
=>
60
sub
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
).
get
:head
=>
headers
sub
.
stream
do
|
chunk
|
chunks_received
+=
1
;
step1
=
Time
.
now
if
chunks_received
==
1
...
...
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