The unified test format spec clarifies additional error codes that may be ignored when executing killAllSessions to work around
SERVER-54216 and Atlas prohibiting usage of the command. Additionally, it suggests several approaches to disable killAllSessions behavior for Atlas (e.g. detecting "mongodb.net" hostnames, implementing a configuration option for the test runner).
Unified test format currently contains the recommendation to kill all sessions before every test:
Terminating Open Transactions
Open transactions can cause tests to block indiscriminately. Test runners SHOULD terminate all open transactions at the start of a test suite and after each failed test by killing all sessions in the cluster. Using the internal MongoClient, execute the killAllSessions command on either the primary or, if connected to a sharded cluster, all mongos servers.
killAllSessions command does not work in Atlas (HELP-22193). The closest workaround is killing the user's own sessions, but this currently doesn't work due to server bug (
SERVER-54216 is fixed, unified test runners should provide an option to not run killAllSessions at all, and the workload executor should request this option when instantiating the test runner.
SERVER-54216 is fixed, unified test runners may switch to killing only sessions of their user, at which point the option to not kill sessions may be removed, OR outside of Atlas the test runners could continue killing all sessions but for Atlas testing the test runners would only kill their own sessions.
Note that killing sessions is not strictly necessary in the test runner unless transactions are actually being used, and currently Atlas planned maintenance tests do not use transactions.