-
Notifications
You must be signed in to change notification settings - Fork 243
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
env_process: Refactor huge pages setup/cleanup steps #4054
base: master
Are you sure you want to change the base?
env_process: Refactor huge pages setup/cleanup steps #4054
Conversation
Creating a new Setuper subclass for setting and cleaning huge pages up. Removing the original code from virttest.env_process and replacing it instead with the new HugePagesSetup class being registered in the setup_manager. _pre_hugepages_surp and _post_hugepages_surp were left in env_process. Their goal is to provide a mechanism in env_process to raise a TestFail in case pages were leaked during a test. If that mechanism was refactored into the setuper, the TestFail would be masked by just an Error due to the way setup_manager handles postprocess exceptions. Changing the way SetupManager handles that requires bigger discussion on how the test infrastructure should handle test status reports, which is a way broader topic that what this patch aims to be. This is a patch from a larger patch series refactoring the env_process preprocess and postprocess functions. In each of these patches, a pre/post process step is identified and replaced with a Setuper subclass so the following can finally be met: - Only cleanup steps of successful setup steps are run to avoid possible environment corruption or hard to read errors. - Running setup/cleanup steps symmetrically during env pre/post process. - Reduce explicit pre/post process function code length. Signed-off-by: Beñat Gartzia Arruabarrena <[email protected]>
Hi @PaulYuuu |
self.params["setup_hugepages"] = "yes" | ||
if self.params.get("setup_hugepages") == "yes": | ||
h = test_setup.HugePageConfig(self.params) | ||
env_process._pre_hugepages_surp = h.ext_hugepages_surp |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_pre_hugepages_surp
and _post_hugepages_surp
are for hugepage leak check, with this Setuper, I would suggest dropping them. by returning a variable after do_cleanup
. so leak_num = _post_hugepages_surp - _pre_hugepages_surp
can short to leak_num = <new_var>
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I understood correctly, you are proposing to make the cleanup
method of this Setuper
return the leak_num
value?
That would also involve updating the SetupManager
behavior to meet the demands of HugePagesSetup
. If that's the case, we would permit every Setuper
return a value, which goes against the current implementation. We would then have to update the SetupManager
do_cleanup
logic to handle that.
In my opinion, if we were to do that, we would have to think of a protocol of some sort to make this implementable by each Setuper
instead of adding specific Setuper
logic into the rather general SetupManager
. Could something like adding a post_cleanup_check
function into the core Setuper
and calling it after the cleanup
method has been called from SetupManager.do_cleanup
be the answer to that issue?
I also thought on other approaches, as implementing a core Singleton
abstraction, so we would be able to reach Setuper
instances instead of classes from within env_process
so we could call extra functions on demand after the cleanup would have terminated. However, this approach sounds too complex for a workaround, and it could introduce further issues, as Setuper
instances "surviving" from one test case run to the next one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I understood correctly, you are proposing to make the
cleanup
method of thisSetuper
return theleak_num
value?
No, the workaround is the Setuper will calculate_post_hugepages_surp - _pre_hugepages_surp
and set env_process._hugepage_leaks(take this name as example).
The complex solution you mentioned is that Setuper can return something. I agree we can do this, but not now, the implementation can closely combine env_process and Setuper.
Creating a new Setuper subclass for setting and cleaning huge pages up. Removing the original code from virttest.env_process and replacing it instead with the new HugePagesSetup class being registered in the setup_manager.
_pre_hugepages_surp and _post_hugepages_surp were left in env_process. Their goal is to provide a mechanism in env_process to raise a TestFail in case pages were leaked during a test. If that mechanism was refactored into the setuper, the TestFail would be masked by just an Error due to the way setup_manager handles postprocess exceptions. Changing the way SetupManager handles that requires bigger discussion on how the test infrastructure should handle test status reports, which is a way broader topic that what this patch aims to be.
This is a patch from a larger patch series refactoring the env_process preprocess and postprocess functions. In each of these patches, a pre/post process step is identified and replaced with a Setuper subclass so the following can finally be met:
- Only cleanup steps of successful setup steps are run to avoid possible environment corruption or hard to read errors.
- Running setup/cleanup steps symmetrically during env pre/post process.
- Reduce explicit pre/post process function code length.