Skip to content

Instantly share code, notes, and snippets.

@adreyer
Created December 9, 2011 15:15
Show Gist options
  • Select an option

  • Save adreyer/1451913 to your computer and use it in GitHub Desktop.

Select an option

Save adreyer/1451913 to your computer and use it in GitHub Desktop.
proxy load tester
""" __init__ """
-set /etc/hosts so that www.test.wsbtv.com points to the OTIS vip-
-cd here
-run "runload.sh 100
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()
from mockmedley.mockmedley import app as application
#!/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()
#!/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