Browse Source

Try de-flaking testMultipleConnectivityObserversAreCalled. (#441)

Daniel Alm 6 years ago
parent
commit
c0eca15914

+ 1 - 1
Tests/SwiftGRPCTests/ChannelConnectivityTests.swift

@@ -57,7 +57,7 @@ extension ChannelConnectivityTests {
     client.channel.addConnectivityObserver { _ in secondObserverCalled = true }
 
     let completionHandlerExpectation = expectation(description: "completion handler called")
-    _ = try! client.expand(Echo_EchoRequest(text: "foo bar baz foo bar baz")) { _ in
+    _ = try! client.get(Echo_EchoRequest(text: "foo")) { _, _ in
       completionHandlerExpectation.fulfill()
     }
 

+ 8 - 8
Tests/SwiftGRPCTests/ServerTimeoutTests.swift

@@ -20,22 +20,22 @@ import XCTest
 
 fileprivate class TimingOutEchoProvider: Echo_EchoProvider {
   func get(request: Echo_EchoRequest, session _: Echo_EchoGetSession) throws -> Echo_EchoResponse {
-    Thread.sleep(forTimeInterval: 0.2)
+    Thread.sleep(forTimeInterval: 0.1)
     return Echo_EchoResponse()
   }
   
   func expand(request: Echo_EchoRequest, session: Echo_EchoExpandSession) throws -> ServerStatus? {
-    Thread.sleep(forTimeInterval: 0.2)
+    Thread.sleep(forTimeInterval: 0.1)
     return .ok
   }
   
   func collect(session: Echo_EchoCollectSession) throws -> Echo_EchoResponse? {
-    Thread.sleep(forTimeInterval: 0.2)
+    Thread.sleep(forTimeInterval: 0.1)
     return Echo_EchoResponse()
   }
   
   func update(session: Echo_EchoUpdateSession) throws -> ServerStatus? {
-    Thread.sleep(forTimeInterval: 0.2)
+    Thread.sleep(forTimeInterval: 0.1)
     return .ok
   }
 }
@@ -52,7 +52,7 @@ class ServerTimeoutTests: BasicEchoTestCase {
   
   override func makeProvider() -> Echo_EchoProvider { return TimingOutEchoProvider() }
   
-  override var defaultTimeout: TimeInterval { return 0.1 }
+  override var defaultTimeout: TimeInterval { return 0.01 }
 }
 
 extension ServerTimeoutTests {
@@ -90,7 +90,7 @@ extension ServerTimeoutTests {
       XCTAssertEqual(.unknown, (receiveError as! RPCError).callResult!.statusCode)
     }
     
-    waitForExpectations(timeout: defaultTimeout)
+    waitForExpectations(timeout: 0.2)
   }
   
   func testTimeoutServerStreaming() {
@@ -104,7 +104,7 @@ extension ServerTimeoutTests {
     // rather than returning an error?
     XCTAssertNil(try! call.receive())
     
-    waitForExpectations(timeout: defaultTimeout)
+    waitForExpectations(timeout: 0.2)
   }
   
   func testTimeoutBidirectionalStreaming() {
@@ -126,6 +126,6 @@ extension ServerTimeoutTests {
     // rather than returning an error?
     XCTAssertNil(try! call.receive())
     
-    waitForExpectations(timeout: defaultTimeout)
+    waitForExpectations(timeout: 0.2)
   }
 }