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
65a25ea5
Commit
65a25ea5
authored
Dec 26, 2010
by
Wandenberg Peixoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactoring tests
parent
234270f1
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
7 deletions
+17
-7
base_test_case.rb
test/base_test_case.rb
+1
-0
test_comunication_properties.rb
test/test_comunication_properties.rb
+15
-7
test_subscriber_properties.rb
test/test_subscriber_properties.rb
+1
-0
No files found.
test/base_test_case.rb
View file @
65a25ea5
...
@@ -25,6 +25,7 @@ module BaseTestCase
...
@@ -25,6 +25,7 @@ module BaseTestCase
def
nginx_executable
def
nginx_executable
return
"/usr/local/nginxpushstream/source/nginx-0.7.67/objs/nginx"
return
"/usr/local/nginxpushstream/source/nginx-0.7.67/objs/nginx"
# return "/usr/local/nginxpushstream/source/nginx-0.8.53/objs/nginx"
end
end
def
nginx_address
def
nginx_address
...
...
test/test_comunication_properties.rb
View file @
65a25ea5
...
@@ -69,6 +69,8 @@ class TestComunicationProperties < Test::Unit::TestCase
...
@@ -69,6 +69,8 @@ class TestComunicationProperties < Test::Unit::TestCase
channel
=
'ch3'
channel
=
'ch3'
headers
=
{
'accept'
=>
'text/html'
}
headers
=
{
'accept'
=>
'text/html'
}
body
=
'message to test buffer timeout '
body
=
'message to test buffer timeout '
response_1
=
response_2
=
response_3
=
""
sub_1
=
sub_2
=
sub_3
=
nil
EventMachine
.
run
{
EventMachine
.
run
{
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
...
@@ -76,8 +78,8 @@ class TestComunicationProperties < Test::Unit::TestCase
...
@@ -76,8 +78,8 @@ class TestComunicationProperties < Test::Unit::TestCase
EM
.
add_timer
(
2
)
do
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
,
:timeout
=>
60
sub_1
.
stream
{
|
chunk
|
sub_1
.
stream
{
|
chunk
|
assert_equal
(
"
#{
@header_template
}
\r\n
#{
body
}
\r\n
"
,
chunk
,
"Didn't received header and message"
)
response_1
+=
chunk
sub_1
.
close_connection
sub_1
.
close_connection
if
response_1
.
include?
(
body
)
}
}
fail_if_connecttion_error
(
sub_1
)
fail_if_connecttion_error
(
sub_1
)
end
end
...
@@ -85,8 +87,8 @@ class TestComunicationProperties < Test::Unit::TestCase
...
@@ -85,8 +87,8 @@ class TestComunicationProperties < Test::Unit::TestCase
EM
.
add_timer
(
6
)
do
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
,
:timeout
=>
60
sub_2
.
stream
{
|
chunk
|
sub_2
.
stream
{
|
chunk
|
assert_equal
(
"
#{
@header_template
}
\r\n
#{
body
}
\r\n
"
,
chunk
,
"Didn't received header and message"
)
response_2
+=
chunk
sub_2
.
close_connection
sub_2
.
close_connection
if
response_2
.
include?
(
body
)
}
}
fail_if_connecttion_error
(
sub_2
)
fail_if_connecttion_error
(
sub_2
)
end
end
...
@@ -94,12 +96,18 @@ class TestComunicationProperties < Test::Unit::TestCase
...
@@ -94,12 +96,18 @@ class TestComunicationProperties < Test::Unit::TestCase
EM
.
add_timer
(
13
)
do
EM
.
add_timer
(
13
)
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
,
:timeout
=>
60
sub_3
.
stream
{
|
chunk
|
sub_3
.
stream
{
|
chunk
|
assert_equal
(
"
#{
@header_template
}
\r\n
"
,
chunk
,
"Didn't received header"
)
response_3
+=
chunk
sub_3
.
close_connection
sub_3
.
close_connection
if
response_3
.
include?
(
body
)
EventMachine
.
stop
}
}
fail_if_connecttion_error
(
sub_3
)
fail_if_connecttion_error
(
sub_3
)
end
end
EM
.
add_timer
(
14
)
do
assert_equal
(
"
#{
@header_template
}
\r\n
#{
body
}
\r\n
"
,
response_1
,
"Didn't received header and message"
)
assert_equal
(
"
#{
@header_template
}
\r\n
#{
body
}
\r\n
"
,
response_2
,
"Didn't received header and message"
)
assert_equal
(
"
#{
@header_template
}
\r\n
"
,
response_3
,
"Didn't received header"
)
EventMachine
.
stop
end
}
}
end
end
...
...
test/test_subscriber_properties.rb
View file @
65a25ea5
...
@@ -72,6 +72,7 @@ class TestSubscriberProperties < Test::Unit::TestCase
...
@@ -72,6 +72,7 @@ class TestSubscriberProperties < Test::Unit::TestCase
end
end
}
}
sub
.
callback
{
sub
.
callback
{
assert_equal
(
4
,
chuncksReceived
,
"Didn't received expected messages"
)
interval1
=
time_diff_sec
(
step2
,
step1
).
round
interval1
=
time_diff_sec
(
step2
,
step1
).
round
interval2
=
time_diff_sec
(
step4
,
step3
).
round
interval2
=
time_diff_sec
(
step4
,
step3
).
round
assert_equal
(
interval1
,
interval2
,
"Wrong
#{
interval1
}
,
#{
interval2
}
intervals"
)
assert_equal
(
interval1
,
interval2
,
"Wrong
#{
interval1
}
,
#{
interval2
}
intervals"
)
...
...
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