SiyaoIsHiding commented on code in PR #462:
URL:
https://github.com/apache/cassandra-nodejs-driver/pull/462#discussion_r3271498379
##########
test/integration/short/control-connection-tests.js:
##########
@@ -153,6 +153,25 @@ describe('ControlConnection', function () {
assert.strictEqual(cc.hosts.length, 1);
});
+ it('should not break when refreshing concurrently', async () => {
+ const cc = newInstance();
+ cc.options.policies.loadBalancing = new
policies.loadBalancing.RoundRobinPolicy();
+ disposeAfter(cc);
+
+ await cc.init();
+ await new Promise(r => cc.options.policies.loadBalancing.init(null,
cc.hosts, r));
+
+ const refreshPromises = [];
+ // randomly emit cc._refresh 100 times
+ for (let i = 0; i < 100; i++) {
+ refreshPromises.push(cc._refresh());
+ await helper.delayAsync(~~(Math.random() * 100));
+ }
+ await Promise.all(refreshPromises);
Review Comment:
And although my test can be unreliable, false test failures won't happen.
I agree that this test isn't ideal tho, open to ideas on how to improve it
##########
test/integration/short/control-connection-tests.js:
##########
@@ -153,6 +153,25 @@ describe('ControlConnection', function () {
assert.strictEqual(cc.hosts.length, 1);
});
+ it('should not break when refreshing concurrently', async () => {
+ const cc = newInstance();
+ cc.options.policies.loadBalancing = new
policies.loadBalancing.RoundRobinPolicy();
+ disposeAfter(cc);
+
+ await cc.init();
+ await new Promise(r => cc.options.policies.loadBalancing.init(null,
cc.hosts, r));
+
+ const refreshPromises = [];
+ // randomly emit cc._refresh 100 times
+ for (let i = 0; i < 100; i++) {
+ refreshPromises.push(cc._refresh());
+ await helper.delayAsync(~~(Math.random() * 100));
+ }
+ await Promise.all(refreshPromises);
Review Comment:
Copilot's suggestion won't work. If the `_refresh` call all starts around
the same time and ends around the same time, the null pointer exception won't
actually happen
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]