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

RSC15a #384

Merged
merged 4 commits into from
Apr 18, 2016
Merged

RSC15a #384

merged 4 commits into from
Apr 18, 2016

Conversation

ricardopereira
Copy link
Contributor

No description provided.

@ricardopereira ricardopereira force-pushed the rsc15a branch 3 times, most recently from 5ac5963 to 06f3a3b Compare April 14, 2016 08:44
let resultFallbackHosts = testHTTPExecutor.requests.flatMap(extractHostname)
let orderedFallbackHosts = "abcde".characters.map({String($0) + ".ably-rest.com"})

expect(resultFallbackHosts).toNot(equal(orderedFallbackHosts))
Copy link
Member

Choose a reason for hiding this comment

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

This test will fail once every 120 times (I think) so I am not sure is a great test. I am not sure how to test it perfectly though, perhaps retry once making it a 1 in 14,400 chance?

Copy link
Contributor

Choose a reason for hiding this comment

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

Relevant xckd:

random_number

Meaning, it's impossible to test that random numbers are being generated. What about using a mockable random() -> Int function?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

😅 Thanks for the fix.

@tcard
Copy link
Contributor

tcard commented Apr 15, 2016

PTAL

@mattheworiordan
Copy link
Member

He he, nice one @tcard re: xckd! 👍

@ricardopereira
Copy link
Contributor Author

LGTM, thank you.

@ricardopereira
Copy link
Contributor Author

I wanted to merge this but the test suite is failing.
It's failing with tests that never failed before:

...
[18:19:17]: ▸ testAttachBeforeConnect, Asynchronous wait failed: Exceeded timeout of 10 seconds, with unfulfilled expectations: "attach_before_connect".
[18:19:17]: ▸ <unknown>:0
[18:19:17]: ▸ ```
[18:19:17]: ▸ ```
[18:19:17]: ▸ testAttachFails, Asynchronous wait failed: Exceeded timeout of 10 seconds, with unfulfilled expectations: "testAttachFails".
[18:19:17]: ▸ <unknown>:0
...

The odd thing is, I tried on my machine and many tests are failing as well with Exceeded timeout of 10 seconds.

@mattheworiordan
Copy link
Member

@ricardopereira please provide a detailed log of the protocol messages with timestamps so that we can see if this is a realtime sandbox issue or a test suite issue

@tcard
Copy link
Contributor

tcard commented Apr 18, 2016

testAttachBeforeConnect, testAttachFails don't sound like they can be affected like this, as this is REST and attach/connect is Realtime. This is most likely a sandbox issue.

@ricardopereira
Copy link
Contributor Author

I ran the complete test suite with verbose log and I noticed a bunch of can't detach when in a failed state (ARTRealtimeChannel.m#L570). I think it's a recent change. Stack trace:

#0  0x000000010af86494 in -[ARTRealtimeChannel detach:] at Source/ARTRealtimeChannel.m:570
#1  0x000000010af7d87c in -[ARTRealtimeChannels release:callback:] at Source/ARTRealtimeChannels.m:58
#2  0x000000010af7db90 in -[ARTRealtimeChannels release:] at Source/ARTRealtimeChannels.m:69
#3  0x000000010ab1be06 in +[ARTTestUtil removeAllChannels:] at Tests/ARTTestUtil.m:265

But I think that's not what's causing failures.

@ricardopereira
Copy link
Contributor Author

So, I found the problem. The https://sandbox-rest.ably.io:443/apps request sometimes takes more than 10 seconds and the timeout is exceeded:

Test Case '-[ARTRealtimeAttachTest testAttachFailsOnFailedConnection]' started.
2016-04-18 15:47:54.202 xctest[14706:1873194] Get app key from sandbox: 2016-04-18 14:47:54 +0000
Tests/ARTRealtimeAttachTest.m:293: error: -[ARTRealtimeAttachTest testAttachFailsOnFailedConnection] : Asynchronous wait failed: Exceeded timeout of 10 seconds, with unfulfilled expectations: "testAttachFailsOnFailedConnection".
Test Case '-[ARTRealtimeAttachTest testAttachFailsOnFailedConnection]' failed (10.028 seconds).

Most of the tests are written like this, e.g.:

__weak XCTestExpectation *expectation = [self expectationWithDescription:@"detaching_to_attaching"];
[ARTTestUtil testRealtime:^(ARTRealtime *realtime) {  //<-- https://sandbox-rest.ably.io:443/apps call
   ...
}
[self waitForExpectationsWithTimeout:[ARTTestUtil timeout] handler:nil];

where the XCTestExpectation is created before the https://sandbox-rest.ably.io:443/apps request and the timeout is easily exceeded. I will do some changes and run a full test.

@tcard
Copy link
Contributor

tcard commented Apr 18, 2016

Cool, good catch @ricardopereira. I'm merging this though, as this PR has nothing to do with that and all the RestClient tests are passing, so please issue a separate PR if you don't mind.

@ricardopereira
Copy link
Contributor Author

@tcard Yes, I will. Just making some final tests.

@tcard tcard merged commit 57ae456 into master Apr 18, 2016
@mattheworiordan mattheworiordan deleted the rsc15a branch April 19, 2016 07:20
tcard pushed a commit that referenced this pull request May 16, 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.

3 participants