예제 #1
0
        public async Task ActorCanPerformReentrantCalls()
        {
            using var cts = new CancellationTokenSource(TimeSpan.FromSeconds(60));
            var proxy = this.ProxyFactory.CreateActorProxy <IReentrantActor>(ActorId.CreateRandom(), "ReentrantActor");

            await ActorRuntimeChecker.WaitForActorRuntimeAsync(this.AppId, this.Output, proxy, cts.Token);

            await proxy.ReentrantCall(new ReentrantCallOptions()
            {
                CallsRemaining = NumCalls,
            });

            var records = new List <CallRecord>();

            for (int i = 0; i < NumCalls; i++)
            {
                var state = await proxy.GetState(i);

                records.AddRange(state.Records);
            }

            var enterRecords = records.FindAll(record => record.IsEnter);
            var exitRecords  = records.FindAll(record => !record.IsEnter);

            this.Output.WriteLine($"Got {records.Count} records.");
            Assert.True(records.Count == NumCalls * 2);
            for (int i = 0; i < NumCalls; i++)
            {
                for (int j = 0; j < NumCalls; j++)
                {
                    // Assert all the enters happen before the exits.
                    Assert.True(enterRecords[i].Timestamp < exitRecords[j].Timestamp);
                }
            }
        }
예제 #2
0
파일: E2ETests.cs 프로젝트: dapr/dotnet-sdk
 protected async Task WaitForActorRuntimeAsync(IPingActor proxy, CancellationToken cancellationToken)
 {
     await ActorRuntimeChecker.WaitForActorRuntimeAsync(this.AppId, this.Output, proxy, cancellationToken);
 }