-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #609 from nats-io/tests
[TEST] made some tests less likely to flap
- Loading branch information
Showing
7 changed files
with
30 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ | |
*/ | ||
import { | ||
assert, | ||
assertAlmostEquals, | ||
assertEquals, | ||
fail, | ||
} from "https://deno.land/[email protected]/assert/mod.ts"; | ||
|
@@ -124,23 +125,23 @@ Deno.test("reconnect - reconnecting after proper delay", async () => { | |
reconnectTimeWait: 500, | ||
maxReconnectAttempts: 1, | ||
}) as NatsConnectionImpl; | ||
const serverLastConnect = nc.protocol.servers.getCurrentServer().lastConnect; | ||
const first = nc.protocol.servers.getCurrentServer().lastConnect; | ||
|
||
const dt = deferred<number>(); | ||
(async () => { | ||
for await (const e of nc.status()) { | ||
switch (e.type) { | ||
switch (e.type as string) { | ||
case DebugEvents.Reconnecting: { | ||
const elapsed = Date.now() - serverLastConnect; | ||
dt.resolve(elapsed); | ||
const last = nc.protocol.servers.getCurrentServer().lastConnect; | ||
dt.resolve(last - first); | ||
break; | ||
} | ||
} | ||
} | ||
})().then(); | ||
await srv.stop(); | ||
const elapsed = await dt; | ||
assert(elapsed >= 500 && elapsed <= 700, `elapsed was ${elapsed}`); | ||
assert(elapsed >= 500 && elapsed <= 800, `elapsed was ${elapsed}`); | ||
await nc.closed(); | ||
}); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters