コード例 #1
0
        public void TableOperationExecuteRetrySync()
        {
            CloudTableClient   tableClient  = GenerateCloudTableClient();
            DynamicTableEntity insertEntity = new DynamicTableEntity("insert test", "foo");

            for (int m = 0; m < 20; m++)
            {
                insertEntity.Properties.Add("prop" + m.ToString(), new EntityProperty(new byte[50 * 1024]));
            }

            TestHelper.ExecuteMethodWithRetry(
                3,
                new[] {
                //Insert upstream network delay to prevent upload to server @ 1000ms / kb
                PerformanceBehaviors.InsertUpstreamNetworkDelay(10000,
                                                                AzureStorageSelectors.TableTraffic().IfHostNameContains(tableClient.Credentials.AccountName),
                                                                new BehaviorOptions(2)),
                // After 500 ms return throttle message
                DelayedActionBehaviors.ExecuteAfter(Actions.ThrottleTableRequest,
                                                    100,
                                                    AzureStorageSelectors.TableTraffic().IfHostNameContains(tableClient.Credentials.AccountName),
                                                    new BehaviorOptions(2))
            },
                (options, opContext) => currentTable.Execute(TableOperation.Insert(insertEntity), (TableRequestOptions)options, opContext));
        }
コード例 #2
0
        public void OpContextTestCustomUserAgent()
        {
            CloudBlobClient    blobClient = GenerateCloudBlobClient();
            CloudBlobContainer container  = blobClient.GetContainerReference("test");

            string uniqueID = Guid.NewGuid().ToString();

            OperationContext ctx = new OperationContext();

            ctx.CustomUserAgent = "product-info-correct-format";
            string userAgentValue = ctx.CustomUserAgent + " " + Microsoft.Azure.Storage.Shared.Protocol.Constants.HeaderConstants.UserAgent;

            Action act = () => container.Exists(null, ctx);

            TestHelper.VerifyHeaderWasSent("User-Agent", userAgentValue, AzureStorageSelectors.BlobTraffic().IfHostNameContains(blobClient.Credentials.AccountName), act);

            act = () => container.EndExists(container.BeginExists(null, ctx, null, null));

            TestHelper.VerifyHeaderWasSent("User-Agent", userAgentValue, AzureStorageSelectors.BlobTraffic().IfHostNameContains(blobClient.Credentials.AccountName), act);

#if TASK
            act = () => container.ExistsAsync(null, ctx).Wait();

            TestHelper.VerifyHeaderWasSent("User-Agent", userAgentValue, AzureStorageSelectors.BlobTraffic().IfHostNameContains(blobClient.Credentials.AccountName), act);
#endif
        }
コード例 #3
0
        public void TableQueryWithRetrySync()
        {
            CloudTableClient    tableClient = GenerateCloudTableClient();
            TableBatchOperation batch       = new TableBatchOperation();

            for (int m = 0; m < 1500; m++)
            {
                // Insert Entity
                DynamicTableEntity insertEntity = new DynamicTableEntity("insert test", m.ToString());
                batch.Insert(insertEntity);

                if ((m + 1) % 100 == 0)
                {
                    currentTable.ExecuteBatch(batch);
                    batch = new TableBatchOperation();
                }
            }

            TableQuery query = new TableQuery().Where(TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, "insert test"));

            TestHelper.ExecuteMethodWithRetry(
                4, // 2 segments, 2 failures
                new[] {
                //Insert upstream network delay to prevent upload to server @ 1000ms / kb
                PerformanceBehaviors.InsertDownstreamNetworkDelay(10000,
                                                                  AzureStorageSelectors.TableTraffic().IfHostNameContains(tableClient.Credentials.AccountName).Alternating(true),
                                                                  new BehaviorOptions(4)),
                // After 100 ms return throttle message
                DelayedActionBehaviors.ExecuteAfter(Actions.ThrottleTableRequest,
                                                    100,
                                                    AzureStorageSelectors.TableTraffic().IfHostNameContains(tableClient.Credentials.AccountName).Alternating(true),
                                                    new BehaviorOptions(4))
            },
                (options, opContext) => currentTable.ExecuteQuery(query, (TableRequestOptions)options, opContext).ToList());
        }
コード例 #4
0
        public void A00XStoreThrottleTest()
        {
            string entityPartitionKey = "jobType-XStoreThrottleTest";
            string entityRowKey       = "jobId-XStoreThrottleTest";

            this.ForceDeleteEntryFromStorageTablesDirectly(entityPartitionKey, entityRowKey);

            int  targetStorageAccount    = 0;
            bool targetApiExpectedToFail = true;

            Assert.IsTrue(0 <= targetStorageAccount && targetStorageAccount < this.actualStorageAccountsUsed.Count,
                          "targetStorageAccount={0} is out-of-range", targetStorageAccount);
            int    index = this.actualStorageAccountsUsed[targetStorageAccount];
            string accountNameToTamper = this.rtableTestConfiguration.StorageInformation.AccountNames[index];

            Console.WriteLine("accountNameToTamper={0}", accountNameToTamper);

            // Throttle behavior
            ProxyBehavior[] behaviors = new[]
            {
                TamperBehaviors.TamperAllRequestsIf(
                    Actions.ThrottleTableRequest,
                    AzureStorageSelectors.TableTraffic().IfHostNameContains(accountNameToTamper))
            };

            this.SetupAndRunXStoreHttpManglerTest(
                entityPartitionKey,
                entityRowKey,
                targetStorageAccount,
                targetApiExpectedToFail,
                behaviors);
        }
コード例 #5
0
ファイル: TableRetryTests.cs プロジェクト: Ankitvaibs/SM
        public void TableServiceQueryWithRetryAPM()
        {
            CloudTableClient    tableClient = GenerateCloudTableClient();
            TableServiceContext ctx         = tableClient.GetTableServiceContext();

            for (int m = 0; m < 1000; m++)
            {
                // Insert Entity
                ComplexEntity insertEntity = new ComplexEntity("insert test", m.ToString());
                ctx.AddObject(currentTable.Name, insertEntity);

                if ((m + 1) % 100 == 0)
                {
                    ctx.SaveChangesWithRetries(SaveChangesOptions.Batch);
                }
            }

            TableServiceQuery <ComplexEntity> query = (from ent in ctx.CreateQuery <ComplexEntity>(currentTable.Name)
                                                       select ent).AsTableServiceQuery(ctx);

            TestHelper.ExecuteAPMMethodWithRetry(
                2, // 1 failure, one success
                new[] {
                //Insert upstream network delay to prevent upload to server @ 1000ms / kb
                PerformanceBehaviors.InsertDownstreamNetworkDelay(10000,
                                                                  AzureStorageSelectors.TableTraffic().IfHostNameContains(tableClient.Credentials.AccountName).Alternating(true)),
                // After 100 ms return throttle message
                DelayedActionBehaviors.ExecuteAfter(Actions.ThrottleTableRequest,
                                                    100,
                                                    AzureStorageSelectors.TableTraffic().IfHostNameContains(tableClient.Credentials.AccountName).Alternating(true))
            },
                (options, opContext, callback, state) => query.BeginExecuteSegmented(null, (TableRequestOptions)options, opContext, callback, state),
                query.EndExecuteSegmented);
        }
コード例 #6
0
ファイル: TableRetryTests.cs プロジェクト: Ankitvaibs/SM
        public void TableServiceContextSaveChangesRetryAPM()
        {
            CloudTableClient    tableClient = GenerateCloudTableClient();
            TableServiceContext ctx         = tableClient.GetTableServiceContext();

            for (int m = 0; m < 100; m++)
            {
                // Insert Entity
                ComplexEntity insertEntity = new ComplexEntity("insert test", m.ToString());
                insertEntity.Binary = new byte[20 * 1024];
                ctx.AddObject(currentTable.Name, insertEntity);
            }

            TestHelper.ExecuteAPMMethodWithRetry(3,
                                                 new[] {
                //Insert upstream network delay to prevent upload to server @ 1000ms / kb
                PerformanceBehaviors.InsertUpstreamNetworkDelay(10000,
                                                                AzureStorageSelectors.TableTraffic().IfHostNameContains(tableClient.Credentials.AccountName),
                                                                new BehaviorOptions(2)),
                // After 500 ms return throttle message
                DelayedActionBehaviors.ExecuteAfter(Actions.ThrottleTableRequest,
                                                    100,
                                                    AzureStorageSelectors.TableTraffic().IfHostNameContains(tableClient.Credentials.AccountName),
                                                    new BehaviorOptions(2))
            },
                                                 (options, opContext, callback, state) => ctx.BeginSaveChangesWithRetries(SaveChangesOptions.Batch, (TableRequestOptions)options, opContext, callback, state),
                                                 (res) => ctx.EndSaveChangesWithRetries(res));
        }
コード例 #7
0
        public void TableQueryWithRetryAPM()
        {
            CloudTableClient    tableClient = GenerateCloudTableClient();
            TableBatchOperation batch       = new TableBatchOperation();

            for (int m = 0; m < 1500; m++)
            {
                // Insert Entity
                DynamicTableEntity insertEntity = new DynamicTableEntity("insert test", m.ToString());
                insertEntity.Properties.Add("prop" + m.ToString(), new EntityProperty(new byte[1 * 1024]));
                batch.Insert(insertEntity);

                if ((m + 1) % 100 == 0)
                {
                    currentTable.ExecuteBatch(batch);
                    batch = new TableBatchOperation();
                }
            }

            TableQuery query = new TableQuery().Where(TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, "insert test"));

            TestHelper.ExecuteAPMMethodWithRetry(
                2, // 1 failure, one success
                new[] {
                //Insert upstream network delay to prevent upload to server @ 1000ms / kb
                PerformanceBehaviors.InsertDownstreamNetworkDelay(10000,
                                                                  AzureStorageSelectors.TableTraffic().IfHostNameContains(tableClient.Credentials.AccountName).Alternating(true)),
                // After 100 ms return throttle message
                DelayedActionBehaviors.ExecuteAfter(Actions.ThrottleTableRequest,
                                                    100,
                                                    AzureStorageSelectors.TableTraffic().IfHostNameContains(tableClient.Credentials.AccountName).Alternating(true))
            },
                (options, opContext, callback, state) => currentTable.BeginExecuteQuerySegmented(query, null, (TableRequestOptions)options, opContext, callback, state),
                (res) => currentTable.EndExecuteQuerySegmented(res));
        }
コード例 #8
0
        public void OpContextTestClientRequestIDOnQueue()
        {
            CloudQueueClient qClient = GenerateCloudQueueClient();
            CloudQueue       queue   = qClient.GetQueueReference("test");

            string uniqueID = Guid.NewGuid().ToString();

            Action act = () => queue.Exists(null, new OperationContext()
            {
                ClientRequestID = uniqueID
            });

            TestHelper.VerifyHeaderWasSent("x-ms-client-request-id", uniqueID, AzureStorageSelectors.QueueTraffic().IfHostNameContains(qClient.Credentials.AccountName), act);

            act = () => queue.EndExists(queue.BeginExists(null, new OperationContext()
            {
                ClientRequestID = uniqueID
            }, null, null));

            TestHelper.VerifyHeaderWasSent("x-ms-client-request-id", uniqueID, AzureStorageSelectors.QueueTraffic().IfHostNameContains(qClient.Credentials.AccountName), act);

#if TASK
            act = () => queue.ExistsAsync(null, new OperationContext()
            {
                ClientRequestID = uniqueID
            }).Wait();

            TestHelper.VerifyHeaderWasSent("x-ms-client-request-id", uniqueID, AzureStorageSelectors.QueueTraffic().IfHostNameContains(qClient.Credentials.AccountName), act);
#endif
        }
コード例 #9
0
        public void TableOperationNoRetry()
        {
            CloudTableClient tableClient = GenerateCloudTableClient();

            tableClient.DefaultRequestOptions.RetryPolicy = new NoRetry();
            CloudTable currentTable = tableClient.GetTableReference("noretrytable");

            currentTable.CreateIfNotExists();
            DynamicTableEntity insertEntity = new DynamicTableEntity("insert test", "foo");

            currentTable.Execute(TableOperation.Insert(insertEntity));
            TableQuery query = new TableQuery().Where(TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, "insert test"));

            try
            {
                TestHelper.ExecuteMethodWithRetry(
                    1,
                    new[] {
                    //Insert upstream network delay to prevent upload to server @ 1000ms / kb
                    PerformanceBehaviors.InsertDownstreamNetworkDelay(10000,
                                                                      AzureStorageSelectors.TableTraffic().IfHostNameContains(tableClient.Credentials.AccountName).Alternating(true)),
                    // After 100 ms return throttle message
                    DelayedActionBehaviors.ExecuteAfter(Actions.ThrottleTableRequest,
                                                        100,
                                                        AzureStorageSelectors.TableTraffic().IfHostNameContains(tableClient.Credentials.AccountName).Alternating(true))
                },
                    (options, opContext) => currentTable.ExecuteQuery(query, (TableRequestOptions)options, opContext).ToList());
            }
            catch (StorageException ex)
            {
                Assert.IsTrue(ex.RequestInformation.HttpStatusCode == 503);
            }
            finally
            {
                currentTable.DeleteIfExists();
            }
        }
コード例 #10
0
        public void TableServiceContextTimeoutDuringSaveChangesNonBatchAPM()
        {
            CloudTableClient    tableClient = GenerateCloudTableClient();
            TableServiceContext ctx         = tableClient.GetTableServiceContext();

            for (int m = 0; m < 100; m++)
            {
                BaseEntity ent = new BaseEntity("testpartition", m.ToString());
                ent.Randomize();
                ent.A = ent.RowKey;
                ctx.AddObject(currentTable.Name, ent);
            }

            OperationContext    opContext      = new OperationContext();
            TableRequestOptions requestOptions = new TableRequestOptions()
            {
                MaximumExecutionTime = TimeSpan.FromSeconds(5)
            };

            using (HttpMangler proxy = new HttpMangler(false,
                                                       new[] { DelayBehaviors.DelayAllRequestsIf(2000, AzureStorageSelectors.TableTraffic().IfHostNameContains(tableClient.Credentials.AccountName).SkipNSessions(10)) }))
            {
                try
                {
                    using (ManualResetEvent evt = new ManualResetEvent(false))
                    {
                        IAsyncResult result = ctx.BeginSaveChangesWithRetries(SaveChangesOptions.None, requestOptions, opContext,
                                                                              (res) =>
                        {
                            result = res;
                            evt.Set();
                        }, null);

                        evt.WaitOne();

                        ctx.EndSaveChangesWithRetries(result);
                    }

                    ctx.SaveChangesWithRetries(SaveChangesOptions.None, requestOptions, opContext);
                }
                catch (StorageException ex)
                {
                    Assert.AreEqual(ex.RequestInformation.HttpStatusCode, (int)HttpStatusCode.RequestTimeout);
                    Assert.AreEqual("The client could not finish the operation within specified timeout.", ex.Message);
                    Assert.IsTrue(ex.InnerException is TimeoutException);
                }
            }
        }
コード例 #11
0
        public void CloudBlockBlobDownloadRangeToStreamAPMRetry()
        {
            byte[]             buffer    = GetRandomBuffer(1 * 1024 * 1024);
            int                offset    = 1024;
            CloudBlobContainer container = GetRandomContainerReference();

            try
            {
                container.Create();

                CloudBlockBlob blob = container.GetBlockBlobReference("blob1");
                using (MemoryStream originalBlob = new MemoryStream(buffer))
                {
                    using (AutoResetEvent waitHandle = new AutoResetEvent(false))
                    {
                        ICancellableAsyncResult result = blob.BeginUploadFromStream(originalBlob,
                                                                                    ar => waitHandle.Set(),
                                                                                    null);
                        waitHandle.WaitOne();
                        blob.EndUploadFromStream(result);
                    }
                }

                using (MemoryStream originalBlob = new MemoryStream())
                {
                    originalBlob.Write(buffer, offset, buffer.Length - offset);

                    using (AutoResetEvent waitHandle = new AutoResetEvent(false))
                    {
                        Exception manglerEx = null;
                        using (HttpMangler proxy = new HttpMangler(false,
                                                                   new[]
                        {
                            TamperBehaviors.TamperNRequestsIf(
                                session => ThreadPool.QueueUserWorkItem(state =>
                            {
                                Thread.Sleep(1000);
                                try
                                {
                                    session.Abort();
                                }
                                catch (Exception e)
                                {
                                    manglerEx = e;
                                }
                            }),
                                2,
                                AzureStorageSelectors.BlobTraffic().IfHostNameContains(container.ServiceClient.Credentials.AccountName))
                        }))
                        {
                            foreach (var options in new[]
                            {
                                new BlobRequestOptions()
                                {
                                    ChecksumOptions =
                                        new ChecksumOptions
                                    {
                                        UseTransactionalMD5 = true,
                                        UseTransactionalCRC64 = false
                                    }
                                },
                                new BlobRequestOptions()
                                {
                                    ChecksumOptions =
                                        new ChecksumOptions
                                    {
                                        UseTransactionalMD5 = false,
                                        UseTransactionalCRC64 = true
                                    }
                                }
                            })
                            {
                                using (MemoryStream downloadedBlob = new MemoryStream())
                                {
                                    OperationContext operationContext = new OperationContext();

                                    ICancellableAsyncResult result = blob.BeginDownloadRangeToStream(downloadedBlob, offset, buffer.Length - offset, null, options, operationContext,
                                                                                                     ar => waitHandle.Set(),
                                                                                                     null);
                                    waitHandle.WaitOne();
                                    blob.EndDownloadToStream(result);
                                    TestHelper.AssertStreamsAreEqual(originalBlob, downloadedBlob);

                                    if (manglerEx != null)
                                    {
                                        throw manglerEx;
                                    }
                                }
                            }
                        }
                    }
                }
            }
            finally
            {
                container.DeleteIfExists();
            }
        }
