From aabbf032aa5fd33ddfc5679ffb844295035a3014 Mon Sep 17 00:00:00 2001 From: Vladislav Alekseev Date: Mon, 11 May 2020 20:56:00 +0300 Subject: [PATCH] Wait for remote cache store request --- Package.swift | 1 + .../DefaultRuntimeDumpRemoteCache.swift | 8 ++++++++ .../TestDiscoveryTests/RuntimeDumpRemoteCacheTests.swift | 1 + 3 files changed, 10 insertions(+) diff --git a/Package.swift b/Package.swift index 22620838..efbdfdf0 100644 --- a/Package.swift +++ b/Package.swift @@ -1577,6 +1577,7 @@ let package = Package( name: "TestDiscovery", dependencies: [ "AppleTools", + "AtomicModels", "BuildArtifacts", "DeveloperDirLocator", "Extensions", diff --git a/Sources/TestDiscovery/RuntimeDumpRemoteCache/DefaultRuntimeDumpRemoteCache.swift b/Sources/TestDiscovery/RuntimeDumpRemoteCache/DefaultRuntimeDumpRemoteCache.swift index 7237ae9b..5c34a769 100644 --- a/Sources/TestDiscovery/RuntimeDumpRemoteCache/DefaultRuntimeDumpRemoteCache.swift +++ b/Sources/TestDiscovery/RuntimeDumpRemoteCache/DefaultRuntimeDumpRemoteCache.swift @@ -1,3 +1,4 @@ +import AtomicModels import BuildArtifacts import Foundation import Logging @@ -58,12 +59,19 @@ class DefaultRuntimeDumpRemoteCache: RuntimeDumpRemoteCache { payload: tests ) + let didFinishRequest = AtomicValue(false) + sender.sendRequestWithCallback( request: request, credentials: config.credentials, callbackQueue: callbackQueue ) { (result: Either) in Logger.verboseDebug("Stored runtime query with result: \(result)") + didFinishRequest.set(true) + } + + try waiter.waitWhile(timeout: 20.0, description: "Runtime Dump Remote Cache Store") { () -> Bool in + didFinishRequest.currentValue() == false } } diff --git a/Tests/TestDiscoveryTests/RuntimeDumpRemoteCacheTests.swift b/Tests/TestDiscoveryTests/RuntimeDumpRemoteCacheTests.swift index 1b0db76a..22d1fcea 100644 --- a/Tests/TestDiscoveryTests/RuntimeDumpRemoteCacheTests.swift +++ b/Tests/TestDiscoveryTests/RuntimeDumpRemoteCacheTests.swift @@ -23,6 +23,7 @@ class RuntimeDumpRemoteCacheTests: XCTestCase { let expectedPath = "/pathToRemoteStorage/a74c1c98661e4c27fc3e569f40c74feaf4775d1b77c4a82928364728ab6c23b0.json" let queryResult = TestDiscoveryResultFixtures.queryResult() + requestSender.result = VoidPayload() try cache.store( tests: queryResult.discoveredTests, xcTestBundleLocation: xcTestBundleLocation