private DoTest ( Action |
||
action | Action |
The action. |
instrumentRedApp | bool | Whether red app needs to be instrumented or not. |
Результат | void |
/// <summary> /// Helper to execute Sync Http tests /// </summary> /// <param name="testWebApplication">The test application for which tests are to be executed</param> /// <param name="success">indicates if the tests should test success or failure case</param> /// <param name="count">number to RDD calls to be made by the test application. </param> /// <param name="accessTimeMax">approximate maximum time taken by RDD Call. </param> public static void ExecuteSyncHttpPostTests(TestWebApplication testWebApplication, bool success, int count, TimeSpan accessTimeMax, string resultCodeExpected, string queryString) { testWebApplication.DoTest( application => { var resourceNameExpected = success ? ResourceNameHttpToBing : ResourceNameHttpToFailedRequest; application.ExecuteAnonymousRequest(queryString + count); //// The above request would have trigged RDD module to monitor and create RDD telemetry //// Listen in the fake endpoint and see if the RDDTelemtry is captured var allItems = DeploymentAndValidationTools.SdkEventListener.ReceiveAllItemsDuringTimeOfType <TelemetryItem <RemoteDependencyData> >(DeploymentAndValidationTools.SleepTimeForSdkToSendEvents); var httpItems = allItems.Where(i => i.data.baseData.type == "Http").ToArray(); // Validate the RDD Telemetry properties Assert.AreEqual( count, httpItems.Length, "Total Count of Remote Dependency items for HTTP collected is wrong."); foreach (var httpItem in httpItems) { Validate(httpItem, resourceNameExpected, accessTimeMax, success, "POST", resultCodeExpected); } }); }
public static void ExecuteSyncHttpClientTests(TestWebApplication testWebApplication, TimeSpan accessTimeMax, string resultCodeExpected) { testWebApplication.DoTest( application => { var queryString = "?type=httpClient&count=1"; var resourceNameExpected = new Uri("https://www.google.com/404"); application.ExecuteAnonymousRequest(queryString); //// The above request would have trigged RDD module to monitor and create RDD telemetry //// Listen in the fake endpoint and see if the RDDTelemtry is captured var allItems = DeploymentAndValidationTools.SdkEventListener.ReceiveAllItemsDuringTimeOfType <TelemetryItem <RemoteDependencyData> >(DeploymentAndValidationTools.SleepTimeForSdkToSendEvents); var httpItems = allItems.Where(i => i.data.baseData.type == "Http").ToArray(); Assert.AreEqual( 1, httpItems.Length, "Total Count of Remote Dependency items for HTTP collected is wrong."); foreach (var httpItem in httpItems) { // This is a call to google.com/404 which will fail but typically takes longer time. So accesstime can more than normal. Validate(httpItem, resourceNameExpected, accessTimeMax.Add(TimeSpan.FromSeconds(15)), false, "GET", resultCodeExpected); } }); }
/// <summary> /// Helper to execute Sync SQL tests /// </summary> /// <param name="testWebApplication">The test application for which tests are to be executed</param> /// <param name="success">indicates if the tests should test success or failure case</param> /// <param name="count">number to RDD calls to be made by the test application. </param> /// <param name="accessTimeMax">approximate maximum time taken by RDD Call. </param> /// <param name="queryString">The query string. </param> public static void ExecuteSqlTest( TestWebApplication testWebApplication, bool success, int count, TimeSpan accessTimeMax, string queryString) { testWebApplication.DoTest( application => { application.ExecuteAnonymousRequest(queryString + count); //// The above request would have trigged RDD module to monitor and create RDD telemetry //// Listen in the fake endpoint and see if the RDDTelemtry is captured var allItems = DeploymentAndValidationTools.SdkEventListener .ReceiveAllItemsDuringTimeOfType <TelemetryItem <RemoteDependencyData> >(DeploymentAndValidationTools.SleepTimeForSdkToSendEvents); var sqlItems = allItems.Where(i => i.data.baseData.type == "SQL").ToArray(); Assert.AreEqual( count, sqlItems.Length, "Total Count of Remote Dependency items for HTTP collected is wrong."); var validQuery = queryString.Contains("CommandExecuteScalar") ? ValidSqlQueryCountToApmDatabase : ValidSqlQueryToApmDatabase; var queryToValidate = success ? queryString.Contains("StoredProcedure") ? "GetTopTenMessages" : queryString.Contains("Xml") ? validQuery + " FOR XML AUTO" : validQuery : InvalidSqlQueryToApmDatabase; foreach (var sqlItem in sqlItems) { Validate( sqlItem, ResourceNameSQLToDevApm, queryToValidate, TimeSpan.FromSeconds(20), successFlagExpected: success, sqlErrorCodeExpected: success ? string.Empty : "208", sqlErrorMessageExpected: null); } }); }
/// <summary> /// Helper to execute Azure SDK tests. /// </summary> /// <param name="testWebApplication">The test application for which tests are to be executed.</param> /// <param name="count">number to RDD calls to be made by the test application.</param> /// <param name="type"> type of azure call.</param> /// <param name="expectedUrl">expected url for azure call.</param> public static void ExecuteAzureSDKTests(TestWebApplication testWebApplication, int count, string type, string expectedUrl, string queryString, bool checkStatus) { testWebApplication.DoTest( application => { application.ExecuteAnonymousRequest(string.Format(CultureInfo.InvariantCulture, queryString, type, count)); //// The above request would have trigged RDD module to monitor and create RDD telemetry //// Listen in the fake endpoint and see if the RDDTelemtry is captured var allItems = DeploymentAndValidationTools.SdkEventListener.ReceiveAllItemsDuringTimeOfType <TelemetryItem <RemoteDependencyData> >(DeploymentAndValidationTools.SleepTimeForSdkToSendEvents); var httpItems = allItems.Where(i => i.data.baseData.type == "Http").ToArray(); int countItem = 0; foreach (var httpItem in httpItems) { TimeSpan accessTime = TimeSpan.Parse(httpItem.data.baseData.duration, CultureInfo.InvariantCulture); Assert.IsTrue(accessTime.TotalMilliseconds >= 0, "Access time should be above zero for azure calls"); string actualSdkVersion = httpItem.tags[new ContextTagKeys().InternalSdkVersion]; Assert.IsTrue(actualSdkVersion.Contains(DeploymentAndValidationTools.ExpectedHttpSDKPrefix), "Actual version:" + actualSdkVersion); var url = httpItem.data.baseData.data; if (url.Contains(expectedUrl)) { countItem++; } else { Assert.Fail("ExecuteAzureSDKTests.url not matching for " + url); } var successFlagActual = httpItem.data.baseData.success; if (checkStatus) { Assert.AreEqual(true, successFlagActual, "Success flag collected is wrong.It is expected to be true for all azure sdk calls."); } } Assert.IsTrue(countItem >= count, "Azure " + type + " access captured " + countItem + " is less than " + count); }); }
/// <summary> /// Helper to execute Sync Http tests /// </summary> /// <param name="testWebApplication">The test application for which tests are to be executed</param> /// <param name="success">indicates if the tests should test success or failure case</param> /// <param name="count">number to RDD calls to be made by the test application. </param> /// <param name="accessTimeMax">approximate maximum time taken by RDD Call. </param> private void ExecuteSyncHttpTests(TestWebApplication testWebApplication, bool success, int count, TimeSpan accessTimeMax) { testWebApplication.DoTest( application => { var queryString = success ? QueryStringOutboundHttp : QueryStringOutboundHttpFailed; var resourceNameExpected = success ? ResourceNameHttpToBing : ResourceNameHttpToFailedRequest; application.ExecuteAnonymousRequest(queryString + count); //// The above request would have trigged RDD module to monitor and create RDD telemetry //// Listen in the fake endpoint and see if the RDDTelemtry is captured var allItems = DeploymentAndValidationTools.SdkEventListener.ReceiveAllItemsDuringTimeOfType<TelemetryItem<RemoteDependencyData>>(DeploymentAndValidationTools.SleepTimeForSdkToSendEvents); var httpItems = allItems.Where(i => i.data.baseData.type == "Http").ToArray(); Assert.AreEqual( count, httpItems.Length, "Total Count of Remote Dependency items for HTTP collected is wrong."); foreach (var httpItem in httpItems) { this.Validate(httpItem, resourceNameExpected, accessTimeMax, success, verb: "GET"); } }); }
private void ExecuteSyncHttpClientTests(TestWebApplication testWebApplication, TimeSpan accessTimeMax) { testWebApplication.DoTest( application => { var queryString = "?type=httpClient&count=1"; var resourceNameExpected = new Uri("http://www.google.com/404"); application.ExecuteAnonymousRequest(queryString); //// The above request would have trigged RDD module to monitor and create RDD telemetry //// Listen in the fake endpoint and see if the RDDTelemtry is captured var allItems = DeploymentAndValidationTools.SdkEventListener.ReceiveAllItemsDuringTimeOfType<TelemetryItem<RemoteDependencyData>>(DeploymentAndValidationTools.SleepTimeForSdkToSendEvents); var httpItems = allItems.Where(i => i.data.baseData.type == "Http").ToArray(); Assert.AreEqual( 1, httpItems.Length, "Total Count of Remote Dependency items for HTTP collected is wrong."); foreach (var httpItem in httpItems) { this.Validate(httpItem, resourceNameExpected, accessTimeMax, successFlagExpected: false, verb: "GET"); } }); }
/// <summary> /// Helper to execute Azure SDK tests. /// </summary> /// <param name="testWebApplication">The test application for which tests are to be executed.</param> /// <param name="count">number to RDD calls to be made by the test application.</param> /// <param name="type"> type of azure call.</param> /// <param name="expectedUrl">expected url for azure call.</param> private void ExecuteAzureSDKTests(TestWebApplication testWebApplication, int count, string type, string expectedUrl) { testWebApplication.DoTest( application => { application.ExecuteAnonymousRequest(string.Format(QueryStringOutboundAzureSdk, type, count)); //// The above request would have trigged RDD module to monitor and create RDD telemetry //// Listen in the fake endpoint and see if the RDDTelemtry is captured var allItems = DeploymentAndValidationTools.SdkEventListener.ReceiveAllItemsDuringTimeOfType<TelemetryItem<RemoteDependencyData>>(DeploymentAndValidationTools.SleepTimeForSdkToSendEvents); var httpItems = allItems.Where(i => i.data.baseData.type == "Http").ToArray(); int countItem = 0; foreach (var httpItem in httpItems) { TimeSpan accessTime = TimeSpan.Parse(httpItem.data.baseData.duration); Assert.IsTrue(accessTime.TotalMilliseconds >= 0, "Access time should be above zero for azure calls"); var url = httpItem.data.baseData.data; if (url.Contains(expectedUrl)) { countItem++; } else { Assert.Fail("ExecuteAzureSDKTests.url not matching for " + url); } } Assert.IsTrue(countItem >= count, "Azure " + type + " access captured " + countItem + " is less than " + count); }); }
/// <summary> /// Helper to execute Async http test which uses Callbacks. /// </summary> /// <param name="testWebApplication">The test application for which tests are to be executed</param> /// <param name="success">indicates if the tests should test success or failure case</param> private void ExecuteAsyncWithCallbackTests(TestWebApplication testWebApplication, bool success) { var resourceNameExpected = success ? ResourceNameHttpToBing : ResourceNameHttpToFailedRequest; testWebApplication.DoTest( application => { application.ExecuteAnonymousRequest(success ? QueryStringOutboundHttpAsync4 : QueryStringOutboundHttpAsync4Failed); //// The above request would have trigged RDD module to monitor and create RDD telemetry //// Listen in the fake endpoint and see if the RDDTelemtry is captured var allItems = DeploymentAndValidationTools.SdkEventListener.ReceiveAllItemsDuringTimeOfType<TelemetryItem<RemoteDependencyData>>(DeploymentAndValidationTools.SleepTimeForSdkToSendEvents); var httpItems = allItems.Where(i => i.data.baseData.type == "Http").ToArray(); // Validate the RDD Telemetry properties Assert.AreEqual( 1, httpItems.Length, "Total Count of Remote Dependency items for HTTP collected is wrong."); this.Validate(httpItems[0], resourceNameExpected, AccessTimeMaxHttpInitial, success, "GET"); }); }
/// <summary> /// Helper to execute Sync Http tests /// </summary> /// <param name="testWebApplication">The test application for which tests are to be executed</param> /// <param name="success">indicates if the tests should test success or failure case</param> /// <param name="expectedCount">number of expected RDD calls to be made by the test application </param> /// <param name="count">number to RDD calls to be made by the test application </param> /// <param name="accessTimeMax">approximate maximum time taken by RDD Call. </param> private void ExecuteSyncSqlTests(TestWebApplication testWebApplication, bool success, int expectedCount, int count, TimeSpan accessTimeMax) { testWebApplication.DoTest( (application) => { application.ExecuteAnonymousRequest(QueryStringOutboundSql + count); //// The above request would have trigged RDD module to monitor and create RDD telemetry //// Listen in the fake endpoint and see if the RDDTelemtry is captured var allItems = sdkEventListener.ReceiveAllItemsDuringTimeOfType<TelemetryItem<RemoteDependencyData>>(SleepTimeForSdkToSendEvents); var sqlItems = allItems.Where(i => i.Data.BaseData.DependencyKind == RemoteDependencyKind.SQL).ToArray(); Assert.AreEqual( expectedCount, sqlItems.Length, "Total Count of Remote Dependency items for SQL collected is wrong."); foreach (var sqlItem in sqlItems) { string spName = "GetTopTenMessages"; this.ValidateRddTelemetryValues(sqlItem, ResourceNameSQLToDevApm + " | " + spName, spName, expectedCount, accessTimeMax, true, false); } }); }
/// <summary> /// Helper to execute Sync Http tests /// </summary> /// <param name="testWebApplication">The test application for which tests are to be executed</param> /// <param name="success">indicates if the tests should test success or failure case</param> /// <param name="count">number to RDD calls to be made by the test application. </param> /// <param name="accessTimeMax">approximate maximum time taken by RDD Call. </param> private void ExecuteSyncHttpTests(TestWebApplication testWebApplication, bool success, int count, TimeSpan accessTimeMax) { testWebApplication.DoTest( (application) => { var queryString = success == true ? QueryStringOutboundHttp : QueryStringOutboundHttpFailed; var resourceNameExpected = success == true ? ResourceNameHttpToBing : ResourceNameHttpToFailedRequest; string commandNameExpected = string.Empty; application.ExecuteAnonymousRequest(queryString + count); //// The above request would have trigged RDD module to monitor and create RDD telemetry //// Listen in the fake endpoint and see if the RDDTelemtry is captured var allItems = sdkEventListener.ReceiveAllItemsDuringTimeOfType<TelemetryItem<RemoteDependencyData>>(SleepTimeForSdkToSendEvents); var httpItems = allItems.Where(i => i.Data.BaseData.DependencyKind == RemoteDependencyKind.Http).ToArray(); // Validate the RDD Telemetry properties Assert.AreEqual( count, httpItems.Length, "Total Count of Remote Dependency items for HTTP collected is wrong."); foreach (var httpItem in httpItems) { this.ValidateRddTelemetryValues(httpItem, resourceNameExpected, commandNameExpected, count, accessTimeMax, success, false); } }); }
private void ExecuteSyncHttpClientTests(TestWebApplication testWebApplication, TimeSpan accessTimeMax) { testWebApplication.DoTest( (application) => { var queryString = "?type=httpClient&count=1"; var resourceNameExpected = "http://www.google.com/404"; string commandNameExpected = string.Empty; application.ExecuteAnonymousRequest(queryString); //// The above request would have trigged RDD module to monitor and create RDD telemetry //// Listen in the fake endpoint and see if the RDDTelemtry is captured var allItems = sdkEventListener.ReceiveAllItemsDuringTimeOfType<TelemetryItem<RemoteDependencyData>>(SleepTimeForSdkToSendEvents); var httpItems = allItems.Where(i => i.Data.BaseData.DependencyKind == RemoteDependencyKind.Http).ToArray(); // Validate the RDD Telemetry properties Assert.AreEqual( 1, httpItems.Length, "Total Count of Remote Dependency items for HTTP collected is wrong."); foreach (var httpItem in httpItems) { if (DependencySourceType.Apmc == sourceExpected) { Assert.AreEqual("GET " + resourceNameExpected, httpItem.Data.BaseData.Name, "For StatusMonitor implementation we expect verb to be collected."); } this.ValidateRddTelemetryValues(httpItem, resourceNameExpected, commandNameExpected, 1, accessTimeMax, false, false); } }); }
/// <summary> /// Helper to execute Async Http tests. /// </summary> /// <param name="testWebApplication">The test application for which tests are to be executed.</param> /// <param name="success">Indicates if the tests should test success or failure case.</param> /// <param name="count">Number to RDD calls to be made by the test application. </param> /// <param name="accessTimeMax">Approximate maximum time taken by RDD Call. </param> private void ExecuteAsyncTests(TestWebApplication testWebApplication, bool success, int count, TimeSpan accessTimeMax, string url) { var resourceNameExpected = success == true ? ResourceNameHttpToBing : ResourceNameHttpToFailedRequest; var commandNameExpected = string.Empty; testWebApplication.DoTest( (application) => { var queryString = url; application.ExecuteAnonymousRequest(queryString + count); application.ExecuteAnonymousRequest(queryString + count); application.ExecuteAnonymousRequest(queryString + count); //// The above request would have trigged RDD module to monitor and create RDD telemetry //// Listen in the fake endpoint and see if the RDDTelemtry is captured var allItems = sdkEventListener.ReceiveAllItemsDuringTimeOfType<TelemetryItem<RemoteDependencyData>>(SleepTimeForSdkToSendEvents); var httpItems = allItems.Where(i => i.Data.BaseData.DependencyKind == RemoteDependencyKind.Http).ToArray(); // Validate the RDD Telemetry properties Assert.AreEqual( 3 * count, httpItems.Length, "Total Count of Remote Dependency items for HTTP collected is wrong."); foreach (var httpItem in httpItems) { if (DependencySourceType.Apmc == sourceExpected) { Assert.AreEqual("GET " + resourceNameExpected, httpItem.Data.BaseData.Name, "For StatusMonitor implementation we expect verb to be collected."); } this.ValidateRddTelemetryValues(httpItem, resourceNameExpected, commandNameExpected, 1, accessTimeMax, success, true); } }); }
/// <summary> /// Helper to execute Sync Http tests /// </summary> /// <param name="testWebApplication">The test application for which tests are to be executed</param> /// <param name="expectedCount">number of expected RDD calls to be made by the test application </param> /// <param name="count">number to RDD calls to be made by the test application </param> /// <param name="accessTimeMax">approximate maximum time taken by RDD Call. </param> private void ExecuteSyncSqlTests(TestWebApplication testWebApplication, int expectedCount, int count, TimeSpan accessTimeMax) { testWebApplication.DoTest( application => { application.ExecuteAnonymousRequest(QueryStringOutboundSql + count); //// The above request would have trigged RDD module to monitor and create RDD telemetry //// Listen in the fake endpoint and see if the RDDTelemtry is captured var allItems = DeploymentAndValidationTools.SdkEventListener.ReceiveAllItemsDuringTimeOfType<TelemetryItem<RemoteDependencyData>>(DeploymentAndValidationTools.SleepTimeForSdkToSendEvents).ToArray(); var sqlItems = allItems.Where(i => i.data.baseData.type == "SQL").ToArray(); Assert.AreEqual( expectedCount, sqlItems.Length, "Total Count of Remote Dependency items for SQL collected is wrong."); foreach (var sqlItem in sqlItems) { string spName = "GetTopTenMessages"; this.Validate( sqlItem, ResourceNameSQLToDevApm, spName, accessTimeMax, successFlagExpected: true, sqlErrorCodeExpected: "0", sqlErrorMessageExpected: null); } }); }