-
-
Notifications
You must be signed in to change notification settings - Fork 45
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
πΈοΈ Implement cluster commands #110
Conversation
The cluster tests need to be run against a cluster enabled redis-server, which will interfere with other tests since in cluster mode some functionalities are disabled. So for now I don't include them in |
First of all, thanks for submitting this PR @tumile!
Personally, I don't think it needs to be included in the API.
That is exactly what I want to do. (#104) |
I see. Has there been any plan for #104? This PR can wait till then don't you think? |
I'm thinking about adding a |
I currently use a timeout at the end of file to clean up the redis cluster after tests in Is there a way to ensure all tests have run before cleanup? I tried putting cleanup in another |
https://deno.land/manual/testing You may have looked at this already, and it's my first time reading it, but I don't see any simple/prepackaged way to accomplish what you're asking. Will probably require a creative hack or some third party test util(if such a thing exists)? |
There is an option to run each test file in serial, so test timeouts will not interfere with others. I don't think this is a bad idea, with #114 it's probably good to put all commands tests in a single file and start a redis instance. Tests like cluster and pubsub, which require customized instances, will be run independently. Still, this doesn't solve using timeout for cleanup, but a test will not suddenly fail if other ones take longer than expected.
I don't think there is a test framework like mocha or ava for Deno yet. Never realized how much we needed them π. |
How about the following? π€ async function makeClusterTest(): Promise<{
test: (name: string, fn: () => Promise<void>) => void,
client: Redis,
runTests: () => Promise<void>
}> {
const cleanupCluster = await startRedisCluster();
const client = await connect({ hostname: "127.0.0.1", port: 7000 });
const tests = [] as Array<{ name: string, fn: () => Promise<void> }>;
function test(name: string, fn: () => Promise<void>): void {
tests.push({ name, fn });
}
function runTests(): Promise<void> {
const promises = [] as Promise<void>[];
function defineTest(name: string, fn: () => Promise<void>): void {
Deno.test(name, () => {
const promise = fn();
promises.push(promise);
return promise;
});
}
for (const test of tests) {
defineTest(test.name, test.fn);
}
return Promise.allSettled(promises).finally(() => {
cleanupCluster();
client.close();
});
}
return { test, client, runTests };
} const { test, client, runTests } = await makeClusterTest();
test("[cluster] flushslots", async () => {
...
});
...
runTests(); |
Looks promising, I'll test it in a bit. How about wrapping the makeTest/makeClusterTest in a class? Probably cleaner. |
@uki00a can you review my test suite implementation? I think if it's good, we can roll this out to other tests as well! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @tumile!
I've left a few comments on this PR.
Please check them out!
I've addressed the comments π. Please review again |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks @tumile!
Released in v0.11.0! |
π§ WIP: Cluster API
This changeset will resolve #37 π
Commands to implement and test
cluster_bumpepochcluster_setconfigepochAdditional requirements