From 7ad452c7f47cf317bc02a965a5cb8c75a3b40e08 Mon Sep 17 00:00:00 2001 From: Vagisha Nidhi Date: Thu, 12 Sep 2019 13:36:21 +0530 Subject: [PATCH] Adding Translation layer logs (#2166) * Adding Translation layer logs --- .../VsTestConsoleRequestSender.cs | 104 +++++++++++++++++- .../VsTestConsoleWrapper.cs | 8 ++ .../VsTestConsoleWrapperAsync.cs | 2 + 3 files changed, 113 insertions(+), 1 deletion(-) diff --git a/src/Microsoft.TestPlatform.VsTestConsole.TranslationLayer/VsTestConsoleRequestSender.cs b/src/Microsoft.TestPlatform.VsTestConsole.TranslationLayer/VsTestConsoleRequestSender.cs index 1f4222fea3..9067b03042 100644 --- a/src/Microsoft.TestPlatform.VsTestConsole.TranslationLayer/VsTestConsoleRequestSender.cs +++ b/src/Microsoft.TestPlatform.VsTestConsole.TranslationLayer/VsTestConsoleRequestSender.cs @@ -68,6 +68,11 @@ internal VsTestConsoleRequestSender(ICommunicationManager communicationManager, /// Port Number of hosted server on this side public int InitializeCommunication() { + if (EqtTrace.IsInfoEnabled) + { + EqtTrace.Info("VsTestConsoleRequestSender.InitializeCommunication: Started."); + } + this.processExitCancellationTokenSource = new CancellationTokenSource(); this.handShakeSuccessful = false; this.handShakeComplete.Reset(); @@ -90,6 +95,11 @@ public int InitializeCommunication() this.handShakeComplete.Set(); } + if (EqtTrace.IsInfoEnabled) + { + EqtTrace.Info("VsTestConsoleRequestSender.InitializeCommunication: Ended."); + } + return port; } @@ -107,6 +117,11 @@ public bool WaitForRequestHandlerConnection(int clientConnectionTimeout) /// public async Task InitializeCommunicationAsync(int clientConnectionTimeout) { + if (EqtTrace.IsInfoEnabled) + { + EqtTrace.Info($"VsTestConsoleRequestSender.InitializeCommunicationAsync: Started with client connection timeout {clientConnectionTimeout} milliseconds."); + } + this.processExitCancellationTokenSource = new CancellationTokenSource(); this.handShakeSuccessful = false; this.handShakeComplete.Reset(); @@ -126,18 +141,31 @@ public async Task InitializeCommunicationAsync(int clientConnectionTimeout) this.handShakeComplete.Set(); } + if (EqtTrace.IsInfoEnabled) + { + EqtTrace.Info("VsTestConsoleRequestSender.InitializeCommunicationAsync: Ended."); + } + return this.handShakeSuccessful ? port : -1; } /// public void InitializeExtensions(IEnumerable pathToAdditionalExtensions) { + if (EqtTrace.IsInfoEnabled) + { + EqtTrace.Info($"VsTestConsoleRequestSender.InitializeExtensions: Initializing extensions with additional extensions path {string.Join(",", pathToAdditionalExtensions.ToList())}."); + } this.communicationManager.SendMessage(MessageType.ExtensionsInitialize, pathToAdditionalExtensions, this.protocolVersion); } /// public void DiscoverTests(IEnumerable sources, string runSettings, TestPlatformOptions options, ITestDiscoveryEventsHandler2 eventHandler) { + if (EqtTrace.IsInfoEnabled) + { + EqtTrace.Info("VsTestConsoleRequestSender.DiscoverTests: Starting test discovery."); + } this.SendMessageAndListenAndReportTestCases(sources, runSettings, options, eventHandler); } @@ -146,12 +174,21 @@ public void DiscoverTests(IEnumerable sources, string runSettings, TestP /// public async Task DiscoverTestsAsync(IEnumerable sources, string runSettings, TestPlatformOptions options, ITestDiscoveryEventsHandler2 eventHandler) { + if (EqtTrace.IsInfoEnabled) + { + EqtTrace.Info("VsTestConsoleRequestSender.DiscoverTestsAsync: Starting test discovery."); + } await this.SendMessageAndListenAndReportTestCasesAsync(sources, runSettings, options, eventHandler); } /// public void StartTestRun(IEnumerable sources, string runSettings, TestPlatformOptions options, ITestRunEventsHandler runEventsHandler) { + if (EqtTrace.IsInfoEnabled) + { + EqtTrace.Info("VsTestConsoleRequestSender.StartTestRun: Starting test run."); + } + this.SendMessageAndListenAndReportTestResults( MessageType.TestRunAllSourcesWithDefaultHost, new TestRunRequestPayload() { Sources = sources.ToList(), RunSettings = runSettings, TestPlatformOptions = options }, @@ -162,6 +199,10 @@ public void StartTestRun(IEnumerable sources, string runSettings, TestPl /// public async Task StartTestRunAsync(IEnumerable sources, string runSettings, TestPlatformOptions options, ITestRunEventsHandler runEventsHandler) { + if (EqtTrace.IsInfoEnabled) + { + EqtTrace.Info("VsTestConsoleRequestSender.StartTestRunAsync: Starting test run."); + } await this.SendMessageAndListenAndReportTestResultsAsync( MessageType.TestRunAllSourcesWithDefaultHost, new TestRunRequestPayload() { Sources = sources.ToList(), RunSettings = runSettings, TestPlatformOptions = options }, @@ -172,6 +213,10 @@ await this.SendMessageAndListenAndReportTestResultsAsync( /// public void StartTestRun(IEnumerable testCases, string runSettings, TestPlatformOptions options, ITestRunEventsHandler runEventsHandler) { + if (EqtTrace.IsInfoEnabled) + { + EqtTrace.Info("VsTestConsoleRequestSender.StartTestRun: Starting test run."); + } this.SendMessageAndListenAndReportTestResults( MessageType.TestRunAllSourcesWithDefaultHost, new TestRunRequestPayload() { TestCases = testCases.ToList(), RunSettings = runSettings, TestPlatformOptions = options }, @@ -182,6 +227,11 @@ public void StartTestRun(IEnumerable testCases, string runSettings, Te /// public async Task StartTestRunAsync(IEnumerable testCases, string runSettings, TestPlatformOptions options, ITestRunEventsHandler runEventsHandler) { + if (EqtTrace.IsInfoEnabled) + { + EqtTrace.Info("VsTestConsoleRequestSender.StartTestRunAsync: Starting test run."); + } + await this.SendMessageAndListenAndReportTestResultsAsync( MessageType.TestRunAllSourcesWithDefaultHost, new TestRunRequestPayload() { TestCases = testCases.ToList(), RunSettings = runSettings, TestPlatformOptions = options }, @@ -197,6 +247,11 @@ public void StartTestRunWithCustomHost( ITestRunEventsHandler runEventsHandler, ITestHostLauncher customHostLauncher) { + if (EqtTrace.IsInfoEnabled) + { + EqtTrace.Info("VsTestConsoleRequestSender.StartTestRunWithCustomHost: Starting test run."); + } + this.SendMessageAndListenAndReportTestResults( MessageType.GetTestRunnerProcessStartInfoForRunAll, new TestRunRequestPayload() @@ -218,6 +273,11 @@ public async Task StartTestRunWithCustomHostAsync( ITestRunEventsHandler runEventsHandler, ITestHostLauncher customHostLauncher) { + if (EqtTrace.IsInfoEnabled) + { + EqtTrace.Info("VsTestConsoleRequestSender.StartTestRunWithCustomHostAsync: Starting test run."); + } + await this.SendMessageAndListenAndReportTestResultsAsync( MessageType.GetTestRunnerProcessStartInfoForRunAll, new TestRunRequestPayload() @@ -234,6 +294,11 @@ await this.SendMessageAndListenAndReportTestResultsAsync( /// public void StartTestRunWithCustomHost(IEnumerable testCases, string runSettings, TestPlatformOptions options, ITestRunEventsHandler runEventsHandler, ITestHostLauncher customHostLauncher) { + if (EqtTrace.IsInfoEnabled) + { + EqtTrace.Info("VsTestConsoleRequestSender.StartTestRunWithCustomHost: Starting test run."); + } + this.SendMessageAndListenAndReportTestResults( MessageType.GetTestRunnerProcessStartInfoForRunSelected, new TestRunRequestPayload @@ -250,6 +315,11 @@ public void StartTestRunWithCustomHost(IEnumerable testCases, string r /// public async Task StartTestRunWithCustomHostAsync(IEnumerable testCases, string runSettings, TestPlatformOptions options, ITestRunEventsHandler runEventsHandler, ITestHostLauncher customHostLauncher) { + if (EqtTrace.IsInfoEnabled) + { + EqtTrace.Info("VsTestConsoleRequestSender.StartTestRunWithCustomHostAsync: Starting test run."); + } + await this.SendMessageAndListenAndReportTestResultsAsync( MessageType.GetTestRunnerProcessStartInfoForRunSelected, new TestRunRequestPayload() @@ -266,18 +336,30 @@ await this.SendMessageAndListenAndReportTestResultsAsync( /// public void CancelTestRun() { + if (EqtTrace.IsInfoEnabled) + { + EqtTrace.Info("VsTestConsoleRequestSender.CancelTestRun: Cancelling test run."); + } this.communicationManager.SendMessage(MessageType.CancelTestRun); } /// public void AbortTestRun() { + if (EqtTrace.IsInfoEnabled) + { + EqtTrace.Info("VsTestConsoleRequestSender.AbortTestRun: Aborting test run."); + } this.communicationManager.SendMessage(MessageType.AbortTestRun); } /// public void CancelDiscovery() { + if (EqtTrace.IsInfoEnabled) + { + EqtTrace.Info("VsTestConsoleRequestSender.CancelDiscovery: Cancelling test discovery."); + } this.communicationManager.SendMessage(MessageType.CancelDiscovery); } @@ -328,7 +410,7 @@ private bool HandShakeWithVsTestConsole() else if (message.MessageType == MessageType.ProtocolError) { // TODO : Payload for ProtocolError needs to finalized. - EqtTrace.Error("VsTestConsoleRequestSender.HandShakeWithVsTestConsole: Version Check failed. ProtolError was revceived from the runner"); + EqtTrace.Error("VsTestConsoleRequestSender.HandShakeWithVsTestConsole: Version Check failed. ProtolError was received from the runner"); } else { @@ -400,6 +482,11 @@ private void SendMessageAndListenAndReportTestCases(IEnumerable sources, } else if (string.Equals(MessageType.DiscoveryComplete, message.MessageType)) { + if (EqtTrace.IsInfoEnabled) + { + EqtTrace.Info("VsTestConsoleRequestSender.SendMessageAndListenAndReportTestCases: Discovery complete."); + } + var discoveryCompletePayload = this.dataSerializer.DeserializePayload(message); @@ -461,6 +548,11 @@ private async Task SendMessageAndListenAndReportTestCasesAsync(IEnumerable(message); @@ -520,6 +612,11 @@ private void SendMessageAndListenAndReportTestResults(string messageType, object } else if (string.Equals(MessageType.ExecutionComplete, message.MessageType)) { + if (EqtTrace.IsInfoEnabled) + { + EqtTrace.Info("VsTestConsoleRequestSender.SendMessageAndListenAndReportTestResults: Execution complete."); + } + var testRunCompletePayload = this.dataSerializer.DeserializePayload(message); @@ -578,6 +675,11 @@ private async Task SendMessageAndListenAndReportTestResultsAsync(string messageT } else if (string.Equals(MessageType.ExecutionComplete, message.MessageType)) { + if (EqtTrace.IsInfoEnabled) + { + EqtTrace.Info("VsTestConsoleRequestSender.SendMessageAndListenAndReportTestResultsAsync: Execution complete."); + } + var testRunCompletePayload = this.dataSerializer.DeserializePayload(message); diff --git a/src/Microsoft.TestPlatform.VsTestConsole.TranslationLayer/VsTestConsoleWrapper.cs b/src/Microsoft.TestPlatform.VsTestConsole.TranslationLayer/VsTestConsoleWrapper.cs index e947ea8617..d22e5eb3a9 100644 --- a/src/Microsoft.TestPlatform.VsTestConsole.TranslationLayer/VsTestConsoleWrapper.cs +++ b/src/Microsoft.TestPlatform.VsTestConsole.TranslationLayer/VsTestConsoleWrapper.cs @@ -114,6 +114,11 @@ internal VsTestConsoleWrapper(ITranslationLayerRequestSender requestSender, IPro /// public void StartSession() { + if (EqtTrace.IsInfoEnabled) + { + EqtTrace.Info("VsTestConsoleWrapper.StartSession: Starting VsTestConsoleWrapper session."); + } + this.testPlatformEventSource.TranslationLayerInitializeStart(); // Start communication @@ -140,6 +145,7 @@ public void StartSession() public void InitializeExtensions(IEnumerable pathToAdditionalExtensions) { this.EnsureInitialized(); + this.pathToAdditionalExtensions = pathToAdditionalExtensions.ToList(); this.requestSender.InitializeExtensions(this.pathToAdditionalExtensions); } @@ -256,6 +262,8 @@ public void AbortTestRun() /// public void EndSession() { + EqtTrace.Info("VsTestConsoleWrapper.EndSession: Endinhg VsTestConsoleWrapper session"); + this.requestSender.EndSession(); this.requestSender.Close(); diff --git a/src/Microsoft.TestPlatform.VsTestConsole.TranslationLayer/VsTestConsoleWrapperAsync.cs b/src/Microsoft.TestPlatform.VsTestConsole.TranslationLayer/VsTestConsoleWrapperAsync.cs index 67f6a8471e..ca0a357c75 100644 --- a/src/Microsoft.TestPlatform.VsTestConsole.TranslationLayer/VsTestConsoleWrapperAsync.cs +++ b/src/Microsoft.TestPlatform.VsTestConsole.TranslationLayer/VsTestConsoleWrapperAsync.cs @@ -90,6 +90,8 @@ internal VsTestConsoleWrapperAsync(ITranslationLayerRequestSenderAsync requestSe /// public async Task StartSessionAsync() { + EqtTrace.Info("VsTestConsoleWrapperAsync.StartSessionAsync: Starting VsTestConsoleWrapper session"); + this.testPlatformEventSource.TranslationLayerInitializeStart(); var timeout = EnvironmentHelper.GetConnectionTimeout();