feat: add Dapr.IntegrationTest.DaprClient integration tests for HTTP and gRPC proxy invocation#1814
Conversation
…and gRPC proxy invocation Agent-Logs-Url: https://github.com/dapr/dotnet-sdk/sessions/d477244b-9f9b-439e-9c0a-791e2add786e Co-authored-by: WhitWaldo <2238529+WhitWaldo@users.noreply.github.com>
Agent-Logs-Url: https://github.com/dapr/dotnet-sdk/sessions/d477244b-9f9b-439e-9c0a-791e2add786e Co-authored-by: WhitWaldo <2238529+WhitWaldo@users.noreply.github.com>
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #1814 +/- ##
==========================================
- Coverage 63.46% 63.34% -0.12%
==========================================
Files 312 313 +1
Lines 9279 9301 +22
Branches 1101 1103 +2
==========================================
+ Hits 5889 5892 +3
- Misses 3130 3149 +19
Partials 260 260
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Agent-Logs-Url: https://github.com/dapr/dotnet-sdk/sessions/4258a9b8-320d-41bf-a8c5-599f90aa5f2f Co-authored-by: WhitWaldo <2238529+WhitWaldo@users.noreply.github.com>
Done in commit Usage for a containerized app scenario: var options = new DaprRuntimeOptions()
.WithAppChannelAddress("my-app-container"); // Docker network alias of the app container |
|
@copilot I'm seeing a lot of test failures. Can you please address those? |
The failures are all in |
|
@copilot Can you please resolve the merge conflicts? |
Resolve add/add conflict in Dapr.IntegrationTest.DaprClient.csproj: - Keep Microsoft.NET.Sdk.Web (needed for Kestrel/gRPC hosting in tests) - Keep gRPC packages + echo.proto Protobuf item from our branch - Add Dapr.AspNetCore + Dapr.Testcontainers.Xunit project references from master - Include DaprBulkDeleteStateApiKeyTests.cs added by master (#1820) Agent-Logs-Url: https://github.com/dapr/dotnet-sdk/sessions/75bcb7ec-f89b-4aa5-9950-a7c424a3ed31 Co-authored-by: WhitWaldo <2238529+WhitWaldo@users.noreply.github.com>
Done in commit |
|
@copilot I'm still seeing some outstanding merge conflicts. Can you please address them as well? |
…eck-test-coverage # Conflicts: # test/Dapr.IntegrationTest.DaprClient/Dapr.IntegrationTest.DaprClient.csproj Co-authored-by: WhitWaldo <2238529+WhitWaldo@users.noreply.github.com>
Fixed in commit |
Description
Creates
Dapr.IntegrationTest.DaprClient— a new integration test project that covers the legacyDapr.Clientservice-invocation surface area against a real Dapr sidecar. This closes the gap identified in the previous analysis where HTTP service invocation and gRPC proxy tests existed only in the olderDapr.E2E.Testsuite (which runs against a locally-installeddaprCLI) and not yet in the modern container-basedDapr.IntegrationTest.*suite.Also extends
Dapr.Testcontainerswith configurable--app-protocoland--app-channel-addresssupport, implementing #1699 and allowing the sidecar to reach an app running inside its own Docker container (rather than only on the host machine).src/Dapr.Testcontainers— library extensionsCommon/Options/DaprRuntimeOptions.csAppProtocolproperty (default"http") and validatedWithAppProtocol()fluent setter; addedAppChannelAddressproperty (default"host.docker.internal") and validatedWithAppChannelAddress()fluent setterContainers/Dapr/DaprdContainer.csoptions.AppProtocolas-app-protocolandoptions.AppChannelAddressas-app-channel-addresson the daprd command line (replaces previously hardcodedhost.docker.internal)Harnesses/BaseHarness.cspublic string AppIdso tests can discover the auto-generated app-id for routingHarnesses/ServiceInvocationHarness.cs(new)Common/DaprHarnessBuilder.csBuildServiceInvocation()factory methodtest/Dapr.IntegrationTest.DaprClient— new test projectAuto-discovered by CI via the
Dapr.IntegrationTest.*.csprojglob. Builds on net8.0 / net9.0 / net10.0.Dapr.IntegrationTest.DaprClient.csprojProtos/echo.protoEchoService(unary, bidirectional streaming, slow-echo)GrpcServices/EchoServiceImpl.csServiceInvocation/HttpServiceInvocationTests.csCreateInvokeHttpClient,CreateInvokableHttpClient, and threeInvokeMethodAsyncoverloadsServiceInvocation/GrpcProxyInvocationTests.csDaprBulkDeleteStateApiKeyTests.csDeleteBulkStateAsyncwith a Dapr API token (from master #1820)HTTP service invocation (
HttpServiceInvocationTests)CreateInvokeHttpClient— POST with typed payload; GET requestCreateInvokableHttpClient(instance method) — relative URI routed through sidecarInvokeMethodAsync<TRequest, TResponse>— typed request + typed responseInvokeMethodAsync<TResponse>— no request body, typed responseInvokeMethodAsync<TRequest>— typed request, void (204) responsegRPC proxy invocation (
GrpcProxyInvocationTests)RpcExceptionwithStatusCode.DeadlineExceededEach test spins up its own
ServiceInvocationHarnessviaDaprHarnessBuilder. For HTTP tests the harness uses the default--app-protocol http; for gRPC proxy testsWithOptions(new DaprRuntimeOptions().WithAppProtocol("grpc"))is passed so daprd uses gRPC to talk to the in-process Kestrel server. No external infrastructure (Redis, RabbitMQ, etc.) is needed.The new
WithAppChannelAddress()option allows the Dapr sidecar to connect to an app running inside a Docker container on the same network (by passing the container's network alias), rather than being limited tohost.docker.internal. The default value is preserved for backward compatibility.[Obsolete]attribute on test methods is the standard pattern in this repo for suppressing CS0618 when testing deprecated APIs (matchesDaprClientTest.InvokeMethodAsync.csetc.)Dapr.E2E.Testservice-invocation tests are left untouched for now; they can be retired once this suite is stable in CIIssue reference
We strive to have all PR being opened based on an issue, where the problem or feature have been discussed prior to implementation.
Checklist
Please make sure you've completed the relevant tasks for this PR, out of the following list: