Changeset 1012
- Timestamp:
- 04/18/08 02:09:44 (3 months ago)
- Files:
-
- branches/stable_1-2 (modified) (2 props)
- branches/stable_1-2/projects/mongrel_service/CHANGELOG (modified) (1 diff)
- branches/stable_1-2/projects/mongrel_service/native/console_process.bas (modified) (6 diffs)
- branches/stable_1-2/projects/mongrel_service/tests/test_console_process.bas (modified) (24 diffs)
- branches/stable_1-2/projects/mongrel_service/tests/test_helpers.bas (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/stable_1-2
- Property bzr:revision-id:v3-trunk0 changed from
814 luislavena@gmail.com-20080331074345-8r7ghwi05bwwqz7f
815 luislavena@gmail.com-20080331075048-t48wb12km03z1k7d
816 luislavena@gmail.com-20080331081757-x3m83b2w24vlgbhz
817 luislavena@gmail.com-20080406001418-f6mxbnyordlkvosz
822 luislavena@gmail.com-20080418001345-y6hgwpxkfc5qml6v
823 luislavena@gmail.com-20080418001931-wxuitk2diz0s32cu
824 luislavena@gmail.com-20080418001955-wdpwvupki3pe6mu4
825 luislavena@gmail.com-20080418065700-yx69onb815nh8zgg
to
814 luislavena@gmail.com-20080331074345-8r7ghwi05bwwqz7f
815 luislavena@gmail.com-20080331075048-t48wb12km03z1k7d
816 luislavena@gmail.com-20080331081757-x3m83b2w24vlgbhz
817 luislavena@gmail.com-20080406001418-f6mxbnyordlkvosz
822 luislavena@gmail.com-20080418001345-y6hgwpxkfc5qml6v
823 luislavena@gmail.com-20080418001931-wxuitk2diz0s32cu
824 luislavena@gmail.com-20080418001955-wdpwvupki3pe6mu4
825 luislavena@gmail.com-20080418065700-yx69onb815nh8zgg
826 luislavena@gmail.com-20080418070615-2a0sikp3sfacwy2k - Property bzr:revision-info changed from
timestamp: 2008-04-18 03:57:00.687000036 -0300
committer: Luis Lavena <luislavena@gmail.com>
properties:
branch-nick: stable_1-2
to
timestamp: 2008-04-18 04:06:15.515000105 -0300
committer: Luis Lavena <luislavena@gmail.com>
properties:
branch-nick: stable_1-2
- Property bzr:revision-id:v3-trunk0 changed from
branches/stable_1-2/projects/mongrel_service/CHANGELOG
r1007 r1012 1 * 0.3.5 * 2 3 * Wait longer for child process terminate properly (max 20 seconds). Imported 4 tests from RubyServices project. (Closes #18). 5 * Updated ServiceFB to work with FB > 0.18. 1 6 2 7 * 0.3.4 * branches/stable_1-2/projects/mongrel_service/native/console_process.bas
r623 r1012 82 82 83 83 property ConsoleProcess.exit_code() as uinteger 84 static previous_code as uinteger 84 85 dim result as uinteger 85 86 … … 91 92 '# the process reference is valid, get the exit_code 92 93 if not (GetExitCodeProcess(_process_info.hProcess, @result) = 0) then 94 previous_code = result 93 95 '# OK 94 96 '# no error in the query, get result 97 if not (result = STILL_ACTIVE) then 98 CloseHandle(_process_info.hProcess) 99 _process_info.hProcess = NULL 100 end if '# (result = STILL_ACTIVE) 95 101 end if '# not (GetExitCodeProcess() = 0) 102 else 103 result = previous_code 96 104 end if '# not (proc = NULL) 97 105 end if '# not (_pid = 0) … … 229 237 '# use pipes instead 230 238 '# StdOut 231 if (CreatePipe(@StdErrRd, @StdErrWr, @proc_sa, 0) = 0) then 239 if (CreatePipe(@StdErrRd, @StdErrWr, @proc_sa, 0) = 0) then 232 240 success = false 233 241 end if … … 284 292 CloseHandle(StdErrWr) 285 293 286 '# close children main Thread handle 287 ' CloseHandle(proc.hThread)288 'CloseHandle(proc.hProcess)289 294 '# close children main Thread handle and 295 '# NULLify to avoid issues 296 CloseHandle(_process_info.hThread) 297 _process_info.hThread = NULL 290 298 end if '# (CreateProcess() = 0) 291 299 else … … 323 331 if not (GenerateConsoleCtrlEvent(CTRL_C_EVENT, 0) = 0) then 324 332 '# it worked, wait 5 seconds terminates. 325 wait_code = WaitForSingleObject(proc, 5000)333 wait_code = WaitForSingleObject(proc, 10000) 326 334 if not (wait_code = WAIT_TIMEOUT) then 327 335 success = true … … 336 344 if not (GenerateConsoleCtrlEvent(CTRL_BREAK_EVENT, 0) = 0) then 337 345 '# it worked, wait 5 seconds terminates. 338 wait_code = WaitForSingleObject(proc, 5000)346 wait_code = WaitForSingleObject(proc, 10000) 339 347 if not (wait_code = WAIT_TIMEOUT) then 340 348 success = true branches/stable_1-2/projects/mongrel_service/tests/test_console_process.bas
r1009 r1012 31 31 sub test_process_create() 32 32 child = new ConsoleProcess() 33 assert_not_equal _error(0, child)33 assert_not_equal(0, child) 34 34 assert_equal("", child->filename) 35 35 assert_equal("", child->arguments) … … 65 65 '# improperly 66 66 assert_true(child->start()) 67 sleep 15067 sleep 500 68 68 69 69 '# should not be running, but pid should be != than 0 … … 81 81 82 82 sub test_redirected_output() 83 assert_false(fileexists("out.log")) 84 assert_false(fileexists("err.log")) 85 83 86 '# redirected output is used with logging files. 84 87 child = new ConsoleProcess("mock_process.exe") … … 94 97 '# start() will be true since process terminated nicely 95 98 assert_true(child->start()) 96 sleep 15099 sleep 500 97 100 98 101 '# running should be false … … 101 104 '# exit_code should be 0 102 105 assert_equal(0, child->exit_code) 106 107 delete child 103 108 104 109 '# now out.log and err.log must exist and content must be valid. … … 109 114 assert_string_equal("err: error", content_of_file("err.log")) 110 115 111 '# cleanup 112 process_cleanup() 113 assert_equal_error(0, kill("out.log")) 114 assert_equal_error(0, kill("err.log")) 115 116 assert_true_error(fileexists("err.log")) 117 118 delete child 116 assert_equal(0, kill("out.log")) 117 assert_equal(0, kill("err.log")) 119 118 end sub 120 119 … … 132 131 '# start() will be true since process terminated nicely 133 132 assert_true(child->start()) 134 sleep 150133 sleep 500 135 134 136 135 '# running should be false … … 140 139 assert_equal(0, child->exit_code) 141 140 141 delete child 142 142 143 '# file must exists 143 144 assert_true(fileexists("both.log")) … … 149 150 assert_not_equal(0, instr(content, "err: error")) 150 151 151 '# cleanup 152 process_cleanup() 153 assert_equal_error(0, kill("both.log")) 154 155 delete child 152 assert_equal(0, kill("both.log")) 156 153 end sub 157 154 … … 166 163 '# start() will be true since process terminated nicely 167 164 assert_true(child->start()) 168 sleep 150165 sleep 500 169 166 170 167 content = content_of_file("both.log") … … 172 169 '# start() again 173 170 assert_true(child->start()) 174 sleep 150 171 sleep 500 172 173 delete child 175 174 176 175 assert_not_equal(len(content), len(content_of_file("both.log"))) 177 176 178 '# cleanup 179 process_cleanup() 180 assert_equal_error(0, kill("both.log")) 181 182 delete child 177 assert_equal(0, kill("both.log")) 183 178 end sub 184 179 … … 192 187 '# start 193 188 assert_true(child->start()) 194 sleep 150189 sleep 500 195 190 196 191 '# validate if running … … 202 197 '# now terminates it 203 198 assert_true(child->terminate()) 204 sleep 150199 sleep 500 205 200 206 201 assert_equal(9, child->exit_code) … … 208 203 '# it should be done 209 204 assert_false(child->running) 205 206 delete child 210 207 211 208 '# validate output … … 220 217 assert_not_equal(0, instr(content, "interrupted")) 221 218 222 '# cleanup 223 process_cleanup() 224 assert_equal_error(0, kill("both.log")) 225 226 delete child 227 end sub 228 229 sub test_process_terminate_slow() 230 dim content as string 231 232 '# redirected output is used with logging files. 233 child = new ConsoleProcess("mock_process.exe", "slow") 234 child->redirect(ProcessStdBoth, "both_slow.log") 219 assert_equal(0, kill("both.log")) 220 end sub 221 222 sub test_process_terminate_slow1() 223 dim content as string 224 225 '# redirected output is used with logging files. 226 child = new ConsoleProcess("mock_process.exe", "slow1") 227 child->redirect(ProcessStdBoth, "both_slow1.log") 235 228 236 229 '# start 237 230 assert_true(child->start()) 238 sleep 150231 sleep 500 239 232 240 233 '# validate if running … … 246 239 '# now terminates it 247 240 assert_true(child->terminate()) 248 sleep 150 249 250 '# it should be done now 251 assert_false(child->running) 241 sleep 500 242 252 243 assert_equal(10, child->exit_code) 244 245 '# it should be done 246 assert_false(child->running) 247 248 delete child 253 249 254 250 '# validate output 255 251 '# file must exists 256 assert_true(fileexists("both_slow .log"))252 assert_true(fileexists("both_slow1.log")) 257 253 258 254 '# contents must match 259 content = content_of_file("both_slow.log") 260 261 assert_not_equal(0, instr(content, "out: message")) 262 assert_not_equal(0, instr(content, "err: error")) 263 assert_not_equal(0, instr(content, "out: slow stop")) 255 content = content_of_file("both_slow1.log") 256 264 257 assert_equal(0, instr(content, "interrupted")) 258 assert_not_equal(0, instr(content, "out: CTRL-C received")) 259 assert_equal(0, instr(content, "out: CTRL-BREAK received")) 260 261 assert_equal(0, kill("both_slow1.log")) 262 end sub 263 264 sub test_process_terminate_slow2() 265 dim content as string 266 267 '# redirected output is used with logging files. 268 child = new ConsoleProcess("mock_process.exe", "slow2") 269 child->redirect(ProcessStdBoth, "both_slow2.log") 270 271 '# start 272 assert_true(child->start()) 273 sleep 500 274 275 '# validate if running 276 assert_true(child->running) 277 278 '# validate PID 279 assert_not_equal(0, child->pid) 280 281 '# now terminates it 282 assert_true(child->terminate()) 283 sleep 500 284 285 assert_equal(20, child->exit_code) 286 287 '# it should be done 288 assert_false(child->running) 289 290 delete child 291 292 '# validate output 293 '# file must exists 294 assert_true(fileexists("both_slow2.log")) 295 296 '# contents must match 297 content = content_of_file("both_slow2.log") 298 299 assert_equal(0, instr(content, "interrupted")) 300 assert_not_equal(0, instr(content, "out: CTRL-C received")) 301 assert_not_equal(0, instr(content, "out: CTRL-BREAK received")) 265 302 266 303 '# cleanup 267 process_cleanup() 268 assert_equal_error(0, kill("both_slow.log")) 269 270 delete child 271 end sub 272 304 assert_equal(0, kill("both_slow2.log")) 305 end sub 306 273 307 sub test_process_terminate_forced() 274 308 dim content as string 275 dim x as integer276 309 277 310 '# redirected output is used with logging files. … … 281 314 '# start 282 315 assert_true(child->start()) 283 sleep 150316 sleep 500 284 317 285 318 '# validate if running … … 291 324 '# now terminates it 292 325 assert_true(child->terminate(true)) 293 sleep 150326 sleep 500 294 327 295 328 '# it should be done … … 298 331 '# look for termination code 299 332 assert_equal(0, child->exit_code) 333 334 delete child 300 335 301 336 '# validate output … … 310 345 assert_equal(0, instr(content, "interrupted")) 311 346 312 '# cleanup 313 process_cleanup() 314 assert_equal_error(0, kill("both_forced.log")) 315 316 delete child 347 assert_equal(0, kill("both_forced.log")) 317 348 end sub 318 349 … … 324 355 '# start 325 356 assert_true(child->start()) 326 sleep 150357 sleep 500 327 358 328 359 '# validate not running … … 337 368 '# start it again 338 369 assert_true(child->start()) 339 sleep 150370 sleep 500 340 371 341 372 '# it should have stopped by now … … 343 374 assert_not_equal(0, child->pid) 344 375 assert_not_equal(first_pid, child->pid) 345 346 '# cleanup347 process_cleanup()348 376 349 377 delete child … … 361 389 add_test(test_redirected_output_append) 362 390 add_test(test_process_terminate) 363 add_test(test_process_terminate_slow) 391 add_test(test_process_terminate_slow1) 392 add_test(test_process_terminate_slow2) 364 393 add_test(test_process_terminate_forced) 365 394 add_test(test_reuse_object_instance) branches/stable_1-2/projects/mongrel_service/tests/test_helpers.bas
r1009 r1012 34 34 return result 35 35 end function 36 37 print content_of_file("testing.log")
