[SERVER-33034] Change assertion functions to accept a function returning a string as the message parameter Created: 31/Jan/18  Updated: 29/Oct/23  Resolved: 15/Feb/18

Status: Closed
Project: Core Server
Component/s: Testing Infrastructure
Affects Version/s: None
Fix Version/s: 3.7.3

Type: New Feature Priority: Major - P3
Reporter: Max Hirschhorn Assignee: David Bradford (Inactive)
Resolution: Fixed Votes: 0
Labels: tig-assertjs
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
is duplicated by SERVER-29671 writeError should check that msg is a... Closed
is duplicated by SERVER-45506 Add custom generated messages for ass... Closed
Related
related to SERVER-33361 Update sasl_mechanism_discovery asser... Closed
is related to SERVER-32497 implicitly_retry_on_database_drop_pen... Closed
is related to SERVER-32778 Fix perf regression on shell assertio... Closed
Backwards Compatibility: Fully Compatible
Sprint: TIG 2018-02-26
Participants:

 Description   

SERVER-32497 and SERVER-32778 are two recent cases where accidentally calling tojson() in a loop impacts performance negatively enough to cause tests to fail. We could avoid this issue by changing the assertion functions to accept a function returning a string as the message parameter and only lazily calling the function if doassert() would be called. Note: The doassert() functions attempts to handle when the message parameter is a function; however, it is defeated by the assertion functions prefixing a string to the intended assertion message.

As part of this ticket, we should also update existing tests that define an object with a "toString" property as a way to define a function for getting the assertion message to just pass the function directly instead.



 Comments   
Comment by Githook User [ 15/Feb/18 ]

Author:

{'email': 'david.bradford@mongodb.com', 'name': 'David Bradford', 'username': 'dbradf'}

Message: SERVER-33034: Update jstest asserts to accept a function for messages
Branch: master
https://github.com/mongodb/mongo/commit/aa8388487e3bea0737237b48a06e6b20b243e791

Comment by Githook User [ 15/Feb/18 ]

Author:

{'email': 'david.bradford@mongodb.com', 'name': 'David Bradford', 'username': 'dbradf'}

Message: SERVER-33034: Fix tests with bad assertions
Branch: master
https://github.com/mongodb/mongo/commit/caf6f27ec26a5b0d325e2fcbad39d0239f798a43

Comment by Githook User [ 15/Feb/18 ]

Author:

{'email': 'david.bradford@mongodb.com', 'name': 'David Bradford', 'username': 'dbradf'}

Message: SERVER-33034: Send assertion messages to assert functions
Branch: master
https://github.com/10gen/mongo-enterprise-modules/commit/19dfc26e477d4be4f724adcde3afab4c7f85c2b5

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