Browse Source

Move generated interoperability test models to their own target. (#556)

Motivation:

To implement other interoperability tests (i.e. the connection backoff test)
it would be convenient for the gRPC interoperability test models to be
in a self contained target (instead of using symlinks).

Modifications:

- Move the interoperability test models into their own target
- Rename the interoperability test implementation and CLI
- Add missing imports

Result:

gRPC interoperability test models are in their own target.
George Barnett 6 years ago
parent
commit
12e7553aaf
22 changed files with 46 additions and 16 deletions
  1. 22 9
      Package.swift
  2. 0 0
      Sources/GRPCInteroperabilityTestModels/Generated/empty.pb.swift
  3. 0 0
      Sources/GRPCInteroperabilityTestModels/Generated/messages.pb.swift
  4. 1 1
      Sources/GRPCInteroperabilityTestModels/Generated/test.grpc.swift
  5. 0 0
      Sources/GRPCInteroperabilityTestModels/Generated/test.pb.swift
  6. 12 0
      Sources/GRPCInteroperabilityTestModels/README.md
  7. 2 2
      Sources/GRPCInteroperabilityTestModels/generate.sh
  8. 0 0
      Sources/GRPCInteroperabilityTestModels/src/proto/grpc/testing/empty.proto
  9. 0 0
      Sources/GRPCInteroperabilityTestModels/src/proto/grpc/testing/empty_service.proto
  10. 0 0
      Sources/GRPCInteroperabilityTestModels/src/proto/grpc/testing/messages.proto
  11. 0 0
      Sources/GRPCInteroperabilityTestModels/src/proto/grpc/testing/test.proto
  12. 1 1
      Sources/GRPCInteroperabilityTests/main.swift
  13. 0 0
      Sources/GRPCInteroperabilityTestsImplementation/Assertions.swift
  14. 5 2
      Sources/GRPCInteroperabilityTestsImplementation/GRPCTestingConvenienceMethods.swift
  15. 0 0
      Sources/GRPCInteroperabilityTestsImplementation/InteroperabilityTestCase.swift
  16. 1 0
      Sources/GRPCInteroperabilityTestsImplementation/InteroperabilityTestCases.swift
  17. 0 0
      Sources/GRPCInteroperabilityTestsImplementation/InteroperabilityTestClientConnection.swift
  18. 0 0
      Sources/GRPCInteroperabilityTestsImplementation/InteroperabilityTestCredentials.swift
  19. 0 0
      Sources/GRPCInteroperabilityTestsImplementation/InteroperabilityTestServer.swift
  20. 0 0
      Sources/GRPCInteroperabilityTestsImplementation/ServerFeatures.swift
  21. 1 0
      Sources/GRPCInteroperabilityTestsImplementation/TestServiceProvider.swift
  22. 1 1
      Tests/GRPCTests/GRPCInteroperabilityTests.swift

+ 22 - 9
Package.swift

@@ -21,7 +21,7 @@ let package = Package(
   name: "GRPC",
   products: [
     .library(name: "GRPC", targets: ["GRPC"]),
-    .executable(name: "InteroperabilityTestRunner", targets: ["GRPCInteroperabilityTestsCLI"]),
+    .executable(name: "InteroperabilityTestRunner", targets: ["GRPCInteroperabilityTests"]),
     .executable(name: "PerformanceTestRunner", targets: ["GRPCPerformanceTests"]),
     .executable(name: "Echo", targets: ["Echo"]),
   ],
@@ -66,7 +66,7 @@ let package = Package(
       dependencies: [
         "GRPC",
         "GRPCSampleData",
-        "GRPCInteroperabilityTests"
+        "GRPCInteroperabilityTestsImplementation"
       ]
     ),
 
@@ -80,23 +80,36 @@ let package = Package(
       ]
     ),
 
-    // Interoperability tests, this target doesn't contain the CLI as the
-    // interoperability tests are reused in the main test suite.
+    // Interoperability tests implementation.
     .target(
-      name: "GRPCInteroperabilityTests",
-      dependencies: ["GRPC"]
+      name: "GRPCInteroperabilityTestsImplementation",
+      dependencies: [
+        "GRPC",
+        "GRPCInteroperabilityTestModels"
+      ]
+    ),
+
+    // Generated interoperability test models.
+    .target(
+      name: "GRPCInteroperabilityTestModels",
+      dependencies: [
+        "GRPC",
+        "NIO",
+        "NIOHTTP1",
+        "SwiftProtobuf"
+      ]
     ),
 
     // The CLI for the interoperability tests.
     .target(
-      name: "GRPCInteroperabilityTestsCLI",
+      name: "GRPCInteroperabilityTests",
       dependencies: [
-        "GRPCInteroperabilityTests",
+        "GRPCInteroperabilityTestsImplementation",
         "Commander"
       ]
     ),
 
-    // Performance tests and CLI.
+    // Performance tests implementation and CLI.
     .target(
       name: "GRPCPerformanceTests",
       dependencies: [

+ 0 - 0
Sources/GRPCInteroperabilityTests/protos/Generated/empty.pb.swift → Sources/GRPCInteroperabilityTestModels/Generated/empty.pb.swift


+ 0 - 0
Sources/GRPCInteroperabilityTests/protos/Generated/messages.pb.swift → Sources/GRPCInteroperabilityTestModels/Generated/messages.pb.swift


+ 1 - 1
Sources/GRPCInteroperabilityTests/protos/Generated/test.grpc.swift → Sources/GRPCInteroperabilityTestModels/Generated/test.grpc.swift

@@ -21,9 +21,9 @@
 // limitations under the License.
 //
 import Foundation
+import GRPC
 import NIO
 import NIOHTTP1
-import GRPC
 import SwiftProtobuf
 
 

+ 0 - 0
Sources/GRPCInteroperabilityTests/protos/Generated/test.pb.swift → Sources/GRPCInteroperabilityTestModels/Generated/test.pb.swift


+ 12 - 0
Sources/GRPCInteroperabilityTestModels/README.md

@@ -0,0 +1,12 @@
+# gRPC Interoperability Test Protos
+
+This module contains the generated models for the gRPC interoperability tests
+and the script used to generate them.
+
+The tests require that some methods and services are left unimplemented, this
+requires manual edits after code generation. These instructions are emitted to
+`stdout` at the end of the `generate.sh` script.
+
+* `generate.sh`: generates models from interoperability test protobufs.
+* `src`: source of protobufs.
+* `Generated`: output directory for generated models.

+ 2 - 2
Sources/GRPCInteroperabilityTests/protos/generate.sh → Sources/GRPCInteroperabilityTestModels/generate.sh

@@ -1,7 +1,7 @@
 #!/bin/sh
 
-PLUGIN_SWIFT=../../../protoc-gen-swift
-PLUGIN_SWIFTGRPC=../../../protoc-gen-swiftgrpc
+PLUGIN_SWIFT=../../protoc-gen-swift
+PLUGIN_SWIFTGRPC=../../protoc-gen-swiftgrpc
 PROTO="src/proto/grpc/testing/test.proto"
 
 OUTPUT="Generated"

+ 0 - 0
Sources/GRPCInteroperabilityTests/protos/src/proto/grpc/testing/empty.proto → Sources/GRPCInteroperabilityTestModels/src/proto/grpc/testing/empty.proto


+ 0 - 0
Sources/GRPCInteroperabilityTests/protos/src/proto/grpc/testing/empty_service.proto → Sources/GRPCInteroperabilityTestModels/src/proto/grpc/testing/empty_service.proto


+ 0 - 0
Sources/GRPCInteroperabilityTests/protos/src/proto/grpc/testing/messages.proto → Sources/GRPCInteroperabilityTestModels/src/proto/grpc/testing/messages.proto


+ 0 - 0
Sources/GRPCInteroperabilityTests/protos/src/proto/grpc/testing/test.proto → Sources/GRPCInteroperabilityTestModels/src/proto/grpc/testing/test.proto


+ 1 - 1
Sources/GRPCInteroperabilityTestsCLI/main.swift → Sources/GRPCInteroperabilityTests/main.swift

@@ -17,7 +17,7 @@ import Foundation
 import GRPC
 import NIO
 import NIOSSL
-import GRPCInteroperabilityTests
+import GRPCInteroperabilityTestsImplementation
 import Commander
 
 enum InteroperabilityTestError: LocalizedError {

+ 0 - 0
Sources/GRPCInteroperabilityTests/Assertions.swift → Sources/GRPCInteroperabilityTestsImplementation/Assertions.swift


+ 5 - 2
Sources/GRPCInteroperabilityTests/GRPCTestingConvenienceMethods.swift → Sources/GRPCInteroperabilityTestsImplementation/GRPCTestingConvenienceMethods.swift

@@ -16,6 +16,7 @@
 import Foundation
 import SwiftProtobuf
 import NIOHTTP1
+import GRPCInteroperabilityTestModels
 
 // MARK: - Payload creation
 extension Grpc_Testing_Payload {
@@ -35,8 +36,10 @@ extension Grpc_Testing_Payload {
 // MARK: - Echo status creation
 extension Grpc_Testing_EchoStatus {
   init(code: Int32, message: String) {
-    self.code = code
-    self.message = message
+    self = .with {
+      $0.code = code
+      $0.message = message
+    }
   }
 }
 

+ 0 - 0
Sources/GRPCInteroperabilityTests/InteroperabilityTestCase.swift → Sources/GRPCInteroperabilityTestsImplementation/InteroperabilityTestCase.swift


+ 1 - 0
Sources/GRPCInteroperabilityTests/InteroperabilityTestCases.swift → Sources/GRPCInteroperabilityTestsImplementation/InteroperabilityTestCases.swift

@@ -15,6 +15,7 @@
  */
 import Foundation
 import GRPC
+import GRPCInteroperabilityTestModels
 import NIOHTTP1
 
 /// This test verifies that implementations support zero-size messages. Ideally, client

+ 0 - 0
Sources/GRPCInteroperabilityTests/InteroperabilityTestClientConnection.swift → Sources/GRPCInteroperabilityTestsImplementation/InteroperabilityTestClientConnection.swift


+ 0 - 0
Sources/GRPCInteroperabilityTests/InteroperabilityTestCredentials.swift → Sources/GRPCInteroperabilityTestsImplementation/InteroperabilityTestCredentials.swift


+ 0 - 0
Sources/GRPCInteroperabilityTests/InteroperabilityTestServer.swift → Sources/GRPCInteroperabilityTestsImplementation/InteroperabilityTestServer.swift


+ 0 - 0
Sources/GRPCInteroperabilityTests/ServerFeatures.swift → Sources/GRPCInteroperabilityTestsImplementation/ServerFeatures.swift


+ 1 - 0
Sources/GRPCInteroperabilityTests/TestServiceProvider.swift → Sources/GRPCInteroperabilityTestsImplementation/TestServiceProvider.swift

@@ -15,6 +15,7 @@
  */
 import Foundation
 import GRPC
+import GRPCInteroperabilityTestModels
 import NIO
 
 /// A service prodiver for the gRPC interoperaability test suite.

+ 1 - 1
Tests/GRPCTests/GRPCInteroperabilityTests.swift

@@ -15,7 +15,7 @@
  */
 import Foundation
 import GRPC
-import GRPCInteroperabilityTests
+import GRPCInteroperabilityTestsImplementation
 import NIO
 import XCTest