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
3ac55889
Commit
3ac55889
authored
Sep 07, 2011
by
Wandenberg Peixoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
improving some tests
parent
cef7f302
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
96 additions
and
23 deletions
+96
-23
base_test_case.rb
test/base_test_case.rb
+3
-1
test_publisher_admin.rb
test/test_publisher_admin.rb
+1
-0
test_send_signals.rb
test/test_send_signals.rb
+25
-22
test_subscriber_connection_cleanup.rb
test/test_subscriber_connection_cleanup.rb
+67
-0
No files found.
test/base_test_case.rb
View file @
3ac55889
...
...
@@ -23,10 +23,12 @@ module BaseTestCase
end
def
teardown
old_cld_trap
=
Signal
.
trap
(
"CLD"
,
"IGNORE"
)
unless
@disable_ignore_childs
unless
@disable_start_stop_server
self
.
stop_server
end
self
.
delete_config_and_log_files
Signal
.
trap
(
"CLD"
,
old_cld_trap
)
unless
@disable_ignore_childs
end
def
nginx_executable
...
...
@@ -285,7 +287,7 @@ http {
# activate subscriber mode for this location
push_stream_subscriber;
# activate eventsource support for this location
# activate event
source support for this location
<%= "push_stream_subscriber_eventsource #{@subscriber_eventsource};" unless @subscriber_eventsource.nil? %>
# positional channel path
...
...
test/test_publisher_admin.rb
View file @
3ac55889
...
...
@@ -473,6 +473,7 @@ class TestPublisherAdmin < Test::Unit::TestCase
EventMachine
.
stop
end
}
add_test_timeout
}
end
...
...
test/test_send_signals.rb
View file @
3ac55889
...
...
@@ -11,6 +11,7 @@ class TestSendSignals < Test::Unit::TestCase
@master_process
=
'on'
@daemon
=
'on'
@header_template
=
'HEADER'
@disable_ignore_childs
=
true
end
def
test_send_hup_signal
...
...
@@ -41,31 +42,31 @@ class TestSendSignals < Test::Unit::TestCase
pid
=
resp_1
[
"by_worker"
][
0
][
'pid'
].
to_i
# send reload signal
POpen4
::
popen4
(
"
#{
nginx_executable
}
-c
#{
config_filename
}
-s reload"
)
do
# publish a message
pub_2
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/pub?id='
+
channel
.
to_s
).
post
:head
=>
headers
,
:body
=>
body
,
:timeout
=>
30
pub_2
.
callback
{
# add new subscriber
sub_2
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
+
'.b1'
).
get
:head
=>
headers
,
:timeout
=>
30
sub_2
.
stream
{
|
chunk
|
response2
=
response2
+
chunk
if
response2
.
strip
==
@header_template
# check statistics again
pub_3
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/channels-stats'
).
get
:head
=>
headers
,
:timeout
=>
30
pub_3
.
callback
{
`
#{
nginx_executable
}
-c
#{
config_filename
}
-s reload`
resp_2
=
JSON
.
parse
(
pub_3
.
response
)
assert
(
resp_2
.
has_key?
(
"channels"
),
"Didn't received the correct answer with channels info"
)
assert_equal
(
1
,
resp_2
[
"channels"
].
to_i
,
"Didn't create channel"
)
assert_equal
(
1
,
resp_2
[
"published_messages"
].
to_i
,
"Didn't create messages"
)
assert_equal
(
2
,
resp_2
[
"subscribers"
].
to_i
,
"Didn't create subscribers"
)
assert_equal
(
2
,
resp_2
[
"by_worker"
].
count
,
"Didn't return infos by_worker"
)
# publish a message
pub_2
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/pub?id='
+
channel
.
to_s
).
post
:head
=>
headers
,
:body
=>
body
,
:timeout
=>
30
pub_2
.
callback
{
# add new subscriber
sub_2
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
+
'.b1'
).
get
:head
=>
headers
,
:timeout
=>
30
sub_2
.
stream
{
|
chunk
|
response2
=
response2
+
chunk
if
response2
.
strip
==
@header_template
# check statistics again
pub_3
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/channels-stats'
).
get
:head
=>
headers
,
:timeout
=>
30
pub_3
.
callback
{
}
end
}
resp_2
=
JSON
.
parse
(
pub_3
.
response
)
assert
(
resp_2
.
has_key?
(
"channels"
),
"Didn't received the correct answer with channels info"
)
assert_equal
(
1
,
resp_2
[
"channels"
].
to_i
,
"Didn't create channel"
)
assert_equal
(
1
,
resp_2
[
"published_messages"
].
to_i
,
"Didn't create messages"
)
assert_equal
(
2
,
resp_2
[
"subscribers"
].
to_i
,
"Didn't create subscribers"
)
assert_equal
(
2
,
resp_2
[
"by_worker"
].
count
,
"Didn't return infos by_worker"
)
}
end
}
end
}
rescue
JSON
::
ParserError
fail
(
"Didn't receive a valid response"
)
EventMachine
.
stop
...
...
@@ -102,6 +103,8 @@ class TestSendSignals < Test::Unit::TestCase
end
}
end
add_test_timeout
(
60
)
}
end
end
test/test_subscriber_connection_cleanup.rb
View file @
3ac55889
...
...
@@ -30,6 +30,8 @@ class TestSubscriberConnectionCleanup < Test::Unit::TestCase
assert
(
response
.
include?
(
@footer_template
),
"Didn't received footer template"
)
EventMachine
.
stop
}
add_test_timeout
(
50
)
}
end
...
...
@@ -59,6 +61,71 @@ class TestSubscriberConnectionCleanup < Test::Unit::TestCase
assert_equal
(
7
,
chunksReceived
,
"Received
#{
chunksReceived
}
chunks"
)
EventMachine
.
stop
}
add_test_timeout
(
50
)
}
end
def
config_test_multiple_subscribers_connection_timeout
@subscriber_connection_timeout
=
"5s"
@header_template
=
"HEADER_TEMPLATE"
@footer_template
=
"FOOTER_TEMPLATE"
@ping_message_interval
=
nil
end
def
test_multiple_subscribers_connection_timeout
channel
=
'ch_test_multiple_subscribers_connection_timeout'
headers
=
{
'accept'
=>
'text/html'
}
EventMachine
.
run
{
response_1
=
''
sub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
).
get
:head
=>
headers
,
:timeout
=>
60
sub_1
.
stream
{
|
chunk
|
response_1
+=
chunk
assert
(
response_1
.
include?
(
@header_template
),
"Didn't received header template"
)
}
sub_1
.
callback
{
assert
(
response_1
.
include?
(
@footer_template
),
"Didn't received footer template"
)
}
sleep
(
2
)
response_2
=
''
sub_2
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
).
get
:head
=>
headers
,
:timeout
=>
60
sub_2
.
stream
{
|
chunk
|
response_2
+=
chunk
assert
(
response_2
.
include?
(
@header_template
),
"Didn't received header template"
)
}
sub_2
.
callback
{
assert
(
response_2
.
include?
(
@footer_template
),
"Didn't received footer template"
)
response_4
=
''
sub_4
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
).
get
:head
=>
headers
,
:timeout
=>
60
sub_4
.
stream
{
|
chunk
|
response_4
+=
chunk
assert
(
response_4
.
include?
(
@header_template
),
"Didn't received header template"
)
}
sub_4
.
callback
{
assert
(
response_4
.
include?
(
@footer_template
),
"Didn't received footer template"
)
EventMachine
.
stop
}
}
sleep
(
6
)
response_3
=
''
sub_3
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
).
get
:head
=>
headers
,
:timeout
=>
60
sub_3
.
stream
{
|
chunk
|
response_3
+=
chunk
assert
(
response_3
.
include?
(
@header_template
),
"Didn't received header template"
)
}
sub_3
.
callback
{
assert
(
response_3
.
include?
(
@footer_template
),
"Didn't received footer template"
)
}
add_test_timeout
(
15
)
}
end
end
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