Ejemplo n.º 1
0
        public void StorageTransientErrorDetectionStrategyWebExceptionTest()
        {
            WebExceptionStatus[] allWebExceptionStatusValues = (WebExceptionStatus[])Enum.GetValues(typeof(WebExceptionStatus));

            StorageTransientErrorDetectionStrategy strategy = new StorageTransientErrorDetectionStrategy();

            foreach (WebExceptionStatus status in allWebExceptionStatusValues)
            {
                if (status == WebExceptionStatus.ProtocolError)
                {
                    // This is covered in a separate test
                    continue;
                }

                WebException exception = new WebException("Simulated WebException with " + status.ToString(), status);

                if (strategy.IsTransient(exception))
                {
                    Assert.IsTrue(QueryErrorDetectionStrategyTest.SupportedRetryableWebExceptions.Contains(exception.Status), exception.Status.ToString());
                }
                else
                {
                    Assert.IsFalse(QueryErrorDetectionStrategyTest.SupportedRetryableWebExceptions.Contains(exception.Status), exception.Status.ToString());
                }
            }
        }
Ejemplo n.º 2
0
        public void StorageTransientErrorDetectionStrategyDataServiceTransportExceptionTest()
        {
            HttpStatusCode[] allHttpStatusCodeValues = (HttpStatusCode[])Enum.GetValues(typeof(HttpStatusCode));

            StorageTransientErrorDetectionStrategy strategy = new StorageTransientErrorDetectionStrategy();

            foreach (HttpStatusCode status in allHttpStatusCodeValues)
            {
                DataServiceTransportException exception = QueryErrorDetectionStrategyTest.GetMockedTransportException(status);

                Assert.IsFalse(strategy.IsTransient(exception));
            }
        }
Ejemplo n.º 3
0
        public void then_error_is_not_transient()
        {
            var client = account.CreateCloudBlobClient();

            client.RetryPolicy = new NoRetry();

            try
            {
                this.account.CreateCloudBlobClient().ListContainers().ToList();

                Assert.Fail("Exception not thrown");
            }
            catch (StorageException ex)
            {
                Assert.IsInstanceOfType(ex.InnerException, typeof(WebException));
                Assert.IsFalse(strategy.IsTransient(ex), ex.ToString());
            }
        }
Ejemplo n.º 4
0
        public void StorageTransientErrorDetectionStrategyTestStorageException()
        {
            List <String> allStorageErrorCodeStrings = GetAllStorageErrorStringConstants();

            StorageTransientErrorDetectionStrategy strategy = new StorageTransientErrorDetectionStrategy();

            foreach (string errorString in allStorageErrorCodeStrings)
            {
                var exception = GetSimulatedStorageTransientErrorDetectionStrategy(errorString);

                if (strategy.IsTransient(exception))
                {
                    Assert.IsTrue(SupportedRetryableStorageErrorStrings.Contains(errorString));
                }
                else
                {
                    Assert.IsFalse(SupportedRetryableStorageErrorStrings.Contains(errorString));
                }
            }
        }
Ejemplo n.º 5
0
        public void StorageTransientErrorDetectionStrategyDataServiceClientExceptionTestByStatusCode()
        {
            HttpStatusCode[] allHttpStatusCodeValues = (HttpStatusCode[])Enum.GetValues(typeof(HttpStatusCode));

            StorageTransientErrorDetectionStrategy strategy = new StorageTransientErrorDetectionStrategy();

            foreach (HttpStatusCode status in allHttpStatusCodeValues)
            {
                DataServiceClientException exception = QueryErrorDetectionStrategyTest.GetMockedClientException(status);

                if (strategy.IsTransient(exception))
                {
                    Assert.IsTrue(SupportedRetryableHttpStatusCodes.Contains(status), status.ToString());
                }
                else
                {
                    Assert.IsFalse(SupportedRetryableHttpStatusCodes.Contains(status), status.ToString());
                }
            }
        }
Ejemplo n.º 6
0
        public void StorageTransientErrorDetectionStrategyDataServiceClientExceptionTestByErrorString()
        {
            List <String> allStorageErrorCodeStrings = GetAllStorageErrorStringConstants();

            StorageTransientErrorDetectionStrategy strategy = new StorageTransientErrorDetectionStrategy();

            foreach (string errorString in allStorageErrorCodeStrings)
            {
                var innerException = new Exception(FormatErrorString(errorString));
                var exception      = new DataServiceQueryException("Simulated DataServiceQueryException", innerException);

                if (strategy.IsTransient(exception))
                {
                    Assert.IsTrue(SupportedRetryableStorageErrorStrings.Contains(errorString));
                }
                else
                {
                    Assert.IsFalse(SupportedRetryableStorageErrorStrings.Contains(errorString));
                }
            }
        }
 private bool IsTransientInner(Exception exception)
 {
     return(this.CustomStrategyIsTransient(exception) || SqlDatabaseStrategy.IsTransient(exception) || StorageStrategy.IsTransient(exception));
 }