-
-
Save jmhodges/169408 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'benchmark' | |
require 'rubygems' | |
require 'gruff' | |
require 'httparty' | |
require 'json' | |
class LoggedRequest | |
attr_reader :response_time, :path, :status | |
def initialize(request) | |
if request =~ /\"[A-Z]{3,4}\ (.+)\ HTTP/ | |
@path = $1 | |
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 Fast5 | |
include HTTParty | |
base_uri 'localhost:8000' | |
end | |
def clean(resp) | |
resp.delete 'TileResult' | |
res = resp['SearchResult'] | |
return unless res | |
if listings = res['BusinessListings'] | |
listings.each{|l| l.delete 'HasAdBundle' } | |
end | |
# FIXME DUNPHY: ARE THESE OKAY TO REMOVE? | |
if metadata = res['SearchMetadata'] | |
keys = ['excluded_cities','excluded_headings','excluded_tiers','excluded_zips','heading_codes'] | |
keys.each do |key| | |
metadata.delete(key) if metadata[key] == [] | |
end | |
end | |
end | |
path = ARGV.shift | |
f = File.new(path) | |
i = 0 | |
fails = [] | |
f.each_line do |l| | |
r = LoggedRequest.new(l) | |
puts i | |
i += 1 | |
begin | |
base = JSON.parse(Base.get(r.path)) | |
fast5 = JSON.parse(Fast5.get(r.path)) | |
rescue => e | |
fails << [r.path, e.inspect, nil] | |
break if i > 300 | |
next | |
end | |
clean(base) | |
clean(fast5) | |
if base != fast5 | |
fails << [r.path, base.to_json, fast5.to_json] | |
end | |
break if i > 300 | |
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