1
0
mirror of https://github.com/redis/node-redis.git synced 2025-08-04 15:02:09 +03:00

V5 bringing RESP3, Sentinel and TypeMapping to node-redis

RESP3 Support
   - Some commands responses in RESP3 aren't stable yet and therefore return an "untyped" ReplyUnion.
 
Sentinel

TypeMapping

Correctly types Multi commands

Note: some API changes to be further documented in v4-to-v5.md
This commit is contained in:
Shaya Potter
2024-10-15 17:46:52 +03:00
committed by GitHub
parent 2fc79bdfb3
commit b2d35c5286
1174 changed files with 45931 additions and 36274 deletions

View File

@@ -1,108 +1,46 @@
import { strict as assert } from 'assert';
import { transformArguments, transformReply } from './MEMORY_STATS';
import { strict as assert } from 'node:assert';
import testUtils, { GLOBAL } from '../test-utils';
import MEMORY_STATS from './MEMORY_STATS';
describe('MEMORY STATS', () => {
it('transformArguments', () => {
assert.deepEqual(
transformArguments(),
['MEMORY', 'STATS']
);
});
it('transformArguments', () => {
assert.deepEqual(
MEMORY_STATS.transformArguments(),
['MEMORY', 'STATS']
);
});
it('transformReply', () => {
assert.deepEqual(
transformReply([
'peak.allocated',
952728,
'total.allocated',
892904,
'startup.allocated',
809952,
'replication.backlog',
0,
'clients.slaves',
0,
'clients.normal',
41000,
'aof.buffer',
0,
'lua.caches',
0,
'db.0',
[
'overhead.hashtable.main',
72,
'overhead.hashtable.expires',
0
],
'overhead.total',
850952,
'keys.count',
0,
'keys.bytes-per-key',
0,
'dataset.bytes',
41952,
'dataset.percentage',
'50.573825836181641',
'peak.percentage',
'93.720771789550781',
'allocator.allocated',
937632,
'allocator.active',
1191936,
'allocator.resident',
4005888,
'allocator-fragmentation.ratio',
'1.2712193727493286',
'allocator-fragmentation.bytes',
254304,
'allocator-rss.ratio',
'3.3608248233795166',
'allocator-rss.bytes',
2813952,
'rss-overhead.ratio',
'2.4488751888275146',
'rss-overhead.bytes',
5804032,
'fragmentation',
'11.515504837036133',
'fragmentation.bytes',
8958032
]),
{
peakAllocated: 952728,
totalAllocated: 892904,
startupAllocated: 809952,
replicationBacklog: 0,
clientsReplicas: 0,
clientsNormal: 41000,
aofBuffer: 0,
luaCaches: 0,
overheadTotal: 850952,
keysCount: 0,
keysBytesPerKey: 0,
datasetBytes: 41952,
datasetPercentage: 50.573825836181641,
peakPercentage: 93.720771789550781,
allocatorAllocated: 937632,
allocatorActive: 1191936,
allocatorResident: 4005888,
allocatorFragmentationRatio: 1.2712193727493286,
allocatorFragmentationBytes: 254304,
allocatorRssRatio: 3.3608248233795166,
allocatorRssBytes: 2813952,
rssOverheadRatio: 2.4488751888275146,
rssOverheadBytes: 5804032,
fragmentation: 11.515504837036133,
fragmentationBytes: 8958032,
db: {
0: {
overheadHashtableMain: 72,
overheadHashtableExpires: 0
}
}
}
);
});
testUtils.testWithClient('client.memoryStats', async client => {
const memoryStats = await client.memoryStats();
assert.equal(typeof memoryStats['peak.allocated'], 'number');
assert.equal(typeof memoryStats['total.allocated'], 'number');
assert.equal(typeof memoryStats['startup.allocated'], 'number');
assert.equal(typeof memoryStats['replication.backlog'], 'number');
assert.equal(typeof memoryStats['clients.slaves'], 'number');
assert.equal(typeof memoryStats['clients.normal'], 'number');
assert.equal(typeof memoryStats['aof.buffer'], 'number');
assert.equal(typeof memoryStats['lua.caches'], 'number');
assert.equal(typeof memoryStats['overhead.total'], 'number');
assert.equal(typeof memoryStats['keys.count'], 'number');
assert.equal(typeof memoryStats['keys.bytes-per-key'], 'number');
assert.equal(typeof memoryStats['dataset.bytes'], 'number');
assert.equal(typeof memoryStats['dataset.percentage'], 'number');
assert.equal(typeof memoryStats['peak.percentage'], 'number');
assert.equal(typeof memoryStats['allocator.allocated'], 'number');
assert.equal(typeof memoryStats['allocator.active'], 'number');
assert.equal(typeof memoryStats['allocator.resident'], 'number');
assert.equal(typeof memoryStats['allocator-fragmentation.ratio'], 'number', 'allocator-fragmentation.ratio');
assert.equal(typeof memoryStats['allocator-fragmentation.bytes'], 'number');
assert.equal(typeof memoryStats['allocator-rss.ratio'], 'number', 'allocator-rss.ratio');
assert.equal(typeof memoryStats['allocator-rss.bytes'], 'number');
assert.equal(typeof memoryStats['rss-overhead.ratio'], 'number', 'rss-overhead.ratio');
assert.equal(typeof memoryStats['rss-overhead.bytes'], 'number');
assert.equal(typeof memoryStats['fragmentation'], 'number', 'fragmentation');
assert.equal(typeof memoryStats['fragmentation.bytes'], 'number');
if (testUtils.isVersionGreaterThan([7])) {
assert.equal(typeof memoryStats['cluster.links'], 'number');
assert.equal(typeof memoryStats['functions.caches'], 'number');
}
}, GLOBAL.SERVERS.OPEN);
});