コード例 #12
0
        public void TableGetACLCancellation()
        {
            CloudTableClient tableClient = GenerateCloudTableClient();

            CloudTable tbl = tableClient.GetTableReference(GenerateRandomTableName());

            TestHelper.ExecuteAPMMethodWithCancellation(4000,
                                                        new[] { DelayBehaviors.DelayAllRequestsIf(4000 * 3, AzureStorageSelectors.TableTraffic().IfHostNameContains(tableClient.Credentials.AccountName)) },
                                                        (options, opContext, callback, state) => tbl.BeginGetPermissions((TableRequestOptions)options, opContext, callback, state),
                                                        (res) => tbl.EndGetPermissions(res));
        }
コード例 #13
0
        public void TableSetACLCancellation()
        {
            CloudTableClient tableClient = GenerateCloudTableClient();

            CloudTable tbl = tableClient.GetTableReference(GenerateRandomTableName());

            TablePermissions perms = new TablePermissions();

            // Add a policy, check setting and getting.
            perms.SharedAccessPolicies.Add(Guid.NewGuid().ToString(), new SharedAccessTablePolicy
            {
                Permissions            = SharedAccessTablePermissions.Query,
                SharedAccessStartTime  = DateTimeOffset.Now - TimeSpan.FromHours(1),
                SharedAccessExpiryTime = DateTimeOffset.Now + TimeSpan.FromHours(1)
            });

            TestHelper.ExecuteAPMMethodWithCancellation(4000,
                                                        new[] { DelayBehaviors.DelayAllRequestsIf(4000 * 3, AzureStorageSelectors.TableTraffic().IfHostNameContains(tableClient.Credentials.AccountName)) },
                                                        (options, opContext, callback, state) => tbl.BeginSetPermissions(perms, (TableRequestOptions)options, opContext, callback, state),
                                                        tbl.EndSetPermissions);
        }
コード例 #14
0
        public void CloudBlobContainerSetMetadataAPMCancel()
        {
            CloudBlobContainer container = GetRandomContainerReference();

            try
            {
                container.Create();
                container.Metadata.Add("key1", "value1");

                TestHelper.ExecuteAPMMethodWithCancellation(4000,
                                                            new[] { DelayBehaviors.DelayAllRequestsIf(4000 * 3, AzureStorageSelectors.BlobTraffic().IfHostNameContains(container.ServiceClient.Credentials.AccountName)) },
                                                            (options, opContext, callback, state) => container.BeginSetMetadata(null, (BlobRequestOptions)options, opContext, callback, state),
                                                            container.EndSetMetadata);
            }
            finally
            {
                container.DeleteIfExists();
            }
        }
