Skip to content
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

Refactor incremental backoff and jitter with tests #1864

Open
sacOO7 opened this issue Jan 30, 2024 · 2 comments
Open

Refactor incremental backoff and jitter with tests #1864

sacOO7 opened this issue Jan 30, 2024 · 2 comments
Labels
code-quality Affects the developer experience when working in our codebase. testing Includes all kinds of automated tests, the way that we run them and the infrastructure around them.

Comments

@sacOO7
Copy link
Contributor

sacOO7 commented Jan 30, 2024

Simplify unit tests for backoff and jitter since we already have a formula to generate lower and upper bounds.

Expression to calculate upper and lower bounds for generated values using getRetryTime

upper = min((retryCount + 2) / 3, 2) *initialTimeout
lower = 0.8 * upper
if x is a generated retryTimeout from getRetryTime, then

lower < x < upper

Backoff and jitter formula can be put in one file ARTBackoffRetryDelayCalculator.m same as
https://github.com/ably/ably-java/blob/main/lib/src/main/java/io/ably/lib/util/ReconnectionStrategy.java
So, other files BackoffCoefficients.swift, StaticJitterCoefficients.swift, ARTJitterCoefficientGenerator.m and ARTJitterCoefficientGenerator.h should be removed

Unit tests can be put in one file same as
https://github.com/ably/ably-java/blob/main/lib/src/test/java/io/ably/lib/util/ReconnectionStrategyTest.java

So, other files DefaultJitterCoefficientGeneratorTests.swift and MockJitterCoefficientGenerator.swift can be removed

┆Issue is synchronized with this Jira Task by Unito

@sacOO7 sacOO7 changed the title Refactor incremental backoff and jitter tests Refactor incremental backoff and jitter with tests Jan 30, 2024
Copy link

sync-by-unito bot commented Jan 30, 2024

➤ Automation for Jira commented:

The link to the corresponding Jira issue is https://ably.atlassian.net/browse/SDK-4062

@lawrence-forooghian lawrence-forooghian added the code-quality Affects the developer experience when working in our codebase. label Apr 22, 2024
@lawrence-forooghian
Copy link
Collaborator

I think that writing tests is a pretty subjective thing and there frequently isn’t really a "right" way to do it — I was satisfied with the way I did these tests, but if someone wants to change them feel free 🙂

@lawrence-forooghian lawrence-forooghian added the testing Includes all kinds of automated tests, the way that we run them and the infrastructure around them. label Apr 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code-quality Affects the developer experience when working in our codebase. testing Includes all kinds of automated tests, the way that we run them and the infrastructure around them.
Development

No branches or pull requests

2 participants