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

Load and Initialize Data Collectors #2

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 0 additions & 2 deletions Nuget.config
Expand Up @@ -6,8 +6,6 @@
<add key="dotnet-core" value="https://dotnet.myget.org/F/dotnet-core/api/v3/index.json" />
<add key="api.nuget.org" value="https://api.nuget.org/v3/index.json" />
<add key="vstest" value="https://dotnet.myget.org/F/vstest/auth/967ad631-d24c-4c0e-bece-922de3064956/api/v3/index.json" />

<!-- Moq -->
<add key="aspnetcidev" value="https://www.myget.org/F/aspnetcidev/api/v3/index.json" />
</packageSources>
<activePackageSource>
Expand Down
16 changes: 15 additions & 1 deletion TestPlatform.sln
Expand Up @@ -83,7 +83,11 @@ Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "datacollector", "src\dataco
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "datacollector.x86", "src\datacollector.x86\datacollector.x86.xproj", "{00DFB5C7-3850-4A65-986B-713F200482D4}"
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "datacollector.x86.UnitTests", "test\datacollector.x86.UnitTests\datacollector.x86.UnitTests.xproj", "{00AA21F3-31E4-4748-AC0B-C4EADB41CA24}"
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "datacollector.UnitTests", "test\datacollector.UnitTests\datacollector.UnitTests.xproj", "{00AA21F3-31E4-4748-AC0B-C4EADB41CA24}"
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.TestPlatform.DataCollection.v1", "src\Microsoft.TestPlatform.DataCollection.v1\Microsoft.TestPlatform.DataCollection.v1.xproj", "{D5C951F1-B6FF-4DE2-AD89-F5C5803DE126}"
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.TestPlatform.DataCollection.v1.UnitTests", "test\Microsoft.TestPlatform.DataCollection.v1.UnitTests\Microsoft.TestPlatform.DataCollection.v1.UnitTests.xproj", "{07D89FBD-F76D-40EF-A0CA-9213DEE61941}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down Expand Up @@ -211,6 +215,14 @@ Global
{00AA21F3-31E4-4748-AC0B-C4EADB41CA24}.Debug|Any CPU.Build.0 = Debug|Any CPU
{00AA21F3-31E4-4748-AC0B-C4EADB41CA24}.Release|Any CPU.ActiveCfg = Release|Any CPU
{00AA21F3-31E4-4748-AC0B-C4EADB41CA24}.Release|Any CPU.Build.0 = Release|Any CPU
{D5C951F1-B6FF-4DE2-AD89-F5C5803DE126}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D5C951F1-B6FF-4DE2-AD89-F5C5803DE126}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D5C951F1-B6FF-4DE2-AD89-F5C5803DE126}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D5C951F1-B6FF-4DE2-AD89-F5C5803DE126}.Release|Any CPU.Build.0 = Release|Any CPU
{07D89FBD-F76D-40EF-A0CA-9213DEE61941}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{07D89FBD-F76D-40EF-A0CA-9213DEE61941}.Debug|Any CPU.Build.0 = Debug|Any CPU
{07D89FBD-F76D-40EF-A0CA-9213DEE61941}.Release|Any CPU.ActiveCfg = Release|Any CPU
{07D89FBD-F76D-40EF-A0CA-9213DEE61941}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -248,5 +260,7 @@ Global
{3572E78C-5AA5-4F68-876D-FC5322677263} = {D8EF073C-279A-4279-912D-E9D4B0635E17}
{00DFB5C7-3850-4A65-986B-713F200482D4} = {D8EF073C-279A-4279-912D-E9D4B0635E17}
{00AA21F3-31E4-4748-AC0B-C4EADB41CA24} = {463031A2-7F16-4E38-9944-1F5161D04933}
{D5C951F1-B6FF-4DE2-AD89-F5C5803DE126} = {D8EF073C-279A-4279-912D-E9D4B0635E17}
{07D89FBD-F76D-40EF-A0CA-9213DEE61941} = {463031A2-7F16-4E38-9944-1F5161D04933}
EndGlobalSection
EndGlobal
5 changes: 5 additions & 0 deletions src/Microsoft.TestPlatform.Common/Constants.cs
Expand Up @@ -36,5 +36,10 @@ public static class TestPlatformDefaults
/// Default value of the boolean that determines whether or not job queue should be bounded.
/// </summary>
public const bool DefaultEnableBoundsOnLoggerEventQueue = true;

/// <summary>
/// Name of the key used in app settings for TestRunnerService.exe to specify location of plugin directory.
/// </summary>
public const string PluginDirectorySettingsKeyName = "DataCollectorPluginDirectory";
}
}
147 changes: 147 additions & 0 deletions src/Microsoft.TestPlatform.Common/DataCollection/CopyRequestData.cs
@@ -0,0 +1,147 @@
// Copyright (c) Microsoft. All rights reserved.

namespace Microsoft.VisualStudio.TestPlatform.Common.DataCollection
{
using System;
using System.IO;
using System.Threading;

/// <summary>
/// Contains all information required for file transfer once scheduled from data collector.
/// </summary>
internal class CopyRequestData : IDisposable
{
#region Properties & Fields
/// <summary>
/// Specifies whether the object is disposed or not.
/// </summary>
private bool disposed;

/// <summary>
/// Set when this request is processed/completed.
/// </summary>
private ManualResetEvent requestCompleted;

#endregion

#region Constructor

/// <summary>
/// Initializes a new instance of the <see cref="CopyRequestData"/> class.
/// </summary>
/// <param name="baseDirectory">
/// Base directory for creating collection log destination file path.
/// </param>
/// <param name="headerMessage">
/// Header message containing all information for file transfer.
/// </param>
internal CopyRequestData(string baseDirectory, FileDataHeaderMessage headerMessage)
{
this.requestCompleted = new ManualResetEvent(false);
this.FileDataHeaderMessage = headerMessage;
this.LocalFileName = Path.GetFileName(headerMessage.FileName);

// Testcase specific collection should be created in testcase directorty.
var directoryPath = Path.Combine(
baseDirectory,
headerMessage.DataCollectionContext.HasTestCase ? this.FileDataHeaderMessage.DataCollectionContext.TestExecId.Id.ToString() : string.Empty);

this.LocalFilePath = Path.Combine(directoryPath, this.LocalFileName);
}

#endregion

/// <summary>
/// Gets fileName with extension
/// </summary>
internal string LocalFileName
{
get;
private set;
}

/// <summary>
/// Gets path to LocalFileName (including file name)
/// </summary>
internal string LocalFilePath
{
get;
private set;
}

/// <summary>
/// Gets DataCollectionMessage sent by data collector for file transfer
/// </summary>
internal FileDataHeaderMessage FileDataHeaderMessage
{
get;
private set;
}

/// <summary>
/// Gets error in processing the request.
/// </summary>
internal Exception Error
{
get;
private set;
}

/// <summary>
/// Dispose event object
/// </summary>
public void Dispose()
{
this.Dispose(true);

// Use SupressFinalize in case a subclass
// of this type implements a finalizer.
GC.SuppressFinalize(this);
}

#region internal methods
/// <summary>
/// Wait for file transfer to complete.
/// </summary>
internal void WaitForCopyComplete()
{
this.requestCompleted.WaitOne();
}

/// <summary>
/// Mark this request as completed by setting the event.
/// Store any error information for further processing.
/// </summary>
/// <param name="error">
/// The error.
/// </param>
internal void CompleteRequest(Exception error)
{
this.Error = error;
this.requestCompleted.Set();
}
#endregion

#region IDisposable

/// <summary>
/// The dispose.
/// </summary>
/// <param name="disposing">
/// The disposing.
/// </param>
protected virtual void Dispose(bool disposing)
{
if (!this.disposed)
{
if (disposing)
{
this.requestCompleted.Dispose();
}

this.disposed = true;
}
}
#endregion
}
}