diff --git a/packages/shell-api/src/helpers.ts b/packages/shell-api/src/helpers.ts index 403f5a12ae..69ec523e08 100644 --- a/packages/shell-api/src/helpers.ts +++ b/packages/shell-api/src/helpers.ts @@ -327,6 +327,15 @@ export async function getPrintableShardStatus( autosplit === null || autosplit.enabled ? 'yes' : 'no', }; })(), + (async (): Promise => { + // Is automerge currently enabled, available since >= 7.0 + const automerge = await settingsColl.findOne({ _id: 'automerge' }); + if (automerge) { + result.automerge = { + 'Currently enabled': automerge.enabled ? 'yes' : 'no', + }; + } + })(), (async (): Promise => { // Is the balancer currently enabled const balancerEnabled = await settingsColl.findOne({ _id: 'balancer' }); @@ -713,6 +722,10 @@ export type ShardingStatusResult = { autosplit: { 'Currently enabled': 'yes' | 'no'; }; + /** Shown if explicitly set, available and enabled by default from 7.0.0 */ + automerge?: { + 'Currently enabled': 'yes' | 'no'; + }; balancer: { 'Currently enabled': 'yes' | 'no'; 'Currently running': 'yes' | 'no' | 'unknown'; diff --git a/packages/shell-api/src/shard.spec.ts b/packages/shell-api/src/shard.spec.ts index d797666a0f..cfc6fd37fa 100644 --- a/packages/shell-api/src/shard.spec.ts +++ b/packages/shell-api/src/shard.spec.ts @@ -2468,6 +2468,18 @@ describe('Shard', function () { ]); }); }); + describe('with a 7.0+ server', function () { + skipIfServerVersion(mongos, '< 7.0'); + + it('displays automerge status, if explicitly set', async function () { + await sh.startAutoMerger(); + const result = await sh.status(); + + expect(result.value.automerge).to.deep.equal({ + 'Currently enabled': 'yes', + }); + }); + }); }); describe('turn on sharding', function () { it('enableSharding for a db', async function () { @@ -2516,6 +2528,35 @@ describe('Shard', function () { ); }); }); + describe('automerge', function () { + it('not shown if sh.status() if not explicitly enabled', async function () { + // It might be explicitly set from 7.0 + skipIfServerVersion(mongos, '>= 7.0'); + + // Ensure no previous automerge settings are present + await instanceState.currentDb + .getSiblingDB('config') + .getCollection('settings') + .deleteOne({ _id: 'automerge' }); + + expect((await sh.status()).value.automerge).is.undefined; + }); + describe('from 7.0', function () { + skipIfServerVersion(mongos, '< 7.0'); // Available from 7.0 + it('stops correctly', async function () { + expect((await sh.stopAutoMerger()).acknowledged).to.equal(true); + expect( + ((await sh.status()).value.automerge ?? {})['Currently enabled'] + ).to.equal('no'); + }); + it('enables correctly', async function () { + expect((await sh.startAutoMerger()).acknowledged).to.equal(true); + expect( + ((await sh.status()).value.automerge ?? {})['Currently enabled'] + ).to.equal('yes'); + }); + }); + }); describe('autosplit', function () { skipIfServerVersion(mongos, '> 6.x'); // Auto-splitter is removed in 7.0 it('disables correctly', async function () {