Created
March 7, 2014 16:02
-
-
Save queertypes/9414251 to your computer and use it in GitHub Desktop.
Test against eom:governor
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
# rate_test.py | |
# usage: python test_rate.py <count> <url> <auth_token> | |
# reqs: pip install grequests | |
from __future__ import print_function | |
import grequests | |
import itertools | |
import requests | |
import sys | |
if __name__ == '__main__': | |
if len(sys.argv) < 4: | |
print('usage: {0} count url auth_token'.format(sys.argv[0])) | |
quit() | |
count, url, auth_token = sys.argv[1:] | |
count = int(count) | |
headers = {'x-auth-token': auth_token} | |
responses = [] | |
print(requests.get(url, headers=headers)) | |
responses = [r.status_code for r in grequests.map( | |
(grequests.get(u, headers=headers) | |
for u in itertools.repeat(url, count)) | |
)] | |
codes = { | |
'429': sum([1 for r in responses if r == 429]), | |
'200': sum([1 for r in responses if r == 200]), | |
'204': sum([1 for r in responses if r == 204]), | |
'other': sum([1 for r in responses if r not in [200, 204, 429]]) | |
} | |
print(codes) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment