Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/shell-api/src/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1602,7 +1602,7 @@ export class Database<
if (startOptimeDate) {
nodeResult.syncedTo = node.optimeDate.toString();
}
const ago = (node.optimeDate - startOptimeDate) / 1000;
const ago = (startOptimeDate - node.optimeDate) / 1000;
const hrs = Math.round(ago / 36) / 100;
let suffix = '';
if (primary) {
Expand Down
9 changes: 9 additions & 0 deletions packages/shell-api/src/replica-set.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -895,8 +895,17 @@ describe('ReplicaSet', function () {
expect(result.ismaster).to.be.true;
});
it('returns StatsResult for print secondary replication info', async function () {
const coll = db.getCollection('cstest');
await coll.insertOne({ i: 42 });

const result = await rs.printSecondaryReplicationInfo();
expect(result.type).to.equal('StatsResult');
for (const value of Object.values(
result.value as Record<string, any>
)) {
// just check that the value is not negative
expect(value.replLag).to.match(/^\d+ sec/);
}
});
it('returns StatsResult for print replication info', async function () {
const result = await rs.printReplicationInfo();
Expand Down
Loading