Skip to content

Commit

Permalink
Remove getOrConnectToMember assertion because it is also called by tr…
Browse files Browse the repository at this point in the history
…iggerClusterReconnection
  • Loading branch information
srknzl committed Jun 13, 2023
1 parent a896ca8 commit a97545b
Showing 1 changed file with 1 addition and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,14 @@
const RC = require('../../RC');
const TestUtil = require('../../../TestUtil');
const { expect } = require('chai');
const sinon = require('sinon');
const sandbox = sinon.createSandbox();

/**
* Basic tests for reconnection to cluster scenarios.
*/
describe('ClientClusterReconnectionRetryTest', function () {
let cluster;
let client;
let ClientState, ConnectionManager;
let ClientState;
const ASSERTION_MILLISECONDS = 30000;
const INT32_MAX_VALUE = Math.pow(2, 31) - 1;

Expand All @@ -36,19 +34,13 @@ describe('ClientClusterReconnectionRetryTest', function () {
before(function() {
TestUtil.markClientVersionAtLeast(this, '5.3.0');
ClientState = require('../../../../lib/network/ConnectionManager').ClientState;
ConnectionManager = require('../../../../lib/network/ConnectionManager').ConnectionManager;
});

afterEach(async function () {
await testFactory.shutdownAll();
});

it('testClientShouldNotTryToConnectCluster_whenThereIsNoConnection', async function () {
const fnGetOrConnectToMember = sandbox.replace(
ConnectionManager.prototype,
'getOrConnectToMember',
sandbox.fake(ConnectionManager.prototype.getOrConnectToMember)
);
cluster = await testFactory.createClusterForSerialTests();
const member = await RC.startMember(cluster.id);
// Sleep indefinitely after the first connection attempt fails
Expand All @@ -67,14 +59,10 @@ describe('ClientClusterReconnectionRetryTest', function () {
// After terminateMember client state will be DISCONNECTED_FROM_CLUSTER
expect(client.getConnectionManager().getConnectionRegistry().getClientState()
== ClientState.DISCONNECTED_FROM_CLUSTER).to.be.eq(true);
const callCountFnGetOrConnectToMember = fnGetOrConnectToMember.callCount;
// Wait a bit more to make it more likely that the first reconnection
// attempt is made before we restart the instance
await TestUtil.promiseLater(ASSERTION_MILLISECONDS, () => { });

// getOrConnectToMember function call count will be stable
// after disconnection, client will not try to reconnect
fnGetOrConnectToMember.callCount.should.be.eq(callCountFnGetOrConnectToMember);
await RC.startMember(cluster.id);
const clientConnectionsFn = await TestUtil.getClientConnectionsFn(client);
await TestUtil.assertTrueAllTheTime(async () => {
Expand Down

0 comments on commit a97545b

Please sign in to comment.