[SERVER-78876] Add an example for how to check FCV in a JS test Created: 11/Jul/23  Updated: 26/Jan/24  Resolved: 26/Jan/24

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: 7.3.0-rc2

Type: Improvement Priority: Major - P3
Reporter: George Wangensteen Assignee: Kaitlin Mahar
Resolution: Fixed Votes: 0
Labels: repl-shortlist
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Assigned Teams:
Replication
Backwards Compatibility: Fully Compatible
Sprint: Repl 2024-01-08, Repl 2024-01-22, Repl 2024-02-05
Participants:

 Description   

Add an example for how to write logic that depends on FCV in a JS test.

Original description

We frequently add small changes to the syntax or expected output of commands between server versions. When we do so, we often break Javascript tests that rely on these command names or outputs when the tests run in multi-version environments.

After finding this failure (often in a patch or on the waterfall), we add special code to the jstest to handle the edge case, generally by switching on the FCV-version of the server we're connected to and exercising different behavior/assertions depending on the result. Then, we file server tickets (i.e. SERVER-75941) to fix the behavior once last-lts changes again and we won't be comparing server versions with the differential behavior on the main branch. 

These tickets pile up and create laundry-list of tech-debt work we need to do with each FCV/version bump. And each "fix" is generally some hand-rolled FCV check that is manually written and tested after each failure is found.

I think it might be useful to have some sort of 'helper' component in jstest-land that handles this conditional behavior. I.e. a function that, given a connection to a server and a command or response from that server, exercise conditional behavior/assertions depending on the FCV of that server.  

This would reduce server engineer development in fixing these issues, and make this an easily discoverable 'pattern' that we could grep for on version-bump/branching. Even better, we might be able to use this to automatically "fix" all of the tests on version bump with scripts/tooling instead of a bunch of server tickets that are done manually by engineers. 



 Comments   
Comment by Githook User [ 25/Jan/24 ]

Author:

{'name': 'Kaitlin Mahar', 'email': 'kaitlin.mahar@mongodb.com', 'username': 'kmahar'}

Message: SERVER-78876 Add JS test FCV check example (#18108)

GitOrigin-RevId: dee8f6a72d31eae88c3341f56d87967b8df340f7
Branch: master
https://github.com/mongodb/mongo/commit/71f5a5aa3a2d6deb58ee62f80cc4301734f259d1

Generated at Thu Feb 08 06:39:31 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.