-
-
Save Gsantomaggio/0b32a0eb9a08e2316051 to your computer and use it in GitHub Desktop.
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
__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