diff --git a/lib/commands/CLUSTER_INFO.spec.ts b/lib/commands/CLUSTER_INFO.spec.ts index a4def45cb7..ce41151b67 100644 --- a/lib/commands/CLUSTER_INFO.spec.ts +++ b/lib/commands/CLUSTER_INFO.spec.ts @@ -1,4 +1,5 @@ import { strict as assert } from 'assert'; +import { itWithCluster, TestRedisClusters } from '../test-utils'; import { transformArguments, transformReply } from './CLUSTER_INFO'; describe('CLUSTER INFO', () => { @@ -43,4 +44,21 @@ describe('CLUSTER INFO', () => { } ); }); + + itWithCluster(TestRedisClusters.OPEN, 'cluster.clusterInfo', async cluster => { + const info = await cluster.clusterInfo(); + assert.equal(info.state, 'ok'); + assert.deepEqual(info.slots, { + assigned: 16384, + ok: 16384, + pfail: 0, + fail: 0 + }); + assert.equal(info.knownNodes, 3); + assert.equal(info.size, 3); + assert.equal(typeof info.currentEpoch, 'number'); + assert.equal(typeof info.myEpoch, 'number'); + assert.equal(typeof info.stats.messagesReceived, 'number'); + assert.equal(typeof info.stats.messagesSent, 'number'); + }); }); diff --git a/lib/commands/CLUSTER_NODES.spec.ts b/lib/commands/CLUSTER_NODES.spec.ts index 2b3881d8cd..b577b631fe 100644 --- a/lib/commands/CLUSTER_NODES.spec.ts +++ b/lib/commands/CLUSTER_NODES.spec.ts @@ -1,4 +1,5 @@ import { strict as assert } from 'assert'; +import { itWithCluster, TestRedisClusters } from '../test-utils'; import { RedisClusterNodeLinkStates, transformArguments, transformReply } from './CLUSTER_NODES'; describe('CLUSTER NODES', () => { @@ -92,4 +93,26 @@ describe('CLUSTER NODES', () => { ); }); }); + + itWithCluster(TestRedisClusters.OPEN, 'cluster.clusterNodes', async cluster => { + const nodes = await cluster.clusterNodes(); + + for (const node of (await cluster.clusterNodes())) { + assert.equal(typeof node.id, 'string'); + assert.equal(typeof node.url, 'string'); + assert.equal(typeof node.host, 'string'); + assert.equal(typeof node.port, 'number'); + assert.equal(typeof node.cport, 'number'); + assert.ok(Array.isArray(node.flags)); + assert.equal(typeof node.pingSent, 'number'); + assert.equal(typeof node.pongRecv, 'number'); + assert.equal(typeof node.configEpoch, 'number'); + assert.equal(typeof node.linkState, 'string'); + + for (const slot of node.slots) { + assert.equal(typeof slot.from, 'number'); + assert.equal(typeof slot.to, 'number'); + } + } + }); }); diff --git a/lib/commands/CLUSTER_NODES.ts b/lib/commands/CLUSTER_NODES.ts index dd2bab36df..d04ffc10a1 100644 --- a/lib/commands/CLUSTER_NODES.ts +++ b/lib/commands/CLUSTER_NODES.ts @@ -16,7 +16,7 @@ interface RedisClusterNodeTransformedUrl { export interface RedisClusterReplicaNode extends RedisClusterNodeTransformedUrl { id: string; url: string; - flags: Array, + flags: Array; pingSent: number; pongRecv: number; configEpoch: number; @@ -25,8 +25,8 @@ export interface RedisClusterReplicaNode extends RedisClusterNodeTransformedUrl export interface RedisClusterMasterNode extends RedisClusterReplicaNode { slots: Array<{ - from: number, - to: number + from: number; + to: number; }>; replicas: Array; }