-
Notifications
You must be signed in to change notification settings - Fork 331
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
Integration of vstest.console process with datacollector process. #418
Integration of vstest.console process with datacollector process. #418
Conversation
Hi @harshjain2, I'm your friendly neighborhood Microsoft Pull Request Bot (You can call me MSBOT). Thanks for your contribution!
TTYL, MSBOT; |
@@ -291,7 +292,7 @@ public void HandleTestRunComplete(TestRunCompleteEventArgs runCompleteArgs, Test | |||
runCompleteArgs.IsCanceled, | |||
runCompleteArgs.IsAborted, | |||
runCompleteArgs.Error, | |||
null, | |||
new Collection<AttachmentSet>(new List<AttachmentSet>(runContextAttachments)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not pass runContextAttachments
directly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
@@ -363,7 +364,7 @@ public virtual void HandleTestRunStatsChange(TestRunChangedEventArgs testRunChan | |||
EqtTrace.Info("TestRunRequest:SendTestRunStatsChange: Completed."); | |||
} | |||
} | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: remove blank line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
{ | ||
Task.WhenAll(this.attachmentTasks.ToArray()).Wait(); | ||
return this.AttachmentSets.Values.ToList(); | ||
if (isCancelled) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should cancel be a responsibility of GetAttachments?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Implemented a new method Cancel that will take care of cancellation.
@@ -30,6 +29,7 @@ internal class DataCollectorLoader : IDataCollectorLoader | |||
#else | |||
assembly = AssemblyLoadContext.Default.LoadFromAssemblyPath(location); | |||
#endif | |||
var dataCollectorType = assembly.GetTypes().ToList().Where(t => t.AssemblyQualifiedName.Equals(assemblyQualifiedName)).FirstOrDefault(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove ToList.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
EqtTrace.Error(ex.Message); | ||
} | ||
|
||
return this.AttachmentSets?.Values.ToList(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When will AttachmentSets be null?
/// <returns>Collection of session attachmentSet.</returns> | ||
Collection<AttachmentSet> SessionEnded(); | ||
/// <param name="isCancelled"> | ||
/// Boolean to specify is the test ruun is cancelled or not. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: s/ruun/run
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
@@ -6,11 +6,16 @@ | |||
#region Product Assemblies | |||
[assembly: InternalsVisibleTo("Microsoft.TestPlatform.CrossPlatEngine, PublicKey=002400000480000094000000060200000024000052534131000400000100010007d1fa57c4aed9f0a32e84aa0faefd0de9e8fd6aec8f87fb03766c834c99921eb23be79ad9d5dcc1dd9ad236132102900b723cf980957fc4e177108fc607774f29e8320e92ea05ece4e821c0a5efe8f1645c4c0c93c1ab99285d622caa652c1dfad63d745d6f2de5f17e5eaf0fc4963d261c8a12436518206dc093344d5ad293")] | |||
[assembly: InternalsVisibleTo("vstest.console, PublicKey =002400000480000094000000060200000024000052534131000400000100010007d1fa57c4aed9f0a32e84aa0faefd0de9e8fd6aec8f87fb03766c834c99921eb23be79ad9d5dcc1dd9ad236132102900b723cf980957fc4e177108fc607774f29e8320e92ea05ece4e821c0a5efe8f1645c4c0c93c1ab99285d622caa652c1dfad63d745d6f2de5f17e5eaf0fc4963d261c8a12436518206dc093344d5ad293")] | |||
[assembly: InternalsVisibleTo("datacollector, PublicKey =002400000480000094000000060200000024000052534131000400000100010007d1fa57c4aed9f0a32e84aa0faefd0de9e8fd6aec8f87fb03766c834c99921eb23be79ad9d5dcc1dd9ad236132102900b723cf980957fc4e177108fc607774f29e8320e92ea05ece4e821c0a5efe8f1645c4c0c93c1ab99285d622caa652c1dfad63d745d6f2de5f17e5eaf0fc4963d261c8a12436518206dc093344d5ad293")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are internalsvisibleto required for these?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For exposing IMessageSink interface that is in common, datacollector implements IMessageSink.
@@ -6,11 +6,16 @@ | |||
#region Product Assemblies | |||
[assembly: InternalsVisibleTo("Microsoft.TestPlatform.CrossPlatEngine, PublicKey=002400000480000094000000060200000024000052534131000400000100010007d1fa57c4aed9f0a32e84aa0faefd0de9e8fd6aec8f87fb03766c834c99921eb23be79ad9d5dcc1dd9ad236132102900b723cf980957fc4e177108fc607774f29e8320e92ea05ece4e821c0a5efe8f1645c4c0c93c1ab99285d622caa652c1dfad63d745d6f2de5f17e5eaf0fc4963d261c8a12436518206dc093344d5ad293")] | |||
[assembly: InternalsVisibleTo("vstest.console, PublicKey =002400000480000094000000060200000024000052534131000400000100010007d1fa57c4aed9f0a32e84aa0faefd0de9e8fd6aec8f87fb03766c834c99921eb23be79ad9d5dcc1dd9ad236132102900b723cf980957fc4e177108fc607774f29e8320e92ea05ece4e821c0a5efe8f1645c4c0c93c1ab99285d622caa652c1dfad63d745d6f2de5f17e5eaf0fc4963d261c8a12436518206dc093344d5ad293")] | |||
[assembly: InternalsVisibleTo("datacollector, PublicKey =002400000480000094000000060200000024000052534131000400000100010007d1fa57c4aed9f0a32e84aa0faefd0de9e8fd6aec8f87fb03766c834c99921eb23be79ad9d5dcc1dd9ad236132102900b723cf980957fc4e177108fc607774f29e8320e92ea05ece4e821c0a5efe8f1645c4c0c93c1ab99285d622caa652c1dfad63d745d6f2de5f17e5eaf0fc4963d261c8a12436518206dc093344d5ad293")] | |||
[assembly: InternalsVisibleTo("Microsoft.TestPlatform.CommunicationUtilities, PublicKey=002400000480000094000000060200000024000052534131000400000100010007d1fa57c4aed9f0a32e84aa0faefd0de9e8fd6aec8f87fb03766c834c99921eb23be79ad9d5dcc1dd9ad236132102900b723cf980957fc4e177108fc607774f29e8320e92ea05ece4e821c0a5efe8f1645c4c0c93c1ab99285d622caa652c1dfad63d745d6f2de5f17e5eaf0fc4963d261c8a12436518206dc093344d5ad293")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure why TP.Common needs a dependency on CommunicationUtilities.
@@ -33,6 +33,11 @@ | |||
<Reference Include="Microsoft.CSharp" /> | |||
</ItemGroup> | |||
<ItemGroup> | |||
<Reference Include="System.Dynamic.Runtime"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this change required?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not required, removed.
@@ -65,33 +58,18 @@ public void Initialize(Architecture architecture) | |||
public virtual int LaunchDataCollector(IDictionary<string, string> environmentVariables, IList<string> commandLineArguments) | |||
{ | |||
var currentWorkingDirectory = Path.GetDirectoryName(typeof(DataCollectionLauncher).GetTypeInfo().Assembly.Location); | |||
string dataCollectorProcessPath, processWorkingDirectory = null; | |||
string dataCollectorProcessPath = null, processWorkingDirectory = null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How are we handling scenarios where process doesn't start? Or process crashes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is handled in ProxyExecutionManagerWithDataCollection, the class responsible for initiating test execution when data collection is enabled.
|
||
dataCollectorFileName = Path.GetFileNameWithoutExtension(dataCollectorAssemblyPath); | ||
|
||
// .NET core host manager is not a shared host. It will expect a single test source to be provided. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not true. Datacollector is always shared?
@@ -20,13 +19,8 @@ namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.DataCollection | |||
internal class DataCollectionLauncher : IDataCollectionLauncher |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please follow the convention:
- DefaultDataCollectionLauncher
- DotnetDataCollectionLauncher
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
} | ||
} | ||
|
||
commandLineArguments.Insert(0, args); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IList.Insert is O(n). We're doing it multiple times in this logic. Why not use String.Concat and String.Join(commandLineArguments)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
foreach (string path in pathString.Split(separator)) | ||
{ | ||
var exeFullPath = Path.Combine(path.Trim(), dotnetExeName); | ||
if (File.Exists(exeFullPath)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How are we testing this logic? We have to use IFileHelper here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
/// </summary> | ||
/// <returns>Full path to <c>dotnet</c> executable</returns> | ||
/// <remarks>Debuggers require the full path of executable to launch it.</remarks> | ||
private string GetDotnetHostFullPath() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This functionality is DRY violation with DotnetTestHostManager. Please extract it to an independent unit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. Extracted an interface IDotnetHostHelper.
{ | ||
} | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="ProxyDataCollectionManager"/> class. | ||
/// </summary> | ||
/// <param name="arch"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Boilerplate docs.
Assert.AreEqual("my://custom/datacollector", attachments[0].Uri.ToString()); | ||
Assert.IsTrue(attachments[0].Attachments[0].Uri.ToString().Contains("filename.txt")); | ||
|
||
proxyDataCollectionManager.Dispose(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
using () { ... } in all TestMethods.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
{ | ||
var socketCommManager = new SocketCommunicationManager(); | ||
var dataCollectionRequestSender = new DataCollectionRequestSender(socketCommManager, JsonDataSerializer.Instance); | ||
#if NET46 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not use this.dataCollectionLauncher
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IDataCollectorLauncher doesn't expose Process which I am using to monitor the process.
I don't see a need to expose the process in interface, therefore I am using specific instances here.
Assert.IsNull(attachments); | ||
|
||
// Give time to datacollector process to exit. | ||
Thread.Sleep(500); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use result.WaitForExit()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
<Import Project="$(TestPlatformRoot)scripts\build\TestPlatform.targets" /> | ||
|
||
<Target Name="AfterBuild" Condition=" '$(TargetFramework)' == 'netcoreapp1.0' "> | ||
<Copy |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this required? Isn't the datacollector launched from artifacts\Debug\netXX\...
directory in these tests?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These tests are executed from test\datacollector.PlatformTests\bin\Debug
, therefore, we need to manually copy these files.
} | ||
} | ||
}, | ||
this.cancellationTokenSource.Token); | ||
|
||
this.attachmentTasks.Add(task); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just monitoring the continuationTask will suffice?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good with few suggestions.
For the resx changes, please run |
Integration of vstest.console process with datacollector process.
Related to :
#309