Skip to content

Conversation

@stefanadranca
Copy link
Collaborator

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.

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.
@stefanadranca stefanadranca requested a review from glbrntt March 5, 2024 15:55
@stefanadranca stefanadranca requested a review from gjcairo March 5, 2024 15:58
@stefanadranca stefanadranca marked this pull request as ready for review March 6, 2024 10:53
Copy link
Collaborator

@glbrntt glbrntt left a 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,
Copy link
Collaborator

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

Comment on lines 54 to 58
public func assertFailure(
_ message: String = "Failure.",
file: String = #fileID,
line: Int = #line
) throws {
Copy link
Collaborator

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

Comment on lines 99 to 125
/// 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 []
}
}
Copy link
Collaborator

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
Copy link
Collaborator

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
Copy link
Collaborator

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

Comment on lines 643 to 644
try await testServiceClient.unaryCall(request: ClientRequest.Single(message: message)) {
response in
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
try await testServiceClient.unaryCall(request: ClientRequest.Single(message: message)) {
response in
try await testServiceClient.unaryCall(
request: ClientRequest.Single(message: message)
) { response in

Comment on lines 677 to 678
) {
response in
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
) {
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)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
try assertEqual(error.code, RPCError.Code.unimplemented)
try assertEqual(error.code, .unimplemented)

Comment on lines 710 to 711
) {
response in
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
) {
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)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
try assertEqual(error.code, RPCError.Code.unimplemented)
try assertEqual(error.code, .unimplemented)

Copy link
Collaborator

@glbrntt glbrntt left a 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!

Comment on lines 211 to 212
file: #fileID,
line: #line
Copy link
Collaborator

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)]
Copy link
Collaborator

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

Comment on lines 324 to 325
file: #fileID,
line: #line
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here re: init

Comment on lines 487 to 488
file: #fileID,
line: #line
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here re: init

Comment on lines 553 to 554
file: #fileID,
line: #line
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here re: init

Comment on lines 575 to 576
file: #fileID,
line: #line
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here re: init

Comment on lines 628 to 629
file: #fileID,
line: #line
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here re: init

Comment on lines 666 to 667
file: #fileID,
line: #line
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here re: init

Comment on lines 702 to 703
file: #fileID,
line: #line
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here re: init

@stefanadranca stefanadranca requested a review from glbrntt March 6, 2024 17:22
@glbrntt glbrntt merged commit 9f0956e into grpc:main Mar 7, 2024
@glbrntt glbrntt added the version/v2 Relates to v2 label Mar 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

version/v2 Relates to v2

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants