diff --git a/test/functional/pipeline.ts b/test/functional/pipeline.ts index 4b2ae4aa0..cd0228cbe 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,13 +366,17 @@ describe("pipeline", function () { expect(err).to.equal(null); expect(res).to.equal("OK"); - const clientId = await redis.client("id"); - await redis2 - .pipeline([ - ["script", "flush"], - ["client", "kill", "id", clientId], - ]) - .exec(); + 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.script("flush"); + await redis2.client("kill", "addr", client); // Wait for reconnect, at the moment scripts are not loaded // if the pipeline starts before ioredis reconnects @@ -381,6 +385,7 @@ describe("pipeline", function () { const [[err2, res2]] = await redis .multi([["exeecafterreconnect"]]) .exec(); + expect(err2).to.equal(null); expect(res2).to.equal("OK"); redis.disconnect();