Esempio n. 1
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);
        }
Esempio n. 2
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}");
        }
Esempio n. 3
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);
        }
Esempio n. 4
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}");
        }
Esempio n. 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);
        }
Esempio n. 6
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}");
        }
Esempio n. 7
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);
 }
Esempio n. 8
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}");
 }