From 020bac94a3813fae26d8db29cb2df175c8f1f2c9 Mon Sep 17 00:00:00 2001 From: Marc Bachmann Date: Mon, 31 Jan 2022 01:30:07 +0100 Subject: [PATCH] test: Make the reconnect test compatible with redis lower v5 --- test/functional/pipeline.ts | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/test/functional/pipeline.ts b/test/functional/pipeline.ts index 4b2ae4aa..37c4e63b 100644 --- a/test/functional/pipeline.ts +++ b/test/functional/pipeline.ts @@ -355,7 +355,7 @@ describe("pipeline", function () { }); it("should reload scripts on redis restart (reconnect)", async function () { - const redis = new Redis(); + const redis = new Redis({ connectionName: "load-script-on-reconnect" }); const redis2 = new Redis(); redis.defineCommand("exeecafterreconnect", { numberOfKeys: 0, @@ -366,11 +366,19 @@ describe("pipeline", function () { expect(err).to.equal(null); expect(res).to.equal("OK"); - const clientId = await redis.client("id"); + const client = await redis.client("list").then((clients) => { + const myInfo = clients + .split("\n") + .find((client) => client.includes("load-script-on-reconnect")); + + const match = / addr=([^ ]+)/.exec(myInfo); + if (match) return match[1]; + }); + await redis2 .pipeline([ ["script", "flush"], - ["client", "kill", "id", clientId], + ["client", "kill", client], ]) .exec();