Detect process conflicts with sdw-notify#454
Merged
Conversation
Contributor
Author
|
We will likely want to use this utility function in |
This is necessary to suppress the notification during provisioning, or other processes during which we may not want to encourage the user to run updates. For now, qubesctl and make are detected.
c24b311 to
1ad6fcd
Compare
emkll
approved these changes
Feb 20, 2020
Contributor
emkll
left a comment
There was a problem hiding this comment.
Functional testing looks good to me, thanks @eloquence
- Run
/opt/securedrop/launcher/sdw-notify.py. The notification should show up. - Run
make testand run/opt/securedrop/launcher/sdw-notify.pywhile it is doing its thing. The notification should not appear, and you should see a log entry in~/.securedrop_launcher/logs/sdw-notify.logexplaining why. - (optional, for good measure) Run the Qubes GUI updater and kick off a graphical update process (
qubesctlmust be running in the process list). Runsdw-notifywhile that's underway. Result should be the same as above. - confirmed was made with love and 100% test coverage
| assert running_process is True | ||
| mocked_error.assert_called_once() | ||
| error_string = mocked_error.call_args[0][0] | ||
| assert re.search(CONFLICTING_PROCESS_REGEX, error_string) is not None |
Contributor
There was a problem hiding this comment.
It may be easier and more reliable to use format strings here given the predictability of the output. Since the regex is used only once, there may be little value in declaring outside of the test function (for now) , for example
diff --git a/launcher/tests/test_util.py b/launcher/tests/test_util.py
index 8a25165ea..44e14c034 100644
--- a/launcher/tests/test_util.py
+++ b/launcher/tests/test_util.py
@@ -13,8 +13,6 @@ BUSY_LOCK_REGEX = r"Error obtaining lock on '.*'."
# Regex for failure to obtain lock due to permission error
LOCK_PERMISSION_REGEX = r"Error writing to lock file '.*'"
-CONFLICTING_PROCESS_REGEX = r"Conflicting process .* is currently running."
-
relpath_util = "../sdw_util/Util.py"
path_to_util = os.path.join(os.path.dirname(os.path.abspath(__file__)), relpath_util)
util = SourceFileLoader("Util", path_to_util).load_module()
@@ -191,9 +189,7 @@ def test_for_conflicting_process(
mocked_run.assert_called_once()
if expected_result is True:
assert running_process is True
- mocked_error.assert_called_once()
- error_string = mocked_error.call_args[0][0]
- assert re.search(CONFLICTING_PROCESS_REGEX, error_string) is not None
+ mocked_error.assert_called_once_with("Conflicting process '{}' is currently running.".format("cowsay"))
else:
assert running_process is False
assert not mocked_error.called
cfm
pushed a commit
that referenced
this pull request
Apr 1, 2024
…flict Detect process conflicts with sdw-notify
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Status
Ready for review
Description of Changes
Resolves #453.
We check for a defined list of processes using
pgrepto ensure thatsdw-notifydoes not run when provisioning or similar system updates are already underway.Test plan
Setup:
make prep-dom0~/.securedrop_launcher/sdw-last-updateddoes not exist, to force the notification to always appear.Tests:
/opt/securedrop/launcher/sdw-notify.py. The notification should show up.make testand run/opt/securedrop/launcher/sdw-notify.pywhile it is doing its thing. The notification should not appear, and you should see a log entry in~/.securedrop_launcher/logs/sdw-notify.logexplaining why.qubesctlmust be running in the process list). Runsdw-notifywhile that's underway. Result should be the same as above.Checklist
make flake8passesmake testpasses