Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #50 from romand-ironio/master
updating test_quick_run
  • Loading branch information
romand-ironio committed May 24, 2012
2 parents 722a7fd + aaa1841 commit 025462b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
1 change: 0 additions & 1 deletion test/test_change_runtime.rb
Expand Up @@ -23,7 +23,6 @@ def ruby_worker(code_name)
def sh_worker(code_name)
c = IronWorkerNG::Code::Binary
client.codes_create c.new(:name => code_name,
:runtime => 'sh',
:exec => (Tempfile.open('sh') do |f|
f << 'echo "hello"'
end).path)
Expand Down
25 changes: 19 additions & 6 deletions test/test_quick_run.rb
Expand Up @@ -24,15 +24,28 @@ def test_quick_run
end

def test_scheduler_quick
client.codes.create code_bundle(:name => 'test_schedule',
:exec => 'test/hello.rb')
client.codes.create( code_bundle(:name => 'test_schedule') do
worker_code 'sleep 10 and puts "hello"'
end )

start = (Time.now + 10).utc

id = client.schedules.create('scheduler_quick', :start_at => start).id
sleep 5 until client.schedules.get(id).status == 'complete'

task = get_all_tasks.
keep_if{ |t| t.code_name == 'scheduler_quick' }.
max_by{ |t| Time.parse t.start_time }

client.tasks.wait_for task.id

id = client.schedules.create('test_schedule', :start_at => Time.now + 10).id
sleep 5 until client.schedules.get(id).status != 'complete'
puts "planned start: ", start
puts "actual start: ", Time.parse(task.start_time)

task = get_all_tasks.find{ |t| t.code_name == 'test_schedule' }
# if fails, ensure local time is correct, try ntpdate
assert Time.parse(task.start_time) >= start

assert task
assert Time.parse(task.start_time) + 10 <= Time.parse(task.end_time)
assert_equal 'complete', task.status
assert_equal "hello\n", client.tasks.log(task.id)
end
Expand Down

0 comments on commit 025462b

Please sign in to comment.