[SERVER-47418] setMinimumLoggedSeverity in unittest/log_test.h needs to get cleaned up Created: 08/Apr/20  Updated: 29/Oct/23  Resolved: 16/Apr/20

Status: Closed
Project: Core Server
Component/s: Logging
Affects Version/s: None
Fix Version/s: 4.7.0

Type: Improvement Priority: Major - P3
Reporter: Gabriel Russell (Inactive) Assignee: Billy Donahue
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Problem/Incident
causes SERVER-47483 Logs from util_test unittest get supp... Closed
Backwards Compatibility: Fully Compatible
Sprint: Service arch 2020-04-20
Participants:

 Description   

when using setMinimumLoggedSeverity in unittests, the value doesn't get reset after the test and could effect subsequent test. A possible solution would be to return a sort of an ON_BLOCK_EXIT clean up function that would reset the value at the end of the test.



 Comments   
Comment by Githook User [ 01/May/20 ]

Author:

{'name': 'Billy Donahue', 'email': 'billy.donahue@mongodb.com', 'username': 'BillyDonahue'}

Message: SERVER-47418 deploy unittest::MinimumLoggedSeverityGuard to all tests

(cherry picked from commit e4794531419bff51da233bc4453db6f99d1809ff)
Branch: v4.4
https://github.com/mongodb/mongo/commit/5d32cf67738d377070c5ab0e44a267d4b3b3b7bb

Comment by Githook User [ 15/Apr/20 ]

Author:

{'name': 'Billy Donahue', 'email': 'billy.donahue@mongodb.com', 'username': 'BillyDonahue'}

Message: SERVER-47418 deploy unittest::MinimumLoggedSeverityGuard to all tests
Branch: master
https://github.com/mongodb/mongo/commit/e4794531419bff51da233bc4453db6f99d1809ff

Comment by Billy Donahue [ 14/Apr/20 ]

(I up-prioritized this into my current sprint and fixed it immediately because we had a few BFs that we couldn't debug because of bad MinimumLogSeverity hygiene in unit tests.)

Comment by Billy Donahue [ 14/Apr/20 ]

CR http://mongodbcr.appspot.com/582970082

Comment by Billy Donahue [ 14/Apr/20 ]

Regarding automatically restoring state after a test run, there's an unbounded list of "state" to be restored, but we could alert on what we can notice. I noticed that time_support_test.cpp changes the process time zone and doesn't put it back, for example. I'd prefer tests to clean up after themselves, and for tests to be correct regardless of launcher's details. We need to audit the tests. To help with that auditing, we might place assertions into the unit test launcher that fail the test if it doesn't clean up after itself. We'd consider a test that exhibits a failure to clean up global state to be a failed test, as it could indicate an important infrastructure bug.

Anyway, SERVER-47483 added a MinimumLoggedSeverityGuard class that can be used to temporarily set or clear, and then restore a LogComponent's severity in tests.
Now we can find all the setMinimumLoggedSeverity and make them use it.

I also feel the ???MinimumLoggedSeverity functions need work. They have an inconsistent naming convention with some using MinimumLogSeverity and others spelled as MinimumLoggedSeverity, and they should be moved to the mongo::unittest namespace as these free functions are really test helpers defined in the unittest directory.

Comment by Sara Williamson [ 13/Apr/20 ]

We may want to consider automatically restoring state after test run by the test runner.

Generated at Thu Feb 08 05:14:08 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.