Skip to content

Commit

Permalink
Shift more expensive unit tests to tests/unit (#14531)
Browse files Browse the repository at this point in the history
The odds of these features regressing in a PR are minimal and
so we should move them to our unit tests that are run with
incremental builds.

This also fixes an issue where pam_fail_delay() could actually
result in delays as small as 1.20 seconds, and so we need to
not be quite so restrictive in testing.
  • Loading branch information
anodos325 authored Sep 17, 2024
1 parent 961b26d commit 8e3f197
Show file tree
Hide file tree
Showing 9 changed files with 7 additions and 3 deletions.
6 changes: 5 additions & 1 deletion tests/run_unit_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,17 @@
)

UNIT_TESTS = 'tests/unit'
MIDDLEWARE_MODULE_PATH = os.path.dirname(os.path.abspath(middlewared.__file__))
MIDDLEWARE_MODULE_PATH = '/usr/lib/python3/dist-packages/middlewared'
MIDDLEWARE_PYTEST = 'src/middlewared/middlewared/pytest'
MIDDLEWARE_UNIT_TESTS = os.path.join(MIDDLEWARE_PYTEST, 'unit')
MIDDLEWARE_PYTEST_MODULE = os.path.join(MIDDLEWARE_MODULE_PATH, 'pytest')
RESULT_FILE = 'unit_tests_result.xml'
PYTEST_CONFTEST_FILE = 'tests/conftest.py'

if not os.path.exists(MIDDLEWARE_MODULE_PATH):
# If middlware has been reinstalled then we should try to find where it's located
MIDDLEWARE_MODULE_PATH = os.path.dirname(os.path.abspath(middlewared.__file__))


@dataclass()
class UnitTestRun:
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion tests/unit/test_pam_tdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
PAM_DIR = '/etc/pam.d'
PAM_FILE = 'middleware-api-key'
PAM_AUTH_LINE = 'auth [success=1 default=die] pam_tdb.so debug '
PAM_FAIL_DELAY = 1.50 # pam_fail_delay is 2s, but we need a little wiggle-room
PAM_FAIL_DELAY = 1 # pam_fail_delay is 2s, but we need a little wiggle-room

PAM_FILE_REMAINING_CONTENTS = """
@include common-auth-unix
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from base64 import b64encode
from contextlib import closing
from middlewared.plugins.sysdataset import SYSDATASET_PATH
from middlewared.plugins.system_dataset.utils import SYSDATASET_PATH
from middlewared.utils.tdb import (
close_sysdataset_tdb_handles,
get_tdb_handle,
Expand Down

0 comments on commit 8e3f197

Please sign in to comment.