Skip to content

Instantly share code, notes, and snippets.

@jackiig
Created December 4, 2015 22:01
Show Gist options
  • Save jackiig/4509ebef918de17c8fa9 to your computer and use it in GitHub Desktop.
Save jackiig/4509ebef918de17c8fa9 to your computer and use it in GitHub Desktop.
Testing sticky sessions.
#!/usr/bin/env ruby
# curl -ik 'https://54.183.250.60/whoami.mhtml' -H 'Cache-Control: max-age=0' -H 'Cookie: ROUTEID=.node2'
require 'net/https'
require 'uri'
ARGV[0] ||= "node2"
uri = URI.parse("https://54.183.250.60/whoami.mhtml?route=#{ARGV[0]}")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Get.new(uri.request_uri)
request["Cookie"] = "ROUTEID=.#{ARGV[0]}"
expected = nil
1000.times do
res = http.request(request)
if res['x-route-changed'].to_i > 0
raise "Route changed! #{res['x-route-changed']}, #{res['x-route']}"
end
if expected.nil?
expected = res.body
else
unless res.body == expected
raise "Response changed! #{res['x-route-changed']}, #{res['x-route']}"
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment