Commit 784a81de by Ben Patterson Committed by Eric Fischer

ORA acceptance test cleanup

Made a few small optimizations to acceptance tests, added ability to profile
tests with an environment var, and updated .gitignore to ignore files
generated when running acceptance tests locally.
parent 2adb90b4
...@@ -38,6 +38,7 @@ test_ora2db-journal ...@@ -38,6 +38,7 @@ test_ora2db-journal
test/custom_a11y_rules.js test/custom_a11y_rules.js
test/acceptance/screenshots/*.png test/acceptance/screenshots/*.png
test/logs/* test/logs/*
test/acceptance/xunit-*
# Mr Developer # Mr Developer
.mr.developer.cfg .mr.developer.cfg
......
bok-choy==0.4.10 bok-choy==0.4.10
ddt==1.0.0 ddt==1.0.0
nose==1.3.7 nose==1.3.7
pyinstrument==0.13.1
...@@ -29,6 +29,7 @@ if [ -z "$TEST_HOST" ]; then ...@@ -29,6 +29,7 @@ if [ -z "$TEST_HOST" ]; then
exit 1; exit 1;
fi fi
# export ORA_PROFILING_ENABLED=True # uncomment this line to get profiling on jenkins runs
export ORA_SANDBOX_URL="https://${BASIC_AUTH_USER}:${BASIC_AUTH_PASSWORD}@${TEST_HOST}" export ORA_SANDBOX_URL="https://${BASIC_AUTH_USER}:${BASIC_AUTH_PASSWORD}@${TEST_HOST}"
EXIT=0 EXIT=0
......
...@@ -135,7 +135,7 @@ class StaffAreaA11yTest(OpenAssessmentA11yTest): ...@@ -135,7 +135,7 @@ class StaffAreaA11yTest(OpenAssessmentA11yTest):
Check the accessibility of the learner information sections of the "Staff Tools" panel. Check the accessibility of the learner information sections of the "Staff Tools" panel.
""" """
self.auto_auth_page.visit() self.auto_auth_page.visit()
username = self.auto_auth_page.get_username() username, _ = self.auto_auth_page.get_username_and_email()
self.submission_page.visit().submit_response(self.SUBMISSION) self.submission_page.visit().submit_response(self.SUBMISSION)
self.assertTrue(self.submission_page.has_submitted) self.assertTrue(self.submission_page.has_submitted)
......
...@@ -80,27 +80,12 @@ class AutoAuthPage(PageObject): ...@@ -80,27 +80,12 @@ class AutoAuthPage(PageObject):
match = re.search(r' user_id ([^$]+)$', message) match = re.search(r' user_id ([^$]+)$', message)
return match.groups()[0] if match else None return match.groups()[0] if match else None
def get_username(self): def get_username_and_email(self):
"""
Finds and returns the username of the current user.
"""
username, _ = self._get_username_and_email()
return username
def get_email(self):
"""
Finds and returns the email address of the current user.
"""
_, email = self._get_username_and_email()
return email
def _get_username_and_email(self):
""" """
Finds and returns the username and email address of the current user. Finds and returns the username and email address of the current user.
""" """
message = self.q(css='BODY').text[0].strip() message = self.q(css='BODY').text[0].strip()
match = re.search(r'Logged in user ([^$]+) with password ([^$]+) and user_id ([^$]+)$', message) match = re.search(r'Logged in user (\S+) \(.*\) with password (\S+)', message)
if not match: if not match:
return None return None
username_and_email = match.groups()[0].split(' ') return match.group(1), match.group(2)
return username_and_email[0], username_and_email[1]
...@@ -6,6 +6,7 @@ import os ...@@ -6,6 +6,7 @@ import os
import unittest import unittest
import time import time
from functools import wraps from functools import wraps
from pyinstrument import Profiler
from nose.plugins.attrib import attr from nose.plugins.attrib import attr
from bok_choy.web_app_test import WebAppTest from bok_choy.web_app_test import WebAppTest
...@@ -15,8 +16,10 @@ from pages import ( ...@@ -15,8 +16,10 @@ from pages import (
SubmissionPage, AssessmentPage, GradePage, StaffAreaPage SubmissionPage, AssessmentPage, GradePage, StaffAreaPage
) )
# This value is generally used in jenkins, but not locally
PROFILING_ENABLED = os.environ.get('ORA_PROFILING_ENABLED', False)
def retry(tries=4, delay=3, backoff=2): def retry(tries=2, delay=4, backoff=2):
""" """
Retry decorator with exponential backoff. Retry decorator with exponential backoff.
...@@ -103,6 +106,10 @@ class OpenAssessmentTest(WebAppTest): ...@@ -103,6 +106,10 @@ class OpenAssessmentTest(WebAppTest):
""" """
super(OpenAssessmentTest, self).setUp() super(OpenAssessmentTest, self).setUp()
if PROFILING_ENABLED:
self.profiler = Profiler(use_signal=False)
self.profiler.start()
self.problem_loc = self.PROBLEM_LOCATIONS[problem_type] self.problem_loc = self.PROBLEM_LOCATIONS[problem_type]
self.auto_auth_page = AutoAuthPage(self.browser, course_id=self.TEST_COURSE_ID, staff=staff) self.auto_auth_page = AutoAuthPage(self.browser, course_id=self.TEST_COURSE_ID, staff=staff)
self.submission_page = SubmissionPage(self.browser, self.problem_loc) self.submission_page = SubmissionPage(self.browser, self.problem_loc)
...@@ -112,6 +119,15 @@ class OpenAssessmentTest(WebAppTest): ...@@ -112,6 +119,15 @@ class OpenAssessmentTest(WebAppTest):
self.staff_asmnt_page = AssessmentPage('staff-assessment', self.browser, self.problem_loc) self.staff_asmnt_page = AssessmentPage('staff-assessment', self.browser, self.problem_loc)
self.grade_page = GradePage(self.browser, self.problem_loc) self.grade_page = GradePage(self.browser, self.problem_loc)
def log_to_file(self):
with open('{}-profile.log'.format(self.id()), 'w') as f:
f.write(self.profiler.output_text())
def tearDown(self):
if PROFILING_ENABLED:
self.profiler.stop()
self.log_to_file()
def login_user(self, learner, email): def login_user(self, learner, email):
""" """
Logs in an already existing user. Logs in an already existing user.
...@@ -132,7 +148,7 @@ class OpenAssessmentTest(WebAppTest): ...@@ -132,7 +148,7 @@ class OpenAssessmentTest(WebAppTest):
learner for which the self assessment was submitted. learner for which the self assessment was submitted.
""" """
self.auto_auth_page.visit() self.auto_auth_page.visit()
username = self.auto_auth_page.get_username() username, _ = self.auto_auth_page.get_username_and_email()
self.submission_page.visit().submit_response(self.SUBMISSION) self.submission_page.visit().submit_response(self.SUBMISSION)
self.assertTrue(self.submission_page.has_submitted) self.assertTrue(self.submission_page.has_submitted)
...@@ -303,7 +319,7 @@ class StaffAssessmentTest(OpenAssessmentTest): ...@@ -303,7 +319,7 @@ class StaffAssessmentTest(OpenAssessmentTest):
def test_staff_assessment(self): def test_staff_assessment(self):
# Set up user and navigate to submission page # Set up user and navigate to submission page
self.auto_auth_page.visit() self.auto_auth_page.visit()
username = self.auto_auth_page.get_username() username, _ = self.auto_auth_page.get_username_and_email()
self.submission_page.visit() self.submission_page.visit()
# Verify that staff grade step is shown initially # Verify that staff grade step is shown initially
...@@ -390,7 +406,7 @@ class PeerAssessmentTestStaffOverride(OpenAssessmentTest): ...@@ -390,7 +406,7 @@ class PeerAssessmentTestStaffOverride(OpenAssessmentTest):
# Create a submission for the third student (used for the remainder of the test). # Create a submission for the third student (used for the remainder of the test).
self.auto_auth_page.visit() self.auto_auth_page.visit()
username = self.auto_auth_page.get_username() username, _ = self.auto_auth_page.get_username_and_email()
self.submission_page.visit().submit_response(self.SUBMISSION) self.submission_page.visit().submit_response(self.SUBMISSION)
# Staff Grade field should not be visible yet. # Staff Grade field should not be visible yet.
self.assertFalse(self.staff_asmnt_page.is_browser_on_page()) self.assertFalse(self.staff_asmnt_page.is_browser_on_page())
...@@ -472,12 +488,7 @@ class StaffAreaTest(OpenAssessmentTest): ...@@ -472,12 +488,7 @@ class StaffAreaTest(OpenAssessmentTest):
@retry() @retry()
@attr('acceptance') @attr('acceptance')
@ddt.data( def test_staff_area_panel(self):
("staff-tools", "MANAGE INDIVIDUAL LEARNERS"),
("staff-info", "VIEW ASSIGNMENT STATISTICS"),
)
@ddt.unpack
def test_staff_area_panel(self, panel_name, button_label):
""" """
Scenario: the staff area panels should be shown correctly Scenario: the staff area panels should be shown correctly
...@@ -495,6 +506,10 @@ class StaffAreaTest(OpenAssessmentTest): ...@@ -495,6 +506,10 @@ class StaffAreaTest(OpenAssessmentTest):
self.assertEqual(self.staff_area_page.selected_button_names, []) self.assertEqual(self.staff_area_page.selected_button_names, [])
self.assertEqual(self.staff_area_page.visible_staff_panels, []) self.assertEqual(self.staff_area_page.visible_staff_panels, [])
for panel_name, button_label in [
("staff-tools", "MANAGE INDIVIDUAL LEARNERS"),
("staff-info", "VIEW ASSIGNMENT STATISTICS"),
]:
# Click on the button and verify that the panel has opened # Click on the button and verify that the panel has opened
self.staff_area_page.click_staff_toolbar_button(panel_name) self.staff_area_page.click_staff_toolbar_button(panel_name)
self.assertEqual(self.staff_area_page.selected_button_names, [button_label]) self.assertEqual(self.staff_area_page.selected_button_names, [button_label])
...@@ -665,7 +680,7 @@ class StaffAreaTest(OpenAssessmentTest): ...@@ -665,7 +680,7 @@ class StaffAreaTest(OpenAssessmentTest):
""" """
# View the problem-- no Staff Grade area. # View the problem-- no Staff Grade area.
self.auto_auth_page.visit() self.auto_auth_page.visit()
username = self.auto_auth_page.get_username() username, _ = self.auto_auth_page.get_username_and_email()
self.submission_page.visit() self.submission_page.visit()
self.assertFalse(self.staff_asmnt_page.is_browser_on_page()) self.assertFalse(self.staff_asmnt_page.is_browser_on_page())
...@@ -778,11 +793,10 @@ class FullWorkflowMixin(object): ...@@ -778,11 +793,10 @@ class FullWorkflowMixin(object):
self.browser, password=self.TEST_PASSWORD, course_id=self.TEST_COURSE_ID, staff=True self.browser, password=self.TEST_PASSWORD, course_id=self.TEST_COURSE_ID, staff=True
) )
auto_auth_page.visit() auto_auth_page.visit()
username = auto_auth_page.get_username() username_email = auto_auth_page.get_username_and_email()
email = auto_auth_page.get_email()
self.submission_page.visit().submit_response(self.SUBMISSION) self.submission_page.visit().submit_response(self.SUBMISSION)
return username, email return username_email
def do_submission_training_self_assessment(self): def do_submission_training_self_assessment(self):
""" """
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment