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

stress-ng: fix teardown #2910

Merged
merged 1 commit into from
Oct 24, 2024

Conversation

disgoel
Copy link
Contributor

@disgoel disgoel commented Oct 23, 2024

Fix the teardown function to prevent AttributeError by adding checks to see if the attribute and path exists before trying to remove it.

Before fix:
ERROR: 'Stressng' object has no attribute 'loop_dev'
ERROR: 'Stressng' object has no attribute 'stressmnt'

After fix:
CANCEL: Build Failed, Please check the build logs for details !!

avocado run stress-ng.py -m stress-ng.py.data/stress-ng-fs.yaml
Fetching asset from stress-ng.py:Stressng.test
JOB ID     : 6fc94c4cdaeba93499384ac1ca4b3790620f005a
JOB LOG    : /home/avocado-fvt-wrapper/results/job-2024-10-23T13.59-6fc94c4/job.log
 (1/1) stress-ng.py:Stressng.test;run-exclude-fs_type-ext4-stressors-workers-f640: STARTED
 (1/1) stress-ng.py:Stressng.test;run-exclude-fs_type-ext4-stressors-workers-f640: CANCEL: Build Failed, Please check the build logs for details !! (10.28 s)
RESULTS    : PASS 0 | ERROR 0 | FAIL 0 | SKIP 0 | WARN 0 | INTERRUPT 0 | CANCEL 1
JOB HTML   : /home/avocado-fvt-wrapper/results/job-2024-10-23T13.59-6fc94c4/results.html
JOB TIME   : 27.14 s

@Naresh-ibm Naresh-ibm self-assigned this Oct 23, 2024
sudo=True)
if hasattr(self, 'loop_dev') and os.path.exists(self.loop_dev):
process.run("umount %s" % self.loop_dev, ignore_status=True, sudo=True)
process.run("losetup -d %s" % self.loop_dev, ignore_status=True, sudo=True)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@disgoel please take care of pep8 errors

# pycodestyle test.py 
test.py:80:80: E501 line too long (82 > 79 characters)
test.py:117:80: E501 line too long (81 > 79 characters)
test.py:124:80: E501 line too long (87 > 79 characters)
test.py:173:80: E501 line too long (86 > 79 characters)
test.py:184:80: E501 line too long (86 > 79 characters)
test.py:202:80: E501 line too long (83 > 79 characters)
test.py:203:80: E501 line too long (87 > 79 characters)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed pep8 errors

Fix the teardown function to prevent AttributeError by adding checks
to see if the attribute and path exists before trying to remove it.

Before fix:
ERROR: 'Stressng' object has no attribute 'loop_dev'
ERROR: 'Stressng' object has no attribute 'stressmnt'

After fix:
CANCEL: Build Failed, Please check the build logs for details !!

Signed-off-by: Disha Goel <[email protected]>
process.run("rm -rf /tmp/blockfile", ignore_status=True, sudo=True)
if (os.path.exists(self.stressmnt)):
process.run(f"rm -rf {self.stressmnt}")
if hasattr(self, 'stressmnt') and os.path.exists(self.stressmnt):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@disgoel is stressmnt and /tmp/blockfile are the same?
if so why are we using variable at one place and hardcoded value at another place?
prefer not to hard code as it may fail if variable name differs

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

both are different
self.stressmnt is a directory and /tmp/blockfile is a block device

Copy link
Collaborator

@Naresh-ibm Naresh-ibm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@disgoel Thanks for PR.
LGTM

@Naresh-ibm Naresh-ibm merged commit 0ad19b1 into avocado-framework-tests:master Oct 24, 2024
3 checks passed
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.

2 participants