Enhance NFS mount option check for empty response#11839
Conversation
```
ERROR: test suite for <class 'tests.component.maint.test_primary_storage_nfsmountopts_kvm.TestNFSMountOptsKVM'>
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/nose/suite.py", line 210, in run
self.setUp()
File "/usr/local/lib/python3.9/site-packages/nose/suite.py", line 293, in setUp
self.setupContext(ancestor)
File "/usr/local/lib/python3.9/site-packages/nose/suite.py", line 316, in setupContext
try_run(context, names)
File "/usr/local/lib/python3.9/site-packages/nose/util.py", line 471, in try_run
return func()
File "/marvin/tests/component/maint/test_primary_storage_nfsmountopts_kvm.py", line 46, in setUpClass
cls.version = cls.getNFSMountOptionForPool(cls, "vers", cls.storage_pool.id)
File "/marvin/tests/component/maint/test_primary_storage_nfsmountopts_kvm.py", line 115, in getNFSMountOptionForPool
stat = nfsstat[0]
IndexError: list index out of range
```
because
```
shClient: DEBUG: {Cmd: nfsstat -m | sed -n '/e08df33d-d187-3c1c-88f4-10c69669f41a/{ n; p }' via Host: 10.0.32.210} {returns: []}
```
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## 4.22 #11839 +/- ##
============================================
- Coverage 17.55% 17.54% -0.01%
- Complexity 15526 15548 +22
============================================
Files 5908 5908
Lines 528696 529921 +1225
Branches 64569 65087 +518
============================================
+ Hits 92801 92974 +173
- Misses 425457 426494 +1037
- Partials 10438 10453 +15
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull Request Overview
This PR fixes an IndexError in the NFS mount options test by adding a length check for empty command output. The error occurred when the nfsstat -m command returned an empty list, causing an index out of range exception when trying to access nfsstat[0].
Key Changes:
- Enhanced the condition check to handle empty lists from SSH command execution
- Prevents IndexError when accessing the first element of an empty list
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
|
@blueorangutan package |
|
@abh1sar a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress. |
|
Lots of clunky bits in this file. I'll raise a separate PR to improve the test later. |
|
|
Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 15464 |
|
@blueorangutan test |
|
@abh1sar a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests |
|
[SF] Trillian test result (tid-14692)
|
|
@abh1sar do we still need to push this through (as you were refactoring the test anyway)? |
Let's push this at least. |



because
Description
This PR fixes a component test error
Types of changes
Feature/Enhancement Scale or Bug Severity
Feature/Enhancement Scale
Bug Severity
Screenshots (if appropriate):
How Has This Been Tested?
How did you try to break this feature and the system with this change?