-
Notifications
You must be signed in to change notification settings - Fork 84
feat(shell-api): add automerge information to sh.status() MONGOSH-1649 #2422
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
1c3f5dd
cfb1c3a
721736a
5615062
4b531d9
3496b4b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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; | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this works but does kind of mess with the I'm unsure how problematic would determining the implicit default status based on the version would be but that seems to be the only other option (or setting the status to
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The server version? The only reliable version that clients are supposed to make decisions on is the wire version reported by
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hm okay, if omitting the field is fine then we could just go with that. |
||
| }); | ||
| 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 () { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm using
nullscenario to returntrueto match the mongod behavior. But this is available since 7.0 which means in older versions it'd also similarly say'yes'which is weird.The solution to this is to check for the server version and compare with semver but I don't see this being used anywhere
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just wondering – what does
automerge === nullcorrespond to? Is that the case in which we would want to not print this information?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Going off https://github.com/mongodb/mongo/blob/a79ad6aa8b026d511227c4ece3d8c80265578831/src/mongo/shell/utils_sh.js#L264 my guess is that the idea here is that automerge wasn't explicitly enabled but it is enabled by default in 7.x+ so they print it out as such
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah just confirmed this more or less with
start/stop autoMergeris when that'd appear.We could omit it when the information isn't explicitly set and show only if it has been configured; users looking for it would probably end up starting/stopping automerger so seems reasonable, though a bit of divergence from what we usually do