Skip to content

Commit

Permalink
Adding Translation layer logs (#2166)
Browse files Browse the repository at this point in the history
* Adding Translation layer logs
  • Loading branch information
vagisha-nidhi authored Sep 12, 2019
1 parent 96bb81e commit 7ad452c
Show file tree
Hide file tree
Showing 3 changed files with 113 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ internal VsTestConsoleRequestSender(ICommunicationManager communicationManager,
/// <returns>Port Number of hosted server on this side</returns>
public int InitializeCommunication()
{
if (EqtTrace.IsInfoEnabled)
{
EqtTrace.Info("VsTestConsoleRequestSender.InitializeCommunication: Started.");
}

this.processExitCancellationTokenSource = new CancellationTokenSource();
this.handShakeSuccessful = false;
this.handShakeComplete.Reset();
Expand All @@ -90,6 +95,11 @@ public int InitializeCommunication()
this.handShakeComplete.Set();
}

if (EqtTrace.IsInfoEnabled)
{
EqtTrace.Info("VsTestConsoleRequestSender.InitializeCommunication: Ended.");
}

return port;
}

Expand All @@ -107,6 +117,11 @@ public bool WaitForRequestHandlerConnection(int clientConnectionTimeout)
/// <inheritdoc/>
public async Task<int> 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();
Expand All @@ -126,18 +141,31 @@ public async Task<int> InitializeCommunicationAsync(int clientConnectionTimeout)
this.handShakeComplete.Set();
}

if (EqtTrace.IsInfoEnabled)
{
EqtTrace.Info("VsTestConsoleRequestSender.InitializeCommunicationAsync: Ended.");
}

return this.handShakeSuccessful ? port : -1;
}

/// <inheritdoc/>
public void InitializeExtensions(IEnumerable<string> 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);
}

/// <inheritdoc/>
public void DiscoverTests(IEnumerable<string> sources, string runSettings, TestPlatformOptions options, ITestDiscoveryEventsHandler2 eventHandler)
{
if (EqtTrace.IsInfoEnabled)
{
EqtTrace.Info("VsTestConsoleRequestSender.DiscoverTests: Starting test discovery.");
}
this.SendMessageAndListenAndReportTestCases(sources, runSettings, options, eventHandler);
}

