1
0
mirror of https://github.com/redis/node-redis.git synced 2025-12-14 09:42:12 +03:00

tests: Adjust scenario tests according to latest maint naming changes (#3090)

* rename maint options according to the latest client options
* adjust env variables
cae repo uses RE_FAULT_INJECTOR_URL for fault injector
DATABASE_NAME is needed to choose from the many databases in cae
* fix connection cleanup test
This commit is contained in:
Nikolay Karadzhov
2025-10-06 18:30:18 +03:00
committed by GitHub
parent 0438865b8a
commit adb19c5c5f
9 changed files with 419 additions and 209 deletions

View File

@@ -98,49 +98,12 @@ describe("Push Notifications", () => {
);
});
it("should receive FAILING_OVER and FAILED_OVER push notifications", async () => {
const notifications: Array<DiagnosticsEvent["type"]> = [
"FAILING_OVER",
"FAILED_OVER",
];
const diagnosticsMap: Record<DiagnosticsEvent["type"], number> = {};
onMessageHandler = createNotificationMessageHandler(
diagnosticsMap,
notifications
);
diagnostics_channel.subscribe("redis.maintenance", onMessageHandler);
const { action_id: failoverActionId } =
await faultInjectorClient.triggerAction({
type: "failover",
parameters: {
bdb_id: clientConfig.bdbId.toString(),
cluster_index: 0,
},
});
await faultInjectorClient.waitForAction(failoverActionId);
assert.strictEqual(
diagnosticsMap.FAILING_OVER,
1,
"Should have received exactly one FAILING_OVER notification"
);
assert.strictEqual(
diagnosticsMap.FAILED_OVER,
1,
"Should have received exactly one FAILED_OVER notification"
);
});
});
describe("Push Notifications Disabled - Client", () => {
beforeEach(async () => {
client = await createTestClient(clientConfig, {
maintPushNotifications: "disabled",
maintNotifications: "disabled",
});
client.on("error", (_err) => {
@@ -192,43 +155,6 @@ describe("Push Notifications", () => {
);
});
it("should NOT receive FAILING_OVER and FAILED_OVER push notifications", async () => {
const notifications: Array<DiagnosticsEvent["type"]> = [
"FAILING_OVER",
"FAILED_OVER",
];
const diagnosticsMap: Record<DiagnosticsEvent["type"], number> = {};
onMessageHandler = createNotificationMessageHandler(
diagnosticsMap,
notifications
);
diagnostics_channel.subscribe("redis.maintenance", onMessageHandler);
const { action_id: failoverActionId } =
await faultInjectorClient.triggerAction({
type: "failover",
parameters: {
bdb_id: clientConfig.bdbId.toString(),
cluster_index: 0,
},
});
await faultInjectorClient.waitForAction(failoverActionId);
assert.strictEqual(
diagnosticsMap.FAILING_OVER,
undefined,
"Should have received exactly one FAILING_OVER notification"
);
assert.strictEqual(
diagnosticsMap.FAILED_OVER,
undefined,
"Should have received exactly one FAILED_OVER notification"
);
});
});
describe("Push Notifications Disabled - Server", () => {
@@ -308,42 +234,5 @@ describe("Push Notifications", () => {
);
});
it("should NOT receive FAILING_OVER and FAILED_OVER push notifications", async () => {
const notifications: Array<DiagnosticsEvent["type"]> = [
"FAILING_OVER",
"FAILED_OVER",
];
const diagnosticsMap: Record<DiagnosticsEvent["type"], number> = {};
onMessageHandler = createNotificationMessageHandler(
diagnosticsMap,
notifications
);
diagnostics_channel.subscribe("redis.maintenance", onMessageHandler);
const { action_id: failoverActionId } =
await faultInjectorClient.triggerAction({
type: "failover",
parameters: {
bdb_id: clientConfig.bdbId.toString(),
cluster_index: 0,
},
});
await faultInjectorClient.waitForAction(failoverActionId);
assert.strictEqual(
diagnosticsMap.FAILING_OVER,
undefined,
"Should have received exactly one FAILING_OVER notification"
);
assert.strictEqual(
diagnosticsMap.FAILED_OVER,
undefined,
"Should have received exactly one FAILED_OVER notification"
);
});
});
});