From 13967c46dec286814978f2c53fc4c6eeafbbadb9 Mon Sep 17 00:00:00 2001 From: sudheesh001 Date: Tue, 12 Aug 2014 13:32:56 +0530 Subject: [PATCH] Starts load test for login, fixes Issue #39 partially, needs fixes --- test/LoadTest.py | 28 ++++++++++++++++++++++++++++ test/config.py | 22 ++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 test/config.py diff --git a/test/LoadTest.py b/test/LoadTest.py index e69de29..6af1cdd 100644 --- a/test/LoadTest.py +++ b/test/LoadTest.py @@ -0,0 +1,28 @@ +import os,binascii +from flask import Flask, request, session, g, redirect, url_for, abort, \ + render_template, flash +from flaskext.mysql import MySQL +from config import config, ADMINS, MAIL_SERVER, MAIL_PORT, MAIL_USERNAME, MAIL_PASSWORD + +app = Flask(__name__) + +for key in config: + app.config[key] = config[key] + +mysql = MySQL() + +def get_cursor(): + return mysql.connect().cursor() + +def logintest(): + db = get_cursor() + for i in range(1,100): + EmpID=i + UserName = ''.join([random.choice(string.ascii_letters + string.digits) for n in xrange(10)]) + Password = binascii.b2a_hex(os.urandom(15)) + Occupation = i%5 + sql = 'insert into Login values ("%s","%s",MD5("%s"),"%s")' + db.execute(sql%(EmpID,UserName,Password,Occupation)) + db.execute("Commit") + +logintest() \ No newline at end of file diff --git a/test/config.py b/test/config.py new file mode 100644 index 0000000..d757009 --- /dev/null +++ b/test/config.py @@ -0,0 +1,22 @@ +# Database Config + +config = { + 'MYSQL_DATABASE_USER' : '', #Username for mysql + 'MYSQL_DATABASE_DB' : 'Dispensary', + 'MYSQL_DATABASE_PASSWORD' : '', # Password to connect to mysql + 'MYSQL_DATABASE_HOST' : 'localhost', + 'USERNAME' : '', + 'USERID' :'', +} + +# To run the mail server run +# sudo python -m smtpd -n -c DebuggingServer localhost:25 +# mail server settings + +MAIL_SERVER = 'localhost' +MAIL_PORT = 25 +MAIL_USERNAME = None +MAIL_PASSWORD = None + +# Administrator list +ADMINS = ['you@example.com'] \ No newline at end of file