[Orleans 7] Error when trying to test JournaledGrain with Orleans TestKit
- Dominant language
- C#
- Stars
- 10.9k
- Forks
- 2.1k
- Avg merge
- 14h 42m
- Merged PRs (30d)
- 354
Description
Hi I'm trying to test a JournaledGrain with Orleans Testkit (Orleans 7) and I'm getting this error:
```
Message:
System.InvalidOperationException : No service for type 'Orleans.Factory`2[Orleans.Runtime.IGrainContext,Orleans.EventSourcing.ILogConsistencyProtocolServices]' has been registered.
Stack Trace:
ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType)
ServiceProviderServiceExtensions.GetRequiredService[T](IServiceProvider provider)
LogConsistentGrain`1.OnSetupState(CancellationToken ct) line 58
Observer.OnStart(CancellationToken ct) line 123
LifecycleSubject.g__CallOnStart|7_0(OrderedObserver observer, CancellationToken cancellationToken) line 139
--- End of stack trace from previous location ---
LifecycleSubject.OnStart(CancellationToken cancellationToken) line 118
OrleansTaskExtentions.WithCancellation(Task taskToComplete, CancellationToken cancellationToken, String message) line 145
ActivationData.g__CallActivateAsync|132_0(Dictionary`2 requestContextData, CancellationToken cancellationToken) line 1180
```
Grain code:
```
[LogConsistencyProvider(ProviderName = "Default")]
[StorageProvider(ProviderName = "Default")]
public class TestAggregate : JournaledGrain, ITestAggregateActor
{
public TestAggregate(IGrainContext grainContext)
{
GrainContext = grainContext;
}
public IGrainContext GrainContext { get; }
public async Task Handle(TestCommand command)
{
RaiseEvent(new TestEvent(command.Id));
await ConfirmEvents();
return new TestCommandResult(command.Id, GrainContext.GrainId.Key.ToString());
}
}
```
Test codes:
```
public class AggregateActorTests
{
[Fact]
public async void CanExecuteCommandWithRequestBus()
{
var builder = new TestClusterBuilder();
builder.AddClientBuilderConfigurator();
builder.AddSiloBuilderConfigurator();
var cluster = builder.Build();
var grain = cluster.Client.GetGrain("testId");
await grain.Handle(new TestCommand() { AggregateId = "testId"});
cluster.Deploy();
}
}
internal class SiloConfiguration : IHostConfigurator
{
public void Configure(IHostBuilder hostBuilder)
{
hostBuilder.UseOrleans(sb =>
{
sb.AddStateStorageBasedLogConsistencyProviderAsDefault();
sb.AddMemoryGrainStorageAsDefault();
});
}
}
```
Contributor guide
Research direction
Start by reproducing the failure with AggregateActorTests and inspect LogConsistentGrain.OnSetupState at the stack-trace line. Compare the services configured in SiloConfiguration with the service requested during JournaledGrain activation. Done means the TestKit cluster activates TestAggregate and Handle completes without the missing Factory error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- distributed-systems, testing
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100