Skip to content

Commit 721736a

Browse files
committed
fix: do not show if not explicitly enabled
1 parent cfb1c3a commit 721736a

File tree

3 files changed

+24
-18
lines changed

3 files changed

+24
-18
lines changed

packages/shell-api/src/helpers.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ describe('getPrintableShardStatus', function () {
224224
);
225225
expect(status['most recently active mongoses']).to.have.lengthOf(1);
226226
expect(status.autosplit['Currently enabled']).to.equal('yes');
227-
expect(status.automerge['Currently enabled']).to.equal('yes');
227+
expect((status.automerge ?? {})['Currently enabled']).to.equal('yes');
228228
expect(status.balancer['Currently enabled']).to.equal('yes');
229229
expect(
230230
status.balancer['Failed balancer rounds in last 5 attempts']

packages/shell-api/src/helpers.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -330,10 +330,11 @@ export async function getPrintableShardStatus(
330330
(async (): Promise<void> => {
331331
// Is automerge currently enabled, available since >= 7.0
332332
const automerge = await settingsColl.findOne({ _id: 'automerge' });
333-
result.automerge = {
334-
'Currently enabled':
335-
automerge === null || automerge.enabled ? 'yes' : 'no',
336-
};
333+
if (automerge) {
334+
result.automerge = {
335+
'Currently enabled': automerge.enabled ? 'yes' : 'no',
336+
};
337+
}
337338
})(),
338339
(async (): Promise<void> => {
339340
// Is the balancer currently enabled
@@ -721,8 +722,8 @@ export type ShardingStatusResult = {
721722
autosplit: {
722723
'Currently enabled': 'yes' | 'no';
723724
};
724-
/** Available from 7.0.0 */
725-
automerge: {
725+
/** Shown if explicitly set, available and enabled by default from 7.0.0 */
726+
automerge?: {
726727
'Currently enabled': 'yes' | 'no';
727728
};
728729
balancer: {

packages/shell-api/src/shard.spec.ts

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2519,18 +2519,23 @@ describe('Shard', function () {
25192519
});
25202520
});
25212521
describe('automerge', function () {
2522-
skipIfServerVersion(mongos, '< 7.0'); // Available from 7.0
2523-
it('stops correctly', async function () {
2524-
expect((await sh.stopAutoMerger()).acknowledged).to.equal(true);
2525-
expect(
2526-
(await sh.status()).value.automerge['Currently enabled']
2527-
).to.equal('no');
2522+
it('not shown if sh.status() if not explicitly enabled', async function () {
2523+
expect((await sh.status()).value.automerge).is.undefined;
25282524
});
2529-
it('enables correctly', async function () {
2530-
expect((await sh.startAutoMerger()).acknowledged).to.equal(true);
2531-
expect(
2532-
(await sh.status()).value.automerge['Currently enabled']
2533-
).to.equal('yes');
2525+
describe('from 7.0', function () {
2526+
skipIfServerVersion(mongos, '< 7.0'); // Available from 7.0
2527+
it('stops correctly', async function () {
2528+
expect((await sh.stopAutoMerger()).acknowledged).to.equal(true);
2529+
expect(
2530+
((await sh.status()).value.automerge ?? {})['Currently enabled']
2531+
).to.equal('no');
2532+
});
2533+
it('enables correctly', async function () {
2534+
expect((await sh.startAutoMerger()).acknowledged).to.equal(true);
2535+
expect(
2536+
((await sh.status()).value.automerge ?? {})['Currently enabled']
2537+
).to.equal('yes');
2538+
});
25342539
});
25352540
});
25362541
describe('autosplit', function () {

0 commit comments

Comments
 (0)