1
0
mirror of https://github.com/redis/node-redis.git synced 2025-12-15 23:55:38 +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:
Kumar Arnav
2023-05-29 18:30:58 +05:30
committed by GitHub
parent 499ea85594
commit e696653bf9
5 changed files with 57 additions and 13 deletions

View File

@@ -24,9 +24,5 @@ describe('LATENCY GRAPH', () => {
typeof await client.latencyGraph('command'),
'string'
);
}, {
serverArguments: testUtils.isVersionGreaterThan([7]) ?
['--enable-debug-command', 'yes'] :
GLOBAL.SERVERS.OPEN.serverArguments
});
}, GLOBAL.SERVERS.OPEN);
});

View 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);
});

View 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
]>;