From 486e25bd79e5ee269dfea1a9fa205843fdb9b330 Mon Sep 17 00:00:00 2001 From: Feanil Patel Date: Fri, 6 Sep 2019 15:06:22 -0400 Subject: [PATCH 1/3] Set a default value for PROCTORING_SETTINGS The proctoring app assumes that this setting exists and so we get an attribute error at runtime if it doesn't. In python 2 this was not an issue but because of the change in how exceptions are handle for getting attributes, it's a problem in python 3. The correct thing to do would be to fix this in the proctoring app so that it checks for the existence of its value before using it but that's a longer cycle to make/deploy that change so doing this as a stopgap to get past it. --- lms/envs/test.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lms/envs/test.py b/lms/envs/test.py index 8e14cf87e5..2557ebeb10 100644 --- a/lms/envs/test.py +++ b/lms/envs/test.py @@ -594,3 +594,5 @@ ACCOUNT_MICROFRONTEND_URL = "http://account-mfe/" ########################## limiting dashboard courses ###################### DASHBOARD_COURSE_LIMIT = 250 + +PROCTORING_SETTINGS = {} From f2445cfe36941160d135dcc06f422e8fe3a2dd03 Mon Sep 17 00:00:00 2001 From: Feanil Patel Date: Fri, 6 Sep 2019 15:25:25 -0400 Subject: [PATCH 2/3] Turn off hash randomization on the xdist workers as well. --- cms/envs/test.py | 2 ++ openedx/tests/settings.py | 2 ++ pavelib/utils/test/suites/pytest_suite.py | 2 +- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/cms/envs/test.py b/cms/envs/test.py index 89c93460f7..bc43fb0510 100644 --- a/cms/envs/test.py +++ b/cms/envs/test.py @@ -308,3 +308,5 @@ derive_settings(__name__) SYSTEM_WIDE_ROLE_CLASSES = os.environ.get("SYSTEM_WIDE_ROLE_CLASSES", []) DEFAULT_MOBILE_AVAILABLE = True + +PROCTORING_SETTINGS = {} diff --git a/openedx/tests/settings.py b/openedx/tests/settings.py index 97eb1ec558..434ee0da83 100644 --- a/openedx/tests/settings.py +++ b/openedx/tests/settings.py @@ -115,3 +115,5 @@ USE_TZ = True RETIREMENT_SERVICE_WORKER_USERNAME = 'RETIREMENT_SERVICE_USER' RETIRED_USERNAME_PREFIX = 'retired__user_' + +PROCTORING_SETTINGS = {} diff --git a/pavelib/utils/test/suites/pytest_suite.py b/pavelib/utils/test/suites/pytest_suite.py index 66c1f4b841..02f5fd2882 100644 --- a/pavelib/utils/test/suites/pytest_suite.py +++ b/pavelib/utils/test/suites/pytest_suite.py @@ -180,7 +180,7 @@ class SystemTestSuite(PytestSuite): xdist_remote_processes = self.processes for ip in self.xdist_ip_addresses.split(','): # Propogate necessary env vars to xdist containers - env_var_cmd = u'export DJANGO_SETTINGS_MODULE={} DISABLE_COURSEENROLLMENT_HISTORY={}'\ + env_var_cmd = u'export DJANGO_SETTINGS_MODULE={} DISABLE_COURSEENROLLMENT_HISTORY={} PYTHONHASHSEED=0'\ .format('{}.envs.{}'.format(self.root, self.settings), self.disable_courseenrollment_history) xdist_string = u'--tx {}*ssh="jenkins@{} -o StrictHostKeyChecking=no"' \ From d01df30aacd095e518f782c372037e4303bb271c Mon Sep 17 00:00:00 2001 From: Feanil Patel Date: Mon, 9 Sep 2019 10:52:57 -0400 Subject: [PATCH 3/3] Remove pytest command tests. These tests essentially duplicate the logic for how the pytest commands are generated and then compare the duplicated logic to the original logic. This is pretty brittle and since we're running all the variants here pretty regularly I think we have other ways of knowing if we caused the command to break. I don't think these tests are providing sufficient value to merit their added complexity. --- pavelib/paver_tests/test_paver_pytest_cmds.py | 163 ------------------ 1 file changed, 163 deletions(-) delete mode 100644 pavelib/paver_tests/test_paver_pytest_cmds.py diff --git a/pavelib/paver_tests/test_paver_pytest_cmds.py b/pavelib/paver_tests/test_paver_pytest_cmds.py deleted file mode 100644 index d07ca32164..0000000000 --- a/pavelib/paver_tests/test_paver_pytest_cmds.py +++ /dev/null @@ -1,163 +0,0 @@ -# pylint: disable=unicode-format-string -""" -Tests for the pytest paver commands themselves. -Run just this test with: paver test_lib -t pavelib/paver_tests/test_paver_pytest_cmds.py -""" -from __future__ import absolute_import - -import os -import unittest - -import ddt - -from pavelib.utils.envs import Env -from pavelib.utils.test.suites import LibTestSuite, SystemTestSuite - -XDIST_TESTING_IP_ADDRESS_LIST = '0.0.0.1,0.0.0.2,0.0.0.3' - - -@ddt.ddt -class TestPaverPytestCmd(unittest.TestCase): - """ - Test Paver pytest commands - """ - - def _expected_command(self, root, test_id, pytestSubclass, run_under_coverage=True, - processes=0, xdist_ip_addresses=None): - """ - Returns the command that is expected to be run for the given test spec - and store. - """ - report_dir = Env.REPORT_DIR / root - shard = os.environ.get('SHARD') - if shard: - report_dir = report_dir / 'shard_' + shard - - expected_statement = [ - "python", - "-Wd", - "-m", - "pytest" - ] - if pytestSubclass == "SystemTestSuite": - expected_statement.append("--ds={}".format('{}.envs.{}'.format(root, Env.TEST_SETTINGS))) - expected_statement.append("--junitxml={}".format(report_dir / "nosetests.xml")) - - if xdist_ip_addresses: - expected_statement.append('--dist=loadscope') - for ip in xdist_ip_addresses.split(','): - if processes <= 0: - processes = 1 - - if pytestSubclass == "SystemTestSuite": - django_env_var_cmd = u"export DJANGO_SETTINGS_MODULE={}.envs.test".format(root) - elif pytestSubclass == "LibTestSuite": - if 'pavelib/paver_tests' in test_id: - django_env_var_cmd = u"export DJANGO_SETTINGS_MODULE={}.envs.test".format(root) - else: - django_env_var_cmd = "export DJANGO_SETTINGS_MODULE='openedx.tests.settings'" - - env_var_cmd = "{} DISABLE_COURSEENROLLMENT_HISTORY=1".format(django_env_var_cmd) - - xdist_string = u'--tx {}*ssh="jenkins@{} -o StrictHostKeyChecking=no"' \ - '//python="source edx-venv/bin/activate; {}; python"' \ - '//chdir="edx-platform"' \ - .format(processes, ip, env_var_cmd) - expected_statement.append(xdist_string) - for rsync_dir in Env.rsync_dirs(): - expected_statement.append(u'--rsyncdir {}'.format(rsync_dir)) - else: - if processes == -1: - expected_statement.append('-n auto') - expected_statement.append('--dist=loadscope') - elif processes != 0: - expected_statement.append(u'-n {}'.format(processes)) - expected_statement.append('--dist=loadscope') - - expected_statement.extend([ - "-p no:randomly", - test_id - ]) - - if run_under_coverage: - expected_statement.append('--cov') - expected_statement.append('--cov-report=') - return expected_statement - - @ddt.data('lms', 'cms') - def test_SystemTestSuite_suites(self, system): - test_id = 'tests' - suite = SystemTestSuite(system, test_id=test_id) - assert suite.cmd == self._expected_command(system, test_id, "SystemTestSuite") - - @ddt.data('lms', 'cms') - def test_SystemTestSuite_auto_processes(self, system): - test_id = 'tests' - suite = SystemTestSuite(system, test_id=test_id, processes=-1) - assert suite.cmd == self._expected_command(system, test_id, "SystemTestSuite", processes=-1) - - @ddt.data('lms', 'cms') - def test_SystemTestSuite_multi_processes(self, system): - test_id = 'tests' - suite = SystemTestSuite(system, test_id=test_id, processes=3) - assert suite.cmd == self._expected_command(system, test_id, "SystemTestSuite", processes=3) - - @ddt.data('lms', 'cms') - def test_SystemTestSuite_with_xdist(self, system): - test_id = 'tests' - suite = SystemTestSuite(system, test_id=test_id, xdist_ip_addresses=XDIST_TESTING_IP_ADDRESS_LIST) - assert suite.cmd == self._expected_command(system, test_id, "SystemTestSuite", - xdist_ip_addresses=XDIST_TESTING_IP_ADDRESS_LIST) - - @ddt.data('lms', 'cms') - def test_SystemTestSuite_with_xdist_multi_processes(self, system): - test_id = 'tests' - suite = SystemTestSuite(system, test_id=test_id, processes=2, xdist_ip_addresses=XDIST_TESTING_IP_ADDRESS_LIST) - assert suite.cmd == self._expected_command(system, test_id, "SystemTestSuite", processes=2, - xdist_ip_addresses=XDIST_TESTING_IP_ADDRESS_LIST) - - @ddt.data('lms', 'cms') - def test_SystemTestSuite_with_xdist_negative_processes(self, system): - test_id = 'tests' - suite = SystemTestSuite(system, test_id=test_id, processes=-1, xdist_ip_addresses=XDIST_TESTING_IP_ADDRESS_LIST) - assert suite.cmd == self._expected_command(system, test_id, "SystemTestSuite", processes=-1, - xdist_ip_addresses=XDIST_TESTING_IP_ADDRESS_LIST) - - @ddt.data('common/lib/xmodule', 'pavelib/paver_tests') - def test_LibTestSuite_suites(self, system): - test_id = 'tests' - suite = LibTestSuite(system, test_id=test_id) - assert suite.cmd == self._expected_command(system, test_id, "LibTestSuite") - - @ddt.data('common/lib/xmodule', 'pavelib/paver_tests') - def test_LibTestSuite_auto_processes(self, system): - test_id = 'tests' - suite = LibTestSuite(system, test_id=test_id, processes=-1) - assert suite.cmd == self._expected_command(system, test_id, "LibTestSuite", processes=-1) - - @ddt.data('common/lib/xmodule', 'pavelib/paver_tests') - def test_LibTestSuite_multi_processes(self, system): - test_id = 'tests' - suite = LibTestSuite(system, test_id=test_id, processes=3) - assert suite.cmd == self._expected_command(system, test_id, "LibTestSuite", processes=3) - - @ddt.data('common/lib/xmodule', 'pavelib/paver_tests') - def test_LibTestSuite_with_xdist(self, system): - test_id = 'tests' - suite = LibTestSuite(system, test_id=test_id, xdist_ip_addresses=XDIST_TESTING_IP_ADDRESS_LIST) - assert suite.cmd == self._expected_command(system, test_id, "LibTestSuite", - xdist_ip_addresses=XDIST_TESTING_IP_ADDRESS_LIST) - - @ddt.data('common/lib/xmodule', 'pavelib/paver_tests') - def test_LibTestSuite_with_xdist_multi_processes(self, system): - test_id = 'tests' - suite = LibTestSuite(system, test_id=test_id, processes=2, xdist_ip_addresses=XDIST_TESTING_IP_ADDRESS_LIST) - assert suite.cmd == self._expected_command(system, test_id, "LibTestSuite", processes=2, - xdist_ip_addresses=XDIST_TESTING_IP_ADDRESS_LIST) - - @ddt.data('common/lib/xmodule', 'pavelib/paver_tests') - def test_LibTestSuite_with_xdist_negative_processes(self, system): - test_id = 'tests' - suite = LibTestSuite(system, test_id=test_id, processes=-1, xdist_ip_addresses=XDIST_TESTING_IP_ADDRESS_LIST) - assert suite.cmd == self._expected_command(system, test_id, "LibTestSuite", processes=-1, - xdist_ip_addresses=XDIST_TESTING_IP_ADDRESS_LIST)