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
55fc5bd9
Commit
55fc5bd9
authored
Mar 25, 2011
by
Wandenberg Peixoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
organizing test suite
parent
fb09f30e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
63 additions
and
15 deletions
+63
-15
.gitignore
.gitignore
+3
-0
Gemfile.lock
test/Gemfile.lock
+22
-0
base_test_case.rb
test/base_test_case.rb
+38
-15
No files found.
.gitignore
View file @
55fc5bd9
build/
.cproject
.project
.settings/**
test/.bundle
test/tmp/**
test/logs/**
test/Gemfile.lock
View file @
55fc5bd9
...
...
@@ -6,12 +6,32 @@ GEM
open4
Platform (0.4.0)
addressable (2.2.2)
archive-tar-minitar (0.5.2)
columnize (0.3.2)
em-http-request (0.2.14)
addressable (>= 2.0.0)
eventmachine (>= 0.12.9)
eventmachine (0.12.10)
json (1.4.3)
linecache (0.43)
linecache19 (0.5.11)
ruby_core_source (>= 0.1.4)
open4 (1.0.1)
ruby-debug (0.10.4)
columnize (>= 0.1)
ruby-debug-base (~> 0.10.4.0)
ruby-debug-base (0.10.4)
linecache (>= 0.3)
ruby-debug-base19 (0.11.24)
columnize (>= 0.3.1)
linecache19 (>= 0.5.11)
ruby_core_source (>= 0.1.4)
ruby-debug19 (0.11.6)
columnize (>= 0.3.1)
linecache19 (>= 0.5.11)
ruby-debug-base19 (>= 0.11.19)
ruby_core_source (0.1.4)
archive-tar-minitar (>= 0.5.2)
PLATFORMS
ruby
...
...
@@ -20,3 +40,5 @@ DEPENDENCIES
POpen4 (= 0.1.4)
em-http-request (= 0.2.14)
json (= 1.4.3)
ruby-debug
ruby-debug19
test/base_test_case.rb
View file @
55fc5bd9
require
'rubygems'
require
'popen4'
require
'tmpdir'
require
'erb'
require
'f
too
ls'
require
'f
ileuti
ls'
require
'ruby-debug'
require
'test/unit'
require
'em-http'
...
...
@@ -10,9 +9,10 @@ require 'json'
module
BaseTestCase
def
setup
create_dirs
default_configuration
@test_config_file
=
"
#{
self
.
method_name
}
.conf"
config_test_name
=
"config_
#{
self
.
method_name
}
"
@test_config_file
=
"
#{
test_
method_name
}
.conf"
config_test_name
=
"config_
#{
test_
method_name
}
"
self
.
send
(
config_test_name
)
if
self
.
respond_to?
(
config_test_name
)
unless
@disable_start_stop_server
...
...
@@ -27,10 +27,11 @@ module BaseTestCase
self
.
stop_server
self
.
delete_config_file
end
delete_dirs
end
def
nginx_executable
return
ENV
[
'NGINX_EXEC'
].
nil?
?
"/usr/local/nginx
pushstream/source/nginx/objs
/nginx"
:
ENV
[
'NGINX_EXEC'
]
return
ENV
[
'NGINX_EXEC'
].
nil?
?
"/usr/local/nginx
/sbin
/nginx"
:
ENV
[
'NGINX_EXEC'
]
end
def
nginx_address
...
...
@@ -51,7 +52,7 @@ module BaseTestCase
def
start_server
error_message
=
""
status
=
POpen4
::
popen4
(
"
#{
nginx_executable
}
-c
#{
Dir
.
tmpdir
}
/
#{
@test_config_fil
e
}
"
)
do
|
stdout
,
stderr
,
stdin
,
pid
|
status
=
POpen4
::
popen4
(
"
#{
nginx_executable
}
-c
#{
config_filenam
e
}
"
)
do
|
stdout
,
stderr
,
stdin
,
pid
|
error_message
=
stderr
.
read
.
strip
unless
stderr
.
eof
return
error_message
unless
error_message
.
nil?
end
...
...
@@ -60,7 +61,7 @@ module BaseTestCase
def
stop_server
error_message
=
""
status
=
POpen4
::
popen4
(
"
#{
nginx_executable
}
-c
#{
Dir
.
tmpdir
}
/
#{
@test_config_fil
e
}
-s stop"
)
do
|
stdout
,
stderr
,
stdin
,
pid
|
status
=
POpen4
::
popen4
(
"
#{
nginx_executable
}
-c
#{
config_filenam
e
}
-s stop"
)
do
|
stdout
,
stderr
,
stdin
,
pid
|
error_message
=
stderr
.
read
.
strip
unless
stderr
.
eof
return
error_message
unless
error_message
.
nil?
end
...
...
@@ -70,13 +71,35 @@ module BaseTestCase
def
create_config_file
template
=
ERB
.
new
@@config_template
config_content
=
template
.
result
(
binding
)
File
.
open
(
Dir
.
tmpdir
+
"/
#{
@test_config_file
}
"
,
'w'
)
{
|
f
|
f
.
write
(
config_content
)
}
File
.
open
(
Dir
.
tmpdir
+
"/mime.types"
,
'w'
)
{
|
f
|
f
.
write
(
@@mime_tipes_template
)
}
File
.
open
(
config_filename
,
'w'
)
{
|
f
|
f
.
write
(
config_content
)
}
File
.
open
(
mime_types_filename
,
'w'
)
{
|
f
|
f
.
write
(
@@mime_tipes_template
)
}
end
def
delete_config_file
File
.
delete
(
Dir
.
tmpdir
+
"/
#{
@test_config_file
}
"
)
File
.
delete
(
Dir
.
tmpdir
+
"/mime.types"
)
File
.
delete
(
config_filename
)
File
.
delete
(
mime_types_filename
)
end
def
create_dirs
FileUtils
.
mkdir
(
'tmp'
)
unless
File
.
exist?
(
'tmp'
)
and
File
.
directory?
(
'tmp'
)
FileUtils
.
mkdir
(
'logs'
)
unless
File
.
exist?
(
'logs'
)
and
File
.
directory?
(
'logs'
)
end
def
delete_dirs
FileUtils
.
rm_rf
(
'tmp'
)
if
File
.
exist?
(
'tmp'
)
and
File
.
directory?
(
'tmp'
)
FileUtils
.
rm_rf
(
'logs'
)
if
File
.
exist?
(
'logs'
)
and
File
.
directory?
(
'logs'
)
end
def
config_filename
File
.
expand_path
(
"tmp/
#{
@test_config_file
}
"
)
end
def
mime_types_filename
File
.
expand_path
(
"tmp/mime.types"
)
end
def
test_method_name
self
.
respond_to?
(
'method_name'
)
?
self
.
method_name
:
self
.
__name__
end
def
time_diff_milli
(
start
,
finish
)
...
...
@@ -142,8 +165,8 @@ module BaseTestCase
end
@@config_template
=
%q{
pid
logs/nginx.pid
;
error_log
logs/nginx-main_error.log
debug;
pid
<%= File.expand_path("logs/nginx.pid") %>
;
error_log
<%= File.expand_path("logs/nginx-main_error.log") %>
debug;
# Development Mode
master_process off;
daemon off;
...
...
@@ -158,8 +181,8 @@ http {
include mime.types;
default_type application/octet-stream;
access_log
logs/nginx-http_access.log
;
error_log
logs/nginx-http_error.log
debug;
access_log
<%= File.expand_path("logs/nginx-http_access.log")%>
;
error_log
<%= File.expand_path("logs/nginx-http_error.log")%>
debug;
tcp_nopush on;
tcp_nodelay on;
...
...
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