From eb277071b3f49fe78105b915a274b2f4606fa886 Mon Sep 17 00:00:00 2001 From: Tsavo Knott Date: Thu, 14 Mar 2024 20:57:23 -0400 Subject: [PATCH 1/9] Bring all dep paths local for melos deps override --- example/googleapis/googleapis.iml | 16 ++++++++++++++++ example/googleapis/pubspec_overrides.yaml | 4 ++++ example/grpc-web/grpc_web.iml | 16 ++++++++++++++++ example/grpc-web/pubspec_overrides.yaml | 4 ++++ example/helloworld/helloworld.iml | 16 ++++++++++++++++ example/helloworld/pubspec_overrides.yaml | 4 ++++ example/metadata/metadata.iml | 16 ++++++++++++++++ example/metadata/pubspec_overrides.yaml | 4 ++++ example/route_guide/pubspec_overrides.yaml | 4 ++++ example/route_guide/route_guide.iml | 16 ++++++++++++++++ grpc.iml | 16 ++++++++++++++++ interop/interop.iml | 16 ++++++++++++++++ interop/pubspec_overrides.yaml | 4 ++++ 13 files changed, 136 insertions(+) create mode 100644 example/googleapis/googleapis.iml create mode 100644 example/googleapis/pubspec_overrides.yaml create mode 100644 example/grpc-web/grpc_web.iml create mode 100644 example/grpc-web/pubspec_overrides.yaml create mode 100644 example/helloworld/helloworld.iml create mode 100644 example/helloworld/pubspec_overrides.yaml create mode 100644 example/metadata/metadata.iml create mode 100644 example/metadata/pubspec_overrides.yaml create mode 100644 example/route_guide/pubspec_overrides.yaml create mode 100644 example/route_guide/route_guide.iml create mode 100644 grpc.iml create mode 100644 interop/interop.iml create mode 100644 interop/pubspec_overrides.yaml diff --git a/example/googleapis/googleapis.iml b/example/googleapis/googleapis.iml new file mode 100644 index 00000000..389d07a1 --- /dev/null +++ b/example/googleapis/googleapis.iml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/example/googleapis/pubspec_overrides.yaml b/example/googleapis/pubspec_overrides.yaml new file mode 100644 index 00000000..c6917691 --- /dev/null +++ b/example/googleapis/pubspec_overrides.yaml @@ -0,0 +1,4 @@ +# melos_managed_dependency_overrides: grpc +dependency_overrides: + grpc: + path: ../.. diff --git a/example/grpc-web/grpc_web.iml b/example/grpc-web/grpc_web.iml new file mode 100644 index 00000000..389d07a1 --- /dev/null +++ b/example/grpc-web/grpc_web.iml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/example/grpc-web/pubspec_overrides.yaml b/example/grpc-web/pubspec_overrides.yaml new file mode 100644 index 00000000..c6917691 --- /dev/null +++ b/example/grpc-web/pubspec_overrides.yaml @@ -0,0 +1,4 @@ +# melos_managed_dependency_overrides: grpc +dependency_overrides: + grpc: + path: ../.. diff --git a/example/helloworld/helloworld.iml b/example/helloworld/helloworld.iml new file mode 100644 index 00000000..389d07a1 --- /dev/null +++ b/example/helloworld/helloworld.iml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/example/helloworld/pubspec_overrides.yaml b/example/helloworld/pubspec_overrides.yaml new file mode 100644 index 00000000..c6917691 --- /dev/null +++ b/example/helloworld/pubspec_overrides.yaml @@ -0,0 +1,4 @@ +# melos_managed_dependency_overrides: grpc +dependency_overrides: + grpc: + path: ../.. diff --git a/example/metadata/metadata.iml b/example/metadata/metadata.iml new file mode 100644 index 00000000..389d07a1 --- /dev/null +++ b/example/metadata/metadata.iml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/example/metadata/pubspec_overrides.yaml b/example/metadata/pubspec_overrides.yaml new file mode 100644 index 00000000..c6917691 --- /dev/null +++ b/example/metadata/pubspec_overrides.yaml @@ -0,0 +1,4 @@ +# melos_managed_dependency_overrides: grpc +dependency_overrides: + grpc: + path: ../.. diff --git a/example/route_guide/pubspec_overrides.yaml b/example/route_guide/pubspec_overrides.yaml new file mode 100644 index 00000000..c6917691 --- /dev/null +++ b/example/route_guide/pubspec_overrides.yaml @@ -0,0 +1,4 @@ +# melos_managed_dependency_overrides: grpc +dependency_overrides: + grpc: + path: ../.. diff --git a/example/route_guide/route_guide.iml b/example/route_guide/route_guide.iml new file mode 100644 index 00000000..389d07a1 --- /dev/null +++ b/example/route_guide/route_guide.iml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/grpc.iml b/grpc.iml new file mode 100644 index 00000000..389d07a1 --- /dev/null +++ b/grpc.iml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/interop/interop.iml b/interop/interop.iml new file mode 100644 index 00000000..389d07a1 --- /dev/null +++ b/interop/interop.iml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/interop/pubspec_overrides.yaml b/interop/pubspec_overrides.yaml new file mode 100644 index 00000000..917447a4 --- /dev/null +++ b/interop/pubspec_overrides.yaml @@ -0,0 +1,4 @@ +# melos_managed_dependency_overrides: grpc +dependency_overrides: + grpc: + path: .. From 17b4f2a5afd50d73e073e242c3b1ac2ef6a0ebf9 Mon Sep 17 00:00:00 2001 From: Tsavo Knott Date: Thu, 14 Mar 2024 21:30:09 -0400 Subject: [PATCH 2/9] Melos Yaml is looking G2G --- grpc.iml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/grpc.iml b/grpc.iml index 389d07a1..74e5a876 100644 --- a/grpc.iml +++ b/grpc.iml @@ -8,6 +8,8 @@ + + From b6e103f46a9bab10b9ff21502af4e391c1e6e851 Mon Sep 17 00:00:00 2001 From: Tsavo Knott Date: Tue, 19 Mar 2024 12:44:10 -0400 Subject: [PATCH 3/9] External Dependencies --- .../client_keepalive_manager_test.mocks.dart | 7 ++++--- test/src/client_utils.mocks.dart | 21 ++++++++++++++++--- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/test/client_tests/client_keepalive_manager_test.mocks.dart b/test/client_tests/client_keepalive_manager_test.mocks.dart index 941de6a6..f03f3cb6 100644 --- a/test/client_tests/client_keepalive_manager_test.mocks.dart +++ b/test/client_tests/client_keepalive_manager_test.mocks.dart @@ -1,9 +1,7 @@ -// Mocks generated by Mockito 5.4.1 from annotations +// Mocks generated by Mockito 5.4.4 from annotations // in grpc/test/client_tests/client_keepalive_manager_test.dart. // Do not manually edit this file. -// @dart=2.19 - // ignore_for_file: no_leading_underscores_for_library_prefixes import 'package:mockito/mockito.dart' as _i1; @@ -13,6 +11,8 @@ import 'client_keepalive_manager_test.dart' as _i2; // ignore_for_file: avoid_redundant_argument_values // ignore_for_file: avoid_setters_without_getters // ignore_for_file: comment_references +// ignore_for_file: deprecated_member_use +// ignore_for_file: deprecated_member_use_from_same_package // ignore_for_file: implementation_imports // ignore_for_file: invalid_use_of_visible_for_testing_member // ignore_for_file: prefer_const_constructors @@ -32,6 +32,7 @@ class MockPinger extends _i1.Mock implements _i2.Pinger { ), returnValueForMissingStub: null, ); + @override void onPingTimeout() => super.noSuchMethod( Invocation.method( diff --git a/test/src/client_utils.mocks.dart b/test/src/client_utils.mocks.dart index 98702df4..8da129c0 100644 --- a/test/src/client_utils.mocks.dart +++ b/test/src/client_utils.mocks.dart @@ -1,9 +1,7 @@ -// Mocks generated by Mockito 5.4.1 from annotations +// Mocks generated by Mockito 5.4.4 from annotations // in grpc/test/src/client_utils.dart. // Do not manually edit this file. -// @dart=2.19 - // ignore_for_file: no_leading_underscores_for_library_prefixes import 'dart:async' as _i3; @@ -15,6 +13,8 @@ import 'package:mockito/mockito.dart' as _i1; // ignore_for_file: avoid_redundant_argument_values // ignore_for_file: avoid_setters_without_getters // ignore_for_file: comment_references +// ignore_for_file: deprecated_member_use +// ignore_for_file: deprecated_member_use_from_same_package // ignore_for_file: implementation_imports // ignore_for_file: invalid_use_of_visible_for_testing_member // ignore_for_file: prefer_const_constructors @@ -57,6 +57,7 @@ class MockClientTransportConnection extends _i1.Mock Invocation.getter(#isOpen), returnValue: false, ) as bool); + @override set onActiveStateChanged(_i2.ActiveStateHandler? callback) => super.noSuchMethod( @@ -66,21 +67,25 @@ class MockClientTransportConnection extends _i1.Mock ), returnValueForMissingStub: null, ); + @override _i3.Future get onInitialPeerSettingsReceived => (super.noSuchMethod( Invocation.getter(#onInitialPeerSettingsReceived), returnValue: _i3.Future.value(), ) as _i3.Future); + @override _i3.Stream get onPingReceived => (super.noSuchMethod( Invocation.getter(#onPingReceived), returnValue: _i3.Stream.empty(), ) as _i3.Stream); + @override _i3.Stream get onFrameReceived => (super.noSuchMethod( Invocation.getter(#onFrameReceived), returnValue: _i3.Stream.empty(), ) as _i3.Stream); + @override _i2.ClientTransportStream makeRequest( List<_i4.Header>? headers, { @@ -101,6 +106,7 @@ class MockClientTransportConnection extends _i1.Mock ), ), ) as _i2.ClientTransportStream); + @override _i3.Future ping() => (super.noSuchMethod( Invocation.method( @@ -109,6 +115,7 @@ class MockClientTransportConnection extends _i1.Mock ), returnValue: _i3.Future.value(), ) as _i3.Future); + @override _i3.Future finish() => (super.noSuchMethod( Invocation.method( @@ -117,6 +124,7 @@ class MockClientTransportConnection extends _i1.Mock ), returnValue: _i3.Future.value(), ) as _i3.Future); + @override _i3.Future terminate([int? errorCode]) => (super.noSuchMethod( Invocation.method( @@ -141,16 +149,19 @@ class MockClientTransportStream extends _i1.Mock Invocation.getter(#peerPushes), returnValue: _i3.Stream<_i2.TransportStreamPush>.empty(), ) as _i3.Stream<_i2.TransportStreamPush>); + @override int get id => (super.noSuchMethod( Invocation.getter(#id), returnValue: 0, ) as int); + @override _i3.Stream<_i2.StreamMessage> get incomingMessages => (super.noSuchMethod( Invocation.getter(#incomingMessages), returnValue: _i3.Stream<_i2.StreamMessage>.empty(), ) as _i3.Stream<_i2.StreamMessage>); + @override _i3.StreamSink<_i2.StreamMessage> get outgoingMessages => (super.noSuchMethod( Invocation.getter(#outgoingMessages), @@ -159,6 +170,7 @@ class MockClientTransportStream extends _i1.Mock Invocation.getter(#outgoingMessages), ), ) as _i3.StreamSink<_i2.StreamMessage>); + @override set onTerminated(void Function(int?)? value) => super.noSuchMethod( Invocation.setter( @@ -167,6 +179,7 @@ class MockClientTransportStream extends _i1.Mock ), returnValueForMissingStub: null, ); + @override void terminate() => super.noSuchMethod( Invocation.method( @@ -175,6 +188,7 @@ class MockClientTransportStream extends _i1.Mock ), returnValueForMissingStub: null, ); + @override void sendHeaders( List<_i4.Header>? headers, { @@ -188,6 +202,7 @@ class MockClientTransportStream extends _i1.Mock ), returnValueForMissingStub: null, ); + @override void sendData( List? bytes, { From a04061bff1afc08045aaf6c45bd89a4f0e22246f Mon Sep 17 00:00:00 2001 From: Tsavo Knott Date: Tue, 26 Mar 2024 22:13:39 -0400 Subject: [PATCH 4/9] feat: Initial testing & debugging of _UnixNamedLock --- test/connection_server_test.dart | 62 +++++++++++--------------------- test/server_test.dart | 62 +++++++++++--------------------- 2 files changed, 42 insertions(+), 82 deletions(-) diff --git a/test/connection_server_test.dart b/test/connection_server_test.dart index 16969c15..1ef1e4f7 100644 --- a/test/connection_server_test.dart +++ b/test/connection_server_test.dart @@ -110,16 +110,14 @@ void main() { test('Server returns error on unimplemented path', () async { harness - ..expectErrorResponse( - StatusCode.unimplemented, 'Path /Test/NotFound not found') + ..expectErrorResponse(StatusCode.unimplemented, 'Path /Test/NotFound not found') ..sendRequestHeader('/Test/NotFound'); await harness.fromServer.done; }); /// Returns a service method handler that verifies that awaiting the request /// throws a specific error. - Future Function(ServiceCall call, Future request) expectError( - expectedError) { + Future Function(ServiceCall call, Future request) expectError(expectedError) { return expectAsync2((ServiceCall call, Future request) async { try { final result = await request; @@ -138,8 +136,7 @@ void main() { /// Returns a service method handler that verifies that awaiting the request /// stream throws a specific error. - Stream Function(ServiceCall call, Stream request) - expectErrorStreaming(expectedError) { + Stream Function(ServiceCall call, Stream request) expectErrorStreaming(expectedError) { return (ServiceCall call, Stream request) async* { try { await for (var entry in request) { @@ -159,19 +156,16 @@ void main() { test('Server returns error on missing request for unary call', () async { harness - ..service.unaryHandler = - expectError(GrpcError.unimplemented('No request received')) + ..service.unaryHandler = expectError(GrpcError.unimplemented('No request received')) ..expectErrorResponse(StatusCode.unimplemented, 'No request received') ..sendRequestHeader('/Test/Unary') ..toServer.close(); await harness.fromServer.done; }); - test('Server returns error if multiple headers are received for unary call', - () async { + test('Server returns error if multiple headers are received for unary call', () async { harness - ..service.unaryHandler = - expectError(GrpcError.unimplemented('Expected request')) + ..service.unaryHandler = expectError(GrpcError.unimplemented('Expected request')) ..expectErrorResponse(StatusCode.unimplemented, 'Expected request') ..sendRequestHeader('/Test/Unary') ..toServer.add(HeadersStreamMessage([])) @@ -181,8 +175,7 @@ void main() { test('Server returns error on too many requests for unary call', () async { harness - ..service.unaryHandler = - expectError(GrpcError.unimplemented('Too many requests')) + ..service.unaryHandler = expectError(GrpcError.unimplemented('Too many requests')) ..expectErrorResponse(StatusCode.unimplemented, 'Too many requests') ..sendRequestHeader('/Test/Unary') ..sendData(dummyValue) @@ -193,10 +186,8 @@ void main() { test('Server returns request deserialization errors', () async { harness - ..service.bidirectionalHandler = expectErrorStreaming( - GrpcError.internal('Error deserializing request: Failed')) - ..expectErrorResponse( - StatusCode.internal, 'Error deserializing request: Failed') + ..service.bidirectionalHandler = expectErrorStreaming(GrpcError.internal('Error deserializing request: Failed')) + ..expectErrorResponse(StatusCode.internal, 'Error deserializing request: Failed') ..sendRequestHeader('/Test/RequestError') ..sendData(dummyValue) ..toServer.close(); @@ -205,10 +196,8 @@ void main() { test('Server returns response serialization errors', () async { harness - ..service.bidirectionalHandler = expectErrorStreaming( - GrpcError.internal('Error sending response: Failed')) - ..expectErrorResponse( - StatusCode.internal, 'Error sending response: Failed') + ..service.bidirectionalHandler = expectErrorStreaming(GrpcError.internal('Error sending response: Failed')) + ..expectErrorResponse(StatusCode.internal, 'Error sending response: Failed') ..sendRequestHeader('/Test/ResponseError') ..sendData(dummyValue) ..sendData(dummyValue) @@ -269,12 +258,9 @@ void main() { await harness.fromServer.done; }); - test( - 'Server returns error if request stream is closed before sending anything', - () async { + test('Server returns error if request stream is closed before sending anything', () async { harness - ..expectErrorResponse( - StatusCode.unavailable, 'Request stream closed unexpectedly') + ..expectErrorResponse(StatusCode.unavailable, 'Request stream closed unexpectedly') ..toServer.close(); await harness.fromServer.done; }); @@ -289,7 +275,7 @@ void main() { } GrpcError? interceptor(call, method) { - if (method.name == 'Unary') { + if (method.identifier == 'Unary') { return null; } return GrpcError.unauthenticated('Request is unauthenticated'); @@ -305,13 +291,12 @@ void main() { } test('with sync interceptor', () => doTest(interceptor)); - test('with async interceptor', - () => doTest((call, method) async => interceptor(call, method))); + test('with async interceptor', () => doTest((call, method) async => interceptor(call, method))); }); group('returns error if interceptor blocks request', () { GrpcError? interceptor(call, method) { - if (method.name == 'Unary') { + if (method.identifier == 'Unary') { return GrpcError.unauthenticated('Request is unauthenticated'); } return null; @@ -320,16 +305,14 @@ void main() { Future doTest(Interceptor handler) async { harness ..interceptor.handler = handler - ..expectErrorResponse( - StatusCode.unauthenticated, 'Request is unauthenticated') + ..expectErrorResponse(StatusCode.unauthenticated, 'Request is unauthenticated') ..sendRequestHeader('/Test/Unary'); await harness.fromServer.done; } test('with sync interceptor', () => doTest(interceptor)); - test('with async interceptor', - () => doTest((call, method) async => interceptor(call, method))); + test('with async interceptor', () => doTest((call, method) async => interceptor(call, method))); }); group('returns internal error if interceptor throws exception', () { @@ -340,16 +323,14 @@ void main() { Future doTest(Interceptor handler) async { harness ..interceptor.handler = handler - ..expectErrorResponse( - StatusCode.internal, 'Exception: Reason is unknown') + ..expectErrorResponse(StatusCode.internal, 'Exception: Reason is unknown') ..sendRequestHeader('/Test/Unary'); await harness.fromServer.done; } test('with sync interceptor', () => doTest(interceptor)); - test('with async interceptor', - () => doTest((call, method) async => interceptor(call, method))); + test('with async interceptor', () => doTest((call, method) async => interceptor(call, method))); }); test("don't fail if interceptor await 2 times", () async { @@ -361,8 +342,7 @@ void main() { harness ..interceptor.handler = interceptor - ..expectErrorResponse( - StatusCode.internal, 'Exception: Reason is unknown') + ..expectErrorResponse(StatusCode.internal, 'Exception: Reason is unknown') ..sendRequestHeader('/Test/Unary') ..sendData(1); diff --git a/test/server_test.dart b/test/server_test.dart index 63a957c0..837e9fb2 100644 --- a/test/server_test.dart +++ b/test/server_test.dart @@ -110,16 +110,14 @@ void main() { test('Server returns error on unimplemented path', () async { harness - ..expectErrorResponse( - StatusCode.unimplemented, 'Path /Test/NotFound not found') + ..expectErrorResponse(StatusCode.unimplemented, 'Path /Test/NotFound not found') ..sendRequestHeader('/Test/NotFound'); await harness.fromServer.done; }); /// Returns a service method handler that verifies that awaiting the request /// throws a specific error. - Future Function(ServiceCall call, Future request) expectError( - expectedError) { + Future Function(ServiceCall call, Future request) expectError(expectedError) { return expectAsync2((ServiceCall call, Future request) async { try { final result = await request; @@ -138,8 +136,7 @@ void main() { /// Returns a service method handler that verifies that awaiting the request /// stream throws a specific error. - Stream Function(ServiceCall call, Stream request) - expectErrorStreaming(expectedError) { + Stream Function(ServiceCall call, Stream request) expectErrorStreaming(expectedError) { return (ServiceCall call, Stream request) async* { try { await for (var entry in request) { @@ -159,8 +156,7 @@ void main() { test('Server returns error on missing request for unary call', () async { harness - ..service.unaryHandler = - expectError(GrpcError.unimplemented('No request received')) + ..service.unaryHandler = expectError(GrpcError.unimplemented('No request received')) ..expectErrorResponse(StatusCode.unimplemented, 'No request received') ..sendRequestHeader('/Test/Unary') ..toServer.close(); @@ -181,11 +177,9 @@ void main() { await harness.fromServer.done; }); - test('Server returns error if multiple headers are received for unary call', - () async { + test('Server returns error if multiple headers are received for unary call', () async { harness - ..service.unaryHandler = - expectError(GrpcError.unimplemented('Expected request')) + ..service.unaryHandler = expectError(GrpcError.unimplemented('Expected request')) ..expectErrorResponse(StatusCode.unimplemented, 'Expected request') ..sendRequestHeader('/Test/Unary') ..toServer.add(HeadersStreamMessage([])) @@ -195,8 +189,7 @@ void main() { test('Server returns error on too many requests for unary call', () async { harness - ..service.unaryHandler = - expectError(GrpcError.unimplemented('Too many requests')) + ..service.unaryHandler = expectError(GrpcError.unimplemented('Too many requests')) ..expectErrorResponse(StatusCode.unimplemented, 'Too many requests') ..sendRequestHeader('/Test/Unary') ..sendData(dummyValue) @@ -207,10 +200,8 @@ void main() { test('Server returns request deserialization errors', () async { harness - ..service.bidirectionalHandler = expectErrorStreaming( - GrpcError.internal('Error deserializing request: Failed')) - ..expectErrorResponse( - StatusCode.internal, 'Error deserializing request: Failed') + ..service.bidirectionalHandler = expectErrorStreaming(GrpcError.internal('Error deserializing request: Failed')) + ..expectErrorResponse(StatusCode.internal, 'Error deserializing request: Failed') ..sendRequestHeader('/Test/RequestError') ..sendData(dummyValue) ..toServer.close(); @@ -219,10 +210,8 @@ void main() { test('Server returns response serialization errors', () async { harness - ..service.bidirectionalHandler = expectErrorStreaming( - GrpcError.internal('Error sending response: Failed')) - ..expectErrorResponse( - StatusCode.internal, 'Error sending response: Failed') + ..service.bidirectionalHandler = expectErrorStreaming(GrpcError.internal('Error sending response: Failed')) + ..expectErrorResponse(StatusCode.internal, 'Error sending response: Failed') ..sendRequestHeader('/Test/ResponseError') ..sendData(dummyValue) ..sendData(dummyValue) @@ -283,12 +272,9 @@ void main() { await harness.fromServer.done; }); - test( - 'Server returns error if request stream is closed before sending anything', - () async { + test('Server returns error if request stream is closed before sending anything', () async { harness - ..expectErrorResponse( - StatusCode.unavailable, 'Request stream closed unexpectedly') + ..expectErrorResponse(StatusCode.unavailable, 'Request stream closed unexpectedly') ..toServer.close(); await harness.fromServer.done; }); @@ -303,7 +289,7 @@ void main() { } GrpcError? interceptor(call, method) { - if (method.name == 'Unary') { + if (method.identifier == 'Unary') { return null; } return GrpcError.unauthenticated('Request is unauthenticated'); @@ -319,13 +305,12 @@ void main() { } test('with sync interceptor', () => doTest(interceptor)); - test('with async interceptor', - () => doTest((call, method) async => interceptor(call, method))); + test('with async interceptor', () => doTest((call, method) async => interceptor(call, method))); }); group('returns error if interceptor blocks request', () { GrpcError? interceptor(call, method) { - if (method.name == 'Unary') { + if (method.identifier == 'Unary') { return GrpcError.unauthenticated('Request is unauthenticated'); } return null; @@ -334,16 +319,14 @@ void main() { Future doTest(Interceptor handler) async { harness ..interceptor.handler = handler - ..expectErrorResponse( - StatusCode.unauthenticated, 'Request is unauthenticated') + ..expectErrorResponse(StatusCode.unauthenticated, 'Request is unauthenticated') ..sendRequestHeader('/Test/Unary'); await harness.fromServer.done; } test('with sync interceptor', () => doTest(interceptor)); - test('with async interceptor', - () => doTest((call, method) async => interceptor(call, method))); + test('with async interceptor', () => doTest((call, method) async => interceptor(call, method))); }); group('returns internal error if interceptor throws exception', () { @@ -354,16 +337,14 @@ void main() { Future doTest(Interceptor handler) async { harness ..interceptor.handler = handler - ..expectErrorResponse( - StatusCode.internal, 'Exception: Reason is unknown') + ..expectErrorResponse(StatusCode.internal, 'Exception: Reason is unknown') ..sendRequestHeader('/Test/Unary'); await harness.fromServer.done; } test('with sync interceptor', () => doTest(interceptor)); - test('with async interceptor', - () => doTest((call, method) async => interceptor(call, method))); + test('with async interceptor', () => doTest((call, method) async => interceptor(call, method))); }); test("don't fail if interceptor await 2 times", () async { @@ -375,8 +356,7 @@ void main() { harness ..interceptor.handler = interceptor - ..expectErrorResponse( - StatusCode.internal, 'Exception: Reason is unknown') + ..expectErrorResponse(StatusCode.internal, 'Exception: Reason is unknown') ..sendRequestHeader('/Test/Unary') ..sendData(1); From 33381e04e96723995cf7781b02db0b9f358d8c73 Mon Sep 17 00:00:00 2001 From: Tsavo Knott Date: Thu, 11 Apr 2024 18:16:41 -0400 Subject: [PATCH 5/9] Update Deps --- interop/bin/client.dart | 24 ++++++++---------------- interop/pubspec.yaml | 12 ++++++------ pubspec.yaml | 30 ++++++++++++++---------------- 3 files changed, 28 insertions(+), 38 deletions(-) diff --git a/interop/bin/client.dart b/interop/bin/client.dart index e713adb9..9e891d26 100644 --- a/interop/bin/client.dart +++ b/interop/bin/client.dart @@ -68,19 +68,14 @@ Future main(List args) async { help: 'The server host to claim to be connecting to, for use in TLS and ' 'HTTP/2 :authority header. If unspecified, the value of ' '--server_host will be used.'); - argumentParser.addOption(_serverPortArgument, - help: 'The server port to connect to. For example, "8080".'); + argumentParser.addOption(_serverPortArgument, help: 'The server port to connect to. For example, "8080".'); argumentParser.addOption(_testCaseArgument, - help: - 'The name of the test case to execute. For example, "empty_unary".'); + help: 'The name of the test case to execute. For example, "empty_unary".'); argumentParser.addOption(_useTLSArgument, - defaultsTo: 'false', - help: 'Whether to use a plaintext or encrypted connection.'); + defaultsTo: 'false', help: 'Whether to use a plaintext or encrypted connection.'); argumentParser.addOption(_useTestCAArgument, - defaultsTo: 'false', - help: 'Whether to replace platform root CAs with ca.pem as the CA root.'); - argumentParser.addOption(_defaultServiceAccountArgument, - help: 'Email of the GCE default service account.'); + defaultsTo: 'false', help: 'Whether to replace platform root CAs with ca.pem as the CA root.'); + argumentParser.addOption(_defaultServiceAccountArgument, help: 'Email of the GCE default service account.'); argumentParser.addOption(_oauthScopeArgument, help: 'OAuth scope. For example, ' '"https://www.googleapis.com/auth/xapi.zoo".'); @@ -92,14 +87,11 @@ Future main(List args) async { late Tester testClient; try { testClient = Tester( - serverHost: arguments[_serverHostArgument] ?? - (throw 'Must specify --$_serverHostArgument'), + serverHost: arguments[_serverHostArgument] ?? (throw 'Must specify --$_serverHostArgument'), serverHostOverride: arguments[_serverHostOverrideArgument], - serverPort: int.tryParse(arguments[_serverPortArgument] ?? - (throw 'Must specify --$_serverPortArgument')) ?? + serverPort: int.tryParse(arguments[_serverPortArgument] ?? (throw 'Must specify --$_serverPortArgument')) ?? (throw 'Invalid port "${arguments[_serverPortArgument]}"'), - testCase: arguments[_testCaseArgument] ?? - (throw 'Must specify --$_testCaseArgument'), + testCase: arguments[_testCaseArgument] ?? (throw 'Must specify --$_testCaseArgument'), useTls: arguments[_useTLSArgument] == 'true', useTestCA: arguments[_useTestCAArgument] == 'true', defaultServiceAccount: arguments[_defaultServiceAccountArgument], diff --git a/interop/pubspec.yaml b/interop/pubspec.yaml index f4038fae..40b946a4 100644 --- a/interop/pubspec.yaml +++ b/interop/pubspec.yaml @@ -3,15 +3,15 @@ description: Dart gRPC interoperability test suite. publish_to: none environment: - sdk: ^3.0.0 + sdk: '>=3.0.0 <4.0.0' dependencies: - args: ^2.0.0 - async: ^2.2.0 - collection: ^1.14.11 + args: ^2.5.0 + async: ^2.11.0 + collection: ^1.18.0 grpc: path: ../ - protobuf: ^3.0.0 + protobuf: ^3.1.0 dev_dependencies: - test: ^1.16.0 + test: ^1.25.3 diff --git a/pubspec.yaml b/pubspec.yaml index a01ce0ec..1f3949c7 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -4,30 +4,28 @@ version: 3.2.4 repository: https://github.com/grpc/grpc-dart -environment: - sdk: ^3.0.0 dependencies: - archive: ^3.0.0 - async: ^2.5.0 - crypto: ^3.0.0 - fixnum: ^1.0.0 - googleapis_auth: ^1.1.0 - meta: ^1.3.0 + archive: ^3.4.10 + async: ^2.11.0 + crypto: ^3.0.3 + fixnum: ^1.1.0 + googleapis_auth: ^1.6.0 + meta: ^1.14.0 http: '>=0.13.0 <2.0.0' - http2: ^2.2.0 + http2: ^2.3.0 protobuf: '>=2.0.0 <4.0.0' clock: ^1.1.1 dev_dependencies: - build_runner: ^2.0.0 - build_test: ^2.0.0 + build_runner: ^2.4.9 + build_test: ^2.2.2 lints: ">=2.0.0 <4.0.0" - mockito: ^5.0.0 - path: ^1.8.0 - test: ^1.16.0 - stream_channel: ^2.1.0 - stream_transform: ^2.0.0 + mockito: ^5.4.4 + path: ^1.9.0 + test: ^1.25.3 + stream_channel: ^2.1.2 + stream_transform: ^2.1.0 vm_service: ">=11.6.0 <15.0.0" fake_async: ^1.3.1 From a2981c4f1dc76a5cd259b9d6760e62a8fa38ce3e Mon Sep 17 00:00:00 2001 From: Tsavo Knott Date: Thu, 11 Apr 2024 18:35:44 -0400 Subject: [PATCH 6/9] Add Dart Constraint --- pubspec.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pubspec.yaml b/pubspec.yaml index 1f3949c7..0cf3d47f 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -3,7 +3,8 @@ description: Dart implementation of gRPC, a high performance, open-source univer version: 3.2.4 repository: https://github.com/grpc/grpc-dart - +environment: + sdk: '>=3.0.0 <4.0.0' dependencies: archive: ^3.4.10 From 25ea43a4358a382f736b90b1c4abb7ec92c63d7f Mon Sep 17 00:00:00 2001 From: Tsavo Knott Date: Fri, 12 Apr 2024 14:42:22 -0400 Subject: [PATCH 7/9] Update Deps & Refactor --- interop/bin/client.dart | 24 ++++++++----- test/connection_server_test.dart | 58 +++++++++++++++++++++----------- test/server_test.dart | 58 +++++++++++++++++++++----------- 3 files changed, 94 insertions(+), 46 deletions(-) diff --git a/interop/bin/client.dart b/interop/bin/client.dart index 9e891d26..e713adb9 100644 --- a/interop/bin/client.dart +++ b/interop/bin/client.dart @@ -68,14 +68,19 @@ Future main(List args) async { help: 'The server host to claim to be connecting to, for use in TLS and ' 'HTTP/2 :authority header. If unspecified, the value of ' '--server_host will be used.'); - argumentParser.addOption(_serverPortArgument, help: 'The server port to connect to. For example, "8080".'); + argumentParser.addOption(_serverPortArgument, + help: 'The server port to connect to. For example, "8080".'); argumentParser.addOption(_testCaseArgument, - help: 'The name of the test case to execute. For example, "empty_unary".'); + help: + 'The name of the test case to execute. For example, "empty_unary".'); argumentParser.addOption(_useTLSArgument, - defaultsTo: 'false', help: 'Whether to use a plaintext or encrypted connection.'); + defaultsTo: 'false', + help: 'Whether to use a plaintext or encrypted connection.'); argumentParser.addOption(_useTestCAArgument, - defaultsTo: 'false', help: 'Whether to replace platform root CAs with ca.pem as the CA root.'); - argumentParser.addOption(_defaultServiceAccountArgument, help: 'Email of the GCE default service account.'); + defaultsTo: 'false', + help: 'Whether to replace platform root CAs with ca.pem as the CA root.'); + argumentParser.addOption(_defaultServiceAccountArgument, + help: 'Email of the GCE default service account.'); argumentParser.addOption(_oauthScopeArgument, help: 'OAuth scope. For example, ' '"https://www.googleapis.com/auth/xapi.zoo".'); @@ -87,11 +92,14 @@ Future main(List args) async { late Tester testClient; try { testClient = Tester( - serverHost: arguments[_serverHostArgument] ?? (throw 'Must specify --$_serverHostArgument'), + serverHost: arguments[_serverHostArgument] ?? + (throw 'Must specify --$_serverHostArgument'), serverHostOverride: arguments[_serverHostOverrideArgument], - serverPort: int.tryParse(arguments[_serverPortArgument] ?? (throw 'Must specify --$_serverPortArgument')) ?? + serverPort: int.tryParse(arguments[_serverPortArgument] ?? + (throw 'Must specify --$_serverPortArgument')) ?? (throw 'Invalid port "${arguments[_serverPortArgument]}"'), - testCase: arguments[_testCaseArgument] ?? (throw 'Must specify --$_testCaseArgument'), + testCase: arguments[_testCaseArgument] ?? + (throw 'Must specify --$_testCaseArgument'), useTls: arguments[_useTLSArgument] == 'true', useTestCA: arguments[_useTestCAArgument] == 'true', defaultServiceAccount: arguments[_defaultServiceAccountArgument], diff --git a/test/connection_server_test.dart b/test/connection_server_test.dart index 1ef1e4f7..4ced9bf9 100644 --- a/test/connection_server_test.dart +++ b/test/connection_server_test.dart @@ -110,14 +110,16 @@ void main() { test('Server returns error on unimplemented path', () async { harness - ..expectErrorResponse(StatusCode.unimplemented, 'Path /Test/NotFound not found') + ..expectErrorResponse( + StatusCode.unimplemented, 'Path /Test/NotFound not found') ..sendRequestHeader('/Test/NotFound'); await harness.fromServer.done; }); /// Returns a service method handler that verifies that awaiting the request /// throws a specific error. - Future Function(ServiceCall call, Future request) expectError(expectedError) { + Future Function(ServiceCall call, Future request) expectError( + expectedError) { return expectAsync2((ServiceCall call, Future request) async { try { final result = await request; @@ -136,7 +138,8 @@ void main() { /// Returns a service method handler that verifies that awaiting the request /// stream throws a specific error. - Stream Function(ServiceCall call, Stream request) expectErrorStreaming(expectedError) { + Stream Function(ServiceCall call, Stream request) + expectErrorStreaming(expectedError) { return (ServiceCall call, Stream request) async* { try { await for (var entry in request) { @@ -156,16 +159,19 @@ void main() { test('Server returns error on missing request for unary call', () async { harness - ..service.unaryHandler = expectError(GrpcError.unimplemented('No request received')) + ..service.unaryHandler = + expectError(GrpcError.unimplemented('No request received')) ..expectErrorResponse(StatusCode.unimplemented, 'No request received') ..sendRequestHeader('/Test/Unary') ..toServer.close(); await harness.fromServer.done; }); - test('Server returns error if multiple headers are received for unary call', () async { + test('Server returns error if multiple headers are received for unary call', + () async { harness - ..service.unaryHandler = expectError(GrpcError.unimplemented('Expected request')) + ..service.unaryHandler = + expectError(GrpcError.unimplemented('Expected request')) ..expectErrorResponse(StatusCode.unimplemented, 'Expected request') ..sendRequestHeader('/Test/Unary') ..toServer.add(HeadersStreamMessage([])) @@ -175,7 +181,8 @@ void main() { test('Server returns error on too many requests for unary call', () async { harness - ..service.unaryHandler = expectError(GrpcError.unimplemented('Too many requests')) + ..service.unaryHandler = + expectError(GrpcError.unimplemented('Too many requests')) ..expectErrorResponse(StatusCode.unimplemented, 'Too many requests') ..sendRequestHeader('/Test/Unary') ..sendData(dummyValue) @@ -186,8 +193,10 @@ void main() { test('Server returns request deserialization errors', () async { harness - ..service.bidirectionalHandler = expectErrorStreaming(GrpcError.internal('Error deserializing request: Failed')) - ..expectErrorResponse(StatusCode.internal, 'Error deserializing request: Failed') + ..service.bidirectionalHandler = expectErrorStreaming( + GrpcError.internal('Error deserializing request: Failed')) + ..expectErrorResponse( + StatusCode.internal, 'Error deserializing request: Failed') ..sendRequestHeader('/Test/RequestError') ..sendData(dummyValue) ..toServer.close(); @@ -196,8 +205,10 @@ void main() { test('Server returns response serialization errors', () async { harness - ..service.bidirectionalHandler = expectErrorStreaming(GrpcError.internal('Error sending response: Failed')) - ..expectErrorResponse(StatusCode.internal, 'Error sending response: Failed') + ..service.bidirectionalHandler = expectErrorStreaming( + GrpcError.internal('Error sending response: Failed')) + ..expectErrorResponse( + StatusCode.internal, 'Error sending response: Failed') ..sendRequestHeader('/Test/ResponseError') ..sendData(dummyValue) ..sendData(dummyValue) @@ -258,9 +269,12 @@ void main() { await harness.fromServer.done; }); - test('Server returns error if request stream is closed before sending anything', () async { + test( + 'Server returns error if request stream is closed before sending anything', + () async { harness - ..expectErrorResponse(StatusCode.unavailable, 'Request stream closed unexpectedly') + ..expectErrorResponse( + StatusCode.unavailable, 'Request stream closed unexpectedly') ..toServer.close(); await harness.fromServer.done; }); @@ -291,7 +305,8 @@ void main() { } test('with sync interceptor', () => doTest(interceptor)); - test('with async interceptor', () => doTest((call, method) async => interceptor(call, method))); + test('with async interceptor', + () => doTest((call, method) async => interceptor(call, method))); }); group('returns error if interceptor blocks request', () { @@ -305,14 +320,16 @@ void main() { Future doTest(Interceptor handler) async { harness ..interceptor.handler = handler - ..expectErrorResponse(StatusCode.unauthenticated, 'Request is unauthenticated') + ..expectErrorResponse( + StatusCode.unauthenticated, 'Request is unauthenticated') ..sendRequestHeader('/Test/Unary'); await harness.fromServer.done; } test('with sync interceptor', () => doTest(interceptor)); - test('with async interceptor', () => doTest((call, method) async => interceptor(call, method))); + test('with async interceptor', + () => doTest((call, method) async => interceptor(call, method))); }); group('returns internal error if interceptor throws exception', () { @@ -323,14 +340,16 @@ void main() { Future doTest(Interceptor handler) async { harness ..interceptor.handler = handler - ..expectErrorResponse(StatusCode.internal, 'Exception: Reason is unknown') + ..expectErrorResponse( + StatusCode.internal, 'Exception: Reason is unknown') ..sendRequestHeader('/Test/Unary'); await harness.fromServer.done; } test('with sync interceptor', () => doTest(interceptor)); - test('with async interceptor', () => doTest((call, method) async => interceptor(call, method))); + test('with async interceptor', + () => doTest((call, method) async => interceptor(call, method))); }); test("don't fail if interceptor await 2 times", () async { @@ -342,7 +361,8 @@ void main() { harness ..interceptor.handler = interceptor - ..expectErrorResponse(StatusCode.internal, 'Exception: Reason is unknown') + ..expectErrorResponse( + StatusCode.internal, 'Exception: Reason is unknown') ..sendRequestHeader('/Test/Unary') ..sendData(1); diff --git a/test/server_test.dart b/test/server_test.dart index 837e9fb2..2de494d3 100644 --- a/test/server_test.dart +++ b/test/server_test.dart @@ -110,14 +110,16 @@ void main() { test('Server returns error on unimplemented path', () async { harness - ..expectErrorResponse(StatusCode.unimplemented, 'Path /Test/NotFound not found') + ..expectErrorResponse( + StatusCode.unimplemented, 'Path /Test/NotFound not found') ..sendRequestHeader('/Test/NotFound'); await harness.fromServer.done; }); /// Returns a service method handler that verifies that awaiting the request /// throws a specific error. - Future Function(ServiceCall call, Future request) expectError(expectedError) { + Future Function(ServiceCall call, Future request) expectError( + expectedError) { return expectAsync2((ServiceCall call, Future request) async { try { final result = await request; @@ -136,7 +138,8 @@ void main() { /// Returns a service method handler that verifies that awaiting the request /// stream throws a specific error. - Stream Function(ServiceCall call, Stream request) expectErrorStreaming(expectedError) { + Stream Function(ServiceCall call, Stream request) + expectErrorStreaming(expectedError) { return (ServiceCall call, Stream request) async* { try { await for (var entry in request) { @@ -156,7 +159,8 @@ void main() { test('Server returns error on missing request for unary call', () async { harness - ..service.unaryHandler = expectError(GrpcError.unimplemented('No request received')) + ..service.unaryHandler = + expectError(GrpcError.unimplemented('No request received')) ..expectErrorResponse(StatusCode.unimplemented, 'No request received') ..sendRequestHeader('/Test/Unary') ..toServer.close(); @@ -177,9 +181,11 @@ void main() { await harness.fromServer.done; }); - test('Server returns error if multiple headers are received for unary call', () async { + test('Server returns error if multiple headers are received for unary call', + () async { harness - ..service.unaryHandler = expectError(GrpcError.unimplemented('Expected request')) + ..service.unaryHandler = + expectError(GrpcError.unimplemented('Expected request')) ..expectErrorResponse(StatusCode.unimplemented, 'Expected request') ..sendRequestHeader('/Test/Unary') ..toServer.add(HeadersStreamMessage([])) @@ -189,7 +195,8 @@ void main() { test('Server returns error on too many requests for unary call', () async { harness - ..service.unaryHandler = expectError(GrpcError.unimplemented('Too many requests')) + ..service.unaryHandler = + expectError(GrpcError.unimplemented('Too many requests')) ..expectErrorResponse(StatusCode.unimplemented, 'Too many requests') ..sendRequestHeader('/Test/Unary') ..sendData(dummyValue) @@ -200,8 +207,10 @@ void main() { test('Server returns request deserialization errors', () async { harness - ..service.bidirectionalHandler = expectErrorStreaming(GrpcError.internal('Error deserializing request: Failed')) - ..expectErrorResponse(StatusCode.internal, 'Error deserializing request: Failed') + ..service.bidirectionalHandler = expectErrorStreaming( + GrpcError.internal('Error deserializing request: Failed')) + ..expectErrorResponse( + StatusCode.internal, 'Error deserializing request: Failed') ..sendRequestHeader('/Test/RequestError') ..sendData(dummyValue) ..toServer.close(); @@ -210,8 +219,10 @@ void main() { test('Server returns response serialization errors', () async { harness - ..service.bidirectionalHandler = expectErrorStreaming(GrpcError.internal('Error sending response: Failed')) - ..expectErrorResponse(StatusCode.internal, 'Error sending response: Failed') + ..service.bidirectionalHandler = expectErrorStreaming( + GrpcError.internal('Error sending response: Failed')) + ..expectErrorResponse( + StatusCode.internal, 'Error sending response: Failed') ..sendRequestHeader('/Test/ResponseError') ..sendData(dummyValue) ..sendData(dummyValue) @@ -272,9 +283,12 @@ void main() { await harness.fromServer.done; }); - test('Server returns error if request stream is closed before sending anything', () async { + test( + 'Server returns error if request stream is closed before sending anything', + () async { harness - ..expectErrorResponse(StatusCode.unavailable, 'Request stream closed unexpectedly') + ..expectErrorResponse( + StatusCode.unavailable, 'Request stream closed unexpectedly') ..toServer.close(); await harness.fromServer.done; }); @@ -305,7 +319,8 @@ void main() { } test('with sync interceptor', () => doTest(interceptor)); - test('with async interceptor', () => doTest((call, method) async => interceptor(call, method))); + test('with async interceptor', + () => doTest((call, method) async => interceptor(call, method))); }); group('returns error if interceptor blocks request', () { @@ -319,14 +334,16 @@ void main() { Future doTest(Interceptor handler) async { harness ..interceptor.handler = handler - ..expectErrorResponse(StatusCode.unauthenticated, 'Request is unauthenticated') + ..expectErrorResponse( + StatusCode.unauthenticated, 'Request is unauthenticated') ..sendRequestHeader('/Test/Unary'); await harness.fromServer.done; } test('with sync interceptor', () => doTest(interceptor)); - test('with async interceptor', () => doTest((call, method) async => interceptor(call, method))); + test('with async interceptor', + () => doTest((call, method) async => interceptor(call, method))); }); group('returns internal error if interceptor throws exception', () { @@ -337,14 +354,16 @@ void main() { Future doTest(Interceptor handler) async { harness ..interceptor.handler = handler - ..expectErrorResponse(StatusCode.internal, 'Exception: Reason is unknown') + ..expectErrorResponse( + StatusCode.internal, 'Exception: Reason is unknown') ..sendRequestHeader('/Test/Unary'); await harness.fromServer.done; } test('with sync interceptor', () => doTest(interceptor)); - test('with async interceptor', () => doTest((call, method) async => interceptor(call, method))); + test('with async interceptor', + () => doTest((call, method) async => interceptor(call, method))); }); test("don't fail if interceptor await 2 times", () async { @@ -356,7 +375,8 @@ void main() { harness ..interceptor.handler = interceptor - ..expectErrorResponse(StatusCode.internal, 'Exception: Reason is unknown') + ..expectErrorResponse( + StatusCode.internal, 'Exception: Reason is unknown') ..sendRequestHeader('/Test/Unary') ..sendData(1); From bb251213d3d90b257e0f7296d11670dc90ed3811 Mon Sep 17 00:00:00 2001 From: Tsavo Knott Date: Fri, 12 Apr 2024 15:33:40 -0400 Subject: [PATCH 8/9] Update pubspec.yaml --- pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pubspec.yaml b/pubspec.yaml index 0cf3d47f..a936535f 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -12,7 +12,7 @@ dependencies: crypto: ^3.0.3 fixnum: ^1.1.0 googleapis_auth: ^1.6.0 - meta: ^1.14.0 + meta: ">=1.11.0 <2.0.0" http: '>=0.13.0 <2.0.0' http2: ^2.3.0 protobuf: '>=2.0.0 <4.0.0' From 00eabed7f6403ea142e91d33e13ba4f8375d2b86 Mon Sep 17 00:00:00 2001 From: Tsavo Knott Date: Sat, 22 Jun 2024 16:28:05 -0400 Subject: [PATCH 9/9] chore: Update Deps --- pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pubspec.yaml b/pubspec.yaml index a936535f..48013199 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -4,7 +4,7 @@ version: 3.2.4 repository: https://github.com/grpc/grpc-dart environment: - sdk: '>=3.0.0 <4.0.0' + sdk: '>=3.3.0 <4.5.0' dependencies: archive: ^3.4.10