コード例 #15
0
ファイル: FileManglerUnitTests.cs プロジェクト: Ankitvaibs/SM
        public void CloudFileDownloadToStreamAPMRetry()
        {
            byte[]         buffer = GetRandomBuffer(1 * 1024 * 1024);
            CloudFileShare share  = GetRandomShareReference();

            try
            {
                share.Create();

                CloudFile file = share.GetRootDirectoryReference().GetFileReference("file1");
                using (MemoryStream originalFile = new MemoryStream(buffer))
                {
                    using (AutoResetEvent waitHandle = new AutoResetEvent(false))
                    {
                        ICancellableAsyncResult result = file.BeginUploadFromStream(originalFile,
                                                                                    ar => waitHandle.Set(),
                                                                                    null);
                        waitHandle.WaitOne();
                        file.EndUploadFromStream(result);

                        using (MemoryStream downloadedFile = new MemoryStream())
                        {
                            Exception manglerEx = null;
                            using (HttpMangler proxy = new HttpMangler(false,
                                                                       new[]
                            {
                                TamperBehaviors.TamperNRequestsIf(
                                    session => ThreadPool.QueueUserWorkItem(state =>
                                {
                                    Thread.Sleep(1000);
                                    try
                                    {
                                        session.Abort();
                                    }
                                    catch (Exception e)
                                    {
                                        manglerEx = e;
                                    }
                                }),
                                    2,
                                    AzureStorageSelectors.FileTraffic().IfHostNameContains(share.ServiceClient.Credentials.AccountName))
                            }))
                            {
                                OperationContext operationContext = new OperationContext();
                                result = file.BeginDownloadToStream(downloadedFile, null, null, operationContext,
                                                                    ar => waitHandle.Set(),
                                                                    null);
                                waitHandle.WaitOne();
                                file.EndDownloadToStream(result);
                                TestHelper.AssertStreamsAreEqual(originalFile, downloadedFile);
                            }

                            if (manglerEx != null)
                            {
                                throw manglerEx;
                            }
                        }
                    }
                }
            }
            finally
            {
                share.DeleteIfExists();
            }
        }
コード例 #16
0
        public void TableTestTableQueryCancellation()
        {
            CloudTableClient    tableClient = GenerateCloudTableClient();
            TableBatchOperation batch       = new TableBatchOperation();

            for (int m = 0; m < 100; m++)
            {
                // Insert Entity
                DynamicTableEntity insertEntity = new DynamicTableEntity("insert test", m.ToString());
                insertEntity.Properties.Add("prop" + m.ToString(), new EntityProperty(new byte[30 * 1024]));
                batch.Insert(insertEntity);
            }

            currentTable.ExecuteBatch(batch);
            TableQuery query = new TableQuery().Where(TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, "insert test"));

            TestHelper.ExecuteAPMMethodWithCancellation(4000,
                                                        new[] { DelayBehaviors.DelayAllRequestsIf(4000 * 3, AzureStorageSelectors.TableTraffic().IfHostNameContains(tableClient.Credentials.AccountName)) },
                                                        (options, opContext, callback, state) => currentTable.BeginExecuteQuerySegmented(query, null, (TableRequestOptions)options, opContext, callback, state),
                                                        (res) => currentTable.EndExecuteQuerySegmented(res));
        }
コード例 #17
0
        public void TableTestSegmentedQueryCancellation()
        {
            CloudTableClient    tableClient = GenerateCloudTableClient();
            TableServiceContext ctx         = tableClient.GetTableServiceContext();

            for (int m = 0; m < 100; m++)
            {
                // Insert Entity
                ComplexEntity insertEntity = new ComplexEntity("insert test", m.ToString());
                ctx.AddObject(currentTable.Name, insertEntity);
            }
            ctx.SaveChangesWithRetries();

            TableServiceQuery <ComplexEntity> query = (from ent in ctx.CreateQuery <ComplexEntity>(currentTable.Name)
                                                       select ent).AsTableServiceQuery(ctx);


            TestHelper.ExecuteAPMMethodWithCancellation(4000,
                                                        new[] { DelayBehaviors.DelayAllRequestsIf(4000 * 3, AzureStorageSelectors.TableTraffic().IfHostNameContains(tableClient.Credentials.AccountName)) },
                                                        (options, opContext, callback, state) => query.BeginExecuteSegmented(null, (TableRequestOptions)options, opContext, callback, state),
                                                        (res) => query.EndExecuteSegmented(res));
        }
コード例 #18
0
        public void QueueSetACLCancellation()
        {
            CloudQueueClient client = GenerateCloudQueueClient();
            CloudQueue       queue  = client.GetQueueReference(GenerateNewQueueName());

            QueuePermissions permissions = new QueuePermissions();

            permissions.SharedAccessPolicies.Add(Guid.NewGuid().ToString(), new SharedAccessQueuePolicy()
            {
                SharedAccessStartTime  = DateTimeOffset.Now - TimeSpan.FromHours(1),
                SharedAccessExpiryTime = DateTimeOffset.Now + TimeSpan.FromHours(1),
                Permissions            = SharedAccessQueuePermissions.Add | SharedAccessQueuePermissions.ProcessMessages | SharedAccessQueuePermissions.Read | SharedAccessQueuePermissions.Update
            });

            TestHelper.ExecuteAPMMethodWithCancellation(4000,
                                                        new[] { DelayBehaviors.DelayAllRequestsIf(4000 * 3, AzureStorageSelectors.QueueTraffic().IfHostNameContains(client.Credentials.AccountName)) },
                                                        (options, opContext, callback, state) => queue.BeginSetPermissions(permissions, (QueueRequestOptions)options, opContext, callback, state),
                                                        queue.EndSetPermissions);
        }
