Skip to content

Commit

Permalink
test: Make the reconnect test compatible with redis lower v5
Browse files Browse the repository at this point in the history
  • Loading branch information
marcbachmann committed Jan 31, 2022
1 parent 94bafe5 commit 020bac9
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions test/functional/pipeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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();

Expand Down

0 comments on commit 020bac9

Please sign in to comment.