示例#1
0
        public async Task EchoGrain_PingSilo_Remote()
        {
            Stopwatch clock = new Stopwatch();

            string what = "CreateGrain";

            clock.Start();
            grain = this.GrainFactory.GetGrain <IEchoTaskGrain>(Guid.NewGuid());
            this.Logger.LogInformation("{What} took {Elapsed}", what, clock.Elapsed);

            SiloAddress silo1 = HostedCluster.Primary.SiloAddress;
            SiloAddress silo2 = HostedCluster.SecondarySilos[0].SiloAddress;

            what = "EchoGrain.PingRemoteSilo[1]";
            clock.Restart();
            await grain.PingRemoteSiloAsync(silo1).WithTimeout(timeout);

            this.Logger.LogInformation("{What} took {Elapsed}", what, clock.Elapsed);

            what = "EchoGrain.PingRemoteSilo[2]";
            clock.Restart();
            await grain.PingRemoteSiloAsync(silo2).WithTimeout(timeout);

            this.Logger.LogInformation("{What} took {Elapsed}", what, clock.Elapsed);
        }
示例#2
0
        public async Task EchoGrain_PingSilo_Remote()
        {
            Stopwatch clock = new Stopwatch();

            string what = "CreateGrain";

            clock.Start();
            grain = GrainClient.GrainFactory.GetGrain <IEchoTaskGrain>(Guid.NewGuid());
            logger.Info("{0} took {1}", what, clock.Elapsed);

            var         siloHost = TestingSiloHost.Instance;
            SiloAddress silo1    = siloHost.Primary.Silo.SiloAddress;
            SiloAddress silo2    = siloHost.Secondary.Silo.SiloAddress;

            what = "EchoGrain.PingRemoteSilo[1]";
            clock.Restart();
            await grain.PingRemoteSiloAsync(silo1).WithTimeout(timeout);

            logger.Info("{0} took {1}", what, clock.Elapsed);

            what = "EchoGrain.PingRemoteSilo[2]";
            clock.Restart();
            await grain.PingRemoteSiloAsync(silo2).WithTimeout(timeout);

            logger.Info("{0} took {1}", what, clock.Elapsed);
        }
示例#3
0
        public async Task EchoGrain_Timeout_Wait()
        {
            grain = this.GrainFactory.GetGrain <IEchoTaskGrain>(Guid.NewGuid());

            TimeSpan  delay30 = TimeSpan.FromSeconds(30); // grain call timeout (set in config)
            TimeSpan  delay45 = TimeSpan.FromSeconds(45);
            TimeSpan  delay60 = TimeSpan.FromSeconds(60);
            Stopwatch sw      = new Stopwatch();

            sw.Start();
            Task <int> promise = grain.BlockingCallTimeoutAsync(delay60);
            await promise.ContinueWith(
                t =>
            {
                if (!t.IsFaulted)
                {
                    Assert.True(false);                   // BlockingCallTimeout should not have completed successfully
                }
                Exception exc = t.Exception;
                while (exc is AggregateException)
                {
                    exc = exc.InnerException;
                }
                Assert.IsAssignableFrom <TimeoutException>(exc);
            }).WithTimeout(delay45);

            sw.Stop();
            Assert.True(TimeIsLonger(sw.Elapsed, delay30), $"Elapsed time out of range: {sw.Elapsed}");
            Assert.True(TimeIsShorter(sw.Elapsed, delay60), $"Elapsed time out of range: {sw.Elapsed}");
        }
示例#4
0
        public async Task EchoGrain_Timeout_Result()
        {
            grain = GrainClient.GrainFactory.GetGrain <IEchoTaskGrain>(Guid.NewGuid());

            TimeSpan  delay30 = TimeSpan.FromSeconds(30);
            TimeSpan  delay60 = TimeSpan.FromSeconds(60);
            Stopwatch sw      = new Stopwatch();

            sw.Start();
            try
            {
                int res = await grain.BlockingCallTimeoutAsync(delay60);

                Assert.Fail("BlockingCallTimeout should not have completed successfully, but returned " + res);
            }
            catch (Exception exc)
            {
                while (exc is AggregateException)
                {
                    exc = exc.InnerException;
                }
                Assert.IsInstanceOfType(exc, typeof(TimeoutException), "Received exception type: {0}", exc);
            }
            sw.Stop();
            Assert.IsTrue(TimeIsLonger(sw.Elapsed, delay30), "Elapsted time out of range: {0}", sw.Elapsed);
            Assert.IsTrue(TimeIsShorter(sw.Elapsed, delay60), "Elapsted time out of range: {0}", sw.Elapsed);
        }
示例#5
0
        public void EchoGrain_Timeout_Wait()
        {
            grain = GrainClient.GrainFactory.GetGrain <IEchoTaskGrain>(Guid.NewGuid());

            TimeSpan  delay30 = TimeSpan.FromSeconds(30); // grain call timeout (set in config)
            TimeSpan  delay45 = TimeSpan.FromSeconds(45);
            TimeSpan  delay60 = TimeSpan.FromSeconds(60);
            Stopwatch sw      = new Stopwatch();

            sw.Start();
            Task <int> promise = grain.BlockingCallTimeoutAsync(delay60);
            bool       ok      = promise.ContinueWith(t =>
            {
                if (!t.IsFaulted)
                {
                    Assert.Fail("BlockingCallTimeout should not have completed successfully");
                }

                Exception exc = t.Exception;
                while (exc is AggregateException)
                {
                    exc = exc.InnerException;
                }
                Assert.IsInstanceOfType(exc, typeof(TimeoutException), "Received exception type: {0}", exc);
            }).Wait(delay45);

            sw.Stop();
            Assert.IsTrue(ok, "Wait should not have timed-out. The grain call should have time out.");
            Assert.IsTrue(TimeIsLonger(sw.Elapsed, delay30), "Elapsted time out of range: {0}", sw.Elapsed);
            Assert.IsTrue(TimeIsShorter(sw.Elapsed, delay60), "Elapsted time out of range: {0}", sw.Elapsed);
        }
示例#6
0
        public async Task EchoGrain_Timeout_Result()
        {
            grain = this.GrainFactory.GetGrain <IEchoTaskGrain>(Guid.NewGuid());

            TimeSpan  delay30 = TimeSpan.FromSeconds(30);
            TimeSpan  delay60 = TimeSpan.FromSeconds(60);
            Stopwatch sw      = new Stopwatch();

            sw.Start();
            try
            {
                int res = await grain.BlockingCallTimeoutAsync(delay60);

                Assert.True(false, "BlockingCallTimeout should not have completed successfully, but returned " + res);
            }
            catch (Exception exc)
            {
                while (exc is AggregateException)
                {
                    exc = exc.InnerException;
                }
                Assert.IsAssignableFrom <TimeoutException>(exc);
            }
            sw.Stop();
            Assert.True(TimeIsLonger(sw.Elapsed, delay30), $"Elapsed time out of range: {sw.Elapsed}");
            Assert.True(TimeIsShorter(sw.Elapsed, delay60), $"Elapsed time out of range: {sw.Elapsed}");
        }
示例#7
0
        public async Task <string> CallMethodTask_Await(string data)
        {
            string name = GetType().Name + ".CallMethodTask_Await";

            logger.Info(name + " Data=" + data);
            IEchoTaskGrain avGrain = GrainFactory.GetGrain <IEchoTaskGrain>(this.GetPrimaryKey());
            var            result  = await avGrain.EchoAsync(data);

            logger.Info(name + " Result=" + result);
            return(result);
        }
示例#8
0
        public async Task <string> CallMethodTask_Await(string data)
        {
            string name = GetType().Name + ".CallMethodTask_Await";

            logger.LogInformation("{Name} Data={Data}", name, data);
            IEchoTaskGrain avGrain = GrainFactory.GetGrain <IEchoTaskGrain>(this.GetPrimaryKey());
            var            result  = await avGrain.EchoAsync(data);

            logger.LogInformation("{Name} Result={Result}", name, result);
            return(result);
        }
示例#9
0
#pragma warning disable 1998
        public async Task <string> CallMethodTask_Block(string data)
        {
            string name = GetType().Name + ".CallMethodTask_Block";

            logger.Info(name + " Data=" + data);
            IEchoTaskGrain avGrain = GrainFactory.GetGrain <IEchoTaskGrain>(this.GetPrimaryKey());

            // Note: We deliberately use .Result here in this test case to block current executing thread
            var result = avGrain.EchoAsync(data).Result;

            logger.Info(name + " Result=" + result);
            return(result);
        }
示例#10
0
        public async Task EchoGrain_Echo()
        {
            Stopwatch clock = new Stopwatch();

            clock.Start();
            grain = GrainClient.GrainFactory.GetGrain<IEchoTaskGrain>(Guid.NewGuid());
            logger.Info("CreateGrain took " + clock.Elapsed);

            clock.Restart();
            string received = await grain.EchoAsync(expectedEcho);
            logger.Info("EchoGrain.Echo took " + clock.Elapsed);

            Assert.AreEqual(expectedEcho, received);
        }
示例#11
0
        public async Task EchoGrain_Echo()
        {
            Stopwatch clock = new Stopwatch();

            clock.Start();
            grain = this.GrainFactory.GetGrain <IEchoTaskGrain>(Guid.NewGuid());
            this.Logger.LogInformation("CreateGrain took {Elapsed}", clock.Elapsed);

            clock.Restart();
            string received = await grain.EchoAsync(expectedEcho);

            this.Logger.LogInformation("EchoGrain.Echo took {Elapsed}", clock.Elapsed);

            Assert.Equal(expectedEcho, received);
        }
示例#12
0
        public async Task EchoGrain_Echo()
        {
            Stopwatch clock = new Stopwatch();

            clock.Start();
            grain = GrainClient.GrainFactory.GetGrain <IEchoTaskGrain>(Guid.NewGuid());
            logger.Info("CreateGrain took " + clock.Elapsed);

            clock.Restart();
            string received = await grain.EchoAsync(expectedEcho);

            logger.Info("EchoGrain.Echo took " + clock.Elapsed);

            Assert.AreEqual(expectedEcho, received);
        }
示例#13
0
        // ---------- Utility functions ----------

        protected void RunPerfTest(int n, string testName, TimeSpan target,
                                   Func <IEchoTaskGrain, Task> actionNoState,
                                   Func <IPersistenceTestGrain, Task> actionMemory,
                                   Func <IMemoryStorageTestGrain, Task> actionMemoryStore,
                                   Func <IAzureStorageTestGrain, Task> actionAzureTable)
        {
            IEchoTaskGrain[]          noStateGrains     = new IEchoTaskGrain[n];
            IPersistenceTestGrain[]   memoryGrains      = new IPersistenceTestGrain[n];
            IAzureStorageTestGrain[]  azureStoreGrains  = new IAzureStorageTestGrain[n];
            IMemoryStorageTestGrain[] memoryStoreGrains = new IMemoryStorageTestGrain[n];

            for (int i = 0; i < n; i++)
            {
                Guid id = Guid.NewGuid();
                noStateGrains[i]     = this.GrainFactory.GetGrain <IEchoTaskGrain>(id);
                memoryGrains[i]      = this.GrainFactory.GetGrain <IPersistenceTestGrain>(id);
                azureStoreGrains[i]  = this.GrainFactory.GetGrain <IAzureStorageTestGrain>(id);
                memoryStoreGrains[i] = this.GrainFactory.GetGrain <IMemoryStorageTestGrain>(id);
            }

            TimeSpan baseline, elapsed;

            elapsed = baseline = TestUtils.TimeRun(n, TimeSpan.Zero, testName + " (No state)",
                                                   () => RunIterations(testName, n, i => actionNoState(noStateGrains[i])));

            elapsed = TestUtils.TimeRun(n, baseline, testName + " (Local Memory Store)",
                                        () => RunIterations(testName, n, i => actionMemory(memoryGrains[i])));

            elapsed = TestUtils.TimeRun(n, baseline, testName + " (Dev Store Grain Store)",
                                        () => RunIterations(testName, n, i => actionMemoryStore(memoryStoreGrains[i])));

            elapsed = TestUtils.TimeRun(n, baseline, testName + " (Azure Table Store)",
                                        () => RunIterations(testName, n, i => actionAzureTable(azureStoreGrains[i])));

            if (elapsed > target.Multiply(timingFactor))
            {
                string msg = string.Format("{0}: Elapsed time {1} exceeds target time {2}", testName, elapsed, target);

                if (elapsed > target.Multiply(2.0 * timingFactor))
                {
                    Assert.True(false, msg);
                }
                else
                {
                    throw new SkipException(msg);
                }
            }
        }
