/// <summary> /// Validates Runtime Dependency Telemetry values. /// </summary> /// <param name="itemToValidate">RDD Item to be validated.</param> /// <param name="remoteDependencyNameExpected">Expected name.</param> /// <param name="countExpected">Expected count.</param> /// <param name="accessTimeMax">Expected maximum limit for access time.</param> /// <param name="successFlagExpected">Expected value for success flag.</param> /// <param name="asyncFlagExpected">Expected value for async flag.</param> private void ValidateRddTelemetryValues(TelemetryItem <RemoteDependencyData> itemToValidate, string remoteDependencyNameExpected, string commandNameExpected, int countExpected, TimeSpan accessTimeMax, bool successFlagExpected, bool asyncFlagExpected) { DependencySourceType source = sourceExpected; Assert.IsTrue(itemToValidate.Data.BaseData.Name.Contains(remoteDependencyNameExpected), "The remote dependancy name is incorrect"); //If the command name is expected to be empty, the deserializer will make the CommandName null if (DependencySourceType.Apmc == sourceExpected) { if (string.IsNullOrEmpty(commandNameExpected)) { Assert.IsNull(itemToValidate.Data.BaseData.CommandName); } else { Assert.IsTrue(itemToValidate.Data.BaseData.CommandName.Equals(commandNameExpected), "The command name is incorrect"); } } string actualSdkVersion = itemToValidate.InternalContext.SdkVersion; if (DependencySourceType.Apmc == sourceExpected) { Assert.IsTrue(actualSdkVersion.Contains("rddp"), "Actual version:" + actualSdkVersion); } else { Assert.IsTrue(actualSdkVersion.Contains("rddf"), "Actual version:" + actualSdkVersion); } // Validate is within expected limits var ticks = (long)(itemToValidate.Data.BaseData.Value * 10000); var accessTime = TimeSpan.FromTicks(ticks); // DNS resolution may take up to 15 seconds https://msdn.microsoft.com/en-us/library/system.net.httpwebrequest.timeout(v=vs.110).aspx. // In future when tests will be refactored we should re-think failed http calls validation policy - need to validate resposnes that actually fails on GetResponse, // not only those made to not-existing domain. var accessTimeMaxPlusDnsResolutionTime = accessTimeMax.Add(TimeSpan.FromSeconds(15)); if (successFlagExpected == true) { Assert.IsTrue(accessTime.Ticks > 0, "Access time should be above zero"); } else { Assert.IsTrue(accessTime.Ticks >= 0, "Access time should be zero or above for failed calls"); } Assert.IsTrue(accessTime < accessTimeMaxPlusDnsResolutionTime, string.Format("Access time of {0} exceeds expected max of {1}", accessTime, accessTimeMaxPlusDnsResolutionTime)); // Validate success and async flag values var successFlagActual = itemToValidate.Data.BaseData.Success; Assert.AreEqual(successFlagExpected, successFlagActual, "Success flag collected is wrong"); }
public static void MyClassInitialize(TestContext testContext) { // this makes all traces have a timestamp so it's easier to troubleshoot timing issues // looking for the better approach... foreach (TraceListener listener in Trace.Listeners) { listener.TraceOutputOptions |= TraceOptions.DateTime; } sdkEventListener = new HttpListenerObservable(Aspx451FakeDataPlatformEndpoint); aspx451TestWebApplication.Deploy(); aspx451TestWebApplicationWin32.Deploy(true); AzureStorageHelper.Initialize(); LocalDb.CreateLocalDb("RDDTestDatabase", aspx451TestWebApplication.AppFolder + "\\TestDatabase.sql"); if (DotNetVersionCheck.IsNet46Installed) { // .NET 4.6 onwards, there is no need of installing agent sourceExpected = DependencySourceType.Aic; } else { sourceExpected = DependencySourceType.Apmc; Installer.SetInternalUI(InstallUIOptions.Silent); string installerPath = ExecutionEnvironment.InstallerPath; try { Installer.InstallProduct(installerPath, "ACTION=INSTALL ALLUSERS=1 MSIINSTALLPERUSER=1"); } catch (Exception ex) { Trace.TraceError("Agent installer not found. Agent is required for running tests for framework version below 4.6" + ex); throw; } } Iis.Reset(); }
public static void MyClassInitialize(TestContext testContext) { // this makes all traces have a timestamp so it's easier to troubleshoot timing issues // looking for the better approach... foreach (TraceListener listener in Trace.Listeners) { listener.TraceOutputOptions |= TraceOptions.DateTime; } sdkEventListener = new HttpListenerObservable(Aspx451FakeDataPlatformEndpoint); aspx451TestWebApplication.Deploy(); aspx451TestWebApplicationWin32.Deploy(true); AzureStorageHelper.Initialize(); LocalDb.CreateLocalDb("RDDTestDatabase", aspx451TestWebApplication.AppFolder + "\\TestDatabase.sql"); if (DotNetVersionCheck.IsNet46Installed) { // .NET 4.6 onwards, there is no need of installing agent sourceExpected = DependencySourceType.Aic; } else { sourceExpected = DependencySourceType.Apmc; Installer.SetInternalUI(InstallUIOptions.Silent); string installerPath = ExecutionEnvironment.InstallerPath; try { Installer.InstallProduct(installerPath, "ACTION=INSTALL ALLUSERS=1 MSIINSTALLPERUSER=1"); } catch (Exception ex) { Trace.TraceError("Agent installer not found. Agent is required for running tests for framework version below 4.6" + ex); throw; } } Iis.Reset(); }