public void NullRetryPolicyTest()
        {
            CloudBlobContainer container = BlobTestBase.GetRandomContainerReference();

            container.ServiceClient.RetryPolicy = null;
            container.Exists();
        }
Esempio n. 2
0
        private static void TestContainerFetchAttributes(LocationMode?optionsLocationMode, LocationMode clientLocationMode, StorageLocation initialLocation, IList <RetryContext> retryContextList, IList <RetryInfo> retryInfoList)
        {
            CloudBlobContainer container = BlobTestBase.GetRandomContainerReference();

            using (MultiLocationTestHelper helper = new MultiLocationTestHelper(container.ServiceClient.StorageUri, initialLocation, retryContextList, retryInfoList))
            {
                container.ServiceClient.LocationMode = clientLocationMode;
                BlobRequestOptions options = new BlobRequestOptions()
                {
                    LocationMode = optionsLocationMode,
                    RetryPolicy  = helper.RetryPolicy,
                };

                TestHelper.ExpectedException(
                    () => container.FetchAttributes(null, options, helper.OperationContext),
                    "FetchAttributes on a non-existing container should fail",
                    HttpStatusCode.NotFound);
            }
        }
        public void RetryPolicyEnsure304IsNotRetried()
        {
            CloudBlobContainer container = BlobTestBase.GetRandomContainerReference();

            container.Create();

            try
            {
                CloudBlockBlob blob = container.GetBlockBlobReference("blob");
                blob.UploadFromStream(new MemoryStream(new byte[50]));

                AccessCondition  accessCondition = AccessCondition.GenerateIfModifiedSinceCondition(blob.Properties.LastModified.Value.AddMinutes(10));
                OperationContext context         = new OperationContext();

                TestHelper.ExpectedException(
                    () => blob.FetchAttributes(accessCondition, new BlobRequestOptions()
                {
                    RetryPolicy = new ExponentialRetry()
                }, context),
                    "FetchAttributes with invalid modified condition should return NotModified",
                    HttpStatusCode.NotModified);

                TestHelper.AssertNAttempts(context, 1);


                context = new OperationContext();

                TestHelper.ExpectedException(
                    () => blob.FetchAttributes(accessCondition, new BlobRequestOptions()
                {
                    RetryPolicy = new LinearRetry()
                }, context),
                    "FetchAttributes with invalid modified condition should return NotModified",
                    HttpStatusCode.NotModified);

                TestHelper.AssertNAttempts(context, 1);
            }
            finally
            {
                container.Delete();
            }
        }
Esempio n. 4
0
        public void BlobIfExistsShouldNotHitSecondary()
        {
            AssertSecondaryEndpoint();

            BlobRequestOptions options = new BlobRequestOptions();

            CloudBlobContainer container = BlobTestBase.GetRandomContainerReference();

            TestPrimaryOnlyCommand((opt, ctx) => container.CreateIfNotExists(opt, ctx), options);
            TestPrimaryOnlyCommand((opt, ctx) => container.EndCreateIfNotExists(container.BeginCreateIfNotExists(opt, ctx, null, null)), options);
            TestPrimaryOnlyCommand((opt, ctx) => container.DeleteIfExists(null, opt, ctx), options);
            TestPrimaryOnlyCommand((opt, ctx) => container.EndDeleteIfExists(container.BeginDeleteIfExists(null, opt, ctx, null, null)), options);

            CloudBlockBlob blockBlob = container.GetBlockBlobReference("blob1");

            TestPrimaryOnlyCommand((opt, ctx) => blockBlob.DeleteIfExists(DeleteSnapshotsOption.None, null, opt, ctx), options);
            TestPrimaryOnlyCommand((opt, ctx) => blockBlob.EndDeleteIfExists(blockBlob.BeginDeleteIfExists(DeleteSnapshotsOption.None, null, opt, ctx, null, null)), options);

            CloudPageBlob pageBlob = container.GetPageBlobReference("blob2");

            TestPrimaryOnlyCommand((opt, ctx) => pageBlob.DeleteIfExists(DeleteSnapshotsOption.None, null, opt, ctx), options);
            TestPrimaryOnlyCommand((opt, ctx) => pageBlob.EndDeleteIfExists(pageBlob.BeginDeleteIfExists(DeleteSnapshotsOption.None, null, opt, ctx, null, null)), options);
        }