summaryrefslogtreecommitdiff
path: root/yaksh/live_server_tests/load_test.py
diff options
context:
space:
mode:
authorPrabhu Ramachandran2016-09-21 17:58:12 +0530
committerGitHub2016-09-21 17:58:12 +0530
commit8e4ead8ab4caa9366e5357840e1912cbfb8cdb85 (patch)
treea8a9b90e0df9ce0893e7741bc33309af86ea034d /yaksh/live_server_tests/load_test.py
parent4f384f81cbde58f5eaa616dce85f1e4d60ea2c66 (diff)
parent48f5117a0a0f7f712d3bafabf06e1c63de56e9fa (diff)
downloadonline_test-8e4ead8ab4caa9366e5357840e1912cbfb8cdb85.tar.gz
online_test-8e4ead8ab4caa9366e5357840e1912cbfb8cdb85.tar.bz2
online_test-8e4ead8ab4caa9366e5357840e1912cbfb8cdb85.zip
Merge pull request #134 from ankitjavalkar/selenium-test-with-qdemo
Selenium test with qdemo
Diffstat (limited to 'yaksh/live_server_tests/load_test.py')
-rw-r--r--yaksh/live_server_tests/load_test.py77
1 files changed, 77 insertions, 0 deletions
diff --git a/yaksh/live_server_tests/load_test.py b/yaksh/live_server_tests/load_test.py
new file mode 100644
index 0000000..17934d4
--- /dev/null
+++ b/yaksh/live_server_tests/load_test.py
@@ -0,0 +1,77 @@
+import os
+import signal
+import subprocess
+from datetime import datetime
+import pytz
+from threading import Thread
+from selenium.webdriver.firefox.webdriver import WebDriver
+
+from django.contrib.staticfiles.testing import StaticLiveServerTestCase
+
+from yaksh.models import User, Profile, Question, Quiz, Course, QuestionPaper, TestCase
+from selenium_test import SeleniumTest
+
+from yaksh.code_server import ServerPool
+from yaksh import settings
+
+
+class YakshSeleniumTests(StaticLiveServerTestCase):
+ @classmethod
+ def setUpClass(cls):
+ super(YakshSeleniumTests, cls).setUpClass()
+ # setup a demo code server
+ settings.code_evaluators['python']['standardtestcase'] = \
+ "yaksh.python_assertion_evaluator.PythonAssertionEvaluator"
+ settings.code_evaluators['c']['standardtestcase'] = \
+ "yaksh.cpp_code_evaluator.CppCodeEvaluator"
+ settings.code_evaluators['bash']['standardtestcase'] = \
+ "yaksh.bash_code_evaluator.BashCodeEvaluator"
+ settings.SERVER_POOL_PORT = 53578
+ code_server_pool = ServerPool(ports=settings.SERVER_PORTS, pool_port=settings.SERVER_POOL_PORT)
+ cls.code_server_pool = code_server_pool
+ cls.code_server_thread = t = Thread(target=code_server_pool.run)
+ t.start()
+
+ demo_student = User.objects.create_user(username='demo_student',
+ password='demo_student',
+ email='demo_student@test.com'
+ )
+ demo_student_profile = Profile.objects.create(user=demo_student,
+ roll_number=3, institute='IIT',
+ department='Chemical', position='Student'
+ )
+
+ demo_mod = User.objects.create_user(username='demo_mod',
+ password='demo_mod',
+ email='demo_mod@test.com'
+ )
+ demo_mod_profile = Profile.objects.create(user=demo_mod,
+ roll_number=0, institute='IIT',
+ department='Chemical', position='Moderator'
+ )
+
+ course_obj = Course()
+ course_obj.create_demo(demo_mod)
+ demo_course = Course.objects.get(id=1)
+
+ demo_course.students.add(demo_student)
+
+ @classmethod
+ def tearDownClass(cls):
+ User.objects.all().delete()
+ Question.objects.all().delete()
+ Quiz.objects.all().delete()
+ Course.objects.all().delete()
+
+ settings.SERVER_POOL_PORT = 53579
+
+ cls.code_server_pool.stop()
+ cls.code_server_thread.join()
+
+ super(YakshSeleniumTests, cls).tearDownClass()
+
+ def test_load(self):
+ url = '%s%s' % (self.live_server_url, '/exam/login/')
+ quiz_name = "Yaksh Demo quiz"
+ selenium_test = SeleniumTest(url=url, quiz_name=quiz_name)
+ selenium_test.run_load_test(url=url, username='demo_student', password='demo_student')