Skip to content

Commit

Permalink
Node: Increase times for SCRIPT KILL tests to avoid flakeyness
Browse files Browse the repository at this point in the history
Signed-off-by: barshaul <[email protected]>
  • Loading branch information
barshaul committed Nov 6, 2024
1 parent f0fbaea commit de41090
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 8 deletions.
15 changes: 11 additions & 4 deletions node/tests/GlideClient.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1481,7 +1481,7 @@ describe("GlideClient", () => {

// Create a long-running script
const longScript = new Script(
createLongRunningLuaScript(5, false),
createLongRunningLuaScript(10, false),
);

try {
Expand All @@ -1495,16 +1495,18 @@ describe("GlideClient", () => {
);

let killed = false;
let timeout = 4000;
let timeout = 5000;
let last_err;
await new Promise((resolve) => setTimeout(resolve, 1000));

while (timeout >= 0) {
try {
expect(await client1.scriptKill()).toEqual("OK");
killed = true;
break;
} catch {
} catch (err) {
// do nothing
last_err = err;
}

await new Promise((resolve) =>
Expand All @@ -1513,7 +1515,12 @@ describe("GlideClient", () => {
timeout -= 500;
}

expect(killed).toBeTruthy();
if (!killed) {
throw new Error(
`Expected the script to be killed. Last error=${last_err}`,
);
}

await promise;
} finally {
await waitForScriptNotBusy(client1);
Expand Down
15 changes: 11 additions & 4 deletions node/tests/GlideClusterClient.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1949,7 +1949,7 @@ describe("GlideClusterClient", () => {

// Create a long-running script
const longScript = new Script(
createLongRunningLuaScript(5, false),
createLongRunningLuaScript(10, false),
);

try {
Expand All @@ -1963,16 +1963,18 @@ describe("GlideClusterClient", () => {
);

let killed = false;
let timeout = 4000;
let timeout = 5000;
let last_err;
await new Promise((resolve) => setTimeout(resolve, 1000));

while (timeout >= 0) {
try {
expect(await client1.scriptKill()).toEqual("OK");
killed = true;
break;
} catch {
} catch (err) {
// do nothing
last_err = err;
}

await new Promise((resolve) =>
Expand All @@ -1981,7 +1983,12 @@ describe("GlideClusterClient", () => {
timeout -= 500;
}

expect(killed).toBeTruthy();
if (!killed) {
throw new Error(
`Expected the script to be killed. Last error=${last_err}`,
);
}

await promise;
} finally {
await waitForScriptNotBusy(client1);
Expand Down

0 comments on commit de41090

Please sign in to comment.