-
Notifications
You must be signed in to change notification settings - Fork 26
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,4 +43,48 @@ - (void)testAllHostsIncludedOnce { | |
} | ||
} | ||
|
||
- (void)testCustomFallbackHosts { | ||
NSArray *customHosts = @[@"test.ably.com", | ||
@"test2.ably.com", | ||
@"test3.ably.com", | ||
@"test4.ably.com", | ||
@"test5.ably.com", | ||
@"test6.ably.com", | ||
@"test7.ably.com", | ||
@"test8.ably.com", | ||
@"test9.ably.com", | ||
@"test10.ably.com", | ||
@"test11.ably.com", | ||
@"test12.ably.com", | ||
@"test13.ably.com", | ||
@"test14.ably.com"]; | ||
ARTFallback *f = [[ARTFallback alloc] initWithFallbackHosts:customHosts]; | ||
|
||
NSSet *customSet = [NSSet setWithArray:customHosts]; | ||
NSMutableArray *hostsRandomised = [NSMutableArray array]; | ||
for(int i=0;i < [customHosts count]; i++) { | ||
[hostsRandomised addObject:[f popFallbackHost]]; | ||
} | ||
|
||
//popping after all hosts are exhausted returns nil | ||
XCTAssertTrue([f popFallbackHost] == nil); | ||
|
||
// all fallback hosts are used in artfallback | ||
XCTAssertEqual([hostsRandomised count], [customHosts count]); | ||
bool inOrder = true; | ||
for(int i=0;i < [customHosts count]; i++) { | ||
if(![[customHosts objectAtIndex:i] isEqualToString:[hostsRandomised objectAtIndex:i]]) { | ||
inOrder = false; | ||
break; | ||
} | ||
} | ||
//check artfallback randomises the order. | ||
XCTAssertFalse(inOrder); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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? There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please check my latest commit There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
|
||
//every member of fallbacks hosts are in the list of custom hosts | ||
for(int i=0;i < [hostsRandomised count]; i++) { | ||
XCTAssertTrue([customSet containsObject:[hostsRandomised objectAtIndex:i]]); | ||
} | ||
} | ||
|
||
@end |
There was a problem hiding this comment.
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"There was a problem hiding this comment.
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.There was a problem hiding this comment.
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.