Skip to content

Commit

Permalink
Add restart test that excercises the app many times and prints results
Browse files Browse the repository at this point in the history
  • Loading branch information
quirkey committed Aug 27, 2014
1 parent 56b20db commit 85e046f
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions restart_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@

release_path = ENV['RELEASE_PATH']
attempts = (ARGV.shift || 100).to_i
timeout = (ARGV.shift || 6).to_i
failures = 0
successes = 0
i = 0
bin = "cef2go"

def is_running?(bin, timeout)
tries = 0
alive = true
while alive && tries < timeout
sleep 1
tries += 1
alive = `pidof #{bin}`.strip.split(' ').count > 0
end
alive
end

def kill(bin)
`killall -9 #{bin} > /dev/null 2>&1`
end

def run(release_path, bin)
`RELEASE_PATH=#{File.expand_path(release_path)} ./#{bin} >> test.log 2>&1 &`
end

puts "Running #{bin} #{attempts} times"

while i < attempts
run(release_path, bin)
if is_running?(bin, timeout)
successes += 1
print '.'
else
failures += 1
print 'F'
end
kill(bin)
i+=1
end

puts

puts "Successes: #{successes}. Failures: #{failures}. Fail Rate: #{(failures.to_f / attempts.to_f) * 100}"

0 comments on commit 85e046f

Please sign in to comment.