Skip to content

Commit

Permalink
Add tests for TO3l6
Browse files Browse the repository at this point in the history
  • Loading branch information
VeskeR committed Apr 17, 2024
1 parent de3a63f commit d722520
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
7 changes: 6 additions & 1 deletion test/realtime/init.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ define(['ably', 'shared_helper', 'chai'], function (Ably, helper, chai) {
disconnectedRetryTimeout: 123,
suspendedRetryTimeout: 456,
httpRequestTimeout: 789,
httpMaxRetryDuration: 321,
});
/* Note: uses internal knowledge of connectionManager */
try {
Expand All @@ -251,7 +252,11 @@ define(['ably', 'shared_helper', 'chai'], function (Ably, helper, chai) {
);
expect(realtime.connection.connectionManager.options.timeouts.httpRequestTimeout).to.equal(
789,
'Verify suspended retry frequency is settable',
'Verify http request timeout is settable',
);
expect(realtime.connection.connectionManager.options.timeouts.httpMaxRetryDuration).to.equal(
321,
'Verify http max retry duration is settable',
);
} catch (err) {
closeAndFinish(done, realtime, err);
Expand Down
25 changes: 25 additions & 0 deletions test/rest/fallbacks.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,30 @@ define(['shared_helper', 'async', 'chai'], function (helper, async, chai) {
expect(currentFallback && currentFallback.host).to.equal(goodHost, 'Check good host set again');
expect(currentFallback.validUntil > now, 'Check validUntil has been re-set').to.be.ok;
});

// TO3l6
it('Max elapsed time for fallback host retries', async function () {
// set httpMaxRetryDuration lower than httpRequestTimeout so it would fail after first host retry
const httpMaxRetryDuration = 1000;
const rest = helper.AblyRest({
restHost: helper.unroutableHost,
fallbackHosts: [helper.unroutableHost],
httpRequestTimeout: 2000,
httpMaxRetryDuration,
});

let thrownError = null;
try {
// we expect it to fail due to max elapsed time reached for fallback host retries
await rest.time();
} catch (error) {
thrownError = error;
}

expect(thrownError).not.to.be.null;
expect(thrownError.message).to.equal(
`Timeout for trying fallback hosts retries. Total elapsed time exceeded the ${httpMaxRetryDuration}ms limit`,
);
});
});
});

0 comments on commit d722520

Please sign in to comment.