Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Load testing nalanda #3149

Merged
merged 4 commits into from
Feb 28, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 18 additions & 69 deletions kalite/distributed/templates/distributed/loadtesting/load_test.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="shortcut icon" href="{% static "images/favicon.ico" %}">
<script type="text/javascript" src="{% static "js/jquery-1.9.1.min.js" %}"></script>
<script type="text/javascript" src="{% static "js/underscore-min.js" %}"></script>
<script type="text/javascript" src="{% static "js/backbone-min.js" %}"></script>
<script type="text/javascript" src="{% static 'js/jquery-1.9.1.min.js' %}"></script>
<script type="text/javascript" src="{% static 'js/underscore-min.js' %}"></script>
<script type="text/javascript" src="{% static 'js/backbone.js' %}"></script>

<link rel="stylesheet" type="text/css" href="{% static "css/distributed/khan-site.css" %}">
<style>
Expand Down Expand Up @@ -127,7 +127,7 @@
submitForm: function(callback) {
this.startTimer();
this.whenLoaded(callback);
this.$("article form").submit();
this.$("form").submit();
},

startTimer: function() {
Expand Down Expand Up @@ -248,22 +248,7 @@

var video_sequence = [
function(input, callback) {
this.goto("/", callback);
},
function(input, callback) {
this.click(".topic-link", callback);
},
function(input, callback) {
this.click(".topic-link", callback);
},
function(input, callback) {
this.click(".topic-link", callback);
},
function(input, callback) {
this.click(".topic-link", callback);
},
function(input, callback) {
this.click(".video-link", callback);
this.goto("/math/arithmetic/addition-subtraction/basic_addition/v/basic-addition/", callback);
},
function(input, callback) {
try {
Expand All @@ -278,55 +263,19 @@

var exercise_sequence = [
function(input, callback) {
this.goto("/math/arithmetic/fractions/understanding_fractions/e/recognizing_fractions_0.5/", callback);
this.goto("/math/arithmetic/addition-subtraction/basic_addition/e/addition_1/", callback);
},
function(input, callback) {
this.$("#solutionarea input").val(100).keypress()
this.click("#check-answer-button");
callback()
},
function(input, callback) {
this.$("#solutionarea input").val(100).keypress()
this.click("#check-answer-button");
callback()
},
function(input, callback) {
this.$("#solutionarea input").val(100).keypress()
this.click("#check-answer-button");
callback()
},
function(input, callback) {
this.$("#solutionarea input").val(100).keypress()
this.click("#check-answer-button");
callback()
},
function(input, callback) {
this.$("#solutionarea input").val(100).keypress()
this.click("#check-answer-button");
callback()
},
function(input, callback) {
this.$("#solutionarea input").val(100).keypress()
this.click("#check-answer-button");
callback()
},
function(input, callback) {
this.$("#solutionarea input").val(100).keypress()
this.click("#check-answer-button");
callback()
},
function(input, callback) {
this.$("#solutionarea input").val(100).keypress()
this.click("#check-answer-button");
callback()
},
function(input, callback) {
this.$("#solutionarea input").val(100).keypress()
this.click("#check-answer-button");
callback()
},
function(input, callback) {
this.$("#solutionarea input").val(100).keypress()
var numbers = this.$("span[class=mord][style]")
var answer = 0
if (Math.random() > 0.5) {
for (var i=0; i < numbers.length; i++){
if (!isNaN(Number(numbers[i].textContent))) {
answer += Number(numbers[i].textContent)
}
}
}
this.$("#solutionarea input").val(answer).keypress()
this.click("#check-answer-button");
callback()
}
Expand All @@ -341,8 +290,8 @@

this.$("#id_facility option")[1].selected = true;
this.fillForm({
username: "s" + sidx,
password: "s" + sidx,
username: "sssss" + sidx,
password: "sssss" + sidx,
});
this.submitForm(callback);
}
Expand Down
2 changes: 1 addition & 1 deletion kalite/distributed/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
)

# Testing
if "tests.loadtesting" in settings.INSTALLED_APPS:
if "kalite.testing.loadtesting" in settings.INSTALLED_APPS:
urlpatterns += patterns(__package__ + '.views',
url(r'^loadtesting/', include('kalite.testing.loadtesting.urls')),
)
Expand Down
19 changes: 16 additions & 3 deletions kalite/testing/loadtesting/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,21 @@

n_users_created = 0 # keep a global, to let us know if we've initialized, or need to re-initialize.

@render_to("loadtesting/load_test.html")
@render_to("distributed/loadtesting/load_test.html")
def load_test(request, nusers=None):
"""
The principal purpose of this view is to allow the automated testing of multiple clients
connected to the server at once, interacting in a way that is at least somewhat representative
of normal user behaviour.

As such, navigating to the loadtesting page on a client device will load an iframe which will
then use Javascript to automate user interaction with the site. It will try to watch videos and
do exercises in rapid succession in order to put strain on the server and associated network
connections.

So far the principal use for this has been testing with 30+ tablets connected over WiFi to a
server and seeing if the server and wireless connection can handle the strain.
"""
global n_users_created

if not n_users_created or n_users_created < int(request.GET.get("nusers", 1)): # default 1, as before
Expand All @@ -20,13 +33,13 @@ def load_test(request, nusers=None):
# Loop over all needed students
while n_users_created < int(request.GET.get("nusers", 1)):
n_users_created += 1
unpw = "s%d" % n_users_created
unpw = "sssss%d" % n_users_created
(user, _) = FacilityUser.get_or_initialize(username=unpw, facility=fac)
user.set_password(unpw)
user.save()

return {
"pct_videos": request.GET.get("pct_videos", 0.9),
"pct_videos": request.GET.get("pct_videos", 0.5),
"pct_logout": request.GET.get("pct_logout", 0.0),
"nusers": n_users_created,
}