Created
August 18, 2012 08:43
-
-
Save everplays/3385369 to your computer and use it in GitHub Desktop.
stress testing for archipel
This file contains 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 "blather/client" | |
$vm_jid = "3d0483f8-e394-11e1-a994-d0df9ad31bb4@behrooz/hypervisor" | |
class Create < Blather::Stanza::Iq | |
def self.new | |
iq = super("get", $vm_jid) | |
queryTag = Blather::XMPPNode.new("query") | |
queryTag["xmlns"] = "archipel:vm:control" | |
archipelTag = Blather::XMPPNode.new("archipel") | |
archipelTag["action"] = "create" | |
queryTag << archipelTag | |
iq << queryTag | |
iq | |
end | |
end | |
class Destroy < Blather::Stanza::Iq | |
def self.new | |
iq = super("get", $vm_jid) | |
queryTag = Blather::XMPPNode.new("query") | |
queryTag["xmlns"] = "archipel:vm:control" | |
archipelTag = Blather::XMPPNode.new("archipel") | |
archipelTag["action"] = "destroy" | |
queryTag << archipelTag | |
iq << queryTag | |
iq | |
end | |
end | |
creates = {} | |
cerrors = 0 | |
destroys = {} | |
derrors = 0 | |
count = 0 | |
setup "admin@behrooz", "admin" | |
when_ready { | |
count += 1 | |
q = Create.new | |
creates[q["id"]] = Time.now.to_f | |
write_to_stream q | |
} | |
iq '/iq', :ns => 'archipel:vm:control' do |stanza| | |
stop = false | |
if count == 1000 | |
stop = true | |
end | |
if creates[stanza["id"]].present? | |
if stanza["type"]=="error" | |
cerrors += 1 | |
end | |
creates[stanza["id"]] = Time.now.to_f - creates[stanza["id"]] | |
if not stop | |
count += 1 | |
q = Destroy.new | |
destroys[q["id"]] = Time.now.to_f | |
write_to_stream q | |
end | |
elsif destroys[stanza["id"]].present? | |
if stanza["type"]=="error" | |
derrors += 1 | |
end | |
destroys[stanza["id"]] = Time.now.to_f - destroys[stanza["id"]] | |
if not stop | |
count += 1 | |
q = Create.new | |
creates[q["id"]] = Time.now.to_f | |
write_to_stream q | |
end | |
end | |
if stop | |
summary = 0 | |
for k,v in creates | |
summary += v | |
end | |
min = creates.min() | |
max = creates.max() | |
puts "creates (#{creates.length})" | |
puts "errors #{cerrors}" | |
puts "min #{min[1]}s (#{min[0]})" | |
puts "ave #{summary/creates.length}s" | |
puts "max #{max[1]}s (#{max[0]})" | |
summary = 0 | |
for k,v in destroys | |
summary += v | |
end | |
min = destroys.min() | |
max = destroys.max() | |
puts "destroys (#{destroys.length})" | |
puts "errors #{derrors}" | |
puts "min #{min[1]}s (#{min[0]})" | |
puts "ave #{summary/destroys.length}s" | |
puts "max #{max[1]}s (#{max[0]})" | |
shutdown | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment