-
Type: Task
-
Resolution: Unresolved
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: None
-
None
-
Query Execution
-
QE 2025-01-20
-
10
The 'print()' function in mongo (legacy) shell prints currently all its arguments verbatim separated by a space into the output stream.
To achieve structured JSON log format we should EITHER ensure 'print()' is NOT used in our tests & related libraries OR wrap the output into the JSON object
{msg: "<original string>" }and escape double-quotes accordingly. If we decide not to have 'print()' in our tests it should be checked automatically by the linter.
The 'jsTestLog()' (a.k.a. 'jsTest.log()') function in mongo (legacy) shell takes one string or object 'msg' argument and prints it as a multi-line banner into the output stream. The banner is there to easily spot the test output while browsing the log, but it should become obsolete when there is a way to easily separate the mongo shell output (see SERVER-96898 and DEVPROD-12535).
Nevertheless, unlike a general-purpose 'print()', it might be useful to have a log-outputting function in our JavaScript tests that follows JSON log output format of MongoDB server to make it searchable and contain some or all of fields
{ "t": <Datetime>, // timestamp "s": <String>, // severity "c": <String>, // component "id": <Integer>, // unique identifier "ctx": <String>, // context "msg": <String>, // message body "attr": <Object>, // additional attributes (optional) "tags": <Array of strings>, // tags (optional) "truncated": <Object>, // truncation info (if truncated) "size": <Object> // original size of entry (if truncated) }
So, next time, instead of adding
jsTest.log("Change event = " + tojson(event) + " last oplog entry = " + tojson(oplogEntry));
... and deleting it before committing the test, we can add and commit
jsTest.log.debug("Change stream status before topology change",
attr: {lastChangeEvent: event, lastOplogEntry: oplogEntry});
... and activate it with an new resmoke parameter --severity= or --logLevel=DEBUG when the problem re-appears.
Since these changes might break Parsley's resmoke-parsing-mode, we might need to guard it with an opt-in feature flag for now.