Created
December 9, 2011 15:15
-
-
Save adreyer/1451913 to your computer and use it in GitHub Desktop.
proxy load tester
This file contains hidden or 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
| """ __init__ """ |
This file contains hidden or 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
| -set /etc/hosts so that www.test.wsbtv.com points to the OTIS vip- | |
| -cd here | |
| -run "runload.sh 100 |
This file contains hidden or 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
| import time | |
| from flask import Flask | |
| app = Flask(__name__) | |
| DELAY = 5 | |
| fh = open('/tmp/page.html') | |
| page = fh.read() | |
| fh.close() | |
| @app.route('/') | |
| def response(): | |
| time.sleep(DELAY) | |
| return page | |
| if __name__ == '__main__': | |
| app.run() |
This file contains hidden or 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
| from mockmedley.mockmedley import app as application |
This file contains hidden or 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
| #!/usr/bin/python | |
| import random | |
| import time | |
| from urllib2 import urlopen | |
| PROXY_PROB = .1 | |
| BASE_URL = 'http://www.test.wsbtv.com/' | |
| def make_call(): | |
| try: | |
| rand = random.random() | |
| if rand < PROXY_PROB: | |
| url = BASE_URL + '?' + str(rand) | |
| foo = urlopen(url) | |
| else: | |
| t1 = time.time() | |
| foo = urlopen(BASE_URL) | |
| t2 = time.time() | |
| print str(t2 - t1) | |
| except: | |
| pass | |
| while True: | |
| make_call() |
This file contains hidden or 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
| #!/bin/bash | |
| # 2 args, first required concurrency (how many to run) second where to log to, default devnull | |
| DEFAULTLOG=/dev/null | |
| if [ $# -eq 0 ];then | |
| echo "usage" | |
| fi | |
| if [ $2 ];then | |
| DEFAULTLOG=$2 | |
| fi | |
| counter=1 | |
| if [ $2 ]; then | |
| while [ "$counter" -lt "$1" ]; do | |
| { python -u ./proxyload.py >> $DEFAULTLOG/proxyload-$counter.out & }; | |
| counter=`expr $counter + 1`; | |
| done | |
| else | |
| while [ "$counter" -lt "$1" ]; do | |
| { python -u ./proxyload.py >> /dev/null & }; | |
| counter=`expr $counter + 1`; | |
| done | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment