Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding test run attachments processing #2463

Merged
merged 62 commits into from
Jul 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
7efc5c2
v1
jakubch1 May 7, 2020
8e88dea
Merging v1
jakubch1 May 19, 2020
3851666
Merge branch 'master' into dev/jachocho/1114286_merging
jakubch1 May 21, 2020
1cae4c5
Rename to MultiTestRunsFinalization
jakubch1 May 21, 2020
04aac62
New version
jakubch1 May 21, 2020
91c8785
More changes
jakubch1 May 21, 2020
d799be6
More changes
jakubch1 May 21, 2020
872bbcc
Next changes
jakubch1 May 22, 2020
69340a5
Fix
jakubch1 May 22, 2020
e23d24d
test
jakubch1 May 25, 2020
6189eb0
More changes
jakubch1 Jun 2, 2020
4870e7c
Merge branch 'master' into dev/jachocho/1114286_merging
jakubch1 Jun 4, 2020
97ab178
Dmc chagnes
jakubch1 Jun 9, 2020
2314550
next
jakubch1 Jun 9, 2020
e7b839f
small changes
jakubch1 Jun 10, 2020
6aa2912
compiled
jakubch1 Jun 10, 2020
29d618d
More changes
jakubch1 Jun 10, 2020
44c5fdc
acceptance tests green
jakubch1 Jun 10, 2020
39f3f84
Review comments #1
jakubch1 Jun 11, 2020
d56baf6
Resolving more comments
jakubch1 Jun 11, 2020
c5a7134
Tests for design mode client
jakubch1 Jun 11, 2020
daaef85
Tests for events handler
jakubch1 Jun 11, 2020
7d7d8a1
revert not related changes
jakubch1 Jun 11, 2020
5ae0b3a
More changes
jakubch1 Jun 12, 2020
a9eee9c
Compiling OK, tests OK
jakubch1 Jun 12, 2020
08b646a
Unit tests for manager
jakubch1 Jun 15, 2020
e16e3ad
More changes
jakubch1 Jun 15, 2020
cbca05a
More tests
jakubch1 Jun 16, 2020
3176175
tests for reqeust sender
jakubch1 Jun 16, 2020
89f7eed
more tests
jakubch1 Jun 16, 2020
3c3c631
Tests for cancelling
jakubch1 Jun 16, 2020
eeb7963
Acceptance tests done
jakubch1 Jun 16, 2020
bbb2244
Remove not used stuff
jakubch1 Jun 16, 2020
4d61a92
Fix comments
jakubch1 Jun 16, 2020
74f971f
Merge branch 'master' into dev/jachocho/1114286_merging
jakubch1 Jun 16, 2020
1190895
Fix race condition in test
jakubch1 Jun 16, 2020
82bb3de
Fix another race condition
jakubch1 Jun 16, 2020
9376adb
Fix converting to xml
jakubch1 Jun 16, 2020
be9537b
fix next test
jakubch1 Jun 16, 2020
f157e24
fix test
jakubch1 Jun 16, 2020
b25a64e
Next changes
jakubch1 Jun 17, 2020
fc7a1c0
Review changes #1
jakubch1 Jun 19, 2020
bcd0673
Fixing multi test finalization manager tests
jakubch1 Jun 19, 2020
147f23e
Fixes
jakubch1 Jun 19, 2020
5d18566
Fix last unit test
jakubch1 Jun 19, 2020
f4c121a
Fix acceptance tests
jakubch1 Jun 19, 2020
1b56b78
Progress feature, compiling + unit tests
jakubch1 Jun 22, 2020
6c308b5
acceptance tests changes
jakubch1 Jun 22, 2020
4f1ede1
More changes
jakubch1 Jun 22, 2020
e635ec5
Fixing resources accesability
jakubch1 Jun 22, 2020
303cee8
Fix test
jakubch1 Jun 22, 2020
676c02b
Fix race conditions in acceptance tests
jakubch1 Jun 23, 2020
25849e9
Merge remote-tracking branch 'upstream/master' into dev/jachocho/1114…
jakubch1 Jun 30, 2020
571028e
RFC changes merged
jakubch1 Jun 30, 2020
2afcc44
Log warning in case of unexpected message id
jakubch1 Jul 1, 2020
ebf1a79
Fix spelling
jakubch1 Jul 1, 2020
e37a6f7
Additional comment
jakubch1 Jul 1, 2020
5e51a03
Restore some stuff in interfaces
jakubch1 Jul 1, 2020
1267291
Big renaming
jakubch1 Jul 1, 2020
1aee79f
Added processingSettings
jakubch1 Jul 1, 2020
74cb25e
Fix naming
jakubch1 Jul 1, 2020
8468ec0
Move explanation to <remarks>
jakubch1 Jul 2, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
// 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.TestRunAttachmentsProcessing
{
using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces;
using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.ObjectModel;
using Microsoft.VisualStudio.TestPlatform.ObjectModel;
using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client;
using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging;
using System.Collections.Generic;

/// <summary>
/// The test run attachments processing events handler.
/// </summary>
///
public class TestRunAttachmentsProcessingEventsHandler : ITestRunAttachmentsProcessingEventsHandler
{
private readonly ICommunicationManager communicationManager;

/// <summary>
/// Initializes a new instance of the <see cref="TestRunAttachmentsProcessingEventsHandler"/> class.
/// </summary>
/// <param name="communicationManager"> The communication manager. </param>
public TestRunAttachmentsProcessingEventsHandler(ICommunicationManager communicationManager)
{
this.communicationManager = communicationManager;
}

/// <inheritdoc/>
public void HandleTestRunAttachmentsProcessingComplete(TestRunAttachmentsProcessingCompleteEventArgs attachmentsProcessingCompleteEventArgs, IEnumerable<AttachmentSet> lastChunk)
{
if (EqtTrace.IsInfoEnabled)
{
EqtTrace.Info("Test run attachments processing completed.");
}

var payload = new TestRunAttachmentsProcessingCompletePayload()
{
AttachmentsProcessingCompleteEventArgs = attachmentsProcessingCompleteEventArgs,
Attachments = lastChunk
};

this.communicationManager.SendMessage(MessageType.TestRunAttachmentsProcessingComplete, payload);
}

/// <inheritdoc/>
public void HandleTestRunAttachmentsProcessingProgress(TestRunAttachmentsProcessingProgressEventArgs attachmentsProcessingProgressEventArgs)
{
var payload = new TestRunAttachmentsProcessingProgressPayload()
{
AttachmentsProcessingProgressEventArgs = attachmentsProcessingProgressEventArgs,
};

this.communicationManager.SendMessage(MessageType.TestRunAttachmentsProcessingProgress, payload);
}

/// <inheritdoc/>
public void HandleProcessedAttachmentsChunk(IEnumerable<AttachmentSet> attachments)
{
throw new System.NotImplementedException();
}

/// <inheritdoc/>
public void HandleLogMessage(TestMessageLevel level, string message)
{
var testMessagePayload = new TestMessagePayload { MessageLevel = level, Message = message };
this.communicationManager.SendMessage(MessageType.TestMessage, testMessagePayload);
}

/// <inheritdoc/>
public void HandleRawMessage(string rawMessage)
{
// No-Op
}
}
}
43 changes: 42 additions & 1 deletion src/Microsoft.TestPlatform.Client/DesignMode/DesignModeClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace Microsoft.VisualStudio.TestPlatform.Client.DesignMode
using System.Net;
using System.Threading;
using System.Threading.Tasks;

using Microsoft.VisualStudio.TestPlatform.Client.TestRunAttachmentsProcessing;
using Microsoft.VisualStudio.TestPlatform.Client.RequestHelper;
using Microsoft.VisualStudio.TestPlatform.Common.Logging;
using Microsoft.VisualStudio.TestPlatform.Common.Utilities;
Expand Down Expand Up @@ -199,6 +199,14 @@ private void ProcessRequests(ITestRequestManager testRequestManager)
break;
}

case MessageType.TestRunAttachmentsProcessingStart:
{
var testRunAttachmentsProcessingPayload =
this.communicationManager.DeserializePayload<TestRunAttachmentsProcessingPayload>(message);
this.StartTestRunAttachmentsProcessing(testRunAttachmentsProcessingPayload, testRequestManager);
break;
}

case MessageType.CancelDiscovery:
{
testRequestManager.CancelDiscovery();
Expand All @@ -217,6 +225,12 @@ private void ProcessRequests(ITestRequestManager testRequestManager)
break;
}

case MessageType.TestRunAttachmentsProcessingCancel:
{
testRequestManager.CancelTestRunAttachmentsProcessing();
break;
}

case MessageType.CustomTestHostLaunchCallback:
{
this.onCustomTestHostLaunchAckReceived?.Invoke(message);
Expand Down Expand Up @@ -458,6 +472,33 @@ private void StartDiscovery(DiscoveryRequestPayload discoveryRequestPayload, ITe
});
}

