public void TableGenericQueryBasicAPM() { TableQuery query = new TableQuery().Where(TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, "tables_batch_1")); TableQuerySegment <DynamicTableEntity> seg = null; using (ManualResetEvent evt = new ManualResetEvent(false)) { IAsyncResult asyncRes = null; currentTable.BeginExecuteQuerySegmented(query, null, (res) => { asyncRes = res; evt.Set(); }, null); evt.WaitOne(); seg = currentTable.EndExecuteQuerySegmented(asyncRes); } foreach (DynamicTableEntity ent in seg) { Assert.AreEqual(ent.PartitionKey, "tables_batch_1"); Assert.AreEqual(ent.Properties.Count, 4); } }
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)); }
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, XStoreSelectors.TableTraffic().IfHostNameContains(tableClient.Credentials.AccountName)) }, (options, opContext, callback, state) => currentTable.BeginExecuteQuerySegmented(query, null, (TableRequestOptions)options, opContext, callback, state), (res) => currentTable.EndExecuteQuerySegmented(res)); }
public void TableIngressEgressQuery() { 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, true); } currentTable.ExecuteBatch(batch); TableQuery query = new TableQuery().Where(TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, "insert test")); // APM TestHelper.ValidateIngressEgress(Selectors.IfUrlContains(currentTable.Uri.ToString()), () => { OperationContext opContext = new OperationContext(); currentTable.EndExecuteQuerySegmented(currentTable.BeginExecuteQuerySegmented(query, null, new TableRequestOptions() { RetryPolicy = new RetryPolicies.NoRetry() }, opContext, null, null)); return(opContext.LastResult); }); // SYNC TestHelper.ValidateIngressEgress(Selectors.IfUrlContains(currentTable.Uri.ToString()), () => { OperationContext opContext = new OperationContext(); currentTable.ExecuteQuerySegmented(query, null, new TableRequestOptions() { RetryPolicy = new RetryPolicies.NoRetry() }, opContext); return(opContext.LastResult); }); }