Skip to content

Instantly share code, notes, and snippets.

@Gsantomaggio
Last active February 8, 2016 17:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Gsantomaggio/0b32a0eb9a08e2316051 to your computer and use it in GitHub Desktop.
Save Gsantomaggio/0b32a0eb9a08e2316051 to your computer and use it in GitHub Desktop.
__author__ = 'gabriele'
import urllib2
import base64
import time
import datetime
import json
def print_time(step):
ts = time.time();
st = datetime.datetime.fromtimestamp(ts).strftime('%Y-%m-%d %H:%M:%S');
print st + " - " + step;
def call_api(rabbitmqhost, api):
request = urllib2.Request("http://" + rabbitmqhost + ":15672/api/" + api);
base64string = base64.encodestring('%s:%s' % ('guest', 'guest')).replace(
'\n', '')
request.add_header("Authorization", "Basic %s" % base64string);
request.get_method = lambda: 'GET';
response = urllib2.urlopen(request);
print_time(" *** response done, loading json");
json.load(response);
print_time(" *** json loaded");
if __name__ == '__main__':
RabbitmqHost = "localhost";
for x in range(0, 5):
print " --- start test ------- number " + str(x)
print_time("start get full (old api /queues)");
call_api(RabbitmqHost, "queues");
print_time("end get full (old api /queues)");
print " "
pages = ["1", "10", "50", "100", "150"];
for page in pages:
print_time("start get (queues?page=" + page + ")");
call_api(RabbitmqHost, "queues?page=" + page + "&page_size=100");
print_time("end get (queues?page=" + page + ")");
print " "
print " --- start test"
print_time("start get full (old api /exchanges)");
call_api(RabbitmqHost, "exchanges");
print_time("end get full (old api /exchanges)");
print " "
for page in pages:
print_time("start get (/exchanges?page=" + page + ")");
call_api(RabbitmqHost, "/exchanges?page=" + page + "&page_size=100");
print_time("end get (/exchanges?page=" + page + ")");
print " "
print " --- start test"
print_time("start get full (old api /connections)");
call_api(RabbitmqHost, "connections");
print_time("end get full (old api /connections)");
print " "
pages = ["1"];
for page in pages:
print_time("start get (/connections?page=" + page + ")");
call_api(RabbitmqHost, "/connections?page=" + page + "&page_size=100");
print_time("end get (/connections?page=" + page + ")");
print " "
print " --- start test"
print_time("start get full (old api /channels)");
call_api(RabbitmqHost, "channels");
print_time("end get full (old api /channels)");
print " "
for page in pages:
print_time("start get (/channels?page=" + page + ")");
call_api(RabbitmqHost, "/channels?page=" + page + "&page_size=100");
print_time("end get (/channels?page=" + page + ")");
print " "
print " --- end test"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment