Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

changes to support testing against an external redis-enterprise instance #2751

Draft
wants to merge 1 commit into
base: v5
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions packages/client/lib/client/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ describe('Client', () => {
...GLOBAL.SERVERS.PASSWORD.clientOptions,
database: 2
},
minimumDockerVersion: [6, 2]
minimumDockerVersion: [6, 2],
redisEnterpriseNotSupported: true,
});
});

Expand Down Expand Up @@ -278,7 +279,8 @@ describe('Client', () => {
);
}, {
...GLOBAL.SERVERS.OPEN,
minimumDockerVersion: [6, 2] // CLIENT INFO
minimumDockerVersion: [6, 2], // CLIENT INFO
redisEnterpriseNotSupported: true,
});

testUtils.testWithClient('should handle error replies (#2665)', async client => {
Expand Down Expand Up @@ -407,7 +409,8 @@ describe('Client', () => {
);
}, {
...GLOBAL.SERVERS.OPEN,
minimumDockerVersion: [6, 2] // CLIENT INFO
minimumDockerVersion: [6, 2], // CLIENT INFO
redisEnterpriseNotSupported: true,
});

testUtils.testWithClient('scanIterator', async client => {
Expand Down Expand Up @@ -750,7 +753,9 @@ describe('Client', () => {
client.reset()
]);
await assert.doesNotReject(client.ping());
}, GLOBAL.SERVERS.OPEN);
}, {
...GLOBAL.SERVERS.OPEN,
});

