@@ -2468,6 +2468,18 @@ describe('Shard', function () {
2468
2468
] ) ;
2469
2469
} ) ;
2470
2470
} ) ;
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
+ } ) ;
2471
2483
} ) ;
2472
2484
describe ( 'turn on sharding' , function ( ) {
2473
2485
it ( 'enableSharding for a db' , async function ( ) {
@@ -2516,6 +2528,35 @@ describe('Shard', function () {
2516
2528
) ;
2517
2529
} ) ;
2518
2530
} ) ;
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
+ } ) ;
2519
2560
describe ( 'autosplit' , function ( ) {
2520
2561
skipIfServerVersion ( mongos , '> 6.x' ) ; // Auto-splitter is removed in 7.0
2521
2562
it ( 'disables correctly' , async function ( ) {
0 commit comments