/// <summary> /// Prepare common infra for test runs like installing SM, IIS reset if required etc. /// </summary> public static void Initialize() { if (!isInitialized) { lock (lockObj) { if (!isInitialized) { // 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); EtwSession = new EtwEventSessionRdd(); EtwSession.Start(); if (RegistryCheck.IsNet46Installed) { Trace.TraceInformation("Detected DotNet46 as installed. Will check StatusMonitor status to determine expected prefix"); if (RegistryCheck.IsStatusMonitorInstalled) { Trace.TraceInformation("Detected Status Monitor as installed, ExpectedPrefix: rddp"); ExpectedSqlSDKPrefix = "rddp"; ExpectedHttpSDKPrefix = "rddp"; } else { Trace.TraceInformation("Detected Status Monitor as not installed, ExpectedSqlPrefix: rddf, ExpectedHttpPrefix: rdddsd"); ExpectedSqlSDKPrefix = "rddf"; ExpectedHttpSDKPrefix = "rdddsd"; } } else { Trace.TraceInformation("Detected DotNet46 as not installed. Will install StatusMonitor if not already installed."); Trace.TraceInformation("Tests against StatusMonitor instrumentation."); ExpectedSqlSDKPrefix = "rddp"; ExpectedHttpSDKPrefix = "rddp"; if (!RegistryCheck.IsStatusMonitorInstalled) { Trace.TraceInformation("StatusMonitor not already installed.Installing from:" + ExecutionEnvironment.InstallerPath); Installer.SetInternalUI(InstallUIOptions.Silent); string installerPath = ExecutionEnvironment.InstallerPath; try { Installer.InstallProduct(installerPath, "ACTION=INSTALL ALLUSERS=1 MSIINSTALLPERUSER=1"); Trace.TraceInformation("StatusMonitor installed without errors."); } catch (Exception ex) { Trace.TraceError( "Agent installer not found. Agent is required for running tests for framework version below 4.6" + ex); throw; } } else { Trace.TraceInformation("StatusMonitor already installed."); } } isInitialized = true; } } } else { Trace.TraceInformation("Already initialized!"); } }
/// <summary> /// Deploy all test applications and prepera infra. /// </summary> public static void Initialize() { if (!isInitialized) { lock (lockObj) { if (!isInitialized) { Aspx451TestWebApplication = new TestWebApplication { AppName = "Aspx451", Port = Aspx451Port, IsRedFieldApp = false }; Aspx451TestWebApplicationWin32 = new TestWebApplication { AppName = "Aspx451Win32", Port = Aspx451PortWin32, IsRedFieldApp = false }; // 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); EtwSession = new EtwEventSessionRdd(); EtwSession.Start(); Aspx451TestWebApplication.Deploy(); Aspx451TestWebApplicationWin32.Deploy(true); if (RegistryCheck.IsNet46Installed) { // .NET 4.6 onwards, there is no need of installing agent ExpectedSDKPrefix = !RegistryCheck.IsStatusMonitorInstalled ? "rddf" : "rddp"; Trace.TraceInformation("Tests against 4.6 framework (Excpected prefix: " + ExpectedSDKPrefix + ")."); } else { Trace.TraceInformation("Tests against StatusMonitor instrumentation."); ExpectedSDKPrefix = "rddp"; if (!RegistryCheck.IsStatusMonitorInstalled) { 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(); isInitialized = true; } } } }