-
Notifications
You must be signed in to change notification settings - Fork 435
Interop Tests implementation #1821
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Motivation: The test cases test certain functionalities of the new GRPC server and client. Modifications: - created the InteroperabilityTest protocol with the run method - created the InteroperabilityTestCase enum that will be used by main to run certain tests according to the input - implemented the interop tests for the features we support (no caching or compression tests) - added new assertions to the test framework Result: We will be able to implement the main() function that runs the interop tests using in process transport.
glbrntt
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good for the most part, but I think there are a couple of bugs which need fixing first.
Package.swift
Outdated
| name: "InteroperabilityTests", | ||
| dependencies: [ | ||
| .grpcCore, | ||
| .grpcInProcessTransport, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need to provide a transport here
| public func assertFailure( | ||
| _ message: String = "Failure.", | ||
| file: String = #fileID, | ||
| line: Int = #line | ||
| ) throws { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure we should bother with this, we can just throw AssertionFailure instead
| /// The set of server features required to run this test. | ||
| public var requiredServerFeatures: Set<ServerFeature> { | ||
| switch self { | ||
| case .emptyUnary: | ||
| return [.emptyCall] | ||
| case .largeUnary: | ||
| return [.unaryCall] | ||
| case .clientStreaming: | ||
| return [.streamingInputCall] | ||
| case .serverStreaming: | ||
| return [.streamingOutputCall] | ||
| case .pingPong: | ||
| return [.fullDuplexCall] | ||
| case .emptyStream: | ||
| return [.fullDuplexCall] | ||
| case .customMetadata: | ||
| return [.unaryCall, .fullDuplexCall, .echoMetadata] | ||
| case .statusCodeAndMessage: | ||
| return [.unaryCall, .fullDuplexCall, .echoStatus] | ||
| case .specialStatusMessage: | ||
| return [.unaryCall, .echoStatus] | ||
| case .unimplementedMethod: | ||
| return [] | ||
| case .unimplementedService: | ||
| return [] | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we ever used this in the previous set of interop tests, we can just remove this and the server features.
| @@ -0,0 +1,714 @@ | |||
| import Dispatch | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should come after the license header
| * limitations under the License. | ||
| */ | ||
| import GRPCCore | ||
| import GRPCInProcessTransport |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't think we ever use this
| try await testServiceClient.unaryCall(request: ClientRequest.Single(message: message)) { | ||
| response in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| try await testServiceClient.unaryCall(request: ClientRequest.Single(message: message)) { | |
| response in | |
| try await testServiceClient.unaryCall( | |
| request: ClientRequest.Single(message: message) | |
| ) { response in |
| ) { | ||
| response in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| ) { | |
| response in | |
| ) { response in |
| case .success(_): | ||
| try assertFailure("The result should be an error.") | ||
| case .failure(let error): | ||
| try assertEqual(error.code, RPCError.Code.unimplemented) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| try assertEqual(error.code, RPCError.Code.unimplemented) | |
| try assertEqual(error.code, .unimplemented) |
| ) { | ||
| response in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| ) { | |
| response in | |
| ) { response in |
| case .success(_): | ||
| try assertFailure("The result should be an error.") | ||
| case .failure(let error): | ||
| try assertEqual(error.code, RPCError.Code.unimplemented) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| try assertEqual(error.code, RPCError.Code.unimplemented) | |
| try assertEqual(error.code, .unimplemented) |
glbrntt
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couple of nits but looks good otherwise!
| file: #fileID, | ||
| line: #line |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, no need for this, just add a public init to AssertionFailure to default the fileID and line:
public init(message: String, file: String = #fileID, line: Int = #line) {
// ...
}| for try await id in stream { | ||
| for try await id in ids.stream { | ||
| var message = Grpc_Testing_StreamingOutputCallRequest() | ||
| let sizes = [(31_415, 27_182), (9, 8), (2_653, 1_828), (58_979, 45_904)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should create this array outside of the loop to avoid creating it multiple times
| file: #fileID, | ||
| line: #line |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here re: init
| file: #fileID, | ||
| line: #line |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here re: init
| file: #fileID, | ||
| line: #line |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here re: init
| file: #fileID, | ||
| line: #line |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here re: init
| file: #fileID, | ||
| line: #line |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here re: init
| file: #fileID, | ||
| line: #line |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here re: init
| file: #fileID, | ||
| line: #line |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here re: init
Motivation:
The test cases test certain functionalities of the new GRPC server and client.
Modifications:
Result:
We will be able to implement the main() function that runs the interop tests using in process transport.