testUtils.testWithClient('should respect type mapping', async client => {
const duplicate = await client.duplicate().connect(),
Expand Down
17 changes: 5 additions & 12 deletions packages/client/lib/client/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -942,22 +942,15 @@ export default class RedisClient<
* Reset the client to its default state (i.e. stop PubSub, stop monitoring, select default DB, etc.)
*/
async reset() {
const chainId = Symbol('Reset Chain'),
promises = [this._self.#queue.reset(chainId)],
selectedDB = this._self.#options?.database ?? 0;
for (const command of this._self.#handshake(selectedDB)) {
promises.push(
this._self.#queue.addCommand(command, {
chainId
})
);
}
this._self.#scheduleWrite();
await Promise.all(promises);
const selectedDB = this._self.#options?.database ?? 0;
this.destroy();

this._self.#selectedDB = selectedDB;
this._self.#monitorCallback = undefined;
this._self.#dirtyWatch = undefined;
this._self.#watchEpoch = undefined;

await this.connect();
}

/**
Expand Down
5 changes: 4 additions & 1 deletion packages/client/lib/commands/ACL_DELUSER.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,8 @@ describe('ACL DELUSER', () => {
typeof await client.aclDelUser('user'),
'number'
);
}, GLOBAL.SERVERS.OPEN);
}, {
...GLOBAL.SERVERS.OPEN,
redisEnterpriseNotSupported: true,
});
});
5 changes: 4 additions & 1 deletion packages/client/lib/commands/ACL_GENPASS.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,8 @@ describe('ACL GENPASS', () => {
typeof await client.aclGenPass(),
'string'
);
}, GLOBAL.SERVERS.OPEN);
}, {
...GLOBAL.SERVERS.OPEN,
redisEnterpriseNotSupported: true,
});
});
5 changes: 4 additions & 1 deletion packages/client/lib/commands/ACL_LOG.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,8 @@ describe('ACL LOG', () => {
assert.equal(typeof log['timestamp-last-updated'], 'number');
}
}
}, GLOBAL.SERVERS.OPEN);
}, {
...GLOBAL.SERVERS.OPEN,
redisEnterpriseNotSupported: true,
});
});
5 changes: 4 additions & 1 deletion packages/client/lib/commands/ACL_LOG_RESET.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,8 @@ describe('ACL LOG RESET', () => {
await client.aclLogReset(),
'OK'
);
}, GLOBAL.SERVERS.OPEN);
}, {
...GLOBAL.SERVERS.OPEN,
redisEnterpriseNotSupported: true,
});
});
5 changes: 4 additions & 1 deletion packages/client/lib/commands/BGREWRITEAOF.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,8 @@ describe('BGREWRITEAOF', () => {
typeof await client.bgRewriteAof(),
'string'
);
}, GLOBAL.SERVERS.OPEN);
}, {
...GLOBAL.SERVERS.OPEN,
redisEnterpriseNotSupported: true,
});
});
5 changes: 4 additions & 1 deletion packages/client/lib/commands/BGSAVE.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,8 @@ describe('BGSAVE', () => {
}),
'string'
);
}, GLOBAL.SERVERS.OPEN);
}, {
...GLOBAL.SERVERS.OPEN,
redisEnterpriseNotSupported: true,
});
});
25 changes: 16 additions & 9 deletions packages/client/lib/commands/CLIENT_INFO.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ describe('CLIENT INFO', () => {
});

testUtils.testWithClient('client.clientInfo', async client => {
//id=6463001000 addr=5.29.235.17:51462 laddr=10.0.1.6:19664 fd=171 name= age=3 idle=0 flags=N db=0 sub=0 psub=0
//ssub=0 multi=-1 watch=0 obl=0 events=r cmd=client|list user=default resp=2 lib-name= lib-ver=

const reply = await client.clientInfo();
assert.equal(typeof reply.id, 'number');
assert.equal(typeof reply.addr, 'string');
Expand All @@ -25,21 +28,25 @@ describe('CLIENT INFO', () => {
assert.equal(typeof reply.db, 'number');
assert.equal(typeof reply.sub, 'number');
assert.equal(typeof reply.psub, 'number');
assert.equal(typeof reply.multi, 'number');
assert.equal(typeof reply.qbuf, 'number');
assert.equal(typeof reply.qbufFree, 'number');
assert.equal(typeof reply.argvMem, 'number');
assert.equal(typeof reply.multi, 'number');
assert.equal(typeof reply.obl, 'number');
assert.equal(typeof reply.oll, 'number');
assert.equal(typeof reply.omem, 'number');
assert.equal(typeof reply.totMem, 'number');
assert.equal(typeof reply.events, 'string');
assert.equal(typeof reply.cmd, 'string');
assert.equal(typeof reply.user, 'string');
assert.equal(typeof reply.redir, 'number');
if (process.env.REDIS_ENTERPRISE === undefined) {
assert.equal(typeof reply.qbuf, 'number');
assert.equal(typeof reply.qbufFree, 'number');
assert.equal(typeof reply.argvMem, 'number');
assert.equal(typeof reply.oll, 'number');
assert.equal(typeof reply.omem, 'number');
assert.equal(typeof reply.totMem, 'number');
assert.equal(typeof reply.redir, 'number');
}

if (testUtils.isVersionGreaterThan([7, 0])) {
assert.equal(typeof reply.multiMem, 'number');
if (process.env.REDIS_ENTERPRISE === undefined) {
assert.equal(typeof reply.multiMem, 'number');
}
assert.equal(typeof reply.resp, 'number');

if (testUtils.isVersionGreaterThan([7, 0, 3])) {
Expand Down
26 changes: 17 additions & 9 deletions packages/client/lib/commands/CLIENT_LIST.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,25 +45,33 @@ describe('CLIENT LIST', () => {
assert.equal(typeof item.sub, 'number');
assert.equal(typeof item.psub, 'number');
assert.equal(typeof item.multi, 'number');
assert.equal(typeof item.qbuf, 'number');
assert.equal(typeof item.qbufFree, 'number');
assert.equal(typeof item.obl, 'number');
assert.equal(typeof item.oll, 'number');
assert.equal(typeof item.omem, 'number');
assert.equal(typeof item.events, 'string');
assert.equal(typeof item.cmd, 'string');

if (process.env.REDIS_ENTERPRISE === undefined) {
assert.equal(typeof item.qbuf, 'number');
assert.equal(typeof item.qbufFree, 'number');
assert.equal(typeof item.oll, 'number');
assert.equal(typeof item.omem, 'number');
}

if (testUtils.isVersionGreaterThan([6, 0])) {
assert.equal(typeof item.argvMem, 'number');
assert.equal(typeof item.totMem, 'number');
if (process.env.REDIS_ENTERPRISE === undefined) {
assert.equal(typeof item.argvMem, 'number');
assert.equal(typeof item.totMem, 'number');
}
assert.equal(typeof item.user, 'string');

if (testUtils.isVersionGreaterThan([6, 2])) {
assert.equal(typeof item.redir, 'number');
if (process.env.REDIS_ENTERPRISE === undefined) {
assert.equal(typeof item.redir, 'number');
}
assert.equal(typeof item.laddr, 'string');

if (testUtils.isVersionGreaterThan([7, 0])) {
assert.equal(typeof item.multiMem, 'number');
if (process.env.REDIS_ENTERPRISE === undefined) {
assert.equal(typeof item.multiMem, 'number');
}
assert.equal(typeof item.resp, 'number');

if (testUtils.isVersionGreaterThan([7, 0, 3])) {
Expand Down
5 changes: 4 additions & 1 deletion packages/client/lib/commands/CLIENT_NO-EVICT.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,8 @@ describe('CLIENT NO-EVICT', () => {
await client.clientNoEvict(true),
'OK'
);
}, GLOBAL.SERVERS.OPEN);
}, {
...GLOBAL.SERVERS.OPEN,
redisEnterpriseNotSupported: true,
});
});
5 changes: 4 additions & 1 deletion packages/client/lib/commands/CLIENT_PAUSE.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,8 @@ describe('CLIENT PAUSE', () => {
await client.clientPause(0),
'OK'
);
}, GLOBAL.SERVERS.OPEN);
}, {
...GLOBAL.SERVERS.OPEN,
redisEnterpriseNotSupported: true,
});
});
7 changes: 6 additions & 1 deletion packages/client/lib/commands/CLIENT_TRACKING.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,5 +97,10 @@ describe('CLIENT TRACKING', () => {
await client.clientTracking(false),
'OK'
);
}, GLOBAL.SERVERS.OPEN);
}, {
...GLOBAL.SERVERS.OPEN,
clientOptions: {
RESP: 3
}
});
});
5 changes: 4 additions & 1 deletion packages/client/lib/commands/CLIENT_UNPAUSE.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,8 @@ describe('CLIENT UNPAUSE', () => {
await client.clientUnpause(),
'OK'
);
}, GLOBAL.SERVERS.OPEN);
}, {
...GLOBAL.SERVERS.OPEN,
redisEnterpriseNotSupported: true,
});
});
2 changes: 1 addition & 1 deletion packages/client/lib/commands/CONFIG_SET.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ describe('CONFIG SET', () => {

testUtils.testWithClient('client.configSet', async client => {
assert.equal(
await client.configSet('maxmemory', '0'),
await client.configSet('lua-time-limit', '5000'),
'OK'
);
}, GLOBAL.SERVERS.OPEN);
Expand Down
8 changes: 6 additions & 2 deletions packages/client/lib/commands/HELLO.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,15 @@ describe('HELLO', () => {
assert.equal(typeof reply.version, 'string');
assert.equal(reply.proto, 2);
assert.equal(typeof reply.id, 'number');
assert.equal(reply.mode, 'standalone');
if (process.env.REDIS_ENTERPRISE === undefined) {
assert.equal(reply.mode, 'standalone');
} else {
assert.equal(reply.mode, 'cluster');
}
assert.equal(reply.role, 'master');
assert.deepEqual(reply.modules, []);
}, {
...GLOBAL.SERVERS.OPEN,
minimumDockerVersion: [6, 2]
minimumDockerVersion: [6, 2],
});
});
5 changes: 4 additions & 1 deletion packages/client/lib/commands/LASTSAVE.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,8 @@ describe('LASTSAVE', () => {
typeof await client.lastSave(),
'number'
);
}, GLOBAL.SERVERS.OPEN);
}, {
...GLOBAL.SERVERS.OPEN,
redisEnterpriseNotSupported: true,
});
});
5 changes: 4 additions & 1 deletion packages/client/lib/commands/LATENCY_DOCTOR.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,8 @@ describe('LATENCY DOCTOR', () => {
typeof await client.latencyDoctor(),
'string'
);
}, GLOBAL.SERVERS.OPEN);
}, {
...GLOBAL.SERVERS.OPEN,
redisEnterpriseNotSupported: true,
});
});
5 changes: 4 additions & 1 deletion packages/client/lib/commands/LATENCY_GRAPH.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,8 @@ describe('LATENCY GRAPH', () => {
]);

assert.equal(typeof reply, 'string');
}, GLOBAL.SERVERS.OPEN);
}, {
...GLOBAL.SERVERS.OPEN,
redisEnterpriseNotSupported: true,
});
});
5 changes: 4 additions & 1 deletion packages/client/lib/commands/LATENCY_HISTORY.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,8 @@ describe('LATENCY HISTORY', () => {
assert.equal(typeof timestamp, 'number');
assert.equal(typeof latency, 'number');
}
}, GLOBAL.SERVERS.OPEN);
}, {
...GLOBAL.SERVERS.OPEN,
redisEnterpriseNotSupported: true,
});
});
5 changes: 4 additions & 1 deletion packages/client/lib/commands/LATENCY_LATEST.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,8 @@ describe('LATENCY LATEST', () => {
assert.equal(typeof latestLatency, 'number');
assert.equal(typeof allTimeLatency, 'number');
}
}, GLOBAL.SERVERS.OPEN);
}, {
...GLOBAL.SERVERS.OPEN,
redisEnterpriseNotSupported: true,
});
});
5 changes: 4 additions & 1 deletion packages/client/lib/commands/MEMORY_DOCTOR.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,8 @@ describe('MEMORY DOCTOR', () => {
typeof (await client.memoryDoctor()),
'string'
);
}, GLOBAL.SERVERS.OPEN);
}, {
...GLOBAL.SERVERS.OPEN,
redisEnterpriseNotSupported: true,
});
});
5 changes: 4 additions & 1 deletion packages/client/lib/commands/MEMORY_MALLOC-STATS.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,8 @@ describe('MEMORY MALLOC-STATS', () => {
typeof (await client.memoryMallocStats()),
'string'
);
}, GLOBAL.SERVERS.OPEN);
}, {
...GLOBAL.SERVERS.OPEN,
redisEnterpriseNotSupported: true,
});
});
5 changes: 4 additions & 1 deletion packages/client/lib/commands/MEMORY_PURGE.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,8 @@ describe('MEMORY PURGE', () => {
await client.memoryPurge(),
'OK'
);
}, GLOBAL.SERVERS.OPEN);
}, {
...GLOBAL.SERVERS.OPEN,
redisEnterpriseNotSupported: true,
});
});
5 changes: 4 additions & 1 deletion packages/client/lib/commands/MEMORY_STATS.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,8 @@ describe('MEMORY STATS', () => {
assert.equal(typeof memoryStats['cluster.links'], 'number');
assert.equal(typeof memoryStats['functions.caches'], 'number');
}
}, GLOBAL.SERVERS.OPEN);
}, {
...GLOBAL.SERVERS.OPEN,
redisEnterpriseNotSupported: true,
});
});
5 changes: 4 additions & 1 deletion packages/client/lib/commands/MOVE.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,8 @@ describe('MOVE', () => {
await client.move('key', 1),
0
);
}, GLOBAL.SERVERS.OPEN);
}, {
...GLOBAL.SERVERS.OPEN,
redisEnterpriseNotSupported: true,
});
});
Loading