public void UnorderedNonReentrantGrain(bool performDeadlockDetection)
        {
            IUnorderedNonReentrantGrain unonreentrant = this.grainFactory.GetGrain <IUnorderedNonReentrantGrain>(OrleansTestingBase.GetRandomGrainId());

            unonreentrant.SetSelf(unonreentrant).Wait();
            bool timeout  = false;
            bool deadlock = false;

            try
            {
                timeout = !unonreentrant.Two().Wait(2000);
            }
            catch (Exception exc)
            {
                Exception baseExc = exc.GetBaseException();
                if (baseExc.GetType().Equals(typeof(DeadlockException)))
                {
                    deadlock = true;
                }
                else
                {
                    Assert.True(false, $"Unexpected exception {exc.Message}: {exc.StackTrace}");
                }
            }
            if (performDeadlockDetection)
            {
                Assert.True(deadlock, "Non-reentrant grain should deadlock");
            }
            else
            {
                Assert.True(timeout, "Non-reentrant grain should timeout");
            }

            this.logger.Info("Reentrancy UnorderedNonReentrantGrain Test finished OK.");
        }
Example #2
0
        public void UnorderedNonReentrantGrain()
        {
            IUnorderedNonReentrantGrain unonreentrant = GrainClient.GrainFactory.GetGrain <IUnorderedNonReentrantGrain>(GetRandomGrainId());

            unonreentrant.SetSelf(unonreentrant).Wait();
            bool timeout  = false;
            bool deadlock = false;

            try
            {
                timeout = !unonreentrant.Two().Wait(2000);
            }
            catch (Exception exc)
            {
                Exception baseExc = exc.GetBaseException();
                if (baseExc.GetType().Equals(typeof(DeadlockException)))
                {
                    deadlock = true;
                }
                else
                {
                    Assert.Fail("Unexpected exception {0}: {1}", exc.Message, exc.StackTrace);
                }
            }
            if (this.HostedCluster.Primary.Silo.GlobalConfig.PerformDeadlockDetection)
            {
                Assert.IsTrue(deadlock, "Non-reentrant grain should deadlock");
            }
            else
            {
                Assert.IsTrue(timeout, "Non-reentrant grain should timeout");
            }

            logger.Info("Reentrancy UnorderedNonReentrantGrain Test finished OK.");
        }
Example #3
0
 public Task SetSelf(IUnorderedNonReentrantGrain self)
 {
     Self = self;
     return(Task.CompletedTask);
 }
Example #4
0
 public Task SetSelf(IUnorderedNonReentrantGrain self)
 {
     Self = self;
     return TaskDone.Done;
 }
Example #5
0
 public Task SetSelf(IUnorderedNonReentrantGrain self)
 {
     Self = self;
     return(TaskDone.Done);
 }