-
Notifications
You must be signed in to change notification settings - Fork 374
Add integration test project for Actors.Generators (replaces E2E tests) #1791
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
Merged
WhitWaldo
merged 4 commits into
master
from
copilot/add-integration-tests-for-actors-generators
Apr 16, 2026
Merged
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
698cd04
Add Dapr.IntegrationTest.Actors.Generators project with generated cli…
Copilot b3f8b51
Merge origin/master and resolve all.sln conflicts
Copilot 6f15733
Address review: primary constructor, [LoggerMessage] logging, move Nu…
Copilot 9ef744f
Revert Nullable from shared Directory.Build.props back to project csproj
Copilot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
test/Dapr.IntegrationTest.Actors.Generators/Actors/IClientActor.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| // ------------------------------------------------------------------------ | ||
| // Copyright 2026 The Dapr Authors | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
| // ------------------------------------------------------------------------ | ||
|
|
||
| using System.Threading; | ||
| using System.Threading.Tasks; | ||
| using Dapr.Actors.Generators; | ||
|
|
||
| namespace Dapr.IntegrationTest.Actors.Generators.Actors; | ||
|
|
||
| /// <summary> | ||
| /// State record used by the client-side generated actor client. | ||
| /// </summary> | ||
| public record ClientState(string Value); | ||
|
|
||
| /// <summary> | ||
| /// Actor interface decorated with <see cref="GenerateActorClientAttribute"/> to trigger | ||
| /// source generation of a strongly-typed client (<c>ClientActorClient</c>). | ||
| /// The methods use <see cref="ActorMethodAttribute"/> to map to the actual server-side | ||
| /// actor method names. | ||
| /// </summary> | ||
| [GenerateActorClient] | ||
| public interface IClientActor | ||
| { | ||
| /// <summary> | ||
| /// Gets the current state from the remote actor. | ||
| /// </summary> | ||
| [ActorMethod(Name = "GetState")] | ||
| Task<ClientState> GetStateAsync(CancellationToken cancellationToken = default); | ||
|
|
||
| /// <summary> | ||
| /// Sets the state on the remote actor. | ||
| /// </summary> | ||
| [ActorMethod(Name = "SetState")] | ||
| Task SetStateAsync(ClientState state, CancellationToken cancellationToken = default); | ||
|
|
||
| /// <summary> | ||
| /// Calls the SayHello method on the remote actor. | ||
| /// </summary> | ||
| [ActorMethod(Name = "SayHello")] | ||
| Task<string> SayHelloAsync(string name, CancellationToken cancellationToken = default); | ||
|
|
||
| /// <summary> | ||
| /// Calls the IncrementCallCount method on the remote actor. | ||
| /// </summary> | ||
| [ActorMethod(Name = "IncrementCallCount")] | ||
| Task IncrementCallCountAsync(CancellationToken cancellationToken = default); | ||
|
|
||
| /// <summary> | ||
| /// Gets the call count from the remote actor. | ||
| /// </summary> | ||
| [ActorMethod(Name = "GetCallCount")] | ||
| Task<int> GetCallCountAsync(CancellationToken cancellationToken = default); | ||
| } |
33 changes: 33 additions & 0 deletions
33
test/Dapr.IntegrationTest.Actors.Generators/Actors/IPingActor.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| // ------------------------------------------------------------------------ | ||
| // Copyright 2026 The Dapr Authors | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
| // ------------------------------------------------------------------------ | ||
|
|
||
| using System.Threading; | ||
| using System.Threading.Tasks; | ||
| using Dapr.Actors; | ||
|
|
||
| namespace Dapr.IntegrationTest.Actors.Generators; | ||
|
|
||
| /// <summary> | ||
| /// Minimal actor interface used as a readiness probe. | ||
| /// </summary> | ||
| public interface IPingActor : IActor | ||
| { | ||
| /// <summary> | ||
| /// Pings the actor to verify that the runtime is available. | ||
| /// </summary> | ||
| /// <param name="cancellationToken"> | ||
| /// A token that cancels the underlying HTTP request, allowing the caller to impose a | ||
| /// per-attempt timeout instead of waiting for the HttpClient default (100 s). | ||
| /// </param> | ||
| Task Ping(CancellationToken cancellationToken = default); | ||
| } |
56 changes: 56 additions & 0 deletions
56
test/Dapr.IntegrationTest.Actors.Generators/Actors/IRemoteActor.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| // ------------------------------------------------------------------------ | ||
| // Copyright 2026 The Dapr Authors | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
| // ------------------------------------------------------------------------ | ||
|
|
||
| using System.Threading; | ||
| using System.Threading.Tasks; | ||
|
|
||
| namespace Dapr.IntegrationTest.Actors.Generators.Actors; | ||
|
|
||
| /// <summary> | ||
| /// State record used by the remote actor for get/set operations. | ||
| /// </summary> | ||
| public record RemoteState(string Value); | ||
|
|
||
| /// <summary> | ||
| /// Actor interface for the server-side actor that manages state. | ||
| /// Extends <see cref="IPingActor"/> so the runtime readiness check can be performed. | ||
| /// </summary> | ||
| public interface IRemoteActor : IPingActor | ||
| { | ||
| /// <summary> | ||
| /// Returns the current state of the actor. | ||
| /// </summary> | ||
| Task<RemoteState> GetState(); | ||
|
|
||
| /// <summary> | ||
| /// Sets the state of the actor. | ||
| /// </summary> | ||
| /// <param name="state">The new state to set.</param> | ||
| Task SetState(RemoteState state); | ||
|
|
||
| /// <summary> | ||
| /// Returns a greeting message for the specified name. | ||
| /// </summary> | ||
| /// <param name="name">The name to greet.</param> | ||
| Task<string> SayHello(string name); | ||
|
|
||
| /// <summary> | ||
| /// A fire-and-forget method with no parameters and no return value. | ||
| /// </summary> | ||
| Task IncrementCallCount(); | ||
|
|
||
| /// <summary> | ||
| /// Returns the current call count. | ||
| /// </summary> | ||
| Task<int> GetCallCount(); | ||
| } |
80 changes: 80 additions & 0 deletions
80
test/Dapr.IntegrationTest.Actors.Generators/Actors/RemoteActor.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| // ------------------------------------------------------------------------ | ||
| // Copyright 2026 The Dapr Authors | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
| // ------------------------------------------------------------------------ | ||
|
|
||
| using System.Threading; | ||
| using System.Threading.Tasks; | ||
| using Dapr.Actors.Runtime; | ||
| using Microsoft.Extensions.Logging; | ||
|
|
||
| namespace Dapr.IntegrationTest.Actors.Generators.Actors; | ||
|
|
||
| /// <summary> | ||
| /// Implementation of <see cref="IRemoteActor"/> that manages state in memory. | ||
| /// </summary> | ||
| internal sealed class RemoteActor : Actor, IRemoteActor | ||
| { | ||
| private readonly ILogger<RemoteActor> logger; | ||
|
|
||
| private RemoteState currentState = new("default"); | ||
|
|
||
| private int callCount; | ||
|
|
||
| public RemoteActor(ActorHost host, ILogger<RemoteActor> logger) | ||
| : base(host) | ||
| { | ||
| this.logger = logger; | ||
| } | ||
|
|
||
| /// <inheritdoc /> | ||
| public Task<RemoteState> GetState() | ||
| { | ||
| this.logger.LogInformation("GetState called."); | ||
| return Task.FromResult(this.currentState); | ||
| } | ||
|
|
||
| /// <inheritdoc /> | ||
| public Task SetState(RemoteState state) | ||
| { | ||
| this.logger.LogInformation("SetState called."); | ||
|
WhitWaldo marked this conversation as resolved.
Outdated
|
||
| this.currentState = state; | ||
| return Task.CompletedTask; | ||
| } | ||
|
|
||
| /// <inheritdoc /> | ||
| public Task<string> SayHello(string name) | ||
| { | ||
| this.logger.LogInformation("SayHello called with name: {Name}", name); | ||
| return Task.FromResult($"Hello, {name}!"); | ||
| } | ||
|
|
||
| /// <inheritdoc /> | ||
| public Task IncrementCallCount() | ||
| { | ||
| this.logger.LogInformation("IncrementCallCount called."); | ||
| this.callCount++; | ||
| return Task.CompletedTask; | ||
| } | ||
|
|
||
| /// <inheritdoc /> | ||
| public Task<int> GetCallCount() | ||
| { | ||
| this.logger.LogInformation("GetCallCount called."); | ||
| return Task.FromResult(this.callCount); | ||
| } | ||
|
|
||
| /// <inheritdoc /> | ||
| public Task Ping(CancellationToken cancellationToken = default) | ||
| { | ||
| return Task.CompletedTask; | ||
| } | ||
| } | ||
31 changes: 31 additions & 0 deletions
31
test/Dapr.IntegrationTest.Actors.Generators/Dapr.IntegrationTest.Actors.Generators.csproj
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| <Project Sdk="Microsoft.NET.Sdk.Web"> | ||
|
|
||
| <PropertyGroup> | ||
| <ImplicitUsings>enable</ImplicitUsings> | ||
| <Nullable>enable</Nullable> | ||
|
WhitWaldo marked this conversation as resolved.
|
||
| <IsPackable>false</IsPackable> | ||
| </PropertyGroup> | ||
|
|
||
| <ItemGroup> | ||
| <PackageReference Include="coverlet.collector"> | ||
| <PrivateAssets>all</PrivateAssets> | ||
| <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
| </PackageReference> | ||
| <PackageReference Include="Microsoft.NET.Test.Sdk" /> | ||
| <PackageReference Include="xunit.v3" /> | ||
| <PackageReference Include="xunit.v3.extensibility.core" /> | ||
| <PackageReference Include="xunit.runner.visualstudio" /> | ||
| </ItemGroup> | ||
|
|
||
| <ItemGroup> | ||
| <Using Include="Xunit"/> | ||
| </ItemGroup> | ||
|
|
||
| <ItemGroup> | ||
| <ProjectReference Include="..\..\src\Dapr.Actors\Dapr.Actors.csproj" /> | ||
| <ProjectReference Include="..\..\src\Dapr.Actors.AspNetCore\Dapr.Actors.AspNetCore.csproj" /> | ||
| <ProjectReference Include="..\..\src\Dapr.Actors.Generators\Dapr.Actors.Generators.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" /> | ||
| <ProjectReference Include="..\..\src\Dapr.Testcontainers\Dapr.Testcontainers.csproj" /> | ||
| </ItemGroup> | ||
|
|
||
| </Project> | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.