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

NFS tests in need of maintenance #2923 #2925

Merged

Conversation

phillxnet
Copy link
Member

NFS test coverage/quality improvements.

Fixes #2923

Includes

  • Fixture details & creation instructions via code comments.
  • Addition of test_nfs.json fixture from above instructions.
  • Code comment docs on how to invoke this test set.
  • Completes previous partial re-enablement of fixtures.
  • Addresses all outstanding TODOs.
  • Improves input validation coverage for both POST & PUT.

NFS test coverage/quality improvements.
## Includes
- Fixture details & creation instructions via code comments.
- Addition of test_nfs.json fixture from above instructions.
- Code comment docs on how to invoke this test set.
- Completes previous partial re-enablement of fixtures.
- Addresses all outstanding TODOs.
- Improves input validation coverage for both POST & PUT.
@phillxnet
Copy link
Member Author

Testing

A Leap 15.5 host running a recently build from testing branch 5.0.14-2919 rpm was used to indicate before and after results from the modified test file: test_nfs_export.py.

Before

Copied from associated issue #2923 for convenience of comparison:

cd /opt/rockstor/src/rockstor/
poetry run django-admin test -v 2 -p test_nfs_export.py
...
test_adv_nfs_get (rockstor.storageadmin.tests.test_nfs_export.NFSExportTests.test_adv_nfs_get)
Test GET request ... ok
test_adv_nfs_post_requests (rockstor.storageadmin.tests.test_nfs_export.NFSExportTests.test_adv_nfs_post_requests) ... ok
test_delete_requests (rockstor.storageadmin.tests.test_nfs_export.NFSExportTests.test_delete_requests)
. Delete nfs-export that does not exist ... ok
test_invalid_admin_host1 (rockstor.storageadmin.tests.test_nfs_export.NFSExportTests.test_invalid_admin_host1) ... ok
test_invalid_admin_host2 (rockstor.storageadmin.tests.test_nfs_export.NFSExportTests.test_invalid_admin_host2) ... ok
test_invalid_get (rockstor.storageadmin.tests.test_nfs_export.NFSExportTests.test_invalid_get) ... ok
test_post_requests (rockstor.storageadmin.tests.test_nfs_export.NFSExportTests.test_post_requests)
invalid nfs-export api operations ... ok
test_put_requests (rockstor.storageadmin.tests.test_nfs_export.NFSExportTests.test_put_requests)
. Edit nfs-export with no shares ... ok

----------------------------------------------------------------------
Ran 8 tests in 0.352s

OK

After

Same host instance as in above Before section but with the newly introduced fixture file in this branch test_nfs.json and the many updates to the test file test_nfs_export.py via an overwrite:

cd /opt/rockstor/src/rockstor/
poetry run django-admin test -v 2 -p test_nfs_export.py
...
test_adv_nfs_get (rockstor.storageadmin.tests.test_nfs_export.NFSExportTests.test_adv_nfs_get) ... ok
test_adv_nfs_post_requests (rockstor.storageadmin.tests.test_nfs_export.NFSExportTests.test_adv_nfs_post_requests) ... ok
test_delete_requests (rockstor.storageadmin.tests.test_nfs_export.NFSExportTests.test_delete_requests) ... ok
test_get (rockstor.storageadmin.tests.test_nfs_export.NFSExportTests.test_get) ... /opt/rockstor/.venv/lib/python3.11/site-packages/rest_framework/pagination.py:207: UnorderedObjectListWarning: Pagination may yield inconsistent results with an unordered object_list: <class 'storageadmin.models.nfs_export_group.NFSExportGroup'> QuerySet.
  paginator = self.django_paginator_class(queryset, page_size)
ok
test_host_str_validator_post (rockstor.storageadmin.tests.test_nfs_export.NFSExportTests.test_host_str_validator_post) ... FAIL
test_host_str_validator_put (rockstor.storageadmin.tests.test_nfs_export.NFSExportTests.test_host_str_validator_put) ... FAIL
test_invalid_get (rockstor.storageadmin.tests.test_nfs_export.NFSExportTests.test_invalid_get) ... ok
test_low_level_error_post (rockstor.storageadmin.tests.test_nfs_export.NFSExportTests.test_low_level_error_post) ... ok
test_low_level_error_put (rockstor.storageadmin.tests.test_nfs_export.NFSExportTests.test_low_level_error_put) ... ok
test_mod_choice_validator_post (rockstor.storageadmin.tests.test_nfs_export.NFSExportTests.test_mod_choice_validator_post) ... FAIL
test_mod_choice_validator_put (rockstor.storageadmin.tests.test_nfs_export.NFSExportTests.test_mod_choice_validator_put) ... FAIL
test_no_nfs_client (rockstor.storageadmin.tests.test_nfs_export.NFSExportTests.test_no_nfs_client) ... ok
test_post (rockstor.storageadmin.tests.test_nfs_export.NFSExportTests.test_post) ... ok
test_post_requests (rockstor.storageadmin.tests.test_nfs_export.NFSExportTests.test_post_requests) ... ok
test_put_requests (rockstor.storageadmin.tests.test_nfs_export.NFSExportTests.test_put_requests) ... ok
test_share_already_exported (rockstor.storageadmin.tests.test_nfs_export.NFSExportTests.test_share_already_exported) ... ok
test_sync_choice_validator_post (rockstor.storageadmin.tests.test_nfs_export.NFSExportTests.test_sync_choice_validator_post) ... FAIL
test_sync_choice_validator_put (rockstor.storageadmin.tests.test_nfs_export.NFSExportTests.test_sync_choice_validator_put) ... FAIL

