private static void Run(string[] args) { var argsDictionary = CommandLineArgumentsHelper.GetArgumentsDictionary(args); // Invoke the engine with arguments GetEngineInvoker(argsDictionary).Invoke(argsDictionary); }
private void SetParentProcessExitCallback(IDictionary <string, string> argsDictionary) { // Attach to exit of parent process var hasParentProcessArgument = CommandLineArgumentsHelper.TryGetIntArgFromDict(argsDictionary, ParentProcessIdArgument, out var parentProcessId); if (!hasParentProcessArgument) { throw new ArgumentException($"Argument {ParentProcessIdArgument} was not specified."); } EqtTrace.Info("DefaultEngineInvoker.SetParentProcessExitCallback: Monitoring parent process with id: '{0}'", parentProcessId); if (parentProcessId == -1) { // In remote scenario we cannot monitor parent process, so we expect user to pass parentProcessId as -1 return; } if (parentProcessId == 0) { //TODO: should there be a warning / error in this case, on windows and linux we are most likely not started by this PID 0, because it's Idle process on Windows, and Swapper on Linux, and similarly in docker // Trying to attach to 0 will cause access denied error on Windows } this.processHelper.SetExitCallback( parentProcessId, (obj) => { EqtTrace.Info("DefaultEngineInvoker.SetParentProcessExitCallback: ParentProcess '{0}' Exited.", parentProcessId); new PlatformEnvironment().Exit(1); }); }
private static RequestData GetRequestData(IDictionary <string, string> argsDictionary) { // Checks for Telemetry Opted in or not from Command line Arguments. // By Default opting out in Test Host to handle scenario when user running old version of vstest.console var telemetryStatus = CommandLineArgumentsHelper.GetStringArgFromDict(argsDictionary, TelemetryOptedIn); var telemetryOptedIn = false; if (!string.IsNullOrWhiteSpace(telemetryStatus)) { if (telemetryStatus.Equals("true", StringComparison.Ordinal)) { telemetryOptedIn = true; } } var requestData = new RequestData { MetricsCollection = telemetryOptedIn ? (IMetricsCollection) new MetricsCollection() : new NoOpMetricsCollection(), IsTelemetryOptedIn = telemetryOptedIn }; return(requestData); }
private static TestHostConnectionInfo GetConnectionInfo(IDictionary <string, string> argsDictionary) { // vstest.console < 15.5 won't send endpoint and role arguments. // So derive endpoint from port argument and Make connectionRole as Client. var endpoint = CommandLineArgumentsHelper.GetStringArgFromDict(argsDictionary, EndpointArgument); if (string.IsNullOrWhiteSpace(endpoint)) { var port = CommandLineArgumentsHelper.GetIntArgFromDict(argsDictionary, "--port"); endpoint = IPAddress.Loopback + ":" + port; } EqtTrace.Info("DefaultEngineInvoker.GetConnectionInfo: Initialize communication on endpoint address: '{0}'", endpoint); var connectionRole = ConnectionRole.Client; string role = CommandLineArgumentsHelper.GetStringArgFromDict(argsDictionary, RoleArgument); if (!string.IsNullOrWhiteSpace(role) && string.Equals(role, "host", StringComparison.OrdinalIgnoreCase)) { connectionRole = ConnectionRole.Host; } // Start Processing of requests var connectionInfo = new TestHostConnectionInfo { Endpoint = endpoint, Role = connectionRole, Transport = Transport.Sockets }; return(connectionInfo); }
// In UWP(App models) Run will act as entry point from Application end, so making this method public public static void Run(string[] args) { WaitForDebuggerIfEnabled(); var argsDictionary = CommandLineArgumentsHelper.GetArgumentsDictionary(args); // Invoke the engine with arguments GetEngineInvoker(argsDictionary).Invoke(argsDictionary); }
public void GetArgumentsDictionaryShouldReturnEmptyDictionaryIfEmptyArgIsPassed() { var argsDictionary = CommandLineArgumentsHelper.GetArgumentsDictionary(null); Assert.IsTrue(argsDictionary.Count == 0); argsDictionary = CommandLineArgumentsHelper.GetArgumentsDictionary(new string[] { }); Assert.IsTrue(argsDictionary.Count == 0); }
// In UWP(App models) Run will act as entry point from Application end, so making this method public public static void Run(string[] args) { DebuggerBreakpoint.WaitForNativeDebugger("VSTEST_HOST_NATIVE_DEBUG"); DebuggerBreakpoint.WaitForDebugger("VSTEST_HOST_DEBUG"); UILanguageOverride.SetCultureSpecifiedByUser(); var argsDictionary = CommandLineArgumentsHelper.GetArgumentsDictionary(args); // Invoke the engine with arguments GetEngineInvoker(argsDictionary).Invoke(argsDictionary); }
public void Invoke(IDictionary <string, string> argsDictionary) { DefaultEngineInvoker.InitializeEqtTrace(argsDictionary); if (EqtTrace.IsInfoEnabled) { EqtTrace.Info("DefaultEngineInvoker.Invoke: Testhost process started with args :{0}", string.Join(",", argsDictionary)); #if NET451 var appConfigText = System.IO.File.ReadAllText(AppDomain.CurrentDomain.SetupInformation.ConfigurationFile); EqtTrace.Info("DefaultEngineInvoker: Using Application Configuration: '{0}'", appConfigText); #endif } #if NETCOREAPP TestHostTraceListener.Setup(); #endif this.SetParentProcessExitCallback(argsDictionary); this.requestHandler.ConnectionInfo = DefaultEngineInvoker.GetConnectionInfo(argsDictionary); // Initialize Communication with vstest.console this.requestHandler.InitializeCommunication(); // skipping because 0 is the default value, and also the value the the callers use when they // call with the parameter specified, but without providing an actual port var dcPort = CommandLineArgumentsHelper.GetIntArgFromDict(argsDictionary, DataCollectionPortArgument); if (dcPort > 0) { this.ConnectToDatacollector(dcPort); } var requestData = DefaultEngineInvoker.GetRequestData(argsDictionary); // Start processing async in a different task EqtTrace.Info("DefaultEngineInvoker.Invoke: Start Request Processing."); try { this.StartProcessingAsync(requestHandler, new TestHostManagerFactory(requestData)).Wait(); } finally { if (dcPort > 0) { // Close datacollector communication. this.dataCollectionTestCaseEventSender.Close(); } this.requestHandler.Dispose(); } }
private static void Run(string[] args) { var argsDictionary = CommandLineArgumentsHelper.GetArgumentsDictionary(args); // Setup logging if enabled string logFile; if (argsDictionary.TryGetValue(LogFileArgument, out logFile)) { EqtTrace.InitializeVerboseTrace(logFile); } // Attach to exit of parent process var parentProcessId = CommandLineArgumentsHelper.GetIntArgFromDict(argsDictionary, ParentProcessArgument); EqtTrace.Info("DataCollector: Monitoring parent process with id: '{0}'", parentProcessId); var processHelper = new ProcessHelper(); processHelper.SetExitCallback( parentProcessId, (obj) => { EqtTrace.Info("DataCollector: ParentProcess '{0}' Exited.", parentProcessId); Environment.Exit(1); }); // Get server port and initialize communication. string portValue; int port = argsDictionary.TryGetValue(PortArgument, out portValue) ? int.Parse(portValue) : 0; if (port <= 0) { throw new ArgumentException("Incorrect/No Port number"); } var requestHandler = DataCollectionRequestHandler.Create(new SocketCommunicationManager(), new MessageSink()); requestHandler.InitializeCommunication(port); // Can only do this after InitializeCommunication because datacollector cannot "Send Log" unless communications are initialized if (!string.IsNullOrEmpty(EqtTrace.LogFile)) { requestHandler.SendDataCollectionMessage(new DataCollectionMessageEventArgs(TestMessageLevel.Informational, string.Format("Logging DataCollector Diagnostics in file: {0}", EqtTrace.LogFile))); } // Start processing async in a different task EqtTrace.Info("DataCollector: Start Request Processing."); var processingTask = StartProcessingAsync(requestHandler); // Wait for processing to complete. Task.WaitAny(processingTask); }
public void GetIntArgFromDictShouldReturnTheValueIfKeyIsPresent() { var args = new List <string>() { "--port", "1000" }; var argsDictionary = CommandLineArgumentsHelper.GetArgumentsDictionary(args.ToArray()); int data = CommandLineArgumentsHelper.GetIntArgFromDict(argsDictionary, "--port"); Assert.AreEqual(1000, data); }
public void GetStringArgFromDictShouldReturnStringValueOrEmpty() { var args = new List <string>() { "--port", "12312", "--parentprocessid", "2312", "--testsourcepath", @"C:\temp\1.dll" }; var argsDictionary = CommandLineArgumentsHelper.GetArgumentsDictionary(args.ToArray()); string data = CommandLineArgumentsHelper.GetStringArgFromDict(argsDictionary, "--port"); Assert.AreEqual("12312", data); }
public void GetArgumentsDictionaryShouldReturnDictionary() { var args = new List <string>() { "--port", "12312", "--parentprocessid", "2312", "--testsourcepath", @"C:\temp\1.dll" }; var argsDictionary = CommandLineArgumentsHelper.GetArgumentsDictionary(args.ToArray()); Assert.AreEqual("12312", argsDictionary["--port"]); Assert.AreEqual("2312", argsDictionary["--parentprocessid"]); Assert.AreEqual(@"C:\temp\1.dll", argsDictionary["--testsourcepath"]); }
public void GetArgumentsDictionaryShouldTreatValueAsNullIfTwoConsecutiveKeysArePassed() { var args = new List <string>() { "--hello", "--world" }; var argsDictionary = CommandLineArgumentsHelper.GetArgumentsDictionary(args.ToArray()); Assert.IsTrue(argsDictionary.Count == 2); Assert.AreEqual(null, argsDictionary["--hello"]); Assert.AreEqual(null, argsDictionary["--world"]); }
public void TryGetIntArgFromDictShouldReturnFalseIfKeyIsNotPresent() { var args = new List <string>() { "--hello", "--world" }; var argsDictionary = CommandLineArgumentsHelper.GetArgumentsDictionary(args.ToArray()); bool found = CommandLineArgumentsHelper.TryGetIntArgFromDict(argsDictionary, "--port", out var data); Assert.IsFalse(found); }
public void Run(string[] args) { WaitForDebuggerIfEnabled(); var argsDictionary = CommandLineArgumentsHelper.GetArgumentsDictionary(args); // Setup logging if enabled string logFile; if (argsDictionary.TryGetValue(LogFileArgument, out logFile)) { EqtTrace.InitializeVerboseTrace(logFile); } else { EqtTrace.DoNotInitailize = true; } EqtTrace.Info("DataCollectorMain.Run: Starting data collector run with args: {0}", string.Join(",", args)); // Attach to exit of parent process var parentProcessId = CommandLineArgumentsHelper.GetIntArgFromDict(argsDictionary, ParentProcessArgument); EqtTrace.Info("DataCollector: Monitoring parent process with id: '{0}'", parentProcessId); this.processHelper.SetExitCallback( parentProcessId, (obj) => { EqtTrace.Info("DataCollector: ParentProcess '{0}' Exited.", parentProcessId); this.environment.Exit(1); }); // Get server port and initialize communication. string portValue; int port = argsDictionary.TryGetValue(PortArgument, out portValue) ? int.Parse(portValue) : 0; if (port <= 0) { throw new ArgumentException("Incorrect/No Port number"); } this.requestHandler.InitializeCommunication(port); // Can only do this after InitializeCommunication because datacollector cannot "Send Log" unless communications are initialized if (!string.IsNullOrEmpty(EqtTrace.LogFile)) { ((DataCollectionRequestHandler)this.requestHandler).SendDataCollectionMessage(new DataCollectionMessageEventArgs(TestMessageLevel.Informational, string.Format("Logging DataCollector Diagnostics in file: {0}", EqtTrace.LogFile))); } // Start processing async in a different task EqtTrace.Info("DataCollector: Start Request Processing."); StartProcessing(); }
public void GetIntArgFromDictShouldReturnZeroIfKeyIsNotPresent() { var args = new List <string>() { "--hello", "--world" }; var argsDictionary = CommandLineArgumentsHelper.GetArgumentsDictionary(args.ToArray()); int data = CommandLineArgumentsHelper.GetIntArgFromDict(argsDictionary, "--port"); Assert.AreEqual(0, data); }
public void GetStringArgFromDictShouldReturnNullIfValueIsNotPresent() { var args = new List <string>() { "--hello", "--world" }; var argsDictionary = CommandLineArgumentsHelper.GetArgumentsDictionary(args.ToArray()); string data = CommandLineArgumentsHelper.GetStringArgFromDict(argsDictionary, "--hello"); Assert.IsTrue(argsDictionary.Count == 2); Assert.IsNull(data); }
public void TryGetIntArgFromDictShouldReturnTrueIfKeyIsPresentAndTheValue() { var args = new List <string>() { "--port", "59870" }; var argsDictionary = CommandLineArgumentsHelper.GetArgumentsDictionary(args.ToArray()); bool found = CommandLineArgumentsHelper.TryGetIntArgFromDict(argsDictionary, "--port", out var data); Assert.IsTrue(found); Assert.AreEqual(59870, data); }
public void GetStringArgFromDictShouldReturnEmptyStringIfKeyIsNotPresent() { var args = new List <string>() { "--hello", "--world" }; var argsDictionary = CommandLineArgumentsHelper.GetArgumentsDictionary(args.ToArray()); string data = CommandLineArgumentsHelper.GetStringArgFromDict(argsDictionary, "--port"); Assert.IsTrue(argsDictionary.Count == 2); Assert.AreEqual(string.Empty, data); }
private static void InitializeEqtTrace(IDictionary <string, string> argsDictionary) { // Setup logging if enabled if (argsDictionary.TryGetValue(LogFileArgument, out var logFile)) { var traceLevelInt = CommandLineArgumentsHelper.GetIntArgFromDict(argsDictionary, TraceLevelArgument); // In case traceLevelInt is not defined in PlatfromTraceLevel, default it to verbose. var traceLevel = Enum.IsDefined(typeof(PlatformTraceLevel), traceLevelInt) ? (PlatformTraceLevel)traceLevelInt : PlatformTraceLevel.Verbose; EqtTrace.InitializeTrace(logFile, traceLevel); } else { EqtTrace.DoNotInitailize = true; } }
private static void Run(string[] args) { var argsDictionary = CommandLineArgumentsHelper.GetArgumentsDictionary(args); var requestHandler = DataCollectionRequestHandler.Create(new SocketCommunicationManager(), new MessageSink()); // Setup logging if enabled string logFile; if (argsDictionary.TryGetValue(LogFileArgument, out logFile)) { EqtTrace.InitializeVerboseTrace(logFile); } // Get server port and initialize communication. string portValue; int port = argsDictionary.TryGetValue(PortArgument, out portValue) ? int.Parse(portValue) : 0; if (port <= 0) { throw new ArgumentException("Incorrect/No Port number"); } requestHandler.InitializeCommunication(port); // Can only do this after InitializeCommunication because datacollector cannot "Send Log" unless communications are initialized if (!string.IsNullOrEmpty(EqtTrace.LogFile)) { requestHandler.SendDataCollectionMessage(new DataCollectionMessageEventArgs(TestMessageLevel.Informational, string.Format("Logging DataCollector Diagnostics in file: {0}", EqtTrace.LogFile))); } // Wait for the connection to the sender and start processing requests from sender if (requestHandler.WaitForRequestSenderConnection(ClientListenTimeOut)) { requestHandler.ProcessRequests(); } else { EqtTrace.Info("DataCollector: RequestHandler timed out while connecting to the Sender."); requestHandler.Close(); throw new TimeoutException(); } }
private void SetParentProcessExitCallback(IDictionary <string, string> argsDictionary) { // Attach to exit of parent process var parentProcessId = CommandLineArgumentsHelper.GetIntArgFromDict(argsDictionary, ParentProcessIdArgument); EqtTrace.Info("DefaultEngineInvoker.SetParentProcessExitCallback: Monitoring parent process with id: '{0}'", parentProcessId); // In remote scenario we cannot monitor parent process, so we expect user to pass parentProcessId as -1 if (parentProcessId != -1) { this.processHelper.SetExitCallback( parentProcessId, (obj) => { EqtTrace.Info("DefaultEngineInvoker.SetParentProcessExitCallback: ParentProcess '{0}' Exited.", parentProcessId); new PlatformEnvironment().Exit(1); }); } }
public void GetArgumentsDictionaryShouldIgnoreValuesWithoutPreceedingHypen() { var args = new List <string>() { "port", "12312", "--parentprocessid", "2312", "--testsourcepath", @"C:\temp\1.dll" }; var argsDictionary = CommandLineArgumentsHelper.GetArgumentsDictionary(args.ToArray()); Assert.IsTrue(argsDictionary.Count == 2); Assert.AreEqual("2312", argsDictionary["--parentprocessid"]); Assert.AreEqual(@"C:\temp\1.dll", argsDictionary["--testsourcepath"]); args = new List <string>() { "--port", "12312", "--parentprocessid", "2312", "testsourcepath", @"C:\temp\1.dll" }; argsDictionary = CommandLineArgumentsHelper.GetArgumentsDictionary(args.ToArray()); Assert.IsTrue(argsDictionary.Count == 2); Assert.AreEqual("12312", argsDictionary["--port"]); Assert.AreEqual("2312", argsDictionary["--parentprocessid"]); }
public void Invoke(IDictionary <string, string> argsDictionary) { // Setup logging if enabled string logFile; if (argsDictionary.TryGetValue(LogFileArgument, out logFile)) { EqtTrace.InitializeVerboseTrace(logFile); } #if NET451 if (EqtTrace.IsInfoEnabled) { var appConfigText = System.IO.File.ReadAllText(AppDomain.CurrentDomain.SetupInformation.ConfigurationFile); EqtTrace.Info("DefaultEngineInvoker: Using Application Configuration: '{0}'", appConfigText); } #endif // vstest.console < 15.5 won't send endpoint and role arguments. // So derive endpoint from port argument and Make connectionRole as Client. string endpoint = CommandLineArgumentsHelper.GetStringArgFromDict(argsDictionary, EndpointArgument); if (string.IsNullOrWhiteSpace(endpoint)) { var port = CommandLineArgumentsHelper.GetIntArgFromDict(argsDictionary, "--port"); endpoint = IPAddress.Loopback + ":" + port; } var connectionRole = ConnectionRole.Client; string role = CommandLineArgumentsHelper.GetStringArgFromDict(argsDictionary, RoleArgument); if (!string.IsNullOrWhiteSpace(role) && string.Equals(role, "host", StringComparison.OrdinalIgnoreCase)) { connectionRole = ConnectionRole.Host; } // Start Processing of requests using (var requestHandler = new TestRequestHandler(new TestHostConnectionInfo { Endpoint = endpoint, Role = connectionRole, Transport = Transport.Sockets })) { // Attach to exit of parent process var parentProcessId = CommandLineArgumentsHelper.GetIntArgFromDict(argsDictionary, ParentProcessIdArgument); EqtTrace.Info("DefaultEngineInvoker: Monitoring parent process with id: '{0}'", parentProcessId); // In remote scenario we cannot monitor parent process, so we expect user to pass parentProcessId as -1 if (parentProcessId != -1) { var processHelper = new ProcessHelper(); processHelper.SetExitCallback( parentProcessId, () => { EqtTrace.Info("DefaultEngineInvoker: ParentProcess '{0}' Exited.", parentProcessId); new PlatformEnvironment().Exit(1); }); } // Initialize Communication EqtTrace.Info("DefaultEngineInvoker: Initialize communication on endpoint address: '{0}'", endpoint); requestHandler.InitializeCommunication(); // Initialize DataCollection Communication if data collection port is provided. var dcPort = CommandLineArgumentsHelper.GetIntArgFromDict(argsDictionary, DataCollectionPortArgument); if (dcPort > 0) { var dataCollectionTestCaseEventSender = DataCollectionTestCaseEventSender.Create(); dataCollectionTestCaseEventSender.InitializeCommunication(dcPort); dataCollectionTestCaseEventSender.WaitForRequestSenderConnection(ClientListenTimeOut); } // Checks for Telemetry Opted in or not from Command line Arguments. // By Default opting out in Test Host to handle scenario when user running old version of vstest.console var telemetryStatus = CommandLineArgumentsHelper.GetStringArgFromDict(argsDictionary, TelemetryOptedIn); var telemetryOptedIn = false; if (!string.IsNullOrWhiteSpace(telemetryStatus)) { if (telemetryStatus.Equals("true", StringComparison.Ordinal)) { telemetryOptedIn = true; } } var requestData = new RequestData { MetricsCollection = telemetryOptedIn ? (IMetricsCollection) new MetricsCollection() : new NoOpMetricsCollection(), IsTelemetryOptedIn = telemetryOptedIn }; // Start processing async in a different task EqtTrace.Info("DefaultEngineInvoker: Start Request Processing."); var processingTask = this.StartProcessingAsync(requestHandler, new TestHostManagerFactory(requestData)); // Wait for processing to complete. Task.WaitAny(processingTask); if (dcPort > 0) { // Close socket communication connection. DataCollectionTestCaseEventSender.Instance.Close(); } } }
public void Invoke(IDictionary <string, string> argsDictionary) { // Setup logging if enabled string logFile; if (argsDictionary.TryGetValue(LogFileArgument, out logFile)) { EqtTrace.InitializeVerboseTrace(logFile); } #if NET46 if (EqtTrace.IsInfoEnabled) { var appConfigText = System.IO.File.ReadAllText(AppDomain.CurrentDomain.SetupInformation.ConfigurationFile); EqtTrace.Info("DefaultEngineInvoker: Using Application Configuration: '{0}'", appConfigText); } #endif // Get port number and initialize communication var portNumber = CommandLineArgumentsHelper.GetIntArgFromDict(argsDictionary, PortArgument); // Start Processing of requests using (var requestHandler = new TestRequestHandler()) { // Attach to exit of parent process var parentProcessId = CommandLineArgumentsHelper.GetIntArgFromDict(argsDictionary, ParentProcessIdArgument); EqtTrace.Info("DefaultEngineInvoker: Monitoring parent process with id: '{0}'", parentProcessId); var processHelper = new ProcessHelper(); processHelper.SetExitCallback( parentProcessId, () => { EqtTrace.Info("DefaultEngineInvoker: ParentProcess '{0}' Exited.", parentProcessId); Environment.Exit(1); }); // Initialize Communication EqtTrace.Info("DefaultEngineInvoker: Initialize communication on port number: '{0}'", portNumber); requestHandler.InitializeCommunication(portNumber); // Initialize DataCollection Communication if data collection port is provided. var dcPort = CommandLineArgumentsHelper.GetIntArgFromDict(argsDictionary, DataCollectionPortArgument); if (dcPort > 0) { var dataCollectionTestCaseEventSender = DataCollectionTestCaseEventSender.Create(); dataCollectionTestCaseEventSender.InitializeCommunication(dcPort); dataCollectionTestCaseEventSender.WaitForRequestSenderConnection(ClientListenTimeOut); } // Start processing async in a different task EqtTrace.Info("DefaultEngineInvoker: Start Request Processing."); var processingTask = this.StartProcessingAsync(requestHandler, new TestHostManagerFactory()); // Wait for processing to complete. Task.WaitAny(processingTask); if (dcPort > 0) { // Close socket communication connection. DataCollectionTestCaseEventSender.Instance.Close(); } } }
public void Run(string[] args) { WaitForDebuggerIfEnabled(); var argsDictionary = CommandLineArgumentsHelper.GetArgumentsDictionary(args); // Setup logging if enabled string logFile; if (argsDictionary.TryGetValue(LogFileArgument, out logFile)) { var traceLevelInt = CommandLineArgumentsHelper.GetIntArgFromDict(argsDictionary, TraceLevelArgument); var isTraceLevelArgValid = Enum.IsDefined(typeof(PlatformTraceLevel), traceLevelInt); // In case traceLevelInt is not defined in PlatfromTraceLevel, default it to verbose. var traceLevel = isTraceLevelArgValid ? (PlatformTraceLevel)traceLevelInt : PlatformTraceLevel.Verbose; // Initialize trace. EqtTrace.InitializeTrace(logFile, traceLevel); // Log warning in case tracelevel passed in arg is invalid if (!isTraceLevelArgValid) { EqtTrace.Warning("DataCollectorMain.Run: Invalid trace level: {0}, defaulting to verbose tracelevel.", traceLevelInt); } } else { EqtTrace.DoNotInitailize = true; } if (EqtTrace.IsVerboseEnabled) { var version = typeof(DataCollectorMain) .GetTypeInfo() .Assembly .GetCustomAttribute <AssemblyInformationalVersionAttribute>()?.InformationalVersion; EqtTrace.Verbose($"Version: { version }"); } SetCultureSpecifiedByUser(); EqtTrace.Info("DataCollectorMain.Run: Starting data collector run with args: {0}", string.Join(",", args)); // Attach to exit of parent process var parentProcessId = CommandLineArgumentsHelper.GetIntArgFromDict(argsDictionary, ParentProcessArgument); EqtTrace.Info("DataCollector: Monitoring parent process with id: '{0}'", parentProcessId); this.processHelper.SetExitCallback( parentProcessId, (obj) => { EqtTrace.Info("DataCollector: ParentProcess '{0}' Exited.", parentProcessId); this.environment.Exit(1); }); // Get server port and initialize communication. string portValue; int port = argsDictionary.TryGetValue(PortArgument, out portValue) ? int.Parse(portValue) : 0; if (port <= 0) { throw new ArgumentException("Incorrect/No Port number"); } this.requestHandler.InitializeCommunication(port); // Can only do this after InitializeCommunication because datacollector cannot "Send Log" unless communications are initialized if (!string.IsNullOrEmpty(EqtTrace.LogFile)) { (this.requestHandler as DataCollectionRequestHandler)?.SendDataCollectionMessage(new DataCollectionMessageEventArgs(TestMessageLevel.Informational, string.Format("Logging DataCollector Diagnostics in file: {0}", EqtTrace.LogFile))); } // Start processing async in a different task EqtTrace.Info("DataCollector: Start Request Processing."); StartProcessing(); }