Expand All @@ -146,12 +174,21 @@ public void DiscoverTests(IEnumerable<string> sources, string runSettings, TestP
/// </summary>
public async Task DiscoverTestsAsync(IEnumerable<string> sources, string runSettings, TestPlatformOptions options, ITestDiscoveryEventsHandler2 eventHandler)
{
if (EqtTrace.IsInfoEnabled)
{
EqtTrace.Info("VsTestConsoleRequestSender.DiscoverTestsAsync: Starting test discovery.");
}
await this.SendMessageAndListenAndReportTestCasesAsync(sources, runSettings, options, eventHandler);
}

/// <inheritdoc/>
public void StartTestRun(IEnumerable<string> 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 },
Expand All @@ -162,6 +199,10 @@ public void StartTestRun(IEnumerable<string> sources, string runSettings, TestPl
/// <inheritdoc/>
public async Task StartTestRunAsync(IEnumerable<string> 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 },
Expand All @@ -172,6 +213,10 @@ await this.SendMessageAndListenAndReportTestResultsAsync(
/// <inheritdoc/>
public void StartTestRun(IEnumerable<TestCase> 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 },
Expand All @@ -182,6 +227,11 @@ public void StartTestRun(IEnumerable<TestCase> testCases, string runSettings, Te
/// <inheritdoc/>
public async Task StartTestRunAsync(IEnumerable<TestCase> 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 },
Expand All @@ -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()
Expand All @@ -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()
Expand All @@ -234,6 +294,11 @@ await this.SendMessageAndListenAndReportTestResultsAsync(
/// <inheritdoc/>
public void StartTestRunWithCustomHost(IEnumerable<TestCase> 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
Expand All @@ -250,6 +315,11 @@ public void StartTestRunWithCustomHost(IEnumerable<TestCase> testCases, string r
/// <inheritdoc/>
public async Task StartTestRunWithCustomHostAsync(IEnumerable<TestCase> 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()
Expand All @@ -266,18 +336,30 @@ await this.SendMessageAndListenAndReportTestResultsAsync(
/// <inheritdoc/>
public void CancelTestRun()
{
if (EqtTrace.IsInfoEnabled)
{
EqtTrace.Info("VsTestConsoleRequestSender.CancelTestRun: Cancelling test run.");
}
this.communicationManager.SendMessage(MessageType.CancelTestRun);
}

/// <inheritdoc/>
public void AbortTestRun()
{
if (EqtTrace.IsInfoEnabled)
{
EqtTrace.Info("VsTestConsoleRequestSender.AbortTestRun: Aborting test run.");
}
this.communicationManager.SendMessage(MessageType.AbortTestRun);
}

/// <inheritdoc/>
public void CancelDiscovery()
{
if (EqtTrace.IsInfoEnabled)
{
EqtTrace.Info("VsTestConsoleRequestSender.CancelDiscovery: Cancelling test discovery.");
}
this.communicationManager.SendMessage(MessageType.CancelDiscovery);
}

Expand Down Expand Up @@ -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
{
Expand Down Expand Up @@ -400,6 +482,11 @@ private void SendMessageAndListenAndReportTestCases(IEnumerable<string> sources,
}
else if (string.Equals(MessageType.DiscoveryComplete, message.MessageType))
{
if (EqtTrace.IsInfoEnabled)
{
EqtTrace.Info("VsTestConsoleRequestSender.SendMessageAndListenAndReportTestCases: Discovery complete.");
}

var discoveryCompletePayload =
this.dataSerializer.DeserializePayload<DiscoveryCompletePayload>(message);

Expand Down Expand Up @@ -461,6 +548,11 @@ private async Task SendMessageAndListenAndReportTestCasesAsync(IEnumerable<strin
}
else if (string.Equals(MessageType.DiscoveryComplete, message.MessageType))
{
if (EqtTrace.IsInfoEnabled)
{
EqtTrace.Info("VsTestConsoleRequestSender.SendMessageAndListenAndReportTestCasesAsync: Discovery complete.");
}

var discoveryCompletePayload =
this.dataSerializer.DeserializePayload<DiscoveryCompletePayload>(message);

Expand Down Expand Up @@ -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<TestRunCompletePayload>(message);

Expand Down Expand Up @@ -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<TestRunCompletePayload>(message);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,11 @@ internal VsTestConsoleWrapper(ITranslationLayerRequestSender requestSender, IPro
/// <inheritdoc/>
public void StartSession()
{
if (EqtTrace.IsInfoEnabled)
{
EqtTrace.Info("VsTestConsoleWrapper.StartSession: Starting VsTestConsoleWrapper session.");
}

this.testPlatformEventSource.TranslationLayerInitializeStart();

// Start communication
Expand All @@ -140,6 +145,7 @@ public void StartSession()
public void InitializeExtensions(IEnumerable<string> pathToAdditionalExtensions)
{
this.EnsureInitialized();

this.pathToAdditionalExtensions = pathToAdditionalExtensions.ToList();
this.requestSender.InitializeExtensions(this.pathToAdditionalExtensions);
}
Expand Down Expand Up @@ -256,6 +262,8 @@ public void AbortTestRun()
/// <inheritdoc/>
public void EndSession()
{
EqtTrace.Info("VsTestConsoleWrapper.EndSession: Endinhg VsTestConsoleWrapper session");

this.requestSender.EndSession();
this.requestSender.Close();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ internal VsTestConsoleWrapperAsync(ITranslationLayerRequestSenderAsync requestSe
/// <inheritdoc/>
public async Task StartSessionAsync()
{
EqtTrace.Info("VsTestConsoleWrapperAsync.StartSessionAsync: Starting VsTestConsoleWrapper session");

this.testPlatformEventSource.TranslationLayerInitializeStart();

var timeout = EnvironmentHelper.GetConnectionTimeout();
Expand Down

0 comments on commit 7ad452c

Please sign in to comment.