示例#14
0
        public async Task EchoGrain_PingSilo_Local()
        {
            Stopwatch clock = new Stopwatch();

            string what = "CreateGrain";

            clock.Start();
            grain = this.GrainFactory.GetGrain <IEchoTaskGrain>(Guid.NewGuid());
            this.Logger.Info("{0} took {1}", what, clock.Elapsed);

            what = "EchoGrain.PingLocalSilo";
            clock.Restart();
            await grain.PingLocalSiloAsync().WithTimeout(timeout);

            this.Logger.Info("{0} took {1}", what, clock.Elapsed);
        }
示例#15
0
        public async Task EchoGrain_PingSilo_OtherSilo_Membership()
        {
            Stopwatch clock = new Stopwatch();

            string what = "CreateGrain";

            clock.Start();
            grain = GrainClient.GrainFactory.GetGrain <IEchoTaskGrain>(Guid.NewGuid());
            logger.Info("{0} took {1}", what, clock.Elapsed);

            what = "EchoGrain.PingOtherSiloMembership";
            clock.Restart();
            await grain.PingClusterMemberAsync().WithTimeout(timeout);

            logger.Info("{0} took {1}", what, clock.Elapsed);
        }
示例#16
0
        public void EchoGrain_EchoError()
        {
            grain = GrainClient.GrainFactory.GetGrain<IEchoTaskGrain>(Guid.NewGuid());
        
            Task<string> promise = grain.EchoErrorAsync(expectedEchoError);
            bool ok = promise.ContinueWith(t =>
            {
                if (!t.IsFaulted) Assert.Fail("EchoError should not have completed successfully");

                Exception exc = t.Exception;
                while (exc is AggregateException) exc = exc.InnerException;
                string received = exc.Message;
                Assert.AreEqual(expectedEchoError, received);
            }).Wait(timeout);
            Assert.IsTrue(ok, "Finished OK");
        }
示例#17
0
        public async Task EchoGrain_PingSilo_OtherSilo()
        {
            Stopwatch clock = new Stopwatch();

            string what = "CreateGrain";

            clock.Start();
            grain = this.GrainFactory.GetGrain <IEchoTaskGrain>(Guid.NewGuid());
            this.Logger.LogInformation("{What} took {Elapsed}", what, clock.Elapsed);

            what = "EchoGrain.PingOtherSilo";
            clock.Restart();
            await grain.PingOtherSiloAsync().WithTimeout(timeout);

            this.Logger.LogInformation("{What} took {Elapsed}", what, clock.Elapsed);
        }
示例#18
0
        public async Task EchoGrain_EchoError()
        {
            grain = this.GrainFactory.GetGrain <IEchoTaskGrain>(Guid.NewGuid());

            Task <string> promise = grain.EchoErrorAsync(expectedEchoError);
            await promise.ContinueWith(t =>
            {
                if (!t.IsFaulted)
                {
                    Assert.True(false);               // EchoError should not have completed successfully
                }
                Exception exc = t.Exception;
                while (exc is AggregateException)
                {
                    exc = exc.InnerException;
                }
                string received = exc.Message;
                Assert.Equal(expectedEchoError, received);
            }).WithTimeout(timeout);
        }
示例#19
0
        public void EchoGrain_EchoError()
        {
            grain = GrainClient.GrainFactory.GetGrain <IEchoTaskGrain>(Guid.NewGuid());

            Task <string> promise = grain.EchoErrorAsync(expectedEchoError);
            bool          ok      = promise.ContinueWith(t =>
            {
                if (!t.IsFaulted)
                {
                    Assert.Fail("EchoError should not have completed successfully");
                }

                Exception exc = t.Exception;
                while (exc is AggregateException)
                {
                    exc = exc.InnerException;
                }
                string received = exc.Message;
                Assert.AreEqual(expectedEchoError, received);
            }).Wait(timeout);

            Assert.IsTrue(ok, "Finished OK");
        }
示例#20
0
        public void EchoGrain_Timeout_Wait()
        {
            grain = GrainClient.GrainFactory.GetGrain<IEchoTaskGrain>(Guid.NewGuid());
        
            TimeSpan delay30 = TimeSpan.FromSeconds(30); // grain call timeout (set in config)
            TimeSpan delay45 = TimeSpan.FromSeconds(45);
            TimeSpan delay60 = TimeSpan.FromSeconds(60);
            Stopwatch sw = new Stopwatch();
            sw.Start();
            Task<int> promise = grain.BlockingCallTimeoutAsync(delay60);
            bool ok = promise.ContinueWith(t =>
            {
                if (!t.IsFaulted) Assert.Fail("BlockingCallTimeout should not have completed successfully");

                Exception exc = t.Exception;
                while (exc is AggregateException) exc = exc.InnerException;
                Assert.IsInstanceOfType(exc, typeof(TimeoutException), "Received exception type: {0}", exc);
            }).Wait(delay45);
            sw.Stop();
            Assert.IsTrue(ok, "Wait should not have timed-out. The grain call should have time out.");
            Assert.IsTrue(TimeIsLonger(sw.Elapsed, delay30), "Elapsted time out of range: {0}", sw.Elapsed);
            Assert.IsTrue(TimeIsShorter(sw.Elapsed, delay60), "Elapsted time out of range: {0}", sw.Elapsed);
        }
示例#21
0
        public void EchoGrain_Timeout_Wait()
        {
            grain = GrainClient.GrainFactory.GetGrain<IEchoTaskGrain>(Guid.NewGuid());
        
            TimeSpan delay30 = TimeSpan.FromSeconds(30); // grain call timeout (set in config)
            TimeSpan delay45 = TimeSpan.FromSeconds(45);
            TimeSpan delay60 = TimeSpan.FromSeconds(60);
            Stopwatch sw = new Stopwatch();
            sw.Start();
            Task<int> promise = grain.BlockingCallTimeoutAsync(delay60);
            bool ok = promise.ContinueWith(t =>
            {
                if (!t.IsFaulted) Assert.True(false); // BlockingCallTimeout should not have completed successfully

                Exception exc = t.Exception;
                while (exc is AggregateException) exc = exc.InnerException;
                Assert.IsAssignableFrom<TimeoutException>(exc);
            }).Wait(delay45);
            sw.Stop();
            Assert.True(ok); // Wait should not have timed-out. The grain call should have time out.
            Assert.True(TimeIsLonger(sw.Elapsed, delay30), $"Elapsed time out of range: {sw.Elapsed}");
            Assert.True(TimeIsShorter(sw.Elapsed, delay60), $"Elapsed time out of range: {sw.Elapsed}");
        }
        // ---------- Utility functions ----------

        private void RunPerfTest(int n, string testName, TimeSpan target,
            Func<IEchoTaskGrain, Task> actionNoState,
            Func<IPersistenceTestGrain, Task> actionMemory,
            Func<IMemoryStorageTestGrain, Task> actionMemoryStore,
            Func<IAzureStorageTestGrain, Task> actionAzureTable)
        {
            IEchoTaskGrain[] noStateGrains = new IEchoTaskGrain[n];
            IPersistenceTestGrain[] memoryGrains = new IPersistenceTestGrain[n];
            IAzureStorageTestGrain[] azureStoreGrains = new IAzureStorageTestGrain[n];
            IMemoryStorageTestGrain[] memoryStoreGrains = new IMemoryStorageTestGrain[n];

            for (int i = 0; i < n; i++)
            {
                Guid id = Guid.NewGuid();
                noStateGrains[i] = GrainClient.GrainFactory.GetGrain<IEchoTaskGrain>(id);
                memoryGrains[i] = GrainClient.GrainFactory.GetGrain<IPersistenceTestGrain>(id);
                azureStoreGrains[i] = GrainClient.GrainFactory.GetGrain<IAzureStorageTestGrain>(id);
                memoryStoreGrains[i] = GrainClient.GrainFactory.GetGrain<IMemoryStorageTestGrain>(id);
            }

            TimeSpan baseline, elapsed;

            elapsed = baseline = TestUtils.TimeRun(n, TimeSpan.Zero, testName + " (No state)",
                () => RunIterations(testName, n, i => actionNoState(noStateGrains[i])));

            elapsed = TestUtils.TimeRun(n, baseline, testName + " (Local Memory Store)",
                () => RunIterations(testName, n, i => actionMemory(memoryGrains[i])));

            elapsed = TestUtils.TimeRun(n, baseline, testName + " (Dev Store Grain Store)",
                () => RunIterations(testName, n, i => actionMemoryStore(memoryStoreGrains[i])));

            elapsed = TestUtils.TimeRun(n, baseline, testName + " (Azure Table Store)",
                () => RunIterations(testName, n, i => actionAzureTable(azureStoreGrains[i])));

            if (elapsed > target.Multiply(timingFactor))
            {
                string msg = string.Format("{0}: Elapsed time {1} exceeds target time {2}", testName, elapsed, target);

                if (elapsed > target.Multiply(2.0 * timingFactor))
                {
                    Assert.Fail(msg);
                }
                else
                {
                    Assert.Inconclusive(msg);
                }
            }
        }