======================================================================
FAIL: test_host_str_validator_post (rockstor.storageadmin.tests.test_nfs_export.NFSExportTests.test_host_str_validator_post)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/opt/rockstor/src/rockstor/storageadmin/tests/test_nfs_export.py", line 256, in test_host_str_validator_post
    self.assertEqual(
AssertionError: 200 != 500 : {'id': 4, 'exports': [{'id': 4, 'share': 'share2', 'share_id': '22', 'mount': '/export/share2', 'export_group': 4}], 'host_str': '1.!', 'editable': 'ro', 'syncable': 'async', 'mount_security': 'insecure', 'nohide': False, 'enabled': True, 'admin_host': None}

======================================================================
FAIL: test_host_str_validator_put (rockstor.storageadmin.tests.test_nfs_export.NFSExportTests.test_host_str_validator_put)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/opt/rockstor/src/rockstor/storageadmin/tests/test_nfs_export.py", line 274, in test_host_str_validator_put
    self.assertEqual(
AssertionError: 200 != 500 : {'id': 3, 'exports': [{'id': 3, 'share': 'share-nfs', 'share_id': '21', 'mount': '/export/share-nfs', 'export_group': 3}], 'host_str': '*', 'editable': 'rw', 'syncable': 'async', 'mount_security': 'insecure', 'nohide': False, 'enabled': True, 'admin_host': None}

======================================================================
FAIL: test_mod_choice_validator_post (rockstor.storageadmin.tests.test_nfs_export.NFSExportTests.test_mod_choice_validator_post)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/opt/rockstor/src/rockstor/storageadmin/tests/test_nfs_export.py", line 189, in test_mod_choice_validator_post
    self.assertEqual(
AssertionError: 200 != 500 : {'id': 6, 'exports': [{'id': 6, 'share': 'share2', 'share_id': '22', 'mount': '/export/share2', 'export_group': 6}], 'host_str': '*', 'editable': 'rr', 'syncable': 'async', 'mount_security': 'insecure', 'nohide': False, 'enabled': True, 'admin_host': None}

======================================================================
FAIL: test_mod_choice_validator_put (rockstor.storageadmin.tests.test_nfs_export.NFSExportTests.test_mod_choice_validator_put)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/opt/rockstor/src/rockstor/storageadmin/tests/test_nfs_export.py", line 206, in test_mod_choice_validator_put
    self.assertEqual(
AssertionError: 200 != 500 : {'id': 3, 'exports': [{'id': 3, 'share': 'share-nfs', 'share_id': '21', 'mount': '/export/share-nfs', 'export_group': 3}], 'host_str': '*', 'editable': 'rw', 'syncable': 'async', 'mount_security': 'insecure', 'nohide': False, 'enabled': True, 'admin_host': None}

======================================================================
FAIL: test_sync_choice_validator_post (rockstor.storageadmin.tests.test_nfs_export.NFSExportTests.test_sync_choice_validator_post)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/opt/rockstor/src/rockstor/storageadmin/tests/test_nfs_export.py", line 222, in test_sync_choice_validator_post
    self.assertEqual(
AssertionError: 200 != 500 : {'id': 10, 'exports': [{'id': 10, 'share': 'share2', 'share_id': '22', 'mount': '/export/share2', 'export_group': 10}], 'host_str': '*', 'editable': 'ro', 'syncable': 'aaaaa', 'mount_security': 'insecure', 'nohide': False, 'enabled': True, 'admin_host': None}

======================================================================
FAIL: test_sync_choice_validator_put (rockstor.storageadmin.tests.test_nfs_export.NFSExportTests.test_sync_choice_validator_put)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/opt/rockstor/src/rockstor/storageadmin/tests/test_nfs_export.py", line 239, in test_sync_choice_validator_put
    self.assertEqual(
AssertionError: 200 != 500 : {'id': 3, 'exports': [{'id': 3, 'share': 'share-nfs', 'share_id': '21', 'mount': '/export/share-nfs', 'export_group': 3}], 'host_str': '*', 'editable': 'rw', 'syncable': 'async', 'mount_security': 'insecure', 'nohide': False, 'enabled': True, 'admin_host': None}

----------------------------------------------------------------------
Ran 18 tests in 0.795s

FAILED (failures=6)

In summary of the After results we have:

Pagination may yield inconsistent results with an unordered object_list: <class 'storageadmin.models.nfs_export_group.NFSExportGroup'> (pertaining to a need addressed already in many other models re no default ordering defined).

@phillxnet
Copy link
Member Author

phillxnet commented Nov 11, 2024

Normally a successful rpm build is strongly preferred prior to merging a PR (stable branch or late testing branch). However in this PR's case we are intentionally introducing failing tests, which in-turn purposefully blocks rpm builds via our %check rpmbuild scriptlet requiring all test to pass prior to any rpm being build/released.

This test update provides the proof of API validation required as part of fixing #2924 (the six failing tests) , i.e. the next issue to be addressed post this PR being merged.

Moving to merge as these updated tests are a development dependency of:

@phillxnet phillxnet merged commit 8b0cb74 into rockstor:testing Nov 11, 2024
@phillxnet phillxnet deleted the 2923-NFS-tests-in-need-of-maintenance branch November 11, 2024 14:39
@phillxnet
Copy link
Member Author

A test rpmbuild using this branch failed as expected with the same test FAILS introduced in this PR:

...
Ran 295 tests in 37.996s

FAILED (failures=6)
Destroying test database for alias 'default'...
Destroying test database for alias 'smart_manager'...
error: Bad exit status from /var/tmp/rpm-tmp.MbXzFA (%check)
    Bad exit status from /var/tmp/rpm-tmp.MbXzFA (%check)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant