-
Notifications
You must be signed in to change notification settings - Fork 42
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
feat: allow overriding MetadataSyncJob
timeout via Qubes service flag
#1552
Changes from all commits
5e83215
2e4ba6b
715d7ab
0679ae4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,8 @@ | |
Submission = namedtuple("Submission", ["uuid", "source_uuid", "is_file", "is_downloaded"]) | ||
File = namedtuple("File", ["is_downloaded"]) | ||
|
||
TIMEOUT_OVERRIDE = 600 # sec | ||
|
||
|
||
class TestUpdateState(unittest.TestCase): | ||
def setUp(self): | ||
|
@@ -37,6 +39,31 @@ def test_handles_missing_files_gracefully(self): | |
assert self._state.file("9") | ||
|
||
|
||
def test_MetadataSyncJob_has_default_timeout(mocker, homedir, session, session_maker): | ||
api_client = mocker.patch("securedrop_client.logic.sdclientapi.API") | ||
remote_user = factory.RemoteUser() | ||
api_client.get_users = mocker.MagicMock(return_value=[remote_user]) | ||
|
||
job = MetadataSyncJob(homedir) | ||
job.call_api(api_client, session) | ||
assert api_client.default_request_timeout == job.DEFAULT_REQUEST_TIMEOUT | ||
|
||
|
||
def test_MetadataSyncJob_takes_overriden_timeout(mocker, homedir, session, session_maker): | ||
api_client = mocker.patch("securedrop_client.logic.sdclientapi.API") | ||
remote_user = factory.RemoteUser() | ||
api_client.get_users = mocker.MagicMock(return_value=[remote_user]) | ||
|
||
os.environ["SDEXTENDEDTIMEOUT"] = str(TIMEOUT_OVERRIDE) # environment value must be string | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. One alternative strategy to consider for tests that modify env vars might be to mock |
||
|
||
job = MetadataSyncJob(homedir) | ||
job.call_api(api_client, session) | ||
assert api_client.default_request_timeout == TIMEOUT_OVERRIDE | ||
|
||
# Don't pollute the environment for subsequent/out-of-order tests. | ||
del os.environ["SDEXTENDEDTIMEOUT"] | ||
|
||
|
||
def test_MetadataSyncJob_creates_new_user(mocker, homedir, session, session_maker): | ||
api_client = mocker.patch("securedrop_client.logic.sdclientapi.API") | ||
remote_user = factory.RemoteUser() | ||
|
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.
A minor pet peeve of mine: since the message doesn't require action (e.g. like a deprecation warning does), I would prefer it to be at
INFO
level.I say pet peeve because I find personally that most warnings shouldn't be emitted (potentially controversial opinion) because they fall into the following categories:
What would I make a warning? Things that will become fatal errors unless action is taken, e.g. deprecation warnings. YMMV! Admittedly it's nitpickey and mostly a matter of personal preference. 🙂
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.
I generally agree with your criteria, @gonzalo-bulnes. In this specific case, I'm rounding up slightly from our decision to call out this flag "explicitly as experimental, i.e. we cannot guarantee that we will support it in feature" to something akin to a deprecation warning. But I'm happy to demote this message to
INFO
if that logic isn't persuasive.(See also: #1166.)
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.
Oh, that makes sense @cfm I missed that intent! I'm not sure what context goes into the current wording: would there be an opportunity to call out explicitly (and additionally to the warning level): "WARNING: ... use experimental default_..."?