-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make ManagementGrain a reentrant, stateless worker (#8394)
- Loading branch information
1 parent
698e860
commit f16bcd0
Showing
4 changed files
with
64 additions
and
61 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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,61 @@ | ||
using Orleans.Concurrency; | ||
using Orleans.Runtime; | ||
using TestExtensions; | ||
using Xunit; | ||
|
||
namespace UnitTests.OrleansRuntime | ||
{ | ||
public class ManagementGrainTests : HostedTestClusterEnsureDefaultStarted | ||
{ | ||
public ManagementGrainTests(DefaultClusterFixture fixture) : base(fixture) | ||
{ | ||
} | ||
|
||
[Fact] | ||
[TestCategory("BVT")] | ||
public async Task GetActivationAddressTest() | ||
{ | ||
var managementGrain = this.Fixture.Client.GetGrain<IManagementGrain>(0); | ||
var grain1 = this.Fixture.Client.GetGrain<IDumbGrain>(Guid.NewGuid()); | ||
var grain2 = this.Fixture.Client.GetGrain<IDumbGrain>(Guid.NewGuid()); | ||
|
||
var grain1Address = await managementGrain.GetActivationAddress(grain1); | ||
Assert.Null(grain1Address); | ||
|
||
await grain1.DoNothing(); | ||
grain1Address = await managementGrain.GetActivationAddress(grain1); | ||
Assert.NotNull(grain1Address); | ||
var grain2Address = await managementGrain.GetActivationAddress(grain2); | ||
Assert.Null(grain2Address); | ||
|
||
await grain2.DoNothing(); | ||
var grain1Address2 = await managementGrain.GetActivationAddress(grain1); | ||
Assert.NotNull(grain1Address2); | ||
Assert.True(grain1Address.Equals(grain1Address2)); | ||
|
||
var worker = this.Fixture.Client.GetGrain<IDumbWorker>(0); | ||
await Assert.ThrowsAnyAsync<InvalidOperationException>(async () => await managementGrain.GetActivationAddress(worker)); | ||
} | ||
} | ||
|
||
public interface IDumbWorker : IGrainWithIntegerKey | ||
{ | ||
Task DoNothing(); | ||
} | ||
|
||
[StatelessWorker(1)] | ||
public class DumbWorker : Grain, IDumbWorker | ||
{ | ||
public Task DoNothing() => Task.CompletedTask; | ||
} | ||
|
||
public interface IDumbGrain : IGrainWithGuidKey | ||
{ | ||
Task DoNothing(); | ||
} | ||
|
||
public class DumbGrain : Grain, IDumbGrain | ||
{ | ||
public Task DoNothing() => Task.CompletedTask; | ||
} | ||
} |
60 changes: 0 additions & 60 deletions
60
test/TesterInternal/OrleansRuntime/ManagementGrainTests.cs
This file was deleted.
Oops, something went wrong.