@@ -2468,6 +2468,18 @@ describe('Shard', function () {
24682468 ] ) ;
24692469 } ) ;
24702470 } ) ;
2471+ describe ( 'with a 7.0+ server' , function ( ) {
2472+ skipIfServerVersion ( mongos , '< 7.0' ) ;
2473+
2474+ it ( 'displays automerge status, if explicitly set' , async function ( ) {
2475+ await sh . startAutoMerger ( ) ;
2476+ const result = await sh . status ( ) ;
2477+
2478+ expect ( result . value . automerge ) . to . deep . equal ( {
2479+ 'Currently enabled' : 'yes' ,
2480+ } ) ;
2481+ } ) ;
2482+ } ) ;
24712483 } ) ;
24722484 describe ( 'turn on sharding' , function ( ) {
24732485 it ( 'enableSharding for a db' , async function ( ) {
@@ -2516,6 +2528,35 @@ describe('Shard', function () {
25162528 ) ;
25172529 } ) ;
25182530 } ) ;
2531+ describe ( 'automerge' , function ( ) {
2532+ it ( 'not shown if sh.status() if not explicitly enabled' , async function ( ) {
2533+ // It might be explicitly set from 7.0
2534+ skipIfServerVersion ( mongos , '>= 7.0' ) ;
2535+
2536+ // Ensure no previous automerge settings are present
2537+ await instanceState . currentDb
2538+ . getSiblingDB ( 'config' )
2539+ . getCollection ( 'settings' )
2540+ . deleteOne ( { _id : 'automerge' } ) ;
2541+
2542+ expect ( ( await sh . status ( ) ) . value . automerge ) . is . undefined ;
2543+ } ) ;
2544+ describe ( 'from 7.0' , function ( ) {
2545+ skipIfServerVersion ( mongos , '< 7.0' ) ; // Available from 7.0
2546+ it ( 'stops correctly' , async function ( ) {
2547+ expect ( ( await sh . stopAutoMerger ( ) ) . acknowledged ) . to . equal ( true ) ;
2548+ expect (
2549+ ( ( await sh . status ( ) ) . value . automerge ?? { } ) [ 'Currently enabled' ]
2550+ ) . to . equal ( 'no' ) ;
2551+ } ) ;
2552+ it ( 'enables correctly' , async function ( ) {
2553+ expect ( ( await sh . startAutoMerger ( ) ) . acknowledged ) . to . equal ( true ) ;
2554+ expect (
2555+ ( ( await sh . status ( ) ) . value . automerge ?? { } ) [ 'Currently enabled' ]
2556+ ) . to . equal ( 'yes' ) ;
2557+ } ) ;
2558+ } ) ;
2559+ } ) ;
25192560 describe ( 'autosplit' , function ( ) {
25202561 skipIfServerVersion ( mongos , '> 6.x' ) ; // Auto-splitter is removed in 7.0
25212562 it ( 'disables correctly' , async function ( ) {
0 commit comments