示例#23
0
        public async Task EchoGrain_PingSilo_Remote()
        {
            Stopwatch clock = new Stopwatch();

            string what = "CreateGrain";
            clock.Start();
            grain = GrainClient.GrainFactory.GetGrain<IEchoTaskGrain>(Guid.NewGuid());
            logger.Info("{0} took {1}", what, clock.Elapsed);

            SiloAddress silo1 = HostedCluster.Primary.Silo.SiloAddress;
            SiloAddress silo2 = HostedCluster.SecondarySilos[0].Silo.SiloAddress;

            what = "EchoGrain.PingRemoteSilo[1]";
            clock.Restart();
            await grain.PingRemoteSiloAsync(silo1).WithTimeout(timeout);
            logger.Info("{0} took {1}", what, clock.Elapsed);

            what = "EchoGrain.PingRemoteSilo[2]";
            clock.Restart();
            await grain.PingRemoteSiloAsync(silo2).WithTimeout(timeout);
            logger.Info("{0} took {1}", what, clock.Elapsed);
        }
示例#24
0
        public async Task EchoGrain_PingSilo_OtherSilo_Membership()
        {
            Stopwatch clock = new Stopwatch();

            string what = "CreateGrain";
            clock.Start();
            grain = GrainClient.GrainFactory.GetGrain<IEchoTaskGrain>(Guid.NewGuid());
            logger.Info("{0} took {1}", what, clock.Elapsed);

            what = "EchoGrain.PingOtherSiloMembership";
            clock.Restart();
            await grain.PingClusterMemberAsync().WithTimeout(timeout);
            logger.Info("{0} took {1}", what, clock.Elapsed);
        }
示例#25
0
 public void EchoGrain_GetGrain()
 {
     grain = GrainClient.GrainFactory.GetGrain<IEchoTaskGrain>(Guid.NewGuid());
 }
示例#26
0
 public async Task EchoGrain_Timeout_Await()
 {
     grain = GrainClient.GrainFactory.GetGrain<IEchoTaskGrain>(Guid.NewGuid());
     
     TimeSpan delay30 = TimeSpan.FromSeconds(30);
     TimeSpan delay60 = TimeSpan.FromSeconds(60);
     Stopwatch sw = new Stopwatch();
     sw.Start();
     try
     {
         int res = await grain.BlockingCallTimeoutAsync(delay60);
         Assert.True(false); // BlockingCallTimeout should not have completed successfully
     }
     catch (Exception exc)
     {
         while (exc is AggregateException) exc = exc.InnerException;
         Assert.IsAssignableFrom<TimeoutException>(exc);
     }
     sw.Stop();
     Assert.True(TimeIsLonger(sw.Elapsed, delay30), $"Elapsed time out of range: {sw.Elapsed}");
     Assert.True(TimeIsShorter(sw.Elapsed, delay60), $"Elapsed time out of range: {sw.Elapsed}");
 }
示例#27
0
 public void EchoGrain_GetGrain()
 {
     grain = GrainClient.GrainFactory.GetGrain <IEchoTaskGrain>(Guid.NewGuid());
 }
示例#28
0
 public async Task EchoGrain_Timeout_Await()
 {
     grain = GrainClient.GrainFactory.GetGrain<IEchoTaskGrain>(Guid.NewGuid());
     
     TimeSpan delay30 = TimeSpan.FromSeconds(30);
     TimeSpan delay60 = TimeSpan.FromSeconds(60);
     Stopwatch sw = new Stopwatch();
     sw.Start();
     try
     {
         int res = await grain.BlockingCallTimeoutAsync(delay60);
         Assert.Fail("BlockingCallTimeout should not have completed successfully");
     }
     catch (Exception exc)
     {
         while (exc is AggregateException) exc = exc.InnerException;
         Assert.IsInstanceOfType(exc, typeof(TimeoutException), "Received exception type: {0}", exc);
     }
     sw.Stop();
     Assert.IsTrue(TimeIsLonger(sw.Elapsed, delay30), "Elapsted time out of range: {0}", sw.Elapsed);
     Assert.IsTrue(TimeIsShorter(sw.Elapsed, delay60), "Elapsted time out of range: {0}", sw.Elapsed);
 }