Skip to content

Best way to test queue durability? #1460

Answered by johnnyleejy
johnnyleejy asked this question in Q&A
Discussion options

You must be logged in to vote

Here's what I did.

I created listeners to listen if the redisclient did disconnect and reconnect.

Then I returned promises and expect a true value in my tests.

const queueClient = await queue.client;
const didQueueDisconnect = new Promise<boolean>((resolve) => {
  setTimeout(resolve, 10000, false); // resolves to false if client is not closed after 10 seconds
  queueClient.on('close', () => {
    resolve(true); // resolves to true when queue connection is closed
  });
});
const didQueueReconnect = new Promise<boolean>((resolve) => {
  setTimeout(resolve, 10000, false); // resolves to false if client is not reconnected after 10 seconds
  queueClient.on('reconnecting', () => {
    resolve(t…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@manast
Comment options

Answer selected by johnnyleejy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants