From d90699521a67f98fe63c4fc3f07d605970e94c9c Mon Sep 17 00:00:00 2001 From: amnon Date: Tue, 17 Sep 2024 11:21:07 +0100 Subject: [PATCH 1/7] testing - run tests against amnon's cluster DO NOT MERGE --- .github/workflows/integration-test.yaml | 2 +- Test/Test Utilities/TestUtilities.swift | 2 +- Test/Tests/RestClientTests.swift | 4 ++-- Test/Tests/RestPaginatedTests.swift | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/integration-test.yaml b/.github/workflows/integration-test.yaml index f49235800..6f7fb8fc2 100644 --- a/.github/workflows/integration-test.yaml +++ b/.github/workflows/integration-test.yaml @@ -32,7 +32,7 @@ jobs: env: LC_CTYPE: en_US.UTF-8 LANG: en_US.UTF-8 - ABLY_ENV: sandbox + ABLY_ENV: amnon-dev steps: - name: Check out repo diff --git a/Test/Test Utilities/TestUtilities.swift b/Test/Test Utilities/TestUtilities.swift index 09bb0ddac..40ba469cc 100644 --- a/Test/Test Utilities/TestUtilities.swift +++ b/Test/Test Utilities/TestUtilities.swift @@ -627,7 +627,7 @@ public func delay(_ seconds: TimeInterval, closure: @escaping () -> Void) { public func getEnvironment() -> String { let b = Bundle(for: AblyTests.self) guard let env = b.infoDictionary!["ABLY_ENV"] as? String, env.count > 0 else { - return "sandbox" + return "amnon-dev" } return env } diff --git a/Test/Tests/RestClientTests.swift b/Test/Tests/RestClientTests.swift index 0b373cd36..7246158d3 100644 --- a/Test/Tests/RestClientTests.swift +++ b/Test/Tests/RestClientTests.swift @@ -1310,9 +1310,9 @@ class RestClientTests: XCTestCase { // RSC15i func test__066__RestClient__Host_Fallback__retry_hosts_in_random_order__environment_fallback_hosts_have_the_format__environment___a_e__fallback_ably_realtime_com() { - let environmentFallbackHosts = ARTDefault.fallbackHosts(withEnvironment: "sandbox") + let environmentFallbackHosts = ARTDefault.fallbackHosts(withEnvironment: "amnon-dev") environmentFallbackHosts.forEach { host in - expect(host).to(match("sandbox-[a-e]-fallback.ably-realtime.com")) + expect(host).to(match("amnon-dev-[a-e]-fallback.ably-realtime.com")) } XCTAssertEqual(environmentFallbackHosts.count, 5) } diff --git a/Test/Tests/RestPaginatedTests.swift b/Test/Tests/RestPaginatedTests.swift index 549a8e79c..a882b10b9 100644 --- a/Test/Tests/RestPaginatedTests.swift +++ b/Test/Tests/RestPaginatedTests.swift @@ -4,7 +4,7 @@ import XCTest private let links = "<./messages?start=0&end=1535035746063&limit=100&direction=backwards&format=msgpack&firstEnd=1535035746063&fromDate=1535035746063&mode=all>; rel=\"first\", <./messages?start=0&end=1535035746063&limit=100&direction=backwards&format=msgpack&firstEnd=1535035746063&fromDate=1535035746063&mode=all>; rel=\"current\"" -private let url = URL(string: "https://sandbox-rest.ably.io:443/channels/foo/messages?limit=100&direction=backwards")! +private let url = URL(string: "https://amnon-dev-rest.ably.io:443/channels/foo/messages?limit=100&direction=backwards")! class RestPaginatedTests: XCTestCase { // XCTest invokes this method before executing the first test in the test suite. We use it to ensure that the global variables are initialized at the same moment, and in the same order, as they would have been when we used the Quick testing framework. @@ -44,6 +44,6 @@ class RestPaginatedTests: XCTestCase { fail("First link isn't a valid URL"); return } - XCTAssertEqual(firstRequest.url?.absoluteString, "https://sandbox-rest.ably.io:443/channels/foo/messages?start=0&end=1535035746063&limit=100&direction=backwards&format=msgpack&firstEnd=1535035746063&fromDate=1535035746063&mode=all") + XCTAssertEqual(firstRequest.url?.absoluteString, "https://amnon-dev-rest.ably.io:443/channels/foo/messages?start=0&end=1535035746063&limit=100&direction=backwards&format=msgpack&firstEnd=1535035746063&fromDate=1535035746063&mode=all") } } From 43a24d2f18a0c0d5588dba95b89c1458a2b6bdfa Mon Sep 17 00:00:00 2001 From: amnon Date: Tue, 17 Sep 2024 13:00:06 +0100 Subject: [PATCH 2/7] update some more references to sandbox --- .github/workflows/examples.yaml | 2 +- Examples/Tests/TestsTests/TestsTests.swift | 2 +- Makefile | 6 +++--- Scripts/log-environment-information.sh | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/examples.yaml b/.github/workflows/examples.yaml index 6e8895d0d..1565d4c02 100644 --- a/.github/workflows/examples.yaml +++ b/.github/workflows/examples.yaml @@ -14,7 +14,7 @@ jobs: env: LC_CTYPE: en_US.UTF-8 LANG: en_US.UTF-8 - ABLY_ENV: sandbox + ABLY_ENV: amnon-dev steps: - name: Checkout repo diff --git a/Examples/Tests/TestsTests/TestsTests.swift b/Examples/Tests/TestsTests/TestsTests.swift index d932d186c..31e7d505e 100644 --- a/Examples/Tests/TestsTests/TestsTests.swift +++ b/Examples/Tests/TestsTests/TestsTests.swift @@ -18,7 +18,7 @@ class TestsTests: XCTestCase { var responseData: Data? let postAppExpectation = self.expectation(description: "POST app to sandbox") - let request = NSMutableURLRequest(url: URL(string: "https://sandbox-rest.ably.io:443/apps")!) + let request = NSMutableURLRequest(url: URL(string: "https://amnon-dev-rest-admin.ably.io:443/apps")!) request.httpMethod = "POST" request.httpBody = "{\"keys\":[{}]}".data(using: String.Encoding.utf8) request.allHTTPHeaderFields = [ diff --git a/Makefile b/Makefile index 4d0960816..c90ff78ad 100644 --- a/Makefile +++ b/Makefile @@ -67,15 +67,15 @@ submodules: ## [Tests] Run tests on iOS 14.4 using sandbox environment test_iOS: - ABLY_ENV="sandbox" NAME="ably-iOS" bundle exec fastlane test_iOS16_2 + ABLY_ENV="amnon-dev" NAME="ably-iOS" bundle exec fastlane test_iOS16_2 ## [Tests] Run tests on tvOS 14.3 using sandbox environment test_tvOS: - ABLY_ENV="sandbox" NAME="ably-tvOS" bundle exec fastlane test_tvOS16_1 + ABLY_ENV="amnon-dev" NAME="ably-tvOS" bundle exec fastlane test_tvOS16_1 ## [Tests] Run tests on macOS using sandbox environment test_macOS: - ABLY_ENV="sandbox" NAME="ably-macOS" bundle exec fastlane test_macOS + ABLY_ENV="amnon-dev" NAME="ably-macOS" bundle exec fastlane test_macOS ## -- CocoaPods -- diff --git a/Scripts/log-environment-information.sh b/Scripts/log-environment-information.sh index 1d465c801..f071a4243 100755 --- a/Scripts/log-environment-information.sh +++ b/Scripts/log-environment-information.sh @@ -7,5 +7,5 @@ set -e ip=$(curl -s https://api.ipify.org) echo "Public IP address is: $ip" -echo "Output of \`dig sandbox-realtime.ably.io\`:" -dig sandbox-realtime.ably.io +echo "Output of \`dig amnon-dev-realtime.ably.io\`:" +dig amnon-dev-realtime.ably.io From 7222af4822564c49dbd65fd10f91391f12c01c3c Mon Sep 17 00:00:00 2001 From: amnon Date: Tue, 17 Sep 2024 15:37:23 +0100 Subject: [PATCH 3/7] WIP add some debug logging --- Test/Tests/RealtimeClientConnectionTests.swift | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Test/Tests/RealtimeClientConnectionTests.swift b/Test/Tests/RealtimeClientConnectionTests.swift index bf78207d9..e34c37b77 100644 --- a/Test/Tests/RealtimeClientConnectionTests.swift +++ b/Test/Tests/RealtimeClientConnectionTests.swift @@ -2142,7 +2142,7 @@ class RealtimeClientConnectionTests: XCTestCase { // Let the token expire waitUntil(timeout: testTimeout) { done in - delay(tokenTtl + AblyTests.tokenExpiryTolerance) { + delay(tokenTtl + AblyTests.tokenExpiryTolerance+10.0) { done() } } @@ -2159,6 +2159,7 @@ class RealtimeClientConnectionTests: XCTestCase { client.connection.on { stateChange in let state = stateChange.current let errorInfo = stateChange.reason + NSLog("got state change state %s, reason %s\n", stateChange.current, stateChange.reason) switch state { case .connected: fail("Should not be connected") From 5c34712ce0a6c790cb8325ede8798b4585604222 Mon Sep 17 00:00:00 2001 From: amnon Date: Tue, 17 Sep 2024 15:50:04 +0100 Subject: [PATCH 4/7] WIP NSLog not available --- Test/Tests/RealtimeClientConnectionTests.swift | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Test/Tests/RealtimeClientConnectionTests.swift b/Test/Tests/RealtimeClientConnectionTests.swift index e34c37b77..d950c71c6 100644 --- a/Test/Tests/RealtimeClientConnectionTests.swift +++ b/Test/Tests/RealtimeClientConnectionTests.swift @@ -2159,7 +2159,9 @@ class RealtimeClientConnectionTests: XCTestCase { client.connection.on { stateChange in let state = stateChange.current let errorInfo = stateChange.reason - NSLog("got state change state %s, reason %s\n", stateChange.current, stateChange.reason) + print("got state change state:") + print(stateChange.current) + print(stateChange.reason) switch state { case .connected: fail("Should not be connected") From b3db53d46b1458cc97d66057c41a54d6cbec9532 Mon Sep 17 00:00:00 2001 From: amnon Date: Tue, 17 Sep 2024 16:01:41 +0100 Subject: [PATCH 5/7] WIP coersion error --- Test/Tests/RealtimeClientConnectionTests.swift | 1 - 1 file changed, 1 deletion(-) diff --git a/Test/Tests/RealtimeClientConnectionTests.swift b/Test/Tests/RealtimeClientConnectionTests.swift index d950c71c6..e212f055d 100644 --- a/Test/Tests/RealtimeClientConnectionTests.swift +++ b/Test/Tests/RealtimeClientConnectionTests.swift @@ -2161,7 +2161,6 @@ class RealtimeClientConnectionTests: XCTestCase { let errorInfo = stateChange.reason print("got state change state:") print(stateChange.current) - print(stateChange.reason) switch state { case .connected: fail("Should not be connected") From 1918cfd3f8ec93dbee685f68186ca930fc705b91 Mon Sep 17 00:00:00 2001 From: amnon Date: Wed, 18 Sep 2024 16:28:54 +0100 Subject: [PATCH 6/7] WIP turn on debug logs --- Test/Tests/RealtimeClientConnectionTests.swift | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Test/Tests/RealtimeClientConnectionTests.swift b/Test/Tests/RealtimeClientConnectionTests.swift index e212f055d..c4c962738 100644 --- a/Test/Tests/RealtimeClientConnectionTests.swift +++ b/Test/Tests/RealtimeClientConnectionTests.swift @@ -2098,6 +2098,7 @@ class RealtimeClientConnectionTests: XCTestCase { let test = Test() let options = try AblyTests.commonAppSetup(for: test) options.autoConnect = false + options.logLevel = .debug; options.testOptions.transportFactory = TestProxyTransportFactory() let tokenTtl = 3.0 let tokenDetails = try getTestTokenDetails(for: test, key: options.key, capability: nil, ttl: tokenTtl) @@ -2136,17 +2137,18 @@ class RealtimeClientConnectionTests: XCTestCase { let test = Test() let options = try AblyTests.clientOptions(for: test) options.autoConnect = false + options.logLevel = .debug; let tokenTtl = 1.0 options.token = try getTestToken(for: test, ttl: tokenTtl) options.testOptions.transportFactory = TestProxyTransportFactory() // Let the token expire waitUntil(timeout: testTimeout) { done in - delay(tokenTtl + AblyTests.tokenExpiryTolerance+10.0) { + delay(tokenTtl + AblyTests.tokenExpiryTolerance) { done() } } - + let client = ARTRealtime(options: options) defer { client.dispose() @@ -2159,7 +2161,7 @@ class RealtimeClientConnectionTests: XCTestCase { client.connection.on { stateChange in let state = stateChange.current let errorInfo = stateChange.reason - print("got state change state:") + print("got state change state: \(stateChange.current)") print(stateChange.current) switch state { case .connected: @@ -2169,6 +2171,7 @@ class RealtimeClientConnectionTests: XCTestCase { guard let errorInfo = errorInfo else { fail("ErrorInfo is nil"); done(); return } + print("got errorInfo.code=\(errorInfo.code)") XCTAssertEqual(errorInfo.code, ARTErrorCode.tokenExpired.intValue) done() default: @@ -2181,8 +2184,9 @@ class RealtimeClientConnectionTests: XCTestCase { let failures = transport.protocolMessagesReceived.filter { $0.action == .error } + print("failures.count=\(failures.count)") if failures.count != 1 { - fail("Should have only one connection request fail") + fail("Should have only one connection request fail, got \(failures.count)") return } From 91d8ad435791c7cc91412e6c7b959ffb6484ac91 Mon Sep 17 00:00:00 2001 From: amnon Date: Thu, 19 Sep 2024 11:25:25 +0100 Subject: [PATCH 7/7] remove test foor error text --- Test/Tests/AuthTests.swift | 1 - 1 file changed, 1 deletion(-) diff --git a/Test/Tests/AuthTests.swift b/Test/Tests/AuthTests.swift index 143fdb247..15aa74192 100644 --- a/Test/Tests/AuthTests.swift +++ b/Test/Tests/AuthTests.swift @@ -4159,7 +4159,6 @@ class AuthTests: XCTestCase { client.connection.once(.connected) { stateChange in client.connection.once(.disconnected) { stateChange in XCTAssertEqual(stateChange.reason?.code, ARTErrorCode.tokenExpired.intValue) - expect(stateChange.reason?.description).to(contain("Key/token status changed (expire)")) done() } }