webroar 0.3.1 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG +48 -1
- data/README +11 -14
- data/Rakefile +1 -1
- data/conf/mime_type.yml +172 -166
- data/conf/server_internal_config.yml +30 -8
- data/doc/user-guide.html +294 -153
- data/doc/user-guide.txt +9 -13
- data/lib/command_runner.rb +1 -0
- data/lib/dependencies.rb +18 -15
- data/lib/installer.rb +115 -50
- data/src/admin_panel/app/controllers/admin_controller.rb +1 -15
- data/src/admin_panel/app/controllers/application_controller.rb +2 -2
- data/src/admin_panel/app/controllers/application_specification_controller.rb +2 -1
- data/src/admin_panel/app/controllers/headers_controller.rb +73 -0
- data/src/admin_panel/app/controllers/mail_specification_controller.rb +10 -0
- data/src/admin_panel/app/controllers/server_specification_controller.rb +14 -0
- data/src/admin_panel/app/helpers/admin_helper.rb +0 -85
- data/src/admin_panel/app/models/app.rb +1 -1
- data/src/admin_panel/app/models/application_specification.rb +33 -25
- data/src/admin_panel/app/models/headers.rb +116 -0
- data/src/admin_panel/app/models/mail_specification.rb +20 -5
- data/src/admin_panel/app/models/server_specification.rb +2 -7
- data/src/admin_panel/app/views/admin/configuration.html.erb +10 -5
- data/src/admin_panel/app/views/exceptions/_exception_list_partial.html.erb +4 -4
- data/src/admin_panel/app/views/graph/_graph_page.html.erb +3 -0
- data/src/admin_panel/app/views/headers/_add_expires_text_box.html.erb +35 -0
- data/src/admin_panel/app/views/headers/_expires_by_type_form.html.erb +65 -0
- data/src/admin_panel/app/views/headers/_headers_table.html.erb +113 -0
- data/src/admin_panel/app/views/mail_specification/_current_spec.html.erb +168 -0
- data/src/admin_panel/app/views/{admin → server_specification}/_add_div.html.erb +1 -1
- data/src/admin_panel/config/initializers/application_constants.rb +6 -0
- data/src/admin_panel/lib/control.rb +6 -3
- data/src/admin_panel/lib/scgi.rb +74 -21
- data/src/admin_panel/lib/yaml_writer.rb +51 -17
- data/src/admin_panel/public/javascripts/application.js +20 -1
- data/src/head/wr_access_log.c +2 -2
- data/src/head/wr_application.c +294 -236
- data/src/head/wr_application.h +8 -8
- data/src/head/wr_configurator.c +451 -517
- data/src/head/wr_configurator.h +10 -115
- data/src/head/wr_connection.c +26 -25
- data/src/head/wr_connection.h +2 -3
- data/src/head/wr_controller.c +110 -93
- data/src/head/wr_controller.h +6 -6
- data/src/head/wr_main.c +31 -24
- data/src/head/wr_request.c +70 -93
- data/src/head/wr_request.h +0 -4
- data/src/head/wr_resolver.c +21 -15
- data/src/head/wr_resolver.h +2 -2
- data/src/head/wr_server.c +36 -26
- data/src/head/wr_server.h +5 -5
- data/src/head/wr_worker.c +551 -512
- data/src/head/wr_worker.h +33 -20
- data/src/helper/wr_config.c +316 -0
- data/src/helper/wr_config.h +235 -0
- data/src/helper/wr_helper.h +1 -5
- data/src/helper/wr_logger.c +4 -4
- data/src/helper/wr_scgi.c +3 -4
- data/src/helper/wr_scgi.h +2 -0
- data/src/helper/wr_string.h +2 -2
- data/src/helper/wr_util.c +3 -1
- data/src/helper/wr_util.h +0 -0
- data/src/helper/wr_yaml_parser.c +30 -0
- data/src/helper/wr_yaml_parser.h +1 -0
- data/src/ruby_lib/exception_tracker/instrumentation/action_controller.rb +2 -1
- data/src/ruby_lib/mailer/smtpmail.rb +7 -4
- data/src/ruby_lib/profiler/instrumentation/action_controller.rb +2 -1
- data/src/ruby_lib/profiler/instrumentation/active_record.rb +3 -0
- data/src/ruby_lib/rack/adapter/rails.rb +14 -7
- data/src/ruby_lib/ruby_interface/client.rb +1 -1
- data/src/ruby_lib/ruby_interface/version.rb +2 -2
- data/src/ruby_lib/webroar_app_loader.rb +4 -2
- data/src/worker/wkr_controller.c +200 -140
- data/src/worker/wkr_http.c +14 -28
- data/src/worker/wkr_http.h +4 -4
- data/src/worker/wkr_http_request.c +12 -11
- data/src/worker/wkr_http_request.h +7 -8
- data/src/worker/wkr_http_response.c +10 -14
- data/src/worker/wkr_http_response.h +0 -1
- data/src/worker/wkr_main.c +74 -140
- data/src/worker/wkr_static.c +295 -108
- data/src/worker/wkr_static.h +20 -7
- data/src/worker/worker.c +245 -70
- data/src/worker/worker.h +46 -34
- data/tasks/compile.rake +128 -175
- data/tasks/test.rake +345 -469
- data/test/spec/webroar_command_spec.rb +23 -0
- metadata +173 -43
- data/src/admin_panel/vendor/plugins/action_mailer_optional_tls/README +0 -34
- data/src/admin_panel/vendor/plugins/action_mailer_optional_tls/Rakefile +0 -13
- data/src/admin_panel/vendor/plugins/action_mailer_optional_tls/init.rb +0 -5
- data/src/admin_panel/vendor/plugins/action_mailer_optional_tls/lib/action_mailer_tls.rb +0 -16
- data/src/admin_panel/vendor/plugins/action_mailer_optional_tls/lib/smtp_tls.rb +0 -123
- data/src/admin_panel/vendor/plugins/action_mailer_optional_tls/test/tls_test.rb +0 -42
- data/src/head/wr_config.h +0 -165
- data/src/ruby_lib/mailer/action_mailer_tls.rb +0 -16
- data/src/ruby_lib/mailer/smtp_tls.rb +0 -123
data/tasks/test.rake
CHANGED
|
@@ -24,11 +24,11 @@ require 'spec/rake/spectask'
|
|
|
24
24
|
#TODO: forget underscore and cover tests under namespace
|
|
25
25
|
WEBROAR_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..')).freeze
|
|
26
26
|
SPEC_DIR = File.join(WEBROAR_ROOT,'test','spec')
|
|
27
|
-
REPORT_DIR = File.join(WEBROAR_ROOT,'report')
|
|
28
27
|
TEST_DIR = File.join(WEBROAR_ROOT, 'test')
|
|
28
|
+
|
|
29
29
|
DEBUG_LOG_DIR = File.join(TEST_DIR,'debug_log')
|
|
30
30
|
ALL_SPECS = FileList[File.join(SPEC_DIR,'*_spec.rb')].exclude("conditional_spec.rb")
|
|
31
|
-
#ALL_SPECS = FileList[File.join(SPEC_DIR,'
|
|
31
|
+
#ALL_SPECS = FileList[File.join(SPEC_DIR,'http_spec.rb')]
|
|
32
32
|
#ALL_SPECS = FileList[File.join(SPEC_DIR,'*_spec.rb')].exclude(
|
|
33
33
|
#File.join(SPEC_DIR,'host_name_spec.rb'),
|
|
34
34
|
#File.join(SPEC_DIR,'connection_keep_alive_spec.rb'),
|
|
@@ -44,9 +44,58 @@ ALL_SPECS = FileList[File.join(SPEC_DIR,'*_spec.rb')].exclude("conditional_spec.
|
|
|
44
44
|
require File.join(SPEC_DIR,'spec_helper.rb')
|
|
45
45
|
|
|
46
46
|
test_flag = 1
|
|
47
|
+
total = 0
|
|
48
|
+
failed = 0
|
|
49
|
+
file = nil
|
|
50
|
+
|
|
51
|
+
desc "Log exceptions."
|
|
52
|
+
task :log_exception, :exception do |t, args|
|
|
53
|
+
exception_log = File.join(REPORT_DIR,'exception.log')
|
|
54
|
+
|
|
55
|
+
File.open(exception_log,"a") do |f|
|
|
56
|
+
f.puts args.exception
|
|
57
|
+
f.puts args.exception.backtrace
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
desc "Creates required folders for running test cases."
|
|
62
|
+
task :create_test_dirs do
|
|
63
|
+
begin
|
|
64
|
+
if(ENV["report_dir"])
|
|
65
|
+
REPORT_DIR = ENV["report_dir"]
|
|
66
|
+
else
|
|
67
|
+
REPORT_DIR = File.join(WEBROAR_ROOT,'report')
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
# make exception.log empty.
|
|
71
|
+
exception_log = File.join(REPORT_DIR,'exception.log')
|
|
72
|
+
File.truncate(exception_log,0) if File.exists?(exception_log)
|
|
73
|
+
|
|
74
|
+
UNIT_TEST_REPORT = File.join(REPORT_DIR, 'unit_test')
|
|
75
|
+
SPEC_TEST_REPORT = File.join(REPORT_DIR, 'spec')
|
|
76
|
+
ADMIN_TEST_REPORT = File.join(REPORT_DIR, 'admin_panel')
|
|
77
|
+
LOAD_TEST_REPORT = File.join(REPORT_DIR, 'load_test')
|
|
78
|
+
BUILD_TEST_REPORT = File.join(REPORT_DIR, 'build_test')
|
|
79
|
+
|
|
80
|
+
# Create directories.
|
|
81
|
+
if create_directories([UNIT_TEST_REPORT, SPEC_TEST_REPORT, ADMIN_TEST_REPORT, BUILD_TEST_REPORT, LOAD_TEST_REPORT, LOG_FILES]) == true
|
|
82
|
+
puts 'Required directories created successfully.'
|
|
83
|
+
else
|
|
84
|
+
puts 'Required directories could not be created. Can not continue...'
|
|
85
|
+
end
|
|
86
|
+
rescue Exception => e
|
|
87
|
+
puts e
|
|
88
|
+
puts e.backtrace
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
def check_and_copy(src_file, dest_file)
|
|
94
|
+
FileUtils.copy(src_file, dest_file) if File.exists?(src_file)
|
|
95
|
+
end
|
|
47
96
|
|
|
48
97
|
desc "Build .so file for all the test written in c"
|
|
49
|
-
task :
|
|
98
|
+
task :build_unit_test do
|
|
50
99
|
create_directories([TEST_OBJ_DIR])
|
|
51
100
|
test_files = FileList[File.join(UNIT_TEST_DIR, '*.c'), File.join(HELPER_DIR, '*.c'),
|
|
52
101
|
File.join(YAML_DIR, '*.c')]
|
|
@@ -57,79 +106,82 @@ task :build_tests do
|
|
|
57
106
|
test_obj[obj_file]=sfn
|
|
58
107
|
end
|
|
59
108
|
|
|
60
|
-
unless $webroar_config_called
|
|
61
|
-
|
|
62
|
-
end
|
|
63
|
-
|
|
109
|
+
webroar_config unless $webroar_config_called
|
|
110
|
+
|
|
64
111
|
test_obj.each { |obj_file,src_file|
|
|
65
|
-
cmd = "#{
|
|
112
|
+
cmd = "#{CC} #$flags #$debug_flags -c #{src_file} -o #{obj_file}"
|
|
66
113
|
sh cmd
|
|
67
114
|
}
|
|
68
115
|
|
|
69
|
-
|
|
70
116
|
tests_obj_files = FileList[File.join(TEST_OBJ_DIR,"*.o")]
|
|
71
117
|
|
|
72
118
|
if RUBY_PLATFORM =~ /darwin/
|
|
73
119
|
out_file = File.join(UNIT_TEST_DIR, 'test_ext.dylib')
|
|
74
|
-
|
|
75
|
-
lib_flags += " #{ENV['library_flags']}" if ENV['library_flags']
|
|
76
|
-
cmd = "#{COMPILER} #$libs #{tests_obj_files} -dynamiclib -o #{out_file}"
|
|
120
|
+
cmd = "#{CC} #$lib_flags #{tests_obj_files} -dynamiclib -o #{out_file}"
|
|
77
121
|
else
|
|
78
122
|
out_file = File.join(UNIT_TEST_DIR, 'test_ext.so')
|
|
79
|
-
cmd = "#{
|
|
123
|
+
cmd = "#{CC} #$lib_flags #{tests_obj_files} -shared -o #{out_file}"
|
|
80
124
|
end
|
|
81
125
|
|
|
82
126
|
sh cmd
|
|
83
127
|
end
|
|
84
128
|
|
|
85
129
|
desc "Build and executes unit test"
|
|
86
|
-
task :unit_test do
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
130
|
+
task :unit_test => [:create_test_dirs] do
|
|
131
|
+
next unless test_flag == 1
|
|
132
|
+
|
|
133
|
+
begin
|
|
134
|
+
test_file = File.join(UNIT_TEST_DIR, 'test.log')
|
|
135
|
+
summary_file = File.join(UNIT_TEST_REPORT, 'test-summary')
|
|
136
|
+
File.truncate(test_file, 0) if File.exists?(test_file)
|
|
137
|
+
|
|
138
|
+
print "Compiling unit test cases ... "
|
|
139
|
+
system("rake build_unit_test >#{File.join(UNIT_TEST_REPORT,'testcases.log')} 2>>#{File.join(UNIT_TEST_REPORT,'testcases.log')}")
|
|
140
|
+
if($?==0)
|
|
141
|
+
puts "Done."
|
|
142
|
+
system("rake clean >>#{File.join(UNIT_TEST_REPORT,'testcases.log')} 2>>#{File.join(UNIT_TEST_REPORT,'testcases.log')}")
|
|
143
|
+
puts "Running test cases ..."
|
|
144
|
+
puts ""
|
|
145
|
+
$LOAD_PATH.unshift(UNIT_TEST_DIR)
|
|
146
|
+
Dir.chdir(UNIT_TEST_DIR)
|
|
147
|
+
|
|
148
|
+
if RUBY_PLATFORM =~ /darwin/
|
|
149
|
+
require 'dl'
|
|
150
|
+
dl = DL::dlopen(File.join(UNIT_TEST_DIR,'test_ext.dylib'))
|
|
151
|
+
run_test = dl.sym("run_test",'0')
|
|
152
|
+
run_test.call()
|
|
153
|
+
else
|
|
154
|
+
require 'test_ext'
|
|
155
|
+
Test::Test.run
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
puts "\nPlease refer '#{File.join(UNIT_TEST_REPORT, 'test.log')}' for the detailed report."
|
|
107
159
|
else
|
|
108
|
-
|
|
109
|
-
Test::Test.run
|
|
160
|
+
puts "Compilation error. Please refer 'testcases.log' for details."
|
|
110
161
|
end
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
File.open(summary_file, "w") do |f|
|
|
131
|
-
f.puts str
|
|
162
|
+
Dir.chdir(WEBROAR_ROOT)
|
|
163
|
+
next unless File.exists?(test_file)
|
|
164
|
+
|
|
165
|
+
result = File.read(test_file)
|
|
166
|
+
|
|
167
|
+
passed = 0
|
|
168
|
+
failed = 0
|
|
169
|
+
p_f = result.scan(/Test\s*passed\s*:\s*(\d+),\s*Test\s*failed\s*:\s*(\d+)/)
|
|
170
|
+
p_f.each do |e|
|
|
171
|
+
passed += e[0].to_i
|
|
172
|
+
failed += e[1].to_i
|
|
173
|
+
end
|
|
174
|
+
str = "Unit test summary\nTotal test: #{passed+failed}\nFailed test: #{failed}\n"
|
|
175
|
+
|
|
176
|
+
File.open(summary_file, "w") do |f|
|
|
177
|
+
f.puts str
|
|
178
|
+
end
|
|
179
|
+
rescue Exception => e
|
|
180
|
+
Rake::Task[:log_exception].invoke(e)
|
|
132
181
|
end
|
|
182
|
+
|
|
183
|
+
check_and_copy(File.join(UNIT_TEST_DIR, 'test.log'), File.join(UNIT_TEST_REPORT, 'test.log'))
|
|
184
|
+
|
|
133
185
|
end
|
|
134
186
|
|
|
135
187
|
task :test_setup do
|
|
@@ -141,43 +193,96 @@ task :test_setup do
|
|
|
141
193
|
if rv == -1
|
|
142
194
|
puts " * Some problem occured in test setup. Exiting. * "
|
|
143
195
|
test_flag = 0
|
|
144
|
-
# return -1
|
|
145
196
|
exit(-1)
|
|
146
197
|
end
|
|
147
198
|
end
|
|
148
199
|
|
|
149
|
-
desc "Executes functional test"
|
|
150
200
|
task :spec => :test_setup
|
|
151
201
|
Spec::Rake::SpecTask.new(:spec) do |t|
|
|
152
202
|
t.spec_files = ALL_SPECS
|
|
153
203
|
t.spec_opts << "--format specdoc"
|
|
154
204
|
end
|
|
155
205
|
|
|
206
|
+
desc "Run functional test cases."
|
|
207
|
+
task :spec_test => [:create_test_dirs] do
|
|
208
|
+
next unless test_flag == 1
|
|
209
|
+
|
|
210
|
+
puts "Executing functional tests ..."
|
|
156
211
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
212
|
+
begin
|
|
213
|
+
ENV["SPEC_OPTS"] = "--format specdoc:#{TEST_RESULT}"
|
|
214
|
+
Rake::Task[:spec].invoke()
|
|
215
|
+
rescue Exception => e
|
|
216
|
+
Rake::Task[:log_exception].invoke(e)
|
|
217
|
+
ensure
|
|
218
|
+
if File.exists?(TEST_RESULT)
|
|
219
|
+
system("tail -2 #{File.join(SPEC_DIR,'test.log')} > #{File.join(SPEC_TEST_REPORT,'test_result')}")
|
|
220
|
+
result = File.read(File.join(SPEC_TEST_REPORT,'test_result'))
|
|
221
|
+
total = 0
|
|
222
|
+
failed = 0
|
|
223
|
+
if result =~ /(\d+)\s*(example|examples),\s*(\d+)\s*failure/
|
|
224
|
+
total = $1
|
|
225
|
+
failed = $3
|
|
226
|
+
end
|
|
227
|
+
str = "Functional test summary\nTotal test: #{total}\nFailed test: #{failed}\n"
|
|
228
|
+
File.open(File.join(SPEC_TEST_REPORT,'test-summary'),"w") do |f|
|
|
229
|
+
f.puts str
|
|
230
|
+
end
|
|
231
|
+
end
|
|
232
|
+
|
|
233
|
+
log_file_pattern = File.join(LOG_FILES,'*.log')
|
|
234
|
+
log_files = Dir.glob(log_file_pattern)
|
|
235
|
+
for file in log_files
|
|
236
|
+
FileUtils.cp(file,File.join(SPEC_TEST_REPORT,"#{File.basename(file)}"))
|
|
237
|
+
end
|
|
238
|
+
|
|
239
|
+
cmd = "#{File.join(WEBROAR_ROOT,'bin','webroar')} clear"
|
|
240
|
+
system(cmd)
|
|
171
241
|
end
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
242
|
+
|
|
243
|
+
# copy functional tests related files
|
|
244
|
+
check_and_copy(File.join(SPEC_DIR, 'test.log'), File.join(SPEC_TEST_REPORT, 'test.log'))
|
|
245
|
+
check_and_copy(File.join(SPEC_DIR, 'setup.log'), File.join(SPEC_TEST_REPORT, 'test-setup.log'))
|
|
246
|
+
check_and_copy(File.join(SPEC_DIR, 'test-run.log'), File.join(SPEC_TEST_REPORT, 'test-run.log'))
|
|
247
|
+
|
|
248
|
+
end
|
|
249
|
+
|
|
250
|
+
desc "Executes Admin-panel test"
|
|
251
|
+
task :admin_panel_test => [:create_test_dirs] do
|
|
252
|
+
next unless test_flag == 1
|
|
253
|
+
|
|
254
|
+
begin
|
|
255
|
+
puts "Executing Admin-panel tests ..."
|
|
256
|
+
Dir.chdir(File.join(WEBROAR_ROOT,'src','admin_panel'))
|
|
257
|
+
system("rake test RAILS_ENV=test > #{File.join(ADMIN_TEST_REPORT, 'test.log')} 2>#{File.join(ADMIN_TEST_REPORT, 'error.log')}")
|
|
258
|
+
result = File.read(File.join(ADMIN_TEST_REPORT, 'test.log'))
|
|
259
|
+
p_f = result.scan(/(\d+)\s+tests,\s+\d+\s+assertions,\s+(\d+)\s+failures,\s+(\d+)\s+errors/)
|
|
260
|
+
total = 0
|
|
261
|
+
failed = 0
|
|
262
|
+
error = 0
|
|
263
|
+
p_f.each do |e|
|
|
264
|
+
total += e[0].to_i
|
|
265
|
+
failed += e[1].to_i
|
|
266
|
+
error += e[2].to_i
|
|
267
|
+
end
|
|
268
|
+
str = "Admin-panel test summary\nTotal test: #{total}\nFailed test: #{failed}\nError: #{error}\n"
|
|
269
|
+
File.open(File.join(ADMIN_TEST_REPORT, 'test-summary'),"w") do |f|
|
|
270
|
+
f.puts str
|
|
271
|
+
end
|
|
272
|
+
Dir.chdir(WEBROAR_ROOT)
|
|
273
|
+
rescue Exception => e
|
|
274
|
+
Rake::Task[:log_exception].invoke(e)
|
|
175
275
|
end
|
|
176
|
-
|
|
276
|
+
|
|
277
|
+
#copy database file
|
|
278
|
+
check_and_copy(File.join(WEBROAR_ROOT, 'src', 'admin_panel', 'db', 'webroar_test.sqlite3'), ADMIN_TEST_REPORT)
|
|
279
|
+
|
|
177
280
|
end
|
|
178
281
|
|
|
179
282
|
desc "Load testing by ab tool"
|
|
180
|
-
task :load_test do
|
|
283
|
+
task :load_test => [:create_test_dirs] do
|
|
284
|
+
next unless test_flag == 1
|
|
285
|
+
|
|
181
286
|
puts "Executing load tests ..."
|
|
182
287
|
begin
|
|
183
288
|
create_config({},{'baseuri' => '/test_app', 'max_worker' => 6})
|
|
@@ -188,333 +293,169 @@ task :load_test do
|
|
|
188
293
|
sleep(15)
|
|
189
294
|
system("ruby #{File.join(TEST_DIR,'load_test.rb')}")
|
|
190
295
|
stop_server
|
|
296
|
+
|
|
297
|
+
log_file_pattern = File.join(LOG_FILES,'*.log')
|
|
298
|
+
log_files = Dir.glob(log_file_pattern)
|
|
299
|
+
for file in log_files
|
|
300
|
+
FileUtils.cp(file,File.join(LOAD_TEST_REPORT,"#{File.basename(file)}"))
|
|
301
|
+
end
|
|
191
302
|
rescue Exception => e
|
|
303
|
+
Rake::Task[:log_exception].invoke(e)
|
|
192
304
|
ensure
|
|
193
305
|
remove_config
|
|
194
306
|
remove_messaging_config
|
|
195
307
|
end
|
|
308
|
+
|
|
309
|
+
|
|
310
|
+
# copy load tests related files
|
|
311
|
+
check_and_copy(File.join(TEST_DIR, 'load_test_summary'), File.join(LOAD_TEST_REPORT, 'test-summary'))
|
|
312
|
+
check_and_copy(File.join(TEST_DIR, 'load_test_result_fix'), File.join(LOAD_TEST_REPORT, 'test-result-fix'))
|
|
313
|
+
check_and_copy(File.join(TEST_DIR, 'load_test_result_random'), File.join(LOAD_TEST_REPORT, 'test-result-random'))
|
|
314
|
+
|
|
196
315
|
end
|
|
197
316
|
|
|
198
|
-
|
|
199
317
|
desc "Build gem"
|
|
200
|
-
task :
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
318
|
+
task :build_gem => [:create_test_dirs] do
|
|
319
|
+
total += 1
|
|
320
|
+
begin
|
|
321
|
+
file.print "Build gem ... " if file
|
|
322
|
+
cmd = "rm -fr pkg/* 2>> #{File.join(BUILD_TEST_REPORT, 'test.log')} >>#{File.join(BUILD_TEST_REPORT, 'test.log')}"
|
|
323
|
+
system(cmd)
|
|
324
|
+
Rake::Task[:gem].invoke
|
|
325
|
+
file.puts "Pass" if file
|
|
326
|
+
rescue Exception => e
|
|
327
|
+
failed += 1
|
|
328
|
+
file.puts "Failed" if file
|
|
329
|
+
Rake::Task[:log_exception].invoke(e)
|
|
330
|
+
end
|
|
205
331
|
end
|
|
206
332
|
|
|
207
333
|
desc "Gem install. It's meant for automated testing, passing predefined values for required inputs"
|
|
208
|
-
task :build_install do
|
|
334
|
+
task :build_install => [:build_gem] do
|
|
335
|
+
total += 1
|
|
209
336
|
gem_file = File.join(WEBROAR_ROOT,'pkg',"webroar-#{Webroar::VERSION::STRING}.gem")
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
print "
|
|
217
|
-
|
|
337
|
+
unless File.exists?(gem_file)
|
|
338
|
+
failed += 1
|
|
339
|
+
next
|
|
340
|
+
end
|
|
341
|
+
|
|
342
|
+
begin
|
|
343
|
+
file.print "Install gem and server ... " if file
|
|
344
|
+
print "Installing gem ... "
|
|
345
|
+
cmd = "gem install #{gem_file} 2>> #{File.join(BUILD_TEST_REPORT, 'test.log')} >>#{File.join(BUILD_TEST_REPORT, 'test.log')}"
|
|
218
346
|
system(cmd)
|
|
219
347
|
if($?==0)
|
|
220
348
|
puts "Done"
|
|
349
|
+
print "Installing WebROaR ... "
|
|
350
|
+
cmd = "webroar install 2>> #{File.join(BUILD_TEST_REPORT, 'test.log')} >>#{File.join(BUILD_TEST_REPORT, 'test.log')} << **\nadmin\nimpetus\nimpetus\n\n**"
|
|
351
|
+
system(cmd)
|
|
352
|
+
if($?==0)
|
|
353
|
+
file.puts "Pass" if file
|
|
354
|
+
puts "Done"
|
|
355
|
+
else
|
|
356
|
+
failed += 1
|
|
357
|
+
puts "Failed"
|
|
358
|
+
file.puts "Failed" if file
|
|
359
|
+
end
|
|
221
360
|
else
|
|
222
|
-
|
|
361
|
+
failed += 1
|
|
223
362
|
puts "Failed"
|
|
363
|
+
file.puts "Failed" if file
|
|
224
364
|
end
|
|
225
|
-
|
|
226
|
-
|
|
365
|
+
rescue Exception => e
|
|
366
|
+
failed += 1
|
|
227
367
|
puts "Failed"
|
|
368
|
+
file.puts "Failed" if file
|
|
369
|
+
Rake::Task[:log_exception].invoke(e)
|
|
228
370
|
end
|
|
229
|
-
|
|
230
371
|
end
|
|
231
372
|
|
|
232
373
|
desc "Uninstall server and its gem"
|
|
233
|
-
task :build_uninstall do
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
374
|
+
task :build_uninstall => [:create_test_dirs] do
|
|
375
|
+
total += 1
|
|
376
|
+
file.print "Uninstall server and gem ... " if file
|
|
377
|
+
begin
|
|
378
|
+
print "Uninstalling WebROaR ... "
|
|
379
|
+
cmd = "webroar uninstall 2>> #{File.join(BUILD_TEST_REPORT, 'test.log')} >>#{File.join(BUILD_TEST_REPORT, 'test.log')}"
|
|
380
|
+
system(cmd)
|
|
381
|
+
if($?==0)
|
|
382
|
+
puts "Done"
|
|
383
|
+
else
|
|
384
|
+
puts "Failed"
|
|
385
|
+
end
|
|
386
|
+
print "Uninstalling gem ..."
|
|
387
|
+
cmd = "gem uninstall webroar -v #{Webroar::VERSION::STRING} -x 2>> #{File.join(BUILD_TEST_REPORT, 'test.log')} >>#{File.join(BUILD_TEST_REPORT, 'test.log')} << **\ny\n** "
|
|
388
|
+
system(cmd)
|
|
389
|
+
if($?==0)
|
|
390
|
+
puts "Done"
|
|
391
|
+
file.puts "Pass" if file
|
|
392
|
+
else
|
|
393
|
+
failed += 1
|
|
394
|
+
puts "Failed"
|
|
395
|
+
file.puts "Failed" if file
|
|
396
|
+
end
|
|
397
|
+
rescue
|
|
398
|
+
failed += 1
|
|
249
399
|
puts "Failed"
|
|
400
|
+
file.puts "Failed" if file
|
|
401
|
+
Rake::Task[:log_exception].invoke(e)
|
|
250
402
|
end
|
|
251
|
-
|
|
252
|
-
# puts "gem uninstall $? = #$?"
|
|
253
403
|
end
|
|
254
404
|
|
|
255
405
|
desc "Build test"
|
|
256
|
-
task :build_test do
|
|
257
|
-
|
|
258
|
-
build_test = File.join(TEST_DIR,'build_test')
|
|
259
|
-
build_test_summary = File.join(TEST_DIR,'build_test_summary')
|
|
260
|
-
exception_log = File.join(TEST_DIR,'exception.log')
|
|
261
|
-
File.truncate('build_test.log', 0) if File.exists?('build_test.log')
|
|
406
|
+
task :build_test => [:create_test_dirs] do
|
|
407
|
+
next unless test_flag == 1 or ENV["build_test"] == "yes"
|
|
262
408
|
|
|
263
|
-
Dir.chdir(WEBROAR_ROOT)
|
|
264
|
-
File.truncate(build_test,0) if File.exists?(build_test)
|
|
265
|
-
File.truncate(build_test_summary, 0) if File.exists?(build_test_summary)
|
|
266
|
-
total = 0
|
|
267
|
-
failed = 0
|
|
268
|
-
bf = File.open(build_test,'w')
|
|
269
|
-
bf.print "Build gem ... "
|
|
270
|
-
total += 1
|
|
271
|
-
t = Rake::Task[:build]
|
|
272
409
|
begin
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
File.
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
410
|
+
puts "Executing build tests ..."
|
|
411
|
+
build_test_summary = File.join(BUILD_TEST_REPORT,'test-summary')
|
|
412
|
+
build_test = File.join(BUILD_TEST_REPORT,'build_test')
|
|
413
|
+
File.truncate(File.join(BUILD_TEST_REPORT, 'test.log'), 0) if File.exists?(File.join(BUILD_TEST_REPORT, 'test.log'))
|
|
414
|
+
|
|
415
|
+
Dir.chdir(WEBROAR_ROOT)
|
|
416
|
+
File.truncate(build_test_summary, 0) if File.exists?(build_test_summary)
|
|
417
|
+
File.truncate(build_test, 0) if File.exist?(build_test)
|
|
418
|
+
|
|
419
|
+
total = 0
|
|
420
|
+
failed = 0
|
|
421
|
+
file = File.open(build_test,'w')
|
|
422
|
+
|
|
423
|
+
Rake::Task[:build_install].invoke
|
|
424
|
+
Rake::Task[:build_uninstall].invoke
|
|
425
|
+
|
|
426
|
+
file.puts "#{total} total, #{failed} failed\n"
|
|
427
|
+
file.close
|
|
428
|
+
|
|
429
|
+
file = nil
|
|
287
430
|
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
begin
|
|
292
|
-
t.invoke()
|
|
293
|
-
rescue Exception => e
|
|
294
|
-
File.open(exception_log,"a") do |f|
|
|
295
|
-
f.puts e
|
|
296
|
-
f.puts e.backtrace
|
|
431
|
+
str = "Build test summary\nTotal test: #{total}\nFailed test: #{failed}\n"
|
|
432
|
+
File.open(build_test_summary,"w") do |f|
|
|
433
|
+
f.puts str
|
|
297
434
|
end
|
|
298
|
-
end
|
|
299
|
-
# puts "$? = #$?"
|
|
300
|
-
unless $? == 0
|
|
301
|
-
failed += 1
|
|
302
|
-
bf.puts "Failed"
|
|
303
|
-
else
|
|
304
|
-
bf.puts "Pass"
|
|
305
|
-
end
|
|
306
|
-
|
|
307
|
-
bf.print "Uninstall server and gem ... "
|
|
308
|
-
total += 1
|
|
309
|
-
t = Rake::Task[:build_uninstall]
|
|
310
|
-
begin
|
|
311
|
-
t.invoke()
|
|
312
435
|
rescue Exception => e
|
|
313
|
-
|
|
314
|
-
f.puts e
|
|
315
|
-
f.puts e.backtrace
|
|
316
|
-
end
|
|
317
|
-
end
|
|
318
|
-
# puts "$? = #$?"
|
|
319
|
-
unless $? == 0
|
|
320
|
-
failed += 1
|
|
321
|
-
bf.puts "Failed"
|
|
322
|
-
else
|
|
323
|
-
bf.puts "Pass"
|
|
324
|
-
end
|
|
325
|
-
|
|
326
|
-
bf.puts "#{total} total, #{failed} failed\n"
|
|
327
|
-
bf.close
|
|
328
|
-
|
|
329
|
-
str = "Build test summary\nTotal test: #{total}\nFailed test: #{failed}\n"
|
|
330
|
-
File.open(build_test_summary,"w") do |f|
|
|
331
|
-
f.puts str
|
|
332
|
-
end
|
|
333
|
-
end
|
|
334
|
-
|
|
335
|
-
def check_and_copy(src_file, dest_file)
|
|
336
|
-
if File.exists?(src_file)
|
|
337
|
-
FileUtils.copy(src_file, dest_file)
|
|
436
|
+
Rake::Task[:log_exception].invoke(e)
|
|
338
437
|
end
|
|
339
438
|
end
|
|
340
439
|
|
|
341
440
|
def test_cleanup(report_dir)
|
|
342
441
|
|
|
343
|
-
unless
|
|
344
|
-
FileUtils.
|
|
345
|
-
end
|
|
346
|
-
|
|
347
|
-
# copy unit tests related files
|
|
348
|
-
check_and_copy(File.join(UNIT_TEST_DIR,'test_summary'), File.join(report_dir, 'unit-test-summary'))
|
|
349
|
-
check_and_copy(File.join(UNIT_TEST_DIR, 'testcases.log'), File.join(report_dir, 'unit-testcase.log'))
|
|
350
|
-
check_and_copy(File.join(UNIT_TEST_DIR, 'test.log'), File.join(report_dir, 'unit-test.log'))
|
|
351
|
-
|
|
352
|
-
# copy admin-panel tests related files
|
|
353
|
-
check_and_copy(File.join(WEBROAR_ROOT,'src', 'admin_panel', 'test.log'), File.join(report_dir, 'admin-panel-test.log'))
|
|
354
|
-
check_and_copy(File.join(WEBROAR_ROOT,'src', 'admin_panel', 'error.log'), File.join(report_dir, 'admin-panel-error.log'))
|
|
355
|
-
check_and_copy(File.join(WEBROAR_ROOT,'src', 'admin_panel', 'test_summary'), File.join(report_dir, 'admin-panel-test-summary'))
|
|
356
|
-
|
|
357
|
-
# copy functional tests related files
|
|
358
|
-
check_and_copy(File.join(SPEC_DIR, 'test.log'), File.join(report_dir, 'spec-test.log'))
|
|
359
|
-
check_and_copy(File.join(SPEC_DIR, 'test_summary'), File.join(report_dir, 'spec-test-summary'))
|
|
360
|
-
check_and_copy(File.join(SPEC_DIR, 'setup.log'), File.join(report_dir, 'spec-test-setup.log'))
|
|
361
|
-
check_and_copy(File.join(SPEC_DIR, 'test-run.log'), File.join(report_dir, 'spec-test-run.log'))
|
|
362
|
-
|
|
363
|
-
# copy load tests related files
|
|
364
|
-
check_and_copy(File.join(TEST_DIR, 'load_test_summary'), File.join(report_dir, 'load-test-summary'))
|
|
365
|
-
check_and_copy(File.join(TEST_DIR, 'load_test_result_fix'), File.join(report_dir, 'load-test-result-fix'))
|
|
366
|
-
check_and_copy(File.join(TEST_DIR, 'load_test_result_random'), File.join(report_dir, 'load-test-result-random'))
|
|
367
|
-
|
|
368
|
-
# copy exception.log
|
|
369
|
-
check_and_copy(File.join(TEST_DIR, 'exception.log'), File.join(report_dir, 'exception.log.1'))
|
|
370
|
-
|
|
371
|
-
#copy database file
|
|
372
|
-
check_and_copy(File.join(WEBROAR_ROOT, 'src', 'admin_panel', 'db', 'webroar_test.sqlite3'), report_dir)
|
|
373
|
-
|
|
374
|
-
# copy debug_log files
|
|
375
|
-
if ENV["debug_build"] == "yes"
|
|
376
|
-
dest_debug_log_dir = File.join(report_dir, 'debug_log')
|
|
377
|
-
unless File.exists?(dest_debug_log_dir)
|
|
378
|
-
FileUtils.mkdir_p(dest_debug_log_dir)
|
|
379
|
-
end
|
|
380
|
-
log_file_pattern = File.join(DEBUG_LOG_DIR,'*')
|
|
381
|
-
log_files = Dir.glob(log_file_pattern)
|
|
382
|
-
for file in log_files
|
|
383
|
-
FileUtils.cp(file,dest_debug_log_dir)
|
|
384
|
-
end
|
|
442
|
+
unless REPORT_DIR == report_dir
|
|
443
|
+
FileUtils.cp_r(REPORT_DIR, report_dir)
|
|
385
444
|
end
|
|
386
|
-
end
|
|
387
445
|
|
|
388
|
-
desc "Integrated testing executes unit tests, admin-panel tests and functional \
|
|
389
|
-
tests. To run load tests give load_test=yes, to run build tests give \
|
|
390
|
-
build_test=yes as an argument. To run test under debug build give \
|
|
391
|
-
debug_build=yes as an argument."
|
|
392
|
-
task :all_test do
|
|
393
|
-
|
|
394
|
-
if ENV["debug_build"] == "yes"
|
|
395
|
-
# Clear log files.
|
|
396
|
-
system("webroar clear")
|
|
397
|
-
unless File.exists?(LOG_FILES)
|
|
398
|
-
FileUtils.mkdir_p(LOG_FILES)
|
|
399
|
-
end
|
|
400
|
-
end
|
|
401
|
-
|
|
402
|
-
exception_log = File.join(TEST_DIR,'exception.log')
|
|
403
|
-
File.truncate(exception_log,0) if File.exists?(exception_log)
|
|
404
|
-
|
|
405
|
-
if(test_flag==1)
|
|
406
|
-
t = Rake::Task[:unit_test]
|
|
407
|
-
begin
|
|
408
|
-
t.invoke()
|
|
409
|
-
rescue Exception => e
|
|
410
|
-
File.open(exception_log,"a") do |f|
|
|
411
|
-
f.puts e
|
|
412
|
-
f.puts e.backtrace
|
|
413
|
-
end
|
|
414
|
-
end
|
|
415
|
-
end
|
|
416
|
-
|
|
417
|
-
if(test_flag==1)
|
|
418
|
-
t = Rake::Task[:spec]
|
|
419
|
-
puts "Executing functional tests ..."
|
|
420
|
-
begin
|
|
421
|
-
ENV["SPEC_OPTS"] = "--format specdoc:#{TEST_RESULT}"
|
|
422
|
-
t.invoke()
|
|
423
|
-
rescue Exception => e
|
|
424
|
-
File.open(exception_log,"a") do |f|
|
|
425
|
-
f.puts e
|
|
426
|
-
f.puts e.backtrace
|
|
427
|
-
end
|
|
428
|
-
ensure
|
|
429
|
-
if File.exists?(TEST_RESULT)
|
|
430
|
-
system("tail -2 #{File.join(SPEC_DIR,'test.log')} > #{File.join(SPEC_DIR,'test_summary')}")
|
|
431
|
-
result = File.read(File.join(SPEC_DIR,'test_summary'))
|
|
432
|
-
total = 0
|
|
433
|
-
failed = 0
|
|
434
|
-
if result =~ /(\d+)\s*(example|examples),\s*(\d+)\s*failure/
|
|
435
|
-
total = $1
|
|
436
|
-
failed = $3
|
|
437
|
-
end
|
|
438
|
-
str = "Functional test summary\nTotal test: #{total}\nFailed test: #{failed}\n"
|
|
439
|
-
File.open(File.join(SPEC_DIR,'test_summary'),"w") do |f|
|
|
440
|
-
f.puts str
|
|
441
|
-
end
|
|
442
|
-
end
|
|
443
|
-
|
|
444
|
-
if ENV["debug_build"] == "yes"
|
|
445
|
-
unless File.exists?(DEBUG_LOG_DIR)
|
|
446
|
-
FileUtils.mkdir_p(DEBUG_LOG_DIR)
|
|
447
|
-
end
|
|
448
|
-
log_file_pattern = File.join(LOG_FILES,'*.log')
|
|
449
|
-
log_files = Dir.glob(log_file_pattern)
|
|
450
|
-
for file in log_files
|
|
451
|
-
FileUtils.cp(file,File.join(DEBUG_LOG_DIR,"#{File.basename(file)}.spec"))
|
|
452
|
-
end
|
|
453
|
-
cmd = "#{File.join(WEBROAR_ROOT,'bin','webroar')} clear"
|
|
454
|
-
system(cmd)
|
|
455
|
-
end
|
|
456
|
-
end
|
|
457
|
-
end
|
|
458
|
-
|
|
459
|
-
if(test_flag==1)
|
|
460
|
-
t = Rake::Task[:admin_panel_test]
|
|
461
|
-
begin
|
|
462
|
-
t.invoke()
|
|
463
|
-
rescue Exception => e
|
|
464
|
-
File.open(exception_log,"a") do |f|
|
|
465
|
-
f.puts e
|
|
466
|
-
f.puts e.backtrace
|
|
467
|
-
end
|
|
468
|
-
end
|
|
469
|
-
end
|
|
470
|
-
|
|
471
|
-
if test_flag==1 and ENV["load_test"] == 'yes'
|
|
472
|
-
t = Rake::Task[:load_test]
|
|
473
|
-
begin
|
|
474
|
-
t.invoke()
|
|
475
|
-
rescue Exception => e
|
|
476
|
-
File.open(exception_log,"a") do |f|
|
|
477
|
-
f.puts e
|
|
478
|
-
f.puts e.backtrace
|
|
479
|
-
end
|
|
480
|
-
end
|
|
481
|
-
end
|
|
482
|
-
|
|
483
|
-
if test_flag==1 and ENV["build_test"] == "yes"
|
|
484
|
-
t = Rake::Task[:build_test]
|
|
485
|
-
begin
|
|
486
|
-
t.invoke()
|
|
487
|
-
rescue Exception => e
|
|
488
|
-
File.open(exception_log,"a") do |f|
|
|
489
|
-
f.puts e
|
|
490
|
-
f.puts e.backtrace
|
|
491
|
-
end
|
|
492
|
-
end
|
|
493
|
-
end
|
|
494
|
-
|
|
495
|
-
if(ENV["report_dir"])
|
|
496
|
-
test_cleanup(ENV["report_dir"])
|
|
497
|
-
end
|
|
498
|
-
|
|
499
|
-
unless ENV["no_report"]
|
|
500
|
-
test_report(ENV["report_dir"])
|
|
501
|
-
end
|
|
502
|
-
|
|
503
446
|
end
|
|
504
447
|
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
def test_report(report_dir)
|
|
448
|
+
def test_report
|
|
508
449
|
total = 0
|
|
509
450
|
failed = 0
|
|
510
|
-
f = File.open(File.join(
|
|
451
|
+
f = File.open(File.join(REPORT_DIR,'test-summary'),"w")
|
|
511
452
|
f.puts "------------------------------------------------------------------------------"
|
|
512
453
|
fmt = "%*s%*s%*s"
|
|
513
454
|
str = fmt % [-58,'Type',10,'Total',10,'Failed']
|
|
514
455
|
f.puts str
|
|
515
456
|
f.puts "-------------------------------------------------------------------------------"
|
|
516
|
-
if File.exists?(File.join(
|
|
517
|
-
result = File.read(File.join(
|
|
457
|
+
if File.exists?(File.join(UNIT_TEST_REPORT,'test-summary'))
|
|
458
|
+
result = File.read(File.join(UNIT_TEST_REPORT,'test-summary'))
|
|
518
459
|
result =~ /Total\s*test:\s*(\d+)\s*Failed\s*test:\s*(\d+)/m
|
|
519
460
|
str = fmt % [-58, 'Unit Tests',10,$1,10,$2]
|
|
520
461
|
f.puts str
|
|
@@ -522,8 +463,8 @@ def test_report(report_dir)
|
|
|
522
463
|
failed += $2.to_i
|
|
523
464
|
end
|
|
524
465
|
|
|
525
|
-
if File.exists?(File.join(
|
|
526
|
-
result = File.read(File.join(
|
|
466
|
+
if File.exists?(File.join(ADMIN_TEST_REPORT,'test-summary'))
|
|
467
|
+
result = File.read(File.join(ADMIN_TEST_REPORT,'test-summary'))
|
|
527
468
|
result =~ /Total\s*test:\s*(\d+)\s*Failed\s*test:\s*(\d+)\s*Error:\s*(\d+)/m
|
|
528
469
|
str = fmt % [-58, 'Admin Panel Tests',10,$1,10,$2]
|
|
529
470
|
f.puts str
|
|
@@ -531,8 +472,8 @@ def test_report(report_dir)
|
|
|
531
472
|
failed += $2.to_i
|
|
532
473
|
end
|
|
533
474
|
|
|
534
|
-
if File.exists?(File.join(
|
|
535
|
-
result = File.read(File.join(
|
|
475
|
+
if File.exists?(File.join(SPEC_TEST_REPORT,'test-summary'))
|
|
476
|
+
result = File.read(File.join(SPEC_TEST_REPORT,'test-summary'))
|
|
536
477
|
result =~ /Total\s*test:\s*(\d+)\s*Failed\s*test:\s*(\d+)/m
|
|
537
478
|
str = fmt % [-58, 'Functional Tests', 10, $1, 10, $2]
|
|
538
479
|
f.puts str
|
|
@@ -540,8 +481,8 @@ def test_report(report_dir)
|
|
|
540
481
|
failed += $2.to_i
|
|
541
482
|
end
|
|
542
483
|
|
|
543
|
-
if File.exists?(File.join(
|
|
544
|
-
result = File.read(File.join(
|
|
484
|
+
if File.exists?(File.join(LOAD_TEST_REPORT,'test-summary'))
|
|
485
|
+
result = File.read(File.join(LOAD_TEST_REPORT,'test-summary'))
|
|
545
486
|
res = result.scan(/Total\s*test:\s*(\d+)\s*Failed\s*test:\s*(\d+)\s*/m)
|
|
546
487
|
str = fmt % [-58, "Load Test I - Continuous Run", 10, res[0][0], 10, res[0][1]]
|
|
547
488
|
f.puts str
|
|
@@ -551,8 +492,8 @@ def test_report(report_dir)
|
|
|
551
492
|
failed += res[0][1].to_i + res[1][1].to_i
|
|
552
493
|
end
|
|
553
494
|
|
|
554
|
-
if File.exists?(File.join(
|
|
555
|
-
result = File.read(File.join(
|
|
495
|
+
if File.exists?(File.join(BUILD_TEST_REPORT,'test-summary'))
|
|
496
|
+
result = File.read(File.join(BUILD_TEST_REPORT,'test-summary'))
|
|
556
497
|
result =~ /Total\s*test:\s*(\d+)\s*Failed\s*test:\s*(\d+)/m
|
|
557
498
|
str = fmt % [-58, "Build Tests", 10, $1, 10, $2]
|
|
558
499
|
f.puts str
|
|
@@ -562,48 +503,48 @@ def test_report(report_dir)
|
|
|
562
503
|
end
|
|
563
504
|
f.close
|
|
564
505
|
|
|
565
|
-
f = File.open(File.join(
|
|
566
|
-
f.puts File.read(File.join(
|
|
506
|
+
f = File.open(File.join(REPORT_DIR,'test-report'),"w")
|
|
507
|
+
f.puts File.read(File.join(REPORT_DIR,'test-summary')) if File.exists?(File.join(REPORT_DIR,'test-summary'))
|
|
567
508
|
|
|
568
|
-
if File.exists?(File.join(
|
|
509
|
+
if File.exists?(File.join(UNIT_TEST_REPORT,'test.log'))
|
|
569
510
|
f.puts "-------------------------------Unit Tests Result--------------------------------"
|
|
570
|
-
f.puts File.read(File.join(
|
|
511
|
+
f.puts File.read(File.join(UNIT_TEST_REPORT,'test.log'))
|
|
571
512
|
f.puts "\n"
|
|
572
513
|
end
|
|
573
514
|
|
|
574
|
-
if File.exists?(File.join(
|
|
515
|
+
if File.exists?(File.join(ADMIN_TEST_REPORT,'test.log'))
|
|
575
516
|
f.puts "-----------------------------Admin Panel Tests Result---------------------------"
|
|
576
|
-
f.puts File.read(File.join(
|
|
517
|
+
f.puts File.read(File.join(ADMIN_TEST_REPORT, 'test.log'))
|
|
577
518
|
f.puts "\n"
|
|
578
519
|
end
|
|
579
520
|
|
|
580
|
-
if File.exists?(File.join(
|
|
521
|
+
if File.exists?(File.join(SPEC_TEST_REPORT,'test.log'))
|
|
581
522
|
f.puts "------------------------------Functional Tests Result---------------------------"
|
|
582
|
-
f.puts File.read(File.join(
|
|
523
|
+
f.puts File.read(File.join(SPEC_TEST_REPORT,'test.log'))
|
|
583
524
|
f.puts "\n"
|
|
584
525
|
end
|
|
585
526
|
|
|
586
|
-
if File.exists?(File.join(
|
|
527
|
+
if File.exists?(File.join(LOAD_TEST_REPORT,'test-result-fix'))
|
|
587
528
|
f.puts "---------------------------Load Test I - Continuous Run-------------------------"
|
|
588
|
-
f.puts File.read(File.join(
|
|
529
|
+
f.puts File.read(File.join(LOAD_TEST_REPORT,'test-result-fix'))
|
|
589
530
|
f.puts "\n"
|
|
590
531
|
end
|
|
591
532
|
|
|
592
|
-
if File.exists?(File.join(
|
|
533
|
+
if File.exists?(File.join(LOAD_TEST_REPORT,'test-result-random'))
|
|
593
534
|
f.puts "------------------------Load test II - Random Sleep Intervals-------------------"
|
|
594
|
-
f.puts File.read(File.join(
|
|
535
|
+
f.puts File.read(File.join(LOAD_TEST_REPORT,'test-result-random'))
|
|
595
536
|
f.puts "\n"
|
|
596
537
|
end
|
|
597
538
|
|
|
598
|
-
if File.exists?(File.join(
|
|
539
|
+
if File.exists?(File.join(BUILD_TEST_REPORT,'build_test'))
|
|
599
540
|
f.puts "--------------------------------Build Tests Result------------------------------"
|
|
600
|
-
f.puts File.read(File.join(
|
|
541
|
+
f.puts File.read(File.join(BUILD_TEST_REPORT,'build_test'))
|
|
601
542
|
f.puts "\n"
|
|
602
543
|
end
|
|
603
544
|
|
|
604
545
|
f.close
|
|
605
546
|
|
|
606
|
-
f = File.open(File.join(
|
|
547
|
+
f = File.open(File.join(REPORT_DIR,"test-result"),"w")
|
|
607
548
|
if total == 0 and failed == 0
|
|
608
549
|
f.puts "Could not be executed at all"
|
|
609
550
|
elsif total == failed
|
|
@@ -617,105 +558,40 @@ def test_report(report_dir)
|
|
|
617
558
|
|
|
618
559
|
end
|
|
619
560
|
|
|
561
|
+
desc "Integrated testing executes unit tests, admin-panel tests and functional \
|
|
562
|
+
tests. To run load tests give load_test=yes, to run build tests give \
|
|
563
|
+
build_test=yes as an argument. To run test under debug build give \
|
|
564
|
+
debug_build=yes as an argument."
|
|
565
|
+
task :all_test => [:create_test_dirs, :unit_test, :spec_test, :admin_panel_test, :load_test] do
|
|
566
|
+
|
|
567
|
+
unless ENV["no_report"]
|
|
568
|
+
test_report
|
|
569
|
+
end
|
|
570
|
+
|
|
571
|
+
if(ENV["report_dir"])
|
|
572
|
+
test_cleanup(ENV["report_dir"])
|
|
573
|
+
end
|
|
574
|
+
|
|
575
|
+
end
|
|
576
|
+
|
|
620
577
|
desc "Runs integrated test-suit comprises of gem creation, installation, unit \
|
|
621
578
|
tests, admin-panel tests, functional tests. To run load tests give \
|
|
622
579
|
load_test=yes as an argument. To run under debug build give debug_build=\
|
|
623
580
|
yes as an argument."
|
|
624
|
-
task :test do
|
|
625
|
-
exception_log = File.join(TEST_DIR,'exception.log')
|
|
626
|
-
File.truncate(exception_log,0) if File.exists?(exception_log)
|
|
627
|
-
|
|
628
|
-
build_test = File.join(TEST_DIR,'build_test')
|
|
629
|
-
build_test_summary = File.join(TEST_DIR,'build_test_summary')
|
|
630
|
-
exception_log = File.join(TEST_DIR,'exception.log')
|
|
581
|
+
task :test => [:build_test] do
|
|
631
582
|
|
|
632
583
|
Dir.chdir(WEBROAR_ROOT)
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
failed = 0
|
|
637
|
-
bf = File.open(build_test,'w')
|
|
638
|
-
bf.print "Build gem ... "
|
|
639
|
-
total += 1
|
|
640
|
-
t = Rake::Task[:build]
|
|
641
|
-
begin
|
|
642
|
-
t.invoke()
|
|
643
|
-
rescue Exception => e
|
|
644
|
-
File.open(exception_log,"a") do |f|
|
|
645
|
-
f.puts e
|
|
646
|
-
f.puts e.backtrace
|
|
647
|
-
end
|
|
648
|
-
end
|
|
649
|
-
# puts "$? = #$?"
|
|
650
|
-
unless $? == 0
|
|
651
|
-
failed += 1
|
|
652
|
-
bf.puts "Failed"
|
|
653
|
-
else
|
|
654
|
-
bf.puts "Pass"
|
|
655
|
-
end
|
|
656
|
-
|
|
657
|
-
bf.print "Install gem and server ... "
|
|
658
|
-
total += 1
|
|
659
|
-
t = Rake::Task[:build_install]
|
|
660
|
-
begin
|
|
661
|
-
t.invoke()
|
|
662
|
-
rescue Exception => e
|
|
663
|
-
File.open(exception_log,"a") do |f|
|
|
664
|
-
f.puts e
|
|
665
|
-
f.puts e.backtrace
|
|
666
|
-
end
|
|
667
|
-
end
|
|
668
|
-
# puts "$? = #$?"
|
|
669
|
-
unless $? == 0
|
|
670
|
-
failed += 1
|
|
671
|
-
bf.puts "Failed"
|
|
672
|
-
else
|
|
673
|
-
bf.puts "Pass"
|
|
674
|
-
end
|
|
675
|
-
|
|
676
|
-
str = "-n "
|
|
677
|
-
|
|
678
|
-
if ENV["debug_build"] == "yes"
|
|
679
|
-
str += "-d "
|
|
680
|
-
end
|
|
584
|
+
|
|
585
|
+
Rake::Task[:build_install].reenable
|
|
586
|
+
Rake::Task[:build_install].invoke
|
|
681
587
|
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
588
|
+
str = " "
|
|
589
|
+
str += "-d " if ENV["debug_build"] == "yes"
|
|
590
|
+
str += "-l" if ENV["load_test"] == "yes"
|
|
685
591
|
|
|
686
592
|
# Run tests on installed directory. Copy test-report and test-summary to TEST_DIR
|
|
687
593
|
cmd = "webroar test -r=#{REPORT_DIR} #{str}"
|
|
688
594
|
system(cmd)
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
total += 1
|
|
692
|
-
t = Rake::Task[:build_uninstall]
|
|
693
|
-
begin
|
|
694
|
-
t.invoke()
|
|
695
|
-
rescue Exception => e
|
|
696
|
-
File.open(exception_log,"a") do |f|
|
|
697
|
-
f.puts e
|
|
698
|
-
f.puts e.backtrace
|
|
699
|
-
end
|
|
700
|
-
end
|
|
701
|
-
# puts "$? = #$?"
|
|
702
|
-
unless $? == 0
|
|
703
|
-
failed += 1
|
|
704
|
-
bf.puts "Failed"
|
|
705
|
-
else
|
|
706
|
-
bf.puts "Pass"
|
|
707
|
-
end
|
|
708
|
-
|
|
709
|
-
bf.puts "#{total} total, #{failed} failed\n"
|
|
710
|
-
bf.close
|
|
711
|
-
|
|
712
|
-
str = "Build test summary\nTotal test: #{total}\nFailed test: #{failed}\n"
|
|
713
|
-
File.open(build_test_summary,"w") do |f|
|
|
714
|
-
f.puts str
|
|
715
|
-
end
|
|
716
|
-
|
|
717
|
-
test_report(REPORT_DIR)
|
|
595
|
+
Rake::Task[:build_uninstall].reenable
|
|
596
|
+
Rake::Task[:build_uninstall].invoke
|
|
718
597
|
end
|
|
719
|
-
|
|
720
|
-
#desc "Integration testing and test-suite summary, report and one line result."
|
|
721
|
-
#task :test => [:all_test, :test_report]
|