-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: 馃幐 stop all clients on cluster stop
- Loading branch information
Showing
4 changed files
with
57 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import {RedisCluster} from '../../../cluster/RedisCluster'; | ||
import {ClusterTestSetup} from '../../types'; | ||
import {run} from './SET'; | ||
|
||
const host = 'redis-15083.c28691.us-east-1-4.ec2.cloud.rlrcp.com'; | ||
const port = 15083; | ||
const user = 'default'; | ||
const pwd = '7UAmqOMRcZ0KFZUfzze2KaWW8w0Fe8pP'; | ||
const client = new RedisCluster({ | ||
seeds: [{host, port}], | ||
connectionConfig: { | ||
user, | ||
pwd, | ||
}, | ||
}); | ||
client.onError.listen((err) => { | ||
console.error('onError', err); | ||
}); | ||
client.start(); | ||
|
||
const setupCluster: ClusterTestSetup = async () => { | ||
await client.whenRouterReady(); | ||
return {client}; | ||
}; | ||
|
||
run(setupCluster); | ||
|
||
afterAll(() => { | ||
client.stop(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import {ClusterTestSetup} from '../../types'; | ||
|
||
export const run = (setup: ClusterTestSetup) => { | ||
describe('SET', () => { | ||
test('can set a key', async () => { | ||
const {client} = await setup(); | ||
const res = await client.cmd(['SET', 'foo', 'bar']); | ||
expect(res).toBe('OK'); | ||
}); | ||
|
||
test('can set a key with partition brackets', async () => { | ||
const {client} = await setup(); | ||
const res = await client.cmd(['SET', '{foo}', 'bar']); | ||
expect(res).toBe('OK'); | ||
}); | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import {RedisCluster} from '../cluster/RedisCluster'; | ||
|
||
export type TestSetup = ClusterTestSetup; | ||
export type ClusterTestSetup = () => Promise<{ | ||
client: ClusterTestClient; | ||
}>; | ||
|
||
export type TextClient = ClusterTestClient; | ||
export type ClusterTestClient = Pick<RedisCluster, 'cmd'>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters