public void NonReentrantGrain(bool performDeadlockDetection)
        {
            INonReentrantGrain nonreentrant = this.grainFactory.GetGrain <INonReentrantGrain>(OrleansTestingBase.GetRandomGrainId());

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

            try
            {
                timeout = !nonreentrant.Two().Wait(2000);
            }
            catch (Exception exc)
            {
                Exception baseExc = exc.GetBaseException();
                if (baseExc.GetType().Equals(typeof(DeadlockException)))
                {
                    deadlock = true;
                }
                else
                {
                    Assert.True(false, string.Format("Unexpected exception {0}: {1}", 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 NonReentrantGrain Test finished OK.");
        }
Exemplo n.º 2
0
        public void NonReentrantGrain()
        {
            INonReentrantGrain nonreentrant = GrainClient.GrainFactory.GetGrain <INonReentrantGrain>(GetRandomGrainId());

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

            try
            {
                timeout = !nonreentrant.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 NonReentrantGrain Test finished OK.");
        }