Copilot commented on code in PR #440:
URL: 
https://github.com/apache/cassandra-nodejs-driver/pull/440#discussion_r3320868082


##########
test/integration/short/control-connection-tests.js:
##########
@@ -236,6 +237,54 @@ describe('ControlConnection', function () {
 
       assert.strictEqual(helper.lastOctetOf(cc.host), '2');
     });
+
+    it('should stop reconnecting after control connection shutdown is called', 
async () => {
+      const options = clientOptions.extend(utils.extend({ pooling: { 
coreConnectionsPerHost: {}}}, helper.baseOptions));
+      const reconnectionDelay = 200;
+      options.policies.reconnection = new 
policies.reconnection.ConstantReconnectionPolicy(reconnectionDelay);
+      const cc = newInstance(options, 1, 1);
+      disposeAfter(cc);
+
+      await cc.init();
+
+      assert.ok(cc.host);
+      assert.strictEqual(helper.lastOctetOf(cc.host), '1');
+      const lbp = cc.options.policies.loadBalancing;
+
+      await new Promise(r => lbp.init({ log: utils.noop, options: { 
localDataCenter: 'dc1' }}, cc.hosts, r));
+
+      // the control connection host should be local or remote to trigger DOWN 
events
+      for (const h of cc.hosts.values()) {
+        h.setDistance(lbp.getDistance(h));
+        await h.warmupPool();
+      }
+
+      // stop nodes 1 and 2 and make sure they both go down.
+      await util.promisify(helper.ccmHelper.stopNode)(1);
+      await helper.wait.forNodeDown(cc.hosts, 1);
+      await util.promisify(helper.ccmHelper.stopNode)(2);
+      await helper.wait.forNodeDown(cc.hosts, 2);
+
+      // check that both hosts are down.
+      cc.hosts.forEach(h => {
+        if (helper.lastOctetOf(h) === '1') {
+          assert.strictEqual(h.isUp(), false);
+        }
+        else {
+          assert.strictEqual(h.isUp(), false);
+        }

Review Comment:
   This branch has identical assertions in both arms, so the `if` does not add 
any validation and makes the test harder to read. Consider replacing it with a 
single assertion for each host, or assert the expected state per node only 
where the expected values differ.



-- 
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]

Reply via email to