private void StartTestRunAttachmentsProcessing(TestRunAttachmentsProcessingPayload attachmentsProcessingPayload, ITestRequestManager testRequestManager)
{
Task.Run(
delegate
{
try
{
testRequestManager.ProcessTestRunAttachments(attachmentsProcessingPayload, new TestRunAttachmentsProcessingEventsHandler(this.communicationManager), this.protocolConfig);
}
catch (Exception ex)
{
EqtTrace.Error("DesignModeClient: Exception in StartTestRunAttachmentsProcessing: " + ex);

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

var payload = new TestRunAttachmentsProcessingCompletePayload()
{
Attachments = null
};

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

#region IDisposable Support

private bool disposedValue = false; // To detect redundant calls
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@ public interface ITestRequestManager : IDisposable
/// <param name="protocolConfig">Protocol related information</param>
void RunTests(TestRunRequestPayload testRunRequestPayLoad, ITestHostLauncher customTestHostLauncher, ITestRunEventsRegistrar testRunEventsRegistrar, ProtocolConfig protocolConfig);

/// <summary>
/// Processes test run attachments
/// </summary>
/// <param name="testRunAttachmentsProcessingPayload">Test run attachments processing payload</param>
/// <param name="testRunAttachmentsProcessingEventsHandler">Test run attachments processing events handler</param>
void ProcessTestRunAttachments(TestRunAttachmentsProcessingPayload testRunAttachmentsProcessingPayload, ITestRunAttachmentsProcessingEventsHandler testRunAttachmentsProcessingEventsHandler, ProtocolConfig protocolConfig);

/// <summary>
/// Cancel the current TestRun request
/// </summary>
Expand All @@ -58,5 +65,10 @@ public interface ITestRequestManager : IDisposable
/// Cancels the current discovery request
/// </summary>
void CancelDiscovery();

/// <summary>
/// Cancels the current test run attachments processing request
/// </summary>
void CancelTestRunAttachmentsProcessing();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Threading;
using System.Threading.Tasks;

namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine
{
/// <summary>
/// Orchestrates test run attachments processing operations.
/// </summary>
internal interface ITestRunAttachmentsProcessingManager
{
/// <summary>
/// Processes attachments and provides results through handler
/// </summary>
/// <param name="attachments">Collection of attachments</param>
/// <param name="eventHandler">EventHandler for handling test run attachments processing event</param>
/// <param name="cancellationToken">Cancellation token</param>
Task ProcessTestRunAttachmentsAsync(IRequestData requestData, IEnumerable<AttachmentSet> attachments, ITestRunAttachmentsProcessingEventsHandler eventHandler, CancellationToken cancellationToken);

/// <summary>
/// Processes attachments
/// </summary>
/// <param name="attachments">Collection of attachments</param>
/// <param name="cancellationToken">Cancellation token</param>
/// <returns>Collection of attachments.</returns>
Task<Collection<AttachmentSet>> ProcessTestRunAttachmentsAsync(IRequestData requestData, IEnumerable<AttachmentSet> attachments, CancellationToken cancellationToken);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,19 @@ public static class TelemetryDataConstants

public static string NumberOfAdapterUsedToDiscoverTests = "VS.TestDiscovery.AdaptersUsedCount";

// *********************Attachments Processing****************************
public static string NumberOfAttachmentsSentForProcessing = "VS.AttachmentsProcessing.InitialAttachmentsCount";

public static string NumberOfAttachmentsAfterProcessing = "VS.AttachmentsProcessing.FinalAttachmentsCount";

public static string TimeTakenInSecForAttachmentsProcessing = "VS.AttachmentsProcessing.TotalTimeTakenInSec";
public static string AttachmentsProcessingState = "VS.AttachmentsProcessing.State";

// **************Events Name **********************************
public static string TestDiscoveryCompleteEvent = "vs/testplatform/testdiscoverysession";

public static string TestExecutionCompleteEvent = "vs/testplatform/testrunsession";

public static string TestAttachmentsProcessingCompleteEvent = "vs/testplatform/testattachmentsprocessingsession";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,26 @@ public static class MessageType
/// </summary>
public const string CustomTestHostLaunchCallback = "TestExecution.CustomTestHostLaunchCallback";

/// <summary>
/// Test run attachments processing
/// </summary>
public const string TestRunAttachmentsProcessingStart = "TestRunAttachmentsProcessing.Start";

/// <summary>
/// Test run attachments processing callback
/// </summary>
public const string TestRunAttachmentsProcessingComplete = "TestRunAttachmentsProcessing.Complete";

/// <summary>
/// Test run attachments processing progress
/// </summary>
public const string TestRunAttachmentsProcessingProgress = "TestRunAttachmentsProcessing.Progress";

/// <summary>
/// Cancel test run attachments processing
/// </summary>
public const string TestRunAttachmentsProcessingCancel = "TestRunAttachmentsProcessing.Cancel";

/// <summary>
/// Extensions Initialization
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// 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
{
using System.Collections.Generic;

using Microsoft.VisualStudio.TestPlatform.ObjectModel;
using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client;

/// <summary>
/// Test run attachments processing complete payload.
/// </summary>
public class TestRunAttachmentsProcessingCompletePayload
{
/// <summary>
/// Gets or sets the test run attachments processing complete args.
/// </summary>
public TestRunAttachmentsProcessingCompleteEventArgs AttachmentsProcessingCompleteEventArgs { get; set; }

/// <summary>
/// Gets or sets the attachments.
/// </summary>
public IEnumerable<AttachmentSet> Attachments { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// 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
{
using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client;

/// <summary>
/// Test run attachments processing complete payload.
/// </summary>
public class TestRunAttachmentsProcessingProgressPayload
{
/// <summary>
/// Gets or sets the test run attachments processing complete args.
/// </summary>
public TestRunAttachmentsProcessingProgressEventArgs AttachmentsProcessingProgressEventArgs { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -182,5 +182,41 @@ public interface ITestPlatformEventSource
/// Mark the completion of Metrics Dispose.
/// </summary>
void MetricsDisposeStop();

/// <summary>
/// The test run attachments processing request start.
/// </summary>
void TestRunAttachmentsProcessingRequestStart();

/// <summary>
/// The test run attachments processing request stop.
/// </summary>
void TestRunAttachmentsProcessingRequestStop();

/// <summary>
/// The test run attachments processing start.
/// </summary>
/// <param name="numberOfAttachments">
/// The number of attachments.
/// </param>
void TestRunAttachmentsProcessingStart(long numberOfAttachments);

/// <summary>
/// The test run attachments processing stop.
/// </summary>
/// <param name="numberOfAttachments">
/// The number of attachments.
/// </param>
void TestRunAttachmentsProcessingStop(long numberOfAttachments);

/// <summary>
/// Mark the start of translation layer test run attachments processing request.
/// </summary>
void TranslationLayerTestRunAttachmentsProcessingStart();

/// <summary>
/// Mark the completion of translation layer test run attachments processing request.
/// </summary>
void TranslationLayerTestRunAttachmentsProcessingStop();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -237,5 +237,47 @@ public void MetricsDisposeStop()
{
this.WriteEvent(TestPlatformInstrumentationEvents.MetricsDisposeStopEventId);
}

/// <inheritdoc/>
[Event(TestPlatformInstrumentationEvents.TestRunAttachmentsProcessingRequestStartEventId)]
public void TestRunAttachmentsProcessingRequestStart()
{
this.WriteEvent(TestPlatformInstrumentationEvents.TestRunAttachmentsProcessingRequestStartEventId);
}

/// <inheritdoc/>
[Event(TestPlatformInstrumentationEvents.TestRunAttachmentsProcessingRequestStopEventId)]
public void TestRunAttachmentsProcessingRequestStop()
{
this.WriteEvent(TestPlatformInstrumentationEvents.TestRunAttachmentsProcessingRequestStopEventId);
}

/// <inheritdoc/>
[Event(TestPlatformInstrumentationEvents.TestRunAttachmentsProcessingStartEventId)]
public void TestRunAttachmentsProcessingStart(long numberOfAttachments)
{
this.WriteEvent(TestPlatformInstrumentationEvents.TestRunAttachmentsProcessingStartEventId, numberOfAttachments);
}

/// <inheritdoc/>
[Event(TestPlatformInstrumentationEvents.TestRunAttachmentsProcessingStopEventId)]
public void TestRunAttachmentsProcessingStop(long numberOfAttachments)
{
this.WriteEvent(TestPlatformInstrumentationEvents.TestRunAttachmentsProcessingStopEventId, numberOfAttachments);
}

/// <inheritdoc/>
[Event(TestPlatformInstrumentationEvents.TranslationLayerTestRunAttachmentsProcessingStartEventId)]
public void TranslationLayerTestRunAttachmentsProcessingStart()
{
this.WriteEvent(TestPlatformInstrumentationEvents.TranslationLayerTestRunAttachmentsProcessingStartEventId);
}

/// <inheritdoc/>
[Event(TestPlatformInstrumentationEvents.TranslationLayerTestRunAttachmentsProcessingStopEventId)]
public void TranslationLayerTestRunAttachmentsProcessingStop()
{
this.WriteEvent(TestPlatformInstrumentationEvents.TranslationLayerTestRunAttachmentsProcessingStopEventId);
}
}
}
Loading