From 65e0e15cd59809558fb2570ef4d7fe6d6d376d5d Mon Sep 17 00:00:00 2001 From: Warren James Date: Wed, 4 Sep 2024 14:06:39 -0400 Subject: [PATCH] test(NODE-6317): fix test assertions and naming (#4217) --- .../server_discover_and_monitoring.test.ts | 39 ++++++++++++------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/test/integration/server-discovery-and-monitoring/server_discover_and_monitoring.test.ts b/test/integration/server-discovery-and-monitoring/server_discover_and_monitoring.test.ts index 176184e2a7..826a5f4371 100644 --- a/test/integration/server-discovery-and-monitoring/server_discover_and_monitoring.test.ts +++ b/test/integration/server-discovery-and-monitoring/server_discover_and_monitoring.test.ts @@ -83,23 +83,20 @@ describe('Monitoring rtt tests', function () { await promise; }); - it( - 'heartbeat duration is not incorrectly reported as zero on ServerHeartbeatSucceededEvents', - { - metadata: { - requires: { topology: '!load-balanced' } - }, - test: async function () { - for (const durations of Object.values(heartbeatDurations)) { - const relevantDurations = durations.slice(IGNORE_SIZE); - expect(relevantDurations).to.have.length.gt(0); - const averageDuration = - relevantDurations.reduce((acc, x) => acc + x) / relevantDurations.length; - expect(averageDuration).to.be.gt(DELAY_MS); - } + it('ServerHeartbeatSucceededEvent.duration is greater than or equal to the actual rtt', { + metadata: { + requires: { topology: '!load-balanced' } + }, + test: async function () { + for (const durations of Object.values(heartbeatDurations)) { + const relevantDurations = durations.slice(IGNORE_SIZE); + expect(relevantDurations).to.have.length.gt(0); + const averageDuration = + relevantDurations.reduce((acc, x) => acc + x) / relevantDurations.length; + expect(averageDuration).to.be.gte(DELAY_MS); } } - ); + }); it('ServerDescription.roundTripTime is not incorrectly reported as zero', { metadata: { @@ -114,6 +111,18 @@ describe('Monitoring rtt tests', function () { } } }); + + it('ServerDescription.roundTripTime is greater than or equal to the actual rtt', { + metadata: { + requires: { topology: '!load-balanced' } + }, + test: async function () { + for (const server of Object.keys(heartbeatDurations)) { + const rtt = client.topology.description.servers.get(server).roundTripTime; + expect(rtt).to.be.gte(DELAY_MS); + } + } + }); }); }); }