Skip to content

Commit

Permalink
Move test before others
Browse files Browse the repository at this point in the history
  • Loading branch information
gagik committed Oct 24, 2024
1 parent 631c92f commit 0083086
Showing 1 changed file with 80 additions and 80 deletions.
160 changes: 80 additions & 80 deletions packages/shell-api/src/shard.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2044,6 +2044,86 @@ describe('Shard', function () {
return serviceProvider.close(true);
});

describe('collection.status()', function () {
let db: Database;

const dbName = 'shard-status-test';
const ns = `${dbName}.test`;

beforeEach(async function () {
db = sh._database.getSiblingDB(dbName);
await db.getCollection('test').insertOne({ key: 1 });
await db.getCollection('test').createIndex({ key: 1 });
});
afterEach(async function () {
await db.dropDatabase();
});
describe('unsharded collections', function () {
describe('with >= 6.0.3', function () {
skipIfServerVersion(mongos, '< 6.0.3');

it('returns shardedDataDistribution as an empty array', async function () {
const status = await sh.status();
expect(status.value.shardedDataDistribution).deep.equals([]);
});
});

describe('with < 6.0.3', function () {
skipIfServerVersion(mongos, '>= 6.0.3');

it('returns shardedDataDistribution as undefined', async function () {
const status = await sh.status();
expect(status.value.shardedDataDistribution).equals(undefined);
});
});
});

describe('sharded collections', function () {
beforeEach(async function () {
expect((await sh.enableSharding(dbName)).ok).to.equal(1);
expect(
(await sh.shardCollection(ns, { key: 1 })).collectionsharded
).to.equal(ns);
});

describe('with >= 6.0.3', function () {
skipIfServerVersion(mongos, '< 6.0.3');

it('returns correct shardedDataDistribution', async function () {
const expectedShardedDataDistribution: ShardedDataDistribution = [
{
ns,
shards: [
{
shardName: 'rs-shard0-0',
numOrphanedDocs: 0,
numOwnedDocuments: 1,
ownedSizeBytes: 31,
orphanedSizeBytes: 0,
},
],
},
];

const status = await sh.status();

expect(status.value.shardedDataDistribution).deep.equals(
expectedShardedDataDistribution
);
});
});

describe('with < 6.0.3', function () {
skipIfServerVersion(mongos, '>= 6.0.3');

it('returns shardedDataDistribution as undefined', async function () {
const status = await sh.status();
expect(status.value.shardedDataDistribution).equals(undefined);
});
});
});
});

describe('sharding info', function () {
it('returns the status', async function () {
const result = await sh.status();
Expand Down Expand Up @@ -2887,86 +2967,6 @@ describe('Shard', function () {
});
});

describe('collection.status()', function () {
let db: Database;

const dbName = 'shard-status-test';
const ns = `${dbName}.test`;

beforeEach(async function () {
db = sh._database.getSiblingDB(dbName);
await db.getCollection('test').insertOne({ key: 1 });
await db.getCollection('test').createIndex({ key: 1 });
});
afterEach(async function () {
await db.dropDatabase();
});
describe('unsharded collections', function () {
describe('with >= 6.0.3', function () {
skipIfServerVersion(mongos, '< 6.0.3');

it('returns shardedDataDistribution as an empty array', async function () {
const status = await sh.status();
expect(status.value.shardedDataDistribution).deep.equals([]);
});
});

describe('with < 6.0.3', function () {
skipIfServerVersion(mongos, '>= 6.0.3');

it('returns shardedDataDistribution as undefined', async function () {
const status = await sh.status();
expect(status.value.shardedDataDistribution).equals(undefined);
});
});
});

describe('sharded collections', function () {
beforeEach(async function () {
expect((await sh.enableSharding(dbName)).ok).to.equal(1);
expect(
(await sh.shardCollection(ns, { key: 1 })).collectionsharded
).to.equal(ns);
});

describe('with >= 6.0.3', function () {
skipIfServerVersion(mongos, '< 6.0.3');

it('returns correct shardedDataDistribution', async function () {
const expectedShardedDataDistribution: ShardedDataDistribution = [
{
ns,
shards: [
{
shardName: 'rs-shard0-0',
numOrphanedDocs: 0,
numOwnedDocuments: 1,
ownedSizeBytes: 31,
orphanedSizeBytes: 0,
},
],
},
];

const status = await sh.status();

expect(status.value.shardedDataDistribution).deep.equals(
expectedShardedDataDistribution
);
});
});

describe('with < 6.0.3', function () {
skipIfServerVersion(mongos, '>= 6.0.3');

it('returns shardedDataDistribution as undefined', async function () {
const status = await sh.status();
expect(status.value.shardedDataDistribution).equals(undefined);
});
});
});
});

describe('collection.isCapped', function () {
it('returns true for config.changelog', async function () {
const ret = await sh._database
Expand Down

0 comments on commit 0083086

Please sign in to comment.