コード例 #19
0
        public void QueueGetACLCancellation()
        {
            CloudQueueClient client = GenerateCloudQueueClient();
            CloudQueue       queue  = client.GetQueueReference(GenerateNewQueueName());

            TestHelper.ExecuteAPMMethodWithCancellation(4000,
                                                        new[] { DelayBehaviors.DelayAllRequestsIf(4000 * 3, AzureStorageSelectors.QueueTraffic().IfHostNameContains(client.Credentials.AccountName)) },
                                                        (options, opContext, callback, state) => queue.BeginGetPermissions((QueueRequestOptions)options, opContext, callback, state),
                                                        (res) => queue.EndGetPermissions(res));
        }
コード例 #20
0
        public void OpContextTestUserHeadersOnQueue()
        {
            CloudQueueClient qClient = GenerateCloudQueueClient();
            CloudQueue       queue   = qClient.GetQueueReference("test");

            string uniqueID = Guid.NewGuid().ToString();

            OperationContext ctx = new OperationContext();

            ctx.UserHeaders = new Dictionary <string, string>();
            ctx.UserHeaders.Add("foo", "bar");

            Action act = () => queue.Exists(null, ctx);

            TestHelper.VerifyHeaderWasSent(ctx.UserHeaders.Keys.First(), ctx.UserHeaders[ctx.UserHeaders.Keys.First()], AzureStorageSelectors.QueueTraffic().IfHostNameContains(qClient.Credentials.AccountName), act);

            act = () => queue.EndExists(queue.BeginExists(null, ctx, null, null));

            TestHelper.VerifyHeaderWasSent(ctx.UserHeaders.Keys.First(), ctx.UserHeaders[ctx.UserHeaders.Keys.First()], AzureStorageSelectors.QueueTraffic().IfHostNameContains(qClient.Credentials.AccountName), act);

#if TASK
            act = () => queue.ExistsAsync(null, ctx).Wait();

            TestHelper.VerifyHeaderWasSent(ctx.UserHeaders.Keys.First(), ctx.UserHeaders[ctx.UserHeaders.Keys.First()], AzureStorageSelectors.QueueTraffic().IfHostNameContains(qClient.Credentials.AccountName), act);
#endif
        }
コード例 #21
0
        public void TableTestSaveChangesCancellationNonBatch()
        {
            CloudTableClient    tableClient = GenerateCloudTableClient();
            TableServiceContext ctx         = tableClient.GetTableServiceContext();

            for (int m = 0; m < 100; m++)
            {
                // Insert Entity
                ComplexEntity insertEntity = new ComplexEntity("insert test", m.ToString());
                ctx.AddObject(currentTable.Name, insertEntity);
            }

            TestHelper.ExecuteAPMMethodWithCancellation(4000,
                                                        new[] { DelayBehaviors.DelayAllRequestsIf(4000 * 3, AzureStorageSelectors.TableTraffic().IfHostNameContains(tableClient.Credentials.AccountName)) },
                                                        (options, opContext, callback, state) => ctx.BeginSaveChangesWithRetries(SaveChangesOptions.None, (TableRequestOptions)options, opContext, callback, state),
                                                        (res) => ctx.EndSaveChangesWithRetries(res));
        }
コード例 #22
0
        public void TableOperationCancellation()
        {
            CloudTableClient tableClient = GenerateCloudTableClient();

            DynamicTableEntity insertEntity = new DynamicTableEntity("insert test", "foo");

            for (int m = 0; m < 20; m++)
            {
                insertEntity.Properties.Add("prop" + m.ToString(), new EntityProperty(new byte[50 * 1024]));
            }

            TestHelper.ExecuteAPMMethodWithCancellation(4000,
                                                        new[] { DelayBehaviors.DelayAllRequestsIf(4000 * 3, AzureStorageSelectors.TableTraffic().IfHostNameContains(tableClient.Credentials.AccountName)) },
                                                        (options, opContext, callback, state) => currentTable.BeginExecute(TableOperation.Insert(insertEntity), (TableRequestOptions)options, opContext, callback, state),
                                                        (res) => currentTable.EndExecute(res));
        }