Exemplo n.º 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);
                }
            }
        }
Exemplo n.º 2
0
 protected async Task WaitForActorRuntimeAsync(IPingActor proxy, CancellationToken cancellationToken)
 {
     await ActorRuntimeChecker.WaitForActorRuntimeAsync(this.AppId, this.Output, proxy, cancellationToken);
 }