Skip to content

Conversation

@stefanadranca
Copy link
Collaborator

Motivation:

We need unit tests that run the interop tests with the in process transport.

Modifications:

Created a test target and implemented the tests for each interop test, that catch AssertionFailure errors when the interop tests fail.

Result:

We will run the interop tests with the in process transport.

TODO:
The CustomMetadata test fails - I will add the metadata handling in the TestService in a different PR

Motivation:

We need unit tests that run the interop tests with the in process transport.

Modifications:

Created a test target and implemented the tests for each interop test, that catch AssertionFailure
errors when the interop tests fail.

Result:

We will run the interop tests with the in process transport.
@stefanadranca stefanadranca requested a review from glbrntt March 8, 2024 10:53
Package.swift Outdated
]
)

static let interoperabilityUnitTests: Target = .testTarget(
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit, name is a little misleading: these aren't unit tests of the interoperability tests, we're adding the interop tests as unit tests.

I think "InProcessInteroperabilityTests" is a bit clearer.

@available(macOS 13.0, iOS 16.0, watchOS 9.0, tvOS 16.0, *)
struct EmptyUnary: InteroperabilityTest {
func run(client: GRPCClient) async throws {
@Sendable func run(client: GRPCClient) async throws {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Rather than making the function @Sendable we should make InteroperabilityTest be Sendable

import GRPCInProcessTransport
import XCTest

@testable import InteroperabilityTests
Copy link
Collaborator

Choose a reason for hiding this comment

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

Rather than exposing a @testable import we can rely on the InteroperabilityTestCase enum and makeTest.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We also need to import TestService from the InteroperabilityTests which is internal - should I make it public? or should I add a public enum for it as well?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Hmm, no @testable is fine. But do make the switch to use makeTest.

let emptyUnaryTestCase = EmptyUnary()
do {
try await runInProcessTransport(interopTest: emptyUnaryTestCase.run)
} catch let error as AssertionFailure {
Copy link
Collaborator

Choose a reason for hiding this comment

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

We can push this logic into runInProcessTransport(interopTest:) and avoid repeating ourselves.

@stefanadranca stefanadranca requested a review from glbrntt March 8, 2024 15:20
Comment on lines 56 to 57
let emptyUnaryTestCase = InteroperabilityTestCase.emptyUnary.makeTest()
try await runInProcessTransport(interopTest: emptyUnaryTestCase.run)
Copy link
Collaborator

Choose a reason for hiding this comment

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

We can simplify this yet further by change the param to runInProcessTransport to be InteroperabilityTestCase and calling makeTest and run in there.

Comment on lines 56 to 57
let emptyUnaryTestCase = InteroperabilityTestCase.emptyUnary.makeTest()
try await runInProcessTransport(interopTest: emptyUnaryTestCase.run)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Also: use explicit self (and in all the other tests)

@stefanadranca stefanadranca marked this pull request as ready for review March 11, 2024 14:18
@stefanadranca stefanadranca requested a review from glbrntt March 11, 2024 14:18
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, looks good otherwise though


@available(macOS 13.0, iOS 16.0, watchOS 9.0, tvOS 16.0, *)
public protocol InteroperabilityTest {
public protocol InteroperabilityTest: Sendable {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Now that the tests have been refactored to construct the interop test in place this isn't a requirement anymore.

}

func testEmtyUnary() async throws {
try await self.runInProcessTransport(interopTestCase: InteroperabilityTestCase.emptyUnary)
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: prefer using type inference here

Suggested change
try await self.runInProcessTransport(interopTestCase: InteroperabilityTestCase.emptyUnary)
try await self.runInProcessTransport(interopTestCase: .emptyUnary)

@glbrntt glbrntt added the version/v2 Relates to v2 label Mar 11, 2024
@stefanadranca stefanadranca requested a review from glbrntt March 11, 2024 14:48
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.

LGTM!

@glbrntt glbrntt enabled auto-merge (squash) March 11, 2024 16:00
@glbrntt glbrntt merged commit 108a0b9 into grpc:main Mar 11, 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