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

Update RSC15a to new requirements #466

Closed
wants to merge 3 commits into from

Conversation

CezaryKopacz
Copy link

No description provided.

@mattheworiordan
Copy link
Member

Thanks @CezaryKopacz this is very good. Note that we try not to ever add more tests to our old Obj-C test suite and always use the Swift ones, unless just a small change is required and therefore it's quicker than rewriting in Swift. But you didn't know that, so thanks.

}
}
//check artfallback randomises the order.
XCTAssertFalse(inOrder);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW. This test will unfortunately fail every 6 (3x2) times as randomising a set of fallback hosts will be in the original order once every 6 times statistically. So this test is probably not ideal. We could make it statistically unlikely to fail by having a decent number of random hosts (12 would result in failure once every 480 million test runs) or simply run the tests multiple times in a row and only fail if all test runs fail.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point! BTW I can see similar test which will probably fail too. Anyway, what needs to be done yet in order to merge PR?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well I wouldn't worry about the other tests. If you could fix this one that would be great.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please check my latest commit

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have already support for doing this clean by overriding the random function. See https://github.com/ably/ably-ios/blob/e049dab0e87eaa1643e21d70ae3a771529e0d9e7/Spec/RealtimeClientConnection.swift#L2362-L2372 which lets us expect a given order: https://github.com/ably/ably-ios/blob/e049dab0e87eaa1643e21d70ae3a771529e0d9e7/Spec/RealtimeClientConnection.swift#L2585 If we get the expected order, we prove that fallback logic is using the ARTFallback_getRandomHostIndex function correctly, and we can just trust that the default value for ARTFallback_getRandomHostIndex works as expected

@"test2.ably.com",
@"test3.ably.com",
@"test4.ably.com",
@"test5.ably.com"];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

5x4x3x2 = 1 in 120 test will fail.
Why not just go for 15 hosts, for example, giving you a 1 in 479001600 change the test will fail?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, why not. Done

@@ -154,7 +154,11 @@ - (void)executeRequest:(NSMutableURLRequest *)request completion:(void (^)(NSHTT
}
if (retries < _options.httpMaxRetryCount && [self shouldRetryWithFallback:request response:response error:error]) {
if (!blockFallbacks && [request.URL.host isEqualToString:(_prioritizedHost ? _prioritizedHost : [ARTDefault restHost])]) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RSC15b has changed as well, so this condition needs to incorporate this: "or an array of ClientOptions#fallbackHosts is provided"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @tcard, however @CezaryKopacz's scope was only to look at RSC15a for now, so that's a valid comment, but will be addressed in a separate PR.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh OK, sorry, just felt weird as if you're using custom fallback hosts you most probably are also using a custom primary host.

@tcard
Copy link
Contributor

tcard commented Sep 7, 2016

This PRs seems to have stalled. @mattheworiordan should I finish it up?

@mattheworiordan
Copy link
Member

@tcard checking with 10Clouds if they are happy for us to merge as it was a trial task so arguably not our right to use without their permission. I'll have an answer soon.

@ricardopereira
Copy link
Contributor

@mattheworiordan What's the state of this? /cc @tcard

BTW, this should be rebased with master. @EvgenyKarkan updated the RSA15b spec. There's already a fallbackHosts array https://github.com/ably/ably-ios/blob/13fcb23a0e1aa1dc4b0373a32b7c87e72d5f68b4/Source/ARTClientOptions.h#L76.

@ricardopereira ricardopereira mentioned this pull request Oct 11, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants