Skip to content

Commit 7ad452c

Browse files
Adding Translation layer logs (#2166)
* Adding Translation layer logs
1 parent 96bb81e commit 7ad452c

File tree

3 files changed

+113
-1
lines changed

3 files changed

+113
-1
lines changed

src/Microsoft.TestPlatform.VsTestConsole.TranslationLayer/VsTestConsoleRequestSender.cs

Lines changed: 103 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,11 @@ internal VsTestConsoleRequestSender(ICommunicationManager communicationManager,
6868
/// <returns>Port Number of hosted server on this side</returns>
6969
public int InitializeCommunication()
7070
{
71+
if (EqtTrace.IsInfoEnabled)
72+
{
73+
EqtTrace.Info("VsTestConsoleRequestSender.InitializeCommunication: Started.");
74+
}
75+
7176
this.processExitCancellationTokenSource = new CancellationTokenSource();
7277
this.handShakeSuccessful = false;
7378
this.handShakeComplete.Reset();
@@ -90,6 +95,11 @@ public int InitializeCommunication()
9095
this.handShakeComplete.Set();
9196
}
9297

98+
if (EqtTrace.IsInfoEnabled)
99+
{
100+
EqtTrace.Info("VsTestConsoleRequestSender.InitializeCommunication: Ended.");
101+
}
102+
93103
return port;
94104
}
95105

@@ -107,6 +117,11 @@ public bool WaitForRequestHandlerConnection(int clientConnectionTimeout)
107117
/// <inheritdoc/>
108118
public async Task<int> InitializeCommunicationAsync(int clientConnectionTimeout)
109119
{
120+
if (EqtTrace.IsInfoEnabled)
121+
{
122+
EqtTrace.Info($"VsTestConsoleRequestSender.InitializeCommunicationAsync: Started with client connection timeout {clientConnectionTimeout} milliseconds.");
123+
}
124+
110125
this.processExitCancellationTokenSource = new CancellationTokenSource();
111126
this.handShakeSuccessful = false;
112127
this.handShakeComplete.Reset();
@@ -126,18 +141,31 @@ public async Task<int> InitializeCommunicationAsync(int clientConnectionTimeout)
126141
this.handShakeComplete.Set();
127142
}
128143

144+
if (EqtTrace.IsInfoEnabled)
145+
{
146+
EqtTrace.Info("VsTestConsoleRequestSender.InitializeCommunicationAsync: Ended.");
147+
}
148+
129149
return this.handShakeSuccessful ? port : -1;
130150
}
131151

132152
/// <inheritdoc/>
133153
public void InitializeExtensions(IEnumerable<string> pathToAdditionalExtensions)
134154
{
155+
if (EqtTrace.IsInfoEnabled)
156+
{
157+
EqtTrace.Info($"VsTestConsoleRequestSender.InitializeExtensions: Initializing extensions with additional extensions path {string.Join(",", pathToAdditionalExtensions.ToList())}.");
158+
}
135159
this.communicationManager.SendMessage(MessageType.ExtensionsInitialize, pathToAdditionalExtensions, this.protocolVersion);
136160
}
137161

138162
/// <inheritdoc/>
139163
public void DiscoverTests(IEnumerable<string> sources, string runSettings, TestPlatformOptions options, ITestDiscoveryEventsHandler2 eventHandler)
140164
{
165+
if (EqtTrace.IsInfoEnabled)
166+
{
167+
EqtTrace.Info("VsTestConsoleRequestSender.DiscoverTests: Starting test discovery.");
168+
}
141169
this.SendMessageAndListenAndReportTestCases(sources, runSettings, options, eventHandler);
142170
}
143171

