Skip to content

Commit f7fb376

Browse files
committed
Fix flaky test: test pubsub channels and shardchannels separation #4927
Signed-off-by: hank95179 <hank95179@gmail.com>
1 parent 92ec81b commit f7fb376

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

node/tests/PubSub.test.ts

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4024,11 +4024,23 @@ describe("PubSub", () => {
40244024
pubSub,
40254025
);
40264026

4027-
// Test pubsubChannels
4028-
const regularChannels = await client2.pubsubChannels();
4029-
expect(regularChannels).toEqual([regularChannel]);
4027+
{
4028+
// Wait up to 3 seconds (60 * 50ms)
4029+
for (let i = 0; i < 60; i++) {
4030+
const channels = await client2.pubsubChannels();
4031+
4032+
if (channels.includes(regularChannel)) {
4033+
break;
4034+
}
4035+
4036+
await new Promise((r) => setTimeout(r, 50));
4037+
}
4038+
4039+
// Final assertion
4040+
const regularChannels = await client2.pubsubChannels();
4041+
expect(regularChannels).toEqual([regularChannel]);
4042+
}
40304043

4031-
// Test pubsubShardchannels
40324044
const shardChannels = await (
40334045
client2 as GlideClusterClient
40344046
).pubsubShardChannels();

0 commit comments

Comments
 (0)