From d2c79f34ff64c6527f60ef12583b1f449e537a2e Mon Sep 17 00:00:00 2001 From: Steve Ayers Date: Fri, 1 Sep 2023 13:04:15 -0400 Subject: [PATCH 1/4] Update refs for conformance --- Makefile | 18 +++++++++--------- README.md | 8 ++++---- .../AsyncAwaitConformance.swift} | 14 +++++++------- .../CallbackConformance.swift} | 14 +++++++------- .../ConformanceConfiguration.swift} | 14 +++++++------- .../ConformanceNIOHTTPClient.swift} | 6 +++--- .../ConformanceURLSessionHTTPClient.swift} | 8 ++++---- Tests/ConnectLibraryTests/proto/README.md | 2 +- 8 files changed, 42 insertions(+), 42 deletions(-) rename Tests/ConnectLibraryTests/{ConnectCrosstests/AsyncAwaitCrosstests.swift => ConnectConformance/AsyncAwaitConformance.swift} (97%) rename Tests/ConnectLibraryTests/{ConnectCrosstests/CallbackCrosstests.swift => ConnectConformance/CallbackConformance.swift} (97%) rename Tests/ConnectLibraryTests/{ConnectCrosstests/CrosstestConfiguration.swift => ConnectConformance/ConformanceConfiguration.swift} (87%) rename Tests/ConnectLibraryTests/{ConnectCrosstests/CrosstestNIOHTTPClient.swift => ConnectConformance/ConformanceNIOHTTPClient.swift} (84%) rename Tests/ConnectLibraryTests/{ConnectCrosstests/CrosstestURLSessionHTTPClient.swift => ConnectConformance/ConformanceURLSessionHTTPClient.swift} (87%) diff --git a/Makefile b/Makefile index c476c250..08a12e66 100644 --- a/Makefile +++ b/Makefile @@ -8,7 +8,7 @@ MAKEFLAGS += --no-builtin-rules MAKEFLAGS += --no-print-directory BIN := .tmp/bin LICENSE_HEADER_YEAR_RANGE := 2022-2023 -CROSSTEST_VERSION := 4f4e96d8fea3ed9473b90a964a5ba429e7ea5649 +CONFORMANCE_VERSION := 4f4e96d8fea3ed9473b90a964a5ba429e7ea5649 LICENSE_HEADER_VERSION := v1.12.0 LICENSE_IGNORE := -e Package.swift \ -e $(BIN)\/ \ @@ -40,17 +40,17 @@ cleangenerated: ## Delete all generated outputs rm -rf ./Libraries/Connect/Implementation/Generated/* rm -rf ./Tests/ConnectLibraryTests/Generated/* -.PHONY: crosstestserverstop -crosstestserverstop: ## Stop the crosstest server +.PHONY: conformanceserverstop +conformanceserverstop: ## Stop the conformance server -docker container stop serverconnect servergrpc -.PHONY: crosstestserverrun -crosstestserverrun: crosstestserverstop ## Start the crosstest server +.PHONY: conformanceserverrun +conformanceserverrun: conformanceserverstop ## Start the conformance server docker run --rm --name serverconnect -p 8080:8080 -p 8081:8081 -d \ - bufbuild/connect-crosstest:$(CROSSTEST_VERSION) \ + connectrpc/conformance:$(CONFORMANCE_VERSION) \ /usr/local/bin/serverconnect --h1port "8080" --h2port "8081" --cert "cert/localhost.crt" --key "cert/localhost.key" docker run --rm --name servergrpc -p 8083:8083 -d \ - bufbuild/connect-crosstest:$(CROSSTEST_VERSION) \ + connectrpc/conformance:$(CONFORMANCE_VERSION) \ /usr/local/bin/servergrpc --port "8083" --cert "cert/localhost.crt" --key "cert/localhost.key" .PHONY: generate @@ -78,6 +78,6 @@ $(BIN)/license-headers: Makefile GOBIN=$(abspath $(BIN)) go install github.com/bufbuild/buf/private/pkg/licenseheader/cmd/license-header@$(LICENSE_HEADER_VERSION) .PHONY: test -test: crosstestserverrun ## Run all tests +test: conformanceserverrun ## Run all tests swift test - $(MAKE) crosstestserverstop + $(MAKE) conformanceserverstop diff --git a/README.md b/README.md index 24c05433..eb725549 100644 --- a/README.md +++ b/README.md @@ -155,9 +155,9 @@ for details. - [connect-kotlin][connect-kotlin]: Idiomatic gRPC & Connect RPCs for Kotlin - [connect-go][connect-go]: Go service stubs for servers -- [connect-web][connect-web]: TypeScript clients for web browsers +- [connect-es][connect-es]: Type-safe APIs with Protobuf and TypeScript - [Buf Studio][buf-studio]: Web UI for ad-hoc RPCs -- [connect-crosstest][connect-crosstest]: Connect, gRPC, and gRPC-Web +- [connect-conformance][connect-conformance]: Connect, gRPC, and gRPC-Web interoperability tests ## Status @@ -171,11 +171,11 @@ Offered under the [Apache 2 license](./LICENSE). [blog]: https://buf.build/blog/announcing-connect-swift [buf-studio]: https://buf.build/studio -[connect-crosstest]: https://github.com/bufbuild/connect-crosstest +[connect-conformance]: https://github.com/connectrpc/conformance [connect-go]: https://github.com/bufbuild/connect-go [connect-kotlin]: https://github.com/bufbuild/connect-kotlin [connect-protocol]: https://connectrpc.com/docs/protocol -[connect-web]: https://www.npmjs.com/package/@bufbuild/connect-web +[connect-es]: https://github.com/connectrpc/connect-es [error-handling]: https://connectrpc.com/docs/swift/errors [getting-started]: https://connectrpc.com/docs/swift/getting-started [grpc-protocol]: https://github.com/grpc/grpc/blob/master/doc/PROTOCOL-HTTP2.md diff --git a/Tests/ConnectLibraryTests/ConnectCrosstests/AsyncAwaitCrosstests.swift b/Tests/ConnectLibraryTests/ConnectConformance/AsyncAwaitConformance.swift similarity index 97% rename from Tests/ConnectLibraryTests/ConnectCrosstests/AsyncAwaitCrosstests.swift rename to Tests/ConnectLibraryTests/ConnectConformance/AsyncAwaitConformance.swift index 240ccc93..ef0def95 100644 --- a/Tests/ConnectLibraryTests/ConnectCrosstests/AsyncAwaitCrosstests.swift +++ b/Tests/ConnectLibraryTests/ConnectConformance/AsyncAwaitConformance.swift @@ -22,17 +22,17 @@ private typealias TestServiceClient = Grpc_Testing_TestServiceClient private typealias UnimplementedServiceClient = Grpc_Testing_UnimplementedServiceClient /// This test suite runs against multiple protocols and serialization formats. -/// Tests are based on https://github.com/bufbuild/connect-crosstest +/// Tests are based on https://github.com/connectrpc/conformance /// /// Tests are written using async/await APIs. @available(iOS 13, *) -final class AsyncAwaitCrosstests: XCTestCase { +final class AsyncAwaitConformance: XCTestCase { private func executeTestWithClients( function: Selector = #function, timeout: TimeInterval = 60, runTestsWithClient: (TestServiceClient) async throws -> Void ) async rethrows { - let configurations = CrosstestConfiguration.all(timeout: timeout) + let configurations = ConformanceConfiguration.all(timeout: timeout) for configuration in configurations { try await runTestsWithClient(TestServiceClient(client: configuration.protocolClient)) print("Ran \(function) with \(configuration.description)") @@ -43,7 +43,7 @@ final class AsyncAwaitCrosstests: XCTestCase { function: Selector = #function, runTestsWithClient: (UnimplementedServiceClient) async throws -> Void ) async rethrows { - let configurations = CrosstestConfiguration.all(timeout: 60) + let configurations = ConformanceConfiguration.all(timeout: 60) for configuration in configurations { try await runTestsWithClient( UnimplementedServiceClient(client: configuration.protocolClient) @@ -52,7 +52,7 @@ final class AsyncAwaitCrosstests: XCTestCase { } } - // MARK: - Crosstest cases + // MARK: - Conformance cases func testEmptyUnary() async { await self.executeTestWithClients { client in @@ -343,7 +343,7 @@ final class AsyncAwaitCrosstests: XCTestCase { await self.executeTestWithClients { client in let expectedErrorDetail = Grpc_Testing_ErrorDetail.with { proto in proto.reason = "soirée 🎉" - proto.domain = "connect-crosstest" + proto.domain = "connect-conformance" } let response = await client.failUnaryCall(request: Grpc_Testing_SimpleRequest()) XCTAssertEqual(response.error?.code, .resourceExhausted) @@ -356,7 +356,7 @@ final class AsyncAwaitCrosstests: XCTestCase { try await self.executeTestWithClients { client in let expectedErrorDetail = Grpc_Testing_ErrorDetail.with { proto in proto.reason = "soirée 🎉" - proto.domain = "connect-crosstest" + proto.domain = "connect-conformance" } let expectation = self.expectation(description: "Stream completes") let stream = client.failStreamingOutputCall() diff --git a/Tests/ConnectLibraryTests/ConnectCrosstests/CallbackCrosstests.swift b/Tests/ConnectLibraryTests/ConnectConformance/CallbackConformance.swift similarity index 97% rename from Tests/ConnectLibraryTests/ConnectCrosstests/CallbackCrosstests.swift rename to Tests/ConnectLibraryTests/ConnectConformance/CallbackConformance.swift index 430edfca..c86b9bf6 100644 --- a/Tests/ConnectLibraryTests/ConnectCrosstests/CallbackCrosstests.swift +++ b/Tests/ConnectLibraryTests/ConnectConformance/CallbackConformance.swift @@ -24,16 +24,16 @@ private typealias TestServiceClient = Grpc_Testing_TestServiceClient private typealias UnimplementedServiceClient = Grpc_Testing_UnimplementedServiceClient /// This test suite runs against multiple protocols and serialization formats. -/// Tests are based on https://github.com/bufbuild/connect-crosstest +/// Tests are based on https://github.com/connectrpc/conformance /// /// Tests are written using callback APIs. -final class CallbackCrosstests: XCTestCase { +final class CallbackConformance: XCTestCase { private func executeTestWithClients( function: Selector = #function, timeout: TimeInterval = 60, runTestsWithClient: (TestServiceClient) throws -> Void ) rethrows { - let configurations = CrosstestConfiguration.all(timeout: timeout) + let configurations = ConformanceConfiguration.all(timeout: timeout) for configuration in configurations { try runTestsWithClient(TestServiceClient(client: configuration.protocolClient)) print("Ran \(function) with \(configuration.description)") @@ -44,14 +44,14 @@ final class CallbackCrosstests: XCTestCase { function: Selector = #function, runTestsWithClient: (UnimplementedServiceClient) throws -> Void ) rethrows { - let configurations = CrosstestConfiguration.all(timeout: 60) + let configurations = ConformanceConfiguration.all(timeout: 60) for configuration in configurations { try runTestsWithClient(UnimplementedServiceClient(client: configuration.protocolClient)) print("Ran \(function) with \(configuration.description)") } } - // MARK: - Crosstest cases + // MARK: - Conformance cases func testEmptyUnary() { self.executeTestWithClients { client in @@ -377,7 +377,7 @@ final class CallbackCrosstests: XCTestCase { self.executeTestWithClients { client in let expectedErrorDetail = Grpc_Testing_ErrorDetail.with { proto in proto.reason = "soirée 🎉" - proto.domain = "connect-crosstest" + proto.domain = "connect-conformance" } let expectation = self.expectation(description: "Request completes") client.failUnaryCall(request: Grpc_Testing_SimpleRequest()) { response in @@ -395,7 +395,7 @@ final class CallbackCrosstests: XCTestCase { try self.executeTestWithClients { client in let expectedErrorDetail = Grpc_Testing_ErrorDetail.with { proto in proto.reason = "soirée 🎉" - proto.domain = "connect-crosstest" + proto.domain = "connect-conformance" } let expectation = self.expectation(description: "Stream completes") let stream = client.failStreamingOutputCall { result in diff --git a/Tests/ConnectLibraryTests/ConnectCrosstests/CrosstestConfiguration.swift b/Tests/ConnectLibraryTests/ConnectConformance/ConformanceConfiguration.swift similarity index 87% rename from Tests/ConnectLibraryTests/ConnectCrosstests/CrosstestConfiguration.swift rename to Tests/ConnectLibraryTests/ConnectConformance/ConformanceConfiguration.swift index 0e719cc5..3f9df361 100644 --- a/Tests/ConnectLibraryTests/ConnectCrosstests/CrosstestConfiguration.swift +++ b/Tests/ConnectLibraryTests/ConnectConformance/ConformanceConfiguration.swift @@ -16,8 +16,8 @@ import Connect import ConnectNIO import Foundation -/// Represents a specific configuration with which to run a suite of crosstests. -final class CrosstestConfiguration { +/// Represents a specific configuration with which to run a suite of conformance tests. +final class ConformanceConfiguration { let description: String let protocolClient: ProtocolClient @@ -27,14 +27,14 @@ final class CrosstestConfiguration { } /// Configures a list of configurations that can be used to run a comprehensive - /// suite of crosstests. + /// suite of conformance tests. /// /// - parameter timeout: Timeout to apply to the client. /// - /// - returns: A list of configurations to use for crosstests. - static func all(timeout: TimeInterval) -> [CrosstestConfiguration] { - let urlSessionClient = CrosstestURLSessionHTTPClient(timeout: timeout) - let nioClient = CrosstestNIOHTTPClient( + /// - returns: A list of configurations to use for conformance tests. + static func all(timeout: TimeInterval) -> [ConformanceConfiguration] { + let urlSessionClient = ConformanceURLSessionHTTPClient(timeout: timeout) + let nioClient = ConformanceNIOHTTPClient( // swiftlint:disable:next number_separator host: "https://localhost", port: 8081, timeout: timeout ) diff --git a/Tests/ConnectLibraryTests/ConnectCrosstests/CrosstestNIOHTTPClient.swift b/Tests/ConnectLibraryTests/ConnectConformance/ConformanceNIOHTTPClient.swift similarity index 84% rename from Tests/ConnectLibraryTests/ConnectCrosstests/CrosstestNIOHTTPClient.swift rename to Tests/ConnectLibraryTests/ConnectConformance/ConformanceNIOHTTPClient.swift index 2d85d240..a1cc325a 100644 --- a/Tests/ConnectLibraryTests/ConnectCrosstests/CrosstestNIOHTTPClient.swift +++ b/Tests/ConnectLibraryTests/ConnectConformance/ConformanceNIOHTTPClient.swift @@ -17,9 +17,9 @@ import ConnectNIO import Foundation import NIOSSL -/// HTTP client backed by NIO and used by crosstests in order to handle SSL challenges -/// with the crosstest server. -final class CrosstestNIOHTTPClient: ConnectNIO.NIOHTTPClient { +/// HTTP client backed by NIO and used by conformance tests in order to handle SSL challenges +/// with the conformance server. +final class ConformanceNIOHTTPClient: ConnectNIO.NIOHTTPClient { init(host: String, port: Int, timeout: TimeInterval) { super.init(host: host, port: port, timeout: timeout) } diff --git a/Tests/ConnectLibraryTests/ConnectCrosstests/CrosstestURLSessionHTTPClient.swift b/Tests/ConnectLibraryTests/ConnectConformance/ConformanceURLSessionHTTPClient.swift similarity index 87% rename from Tests/ConnectLibraryTests/ConnectCrosstests/CrosstestURLSessionHTTPClient.swift rename to Tests/ConnectLibraryTests/ConnectConformance/ConformanceURLSessionHTTPClient.swift index b56124df..ff8a6195 100644 --- a/Tests/ConnectLibraryTests/ConnectCrosstests/CrosstestURLSessionHTTPClient.swift +++ b/Tests/ConnectLibraryTests/ConnectConformance/ConformanceURLSessionHTTPClient.swift @@ -15,9 +15,9 @@ import Connect import Foundation -/// HTTP client backed by URLSession and used by crosstests in order to handle SSL challenges -/// with the crosstest server. -final class CrosstestURLSessionHTTPClient: URLSessionHTTPClient { +/// HTTP client backed by URLSession and used by conformance tests in order to handle SSL challenges +/// with the conformance server. +final class ConformanceURLSessionHTTPClient: URLSessionHTTPClient { init(timeout: TimeInterval) { let configuration = URLSessionConfiguration.default configuration.timeoutIntervalForRequest = timeout @@ -29,7 +29,7 @@ final class CrosstestURLSessionHTTPClient: URLSessionHTTPClient { _ session: URLSession, didReceive challenge: URLAuthenticationChallenge, completionHandler: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Void ) { - // This codepath is executed when using HTTPS with the crosstest server. + // This codepath is executed when using HTTPS with the conformance server. let protectionSpace = challenge.protectionSpace if protectionSpace.authenticationMethod == NSURLAuthenticationMethodServerTrust, let serverTrust = protectionSpace.serverTrust diff --git a/Tests/ConnectLibraryTests/proto/README.md b/Tests/ConnectLibraryTests/proto/README.md index dcfe4abe..fcc6cc73 100644 --- a/Tests/ConnectLibraryTests/proto/README.md +++ b/Tests/ConnectLibraryTests/proto/README.md @@ -1,2 +1,2 @@ This directory contains `.proto` files that are used to communicate -with the crosstest server when running tests. +with the conformance server when running tests. From 47a6033bacc6db12b39c3f491263696a99adc27e Mon Sep 17 00:00:00 2001 From: Steve Ayers Date: Thu, 7 Sep 2023 23:56:28 -0400 Subject: [PATCH 2/4] Use old docker --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 08a12e66..33cbb7ba 100644 --- a/Makefile +++ b/Makefile @@ -47,10 +47,10 @@ conformanceserverstop: ## Stop the conformance server .PHONY: conformanceserverrun conformanceserverrun: conformanceserverstop ## Start the conformance server docker run --rm --name serverconnect -p 8080:8080 -p 8081:8081 -d \ - connectrpc/conformance:$(CONFORMANCE_VERSION) \ + bufbuild/connect-crosstest:$(CONFORMANCE_VERSION) \ /usr/local/bin/serverconnect --h1port "8080" --h2port "8081" --cert "cert/localhost.crt" --key "cert/localhost.key" docker run --rm --name servergrpc -p 8083:8083 -d \ - connectrpc/conformance:$(CONFORMANCE_VERSION) \ + bufbuild/connect-crosstest:$(CONFORMANCE_VERSION) \ /usr/local/bin/servergrpc --port "8083" --cert "cert/localhost.crt" --key "cert/localhost.key" .PHONY: generate From 96c7ea20c4567450d0d66770704c0030c8d07775 Mon Sep 17 00:00:00 2001 From: Steve Ayers Date: Thu, 7 Sep 2023 23:59:41 -0400 Subject: [PATCH 3/4] Fix domain --- .../ConnectConformance/AsyncAwaitConformance.swift | 4 ++-- .../ConnectConformance/CallbackConformance.swift | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Tests/ConnectLibraryTests/ConnectConformance/AsyncAwaitConformance.swift b/Tests/ConnectLibraryTests/ConnectConformance/AsyncAwaitConformance.swift index ef0def95..21915f96 100644 --- a/Tests/ConnectLibraryTests/ConnectConformance/AsyncAwaitConformance.swift +++ b/Tests/ConnectLibraryTests/ConnectConformance/AsyncAwaitConformance.swift @@ -343,7 +343,7 @@ final class AsyncAwaitConformance: XCTestCase { await self.executeTestWithClients { client in let expectedErrorDetail = Grpc_Testing_ErrorDetail.with { proto in proto.reason = "soirée 🎉" - proto.domain = "connect-conformance" + proto.domain = "connect-crosstest" } let response = await client.failUnaryCall(request: Grpc_Testing_SimpleRequest()) XCTAssertEqual(response.error?.code, .resourceExhausted) @@ -356,7 +356,7 @@ final class AsyncAwaitConformance: XCTestCase { try await self.executeTestWithClients { client in let expectedErrorDetail = Grpc_Testing_ErrorDetail.with { proto in proto.reason = "soirée 🎉" - proto.domain = "connect-conformance" + proto.domain = "connect-crosstest" } let expectation = self.expectation(description: "Stream completes") let stream = client.failStreamingOutputCall() diff --git a/Tests/ConnectLibraryTests/ConnectConformance/CallbackConformance.swift b/Tests/ConnectLibraryTests/ConnectConformance/CallbackConformance.swift index c86b9bf6..1c91b4c5 100644 --- a/Tests/ConnectLibraryTests/ConnectConformance/CallbackConformance.swift +++ b/Tests/ConnectLibraryTests/ConnectConformance/CallbackConformance.swift @@ -377,7 +377,7 @@ final class CallbackConformance: XCTestCase { self.executeTestWithClients { client in let expectedErrorDetail = Grpc_Testing_ErrorDetail.with { proto in proto.reason = "soirée 🎉" - proto.domain = "connect-conformance" + proto.domain = "connect-crosstest" } let expectation = self.expectation(description: "Request completes") client.failUnaryCall(request: Grpc_Testing_SimpleRequest()) { response in @@ -395,7 +395,7 @@ final class CallbackConformance: XCTestCase { try self.executeTestWithClients { client in let expectedErrorDetail = Grpc_Testing_ErrorDetail.with { proto in proto.reason = "soirée 🎉" - proto.domain = "connect-conformance" + proto.domain = "connect-crosstest" } let expectation = self.expectation(description: "Stream completes") let stream = client.failStreamingOutputCall { result in From 47e482980960afe67abbd55c12a5f7a378697925 Mon Sep 17 00:00:00 2001 From: Steve Ayers Date: Fri, 8 Sep 2023 15:16:01 -0400 Subject: [PATCH 4/4] Update CONTRIBUTING --- .github/CONTRIBUTING.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 676012f0..035de673 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -82,7 +82,7 @@ Outputted code will be available in the `out` directories specified by ## Running Tests A test server is used to run -[crosstests](../Tests/ConnectLibraryTests/ConnectCrosstests) - +[conformance](../Tests/ConnectLibraryTests/ConnectConformance) - integration tests which validate the behavior of the `Connect` library with various protocols. **Starting the server requires Docker, so ensure that you have Docker installed before proceeding.** @@ -96,7 +96,7 @@ make test If you prefer to run the tests using Xcode, you can manually start the server: ```sh -make crosstestserverrun +make conformanceserverrun ``` ## Linting