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

User/ivberg/fix ctf folder open upgrade sdk #20

Merged
merged 3 commits into from
Jun 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion LTTngCds/LTTngCds.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Performance.SDK" Version="0.108.2" />
<PackageReference Include="Microsoft.Performance.SDK" Version="0.109.11-preview-g61bc0d83f6" />
</ItemGroup>

<ItemGroup>
Expand Down
17 changes: 11 additions & 6 deletions LTTngCds/LTTngDataSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ namespace LTTngCds
"LTTng",
"Processes LTTng CTF data")]
[FileDataSource("ctf", "ctf")]
[DirectoryDataSource("LTTng CTF Folder")]
public class LTTngDataSource
: CustomDataSourceBase
{
Expand All @@ -23,11 +24,14 @@ public class LTTngDataSource
/// <inheritdoc />
public override IEnumerable<Option> CommandLineOptions => Enumerable.Empty<Option>();

protected override bool IsFileSupportedCore(string path)
protected override bool IsDataSourceSupportedCore(IDataSource dataSource)
{
return StringComparer.OrdinalIgnoreCase.Equals(
".ctf",
Path.GetExtension(path));
if (dataSource.IsDirectory())
{
return Directory.GetFiles(dataSource.Uri.LocalPath, "metadata", SearchOption.AllDirectories).Any();
}

return dataSource.IsFile() && StringComparer.OrdinalIgnoreCase.Equals(".ctf", Path.GetExtension(dataSource.Uri.LocalPath));
}

public override CustomDataSourceInfo GetAboutInfo()
Expand Down Expand Up @@ -68,8 +72,9 @@ protected override ICustomDataProcessor CreateProcessorCore(

var sourceParser = new LTTngSourceParser();

string sourcePath = dataSources.First().GetUri().LocalPath;
if (Directory.Exists(sourcePath))
var firstDataSource = dataSources.First();
string sourcePath = firstDataSource.Uri.LocalPath;
if (firstDataSource.IsDirectory() && Directory.Exists(sourcePath))
{
// handle open directory
sourceParser.SetFolderInput(sourcePath);
Expand Down
6 changes: 3 additions & 3 deletions LTTngDataExtUnitTest/LTTngDataExtUnitTest.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.1" />
<PackageReference Include="Microsoft.Performance.SDK" Version="0.108.2" />
<PackageReference Include="Microsoft.Performance.SDK.Runtime" Version="0.108.2" />
<PackageReference Include="Microsoft.Performance.Toolkit.Engine" Version="0.108.2" />
<PackageReference Include="Microsoft.Performance.SDK" Version="0.109.11-preview-g61bc0d83f6" />
<PackageReference Include="Microsoft.Performance.SDK.Runtime" Version="0.109.11-preview-g61bc0d83f6" />
<PackageReference Include="Microsoft.Performance.Toolkit.Engine" Version="0.109.11-preview-g61bc0d83f6" />
<PackageReference Include="Moq" Version="4.16.1" />
<PackageReference Include="MSTest.TestAdapter" Version="2.2.3" />
<PackageReference Include="MSTest.TestFramework" Version="2.2.3" />
Expand Down
28 changes: 25 additions & 3 deletions LTTngDataExtUnitTest/LTTngUnitTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using System;
using System.Collections.Generic;
using System.IO;
using LTTngCds;
using LTTngDataExtensions.SourceDataCookers;
using LTTngDataExtensions.DataOutputTypes;
using LTTngDataExtensions.SourceDataCookers.Syscall;
Expand All @@ -13,12 +12,12 @@
using Microsoft.Performance.SDK.Processing;
using Microsoft.Performance.Toolkit.Engine;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using UnitTestCommon;
using LTTngDataExtensions.SourceDataCookers.Diagnostic_Messages;
using Microsoft.Performance.SDK;
using LTTngDataExtensions.SourceDataCookers.Module;
using LTTngDataExtensions.SourceDataCookers.Disk;
using System.IO.Compression;
using System.Linq;

namespace LTTngDataExtUnitTest
{
Expand Down Expand Up @@ -89,6 +88,29 @@ public static void ProcessTrace()
}
}

[TestMethod]
public void ProcessTraceAsFolder()
{
// Input data
string[] lttngData = { @"..\..\..\..\TestData\LTTng\lttng-kernel-trace.ctf" };

string tempDirectory = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());

ZipFile.ExtractToDirectory(lttngData[0], tempDirectory);

// Approach #1 - Engine - Doesn't test tables UI but tests processing
var runtime = Engine.Create();

var ds = new DirectoryDataSource(tempDirectory);
runtime.AddDataSource(ds);

Assert.IsTrue(ds.IsDirectory());
Assert.IsTrue(runtime.SourceDataCookers.Count() >= 1);
Assert.IsTrue(runtime.AvailableTables.Count() >= 1);

Directory.Delete(tempDirectory, true);
}

[TestMethod]
public void DiagnosticMessageTable()
{
Expand Down
2 changes: 1 addition & 1 deletion LTTngDataExtensions/LTTngDataExtensions.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Performance.SDK" Version="0.108.2" />
<PackageReference Include="Microsoft.Performance.SDK" Version="0.109.11-preview-g61bc0d83f6" />
</ItemGroup>

<ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions LTTngDriver/LTTngDriver.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Performance.SDK" Version="0.108.2" />
<PackageReference Include="Microsoft.Performance.Toolkit.Engine" Version="0.108.2" />
<PackageReference Include="Microsoft.Performance.SDK" Version="0.109.11-preview-g61bc0d83f6" />
<PackageReference Include="Microsoft.Performance.Toolkit.Engine" Version="0.109.11-preview-g61bc0d83f6" />
</ItemGroup>

<ItemGroup>
Expand Down
3 changes: 3 additions & 0 deletions LTTngDriver/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ public bool Run()
return false;
}
Copy link
Contributor

@zachnew-msft zachnew-msft Jun 28, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this still needed (the commented out ReadLine)?


// Debug
//Console.ReadLine();

//
// Create our runtime environment, enabling cookers and
// adding inputs.
Expand Down
2 changes: 1 addition & 1 deletion LinuxLogParsers/LinuxLogParser/LinuxLogParser.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Performance.SDK" Version="0.108.2" />
<PackageReference Include="Microsoft.Performance.SDK" Version="0.109.11-preview-g61bc0d83f6" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Performance.SDK" Version="0.108.2" />
<PackageReference Include="Microsoft.Performance.SDK" Version="0.109.11-preview-g61bc0d83f6" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.1" />
<PackageReference Include="Microsoft.Performance.SDK" Version="0.108.2" />
<PackageReference Include="Microsoft.Performance.Toolkit.Engine" Version="0.108.2" />
<PackageReference Include="Microsoft.Performance.SDK" Version="0.109.11-preview-g61bc0d83f6" />
<PackageReference Include="Microsoft.Performance.Toolkit.Engine" Version="0.109.11-preview-g61bc0d83f6" />
<PackageReference Include="Moq" Version="4.16.1" />
<PackageReference Include="MSTest.TestAdapter" Version="2.2.3" />
<PackageReference Include="MSTest.TestFramework" Version="2.2.3" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Performance.SDK" Version="0.108.2" />
<PackageReference Include="Microsoft.Performance.SDK" Version="0.109.11-preview-g61bc0d83f6" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,19 +52,19 @@ protected override void SetApplicationEnvironmentCore(IApplicationEnvironment ap
this.applicationEnvironment = applicationEnvironment;
}

protected override bool IsFileSupportedCore(string path)
protected override bool IsDataSourceSupportedCore(IDataSource dataSource)
{
return StringComparer.OrdinalIgnoreCase.Equals(
return dataSource.IsFile() && StringComparer.OrdinalIgnoreCase.Equals(
"cloud-init.log",
Path.GetFileName(path));
Path.GetFileName(dataSource.Uri.LocalPath));
}

protected override ICustomDataProcessor CreateProcessorCore(
IEnumerable<IDataSource> dataSources,
IProcessorEnvironment processorEnvironment,
ProcessorOptions options)
{
string[] filePaths = dataSources.Select(x => x.GetUri().LocalPath).ToArray();
string[] filePaths = dataSources.Select(x => x.Uri.LocalPath).ToArray();
var sourceParser = new CloudInitLogParser(filePaths);

return new CloudInitCustomDataProcessor(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Performance.SDK" Version="0.108.2" />
<PackageReference Include="Microsoft.Performance.SDK" Version="0.109.11-preview-g61bc0d83f6" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class DmesgIsoDataSource : CustomDataSourceBase

protected override ICustomDataProcessor CreateProcessorCore(IEnumerable<IDataSource> dataSources, IProcessorEnvironment processorEnvironment, ProcessorOptions options)
{
string[] filePaths = dataSources.Select(x => x.GetUri().LocalPath).ToArray();
string[] filePaths = dataSources.Select(x => x.Uri.LocalPath).ToArray();
var sourceParser = new DmesgIsoLogParser(filePaths);

return new DmesgIsoCustomDataProcessor(
Expand All @@ -33,9 +33,9 @@ protected override ICustomDataProcessor CreateProcessorCore(IEnumerable<IDataSou
this.MetadataTables);
}

protected override bool IsFileSupportedCore(string path)
protected override bool IsDataSourceSupportedCore(IDataSource dataSource)
{
return path.ToLower().EndsWith("dmesg.iso.log");
return dataSource.IsFile() && dataSource.Uri.LocalPath.ToLower().EndsWith("dmesg.iso.log");
}

protected override void SetApplicationEnvironmentCore(IApplicationEnvironment applicationEnvironment)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Performance.SDK" Version="0.108.2" />
<PackageReference Include="Microsoft.Performance.SDK" Version="0.109.11-preview-g61bc0d83f6" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,19 +53,17 @@ protected override void SetApplicationEnvironmentCore(IApplicationEnvironment ap
this.applicationEnvironment = applicationEnvironment;
}

protected override bool IsFileSupportedCore(string path)
protected override bool IsDataSourceSupportedCore(IDataSource dataSource)
{
return StringComparer.OrdinalIgnoreCase.Equals(
"waagent.log",
Path.GetFileName(path));
return dataSource.IsFile() && StringComparer.OrdinalIgnoreCase.Equals("waagent.log", Path.GetFileName(dataSource.Uri.LocalPath));
}

protected override ICustomDataProcessor CreateProcessorCore(
IEnumerable<IDataSource> dataSources,
IProcessorEnvironment processorEnvironment,
ProcessorOptions options)
{
string[] filePaths = dataSources.Select(x => x.GetUri().LocalPath).ToArray();
string[] filePaths = dataSources.Select(x => x.Uri.LocalPath).ToArray();
var sourceParser = new WaLinuxAgentLogParser(filePaths);

return new WaLinuxAgentCustomDataProcessor(
Expand Down
2 changes: 1 addition & 1 deletion PerfCds/PerfCds.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Performance.SDK" Version="0.108.2" />
<PackageReference Include="Microsoft.Performance.SDK" Version="0.109.11-preview-g61bc0d83f6" />
</ItemGroup>

<ItemGroup>
Expand Down
14 changes: 9 additions & 5 deletions PerfCds/PerfDataSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ namespace PerfCds
"Perf",
"Processes Perf CTF data")]
[FileDataSource("ctf", "ctf")]
[DirectoryDataSource("Perf CTF Folder")]
public class PerfDataSource
: CustomDataSourceBase
{
Expand All @@ -23,11 +24,14 @@ public class PerfDataSource
/// <inheritdoc />
public override IEnumerable<Option> CommandLineOptions => Enumerable.Empty<Option>();

protected override bool IsFileSupportedCore(string path)
protected override bool IsDataSourceSupportedCore(IDataSource dataSource)
{
return StringComparer.OrdinalIgnoreCase.Equals(
".ctf",
Path.GetExtension(path));
if (dataSource.IsDirectory())
{
return Directory.GetFiles(dataSource.Uri.LocalPath, "metadata", SearchOption.AllDirectories).Any();
}

return dataSource.IsFile() && StringComparer.OrdinalIgnoreCase.Equals(".ctf", Path.GetExtension(dataSource.Uri.LocalPath));
}

public override CustomDataSourceInfo GetAboutInfo()
Expand Down Expand Up @@ -68,7 +72,7 @@ protected override ICustomDataProcessor CreateProcessorCore(

var sourceParser = new PerfSourceParser();

string sourcePath = dataSources.First().GetUri().LocalPath;
string sourcePath = dataSources.First().Uri.LocalPath;
if (Directory.Exists(sourcePath))
{
// handle open directory
Expand Down
4 changes: 2 additions & 2 deletions PerfDataExtensions/PerfDataExtensions.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Diagnostics.Tracing.TraceEvent" Version="2.0.57" GeneratePathProperty="true">
<PackageReference Include="Microsoft.Diagnostics.Tracing.TraceEvent" Version="2.0.66" GeneratePathProperty="true">
<IncludeAssets>compile</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Performance.SDK" Version="0.108.2" />
<PackageReference Include="Microsoft.Performance.SDK" Version="0.109.11-preview-g61bc0d83f6" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,9 @@ protected override void SetApplicationEnvironmentCore(IApplicationEnvironment ap
this.applicationEnvironment = applicationEnvironment;
}

protected override bool IsFileSupportedCore(string path)
protected override bool IsDataSourceSupportedCore(IDataSource dataSource)
{
return StringComparer.OrdinalIgnoreCase.Equals(
"perf.data.txt",
Path.GetFileName(path));
return dataSource.IsFile() && StringComparer.OrdinalIgnoreCase.Equals("perf.data.txt", Path.GetFileName(dataSource.Uri.LocalPath));
}

protected override ICustomDataProcessor CreateProcessorCore(
Expand All @@ -78,7 +76,7 @@ protected override ICustomDataProcessor CreateProcessorCore(
//

return new PerfDataCustomDataProcessor(
dataSources.Select(x => x.GetUri().LocalPath).ToArray(),
dataSources.Select(x => x.Uri.LocalPath).ToArray(),
options,
this.applicationEnvironment,
processorEnvironment,
Expand Down
4 changes: 3 additions & 1 deletion PerfUnitTest/PerfUnitTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@

using Microsoft.Performance.SDK;
using Microsoft.Performance.SDK.Processing;
using Microsoft.Performance.Toolkit.Engine;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using PerfDataExtensions.Tables;
using System;
using System.Collections.Generic;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Threading;
using UnitTestCommon;
Expand All @@ -28,7 +30,7 @@ public void ProcessPerfCpuClock()

var perfDataPathFullPath = perfDataPath.FullName;
var datasource = new Mock<IDataSource>();
datasource.Setup(ds => ds.GetUri()).Returns(new Uri(perfDataPathFullPath));
datasource.Setup(ds => ds.Uri).Returns(new Uri(perfDataPathFullPath));

// Env
var appEnv = new Mock<IApplicationEnvironment>();
Expand Down
5 changes: 3 additions & 2 deletions PerfUnitTest/PerfUnitTest.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Diagnostics.Tracing.TraceEvent" Version="2.0.57" />
<PackageReference Include="Microsoft.Diagnostics.Tracing.TraceEvent" Version="2.0.66" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.1" />
<PackageReference Include="Microsoft.Performance.SDK" Version="0.108.2" />
<PackageReference Include="Microsoft.Performance.SDK" Version="0.109.11-preview-g61bc0d83f6" />
<PackageReference Include="Microsoft.Performance.Toolkit.Engine" Version="0.109.11-preview-g61bc0d83f6" />
<PackageReference Include="Moq" Version="4.16.1" />
<PackageReference Include="MSTest.TestAdapter" Version="2.2.3" />
<PackageReference Include="MSTest.TestFramework" Version="2.2.3" />
Expand Down
Loading