File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -295,4 +295,47 @@ def create_driver(conf)
295295 assert_match ( /LoadError/ , event [ 2 ] [ 'message' ] )
296296 end
297297 end
298+ sub_test_case 'command_timeout' do
299+ test 'configure command_timeout' do
300+ d = create_driver %[
301+ command ruby -e "sleep 10"
302+ tag test
303+ run_interval 1s
304+ command_timeout 1s
305+ <parse>
306+ @type none
307+ </parse>
308+ ]
309+ assert_equal 1.0 , d . instance . command_timeout
310+ end
311+
312+ test 'command_timeout kills long-running child process' do
313+ d = create_driver %[
314+ command ruby -e "sleep 10"
315+ tag test
316+ run_interval 5s
317+ command_timeout 1s
318+ <parse>
319+ @type none
320+ </parse>
321+ ]
322+ start_time = Time . now
323+ d . run ( timeout : 3 )
324+ elapsed = Time . now - start_time
325+
326+ assert elapsed < 4 , "command should have been killed by command_timeout"
327+ end
328+
329+ test 'command_timeout defaults to nil' do
330+ d = create_driver %[
331+ command ruby -e "puts 'hello'"
332+ tag test
333+ run_interval 1s
334+ <parse>
335+ @type none
336+ </parse>
337+ ]
338+ assert_nil d . instance . command_timeout
339+ end
340+ end
298341end
You can’t perform that action at this time.
0 commit comments