Skip to content

Instantly share code, notes, and snippets.

@jdunphy
Created March 23, 2010 17:25
Show Gist options
  • Save jdunphy/341428 to your computer and use it in GitHub Desktop.
Save jdunphy/341428 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'httparty'
require 'json'
class LoggedRequest
attr_reader :response_time, :path, :status
def initialize(request)
if request =~ /\"[A-Z]{3,4}\ (.+)\ HTTP/
@path = $1.gsub('//', '/')
end
if request =~ /\" ([2345]\d{2})/
@status = $1.to_i
end
if request =~ /[0-9\.]+\Z/
@response_time = $~[0].to_f
end
end
end
class Base
include HTTParty
base_uri 'localhost:7000'
end
class Other
include HTTParty
base_uri 'localhost:8000'
end
path = ARGV.shift
limit = ARGV.shift || 100
fails = []
`tail -#{limit} #{path}`.split("\n").each_with_index do |l,i|
r = LoggedRequest.new(l)
puts "#{i} => #{r.path}"
[
Thread.new {
@base_json = Base.get(r.path).body
@base = JSON.parse(@base_json)
},
Thread.new {
@other_json = Other.get(r.path).body
@other = JSON.parse(@other_json)
}
].each {|t| t.join }
if @base != @other
fails << [r.path, @base_json, @other_json]
end
end
puts "How many fails? #{fails.length}"
fails.each do |f|
puts f[0]
puts f[1]
puts f[2]
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment