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
cbfa6b69
Commit
cbfa6b69
authored
Oct 05, 2013
by
Wandenberg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
make cleanup test more stable and faster using a socket to publish messages
parent
c5abed57
Changes
2
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
176 additions
and
253 deletions
+176
-253
cleanup_memory_spec.rb
misc/spec/mix/cleanup_memory_spec.rb
+163
-244
spec_helper.rb
misc/spec/spec_helper.rb
+13
-9
No files found.
misc/spec/mix/cleanup_memory_spec.rb
View file @
cbfa6b69
This diff is collapsed.
Click to expand it.
misc/spec/spec_helper.rb
View file @
cbfa6b69
...
...
@@ -61,14 +61,18 @@ def create_channel_by_subscribe(channel, headers, timeout=60, &block)
end
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
pub
.
callback
do
if
pub
.
response_header
.
status
==
200
callbacks
[
:success
].
call
(
pub
.
response_header
.
status
,
pub
.
response
)
unless
callbacks
[
:success
].
nil?
else
callbacks
[
:error
].
call
(
pub
.
response_header
.
status
,
pub
.
response
)
unless
callbacks
[
:error
].
nil?
end
def
publish_messages_until_fill_the_memory
(
channel
,
body
,
&
block
)
i
=
0
resp_headers
,
resp_body
=
nil
socket
=
open_socket
(
nginx_host
,
nginx_port
)
while
(
true
)
do
socket
.
print
(
"POST /pub?id=
#{
channel
.
to_s
%
(
i
)
}
HTTP/1.1
\r\n
Host: localhost
\r\n
Content-Length:
#{
body
.
size
}
\r\n\r\n
#{
body
}
"
)
resp_headers
,
resp_body
=
read_response_on_socket
(
socket
,
{
:wait_for
=>
"}
\r\n
"
})
break
unless
resp_headers
.
match
(
/200 OK/
)
i
+=
1
end
pub
socket
.
close
status
=
resp_headers
.
match
(
/HTTP[^ ]* ([^ ]*)/
)[
1
]
block
.
call
(
status
,
resp_body
)
unless
block
.
nil?
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