public void TestStoredProcedureNameIsCollected() { const string StoredProcedureName = "GetTopTenMessages"; string queryString = "?type=ExecuteReaderStoredProcedureAsync&count=1&storedProcedureName=" + StoredProcedureName; Aspx451TestWebApplication.DoTest( application => { 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 sqlItems = allItems.Where(i => i.data.baseData.type == "SQL").ToArray(); Assert.AreEqual(1, sqlItems.Length, "Total Count of Remote Dependency items for SQL collected is wrong."); this.Validate( sqlItems[0], ResourceNameSQLToDevApm, StoredProcedureName, TimeSpan.FromSeconds(10), successFlagExpected: true, sqlErrorCodeExpected: "0", sqlErrorMessageExpected: null); }); }
private void TestSqlCommandExecute(string type, string errorNumber, string errorMessage, string extraClauseForFailureCase = null) { Aspx451TestWebApplication.DoTest( application => { bool success = errorNumber == "0"; string responseForQueryValidation = application.ExecuteAnonymousRequest("?type=" + type + "&count=1" + "&success=" + success); //// 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(1, sqlItems.Length, "Total Count of Remote Dependency items for SQL collected is wrong."); string queryToValidate = success ? string.Empty : InvalidSqlQueryToApmDatabase + extraClauseForFailureCase; if (!string.IsNullOrEmpty(responseForQueryValidation)) { int placeToStart = responseForQueryValidation.IndexOf(QueryToExecuteLabel, StringComparison.OrdinalIgnoreCase) + QueryToExecuteLabel.Length; int restOfLine = responseForQueryValidation.IndexOf(Environment.NewLine, StringComparison.OrdinalIgnoreCase) - placeToStart; queryToValidate = responseForQueryValidation.Substring(placeToStart, restOfLine); } this.Validate( sqlItems[0], ResourceNameSQLToDevApm, queryToValidate, TimeSpan.FromSeconds(20), successFlagExpected: success, sqlErrorCodeExpected: errorNumber, sqlErrorMessageExpected: errorMessage); }); }
/// <summary> /// Delete all applications and cleanup. /// </summary> public static void CleanUp() { if (isInitialized) { lock (lockObj) { if (isInitialized) { SdkEventListener.Dispose(); EtwSession.Stop(); Aspx451TestWebApplication.Remove(); Aspx451TestWebApplicationWin32.Remove(); if (RegistryCheck.IsNet46Installed) { // .NET 4.6 onwards, there is no need of installing agent } else { string installerPath = ExecutionEnvironment.InstallerPath; Installer.InstallProduct(installerPath, "REMOVE=ALL"); Iis.Reset(); } isInitialized = false; } } } }
public void TestDependencyCollectionForFailedRequestAtDnsResolution() { EnsureNet451Installed(); var queryString = HttpTestConstants.QueryStringOutboundHttpFailedAtDns; var resourceNameExpected = HttpTestHelper.ResourceNameHttpToFailedAtDnsRequest; Aspx451TestWebApplication.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."); var httpItem = httpItems[0]; // Since the outbound request would fail at DNS resolution, there won't be any http code to collect. // This will be a case where success = false, but resultCode is empty Assert.AreEqual(false, httpItem.data.baseData.success, "Success flag collected is wrong."); // Result code is collected only in profiler case. var expectedResultCode = DeploymentAndValidationTools.ExpectedSDKPrefix == "rddp" ? "NameResolutionFailure" : string.Empty; Assert.AreEqual(expectedResultCode, httpItem.data.baseData.resultCode, "Result code collected is wrong."); string actualSdkVersion = httpItem.tags[new ContextTagKeys().InternalSdkVersion]; Assert.IsTrue(actualSdkVersion.Contains(DeploymentAndValidationTools.ExpectedSDKPrefix), "Actual version:" + actualSdkVersion); }
public static void MyClassCleanup() { DeploymentAndValidationTools.CleanUp(); Aspx451TestWebApplication.Remove(); Trace.TraceInformation("IIS Restart begin."); Iis.Reset(); Trace.TraceInformation("IIS Restart end."); Trace.TraceInformation("SQlTests class cleaned up"); }
public static void MyClassCleanup() { AzureStorageHelper.Cleanup(); DeploymentAndValidationTools.CleanUp(); Aspx451TestWebApplication.Remove(); Aspx451TestWebApplicationWin32.Remove(); Trace.TraceInformation("IIS Restart begin."); Iis.Reset(); Trace.TraceInformation("IIS Restart end."); Trace.TraceInformation("HttpTests class cleaned up"); }
public void TestExecuteReaderTwiceWithTasks() { Aspx451TestWebApplication.DoTest( application => { application.ExecuteAnonymousRequest("?type=TestExecuteReaderTwiceWithTasks&count=1"); //// 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(1, sqlItems.Length, "We should only report 1 dependency call"); }); }
private void TestSqlConnectionExecute(string type, bool success, string exceptionType, bool async) { Aspx451TestWebApplication.DoTest( application => { string responseForQueryValidation = application.ExecuteAnonymousRequest("?type=" + type + "&success=" + success + "&exceptionType=" + exceptionType); //// 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> >( async ? DeploymentAndValidationTools.SleepTimeForSdkToSendAsyncEvents : DeploymentAndValidationTools.SleepTimeForSdkToSendEvents); var sqlItems = allItems.Where(i => i.data.baseData.type == "SQL").ToArray(); if (success) { // no items should be sent in case of success connection to database Assert.AreEqual(0, sqlItems.Length, "Total Count of Remote Dependency items for SQL collected is wrong."); } else { Assert.AreEqual(1, sqlItems.Length, "Total Count of Remote Dependency items for SQL collected is wrong."); bool isAccountException = exceptionType.Equals("account", StringComparison.OrdinalIgnoreCase); this.Validate( sqlItems[0], isAccountException ? ResourceNameSQLToDevApm : ResourceNameSQLToWrongDatabase, "Open", TimeSpan.FromSeconds(20), successFlagExpected: success, sqlErrorCodesExpected: isAccountException ? new List <string> { "233", "18456" } : new List <string> { "-1" }, sqlErrorMessagesExpected: isAccountException ? new List <string> { "A connection was successfully established with the server, but then an error occurred during the login process.", "Login failed for user 'AiUser'." } : new List <string> { "A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible." }); } }); }