From 6c2f69f70d683aa6f2b3476a805b300eeebb22e1 Mon Sep 17 00:00:00 2001 From: Avital-Fine Date: Mon, 28 Feb 2022 22:53:28 +0100 Subject: [PATCH 01/13] Support CLUSTER commands --- .../lib/commands/CLUSTER_BUMPEPOCH.spec.ts | 11 ++++++++++ .../client/lib/commands/CLUSTER_BUMPEPOCH.ts | 5 +++++ .../CLUSTER_COUNT-FAILURE-REPORTS.spec.ts | 11 ++++++++++ .../commands/CLUSTER_COUNT-FAILURE-REPORTS.ts | 5 +++++ .../commands/CLUSTER_COUNTKEYSINSLOT.spec.ts | 11 ++++++++++ .../lib/commands/CLUSTER_COUNTKEYSINSLOT.ts | 5 +++++ .../lib/commands/CLUSTER_DELSLOTS.spec.ts | 11 ++++++++++ .../client/lib/commands/CLUSTER_DELSLOTS.ts | 7 +++++++ .../lib/commands/CLUSTER_FAILOVER.spec.ts | 20 +++++++++++++++++++ .../client/lib/commands/CLUSTER_FAILOVER.ts | 16 +++++++++++++++ .../lib/commands/CLUSTER_FORGET.spec.ts | 11 ++++++++++ .../client/lib/commands/CLUSTER_FORGET.ts | 5 +++++ .../lib/commands/CLUSTER_KEYSLOT.spec.ts | 11 ++++++++++ .../client/lib/commands/CLUSTER_KEYSLOT.ts | 5 +++++ .../client/lib/commands/CLUSTER_MYID.spec.ts | 11 ++++++++++ packages/client/lib/commands/CLUSTER_MYID.ts | 5 +++++ .../lib/commands/CLUSTER_REPLICAS.spec.ts | 11 ++++++++++ .../client/lib/commands/CLUSTER_REPLICAS.ts | 5 +++++ .../lib/commands/CLUSTER_REPLICATE.spec.ts | 11 ++++++++++ .../client/lib/commands/CLUSTER_REPLICATE.ts | 5 +++++ .../lib/commands/CLUSTER_SAVECONFIG.spec.ts | 11 ++++++++++ .../client/lib/commands/CLUSTER_SAVECONFIG.ts | 5 +++++ .../commands/CLUSTER_SET-CONFIG-EPOCH.spec.ts | 11 ++++++++++ .../lib/commands/CLUSTER_SET-CONFIG-EPOCH.ts | 5 +++++ .../lib/commands/CLUSTER_SLAVES.spec.ts | 11 ++++++++++ .../client/lib/commands/CLUSTER_SLAVES.ts | 5 +++++ 26 files changed, 230 insertions(+) create mode 100644 packages/client/lib/commands/CLUSTER_BUMPEPOCH.spec.ts create mode 100644 packages/client/lib/commands/CLUSTER_BUMPEPOCH.ts create mode 100644 packages/client/lib/commands/CLUSTER_COUNT-FAILURE-REPORTS.spec.ts create mode 100644 packages/client/lib/commands/CLUSTER_COUNT-FAILURE-REPORTS.ts create mode 100644 packages/client/lib/commands/CLUSTER_COUNTKEYSINSLOT.spec.ts create mode 100644 packages/client/lib/commands/CLUSTER_COUNTKEYSINSLOT.ts create mode 100644 packages/client/lib/commands/CLUSTER_DELSLOTS.spec.ts create mode 100644 packages/client/lib/commands/CLUSTER_DELSLOTS.ts create mode 100644 packages/client/lib/commands/CLUSTER_FAILOVER.spec.ts create mode 100644 packages/client/lib/commands/CLUSTER_FAILOVER.ts create mode 100644 packages/client/lib/commands/CLUSTER_FORGET.spec.ts create mode 100644 packages/client/lib/commands/CLUSTER_FORGET.ts create mode 100644 packages/client/lib/commands/CLUSTER_KEYSLOT.spec.ts create mode 100644 packages/client/lib/commands/CLUSTER_KEYSLOT.ts create mode 100644 packages/client/lib/commands/CLUSTER_MYID.spec.ts create mode 100644 packages/client/lib/commands/CLUSTER_MYID.ts create mode 100644 packages/client/lib/commands/CLUSTER_REPLICAS.spec.ts create mode 100644 packages/client/lib/commands/CLUSTER_REPLICAS.ts create mode 100644 packages/client/lib/commands/CLUSTER_REPLICATE.spec.ts create mode 100644 packages/client/lib/commands/CLUSTER_REPLICATE.ts create mode 100644 packages/client/lib/commands/CLUSTER_SAVECONFIG.spec.ts create mode 100644 packages/client/lib/commands/CLUSTER_SAVECONFIG.ts create mode 100644 packages/client/lib/commands/CLUSTER_SET-CONFIG-EPOCH.spec.ts create mode 100644 packages/client/lib/commands/CLUSTER_SET-CONFIG-EPOCH.ts create mode 100644 packages/client/lib/commands/CLUSTER_SLAVES.spec.ts create mode 100644 packages/client/lib/commands/CLUSTER_SLAVES.ts diff --git a/packages/client/lib/commands/CLUSTER_BUMPEPOCH.spec.ts b/packages/client/lib/commands/CLUSTER_BUMPEPOCH.spec.ts new file mode 100644 index 00000000000..7841b43347d --- /dev/null +++ b/packages/client/lib/commands/CLUSTER_BUMPEPOCH.spec.ts @@ -0,0 +1,11 @@ +import { strict as assert } from 'assert'; +import { transformArguments } from './CLUSTER_BUMPEPOCH'; + +describe('CLUSTER BUMPEPOCH', () => { + it('transformArguments', () => { + assert.deepEqual( + transformArguments(), + ['CLUSTER', 'BUMPEPOCH'] + ); + }); +}); diff --git a/packages/client/lib/commands/CLUSTER_BUMPEPOCH.ts b/packages/client/lib/commands/CLUSTER_BUMPEPOCH.ts new file mode 100644 index 00000000000..d2b1552e1b0 --- /dev/null +++ b/packages/client/lib/commands/CLUSTER_BUMPEPOCH.ts @@ -0,0 +1,5 @@ +export function transformArguments(): Array { + return ['CLUSTER', 'BUMPEPOCH']; +} + +export declare function transformReply(): string; diff --git a/packages/client/lib/commands/CLUSTER_COUNT-FAILURE-REPORTS.spec.ts b/packages/client/lib/commands/CLUSTER_COUNT-FAILURE-REPORTS.spec.ts new file mode 100644 index 00000000000..3368a783f94 --- /dev/null +++ b/packages/client/lib/commands/CLUSTER_COUNT-FAILURE-REPORTS.spec.ts @@ -0,0 +1,11 @@ +import { strict as assert } from 'assert'; +import { transformArguments } from './CLUSTER_COUNT-FAILURE-REPORTS'; + +describe('CLUSTER COUNT-FAILURE-REPORTS', () => { + it('transformArguments', () => { + assert.deepEqual( + transformArguments('1'), + ['CLUSTER', 'COUNT-FAILURE-REPORTS', '1'] + ); + }); +}); diff --git a/packages/client/lib/commands/CLUSTER_COUNT-FAILURE-REPORTS.ts b/packages/client/lib/commands/CLUSTER_COUNT-FAILURE-REPORTS.ts new file mode 100644 index 00000000000..18b36948964 --- /dev/null +++ b/packages/client/lib/commands/CLUSTER_COUNT-FAILURE-REPORTS.ts @@ -0,0 +1,5 @@ +export function transformArguments(nodeId: string): Array { + return ['CLUSTER', 'COUNT-FAILURE-REPORTS', nodeId]; +} + +export declare function transformReply(): number; diff --git a/packages/client/lib/commands/CLUSTER_COUNTKEYSINSLOT.spec.ts b/packages/client/lib/commands/CLUSTER_COUNTKEYSINSLOT.spec.ts new file mode 100644 index 00000000000..26659727310 --- /dev/null +++ b/packages/client/lib/commands/CLUSTER_COUNTKEYSINSLOT.spec.ts @@ -0,0 +1,11 @@ +import { strict as assert } from 'assert'; +import { transformArguments } from './CLUSTER_COUNTKEYSINSLOT'; + +describe('CLUSTER COUNTKEYSINSLOT', () => { + it('transformArguments', () => { + assert.deepEqual( + transformArguments(1), + ['CLUSTER', 'COUNTKEYSINSLOT', '1'] + ); + }); +}); diff --git a/packages/client/lib/commands/CLUSTER_COUNTKEYSINSLOT.ts b/packages/client/lib/commands/CLUSTER_COUNTKEYSINSLOT.ts new file mode 100644 index 00000000000..900af70d738 --- /dev/null +++ b/packages/client/lib/commands/CLUSTER_COUNTKEYSINSLOT.ts @@ -0,0 +1,5 @@ +export function transformArguments(slot: number): Array { + return ['CLUSTER', 'COUNTKEYSINSLOT', slot.toString()]; +} + +export declare function transformReply(): number; diff --git a/packages/client/lib/commands/CLUSTER_DELSLOTS.spec.ts b/packages/client/lib/commands/CLUSTER_DELSLOTS.spec.ts new file mode 100644 index 00000000000..c47a24d7984 --- /dev/null +++ b/packages/client/lib/commands/CLUSTER_DELSLOTS.spec.ts @@ -0,0 +1,11 @@ +import { strict as assert } from 'assert'; +import { transformArguments } from './CLUSTER_DELSLOTS'; + +describe('CLUSTER DELSLOTS', () => { + it('simple', () => { + assert.deepEqual( + transformArguments('1'), + ['CLUSTER', 'DELSLOTS', '1'] + ); + }); +}); diff --git a/packages/client/lib/commands/CLUSTER_DELSLOTS.ts b/packages/client/lib/commands/CLUSTER_DELSLOTS.ts new file mode 100644 index 00000000000..937a97daeca --- /dev/null +++ b/packages/client/lib/commands/CLUSTER_DELSLOTS.ts @@ -0,0 +1,7 @@ +export function transformArguments(...slots: string[]): Array { + const args = ['CLUSTER', 'DELSLOTS']; + args.push(...slots); + return args; +} + +export declare function transformReply(): string; diff --git a/packages/client/lib/commands/CLUSTER_FAILOVER.spec.ts b/packages/client/lib/commands/CLUSTER_FAILOVER.spec.ts new file mode 100644 index 00000000000..66a050be18e --- /dev/null +++ b/packages/client/lib/commands/CLUSTER_FAILOVER.spec.ts @@ -0,0 +1,20 @@ +import { strict as assert } from 'assert'; +import { FailoverModes, transformArguments } from './CLUSTER_FAILOVER'; + +describe('CLUSTER FAILOVER', () => { + describe('transformArguments', () => { + it('simple', () => { + assert.deepEqual( + transformArguments(), + ['CLUSTER', 'FAILOVER'] + ); + }); + it('with mode', () => { + assert.deepEqual( + transformArguments(FailoverModes.FORCE), + ['CLUSTER', 'FAILOVER', 'FORCE'] + ); + }); + }); + +}); diff --git a/packages/client/lib/commands/CLUSTER_FAILOVER.ts b/packages/client/lib/commands/CLUSTER_FAILOVER.ts new file mode 100644 index 00000000000..c73403885f5 --- /dev/null +++ b/packages/client/lib/commands/CLUSTER_FAILOVER.ts @@ -0,0 +1,16 @@ +export enum FailoverModes { + FORCE = 'FORCE', + TAKEOVER = 'TAKEOVER' +} + +export function transformArguments(mode?: FailoverModes): Array { + const args = ['CLUSTER', 'FAILOVER']; + + if (mode) { + args.push(mode); + } + + return args; +} + +export declare function transformReply(): string; diff --git a/packages/client/lib/commands/CLUSTER_FORGET.spec.ts b/packages/client/lib/commands/CLUSTER_FORGET.spec.ts new file mode 100644 index 00000000000..cadcdb678f3 --- /dev/null +++ b/packages/client/lib/commands/CLUSTER_FORGET.spec.ts @@ -0,0 +1,11 @@ +import { strict as assert } from 'assert'; +import { transformArguments } from './CLUSTER_FORGET'; + +describe('CLUSTER FORGET', () => { + it('transformArguments', () => { + assert.deepEqual( + transformArguments('0'), + ['CLUSTER', 'FORGET', '0'] + ); + }); +}); diff --git a/packages/client/lib/commands/CLUSTER_FORGET.ts b/packages/client/lib/commands/CLUSTER_FORGET.ts new file mode 100644 index 00000000000..7f0e6f00c7c --- /dev/null +++ b/packages/client/lib/commands/CLUSTER_FORGET.ts @@ -0,0 +1,5 @@ +export function transformArguments(nodeId: string): Array { + return ['CLUSTER', 'FORGET', nodeId]; +} + +export declare function transformReply(): string; diff --git a/packages/client/lib/commands/CLUSTER_KEYSLOT.spec.ts b/packages/client/lib/commands/CLUSTER_KEYSLOT.spec.ts new file mode 100644 index 00000000000..f71468112e1 --- /dev/null +++ b/packages/client/lib/commands/CLUSTER_KEYSLOT.spec.ts @@ -0,0 +1,11 @@ +import { strict as assert } from 'assert'; +import { transformArguments } from './CLUSTER_KEYSLOT'; + +describe('CLUSTER KEYSLOT', () => { + it('transformArguments', () => { + assert.deepEqual( + transformArguments('key'), + ['CLUSTER', 'KEYSLOT', 'key'] + ); + }); +}); diff --git a/packages/client/lib/commands/CLUSTER_KEYSLOT.ts b/packages/client/lib/commands/CLUSTER_KEYSLOT.ts new file mode 100644 index 00000000000..9ee881cadf4 --- /dev/null +++ b/packages/client/lib/commands/CLUSTER_KEYSLOT.ts @@ -0,0 +1,5 @@ +export function transformArguments(key: string): Array { + return ['CLUSTER', 'KEYSLOT', key]; +} + +export declare function transformReply(): number; diff --git a/packages/client/lib/commands/CLUSTER_MYID.spec.ts b/packages/client/lib/commands/CLUSTER_MYID.spec.ts new file mode 100644 index 00000000000..c4bb3536274 --- /dev/null +++ b/packages/client/lib/commands/CLUSTER_MYID.spec.ts @@ -0,0 +1,11 @@ +import { strict as assert } from 'assert'; +import { transformArguments } from './CLUSTER_MYID'; + +describe('CLUSTER MYID', () => { + it('transformArguments', () => { + assert.deepEqual( + transformArguments(), + ['CLUSTER', 'MYID'] + ); + }); +}); diff --git a/packages/client/lib/commands/CLUSTER_MYID.ts b/packages/client/lib/commands/CLUSTER_MYID.ts new file mode 100644 index 00000000000..2b61684634d --- /dev/null +++ b/packages/client/lib/commands/CLUSTER_MYID.ts @@ -0,0 +1,5 @@ +export function transformArguments(): Array { + return ['CLUSTER', 'MYID']; +} + +export declare function transformReply(): string; diff --git a/packages/client/lib/commands/CLUSTER_REPLICAS.spec.ts b/packages/client/lib/commands/CLUSTER_REPLICAS.spec.ts new file mode 100644 index 00000000000..6c902dc0d82 --- /dev/null +++ b/packages/client/lib/commands/CLUSTER_REPLICAS.spec.ts @@ -0,0 +1,11 @@ +import { strict as assert } from 'assert'; +import { transformArguments } from './CLUSTER_REPLICAS'; + +describe('CLUSTER REPLICAS', () => { + it('transformArguments', () => { + assert.deepEqual( + transformArguments('0'), + ['CLUSTER', 'REPLICAS', '0'] + ); + }); +}); diff --git a/packages/client/lib/commands/CLUSTER_REPLICAS.ts b/packages/client/lib/commands/CLUSTER_REPLICAS.ts new file mode 100644 index 00000000000..80dbbffe831 --- /dev/null +++ b/packages/client/lib/commands/CLUSTER_REPLICAS.ts @@ -0,0 +1,5 @@ +export function transformArguments(nodeId: string): Array { + return ['CLUSTER', 'REPLICAS', nodeId]; +} + +export { transformReply } from './CLUSTER_NODES' diff --git a/packages/client/lib/commands/CLUSTER_REPLICATE.spec.ts b/packages/client/lib/commands/CLUSTER_REPLICATE.spec.ts new file mode 100644 index 00000000000..926b7dd0a77 --- /dev/null +++ b/packages/client/lib/commands/CLUSTER_REPLICATE.spec.ts @@ -0,0 +1,11 @@ +import { strict as assert } from 'assert'; +import { transformArguments } from './CLUSTER_REPLICATE'; + +describe('CLUSTER REPLICATE', () => { + it('transformArguments', () => { + assert.deepEqual( + transformArguments('0'), + ['CLUSTER', 'REPLICATE', '0'] + ); + }); +}); diff --git a/packages/client/lib/commands/CLUSTER_REPLICATE.ts b/packages/client/lib/commands/CLUSTER_REPLICATE.ts new file mode 100644 index 00000000000..453865344fe --- /dev/null +++ b/packages/client/lib/commands/CLUSTER_REPLICATE.ts @@ -0,0 +1,5 @@ +export function transformArguments(nodeId: string): Array { + return ['CLUSTER', 'REPLICATE', nodeId]; +} + +export declare function transformReply(): string; diff --git a/packages/client/lib/commands/CLUSTER_SAVECONFIG.spec.ts b/packages/client/lib/commands/CLUSTER_SAVECONFIG.spec.ts new file mode 100644 index 00000000000..07a08293d20 --- /dev/null +++ b/packages/client/lib/commands/CLUSTER_SAVECONFIG.spec.ts @@ -0,0 +1,11 @@ +import { strict as assert } from 'assert'; +import { transformArguments } from './CLUSTER_SAVECONFIG'; + +describe('CLUSTER SAVECONFIG', () => { + it('transformArguments', () => { + assert.deepEqual( + transformArguments(), + ['CLUSTER', 'SAVECONFIG'] + ); + }); +}); diff --git a/packages/client/lib/commands/CLUSTER_SAVECONFIG.ts b/packages/client/lib/commands/CLUSTER_SAVECONFIG.ts new file mode 100644 index 00000000000..68e8d6e4cab --- /dev/null +++ b/packages/client/lib/commands/CLUSTER_SAVECONFIG.ts @@ -0,0 +1,5 @@ +export function transformArguments(): Array { + return ['CLUSTER', 'SAVECONFIG']; +} + +export declare function transformReply(): string; diff --git a/packages/client/lib/commands/CLUSTER_SET-CONFIG-EPOCH.spec.ts b/packages/client/lib/commands/CLUSTER_SET-CONFIG-EPOCH.spec.ts new file mode 100644 index 00000000000..dd241574168 --- /dev/null +++ b/packages/client/lib/commands/CLUSTER_SET-CONFIG-EPOCH.spec.ts @@ -0,0 +1,11 @@ +import { strict as assert } from 'assert'; +import { transformArguments } from './CLUSTER_SET-CONFIG-EPOCH'; + +describe('CLUSTER SET-CONFIG-EPOCH', () => { + it('transformArguments', () => { + assert.deepEqual( + transformArguments(0), + ['CLUSTER', 'SET-CONFIG-EPOCH', '0'] + ); + }); +}); diff --git a/packages/client/lib/commands/CLUSTER_SET-CONFIG-EPOCH.ts b/packages/client/lib/commands/CLUSTER_SET-CONFIG-EPOCH.ts new file mode 100644 index 00000000000..a697edf01c4 --- /dev/null +++ b/packages/client/lib/commands/CLUSTER_SET-CONFIG-EPOCH.ts @@ -0,0 +1,5 @@ +export function transformArguments(configEpoch: number): Array { + return ['CLUSTER', 'SET-CONFIG-EPOCH', configEpoch.toString()]; +} + +export declare function transformReply(): string; diff --git a/packages/client/lib/commands/CLUSTER_SLAVES.spec.ts b/packages/client/lib/commands/CLUSTER_SLAVES.spec.ts new file mode 100644 index 00000000000..fba6f52ddd2 --- /dev/null +++ b/packages/client/lib/commands/CLUSTER_SLAVES.spec.ts @@ -0,0 +1,11 @@ +import { strict as assert } from 'assert'; +import { transformArguments } from './CLUSTER_SLAVES'; + +describe('CLUSTER SLAVES', () => { + it('transformArguments', () => { + assert.deepEqual( + transformArguments('0'), + ['CLUSTER', 'SLAVES', '0'] + ); + }); +}); diff --git a/packages/client/lib/commands/CLUSTER_SLAVES.ts b/packages/client/lib/commands/CLUSTER_SLAVES.ts new file mode 100644 index 00000000000..1ae55f76401 --- /dev/null +++ b/packages/client/lib/commands/CLUSTER_SLAVES.ts @@ -0,0 +1,5 @@ +export function transformArguments(nodeId: string): Array { + return ['CLUSTER', 'SLAVES', nodeId]; +} + +export { transformReply } from './CLUSTER_NODES' From 7403892bfa48c6a8ff45870f4f16c531b6f81b62 Mon Sep 17 00:00:00 2001 From: Avital-Fine Date: Tue, 1 Mar 2022 12:40:11 +0100 Subject: [PATCH 02/13] add some client tests --- packages/client/lib/cluster/commands.ts | 21 +++++++++++++++++++ .../lib/commands/CLUSTER_BUMPEPOCH.spec.ts | 10 ++++++++- .../CLUSTER_COUNT-FAILURE-REPORTS.spec.ts | 11 +++++++++- .../client/lib/commands/CLUSTER_INFO.spec.ts | 10 ++++++++- .../client/lib/commands/CLUSTER_MYID.spec.ts | 10 ++++++++- .../client/lib/commands/CLUSTER_RESET.spec.ts | 10 ++++++++- .../lib/commands/CLUSTER_SAVECONFIG.spec.ts | 10 ++++++++- .../commands/CLUSTER_SET-CONFIG-EPOCH.spec.ts | 14 ++++++++++++- 8 files changed, 89 insertions(+), 7 deletions(-) diff --git a/packages/client/lib/cluster/commands.ts b/packages/client/lib/cluster/commands.ts index 4b2aba6a7ae..0f638831550 100644 --- a/packages/client/lib/cluster/commands.ts +++ b/packages/client/lib/cluster/commands.ts @@ -10,6 +10,13 @@ import * as BRPOP from '../commands/BRPOP'; import * as BRPOPLPUSH from '../commands/BRPOPLPUSH'; import * as BZPOPMAX from '../commands/BZPOPMAX'; import * as BZPOPMIN from '../commands/BZPOPMIN'; +import * as CLUSTER_BUMPEPOCH from '../commands/CLUSTER_BUMPEPOCH'; +import * as CLUSTER_COUNT_FAILURE_REPORTS from '../commands/CLUSTER_COUNT-FAILURE-REPORTS'; +import * as CLUSTER_INFO from '../commands/CLUSTER_INFO'; +import * as CLUSTER_MYID from '../commands/CLUSTER_MYID'; +import * as CLUSTER_RESET from '../commands/CLUSTER_RESET'; +import * as CLUSTER_SAVECONFIG from '../commands/CLUSTER_SAVECONFIG'; +import * as CLUSTER_SET_CONFIG_EPOCH from '../commands/CLUSTER_SET-CONFIG-EPOCH'; import * as COPY from '../commands/COPY'; import * as DECR from '../commands/DECR'; import * as DECRBY from '../commands/DECRBY'; @@ -199,6 +206,20 @@ export default { bzPopMax: BZPOPMAX, BZPOPMIN, bzPopMin: BZPOPMIN, + CLUSTER_BUMPEPOCH, + clusterBumpEpoch: CLUSTER_BUMPEPOCH, + CLUSTER_COUNT_FAILURE_REPORTS, + clusterCountFailureReports: CLUSTER_COUNT_FAILURE_REPORTS, + CLUSTER_INFO, + clusterInfo: CLUSTER_INFO, + CLUSTER_MYID, + clusterMyId: CLUSTER_MYID, + CLUSTER_RESET, + clusterReset: CLUSTER_RESET, + CLUSTER_SAVECONFIG, + clusterSaveConfig: CLUSTER_SAVECONFIG, + CLUSTER_SET_CONFIG_EPOCH, + clusterSetConfigEpoch: CLUSTER_SET_CONFIG_EPOCH, COPY, copy: COPY, DECR, diff --git a/packages/client/lib/commands/CLUSTER_BUMPEPOCH.spec.ts b/packages/client/lib/commands/CLUSTER_BUMPEPOCH.spec.ts index 7841b43347d..ee2ed37f8da 100644 --- a/packages/client/lib/commands/CLUSTER_BUMPEPOCH.spec.ts +++ b/packages/client/lib/commands/CLUSTER_BUMPEPOCH.spec.ts @@ -1,11 +1,19 @@ import { strict as assert } from 'assert'; +import testUtils, { GLOBAL } from '../test-utils'; import { transformArguments } from './CLUSTER_BUMPEPOCH'; -describe('CLUSTER BUMPEPOCH', () => { +describe.only('CLUSTER BUMPEPOCH', () => { it('transformArguments', () => { assert.deepEqual( transformArguments(), ['CLUSTER', 'BUMPEPOCH'] ); }); + + testUtils.testWithCluster('cluster.clusterBumpEpoch', async cluster => { + assert.equal( + typeof await cluster.clusterBumpEpoch(), + 'string' + ); + }, GLOBAL.CLUSTERS.OPEN); }); diff --git a/packages/client/lib/commands/CLUSTER_COUNT-FAILURE-REPORTS.spec.ts b/packages/client/lib/commands/CLUSTER_COUNT-FAILURE-REPORTS.spec.ts index 3368a783f94..af0df7bf5db 100644 --- a/packages/client/lib/commands/CLUSTER_COUNT-FAILURE-REPORTS.spec.ts +++ b/packages/client/lib/commands/CLUSTER_COUNT-FAILURE-REPORTS.spec.ts @@ -1,11 +1,20 @@ import { strict as assert } from 'assert'; +import testUtils, { GLOBAL } from '../test-utils'; import { transformArguments } from './CLUSTER_COUNT-FAILURE-REPORTS'; -describe('CLUSTER COUNT-FAILURE-REPORTS', () => { +describe.only('CLUSTER COUNT-FAILURE-REPORTS', () => { it('transformArguments', () => { assert.deepEqual( transformArguments('1'), ['CLUSTER', 'COUNT-FAILURE-REPORTS', '1'] ); }); + + testUtils.testWithCluster('cluster.clusterCountFailureReports', async cluster => { + const id: string = await cluster.clusterMyId(); + assert.equal( + await cluster.clusterCountFailureReports(id), + 0 + ); + }, GLOBAL.CLUSTERS.OPEN); }); diff --git a/packages/client/lib/commands/CLUSTER_INFO.spec.ts b/packages/client/lib/commands/CLUSTER_INFO.spec.ts index a4def45cb79..f9cfdd19cf0 100644 --- a/packages/client/lib/commands/CLUSTER_INFO.spec.ts +++ b/packages/client/lib/commands/CLUSTER_INFO.spec.ts @@ -1,7 +1,8 @@ import { strict as assert } from 'assert'; +import testUtils, { GLOBAL } from '../test-utils'; import { transformArguments, transformReply } from './CLUSTER_INFO'; -describe('CLUSTER INFO', () => { +describe.only('CLUSTER INFO', () => { it('transformArguments', () => { assert.deepEqual( transformArguments(), @@ -43,4 +44,11 @@ describe('CLUSTER INFO', () => { } ); }); + + testUtils.testWithCluster('cluster.clusterInfo', async cluster => { + assert.notEqual( + await cluster.clusterInfo(), + null + ); + }, GLOBAL.CLUSTERS.OPEN); }); diff --git a/packages/client/lib/commands/CLUSTER_MYID.spec.ts b/packages/client/lib/commands/CLUSTER_MYID.spec.ts index c4bb3536274..04b61b10ad4 100644 --- a/packages/client/lib/commands/CLUSTER_MYID.spec.ts +++ b/packages/client/lib/commands/CLUSTER_MYID.spec.ts @@ -1,11 +1,19 @@ import { strict as assert } from 'assert'; +import testUtils, { GLOBAL } from '../test-utils'; import { transformArguments } from './CLUSTER_MYID'; -describe('CLUSTER MYID', () => { +describe.only('CLUSTER MYID', () => { it('transformArguments', () => { assert.deepEqual( transformArguments(), ['CLUSTER', 'MYID'] ); }); + + testUtils.testWithCluster('cluster.clusterMyId', async cluster => { + assert.notEqual( + await cluster.clusterMyId(), + null + ); + }, GLOBAL.CLUSTERS.OPEN); }); diff --git a/packages/client/lib/commands/CLUSTER_RESET.spec.ts b/packages/client/lib/commands/CLUSTER_RESET.spec.ts index c077e7f8874..c260dd37ab9 100644 --- a/packages/client/lib/commands/CLUSTER_RESET.spec.ts +++ b/packages/client/lib/commands/CLUSTER_RESET.spec.ts @@ -1,7 +1,8 @@ import { strict as assert } from 'assert'; +import testUtils, { GLOBAL } from '../test-utils'; import { transformArguments } from './CLUSTER_RESET'; -describe('CLUSTER RESET', () => { +describe.only('CLUSTER RESET', () => { describe('transformArguments', () => { it('simple', () => { assert.deepEqual( @@ -24,4 +25,11 @@ describe('CLUSTER RESET', () => { ); }); }); + + testUtils.testWithCluster('cluster.clusterReset', async cluster => { + assert.equal( + await cluster.clusterReset('SOFT'), + 'OK' + ); + }, GLOBAL.CLUSTERS.OPEN); }); diff --git a/packages/client/lib/commands/CLUSTER_SAVECONFIG.spec.ts b/packages/client/lib/commands/CLUSTER_SAVECONFIG.spec.ts index 07a08293d20..a01a67e6b1e 100644 --- a/packages/client/lib/commands/CLUSTER_SAVECONFIG.spec.ts +++ b/packages/client/lib/commands/CLUSTER_SAVECONFIG.spec.ts @@ -1,11 +1,19 @@ import { strict as assert } from 'assert'; +import testUtils, { GLOBAL } from '../test-utils'; import { transformArguments } from './CLUSTER_SAVECONFIG'; -describe('CLUSTER SAVECONFIG', () => { +describe.only('CLUSTER SAVECONFIG', () => { it('transformArguments', () => { assert.deepEqual( transformArguments(), ['CLUSTER', 'SAVECONFIG'] ); }); + + testUtils.testWithCluster('cluster.clusterSaveConfig', async cluster => { + assert.equal( + await cluster.clusterSaveConfig(), + 'OK' + ); + }, GLOBAL.CLUSTERS.OPEN); }); diff --git a/packages/client/lib/commands/CLUSTER_SET-CONFIG-EPOCH.spec.ts b/packages/client/lib/commands/CLUSTER_SET-CONFIG-EPOCH.spec.ts index dd241574168..947182629db 100644 --- a/packages/client/lib/commands/CLUSTER_SET-CONFIG-EPOCH.spec.ts +++ b/packages/client/lib/commands/CLUSTER_SET-CONFIG-EPOCH.spec.ts @@ -1,11 +1,23 @@ import { strict as assert } from 'assert'; +import testUtils, { GLOBAL } from '../test-utils'; import { transformArguments } from './CLUSTER_SET-CONFIG-EPOCH'; -describe('CLUSTER SET-CONFIG-EPOCH', () => { +describe.only('CLUSTER SET-CONFIG-EPOCH', () => { it('transformArguments', () => { assert.deepEqual( transformArguments(0), ['CLUSTER', 'SET-CONFIG-EPOCH', '0'] ); }); + + testUtils.testWithCluster('cluster.clusterSetConfigEpoch', async cluster => { + try { + assert.equal( + await cluster.clusterSetConfigEpoch(1), + 'OK' + ); + } catch (ReplyError) { + //? + } + }, GLOBAL.CLUSTERS.OPEN); }); From df76319b9918658c070b11be4e4151dffe107777 Mon Sep 17 00:00:00 2001 From: Avital-Fine Date: Tue, 1 Mar 2022 12:42:27 +0100 Subject: [PATCH 03/13] remove only --- packages/client/lib/commands/CLUSTER_BUMPEPOCH.spec.ts | 2 +- .../client/lib/commands/CLUSTER_COUNT-FAILURE-REPORTS.spec.ts | 2 +- packages/client/lib/commands/CLUSTER_INFO.spec.ts | 2 +- packages/client/lib/commands/CLUSTER_MYID.spec.ts | 2 +- packages/client/lib/commands/CLUSTER_RESET.spec.ts | 2 +- packages/client/lib/commands/CLUSTER_SAVECONFIG.spec.ts | 2 +- packages/client/lib/commands/CLUSTER_SET-CONFIG-EPOCH.spec.ts | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/client/lib/commands/CLUSTER_BUMPEPOCH.spec.ts b/packages/client/lib/commands/CLUSTER_BUMPEPOCH.spec.ts index ee2ed37f8da..de6a68c8d63 100644 --- a/packages/client/lib/commands/CLUSTER_BUMPEPOCH.spec.ts +++ b/packages/client/lib/commands/CLUSTER_BUMPEPOCH.spec.ts @@ -2,7 +2,7 @@ import { strict as assert } from 'assert'; import testUtils, { GLOBAL } from '../test-utils'; import { transformArguments } from './CLUSTER_BUMPEPOCH'; -describe.only('CLUSTER BUMPEPOCH', () => { +describe('CLUSTER BUMPEPOCH', () => { it('transformArguments', () => { assert.deepEqual( transformArguments(), diff --git a/packages/client/lib/commands/CLUSTER_COUNT-FAILURE-REPORTS.spec.ts b/packages/client/lib/commands/CLUSTER_COUNT-FAILURE-REPORTS.spec.ts index af0df7bf5db..96d1f6a8bad 100644 --- a/packages/client/lib/commands/CLUSTER_COUNT-FAILURE-REPORTS.spec.ts +++ b/packages/client/lib/commands/CLUSTER_COUNT-FAILURE-REPORTS.spec.ts @@ -2,7 +2,7 @@ import { strict as assert } from 'assert'; import testUtils, { GLOBAL } from '../test-utils'; import { transformArguments } from './CLUSTER_COUNT-FAILURE-REPORTS'; -describe.only('CLUSTER COUNT-FAILURE-REPORTS', () => { +describe('CLUSTER COUNT-FAILURE-REPORTS', () => { it('transformArguments', () => { assert.deepEqual( transformArguments('1'), diff --git a/packages/client/lib/commands/CLUSTER_INFO.spec.ts b/packages/client/lib/commands/CLUSTER_INFO.spec.ts index f9cfdd19cf0..9abe4e9fa9c 100644 --- a/packages/client/lib/commands/CLUSTER_INFO.spec.ts +++ b/packages/client/lib/commands/CLUSTER_INFO.spec.ts @@ -2,7 +2,7 @@ import { strict as assert } from 'assert'; import testUtils, { GLOBAL } from '../test-utils'; import { transformArguments, transformReply } from './CLUSTER_INFO'; -describe.only('CLUSTER INFO', () => { +describe('CLUSTER INFO', () => { it('transformArguments', () => { assert.deepEqual( transformArguments(), diff --git a/packages/client/lib/commands/CLUSTER_MYID.spec.ts b/packages/client/lib/commands/CLUSTER_MYID.spec.ts index 04b61b10ad4..d421a186771 100644 --- a/packages/client/lib/commands/CLUSTER_MYID.spec.ts +++ b/packages/client/lib/commands/CLUSTER_MYID.spec.ts @@ -2,7 +2,7 @@ import { strict as assert } from 'assert'; import testUtils, { GLOBAL } from '../test-utils'; import { transformArguments } from './CLUSTER_MYID'; -describe.only('CLUSTER MYID', () => { +describe('CLUSTER MYID', () => { it('transformArguments', () => { assert.deepEqual( transformArguments(), diff --git a/packages/client/lib/commands/CLUSTER_RESET.spec.ts b/packages/client/lib/commands/CLUSTER_RESET.spec.ts index c260dd37ab9..0887fde49f5 100644 --- a/packages/client/lib/commands/CLUSTER_RESET.spec.ts +++ b/packages/client/lib/commands/CLUSTER_RESET.spec.ts @@ -2,7 +2,7 @@ import { strict as assert } from 'assert'; import testUtils, { GLOBAL } from '../test-utils'; import { transformArguments } from './CLUSTER_RESET'; -describe.only('CLUSTER RESET', () => { +describe('CLUSTER RESET', () => { describe('transformArguments', () => { it('simple', () => { assert.deepEqual( diff --git a/packages/client/lib/commands/CLUSTER_SAVECONFIG.spec.ts b/packages/client/lib/commands/CLUSTER_SAVECONFIG.spec.ts index a01a67e6b1e..81a9e5a3dca 100644 --- a/packages/client/lib/commands/CLUSTER_SAVECONFIG.spec.ts +++ b/packages/client/lib/commands/CLUSTER_SAVECONFIG.spec.ts @@ -2,7 +2,7 @@ import { strict as assert } from 'assert'; import testUtils, { GLOBAL } from '../test-utils'; import { transformArguments } from './CLUSTER_SAVECONFIG'; -describe.only('CLUSTER SAVECONFIG', () => { +describe('CLUSTER SAVECONFIG', () => { it('transformArguments', () => { assert.deepEqual( transformArguments(), diff --git a/packages/client/lib/commands/CLUSTER_SET-CONFIG-EPOCH.spec.ts b/packages/client/lib/commands/CLUSTER_SET-CONFIG-EPOCH.spec.ts index 947182629db..84a1521400e 100644 --- a/packages/client/lib/commands/CLUSTER_SET-CONFIG-EPOCH.spec.ts +++ b/packages/client/lib/commands/CLUSTER_SET-CONFIG-EPOCH.spec.ts @@ -2,7 +2,7 @@ import { strict as assert } from 'assert'; import testUtils, { GLOBAL } from '../test-utils'; import { transformArguments } from './CLUSTER_SET-CONFIG-EPOCH'; -describe.only('CLUSTER SET-CONFIG-EPOCH', () => { +describe('CLUSTER SET-CONFIG-EPOCH', () => { it('transformArguments', () => { assert.deepEqual( transformArguments(0), From b0f47d48e5ed2ea5d49643b0a35e079cfb56c6a7 Mon Sep 17 00:00:00 2001 From: Avital-Fine Date: Tue, 1 Mar 2022 13:17:20 +0100 Subject: [PATCH 04/13] delete cluster slaves --- .../client/lib/commands/CLUSTER_RESET.spec.ts | 7 ------- .../lib/commands/CLUSTER_SETSLOT.spec.ts | 20 ------------------- .../client/lib/commands/CLUSTER_SETSLOT.ts | 18 ----------------- 3 files changed, 45 deletions(-) delete mode 100644 packages/client/lib/commands/CLUSTER_SETSLOT.spec.ts delete mode 100644 packages/client/lib/commands/CLUSTER_SETSLOT.ts diff --git a/packages/client/lib/commands/CLUSTER_RESET.spec.ts b/packages/client/lib/commands/CLUSTER_RESET.spec.ts index 0887fde49f5..1e9960367f7 100644 --- a/packages/client/lib/commands/CLUSTER_RESET.spec.ts +++ b/packages/client/lib/commands/CLUSTER_RESET.spec.ts @@ -25,11 +25,4 @@ describe('CLUSTER RESET', () => { ); }); }); - - testUtils.testWithCluster('cluster.clusterReset', async cluster => { - assert.equal( - await cluster.clusterReset('SOFT'), - 'OK' - ); - }, GLOBAL.CLUSTERS.OPEN); }); diff --git a/packages/client/lib/commands/CLUSTER_SETSLOT.spec.ts b/packages/client/lib/commands/CLUSTER_SETSLOT.spec.ts deleted file mode 100644 index 0f46aafd13e..00000000000 --- a/packages/client/lib/commands/CLUSTER_SETSLOT.spec.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { strict as assert } from 'assert'; -import { ClusterSlotStates, transformArguments } from './CLUSTER_SETSLOT'; - -describe('CLUSTER SETSLOT', () => { - describe('transformArguments', () => { - it('simple', () => { - assert.deepEqual( - transformArguments(0, ClusterSlotStates.IMPORTING), - ['CLUSTER', 'SETSLOT', '0', 'IMPORTING'] - ); - }); - - it('with nodeId', () => { - assert.deepEqual( - transformArguments(0, ClusterSlotStates.IMPORTING, 'nodeId'), - ['CLUSTER', 'SETSLOT', '0', 'IMPORTING', 'nodeId'] - ); - }); - }); -}); diff --git a/packages/client/lib/commands/CLUSTER_SETSLOT.ts b/packages/client/lib/commands/CLUSTER_SETSLOT.ts deleted file mode 100644 index 591b5fb9632..00000000000 --- a/packages/client/lib/commands/CLUSTER_SETSLOT.ts +++ /dev/null @@ -1,18 +0,0 @@ -export enum ClusterSlotStates { - IMPORTING = 'IMPORTING', - MIGRATING = 'MIGRATING', - STABLE = 'STABLE', - NODE = 'NODE' -} - -export function transformArguments(slot: number, state: ClusterSlotStates, nodeId?: string): Array { - const args = ['CLUSTER', 'SETSLOT', slot.toString(), state]; - - if (nodeId) { - args.push(nodeId); - } - - return args; -} - -export declare function transformReply(): string; From e88cfdaf00a850e098de1b981f1638d301ae1e66 Mon Sep 17 00:00:00 2001 From: Avital-Fine Date: Tue, 1 Mar 2022 13:20:23 +0100 Subject: [PATCH 05/13] delete reset clietn test --- packages/client/lib/commands/CLUSTER_FAILOVER.spec.ts | 1 - packages/client/lib/commands/CLUSTER_RESET.spec.ts | 1 - 2 files changed, 2 deletions(-) diff --git a/packages/client/lib/commands/CLUSTER_FAILOVER.spec.ts b/packages/client/lib/commands/CLUSTER_FAILOVER.spec.ts index 66a050be18e..0455a63d4c4 100644 --- a/packages/client/lib/commands/CLUSTER_FAILOVER.spec.ts +++ b/packages/client/lib/commands/CLUSTER_FAILOVER.spec.ts @@ -16,5 +16,4 @@ describe('CLUSTER FAILOVER', () => { ); }); }); - }); diff --git a/packages/client/lib/commands/CLUSTER_RESET.spec.ts b/packages/client/lib/commands/CLUSTER_RESET.spec.ts index 1e9960367f7..c077e7f8874 100644 --- a/packages/client/lib/commands/CLUSTER_RESET.spec.ts +++ b/packages/client/lib/commands/CLUSTER_RESET.spec.ts @@ -1,5 +1,4 @@ import { strict as assert } from 'assert'; -import testUtils, { GLOBAL } from '../test-utils'; import { transformArguments } from './CLUSTER_RESET'; describe('CLUSTER RESET', () => { From 8600d97ffea2da5ca401b465f3a8c45edc7d4617 Mon Sep 17 00:00:00 2001 From: Avital-Fine Date: Tue, 1 Mar 2022 13:23:09 +0100 Subject: [PATCH 06/13] SET SLOT --- .../lib/commands/CLUSTER_SETSLOT.spec.ts | 20 +++++++++++++++++++ .../client/lib/commands/CLUSTER_SETSLOT.ts | 18 +++++++++++++++++ .../lib/commands/CLUSTER_SLAVES.spec.ts | 11 ---------- .../client/lib/commands/CLUSTER_SLAVES.ts | 5 ----- 4 files changed, 38 insertions(+), 16 deletions(-) create mode 100644 packages/client/lib/commands/CLUSTER_SETSLOT.spec.ts create mode 100644 packages/client/lib/commands/CLUSTER_SETSLOT.ts delete mode 100644 packages/client/lib/commands/CLUSTER_SLAVES.spec.ts delete mode 100644 packages/client/lib/commands/CLUSTER_SLAVES.ts diff --git a/packages/client/lib/commands/CLUSTER_SETSLOT.spec.ts b/packages/client/lib/commands/CLUSTER_SETSLOT.spec.ts new file mode 100644 index 00000000000..0f46aafd13e --- /dev/null +++ b/packages/client/lib/commands/CLUSTER_SETSLOT.spec.ts @@ -0,0 +1,20 @@ +import { strict as assert } from 'assert'; +import { ClusterSlotStates, transformArguments } from './CLUSTER_SETSLOT'; + +describe('CLUSTER SETSLOT', () => { + describe('transformArguments', () => { + it('simple', () => { + assert.deepEqual( + transformArguments(0, ClusterSlotStates.IMPORTING), + ['CLUSTER', 'SETSLOT', '0', 'IMPORTING'] + ); + }); + + it('with nodeId', () => { + assert.deepEqual( + transformArguments(0, ClusterSlotStates.IMPORTING, 'nodeId'), + ['CLUSTER', 'SETSLOT', '0', 'IMPORTING', 'nodeId'] + ); + }); + }); +}); diff --git a/packages/client/lib/commands/CLUSTER_SETSLOT.ts b/packages/client/lib/commands/CLUSTER_SETSLOT.ts new file mode 100644 index 00000000000..591b5fb9632 --- /dev/null +++ b/packages/client/lib/commands/CLUSTER_SETSLOT.ts @@ -0,0 +1,18 @@ +export enum ClusterSlotStates { + IMPORTING = 'IMPORTING', + MIGRATING = 'MIGRATING', + STABLE = 'STABLE', + NODE = 'NODE' +} + +export function transformArguments(slot: number, state: ClusterSlotStates, nodeId?: string): Array { + const args = ['CLUSTER', 'SETSLOT', slot.toString(), state]; + + if (nodeId) { + args.push(nodeId); + } + + return args; +} + +export declare function transformReply(): string; diff --git a/packages/client/lib/commands/CLUSTER_SLAVES.spec.ts b/packages/client/lib/commands/CLUSTER_SLAVES.spec.ts deleted file mode 100644 index fba6f52ddd2..00000000000 --- a/packages/client/lib/commands/CLUSTER_SLAVES.spec.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { strict as assert } from 'assert'; -import { transformArguments } from './CLUSTER_SLAVES'; - -describe('CLUSTER SLAVES', () => { - it('transformArguments', () => { - assert.deepEqual( - transformArguments('0'), - ['CLUSTER', 'SLAVES', '0'] - ); - }); -}); diff --git a/packages/client/lib/commands/CLUSTER_SLAVES.ts b/packages/client/lib/commands/CLUSTER_SLAVES.ts deleted file mode 100644 index 1ae55f76401..00000000000 --- a/packages/client/lib/commands/CLUSTER_SLAVES.ts +++ /dev/null @@ -1,5 +0,0 @@ -export function transformArguments(nodeId: string): Array { - return ['CLUSTER', 'SLAVES', nodeId]; -} - -export { transformReply } from './CLUSTER_NODES' From 3e5212aac7572762c9cfccc800d18ebdad8bc2ae Mon Sep 17 00:00:00 2001 From: Avital-Fine Date: Tue, 1 Mar 2022 13:56:47 +0100 Subject: [PATCH 07/13] test with client --- packages/client/lib/client/commands.ts | 45 +++++++++++++++++-- packages/client/lib/cluster/commands.ts | 21 --------- .../lib/commands/CLUSTER_BUMPEPOCH.spec.ts | 2 +- .../CLUSTER_COUNT-FAILURE-REPORTS.spec.ts | 2 +- .../commands/CLUSTER_COUNTKEYSINSLOT.spec.ts | 8 ++++ .../client/lib/commands/CLUSTER_INFO.spec.ts | 2 +- .../client/lib/commands/CLUSTER_MYID.spec.ts | 2 +- .../lib/commands/CLUSTER_SAVECONFIG.spec.ts | 2 +- .../commands/CLUSTER_SET-CONFIG-EPOCH.spec.ts | 2 +- 9 files changed, 56 insertions(+), 30 deletions(-) diff --git a/packages/client/lib/client/commands.ts b/packages/client/lib/client/commands.ts index 029a5e60f62..e18b149a0f6 100644 --- a/packages/client/lib/client/commands.ts +++ b/packages/client/lib/client/commands.ts @@ -23,11 +23,24 @@ import * as CLIENT_KILL from '../commands/CLIENT_KILL'; import * as CLIENT_SETNAME from '../commands/CLIENT_SETNAME'; import * as CLIENT_INFO from '../commands/CLIENT_INFO'; import * as CLUSTER_ADDSLOTS from '../commands/CLUSTER_ADDSLOTS'; +import * as CLUSTER_BUMPEPOCH from '../commands/CLUSTER_BUMPEPOCH'; +import * as CLUSTER_COUNT_FAILURE_REPORTS from '../commands/CLUSTER_COUNT-FAILURE-REPORTS'; +import * as CLUSTER_COUNTKEYSINSLOT from '../commands/CLUSTER_COUNTKEYSINSLOT'; +import * as CLUSTER_DELSLOTS from '../commands/CLUSTER_DELSLOTS'; +import * as CLUSTER_FAILOVER from '../commands/CLUSTER_FAILOVER'; import * as CLUSTER_FLUSHSLOTS from '../commands/CLUSTER_FLUSHSLOTS'; +import * as CLUSTER_FORGET from '../commands/CLUSTER_FORGET'; +import * as CLUSTER_GETKEYSINSLOT from '../commands/CLUSTER_GETKEYSINSLOT'; import * as CLUSTER_INFO from '../commands/CLUSTER_INFO'; -import * as CLUSTER_NODES from '../commands/CLUSTER_NODES'; +import * as CLUSTER_KEYSLOT from '../commands/CLUSTER_KEYSLOT'; import * as CLUSTER_MEET from '../commands/CLUSTER_MEET'; +import * as CLUSTER_MYID from '../commands/CLUSTER_MYID'; +import * as CLUSTER_NODES from '../commands/CLUSTER_NODES'; +import * as CLUSTER_REPLICAS from '../commands/CLUSTER_REPLICAS'; +import * as CLUSTER_REPLICATE from '../commands/CLUSTER_REPLICATE'; import * as CLUSTER_RESET from '../commands/CLUSTER_RESET'; +import * as CLUSTER_SAVECONFIG from '../commands/CLUSTER_SAVECONFIG'; +import * as CLUSTER_SET_CONFIG_EPOCH from '../commands/CLUSTER_SET-CONFIG-EPOCH'; import * as CLUSTER_SETSLOT from '../commands/CLUSTER_SETSLOT'; import * as CLUSTER_SLOTS from '../commands/CLUSTER_SLOTS'; import * as COMMAND_COUNT from '../commands/COMMAND_COUNT'; @@ -131,16 +144,42 @@ export default { clientInfo: CLIENT_INFO, CLUSTER_ADDSLOTS, clusterAddSlots: CLUSTER_ADDSLOTS, + CLUSTER_BUMPEPOCH, + clusterBumpEpoch: CLUSTER_BUMPEPOCH, + CLUSTER_COUNT_FAILURE_REPORTS, + clusterCountFailureReports: CLUSTER_COUNT_FAILURE_REPORTS, + CLUSTER_COUNTKEYSINSLOT, + clusterCountKeysInSlot: CLUSTER_COUNTKEYSINSLOT, + CLUSTER_DELSLOTS, + clusterDelSlots: CLUSTER_DELSLOTS, + CLUSTER_FAILOVER, + clusterFailover: CLUSTER_FAILOVER, CLUSTER_FLUSHSLOTS, clusterFlushSlots: CLUSTER_FLUSHSLOTS, + CLUSTER_FORGET, + clusterForget: CLUSTER_FORGET, + CLUSTER_GETKEYSINSLOT, + clusterGetKeysInSlot: CLUSTER_GETKEYSINSLOT, CLUSTER_INFO, clusterInfo: CLUSTER_INFO, - CLUSTER_NODES, - clusterNodes: CLUSTER_NODES, + CLUSTER_KEYSLOT, + clusterKeySlot: CLUSTER_KEYSLOT, CLUSTER_MEET, clusterMeet: CLUSTER_MEET, + CLUSTER_MYID, + clusterMyId: CLUSTER_MYID, + CLUSTER_NODES, + clusterNodes: CLUSTER_NODES, + CLUSTER_REPLICAS, + clusterReplicas: CLUSTER_REPLICAS, + CLUSTER_REPLICATE, + clusterReplicate: CLUSTER_REPLICATE, CLUSTER_RESET, clusterReset: CLUSTER_RESET, + CLUSTER_SAVECONFIG, + clusterSaveConfig: CLUSTER_SAVECONFIG, + CLUSTER_SET_CONFIG_EPOCH, + clusterSetConfigEpoch: CLUSTER_SET_CONFIG_EPOCH, CLUSTER_SETSLOT, clusterSetSlot: CLUSTER_SETSLOT, CLUSTER_SLOTS, diff --git a/packages/client/lib/cluster/commands.ts b/packages/client/lib/cluster/commands.ts index 0f638831550..4b2aba6a7ae 100644 --- a/packages/client/lib/cluster/commands.ts +++ b/packages/client/lib/cluster/commands.ts @@ -10,13 +10,6 @@ import * as BRPOP from '../commands/BRPOP'; import * as BRPOPLPUSH from '../commands/BRPOPLPUSH'; import * as BZPOPMAX from '../commands/BZPOPMAX'; import * as BZPOPMIN from '../commands/BZPOPMIN'; -import * as CLUSTER_BUMPEPOCH from '../commands/CLUSTER_BUMPEPOCH'; -import * as CLUSTER_COUNT_FAILURE_REPORTS from '../commands/CLUSTER_COUNT-FAILURE-REPORTS'; -import * as CLUSTER_INFO from '../commands/CLUSTER_INFO'; -import * as CLUSTER_MYID from '../commands/CLUSTER_MYID'; -import * as CLUSTER_RESET from '../commands/CLUSTER_RESET'; -import * as CLUSTER_SAVECONFIG from '../commands/CLUSTER_SAVECONFIG'; -import * as CLUSTER_SET_CONFIG_EPOCH from '../commands/CLUSTER_SET-CONFIG-EPOCH'; import * as COPY from '../commands/COPY'; import * as DECR from '../commands/DECR'; import * as DECRBY from '../commands/DECRBY'; @@ -206,20 +199,6 @@ export default { bzPopMax: BZPOPMAX, BZPOPMIN, bzPopMin: BZPOPMIN, - CLUSTER_BUMPEPOCH, - clusterBumpEpoch: CLUSTER_BUMPEPOCH, - CLUSTER_COUNT_FAILURE_REPORTS, - clusterCountFailureReports: CLUSTER_COUNT_FAILURE_REPORTS, - CLUSTER_INFO, - clusterInfo: CLUSTER_INFO, - CLUSTER_MYID, - clusterMyId: CLUSTER_MYID, - CLUSTER_RESET, - clusterReset: CLUSTER_RESET, - CLUSTER_SAVECONFIG, - clusterSaveConfig: CLUSTER_SAVECONFIG, - CLUSTER_SET_CONFIG_EPOCH, - clusterSetConfigEpoch: CLUSTER_SET_CONFIG_EPOCH, COPY, copy: COPY, DECR, diff --git a/packages/client/lib/commands/CLUSTER_BUMPEPOCH.spec.ts b/packages/client/lib/commands/CLUSTER_BUMPEPOCH.spec.ts index de6a68c8d63..91f5b850f5c 100644 --- a/packages/client/lib/commands/CLUSTER_BUMPEPOCH.spec.ts +++ b/packages/client/lib/commands/CLUSTER_BUMPEPOCH.spec.ts @@ -10,7 +10,7 @@ describe('CLUSTER BUMPEPOCH', () => { ); }); - testUtils.testWithCluster('cluster.clusterBumpEpoch', async cluster => { + testUtils.testWithClient('cluster.clusterBumpEpoch', async cluster => { assert.equal( typeof await cluster.clusterBumpEpoch(), 'string' diff --git a/packages/client/lib/commands/CLUSTER_COUNT-FAILURE-REPORTS.spec.ts b/packages/client/lib/commands/CLUSTER_COUNT-FAILURE-REPORTS.spec.ts index 96d1f6a8bad..5f85abc7df2 100644 --- a/packages/client/lib/commands/CLUSTER_COUNT-FAILURE-REPORTS.spec.ts +++ b/packages/client/lib/commands/CLUSTER_COUNT-FAILURE-REPORTS.spec.ts @@ -10,7 +10,7 @@ describe('CLUSTER COUNT-FAILURE-REPORTS', () => { ); }); - testUtils.testWithCluster('cluster.clusterCountFailureReports', async cluster => { + testUtils.testWithClient('cluster.clusterCountFailureReports', async cluster => { const id: string = await cluster.clusterMyId(); assert.equal( await cluster.clusterCountFailureReports(id), diff --git a/packages/client/lib/commands/CLUSTER_COUNTKEYSINSLOT.spec.ts b/packages/client/lib/commands/CLUSTER_COUNTKEYSINSLOT.spec.ts index 26659727310..66c982c8c35 100644 --- a/packages/client/lib/commands/CLUSTER_COUNTKEYSINSLOT.spec.ts +++ b/packages/client/lib/commands/CLUSTER_COUNTKEYSINSLOT.spec.ts @@ -1,4 +1,5 @@ import { strict as assert } from 'assert'; +import testUtils, { GLOBAL } from '../test-utils'; import { transformArguments } from './CLUSTER_COUNTKEYSINSLOT'; describe('CLUSTER COUNTKEYSINSLOT', () => { @@ -8,4 +9,11 @@ describe('CLUSTER COUNTKEYSINSLOT', () => { ['CLUSTER', 'COUNTKEYSINSLOT', '1'] ); }); + + testUtils.testWithClient('cluster.clusterInfo', async cluster => { + assert.equal( + typeof await cluster.clusterInfo(), + 'number' + ); + }, GLOBAL.CLUSTERS.OPEN); }); diff --git a/packages/client/lib/commands/CLUSTER_INFO.spec.ts b/packages/client/lib/commands/CLUSTER_INFO.spec.ts index 9abe4e9fa9c..338854876ec 100644 --- a/packages/client/lib/commands/CLUSTER_INFO.spec.ts +++ b/packages/client/lib/commands/CLUSTER_INFO.spec.ts @@ -45,7 +45,7 @@ describe('CLUSTER INFO', () => { ); }); - testUtils.testWithCluster('cluster.clusterInfo', async cluster => { + testUtils.testWithClient('cluster.clusterInfo', async cluster => { assert.notEqual( await cluster.clusterInfo(), null diff --git a/packages/client/lib/commands/CLUSTER_MYID.spec.ts b/packages/client/lib/commands/CLUSTER_MYID.spec.ts index d421a186771..f38b8848716 100644 --- a/packages/client/lib/commands/CLUSTER_MYID.spec.ts +++ b/packages/client/lib/commands/CLUSTER_MYID.spec.ts @@ -10,7 +10,7 @@ describe('CLUSTER MYID', () => { ); }); - testUtils.testWithCluster('cluster.clusterMyId', async cluster => { + testUtils.testWithClient('cluster.clusterMyId', async cluster => { assert.notEqual( await cluster.clusterMyId(), null diff --git a/packages/client/lib/commands/CLUSTER_SAVECONFIG.spec.ts b/packages/client/lib/commands/CLUSTER_SAVECONFIG.spec.ts index 81a9e5a3dca..079179aa2ab 100644 --- a/packages/client/lib/commands/CLUSTER_SAVECONFIG.spec.ts +++ b/packages/client/lib/commands/CLUSTER_SAVECONFIG.spec.ts @@ -10,7 +10,7 @@ describe('CLUSTER SAVECONFIG', () => { ); }); - testUtils.testWithCluster('cluster.clusterSaveConfig', async cluster => { + testUtils.testWithClient('cluster.clusterSaveConfig', async cluster => { assert.equal( await cluster.clusterSaveConfig(), 'OK' diff --git a/packages/client/lib/commands/CLUSTER_SET-CONFIG-EPOCH.spec.ts b/packages/client/lib/commands/CLUSTER_SET-CONFIG-EPOCH.spec.ts index 84a1521400e..64c6a44699e 100644 --- a/packages/client/lib/commands/CLUSTER_SET-CONFIG-EPOCH.spec.ts +++ b/packages/client/lib/commands/CLUSTER_SET-CONFIG-EPOCH.spec.ts @@ -10,7 +10,7 @@ describe('CLUSTER SET-CONFIG-EPOCH', () => { ); }); - testUtils.testWithCluster('cluster.clusterSetConfigEpoch', async cluster => { + testUtils.testWithClient('cluster.clusterSetConfigEpoch', async cluster => { try { assert.equal( await cluster.clusterSetConfigEpoch(1), From de14ee22b7616b8789508b055f2ca6ca631934c9 Mon Sep 17 00:00:00 2001 From: Avital-Fine Date: Fri, 4 Mar 2022 21:06:39 +0100 Subject: [PATCH 08/13] fix fail --- packages/client/lib/client/commands.ts | 63 ------------------- packages/client/lib/cluster/commands.ts | 63 +++++++++++++++++++ .../lib/commands/CLUSTER_BUMPEPOCH.spec.ts | 4 +- .../CLUSTER_COUNT-FAILURE-REPORTS.spec.ts | 2 +- .../commands/CLUSTER_COUNTKEYSINSLOT.spec.ts | 6 +- .../client/lib/commands/CLUSTER_INFO.spec.ts | 2 +- .../client/lib/commands/CLUSTER_MYID.spec.ts | 2 +- .../lib/commands/CLUSTER_SAVECONFIG.spec.ts | 2 +- .../commands/CLUSTER_SET-CONFIG-EPOCH.spec.ts | 2 +- 9 files changed, 73 insertions(+), 73 deletions(-) diff --git a/packages/client/lib/client/commands.ts b/packages/client/lib/client/commands.ts index e18b149a0f6..fc2374c24c8 100644 --- a/packages/client/lib/client/commands.ts +++ b/packages/client/lib/client/commands.ts @@ -22,27 +22,6 @@ import * as CLIENT_ID from '../commands/CLIENT_ID'; import * as CLIENT_KILL from '../commands/CLIENT_KILL'; import * as CLIENT_SETNAME from '../commands/CLIENT_SETNAME'; import * as CLIENT_INFO from '../commands/CLIENT_INFO'; -import * as CLUSTER_ADDSLOTS from '../commands/CLUSTER_ADDSLOTS'; -import * as CLUSTER_BUMPEPOCH from '../commands/CLUSTER_BUMPEPOCH'; -import * as CLUSTER_COUNT_FAILURE_REPORTS from '../commands/CLUSTER_COUNT-FAILURE-REPORTS'; -import * as CLUSTER_COUNTKEYSINSLOT from '../commands/CLUSTER_COUNTKEYSINSLOT'; -import * as CLUSTER_DELSLOTS from '../commands/CLUSTER_DELSLOTS'; -import * as CLUSTER_FAILOVER from '../commands/CLUSTER_FAILOVER'; -import * as CLUSTER_FLUSHSLOTS from '../commands/CLUSTER_FLUSHSLOTS'; -import * as CLUSTER_FORGET from '../commands/CLUSTER_FORGET'; -import * as CLUSTER_GETKEYSINSLOT from '../commands/CLUSTER_GETKEYSINSLOT'; -import * as CLUSTER_INFO from '../commands/CLUSTER_INFO'; -import * as CLUSTER_KEYSLOT from '../commands/CLUSTER_KEYSLOT'; -import * as CLUSTER_MEET from '../commands/CLUSTER_MEET'; -import * as CLUSTER_MYID from '../commands/CLUSTER_MYID'; -import * as CLUSTER_NODES from '../commands/CLUSTER_NODES'; -import * as CLUSTER_REPLICAS from '../commands/CLUSTER_REPLICAS'; -import * as CLUSTER_REPLICATE from '../commands/CLUSTER_REPLICATE'; -import * as CLUSTER_RESET from '../commands/CLUSTER_RESET'; -import * as CLUSTER_SAVECONFIG from '../commands/CLUSTER_SAVECONFIG'; -import * as CLUSTER_SET_CONFIG_EPOCH from '../commands/CLUSTER_SET-CONFIG-EPOCH'; -import * as CLUSTER_SETSLOT from '../commands/CLUSTER_SETSLOT'; -import * as CLUSTER_SLOTS from '../commands/CLUSTER_SLOTS'; import * as COMMAND_COUNT from '../commands/COMMAND_COUNT'; import * as COMMAND_GETKEYS from '../commands/COMMAND_GETKEYS'; import * as COMMAND_INFO from '../commands/COMMAND_INFO'; @@ -142,48 +121,6 @@ export default { clientSetName: CLIENT_SETNAME, CLIENT_INFO, clientInfo: CLIENT_INFO, - CLUSTER_ADDSLOTS, - clusterAddSlots: CLUSTER_ADDSLOTS, - CLUSTER_BUMPEPOCH, - clusterBumpEpoch: CLUSTER_BUMPEPOCH, - CLUSTER_COUNT_FAILURE_REPORTS, - clusterCountFailureReports: CLUSTER_COUNT_FAILURE_REPORTS, - CLUSTER_COUNTKEYSINSLOT, - clusterCountKeysInSlot: CLUSTER_COUNTKEYSINSLOT, - CLUSTER_DELSLOTS, - clusterDelSlots: CLUSTER_DELSLOTS, - CLUSTER_FAILOVER, - clusterFailover: CLUSTER_FAILOVER, - CLUSTER_FLUSHSLOTS, - clusterFlushSlots: CLUSTER_FLUSHSLOTS, - CLUSTER_FORGET, - clusterForget: CLUSTER_FORGET, - CLUSTER_GETKEYSINSLOT, - clusterGetKeysInSlot: CLUSTER_GETKEYSINSLOT, - CLUSTER_INFO, - clusterInfo: CLUSTER_INFO, - CLUSTER_KEYSLOT, - clusterKeySlot: CLUSTER_KEYSLOT, - CLUSTER_MEET, - clusterMeet: CLUSTER_MEET, - CLUSTER_MYID, - clusterMyId: CLUSTER_MYID, - CLUSTER_NODES, - clusterNodes: CLUSTER_NODES, - CLUSTER_REPLICAS, - clusterReplicas: CLUSTER_REPLICAS, - CLUSTER_REPLICATE, - clusterReplicate: CLUSTER_REPLICATE, - CLUSTER_RESET, - clusterReset: CLUSTER_RESET, - CLUSTER_SAVECONFIG, - clusterSaveConfig: CLUSTER_SAVECONFIG, - CLUSTER_SET_CONFIG_EPOCH, - clusterSetConfigEpoch: CLUSTER_SET_CONFIG_EPOCH, - CLUSTER_SETSLOT, - clusterSetSlot: CLUSTER_SETSLOT, - CLUSTER_SLOTS, - clusterSlots: CLUSTER_SLOTS, COMMAND_COUNT, commandCount: COMMAND_COUNT, COMMAND_GETKEYS, diff --git a/packages/client/lib/cluster/commands.ts b/packages/client/lib/cluster/commands.ts index 4b2aba6a7ae..c814802366d 100644 --- a/packages/client/lib/cluster/commands.ts +++ b/packages/client/lib/cluster/commands.ts @@ -10,6 +10,27 @@ import * as BRPOP from '../commands/BRPOP'; import * as BRPOPLPUSH from '../commands/BRPOPLPUSH'; import * as BZPOPMAX from '../commands/BZPOPMAX'; import * as BZPOPMIN from '../commands/BZPOPMIN'; +import * as CLUSTER_ADDSLOTS from '../commands/CLUSTER_ADDSLOTS'; +import * as CLUSTER_BUMPEPOCH from '../commands/CLUSTER_BUMPEPOCH'; +import * as CLUSTER_COUNT_FAILURE_REPORTS from '../commands/CLUSTER_COUNT-FAILURE-REPORTS'; +import * as CLUSTER_COUNTKEYSINSLOT from '../commands/CLUSTER_COUNTKEYSINSLOT'; +import * as CLUSTER_DELSLOTS from '../commands/CLUSTER_DELSLOTS'; +import * as CLUSTER_FAILOVER from '../commands/CLUSTER_FAILOVER'; +import * as CLUSTER_FLUSHSLOTS from '../commands/CLUSTER_FLUSHSLOTS'; +import * as CLUSTER_FORGET from '../commands/CLUSTER_FORGET'; +import * as CLUSTER_GETKEYSINSLOT from '../commands/CLUSTER_GETKEYSINSLOT'; +import * as CLUSTER_INFO from '../commands/CLUSTER_INFO'; +import * as CLUSTER_KEYSLOT from '../commands/CLUSTER_KEYSLOT'; +import * as CLUSTER_MEET from '../commands/CLUSTER_MEET'; +import * as CLUSTER_MYID from '../commands/CLUSTER_MYID'; +import * as CLUSTER_NODES from '../commands/CLUSTER_NODES'; +import * as CLUSTER_REPLICAS from '../commands/CLUSTER_REPLICAS'; +import * as CLUSTER_REPLICATE from '../commands/CLUSTER_REPLICATE'; +import * as CLUSTER_RESET from '../commands/CLUSTER_RESET'; +import * as CLUSTER_SAVECONFIG from '../commands/CLUSTER_SAVECONFIG'; +import * as CLUSTER_SET_CONFIG_EPOCH from '../commands/CLUSTER_SET-CONFIG-EPOCH'; +import * as CLUSTER_SETSLOT from '../commands/CLUSTER_SETSLOT'; +import * as CLUSTER_SLOTS from '../commands/CLUSTER_SLOTS'; import * as COPY from '../commands/COPY'; import * as DECR from '../commands/DECR'; import * as DECRBY from '../commands/DECRBY'; @@ -199,6 +220,48 @@ export default { bzPopMax: BZPOPMAX, BZPOPMIN, bzPopMin: BZPOPMIN, + CLUSTER_ADDSLOTS, + clusterAddSlots: CLUSTER_ADDSLOTS, + CLUSTER_BUMPEPOCH, + clusterBumpEpoch: CLUSTER_BUMPEPOCH, + CLUSTER_COUNT_FAILURE_REPORTS, + clusterCountFailureReports: CLUSTER_COUNT_FAILURE_REPORTS, + CLUSTER_COUNTKEYSINSLOT, + clusterCountKeysInSlot: CLUSTER_COUNTKEYSINSLOT, + CLUSTER_DELSLOTS, + clusterDelSlots: CLUSTER_DELSLOTS, + CLUSTER_FAILOVER, + clusterFailover: CLUSTER_FAILOVER, + CLUSTER_FLUSHSLOTS, + clusterFlushSlots: CLUSTER_FLUSHSLOTS, + CLUSTER_FORGET, + clusterForget: CLUSTER_FORGET, + CLUSTER_GETKEYSINSLOT, + clusterGetKeysInSlot: CLUSTER_GETKEYSINSLOT, + CLUSTER_INFO, + clusterInfo: CLUSTER_INFO, + CLUSTER_KEYSLOT, + clusterKeySlot: CLUSTER_KEYSLOT, + CLUSTER_MEET, + clusterMeet: CLUSTER_MEET, + CLUSTER_MYID, + clusterMyId: CLUSTER_MYID, + CLUSTER_NODES, + clusterNodes: CLUSTER_NODES, + CLUSTER_REPLICAS, + clusterReplicas: CLUSTER_REPLICAS, + CLUSTER_REPLICATE, + clusterReplicate: CLUSTER_REPLICATE, + CLUSTER_RESET, + clusterReset: CLUSTER_RESET, + CLUSTER_SAVECONFIG, + clusterSaveConfig: CLUSTER_SAVECONFIG, + CLUSTER_SET_CONFIG_EPOCH, + clusterSetConfigEpoch: CLUSTER_SET_CONFIG_EPOCH, + CLUSTER_SETSLOT, + clusterSetSlot: CLUSTER_SETSLOT, + CLUSTER_SLOTS, + clusterSlots: CLUSTER_SLOTS, COPY, copy: COPY, DECR, diff --git a/packages/client/lib/commands/CLUSTER_BUMPEPOCH.spec.ts b/packages/client/lib/commands/CLUSTER_BUMPEPOCH.spec.ts index 91f5b850f5c..a63d6301ac2 100644 --- a/packages/client/lib/commands/CLUSTER_BUMPEPOCH.spec.ts +++ b/packages/client/lib/commands/CLUSTER_BUMPEPOCH.spec.ts @@ -10,10 +10,10 @@ describe('CLUSTER BUMPEPOCH', () => { ); }); - testUtils.testWithClient('cluster.clusterBumpEpoch', async cluster => { + testUtils.testWithCluster('cluster.clusterBumpEpoch', async cluster => { assert.equal( typeof await cluster.clusterBumpEpoch(), 'string' ); - }, GLOBAL.CLUSTERS.OPEN); + }, GLOBAL.SERVERS.OPEN); }); diff --git a/packages/client/lib/commands/CLUSTER_COUNT-FAILURE-REPORTS.spec.ts b/packages/client/lib/commands/CLUSTER_COUNT-FAILURE-REPORTS.spec.ts index 5f85abc7df2..96d1f6a8bad 100644 --- a/packages/client/lib/commands/CLUSTER_COUNT-FAILURE-REPORTS.spec.ts +++ b/packages/client/lib/commands/CLUSTER_COUNT-FAILURE-REPORTS.spec.ts @@ -10,7 +10,7 @@ describe('CLUSTER COUNT-FAILURE-REPORTS', () => { ); }); - testUtils.testWithClient('cluster.clusterCountFailureReports', async cluster => { + testUtils.testWithCluster('cluster.clusterCountFailureReports', async cluster => { const id: string = await cluster.clusterMyId(); assert.equal( await cluster.clusterCountFailureReports(id), diff --git a/packages/client/lib/commands/CLUSTER_COUNTKEYSINSLOT.spec.ts b/packages/client/lib/commands/CLUSTER_COUNTKEYSINSLOT.spec.ts index 66c982c8c35..3cc4a31672a 100644 --- a/packages/client/lib/commands/CLUSTER_COUNTKEYSINSLOT.spec.ts +++ b/packages/client/lib/commands/CLUSTER_COUNTKEYSINSLOT.spec.ts @@ -2,7 +2,7 @@ import { strict as assert } from 'assert'; import testUtils, { GLOBAL } from '../test-utils'; import { transformArguments } from './CLUSTER_COUNTKEYSINSLOT'; -describe('CLUSTER COUNTKEYSINSLOT', () => { +describe.only('CLUSTER COUNTKEYSINSLOT', () => { it('transformArguments', () => { assert.deepEqual( transformArguments(1), @@ -10,9 +10,9 @@ describe('CLUSTER COUNTKEYSINSLOT', () => { ); }); - testUtils.testWithClient('cluster.clusterInfo', async cluster => { + testUtils.testWithCluster('cluster.clusterInfo', async cluster => { assert.equal( - typeof await cluster.clusterInfo(), + typeof await cluster.clusterCountKeysInSlot(1), 'number' ); }, GLOBAL.CLUSTERS.OPEN); diff --git a/packages/client/lib/commands/CLUSTER_INFO.spec.ts b/packages/client/lib/commands/CLUSTER_INFO.spec.ts index 338854876ec..9abe4e9fa9c 100644 --- a/packages/client/lib/commands/CLUSTER_INFO.spec.ts +++ b/packages/client/lib/commands/CLUSTER_INFO.spec.ts @@ -45,7 +45,7 @@ describe('CLUSTER INFO', () => { ); }); - testUtils.testWithClient('cluster.clusterInfo', async cluster => { + testUtils.testWithCluster('cluster.clusterInfo', async cluster => { assert.notEqual( await cluster.clusterInfo(), null diff --git a/packages/client/lib/commands/CLUSTER_MYID.spec.ts b/packages/client/lib/commands/CLUSTER_MYID.spec.ts index f38b8848716..d421a186771 100644 --- a/packages/client/lib/commands/CLUSTER_MYID.spec.ts +++ b/packages/client/lib/commands/CLUSTER_MYID.spec.ts @@ -10,7 +10,7 @@ describe('CLUSTER MYID', () => { ); }); - testUtils.testWithClient('cluster.clusterMyId', async cluster => { + testUtils.testWithCluster('cluster.clusterMyId', async cluster => { assert.notEqual( await cluster.clusterMyId(), null diff --git a/packages/client/lib/commands/CLUSTER_SAVECONFIG.spec.ts b/packages/client/lib/commands/CLUSTER_SAVECONFIG.spec.ts index 079179aa2ab..81a9e5a3dca 100644 --- a/packages/client/lib/commands/CLUSTER_SAVECONFIG.spec.ts +++ b/packages/client/lib/commands/CLUSTER_SAVECONFIG.spec.ts @@ -10,7 +10,7 @@ describe('CLUSTER SAVECONFIG', () => { ); }); - testUtils.testWithClient('cluster.clusterSaveConfig', async cluster => { + testUtils.testWithCluster('cluster.clusterSaveConfig', async cluster => { assert.equal( await cluster.clusterSaveConfig(), 'OK' diff --git a/packages/client/lib/commands/CLUSTER_SET-CONFIG-EPOCH.spec.ts b/packages/client/lib/commands/CLUSTER_SET-CONFIG-EPOCH.spec.ts index 64c6a44699e..84a1521400e 100644 --- a/packages/client/lib/commands/CLUSTER_SET-CONFIG-EPOCH.spec.ts +++ b/packages/client/lib/commands/CLUSTER_SET-CONFIG-EPOCH.spec.ts @@ -10,7 +10,7 @@ describe('CLUSTER SET-CONFIG-EPOCH', () => { ); }); - testUtils.testWithClient('cluster.clusterSetConfigEpoch', async cluster => { + testUtils.testWithCluster('cluster.clusterSetConfigEpoch', async cluster => { try { assert.equal( await cluster.clusterSetConfigEpoch(1), From a0c5f631b62a8eae477f0add44114156e8b3d53e Mon Sep 17 00:00:00 2001 From: Avital-Fine <98389525+Avital-Fine@users.noreply.github.com> Date: Fri, 4 Mar 2022 21:15:36 +0100 Subject: [PATCH 09/13] Update CLUSTER_COUNTKEYSINSLOT.spec.ts --- packages/client/lib/commands/CLUSTER_COUNTKEYSINSLOT.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/client/lib/commands/CLUSTER_COUNTKEYSINSLOT.spec.ts b/packages/client/lib/commands/CLUSTER_COUNTKEYSINSLOT.spec.ts index 3cc4a31672a..776feed085e 100644 --- a/packages/client/lib/commands/CLUSTER_COUNTKEYSINSLOT.spec.ts +++ b/packages/client/lib/commands/CLUSTER_COUNTKEYSINSLOT.spec.ts @@ -2,7 +2,7 @@ import { strict as assert } from 'assert'; import testUtils, { GLOBAL } from '../test-utils'; import { transformArguments } from './CLUSTER_COUNTKEYSINSLOT'; -describe.only('CLUSTER COUNTKEYSINSLOT', () => { +describe('CLUSTER COUNTKEYSINSLOT', () => { it('transformArguments', () => { assert.deepEqual( transformArguments(1), From 818609e952188555d56fd3a3b051fb0f1c3b77d8 Mon Sep 17 00:00:00 2001 From: Avital-Fine Date: Fri, 4 Mar 2022 22:18:31 +0100 Subject: [PATCH 10/13] move commands to client/commands.ts --- packages/client/lib/client/commands.ts | 63 +++++++++++++++++++ packages/client/lib/cluster/commands.ts | 63 ------------------- .../lib/commands/CLUSTER_BUMPEPOCH.spec.ts | 2 +- .../CLUSTER_COUNT-FAILURE-REPORTS.spec.ts | 4 +- .../commands/CLUSTER_COUNTKEYSINSLOT.spec.ts | 2 +- .../client/lib/commands/CLUSTER_INFO.spec.ts | 2 +- .../client/lib/commands/CLUSTER_MYID.spec.ts | 2 +- .../lib/commands/CLUSTER_SAVECONFIG.spec.ts | 2 +- .../commands/CLUSTER_SET-CONFIG-EPOCH.spec.ts | 2 +- 9 files changed, 71 insertions(+), 71 deletions(-) diff --git a/packages/client/lib/client/commands.ts b/packages/client/lib/client/commands.ts index fc2374c24c8..e18b149a0f6 100644 --- a/packages/client/lib/client/commands.ts +++ b/packages/client/lib/client/commands.ts @@ -22,6 +22,27 @@ import * as CLIENT_ID from '../commands/CLIENT_ID'; import * as CLIENT_KILL from '../commands/CLIENT_KILL'; import * as CLIENT_SETNAME from '../commands/CLIENT_SETNAME'; import * as CLIENT_INFO from '../commands/CLIENT_INFO'; +import * as CLUSTER_ADDSLOTS from '../commands/CLUSTER_ADDSLOTS'; +import * as CLUSTER_BUMPEPOCH from '../commands/CLUSTER_BUMPEPOCH'; +import * as CLUSTER_COUNT_FAILURE_REPORTS from '../commands/CLUSTER_COUNT-FAILURE-REPORTS'; +import * as CLUSTER_COUNTKEYSINSLOT from '../commands/CLUSTER_COUNTKEYSINSLOT'; +import * as CLUSTER_DELSLOTS from '../commands/CLUSTER_DELSLOTS'; +import * as CLUSTER_FAILOVER from '../commands/CLUSTER_FAILOVER'; +import * as CLUSTER_FLUSHSLOTS from '../commands/CLUSTER_FLUSHSLOTS'; +import * as CLUSTER_FORGET from '../commands/CLUSTER_FORGET'; +import * as CLUSTER_GETKEYSINSLOT from '../commands/CLUSTER_GETKEYSINSLOT'; +import * as CLUSTER_INFO from '../commands/CLUSTER_INFO'; +import * as CLUSTER_KEYSLOT from '../commands/CLUSTER_KEYSLOT'; +import * as CLUSTER_MEET from '../commands/CLUSTER_MEET'; +import * as CLUSTER_MYID from '../commands/CLUSTER_MYID'; +import * as CLUSTER_NODES from '../commands/CLUSTER_NODES'; +import * as CLUSTER_REPLICAS from '../commands/CLUSTER_REPLICAS'; +import * as CLUSTER_REPLICATE from '../commands/CLUSTER_REPLICATE'; +import * as CLUSTER_RESET from '../commands/CLUSTER_RESET'; +import * as CLUSTER_SAVECONFIG from '../commands/CLUSTER_SAVECONFIG'; +import * as CLUSTER_SET_CONFIG_EPOCH from '../commands/CLUSTER_SET-CONFIG-EPOCH'; +import * as CLUSTER_SETSLOT from '../commands/CLUSTER_SETSLOT'; +import * as CLUSTER_SLOTS from '../commands/CLUSTER_SLOTS'; import * as COMMAND_COUNT from '../commands/COMMAND_COUNT'; import * as COMMAND_GETKEYS from '../commands/COMMAND_GETKEYS'; import * as COMMAND_INFO from '../commands/COMMAND_INFO'; @@ -121,6 +142,48 @@ export default { clientSetName: CLIENT_SETNAME, CLIENT_INFO, clientInfo: CLIENT_INFO, + CLUSTER_ADDSLOTS, + clusterAddSlots: CLUSTER_ADDSLOTS, + CLUSTER_BUMPEPOCH, + clusterBumpEpoch: CLUSTER_BUMPEPOCH, + CLUSTER_COUNT_FAILURE_REPORTS, + clusterCountFailureReports: CLUSTER_COUNT_FAILURE_REPORTS, + CLUSTER_COUNTKEYSINSLOT, + clusterCountKeysInSlot: CLUSTER_COUNTKEYSINSLOT, + CLUSTER_DELSLOTS, + clusterDelSlots: CLUSTER_DELSLOTS, + CLUSTER_FAILOVER, + clusterFailover: CLUSTER_FAILOVER, + CLUSTER_FLUSHSLOTS, + clusterFlushSlots: CLUSTER_FLUSHSLOTS, + CLUSTER_FORGET, + clusterForget: CLUSTER_FORGET, + CLUSTER_GETKEYSINSLOT, + clusterGetKeysInSlot: CLUSTER_GETKEYSINSLOT, + CLUSTER_INFO, + clusterInfo: CLUSTER_INFO, + CLUSTER_KEYSLOT, + clusterKeySlot: CLUSTER_KEYSLOT, + CLUSTER_MEET, + clusterMeet: CLUSTER_MEET, + CLUSTER_MYID, + clusterMyId: CLUSTER_MYID, + CLUSTER_NODES, + clusterNodes: CLUSTER_NODES, + CLUSTER_REPLICAS, + clusterReplicas: CLUSTER_REPLICAS, + CLUSTER_REPLICATE, + clusterReplicate: CLUSTER_REPLICATE, + CLUSTER_RESET, + clusterReset: CLUSTER_RESET, + CLUSTER_SAVECONFIG, + clusterSaveConfig: CLUSTER_SAVECONFIG, + CLUSTER_SET_CONFIG_EPOCH, + clusterSetConfigEpoch: CLUSTER_SET_CONFIG_EPOCH, + CLUSTER_SETSLOT, + clusterSetSlot: CLUSTER_SETSLOT, + CLUSTER_SLOTS, + clusterSlots: CLUSTER_SLOTS, COMMAND_COUNT, commandCount: COMMAND_COUNT, COMMAND_GETKEYS, diff --git a/packages/client/lib/cluster/commands.ts b/packages/client/lib/cluster/commands.ts index c814802366d..4b2aba6a7ae 100644 --- a/packages/client/lib/cluster/commands.ts +++ b/packages/client/lib/cluster/commands.ts @@ -10,27 +10,6 @@ import * as BRPOP from '../commands/BRPOP'; import * as BRPOPLPUSH from '../commands/BRPOPLPUSH'; import * as BZPOPMAX from '../commands/BZPOPMAX'; import * as BZPOPMIN from '../commands/BZPOPMIN'; -import * as CLUSTER_ADDSLOTS from '../commands/CLUSTER_ADDSLOTS'; -import * as CLUSTER_BUMPEPOCH from '../commands/CLUSTER_BUMPEPOCH'; -import * as CLUSTER_COUNT_FAILURE_REPORTS from '../commands/CLUSTER_COUNT-FAILURE-REPORTS'; -import * as CLUSTER_COUNTKEYSINSLOT from '../commands/CLUSTER_COUNTKEYSINSLOT'; -import * as CLUSTER_DELSLOTS from '../commands/CLUSTER_DELSLOTS'; -import * as CLUSTER_FAILOVER from '../commands/CLUSTER_FAILOVER'; -import * as CLUSTER_FLUSHSLOTS from '../commands/CLUSTER_FLUSHSLOTS'; -import * as CLUSTER_FORGET from '../commands/CLUSTER_FORGET'; -import * as CLUSTER_GETKEYSINSLOT from '../commands/CLUSTER_GETKEYSINSLOT'; -import * as CLUSTER_INFO from '../commands/CLUSTER_INFO'; -import * as CLUSTER_KEYSLOT from '../commands/CLUSTER_KEYSLOT'; -import * as CLUSTER_MEET from '../commands/CLUSTER_MEET'; -import * as CLUSTER_MYID from '../commands/CLUSTER_MYID'; -import * as CLUSTER_NODES from '../commands/CLUSTER_NODES'; -import * as CLUSTER_REPLICAS from '../commands/CLUSTER_REPLICAS'; -import * as CLUSTER_REPLICATE from '../commands/CLUSTER_REPLICATE'; -import * as CLUSTER_RESET from '../commands/CLUSTER_RESET'; -import * as CLUSTER_SAVECONFIG from '../commands/CLUSTER_SAVECONFIG'; -import * as CLUSTER_SET_CONFIG_EPOCH from '../commands/CLUSTER_SET-CONFIG-EPOCH'; -import * as CLUSTER_SETSLOT from '../commands/CLUSTER_SETSLOT'; -import * as CLUSTER_SLOTS from '../commands/CLUSTER_SLOTS'; import * as COPY from '../commands/COPY'; import * as DECR from '../commands/DECR'; import * as DECRBY from '../commands/DECRBY'; @@ -220,48 +199,6 @@ export default { bzPopMax: BZPOPMAX, BZPOPMIN, bzPopMin: BZPOPMIN, - CLUSTER_ADDSLOTS, - clusterAddSlots: CLUSTER_ADDSLOTS, - CLUSTER_BUMPEPOCH, - clusterBumpEpoch: CLUSTER_BUMPEPOCH, - CLUSTER_COUNT_FAILURE_REPORTS, - clusterCountFailureReports: CLUSTER_COUNT_FAILURE_REPORTS, - CLUSTER_COUNTKEYSINSLOT, - clusterCountKeysInSlot: CLUSTER_COUNTKEYSINSLOT, - CLUSTER_DELSLOTS, - clusterDelSlots: CLUSTER_DELSLOTS, - CLUSTER_FAILOVER, - clusterFailover: CLUSTER_FAILOVER, - CLUSTER_FLUSHSLOTS, - clusterFlushSlots: CLUSTER_FLUSHSLOTS, - CLUSTER_FORGET, - clusterForget: CLUSTER_FORGET, - CLUSTER_GETKEYSINSLOT, - clusterGetKeysInSlot: CLUSTER_GETKEYSINSLOT, - CLUSTER_INFO, - clusterInfo: CLUSTER_INFO, - CLUSTER_KEYSLOT, - clusterKeySlot: CLUSTER_KEYSLOT, - CLUSTER_MEET, - clusterMeet: CLUSTER_MEET, - CLUSTER_MYID, - clusterMyId: CLUSTER_MYID, - CLUSTER_NODES, - clusterNodes: CLUSTER_NODES, - CLUSTER_REPLICAS, - clusterReplicas: CLUSTER_REPLICAS, - CLUSTER_REPLICATE, - clusterReplicate: CLUSTER_REPLICATE, - CLUSTER_RESET, - clusterReset: CLUSTER_RESET, - CLUSTER_SAVECONFIG, - clusterSaveConfig: CLUSTER_SAVECONFIG, - CLUSTER_SET_CONFIG_EPOCH, - clusterSetConfigEpoch: CLUSTER_SET_CONFIG_EPOCH, - CLUSTER_SETSLOT, - clusterSetSlot: CLUSTER_SETSLOT, - CLUSTER_SLOTS, - clusterSlots: CLUSTER_SLOTS, COPY, copy: COPY, DECR, diff --git a/packages/client/lib/commands/CLUSTER_BUMPEPOCH.spec.ts b/packages/client/lib/commands/CLUSTER_BUMPEPOCH.spec.ts index a63d6301ac2..a5feaca12ef 100644 --- a/packages/client/lib/commands/CLUSTER_BUMPEPOCH.spec.ts +++ b/packages/client/lib/commands/CLUSTER_BUMPEPOCH.spec.ts @@ -12,7 +12,7 @@ describe('CLUSTER BUMPEPOCH', () => { testUtils.testWithCluster('cluster.clusterBumpEpoch', async cluster => { assert.equal( - typeof await cluster.clusterBumpEpoch(), + typeof await cluster.getSlotMaster(0).client.clusterBumpEpoch(), 'string' ); }, GLOBAL.SERVERS.OPEN); diff --git a/packages/client/lib/commands/CLUSTER_COUNT-FAILURE-REPORTS.spec.ts b/packages/client/lib/commands/CLUSTER_COUNT-FAILURE-REPORTS.spec.ts index 96d1f6a8bad..fe64f3a0e8e 100644 --- a/packages/client/lib/commands/CLUSTER_COUNT-FAILURE-REPORTS.spec.ts +++ b/packages/client/lib/commands/CLUSTER_COUNT-FAILURE-REPORTS.spec.ts @@ -11,9 +11,9 @@ describe('CLUSTER COUNT-FAILURE-REPORTS', () => { }); testUtils.testWithCluster('cluster.clusterCountFailureReports', async cluster => { - const id: string = await cluster.clusterMyId(); + const id: string = await cluster.getSlotMaster(0).client.clusterMyId(); assert.equal( - await cluster.clusterCountFailureReports(id), + await cluster.getSlotMaster(0).client.clusterCountFailureReports(id), 0 ); }, GLOBAL.CLUSTERS.OPEN); diff --git a/packages/client/lib/commands/CLUSTER_COUNTKEYSINSLOT.spec.ts b/packages/client/lib/commands/CLUSTER_COUNTKEYSINSLOT.spec.ts index 776feed085e..39179eb631e 100644 --- a/packages/client/lib/commands/CLUSTER_COUNTKEYSINSLOT.spec.ts +++ b/packages/client/lib/commands/CLUSTER_COUNTKEYSINSLOT.spec.ts @@ -12,7 +12,7 @@ describe('CLUSTER COUNTKEYSINSLOT', () => { testUtils.testWithCluster('cluster.clusterInfo', async cluster => { assert.equal( - typeof await cluster.clusterCountKeysInSlot(1), + typeof await cluster.getSlotMaster(0).client.clusterCountKeysInSlot(1), 'number' ); }, GLOBAL.CLUSTERS.OPEN); diff --git a/packages/client/lib/commands/CLUSTER_INFO.spec.ts b/packages/client/lib/commands/CLUSTER_INFO.spec.ts index 9abe4e9fa9c..b30814a3666 100644 --- a/packages/client/lib/commands/CLUSTER_INFO.spec.ts +++ b/packages/client/lib/commands/CLUSTER_INFO.spec.ts @@ -47,7 +47,7 @@ describe('CLUSTER INFO', () => { testUtils.testWithCluster('cluster.clusterInfo', async cluster => { assert.notEqual( - await cluster.clusterInfo(), + await cluster.getSlotMaster(0).client.clusterInfo(), null ); }, GLOBAL.CLUSTERS.OPEN); diff --git a/packages/client/lib/commands/CLUSTER_MYID.spec.ts b/packages/client/lib/commands/CLUSTER_MYID.spec.ts index d421a186771..a94502941a8 100644 --- a/packages/client/lib/commands/CLUSTER_MYID.spec.ts +++ b/packages/client/lib/commands/CLUSTER_MYID.spec.ts @@ -12,7 +12,7 @@ describe('CLUSTER MYID', () => { testUtils.testWithCluster('cluster.clusterMyId', async cluster => { assert.notEqual( - await cluster.clusterMyId(), + await cluster.getSlotMaster(0).client.clusterMyId(), null ); }, GLOBAL.CLUSTERS.OPEN); diff --git a/packages/client/lib/commands/CLUSTER_SAVECONFIG.spec.ts b/packages/client/lib/commands/CLUSTER_SAVECONFIG.spec.ts index 81a9e5a3dca..8c607413109 100644 --- a/packages/client/lib/commands/CLUSTER_SAVECONFIG.spec.ts +++ b/packages/client/lib/commands/CLUSTER_SAVECONFIG.spec.ts @@ -12,7 +12,7 @@ describe('CLUSTER SAVECONFIG', () => { testUtils.testWithCluster('cluster.clusterSaveConfig', async cluster => { assert.equal( - await cluster.clusterSaveConfig(), + await cluster.getSlotMaster(0).client.clusterSaveConfig(), 'OK' ); }, GLOBAL.CLUSTERS.OPEN); diff --git a/packages/client/lib/commands/CLUSTER_SET-CONFIG-EPOCH.spec.ts b/packages/client/lib/commands/CLUSTER_SET-CONFIG-EPOCH.spec.ts index 84a1521400e..684522ba898 100644 --- a/packages/client/lib/commands/CLUSTER_SET-CONFIG-EPOCH.spec.ts +++ b/packages/client/lib/commands/CLUSTER_SET-CONFIG-EPOCH.spec.ts @@ -13,7 +13,7 @@ describe('CLUSTER SET-CONFIG-EPOCH', () => { testUtils.testWithCluster('cluster.clusterSetConfigEpoch', async cluster => { try { assert.equal( - await cluster.clusterSetConfigEpoch(1), + await cluster.getSlotMaster(0).client.clusterSetConfigEpoch(1), 'OK' ); } catch (ReplyError) { From 1e2efb9f5f39f920bbe16dc87ad8b3d7d10c027e Mon Sep 17 00:00:00 2001 From: Avital-Fine Date: Tue, 8 Mar 2022 10:29:58 +0100 Subject: [PATCH 11/13] clusterNode --- packages/client/lib/commands/CLUSTER_BUMPEPOCH.spec.ts | 2 +- .../client/lib/commands/CLUSTER_COUNT-FAILURE-REPORTS.spec.ts | 2 +- packages/client/lib/commands/CLUSTER_COUNTKEYSINSLOT.spec.ts | 2 +- packages/client/lib/commands/CLUSTER_INFO.spec.ts | 2 +- packages/client/lib/commands/CLUSTER_MYID.spec.ts | 2 +- packages/client/lib/commands/CLUSTER_SAVECONFIG.spec.ts | 2 +- packages/client/lib/commands/CLUSTER_SET-CONFIG-EPOCH.spec.ts | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/client/lib/commands/CLUSTER_BUMPEPOCH.spec.ts b/packages/client/lib/commands/CLUSTER_BUMPEPOCH.spec.ts index a5feaca12ef..f9d2f5437b2 100644 --- a/packages/client/lib/commands/CLUSTER_BUMPEPOCH.spec.ts +++ b/packages/client/lib/commands/CLUSTER_BUMPEPOCH.spec.ts @@ -10,7 +10,7 @@ describe('CLUSTER BUMPEPOCH', () => { ); }); - testUtils.testWithCluster('cluster.clusterBumpEpoch', async cluster => { + testUtils.testWithCluster('clusterNode.clusterBumpEpoch', async cluster => { assert.equal( typeof await cluster.getSlotMaster(0).client.clusterBumpEpoch(), 'string' diff --git a/packages/client/lib/commands/CLUSTER_COUNT-FAILURE-REPORTS.spec.ts b/packages/client/lib/commands/CLUSTER_COUNT-FAILURE-REPORTS.spec.ts index fe64f3a0e8e..f9f6d443a45 100644 --- a/packages/client/lib/commands/CLUSTER_COUNT-FAILURE-REPORTS.spec.ts +++ b/packages/client/lib/commands/CLUSTER_COUNT-FAILURE-REPORTS.spec.ts @@ -10,7 +10,7 @@ describe('CLUSTER COUNT-FAILURE-REPORTS', () => { ); }); - testUtils.testWithCluster('cluster.clusterCountFailureReports', async cluster => { + testUtils.testWithCluster('clusterNode.clusterCountFailureReports', async cluster => { const id: string = await cluster.getSlotMaster(0).client.clusterMyId(); assert.equal( await cluster.getSlotMaster(0).client.clusterCountFailureReports(id), diff --git a/packages/client/lib/commands/CLUSTER_COUNTKEYSINSLOT.spec.ts b/packages/client/lib/commands/CLUSTER_COUNTKEYSINSLOT.spec.ts index 39179eb631e..aaa8a09c86e 100644 --- a/packages/client/lib/commands/CLUSTER_COUNTKEYSINSLOT.spec.ts +++ b/packages/client/lib/commands/CLUSTER_COUNTKEYSINSLOT.spec.ts @@ -10,7 +10,7 @@ describe('CLUSTER COUNTKEYSINSLOT', () => { ); }); - testUtils.testWithCluster('cluster.clusterInfo', async cluster => { + testUtils.testWithCluster('clusterNode.clusterInfo', async cluster => { assert.equal( typeof await cluster.getSlotMaster(0).client.clusterCountKeysInSlot(1), 'number' diff --git a/packages/client/lib/commands/CLUSTER_INFO.spec.ts b/packages/client/lib/commands/CLUSTER_INFO.spec.ts index b30814a3666..b770ed33616 100644 --- a/packages/client/lib/commands/CLUSTER_INFO.spec.ts +++ b/packages/client/lib/commands/CLUSTER_INFO.spec.ts @@ -45,7 +45,7 @@ describe('CLUSTER INFO', () => { ); }); - testUtils.testWithCluster('cluster.clusterInfo', async cluster => { + testUtils.testWithCluster('clusterNode.clusterInfo', async cluster => { assert.notEqual( await cluster.getSlotMaster(0).client.clusterInfo(), null diff --git a/packages/client/lib/commands/CLUSTER_MYID.spec.ts b/packages/client/lib/commands/CLUSTER_MYID.spec.ts index a94502941a8..5dc4168f518 100644 --- a/packages/client/lib/commands/CLUSTER_MYID.spec.ts +++ b/packages/client/lib/commands/CLUSTER_MYID.spec.ts @@ -10,7 +10,7 @@ describe('CLUSTER MYID', () => { ); }); - testUtils.testWithCluster('cluster.clusterMyId', async cluster => { + testUtils.testWithCluster('clusterNode.clusterMyId', async cluster => { assert.notEqual( await cluster.getSlotMaster(0).client.clusterMyId(), null diff --git a/packages/client/lib/commands/CLUSTER_SAVECONFIG.spec.ts b/packages/client/lib/commands/CLUSTER_SAVECONFIG.spec.ts index 8c607413109..bcdccd90919 100644 --- a/packages/client/lib/commands/CLUSTER_SAVECONFIG.spec.ts +++ b/packages/client/lib/commands/CLUSTER_SAVECONFIG.spec.ts @@ -10,7 +10,7 @@ describe('CLUSTER SAVECONFIG', () => { ); }); - testUtils.testWithCluster('cluster.clusterSaveConfig', async cluster => { + testUtils.testWithCluster('clusterNode.clusterSaveConfig', async cluster => { assert.equal( await cluster.getSlotMaster(0).client.clusterSaveConfig(), 'OK' diff --git a/packages/client/lib/commands/CLUSTER_SET-CONFIG-EPOCH.spec.ts b/packages/client/lib/commands/CLUSTER_SET-CONFIG-EPOCH.spec.ts index 684522ba898..57db372a192 100644 --- a/packages/client/lib/commands/CLUSTER_SET-CONFIG-EPOCH.spec.ts +++ b/packages/client/lib/commands/CLUSTER_SET-CONFIG-EPOCH.spec.ts @@ -10,7 +10,7 @@ describe('CLUSTER SET-CONFIG-EPOCH', () => { ); }); - testUtils.testWithCluster('cluster.clusterSetConfigEpoch', async cluster => { + testUtils.testWithCluster('clusterNode.clusterSetConfigEpoch', async cluster => { try { assert.equal( await cluster.getSlotMaster(0).client.clusterSetConfigEpoch(1), From 990afefd935a383be63e2def0cd4f4ff8ae8b3dd Mon Sep 17 00:00:00 2001 From: Avital-Fine Date: Wed, 9 Mar 2022 10:15:14 +0100 Subject: [PATCH 12/13] remove CLUSTER-SET-CONFIG-EPOCH test with client --- .../lib/commands/CLUSTER_SET-CONFIG-EPOCH.spec.ts | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/packages/client/lib/commands/CLUSTER_SET-CONFIG-EPOCH.spec.ts b/packages/client/lib/commands/CLUSTER_SET-CONFIG-EPOCH.spec.ts index 57db372a192..dd241574168 100644 --- a/packages/client/lib/commands/CLUSTER_SET-CONFIG-EPOCH.spec.ts +++ b/packages/client/lib/commands/CLUSTER_SET-CONFIG-EPOCH.spec.ts @@ -1,5 +1,4 @@ import { strict as assert } from 'assert'; -import testUtils, { GLOBAL } from '../test-utils'; import { transformArguments } from './CLUSTER_SET-CONFIG-EPOCH'; describe('CLUSTER SET-CONFIG-EPOCH', () => { @@ -9,15 +8,4 @@ describe('CLUSTER SET-CONFIG-EPOCH', () => { ['CLUSTER', 'SET-CONFIG-EPOCH', '0'] ); }); - - testUtils.testWithCluster('clusterNode.clusterSetConfigEpoch', async cluster => { - try { - assert.equal( - await cluster.getSlotMaster(0).client.clusterSetConfigEpoch(1), - 'OK' - ); - } catch (ReplyError) { - //? - } - }, GLOBAL.CLUSTERS.OPEN); }); From 4350c57ddc0d59e4b3da4799f714ec6fe20b0109 Mon Sep 17 00:00:00 2001 From: leibale Date: Mon, 28 Mar 2022 02:36:51 +0300 Subject: [PATCH 13/13] clean code --- .../client/lib/commands/CLUSTER_ADDSLOTS.ts | 16 +++++++--------- .../client/lib/commands/CLUSTER_BUMPEPOCH.ts | 4 ++-- .../CLUSTER_COUNT-FAILURE-REPORTS.spec.ts | 12 +++++++----- .../commands/CLUSTER_COUNT-FAILURE-REPORTS.ts | 2 +- .../commands/CLUSTER_COUNTKEYSINSLOT.spec.ts | 8 ++++---- .../lib/commands/CLUSTER_COUNTKEYSINSLOT.ts | 2 +- .../lib/commands/CLUSTER_DELSLOTS.spec.ts | 19 ++++++++++++++----- .../client/lib/commands/CLUSTER_DELSLOTS.ts | 14 +++++++++----- .../lib/commands/CLUSTER_FAILOVER.spec.ts | 1 + .../client/lib/commands/CLUSTER_FAILOVER.ts | 4 ++-- .../client/lib/commands/CLUSTER_FLUSHSLOTS.ts | 2 +- .../client/lib/commands/CLUSTER_FORGET.ts | 2 +- .../commands/CLUSTER_GETKEYSINSLOT.spec.ts | 9 +++++++++ .../lib/commands/CLUSTER_GETKEYSINSLOT.ts | 2 +- .../lib/commands/CLUSTER_KEYSLOT.spec.ts | 8 ++++++++ .../client/lib/commands/CLUSTER_KEYSLOT.ts | 2 +- packages/client/lib/commands/CLUSTER_MEET.ts | 2 +- .../client/lib/commands/CLUSTER_MYID.spec.ts | 6 +++--- .../client/lib/commands/CLUSTER_REPLICAS.ts | 4 ++-- .../client/lib/commands/CLUSTER_REPLICATE.ts | 4 ++-- .../client/lib/commands/CLUSTER_RESET.spec.ts | 9 +-------- packages/client/lib/commands/CLUSTER_RESET.ts | 4 +--- .../client/lib/commands/CLUSTER_SAVECONFIG.ts | 2 +- .../lib/commands/CLUSTER_SET-CONFIG-EPOCH.ts | 2 +- .../client/lib/commands/CLUSTER_SETSLOT.ts | 8 ++++++-- packages/client/lib/commands/CLUSTER_SLOTS.ts | 7 ++++++- .../lib/commands/generic-transformers.spec.ts | 17 +++++++++++++++++ .../lib/commands/generic-transformers.ts | 15 +++++++++++++++ 28 files changed, 125 insertions(+), 62 deletions(-) diff --git a/packages/client/lib/commands/CLUSTER_ADDSLOTS.ts b/packages/client/lib/commands/CLUSTER_ADDSLOTS.ts index e458b8aab91..6cd357fb823 100644 --- a/packages/client/lib/commands/CLUSTER_ADDSLOTS.ts +++ b/packages/client/lib/commands/CLUSTER_ADDSLOTS.ts @@ -1,13 +1,11 @@ -export function transformArguments(slots: number | Array): Array { - const args = ['CLUSTER', 'ADDSLOTS']; +import { RedisCommandArguments } from '.'; +import { pushVerdictNumberArguments } from './generic-transformers'; - if (typeof slots === 'number') { - args.push(slots.toString()); - } else { - args.push(...slots.map(String)); - } - - return args; +export function transformArguments(slots: number | Array): RedisCommandArguments { + return pushVerdictNumberArguments( + ['CLUSTER', 'ADDSLOTS'], + slots + ); } export declare function transformReply(): string; diff --git a/packages/client/lib/commands/CLUSTER_BUMPEPOCH.ts b/packages/client/lib/commands/CLUSTER_BUMPEPOCH.ts index d2b1552e1b0..7f81c8fdc42 100644 --- a/packages/client/lib/commands/CLUSTER_BUMPEPOCH.ts +++ b/packages/client/lib/commands/CLUSTER_BUMPEPOCH.ts @@ -1,5 +1,5 @@ export function transformArguments(): Array { - return ['CLUSTER', 'BUMPEPOCH']; + return ['CLUSTER', 'BUMPEPOCH']; } -export declare function transformReply(): string; +export declare function transformReply(): 'BUMPED' | 'STILL'; diff --git a/packages/client/lib/commands/CLUSTER_COUNT-FAILURE-REPORTS.spec.ts b/packages/client/lib/commands/CLUSTER_COUNT-FAILURE-REPORTS.spec.ts index f9f6d443a45..d84687631bc 100644 --- a/packages/client/lib/commands/CLUSTER_COUNT-FAILURE-REPORTS.spec.ts +++ b/packages/client/lib/commands/CLUSTER_COUNT-FAILURE-REPORTS.spec.ts @@ -5,16 +5,18 @@ import { transformArguments } from './CLUSTER_COUNT-FAILURE-REPORTS'; describe('CLUSTER COUNT-FAILURE-REPORTS', () => { it('transformArguments', () => { assert.deepEqual( - transformArguments('1'), - ['CLUSTER', 'COUNT-FAILURE-REPORTS', '1'] + transformArguments('0'), + ['CLUSTER', 'COUNT-FAILURE-REPORTS', '0'] ); }); testUtils.testWithCluster('clusterNode.clusterCountFailureReports', async cluster => { - const id: string = await cluster.getSlotMaster(0).client.clusterMyId(); + const { client } = cluster.getSlotMaster(0); assert.equal( - await cluster.getSlotMaster(0).client.clusterCountFailureReports(id), - 0 + typeof await client.clusterCountFailureReports( + await client.clusterMyId() + ), + 'number' ); }, GLOBAL.CLUSTERS.OPEN); }); diff --git a/packages/client/lib/commands/CLUSTER_COUNT-FAILURE-REPORTS.ts b/packages/client/lib/commands/CLUSTER_COUNT-FAILURE-REPORTS.ts index 18b36948964..3fbc33052f8 100644 --- a/packages/client/lib/commands/CLUSTER_COUNT-FAILURE-REPORTS.ts +++ b/packages/client/lib/commands/CLUSTER_COUNT-FAILURE-REPORTS.ts @@ -1,5 +1,5 @@ export function transformArguments(nodeId: string): Array { - return ['CLUSTER', 'COUNT-FAILURE-REPORTS', nodeId]; + return ['CLUSTER', 'COUNT-FAILURE-REPORTS', nodeId]; } export declare function transformReply(): number; diff --git a/packages/client/lib/commands/CLUSTER_COUNTKEYSINSLOT.spec.ts b/packages/client/lib/commands/CLUSTER_COUNTKEYSINSLOT.spec.ts index aaa8a09c86e..ecaed428cb7 100644 --- a/packages/client/lib/commands/CLUSTER_COUNTKEYSINSLOT.spec.ts +++ b/packages/client/lib/commands/CLUSTER_COUNTKEYSINSLOT.spec.ts @@ -5,14 +5,14 @@ import { transformArguments } from './CLUSTER_COUNTKEYSINSLOT'; describe('CLUSTER COUNTKEYSINSLOT', () => { it('transformArguments', () => { assert.deepEqual( - transformArguments(1), - ['CLUSTER', 'COUNTKEYSINSLOT', '1'] + transformArguments(0), + ['CLUSTER', 'COUNTKEYSINSLOT', '0'] ); }); - testUtils.testWithCluster('clusterNode.clusterInfo', async cluster => { + testUtils.testWithCluster('clusterNode.clusterCountKeysInSlot', async cluster => { assert.equal( - typeof await cluster.getSlotMaster(0).client.clusterCountKeysInSlot(1), + typeof await cluster.getSlotMaster(0).client.clusterCountKeysInSlot(0), 'number' ); }, GLOBAL.CLUSTERS.OPEN); diff --git a/packages/client/lib/commands/CLUSTER_COUNTKEYSINSLOT.ts b/packages/client/lib/commands/CLUSTER_COUNTKEYSINSLOT.ts index 900af70d738..a5ff75e58a9 100644 --- a/packages/client/lib/commands/CLUSTER_COUNTKEYSINSLOT.ts +++ b/packages/client/lib/commands/CLUSTER_COUNTKEYSINSLOT.ts @@ -1,5 +1,5 @@ export function transformArguments(slot: number): Array { - return ['CLUSTER', 'COUNTKEYSINSLOT', slot.toString()]; + return ['CLUSTER', 'COUNTKEYSINSLOT', slot.toString()]; } export declare function transformReply(): number; diff --git a/packages/client/lib/commands/CLUSTER_DELSLOTS.spec.ts b/packages/client/lib/commands/CLUSTER_DELSLOTS.spec.ts index c47a24d7984..85d13f4ed3d 100644 --- a/packages/client/lib/commands/CLUSTER_DELSLOTS.spec.ts +++ b/packages/client/lib/commands/CLUSTER_DELSLOTS.spec.ts @@ -2,10 +2,19 @@ import { strict as assert } from 'assert'; import { transformArguments } from './CLUSTER_DELSLOTS'; describe('CLUSTER DELSLOTS', () => { - it('simple', () => { - assert.deepEqual( - transformArguments('1'), - ['CLUSTER', 'DELSLOTS', '1'] - ); + describe('transformArguments', () => { + it('single', () => { + assert.deepEqual( + transformArguments(0), + ['CLUSTER', 'DELSLOTS', '0'] + ); + }); + + it('multiple', () => { + assert.deepEqual( + transformArguments([0, 1]), + ['CLUSTER', 'DELSLOTS', '0', '1'] + ); + }); }); }); diff --git a/packages/client/lib/commands/CLUSTER_DELSLOTS.ts b/packages/client/lib/commands/CLUSTER_DELSLOTS.ts index 937a97daeca..bf8d9c18900 100644 --- a/packages/client/lib/commands/CLUSTER_DELSLOTS.ts +++ b/packages/client/lib/commands/CLUSTER_DELSLOTS.ts @@ -1,7 +1,11 @@ -export function transformArguments(...slots: string[]): Array { - const args = ['CLUSTER', 'DELSLOTS']; - args.push(...slots); - return args; +import { RedisCommandArguments } from '.'; +import { pushVerdictNumberArguments } from './generic-transformers'; + +export function transformArguments(slots: number | Array): RedisCommandArguments { + return pushVerdictNumberArguments( + ['CLUSTER', 'DELSLOTS'], + slots + ); } -export declare function transformReply(): string; +export declare function transformReply(): 'OK'; diff --git a/packages/client/lib/commands/CLUSTER_FAILOVER.spec.ts b/packages/client/lib/commands/CLUSTER_FAILOVER.spec.ts index 0455a63d4c4..578ff56b9cd 100644 --- a/packages/client/lib/commands/CLUSTER_FAILOVER.spec.ts +++ b/packages/client/lib/commands/CLUSTER_FAILOVER.spec.ts @@ -9,6 +9,7 @@ describe('CLUSTER FAILOVER', () => { ['CLUSTER', 'FAILOVER'] ); }); + it('with mode', () => { assert.deepEqual( transformArguments(FailoverModes.FORCE), diff --git a/packages/client/lib/commands/CLUSTER_FAILOVER.ts b/packages/client/lib/commands/CLUSTER_FAILOVER.ts index c73403885f5..9bc4b69f343 100644 --- a/packages/client/lib/commands/CLUSTER_FAILOVER.ts +++ b/packages/client/lib/commands/CLUSTER_FAILOVER.ts @@ -4,7 +4,7 @@ export enum FailoverModes { } export function transformArguments(mode?: FailoverModes): Array { - const args = ['CLUSTER', 'FAILOVER']; + const args = ['CLUSTER', 'FAILOVER']; if (mode) { args.push(mode); @@ -13,4 +13,4 @@ export function transformArguments(mode?: FailoverModes): Array { return args; } -export declare function transformReply(): string; +export declare function transformReply(): 'OK'; diff --git a/packages/client/lib/commands/CLUSTER_FLUSHSLOTS.ts b/packages/client/lib/commands/CLUSTER_FLUSHSLOTS.ts index 285c9fd26fe..dfb1e1ccde8 100644 --- a/packages/client/lib/commands/CLUSTER_FLUSHSLOTS.ts +++ b/packages/client/lib/commands/CLUSTER_FLUSHSLOTS.ts @@ -2,4 +2,4 @@ export function transformArguments(): Array { return ['CLUSTER', 'FLUSHSLOTS']; } -export declare function transformReply(): string; +export declare function transformReply(): 'OK'; diff --git a/packages/client/lib/commands/CLUSTER_FORGET.ts b/packages/client/lib/commands/CLUSTER_FORGET.ts index 7f0e6f00c7c..fc557073aeb 100644 --- a/packages/client/lib/commands/CLUSTER_FORGET.ts +++ b/packages/client/lib/commands/CLUSTER_FORGET.ts @@ -2,4 +2,4 @@ export function transformArguments(nodeId: string): Array { return ['CLUSTER', 'FORGET', nodeId]; } -export declare function transformReply(): string; +export declare function transformReply(): 'OK'; diff --git a/packages/client/lib/commands/CLUSTER_GETKEYSINSLOT.spec.ts b/packages/client/lib/commands/CLUSTER_GETKEYSINSLOT.spec.ts index bb20f7521de..7c156341301 100644 --- a/packages/client/lib/commands/CLUSTER_GETKEYSINSLOT.spec.ts +++ b/packages/client/lib/commands/CLUSTER_GETKEYSINSLOT.spec.ts @@ -1,4 +1,5 @@ import { strict as assert } from 'assert'; +import testUtils, { GLOBAL } from '../test-utils'; import { transformArguments } from './CLUSTER_GETKEYSINSLOT'; describe('CLUSTER GETKEYSINSLOT', () => { @@ -8,4 +9,12 @@ describe('CLUSTER GETKEYSINSLOT', () => { ['CLUSTER', 'GETKEYSINSLOT', '0', '10'] ); }); + + testUtils.testWithCluster('clusterNode.clusterGetKeysInSlot', async cluster => { + const reply = await cluster.getSlotMaster(0).client.clusterGetKeysInSlot(0, 1); + assert.ok(Array.isArray(reply)); + for (const item of reply) { + assert.equal(typeof item, 'string'); + } + }, GLOBAL.CLUSTERS.OPEN); }); diff --git a/packages/client/lib/commands/CLUSTER_GETKEYSINSLOT.ts b/packages/client/lib/commands/CLUSTER_GETKEYSINSLOT.ts index 67c5cbafb77..ec75b7b7336 100644 --- a/packages/client/lib/commands/CLUSTER_GETKEYSINSLOT.ts +++ b/packages/client/lib/commands/CLUSTER_GETKEYSINSLOT.ts @@ -2,4 +2,4 @@ export function transformArguments(slot: number, count: number): Array { return ['CLUSTER', 'GETKEYSINSLOT', slot.toString(), count.toString()]; } -export declare function transformReply(): string; +export declare function transformReply(): Array; diff --git a/packages/client/lib/commands/CLUSTER_KEYSLOT.spec.ts b/packages/client/lib/commands/CLUSTER_KEYSLOT.spec.ts index f71468112e1..a7a5ab9472f 100644 --- a/packages/client/lib/commands/CLUSTER_KEYSLOT.spec.ts +++ b/packages/client/lib/commands/CLUSTER_KEYSLOT.spec.ts @@ -1,4 +1,5 @@ import { strict as assert } from 'assert'; +import testUtils, { GLOBAL } from '../test-utils'; import { transformArguments } from './CLUSTER_KEYSLOT'; describe('CLUSTER KEYSLOT', () => { @@ -8,4 +9,11 @@ describe('CLUSTER KEYSLOT', () => { ['CLUSTER', 'KEYSLOT', 'key'] ); }); + + testUtils.testWithCluster('clusterNode.clusterKeySlot', async cluster => { + assert.equal( + typeof await cluster.getSlotMaster(0).client.clusterKeySlot('key'), + 'number' + ); + }, GLOBAL.CLUSTERS.OPEN); }); diff --git a/packages/client/lib/commands/CLUSTER_KEYSLOT.ts b/packages/client/lib/commands/CLUSTER_KEYSLOT.ts index 9ee881cadf4..0af524ff128 100644 --- a/packages/client/lib/commands/CLUSTER_KEYSLOT.ts +++ b/packages/client/lib/commands/CLUSTER_KEYSLOT.ts @@ -1,5 +1,5 @@ export function transformArguments(key: string): Array { - return ['CLUSTER', 'KEYSLOT', key]; + return ['CLUSTER', 'KEYSLOT', key]; } export declare function transformReply(): number; diff --git a/packages/client/lib/commands/CLUSTER_MEET.ts b/packages/client/lib/commands/CLUSTER_MEET.ts index 54a0bf708a8..e6ce1c1fce4 100644 --- a/packages/client/lib/commands/CLUSTER_MEET.ts +++ b/packages/client/lib/commands/CLUSTER_MEET.ts @@ -2,4 +2,4 @@ export function transformArguments(ip: string, port: number): Array { return ['CLUSTER', 'MEET', ip, port.toString()]; } -export declare function transformReply(): string; +export declare function transformReply(): 'OK'; diff --git a/packages/client/lib/commands/CLUSTER_MYID.spec.ts b/packages/client/lib/commands/CLUSTER_MYID.spec.ts index 5dc4168f518..7781c374526 100644 --- a/packages/client/lib/commands/CLUSTER_MYID.spec.ts +++ b/packages/client/lib/commands/CLUSTER_MYID.spec.ts @@ -11,9 +11,9 @@ describe('CLUSTER MYID', () => { }); testUtils.testWithCluster('clusterNode.clusterMyId', async cluster => { - assert.notEqual( - await cluster.getSlotMaster(0).client.clusterMyId(), - null + assert.equal( + typeof await cluster.getSlotMaster(0).client.clusterMyId(), + 'string' ); }, GLOBAL.CLUSTERS.OPEN); }); diff --git a/packages/client/lib/commands/CLUSTER_REPLICAS.ts b/packages/client/lib/commands/CLUSTER_REPLICAS.ts index 80dbbffe831..a4130125fbf 100644 --- a/packages/client/lib/commands/CLUSTER_REPLICAS.ts +++ b/packages/client/lib/commands/CLUSTER_REPLICAS.ts @@ -1,5 +1,5 @@ export function transformArguments(nodeId: string): Array { - return ['CLUSTER', 'REPLICAS', nodeId]; + return ['CLUSTER', 'REPLICAS', nodeId]; } -export { transformReply } from './CLUSTER_NODES' +export { transformReply } from './CLUSTER_NODES'; diff --git a/packages/client/lib/commands/CLUSTER_REPLICATE.ts b/packages/client/lib/commands/CLUSTER_REPLICATE.ts index 453865344fe..c74e1ec5960 100644 --- a/packages/client/lib/commands/CLUSTER_REPLICATE.ts +++ b/packages/client/lib/commands/CLUSTER_REPLICATE.ts @@ -1,5 +1,5 @@ export function transformArguments(nodeId: string): Array { - return ['CLUSTER', 'REPLICATE', nodeId]; + return ['CLUSTER', 'REPLICATE', nodeId]; } -export declare function transformReply(): string; +export declare function transformReply(): 'OK'; diff --git a/packages/client/lib/commands/CLUSTER_RESET.spec.ts b/packages/client/lib/commands/CLUSTER_RESET.spec.ts index c077e7f8874..340da7457c1 100644 --- a/packages/client/lib/commands/CLUSTER_RESET.spec.ts +++ b/packages/client/lib/commands/CLUSTER_RESET.spec.ts @@ -10,18 +10,11 @@ describe('CLUSTER RESET', () => { ); }); - it('HARD', () => { + it('with mode', () => { assert.deepEqual( transformArguments('HARD'), ['CLUSTER', 'RESET', 'HARD'] ); }); - - it('SOFT', () => { - assert.deepEqual( - transformArguments('SOFT'), - ['CLUSTER', 'RESET', 'SOFT'] - ); - }); }); }); diff --git a/packages/client/lib/commands/CLUSTER_RESET.ts b/packages/client/lib/commands/CLUSTER_RESET.ts index 3e7c5bb52fb..c6901e045dc 100644 --- a/packages/client/lib/commands/CLUSTER_RESET.ts +++ b/packages/client/lib/commands/CLUSTER_RESET.ts @@ -1,6 +1,4 @@ -export type ClusterResetModes = 'HARD' | 'SOFT'; - -export function transformArguments(mode?: ClusterResetModes): Array { +export function transformArguments(mode?: 'HARD' | 'SOFT'): Array { const args = ['CLUSTER', 'RESET']; if (mode) { diff --git a/packages/client/lib/commands/CLUSTER_SAVECONFIG.ts b/packages/client/lib/commands/CLUSTER_SAVECONFIG.ts index 68e8d6e4cab..7e7fb181cc6 100644 --- a/packages/client/lib/commands/CLUSTER_SAVECONFIG.ts +++ b/packages/client/lib/commands/CLUSTER_SAVECONFIG.ts @@ -2,4 +2,4 @@ export function transformArguments(): Array { return ['CLUSTER', 'SAVECONFIG']; } -export declare function transformReply(): string; +export declare function transformReply(): 'OK'; diff --git a/packages/client/lib/commands/CLUSTER_SET-CONFIG-EPOCH.ts b/packages/client/lib/commands/CLUSTER_SET-CONFIG-EPOCH.ts index a697edf01c4..c50a6b9d3a5 100644 --- a/packages/client/lib/commands/CLUSTER_SET-CONFIG-EPOCH.ts +++ b/packages/client/lib/commands/CLUSTER_SET-CONFIG-EPOCH.ts @@ -2,4 +2,4 @@ export function transformArguments(configEpoch: number): Array { return ['CLUSTER', 'SET-CONFIG-EPOCH', configEpoch.toString()]; } -export declare function transformReply(): string; +export declare function transformReply(): 'OK'; diff --git a/packages/client/lib/commands/CLUSTER_SETSLOT.ts b/packages/client/lib/commands/CLUSTER_SETSLOT.ts index 591b5fb9632..c01505c71a3 100644 --- a/packages/client/lib/commands/CLUSTER_SETSLOT.ts +++ b/packages/client/lib/commands/CLUSTER_SETSLOT.ts @@ -5,7 +5,11 @@ export enum ClusterSlotStates { NODE = 'NODE' } -export function transformArguments(slot: number, state: ClusterSlotStates, nodeId?: string): Array { +export function transformArguments( + slot: number, + state: ClusterSlotStates, + nodeId?: string +): Array { const args = ['CLUSTER', 'SETSLOT', slot.toString(), state]; if (nodeId) { @@ -15,4 +19,4 @@ export function transformArguments(slot: number, state: ClusterSlotStates, nodeI return args; } -export declare function transformReply(): string; +export declare function transformReply(): 'OK'; diff --git a/packages/client/lib/commands/CLUSTER_SLOTS.ts b/packages/client/lib/commands/CLUSTER_SLOTS.ts index afe1ebc83dd..7e1f5dcc964 100644 --- a/packages/client/lib/commands/CLUSTER_SLOTS.ts +++ b/packages/client/lib/commands/CLUSTER_SLOTS.ts @@ -6,7 +6,12 @@ export function transformArguments(): RedisCommandArguments { type ClusterSlotsRawNode = [ip: string, port: number, id: string]; -type ClusterSlotsRawReply = Array<[from: number, to: number, master: ClusterSlotsRawNode, ...replicas: Array]>; +type ClusterSlotsRawReply = Array<[ + from: number, + to: number, + master: ClusterSlotsRawNode, + ...replicas: Array +]>; type ClusterSlotsNode = { ip: string; diff --git a/packages/client/lib/commands/generic-transformers.spec.ts b/packages/client/lib/commands/generic-transformers.spec.ts index 6e286e284d9..301cab0a75c 100644 --- a/packages/client/lib/commands/generic-transformers.spec.ts +++ b/packages/client/lib/commands/generic-transformers.spec.ts @@ -19,6 +19,7 @@ import { transformPXAT, pushEvalArguments, pushVerdictArguments, + pushVerdictNumberArguments, pushVerdictArgument, pushOptionalVerdictArgument, transformCommandReply, @@ -579,6 +580,22 @@ describe('Generic Transformers', () => { }); }); + describe('pushVerdictNumberArguments', () => { + it('number', () => { + assert.deepEqual( + pushVerdictNumberArguments([], 0), + ['0'] + ); + }); + + it('array', () => { + assert.deepEqual( + pushVerdictNumberArguments([], [0, 1]), + ['0', '1'] + ); + }); + }); + describe('pushVerdictArgument', () => { it('string', () => { assert.deepEqual( diff --git a/packages/client/lib/commands/generic-transformers.ts b/packages/client/lib/commands/generic-transformers.ts index a7bc6805dde..f138cb0430b 100644 --- a/packages/client/lib/commands/generic-transformers.ts +++ b/packages/client/lib/commands/generic-transformers.ts @@ -322,6 +322,21 @@ export function pushVerdictArguments(args: RedisCommandArguments, value: RedisCo return args; } +export function pushVerdictNumberArguments( + args: RedisCommandArguments, + value: number | Array +): RedisCommandArguments { + if (Array.isArray(value)) { + for (const item of value) { + args.push(item.toString()); + } + } else { + args.push(value.toString()); + } + + return args; +} + export function pushVerdictArgument( args: RedisCommandArguments, value: RedisCommandArgument | Array