Skip to content

Commit

Permalink
Review comments #1
Browse files Browse the repository at this point in the history
  • Loading branch information
jakubch1 committed Jun 11, 2020
1 parent 44c5fdc commit 39f3f84
Show file tree
Hide file tree
Showing 46 changed files with 257 additions and 247 deletions.
27 changes: 12 additions & 15 deletions src/Microsoft.TestPlatform.Client/DesignMode/DesignModeClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,19 @@ namespace Microsoft.VisualStudio.TestPlatform.Client.DesignMode
using System.Net;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.VisualStudio.TestPlatform.Client.MultiTestRunsFinalization;
using Microsoft.VisualStudio.TestPlatform.Client.MultiTestRunFinalization;
using Microsoft.VisualStudio.TestPlatform.Client.RequestHelper;
using Microsoft.VisualStudio.TestPlatform.Common.Logging;
using Microsoft.VisualStudio.TestPlatform.Common.Utilities;
using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities;
using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces;
using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.ObjectModel;
using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Helpers;
using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.DataCollection;
using Microsoft.VisualStudio.TestPlatform.ObjectModel;
using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client;
using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging;
using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions;
using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces;
using Microsoft.VisualStudio.TestPlatform.Utilities;
using CommunicationUtilitiesResources = Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Resources.Resources;
using CoreUtilitiesConstants = Microsoft.VisualStudio.TestPlatform.CoreUtilities.Constants;
using ObjectModelConstants = Microsoft.VisualStudio.TestPlatform.ObjectModel.Constants;
Expand Down Expand Up @@ -201,11 +199,11 @@ private void ProcessRequests(ITestRequestManager testRequestManager)
break;
}

case MessageType.MultiTestRunsFinalizationStart:
case MessageType.MultiTestRunFinalizationStart:
{
var multiTestRunsFinalizationPayload =
this.communicationManager.DeserializePayload<MultiTestRunsFinalizationPayload>(message);
this.StartMultiTestRunsFinalization(multiTestRunsFinalizationPayload, testRequestManager);
var multiTestRunFinalizationPayload =
this.communicationManager.DeserializePayload<MultiTestRunFinalizationPayload>(message);
this.StartMultiTestRunFinalization(multiTestRunFinalizationPayload, testRequestManager);
break;
}

Expand All @@ -227,9 +225,9 @@ private void ProcessRequests(ITestRequestManager testRequestManager)
break;
}

case MessageType.MultiTestRunsFinalizationCancel:
case MessageType.MultiTestRunFinalizationCancel:
{
testRequestManager.CancelMultiTestRunsFinalization();
testRequestManager.CancelMultiTestRunFinalization();
break;
}

Expand Down Expand Up @@ -474,30 +472,29 @@ private void StartDiscovery(DiscoveryRequestPayload discoveryRequestPayload, ITe
});
}

private void StartMultiTestRunsFinalization(MultiTestRunsFinalizationPayload finalizationPayload, ITestRequestManager testRequestManager)
private void StartMultiTestRunFinalization(MultiTestRunFinalizationPayload finalizationPayload, ITestRequestManager testRequestManager)
{
Task.Run(
delegate
{
try
{
testRequestManager.ResetOptions();
testRequestManager.FinalizeMultiTestRuns(finalizationPayload, new MultiTestRunsFinalizationEventsHandler(this.communicationManager));
testRequestManager.FinalizeMultiTestRun(finalizationPayload, new MultiTestRunFinalizationEventsHandler(this.communicationManager));
}
catch (Exception ex)
{
EqtTrace.Error("DesignModeClient: Exception in StartMultiTestRunsFinalization: " + ex);
EqtTrace.Error("DesignModeClient: Exception in StartMultiTestRunFinalization: " + ex);

var testMessagePayload = new TestMessagePayload { MessageLevel = TestMessageLevel.Error, Message = ex.ToString() };
this.communicationManager.SendMessage(MessageType.TestMessage, testMessagePayload);

var payload = new MultiTestRunsFinalizationCompletePayload()
var payload = new MultiTestRunFinalizationCompletePayload()
{
Attachments = null
};

// Send run complete to translation layer
this.communicationManager.SendMessage(MessageType.MultiTestRunsFinalizationComplete, payload);
this.communicationManager.SendMessage(MessageType.MultiTestRunFinalizationComplete, payload);
}
});
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

namespace Microsoft.VisualStudio.TestPlatform.Client.MultiTestRunsFinalization
namespace Microsoft.VisualStudio.TestPlatform.Client.MultiTestRunFinalization
{
using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces;
using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.ObjectModel;
Expand All @@ -13,15 +13,17 @@ namespace Microsoft.VisualStudio.TestPlatform.Client.MultiTestRunsFinalization
/// <summary>
/// The multi test finalization event handler.
/// </summary>
public class MultiTestRunsFinalizationEventsHandler : IMultiTestRunsFinalizationEventsHandler
public class MultiTestRunFinalizationEventsHandler : IMultiTestRunFinalizationEventsHandler
{
private ICommunicationManager communicationManager;
private readonly ICommunicationManager communicationManager;
private bool finalizationCompleteSent;
private readonly object syncObject = new object();

/// <summary>
/// Initializes a new instance of the <see cref="MultiTestRunsFinalizationEventsHandler"/> class.
/// Initializes a new instance of the <see cref="MultiTestRunFinalizationEventsHandler"/> class.
/// </summary>
/// <param name="requestHandler"> The Request Handler. </param>
public MultiTestRunsFinalizationEventsHandler(ICommunicationManager communicationManager)
public MultiTestRunFinalizationEventsHandler(ICommunicationManager communicationManager)
{
this.communicationManager = communicationManager;
}
Expand All @@ -37,20 +39,28 @@ public void HandleLogMessage(TestMessageLevel level, string message)
this.communicationManager.SendMessage(MessageType.TestMessage, testMessagePayload);
}

public void HandleMultiTestRunsFinalizationComplete(ICollection<AttachmentSet> attachments)
public void HandleMultiTestRunFinalizationComplete(ICollection<AttachmentSet> attachments)
{
if (EqtTrace.IsInfoEnabled)
lock(this.syncObject)
{
EqtTrace.Info("Multi test runs finalization completed.");
}
if(!finalizationCompleteSent)
{
if (EqtTrace.IsInfoEnabled)
{
EqtTrace.Info("Multi test run finalization completed.");
}

var payload = new MultiTestRunsFinalizationCompletePayload()
{
Attachments = attachments
};
var payload = new MultiTestRunFinalizationCompletePayload()
{
Attachments = attachments
};

// Send run complete to translation layer
this.communicationManager.SendMessage(MessageType.MultiTestRunsFinalizationComplete, payload);
// Send run complete to translation layer
this.communicationManager.SendMessage(MessageType.MultiTestRunFinalizationComplete, payload);

finalizationCompleteSent = true;
}
}
}

public void HandleRawMessage(string rawMessage)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ public interface ITestRequestManager : IDisposable
void RunTests(TestRunRequestPayload testRunRequestPayLoad, ITestHostLauncher customTestHostLauncher, ITestRunEventsRegistrar testRunEventsRegistrar, ProtocolConfig protocolConfig);

/// <summary>
/// Finalize multi test runs
/// Finalize multi test run
/// </summary>
/// <param name="multiTestRunsFinalizationPayload">Multi test runs finalization payload</param>
/// <param name="multiTestRunsFinalizationEventsHandler">Multi test runs finalization events handler</param>
void FinalizeMultiTestRuns(MultiTestRunsFinalizationPayload multiTestRunsFinalizationPayload, IMultiTestRunsFinalizationEventsHandler multiTestRunsFinalizationEventsHandler);
/// <param name="multiTestRunFinalizationPayload">Multi test run finalization payload</param>
/// <param name="multiTestRunFinalizationEventsHandler">Multi test run finalization events handler</param>
void FinalizeMultiTestRun(MultiTestRunFinalizationPayload multiTestRunFinalizationPayload, IMultiTestRunFinalizationEventsHandler multiTestRunFinalizationEventsHandler);

/// <summary>
/// Cancel the current TestRun request
Expand All @@ -67,8 +67,8 @@ public interface ITestRequestManager : IDisposable
void CancelDiscovery();

/// <summary>
/// Cancels the current multi test runs finalization request
/// Cancels the current multi test run finalization request
/// </summary>
void CancelMultiTestRunsFinalization();
void CancelMultiTestRunFinalization();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@
namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine
{
/// <summary>
/// Orchestrates multi test runs finalization operations.
/// Orchestrates multi test run finalization operations.
/// </summary>
public interface IMultiTestRunsFinalizationManager
public interface IMultiTestRunFinalizationManager
{
/// <summary>
/// Finalizes multi test runs
/// Finalizes multi test run
/// </summary>
/// <param name="attachments">Attachments</param>
/// <param name="eventHandler">EventHandler for handling multi test runs finalization events from Engine</param>
/// <param name="eventHandler">EventHandler for handling multi test run finalization events from Engine</param>
/// <param name="cancellationToken">Cancellation token</param>
Task FinalizeMultiTestRunsAsync(ICollection<AttachmentSet> attachments, IMultiTestRunsFinalizationEventsHandler eventHandler, CancellationToken cancellationToken);
Task FinalizeMultiTestRunAsync(ICollection<AttachmentSet> attachments, IMultiTestRunFinalizationEventsHandler eventHandler, CancellationToken cancellationToken);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ private JsonDataSerializer()
// MemoryTraceWriter can help diagnose serialization issues. Enable it for
// debug builds only.
// Note that MemoryTraceWriter is not thread safe, please don't use it in parallel
// test runs. See https://github.com/JamesNK/Newtonsoft.Json/issues/1279
// test run. See https://github.com/JamesNK/Newtonsoft.Json/issues/1279
payloadSerializer.TraceWriter = new MemoryTraceWriter();
payloadSerializer2.TraceWriter = new MemoryTraceWriter();
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,19 +124,19 @@ public static class MessageType
public const string CustomTestHostLaunchCallback = "TestExecution.CustomTestHostLaunchCallback";

/// <summary>
/// Multi test runs finalization
/// Multi test run finalization
/// </summary>
public const string MultiTestRunsFinalizationStart = "MultiTestRunsFinalization.Start";
public const string MultiTestRunFinalizationStart = "MultiTestRunFinalization.Start";

/// <summary>
/// Multi test runs finalization callback
/// Multi test run finalization callback
/// </summary>
public const string MultiTestRunsFinalizationComplete = "MultiTestRunsFinalization.Complete";
public const string MultiTestRunFinalizationComplete = "MultiTestRunFinalization.Complete";

/// <summary>
/// Cancel multi test runs finalization
/// Cancel multi test run finalization
/// </summary>
public const string MultiTestRunsFinalizationCancel = "MultiTestRunsFinalization.Cancel";
public const string MultiTestRunFinalizationCancel = "MultiTestRunFinalization.Cancel";

/// <summary>
/// Extensions Initialization
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

namespace Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.ObjectModel
Expand All @@ -8,9 +8,9 @@ namespace Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.ObjectModel
using Microsoft.VisualStudio.TestPlatform.ObjectModel;

/// <summary>
/// Multi test runs finalization complete payload.
/// Multi test run finalization complete payload.
/// </summary>
public class MultiTestRunsFinalizationCompletePayload
public class MultiTestRunFinalizationCompletePayload
{
/// <summary>
/// Gets or sets the attachments.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,52 +184,52 @@ public interface ITestPlatformEventSource
void MetricsDisposeStop();

/// <summary>
/// The multi test runs finalization request start.
/// The multi test run finalization request start.
/// </summary>
void MultiTestRunsFinalizationRequestStart();
void MultiTestRunFinalizationRequestStart();

/// <summary>
/// The multi test runs finalization request stop.
/// The multi test run finalization request stop.
/// </summary>
void MultiTestRunsFinalizationRequestStop();
void MultiTestRunFinalizationRequestStop();

/// <summary>
/// The adapter multi test runs finalization start.
/// The adapter multi test run finalization start.
/// </summary>
/// <param name="numberOfAttachements">
/// The number of attachements.
/// </param>
void AdapterMultiTestRunsFinalizationStart(long numberOfAttachements);
void AdapterMultiTestRunFinalizationStart(long numberOfAttachements);

/// <summary>
/// The adapter multi test runs finalization stop.
/// The adapter multi test run finalization stop.
/// </summary>
/// <param name="numberOfAttachements">
/// The number of attachements.
/// </param>
void AdapterMultiTestRunsFinalizationStop(long numberOfAttachements);
void AdapterMultiTestRunFinalizationStop(long numberOfAttachements);

/// <summary>
/// The multi test runs finalization start.
/// The multi test run finalization start.
/// </summary>
void MultiTestRunsFinalizationStart();
void MultiTestRunFinalizationStart();

/// <summary>
/// The multi test runs finalization stop.
/// The multi test run finalization stop.
/// </summary>
/// <param name="numberOfAttachements">
/// The number of attachements.
/// </param>
void MultiTestRunsFinalizationStop(long numberOfAttachements);
void MultiTestRunFinalizationStop(long numberOfAttachements);

/// <summary>
/// Mark the start of translation layer multi test runs finalization request.
/// Mark the start of translation layer multi test run finalization request.
/// </summary>
void TranslationLayerMultiTestRunsFinalizationStart();
void TranslationLayerMultiTestRunFinalizationStart();

/// <summary>
/// Mark the completion of translation layer multi test runs finalization request.
/// Mark the completion of translation layer multi test run finalization request.
/// </summary>
void TranslationLayerMultiTestRunsFinalizationStop();
void TranslationLayerMultiTestRunFinalizationStop();
}
}
Loading

0 comments on commit 39f3f84

Please sign in to comment.