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

Data Collector Process #369

Merged
merged 15 commits into from
Jan 30, 2017
Merged
767 changes: 368 additions & 399 deletions TestPlatform.sln

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions scripts/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,6 @@ function Publish-Package
$testhostCorePackageDir = $(Join-Path $env:TP_OUT_DIR "$TPB_Configuration\Microsoft.TestPlatform.TestHost\$TPB_TargetFrameworkCore")
$vstestConsoleProject = Join-Path $env:TP_ROOT_DIR "src\vstest.console\vstest.console.csproj"
$dataCollectorProject = Join-Path $env:TP_ROOT_DIR "src\datacollector\datacollector.csproj"
$dataCollectorx86Project = Join-Path $env:TP_ROOT_DIR "src\datacollector.x86\datacollector.x86.csproj"

Write-Log "Package: Publish package\*.csproj"

Expand All @@ -203,7 +202,6 @@ function Publish-Package
Publish-Package-Internal $dataCollectorProject $TPB_TargetFramework $fullCLRPackageDir
Publish-Package-Internal $dataCollectorProject $TPB_TargetFrameworkCore $coreCLRPackageDir

Write-Log "Package: Publish src\datacollector.x86\datacollector.x86.csproj"
Publish-Package-Internal $dataCollectorx86Project $TPB_TargetFramework $fullCLRPackageDir

# Publish testhost
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,63 @@
namespace Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.DataCollection
{
using System;
using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces;
using Microsoft.VisualStudio.TestPlatform.ObjectModel;
using System.Collections.ObjectModel;

using Microsoft.VisualStudio.TestPlatform.Common.DataCollection;
using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities;
using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.ObjectModel;
using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.DataCollection.Interfaces;
using Microsoft.VisualStudio.TestPlatform.Common.DataCollection;
using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces;
using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.ObjectModel;
using Microsoft.VisualStudio.TestPlatform.ObjectModel;
using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging;

/// <summary>
/// The data collection request handler interface.
/// </summary>
internal class DataCollectionRequestHandler : IDataCollectionRequestHandler, IDisposable
{
private readonly ICommunicationManager communicationManager;
private IDataSerializer dataSerializer;

public DataCollectionRequestHandler()
private static DataCollectionRequestHandler RequestHandler;
private static readonly object obj = new object();

internal DataCollectionRequestHandler()
: this(new SocketCommunicationManager(), JsonDataSerializer.Instance)
{
}

/// <summary>
/// Initializes a new instance of the <see cref="DataCollectionRequestHandler"/> class.
/// </summary>
/// <param name="communicationManager">
/// </param>
/// <param name="dataSerializer">
/// </param>
internal DataCollectionRequestHandler(ICommunicationManager communicationManager, IDataSerializer dataSerializer)
{
this.communicationManager = communicationManager;
this.dataSerializer = dataSerializer;
}

/// <summary>
/// Gets singleton instance of DataCollectionRequestHandler.
/// </summary>
public static DataCollectionRequestHandler Instance
{
get
{
lock (obj)
{
if (RequestHandler == null)
{
RequestHandler = new DataCollectionRequestHandler();
}
return RequestHandler;
}
}
}

/// <summary>
/// The dispose.
/// </summary>
Expand All @@ -45,15 +78,13 @@ public void Close()
EqtTrace.Info("Closing the connection !");
}

/// <summary>
/// Setups client based on port
/// </summary>
/// <param name="port">port number to connect</param>
/// <inheritdoc />
public void InitializeCommunication(int port)
{
this.communicationManager.SetupClientAsync(port);
}

/// <inheritdoc />
public bool WaitForRequestSenderConnection(int connectionTimeout)
{
return this.communicationManager.WaitForServerConnection(connectionTimeout);
Expand Down Expand Up @@ -93,5 +124,14 @@ public void ProcessRequests()
}
while (!isSessionEnd);
}

/// <summary>
///
/// </summary>
/// <param name="args"></param>
public void SendDataCollectionMessage(DataCollectionMessageEventArgs args)
{
this.communicationManager.SendMessage(MessageType.DataCollectionMessage, args);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,3 @@
[assembly: InternalsVisibleTo("Microsoft.TestPlatform.CrossPlatEngine, PublicKey=002400000480000094000000060200000024000052534131000400000100010007d1fa57c4aed9f0a32e84aa0faefd0de9e8fd6aec8f87fb03766c834c99921eb23be79ad9d5dcc1dd9ad236132102900b723cf980957fc4e177108fc607774f29e8320e92ea05ece4e821c0a5efe8f1645c4c0c93c1ab99285d622caa652c1dfad63d745d6f2de5f17e5eaf0fc4963d261c8a12436518206dc093344d5ad293")]
[assembly: InternalsVisibleTo("Microsoft.TestPlatform.CrossPlatEngine.UnitTests, PublicKey=002400000480000094000000060200000024000052534131000400000100010007d1fa57c4aed9f0a32e84aa0faefd0de9e8fd6aec8f87fb03766c834c99921eb23be79ad9d5dcc1dd9ad236132102900b723cf980957fc4e177108fc607774f29e8320e92ea05ece4e821c0a5efe8f1645c4c0c93c1ab99285d622caa652c1dfad63d745d6f2de5f17e5eaf0fc4963d261c8a12436518206dc093344d5ad293")]
[assembly: InternalsVisibleTo("datacollector, PublicKey=002400000480000094000000060200000024000052534131000400000100010007d1fa57c4aed9f0a32e84aa0faefd0de9e8fd6aec8f87fb03766c834c99921eb23be79ad9d5dcc1dd9ad236132102900b723cf980957fc4e177108fc607774f29e8320e92ea05ece4e821c0a5efe8f1645c4c0c93c1ab99285d622caa652c1dfad63d745d6f2de5f17e5eaf0fc4963d261c8a12436518206dc093344d5ad293")]
[assembly: InternalsVisibleTo("datacollector.x86, PublicKey=002400000480000094000000060200000024000052534131000400000100010007d1fa57c4aed9f0a32e84aa0faefd0de9e8fd6aec8f87fb03766c834c99921eb23be79ad9d5dcc1dd9ad236132102900b723cf980957fc4e177108fc607774f29e8320e92ea05ece4e821c0a5efe8f1645c4c0c93c1ab99285d622caa652c1dfad63d745d6f2de5f17e5eaf0fc4963d261c8a12436518206dc093344d5ad293")]
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public static class MessageType
/// The discovery started.
/// </summary>
public const string StartDiscovery = "TestDiscovery.Start";

/// <summary>
/// The test cases found.
/// </summary>
Expand Down Expand Up @@ -138,6 +138,11 @@ public static class MessageType
/// </summary>
public const string LaunchAdapterProcessWithDebuggerAttachedCallback = "TestExecution.LaunchAdapterProcessWithDebuggerAttachedCallback";

/// <summary>
/// Data Collection Message
/// </summary>
public const string DataCollectionMessage = "DataCollection.SendMessage";

#region DataCollector messages

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.DataCollection
/// </summary>
internal class DataCollectionLauncher : IDataCollectionLauncher
{
private const string X64DataCollectorProcessName = "datacollector.exe";
private const string X86DataCollectorProcessName = "datacollector.x86.exe";
private const string DataCollectorProcessName = "datacollector.exe";
private const string DotnetProcessName = "dotnet.exe";
private const string DotnetProcessNameXPlat = "dotnet";

Expand Down Expand Up @@ -54,7 +53,7 @@ internal DataCollectionLauncher(IProcessHelper processHelper)
/// <param name="architecture">architecture for the host</param>
public void Initialize(Architecture architecture)
{
this.dataCollectorProcessName = (architecture == Architecture.X86) ? X86DataCollectorProcessName : X64DataCollectorProcessName;
this.dataCollectorProcessName = DataCollectorProcessName;
}

/// <summary>
Expand Down
1 change: 0 additions & 1 deletion src/Microsoft.TestPlatform.CrossPlatEngine/Friends.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,5 @@

[assembly: InternalsVisibleTo("Microsoft.TestPlatform.CrossPlatEngine.UnitTests, PublicKey=002400000480000094000000060200000024000052534131000400000100010007d1fa57c4aed9f0a32e84aa0faefd0de9e8fd6aec8f87fb03766c834c99921eb23be79ad9d5dcc1dd9ad236132102900b723cf980957fc4e177108fc607774f29e8320e92ea05ece4e821c0a5efe8f1645c4c0c93c1ab99285d622caa652c1dfad63d745d6f2de5f17e5eaf0fc4963d261c8a12436518206dc093344d5ad293")]
[assembly: InternalsVisibleTo("vstest.console.UnitTests, PublicKey=002400000480000094000000060200000024000052534131000400000100010007d1fa57c4aed9f0a32e84aa0faefd0de9e8fd6aec8f87fb03766c834c99921eb23be79ad9d5dcc1dd9ad236132102900b723cf980957fc4e177108fc607774f29e8320e92ea05ece4e821c0a5efe8f1645c4c0c93c1ab99285d622caa652c1dfad63d745d6f2de5f17e5eaf0fc4963d261c8a12436518206dc093344d5ad293")]
[assembly: InternalsVisibleTo("datacollector.x86, PublicKey = 002400000480000094000000060200000024000052534131000400000100010007d1fa57c4aed9f0a32e84aa0faefd0de9e8fd6aec8f87fb03766c834c99921eb23be79ad9d5dcc1dd9ad236132102900b723cf980957fc4e177108fc607774f29e8320e92ea05ece4e821c0a5efe8f1645c4c0c93c1ab99285d622caa652c1dfad63d745d6f2de5f17e5eaf0fc4963d261c8a12436518206dc093344d5ad293")]
[assembly: InternalsVisibleTo("datacollector, PublicKey = 002400000480000094000000060200000024000052534131000400000100010007d1fa57c4aed9f0a32e84aa0faefd0de9e8fd6aec8f87fb03766c834c99921eb23be79ad9d5dcc1dd9ad236132102900b723cf980957fc4e177108fc607774f29e8320e92ea05ece4e821c0a5efe8f1645c4c0c93c1ab99285d622caa652c1dfad63d745d6f2de5f17e5eaf0fc4963d261c8a12436518206dc093344d5ad293")]
[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c547cac37abd99c8db225ef2f6c8a3602f3b3606cc9891605d02baa56104f4cfc0734aa39b93bf7852f7d9266654753cc297e7d2edfe0bac1cdcf9f717241550e0a7b191195b7667bb4f64bcb8e2121380fd1d9d46ad2d92d2d15605093924cceaf74c4861eff62abf69b9291ed0a340e113be11e6a7d3113e92484cf7045cc7")]
5 changes: 0 additions & 5 deletions src/Microsoft.TestPlatform.ObjectModel/AttachmentSet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ namespace Microsoft.VisualStudio.TestPlatform.ObjectModel
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;

/// <summary>
Expand All @@ -17,10 +15,8 @@ public class AttachmentSet
{
/// <summary>
/// URI of the sender.
///
/// If a data-collector is sending this set, then it should be uri of the data collector. Also if an
/// executor is sending this attachment, then it should be uri of executor.
///
/// </summary>
[DataMember]
public Uri Uri {get; private set;}
Expand All @@ -33,7 +29,6 @@ public class AttachmentSet

/// <summary>
/// List of data attachments.
///
/// These attachments can be things such as files that the collector/adapter wants to make available to the publishers.
/// </summary>
[DataMember]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// 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.ObjectModel.DataCollector
{
using System;

/// <summary>
/// Provides a friendly name for the data collector.
/// </summary>
public class DataCollectorFriendlyNameAttribute : Attribute
{
/// <summary>
/// Initializes a new instance of the <see cref="DataCollectorFriendlyNameAttribute"/> class.
/// </summary>
/// <param name="friendlyName">
/// The friendly name.
/// </param>
public DataCollectorFriendlyNameAttribute(string friendlyName)
{
this.FriendlyName = friendlyName;
}

/// <summary>
/// Gets the friendly name.
/// </summary>
public string FriendlyName { get; private set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// 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.ObjectModel.DataCollector
{
using System;

/// <summary>
/// Provides unique identification of a data collector in the form of a URI.
/// Recommended format: 'datacollector://Company/Product/Version'
/// </summary>
public class DataCollectorTypeUriAttribute : Attribute
{
/// <summary>
/// Initializes a new instance of the <see cref="DataCollectorTypeUriAttribute"/> class.
/// </summary>
/// <param name="typeUri">
/// The type uri.
/// </param>
public DataCollectorTypeUriAttribute(string typeUri)
{
this.TypeUri = typeUri;
}

/// <summary>
/// Gets the data collector type uri.
/// </summary>
public string TypeUri { get; private set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,16 @@ namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection
{
using System;
using System.ComponentModel;
using System.IO;

/// <summary>
/// Class used by data collectors to send data to up-stream components
/// (agent, controller, client, etc).
/// </summary>
public abstract class DataCollectionSink
{
#region Constructor

/// <summary>
/// Creates a DataCollectionSink
/// Initializes a new instance of the <see cref="DataCollectionSink"/> class.
/// </summary>
protected DataCollectionSink()
{
Expand All @@ -31,11 +29,6 @@ protected DataCollectionSink()
/// </summary>
public abstract event AsyncCompletedEventHandler SendFileCompleted;

/// <summary>
/// Called when sending of a stream has completed.
/// </summary>
public abstract event AsyncCompletedEventHandler SendStreamCompleted;

#endregion

#region SendFileAsync
Expand All @@ -48,7 +41,7 @@ protected DataCollectionSink()
/// <param name="deleteFile">True to automatically have the file removed after sending it.</param>
public void SendFileAsync(DataCollectionContext context, string path, bool deleteFile)
{
SendFileAsync(context, path, String.Empty, deleteFile);
this.SendFileAsync(context, path, string.Empty, deleteFile);
}

/// <summary>
Expand All @@ -63,7 +56,7 @@ public void SendFileAsync(DataCollectionContext context, string path, string des
var fileInfo = new FileTransferInformation(context, path, deleteFile);
fileInfo.Description = description;

SendFileAsync(fileInfo);
this.SendFileAsync(fileInfo);
}

/// <summary>
Expand All @@ -73,43 +66,5 @@ public void SendFileAsync(DataCollectionContext context, string path, string des
public abstract void SendFileAsync(FileTransferInformation fileTransferInformation);

#endregion

#region SendStreamAsync

/// <summary>
/// Sends a stream to up-stream components.
/// </summary>
/// <param name="context">The context in which the stream is being sent. Cannot be null.</param>
/// <param name="stream">Stream to send.</param>
/// <param name="fileName">File name to use for the data on the client.</param>
/// <param name="closeStream">True to automatically have the stream closed when sending of the contents has completed.</param>
public void SendStreamAsync(DataCollectionContext context, Stream stream, string fileName, bool closeStream)
{
SendStreamAsync(context, stream, fileName, String.Empty, closeStream);
}

/// <summary>
/// Sends a stream to up-stream components.
/// </summary>
/// <param name="context">The context in which the stream is being sent. Cannot be null.</param>
/// <param name="stream">Stream to send.</param>
/// <param name="fileName">File name to use for the data on the client.</param>
/// <param name="description">A short description of the data being sent.</param>
/// <param name="closeStream">True to automatically have the stream closed when sending of the contents has completed.</param>
public void SendStreamAsync(DataCollectionContext context, Stream stream, string fileName, string description, bool closeStream)
{
var streamInfo = new StreamTransferInformation(context, stream, fileName, closeStream);
streamInfo.Description = description;

SendStreamAsync(streamInfo);
}

/// <summary>
/// Sends a stream to up-stream components.
/// </summary>
/// <param name="streamTransferInformation">Information about the stream being transferred.</param>
public abstract void SendStreamAsync(StreamTransferInformation streamTransferInformation);

#endregion
}
}
Loading