Skip to content

Commit

Permalink
fix(shell-api): move subset of validate command tests to replset MO…
Browse files Browse the repository at this point in the history
…NGOSH-1664

Since the 7.3 server, the `validate` command rejects the `background`
option in standalone setups, so we move the corresponding integration tests to
the replica set integration test section. (We keep the `repair` option test in
the core integration test section since it only works on standalone nodes.)
  • Loading branch information
addaleax committed Jan 22, 2024
1 parent 98e265d commit 25eb71b
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 17 deletions.
19 changes: 3 additions & 16 deletions packages/shell-api/src/integration.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1303,7 +1303,9 @@ describe('Shell API (integration)', function () {
});
});

describe('validate', function () {
describe('validate [standalone mode]', function () {
// other options are tested in the ReplicaSet suite because they are not available
// in standalone mode
skipIfApiStrict();
skipIfServerVersion(testServer, '< 5.0');

Expand All @@ -1322,21 +1324,6 @@ describe('Shell API (integration)', function () {
(await collection.validate({ full: true, repair: true })).valid
).to.equal(true);
});

it('validate accepts a background option', async function () {
expect(
(await collection.validate({ full: false, background: true })).valid
).to.equal(true);
});

it('validate fails with background: true and full: true', async function () {
try {
await collection.validate({ full: true, background: true });
expect.fail('missed exception');
} catch (err: any) {
expect(err.name).to.equal('MongoServerError');
}
});
});
});

Expand Down
38 changes: 37 additions & 1 deletion packages/shell-api/src/replica-set.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import {
ALL_TOPOLOGIES,
} from './enums';
import { dummyOptions } from './helpers.spec';
import { signatures, toShellResult } from './index';
import { Collection, signatures, toShellResult } from './index';
import Mongo from './mongo';
import type { ReplSetConfig, ReplSetMemberConfig } from './replica-set';
import ReplicaSet from './replica-set';
Expand Down Expand Up @@ -1057,6 +1057,7 @@ describe('ReplicaSet', function () {
).to.deep.include({ ok: 1 });
});
});

describe('configureQueryAnalyzer()', function () {
skipIfServerVersion(srv0, '< 7.0'); // analyzeShardKey will only be added in 7.0 which is not included in stable yet

Expand Down Expand Up @@ -1090,6 +1091,41 @@ describe('ReplicaSet', function () {
});
});
});

describe('validate [replica set mode]', function () {
// Tested here because since https://jira.mongodb.org/browse/MONGOSH-1664 background: true
// does not work on standalone nodes anymore
skipIfApiStrict();
skipIfServerVersion(srv0, '< 5.0');
let collection: Collection;

beforeEach(async function () {
collection = db.getCollection('test');
await collection.insertOne({ foo: 'bar' });
});

it('validate can be used to validate a collection', async function () {
expect((await collection.validate({ full: true })).valid).to.equal(
true
);
});

it('validate accepts a background option', async function () {
expect(
(await collection.validate({ full: false, background: true })).valid
).to.equal(true);
});

it('validate fails with background: true and full: true', async function () {
try {
await collection.validate({ full: true, background: true });
expect.fail('missed exception');
} catch (err: any) {
expect(err.name).to.equal('MongoServerError');
expect(err.codeName).to.equal('InvalidOptions');
}
});
});
});

describe('integration (PA to PSA transition)', function () {
Expand Down

0 comments on commit 25eb71b

Please sign in to comment.