You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-06 02:15:48 +03:00
Add support for LATENCY LATEST
(#2514)
* Add support for LATENCY LATEST. * Fix the review comments. * Fix the review comments. * Update LATENCY_LATEST.ts * Update dockers.ts * Update LATENCY_GRAPH.spec.ts * enable debug mode in tests --------- Co-authored-by: Leibale Eidelman <me@leibale.com>
This commit is contained in:
@@ -84,6 +84,7 @@ import * as KEYS from '../commands/KEYS';
|
|||||||
import * as LASTSAVE from '../commands/LASTSAVE';
|
import * as LASTSAVE from '../commands/LASTSAVE';
|
||||||
import * as LATENCY_DOCTOR from '../commands/LATENCY_DOCTOR';
|
import * as LATENCY_DOCTOR from '../commands/LATENCY_DOCTOR';
|
||||||
import * as LATENCY_GRAPH from '../commands/LATENCY_GRAPH';
|
import * as LATENCY_GRAPH from '../commands/LATENCY_GRAPH';
|
||||||
|
import * as LATENCY_LATEST from '../commands/LATENCY_LATEST';
|
||||||
import * as LOLWUT from '../commands/LOLWUT';
|
import * as LOLWUT from '../commands/LOLWUT';
|
||||||
import * as MEMORY_DOCTOR from '../commands/MEMORY_DOCTOR';
|
import * as MEMORY_DOCTOR from '../commands/MEMORY_DOCTOR';
|
||||||
import * as MEMORY_MALLOC_STATS from '../commands/MEMORY_MALLOC-STATS';
|
import * as MEMORY_MALLOC_STATS from '../commands/MEMORY_MALLOC-STATS';
|
||||||
@@ -290,6 +291,8 @@ export default {
|
|||||||
latencyDoctor: LATENCY_DOCTOR,
|
latencyDoctor: LATENCY_DOCTOR,
|
||||||
LATENCY_GRAPH,
|
LATENCY_GRAPH,
|
||||||
latencyGraph: LATENCY_GRAPH,
|
latencyGraph: LATENCY_GRAPH,
|
||||||
|
LATENCY_LATEST,
|
||||||
|
latencyLatest: LATENCY_LATEST,
|
||||||
LOLWUT,
|
LOLWUT,
|
||||||
lolwut: LOLWUT,
|
lolwut: LOLWUT,
|
||||||
MEMORY_DOCTOR,
|
MEMORY_DOCTOR,
|
||||||
|
@@ -24,9 +24,5 @@ describe('LATENCY GRAPH', () => {
|
|||||||
typeof await client.latencyGraph('command'),
|
typeof await client.latencyGraph('command'),
|
||||||
'string'
|
'string'
|
||||||
);
|
);
|
||||||
}, {
|
}, GLOBAL.SERVERS.OPEN);
|
||||||
serverArguments: testUtils.isVersionGreaterThan([7]) ?
|
|
||||||
['--enable-debug-command', 'yes'] :
|
|
||||||
GLOBAL.SERVERS.OPEN.serverArguments
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
27
packages/client/lib/commands/LATENCY_LATEST.spec.ts
Normal file
27
packages/client/lib/commands/LATENCY_LATEST.spec.ts
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
import {strict as assert} from 'assert';
|
||||||
|
import testUtils, {GLOBAL} from '../test-utils';
|
||||||
|
import { transformArguments } from './LATENCY_LATEST';
|
||||||
|
|
||||||
|
describe('LATENCY LATEST', () => {
|
||||||
|
it('transformArguments', () => {
|
||||||
|
assert.deepEqual(
|
||||||
|
transformArguments(),
|
||||||
|
['LATENCY', 'LATEST']
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
testUtils.testWithClient('client.latencyLatest', async client => {
|
||||||
|
await Promise.all([
|
||||||
|
client.configSet('latency-monitor-threshold', '100'),
|
||||||
|
client.sendCommand(['DEBUG', 'SLEEP', '1'])
|
||||||
|
]);
|
||||||
|
const latency = await client.latencyLatest();
|
||||||
|
assert.ok(Array.isArray(latency));
|
||||||
|
for (const [name, timestamp, latestLatency, allTimeLatency] of latency) {
|
||||||
|
assert.equal(typeof name, 'string');
|
||||||
|
assert.equal(typeof timestamp, 'number');
|
||||||
|
assert.equal(typeof latestLatency, 'number');
|
||||||
|
assert.equal(typeof allTimeLatency, 'number');
|
||||||
|
}
|
||||||
|
}, GLOBAL.SERVERS.OPEN);
|
||||||
|
});
|
12
packages/client/lib/commands/LATENCY_LATEST.ts
Normal file
12
packages/client/lib/commands/LATENCY_LATEST.ts
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
import { RedisCommandArguments } from '.';
|
||||||
|
|
||||||
|
export function transformArguments(): RedisCommandArguments {
|
||||||
|
return ['LATENCY', 'LATEST'];
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare function transformReply(): Array<[
|
||||||
|
name: string,
|
||||||
|
timestamp: number,
|
||||||
|
latestLatency: number,
|
||||||
|
allTimeLatency: number
|
||||||
|
]>;
|
@@ -2,18 +2,24 @@ import TestUtils from '@redis/test-utils';
|
|||||||
import { SinonSpy } from 'sinon';
|
import { SinonSpy } from 'sinon';
|
||||||
import { promiseTimeout } from './utils';
|
import { promiseTimeout } from './utils';
|
||||||
|
|
||||||
export default new TestUtils({
|
const utils = new TestUtils({
|
||||||
dockerImageName: 'redis',
|
dockerImageName: 'redis',
|
||||||
dockerImageVersionArgument: 'redis-version'
|
dockerImageVersionArgument: 'redis-version'
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export default utils;
|
||||||
|
|
||||||
|
const DEBUG_MODE_ARGS = utils.isVersionGreaterThan([7]) ?
|
||||||
|
['--enable-debug-command', 'yes'] :
|
||||||
|
[];
|
||||||
|
|
||||||
export const GLOBAL = {
|
export const GLOBAL = {
|
||||||
SERVERS: {
|
SERVERS: {
|
||||||
OPEN: {
|
OPEN: {
|
||||||
serverArguments: []
|
serverArguments: [...DEBUG_MODE_ARGS]
|
||||||
},
|
},
|
||||||
PASSWORD: {
|
PASSWORD: {
|
||||||
serverArguments: ['--requirepass', 'password'],
|
serverArguments: ['--requirepass', 'password', ...DEBUG_MODE_ARGS],
|
||||||
clientOptions: {
|
clientOptions: {
|
||||||
password: 'password'
|
password: 'password'
|
||||||
}
|
}
|
||||||
@@ -21,10 +27,10 @@ export const GLOBAL = {
|
|||||||
},
|
},
|
||||||
CLUSTERS: {
|
CLUSTERS: {
|
||||||
OPEN: {
|
OPEN: {
|
||||||
serverArguments: []
|
serverArguments: [...DEBUG_MODE_ARGS]
|
||||||
},
|
},
|
||||||
PASSWORD: {
|
PASSWORD: {
|
||||||
serverArguments: ['--requirepass', 'password'],
|
serverArguments: ['--requirepass', 'password', ...DEBUG_MODE_ARGS],
|
||||||
clusterConfiguration: {
|
clusterConfiguration: {
|
||||||
defaults: {
|
defaults: {
|
||||||
password: 'password'
|
password: 'password'
|
||||||
@@ -32,7 +38,7 @@ export const GLOBAL = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
WITH_REPLICAS: {
|
WITH_REPLICAS: {
|
||||||
serverArguments: [],
|
serverArguments: [...DEBUG_MODE_ARGS],
|
||||||
numberOfMasters: 2,
|
numberOfMasters: 2,
|
||||||
numberOfReplicas: 1,
|
numberOfReplicas: 1,
|
||||||
clusterConfiguration: {
|
clusterConfiguration: {
|
||||||
|
Reference in New Issue
Block a user