@@ -146,12 +174,21 @@ public void DiscoverTests(IEnumerable<string> sources, string runSettings, TestP
146174
/// </summary>
147175
public async Task DiscoverTestsAsync(IEnumerable<string> sources, string runSettings, TestPlatformOptions options, ITestDiscoveryEventsHandler2 eventHandler)
148176
{
177+
if (EqtTrace.IsInfoEnabled)
178+
{
179+
EqtTrace.Info("VsTestConsoleRequestSender.DiscoverTestsAsync: Starting test discovery.");
180+
}
149181
await this.SendMessageAndListenAndReportTestCasesAsync(sources, runSettings, options, eventHandler);
150182
}
151183

152184
/// <inheritdoc/>
153185
public void StartTestRun(IEnumerable<string> sources, string runSettings, TestPlatformOptions options, ITestRunEventsHandler runEventsHandler)
154186
{
187+
if (EqtTrace.IsInfoEnabled)
188+
{
189+
EqtTrace.Info("VsTestConsoleRequestSender.StartTestRun: Starting test run.");
190+
}
191+
155192
this.SendMessageAndListenAndReportTestResults(
156193
MessageType.TestRunAllSourcesWithDefaultHost,
157194
new TestRunRequestPayload() { Sources = sources.ToList(), RunSettings = runSettings, TestPlatformOptions = options },
@@ -162,6 +199,10 @@ public void StartTestRun(IEnumerable<string> sources, string runSettings, TestPl
162199
/// <inheritdoc/>
163200
public async Task StartTestRunAsync(IEnumerable<string> sources, string runSettings, TestPlatformOptions options, ITestRunEventsHandler runEventsHandler)
164201
{
202+
if (EqtTrace.IsInfoEnabled)
203+
{
204+
EqtTrace.Info("VsTestConsoleRequestSender.StartTestRunAsync: Starting test run.");
205+
}
165206
await this.SendMessageAndListenAndReportTestResultsAsync(
166207
MessageType.TestRunAllSourcesWithDefaultHost,
167208
new TestRunRequestPayload() { Sources = sources.ToList(), RunSettings = runSettings, TestPlatformOptions = options },
@@ -172,6 +213,10 @@ await this.SendMessageAndListenAndReportTestResultsAsync(
172213
/// <inheritdoc/>
173214
public void StartTestRun(IEnumerable<TestCase> testCases, string runSettings, TestPlatformOptions options, ITestRunEventsHandler runEventsHandler)
174215
{
216+
if (EqtTrace.IsInfoEnabled)
217+
{
218+
EqtTrace.Info("VsTestConsoleRequestSender.StartTestRun: Starting test run.");
219+
}
175220
this.SendMessageAndListenAndReportTestResults(
176221
MessageType.TestRunAllSourcesWithDefaultHost,
177222
new TestRunRequestPayload() { TestCases = testCases.ToList(), RunSettings = runSettings, TestPlatformOptions = options },
@@ -182,6 +227,11 @@ public void StartTestRun(IEnumerable<TestCase> testCases, string runSettings, Te
182227
/// <inheritdoc/>
183228
public async Task StartTestRunAsync(IEnumerable<TestCase> testCases, string runSettings, TestPlatformOptions options, ITestRunEventsHandler runEventsHandler)
184229
{
230+
if (EqtTrace.IsInfoEnabled)
231+
{
232+
EqtTrace.Info("VsTestConsoleRequestSender.StartTestRunAsync: Starting test run.");
233+
}
234+
185235
await this.SendMessageAndListenAndReportTestResultsAsync(
186236
MessageType.TestRunAllSourcesWithDefaultHost,
187237
new TestRunRequestPayload() { TestCases = testCases.ToList(), RunSettings = runSettings, TestPlatformOptions = options },
@@ -197,6 +247,11 @@ public void StartTestRunWithCustomHost(
197247
ITestRunEventsHandler runEventsHandler,
198248
ITestHostLauncher customHostLauncher)
199249
{
250+
if (EqtTrace.IsInfoEnabled)
251+
{
252+
EqtTrace.Info("VsTestConsoleRequestSender.StartTestRunWithCustomHost: Starting test run.");
253+
}
254+
200255
this.SendMessageAndListenAndReportTestResults(
201256
MessageType.GetTestRunnerProcessStartInfoForRunAll,
202257
new TestRunRequestPayload()
@@ -218,6 +273,11 @@ public async Task StartTestRunWithCustomHostAsync(
218273
ITestRunEventsHandler runEventsHandler,
219274
ITestHostLauncher customHostLauncher)
220275
{
276+
if (EqtTrace.IsInfoEnabled)
277+
{
278+
EqtTrace.Info("VsTestConsoleRequestSender.StartTestRunWithCustomHostAsync: Starting test run.");
279+
}
280+
221281
await this.SendMessageAndListenAndReportTestResultsAsync(
222282
MessageType.GetTestRunnerProcessStartInfoForRunAll,
223283
new TestRunRequestPayload()
@@ -234,6 +294,11 @@ await this.SendMessageAndListenAndReportTestResultsAsync(
234294
/// <inheritdoc/>
235295
public void StartTestRunWithCustomHost(IEnumerable<TestCase> testCases, string runSettings, TestPlatformOptions options, ITestRunEventsHandler runEventsHandler, ITestHostLauncher customHostLauncher)
236296
{
297+
if (EqtTrace.IsInfoEnabled)
298+
{
299+
EqtTrace.Info("VsTestConsoleRequestSender.StartTestRunWithCustomHost: Starting test run.");
300+
}
301+
237302
this.SendMessageAndListenAndReportTestResults(
238303
MessageType.GetTestRunnerProcessStartInfoForRunSelected,
239304
new TestRunRequestPayload
@@ -250,6 +315,11 @@ public void StartTestRunWithCustomHost(IEnumerable<TestCase> testCases, string r
250315
/// <inheritdoc/>
251316
public async Task StartTestRunWithCustomHostAsync(IEnumerable<TestCase> testCases, string runSettings, TestPlatformOptions options, ITestRunEventsHandler runEventsHandler, ITestHostLauncher customHostLauncher)
252317
{
318+
if (EqtTrace.IsInfoEnabled)
319+
{
320+
EqtTrace.Info("VsTestConsoleRequestSender.StartTestRunWithCustomHostAsync: Starting test run.");
321+
}
322+
253323
await this.SendMessageAndListenAndReportTestResultsAsync(
254324
MessageType.GetTestRunnerProcessStartInfoForRunSelected,
255325
new TestRunRequestPayload()
@@ -266,18 +336,30 @@ await this.SendMessageAndListenAndReportTestResultsAsync(
266336
/// <inheritdoc/>
267337
public void CancelTestRun()
268338
{
339+
if (EqtTrace.IsInfoEnabled)
340+
{
341+
EqtTrace.Info("VsTestConsoleRequestSender.CancelTestRun: Cancelling test run.");
342+
}
269343
this.communicationManager.SendMessage(MessageType.CancelTestRun);
270344
}
271345

272346
/// <inheritdoc/>
273347
public void AbortTestRun()
274348
{
349+
if (EqtTrace.IsInfoEnabled)
350+
{
351+
EqtTrace.Info("VsTestConsoleRequestSender.AbortTestRun: Aborting test run.");
352+
}
275353
this.communicationManager.SendMessage(MessageType.AbortTestRun);
276354
}
277355

278356
/// <inheritdoc/>
279357
public void CancelDiscovery()
280358
{
359+
if (EqtTrace.IsInfoEnabled)
360+
{
361+
EqtTrace.Info("VsTestConsoleRequestSender.CancelDiscovery: Cancelling test discovery.");
362+
}
281363
this.communicationManager.SendMessage(MessageType.CancelDiscovery);
282364
}
283365

@@ -328,7 +410,7 @@ private bool HandShakeWithVsTestConsole()
328410
else if (message.MessageType == MessageType.ProtocolError)
329411
{
330412
// TODO : Payload for ProtocolError needs to finalized.
331-
EqtTrace.Error("VsTestConsoleRequestSender.HandShakeWithVsTestConsole: Version Check failed. ProtolError was revceived from the runner");
413+
EqtTrace.Error("VsTestConsoleRequestSender.HandShakeWithVsTestConsole: Version Check failed. ProtolError was received from the runner");
332414
}
333415
else
334416
{
@@ -400,6 +482,11 @@ private void SendMessageAndListenAndReportTestCases(IEnumerable<string> sources,
400482
}
401483
else if (string.Equals(MessageType.DiscoveryComplete, message.MessageType))
402484
{
485+
if (EqtTrace.IsInfoEnabled)
486+
{
487+
EqtTrace.Info("VsTestConsoleRequestSender.SendMessageAndListenAndReportTestCases: Discovery complete.");
488+
}
489+
403490
var discoveryCompletePayload =
404491
this.dataSerializer.DeserializePayload<DiscoveryCompletePayload>(message);
405492

@@ -461,6 +548,11 @@ private async Task SendMessageAndListenAndReportTestCasesAsync(IEnumerable<strin
461548
}
462549
else if (string.Equals(MessageType.DiscoveryComplete, message.MessageType))
463550
{
551+
if (EqtTrace.IsInfoEnabled)
552+
{
553+
EqtTrace.Info("VsTestConsoleRequestSender.SendMessageAndListenAndReportTestCasesAsync: Discovery complete.");
554+
}
555+
464556
var discoveryCompletePayload =
465557
this.dataSerializer.DeserializePayload<DiscoveryCompletePayload>(message);
466558

@@ -520,6 +612,11 @@ private void SendMessageAndListenAndReportTestResults(string messageType, object
520612
}
521613
else if (string.Equals(MessageType.ExecutionComplete, message.MessageType))
522614
{
615+
if (EqtTrace.IsInfoEnabled)
616+
{
617+
EqtTrace.Info("VsTestConsoleRequestSender.SendMessageAndListenAndReportTestResults: Execution complete.");
618+
}
619+
523620
var testRunCompletePayload =
524621
this.dataSerializer.DeserializePayload<TestRunCompletePayload>(message);
525622

@@ -578,6 +675,11 @@ private async Task SendMessageAndListenAndReportTestResultsAsync(string messageT
578675
}
579676
else if (string.Equals(MessageType.ExecutionComplete, message.MessageType))
580677
{
678+
if (EqtTrace.IsInfoEnabled)
679+
{
680+
EqtTrace.Info("VsTestConsoleRequestSender.SendMessageAndListenAndReportTestResultsAsync: Execution complete.");
681+
}
682+
581683
var testRunCompletePayload =
582684
this.dataSerializer.DeserializePayload<TestRunCompletePayload>(message);
583685

src/Microsoft.TestPlatform.VsTestConsole.TranslationLayer/VsTestConsoleWrapper.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,11 @@ internal VsTestConsoleWrapper(ITranslationLayerRequestSender requestSender, IPro
114114
/// <inheritdoc/>
115115
public void StartSession()
116116
{
117+
if (EqtTrace.IsInfoEnabled)
118+
{
119+
EqtTrace.Info("VsTestConsoleWrapper.StartSession: Starting VsTestConsoleWrapper session.");
120+
}
121+
117122
this.testPlatformEventSource.TranslationLayerInitializeStart();
118123

119124
// Start communication
@@ -140,6 +145,7 @@ public void StartSession()
140145
public void InitializeExtensions(IEnumerable<string> pathToAdditionalExtensions)
141146
{
142147
this.EnsureInitialized();
148+
143149
this.pathToAdditionalExtensions = pathToAdditionalExtensions.ToList();
144150
this.requestSender.InitializeExtensions(this.pathToAdditionalExtensions);
145151
}
@@ -256,6 +262,8 @@ public void AbortTestRun()
256262
/// <inheritdoc/>
257263
public void EndSession()
258264
{
265+
EqtTrace.Info("VsTestConsoleWrapper.EndSession: Endinhg VsTestConsoleWrapper session");
266+
259267
this.requestSender.EndSession();
260268
this.requestSender.Close();
261269

src/Microsoft.TestPlatform.VsTestConsole.TranslationLayer/VsTestConsoleWrapperAsync.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@ internal VsTestConsoleWrapperAsync(ITranslationLayerRequestSenderAsync requestSe
9090
/// <inheritdoc/>
9191
public async Task StartSessionAsync()
9292
{
93+
EqtTrace.Info("VsTestConsoleWrapperAsync.StartSessionAsync: Starting VsTestConsoleWrapper session");
94+
9395
this.testPlatformEventSource.TranslationLayerInitializeStart();
9496

9597
var timeout = EnvironmentHelper.GetConnectionTimeout();

0 commit comments

Comments
 (0)