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

Egress Extension Testing (my own testing) #43

Open
wants to merge 32 commits into
base: kkeirstead/feature/egressExtension
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 31 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
eca975c
Added in preliminary test that ensures the correct exception is throw…
kkeirstead Nov 4, 2022
7843e55
Added in basic test that checks that an extension.json file is found …
kkeirstead Nov 4, 2022
1b5ad12
Expanded success case to check against other paths
kkeirstead Nov 7, 2022
fb7e326
Added in test extension app; not being integrated yet.
kkeirstead Nov 7, 2022
8975927
In progress
kkeirstead Nov 8, 2022
d4fd59e
Integration working with egress test app
kkeirstead Nov 8, 2022
a88ac6f
Doing some refactoring
kkeirstead Nov 10, 2022
ff131db
Added in preliminary test that ensures the correct exception is throw…
kkeirstead Nov 4, 2022
cb4a9c0
Added in basic test that checks that an extension.json file is found …
kkeirstead Nov 4, 2022
092d764
Expanded success case to check against other paths
kkeirstead Nov 7, 2022
e26eb36
Added in test extension app; not being integrated yet.
kkeirstead Nov 7, 2022
d776410
In progress
kkeirstead Nov 8, 2022
fd3566a
Integration working with egress test app
kkeirstead Nov 8, 2022
740f991
Doing some refactoring
kkeirstead Nov 10, 2022
a003ad4
Updated testing to work with latest changes
kkeirstead Nov 18, 2022
7c2598e
Fixed conflicts
kkeirstead Nov 18, 2022
773c4ca
Fixes for tests
kkeirstead Nov 22, 2022
63a4449
More testing work
kkeirstead Nov 22, 2022
d3f2e3d
Some cleanup
kkeirstead Nov 28, 2022
44a71ad
Cleanup, added failure test
kkeirstead Nov 28, 2022
cd34fe9
Removing hte notion of passing byte array
kkeirstead Nov 28, 2022
cc5d702
Some cleanup
kkeirstead Nov 29, 2022
a21b920
Added in executing assembly location for tests, some cleanup
kkeirstead Dec 5, 2022
b2e6f35
Cleanup, bug fix
kkeirstead Dec 7, 2022
adde9cb
Refactoring
kkeirstead Dec 7, 2022
2d5b6f4
Fixed sln
kkeirstead Dec 7, 2022
71dedcb
Removed unused file
kkeirstead Dec 7, 2022
3f77992
PR feedback
kkeirstead Dec 7, 2022
4cfaa05
Experimenting with file extensions
kkeirstead Dec 7, 2022
6ea63f5
Tweaks
kkeirstead Dec 7, 2022
73acea9
Experimenting with how to get things working on all OS's
kkeirstead Dec 7, 2022
0fd96ae
Update dotnet-monitor.sln
kkeirstead Mar 22, 2023
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
7 changes: 7 additions & 0 deletions dotnet-monitor.sln
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Diagnostics.Monit
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Diagnostics.Monitoring.ExecuteActionApp", "src\Tests\Microsoft.Diagnostics.Monitoring.ExecuteActionApp\Microsoft.Diagnostics.Monitoring.ExecuteActionApp.csproj", "{A5A0CAAB-C200-44D2-BC93-8445C6E748AD}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Diagnostics.Monitoring.EgressExtensibilityApp", "src\Tests\Microsoft.Diagnostics.Monitoring.EgressExtensibilityApp\Microsoft.Diagnostics.Monitoring.EgressExtensibilityApp.csproj", "{8f8a9a15-24d5-496c-b769-3caed25d1ba8}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AzureBlobStorage", "src\Extensions\AzureBlobStorage\AzureBlobStorage.csproj", "{5ED61A7B-F0AA-45F2-9E9A-8972FF7F7278}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Diagnostics.Monitoring.Profiler.UnitTests", "src\Tests\Microsoft.Diagnostics.Monitoring.Profiler.UnitTests\Microsoft.Diagnostics.Monitoring.Profiler.UnitTests.csproj", "{A25AC517-F7C6-43C6-B892-4A447914C42C}"
Expand Down Expand Up @@ -108,6 +110,10 @@ Global
{A5A0CAAB-C200-44D2-BC93-8445C6E748AD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A5A0CAAB-C200-44D2-BC93-8445C6E748AD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A5A0CAAB-C200-44D2-BC93-8445C6E748AD}.Release|Any CPU.Build.0 = Release|Any CPU
{8f8a9a15-24d5-496c-b769-3caed25d1ba8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8f8a9a15-24d5-496c-b769-3caed25d1ba8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8f8a9a15-24d5-496c-b769-3caed25d1ba8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8f8a9a15-24d5-496c-b769-3caed25d1ba8}.Release|Any CPU.Build.0 = Release|Any CPU
Copy link
Owner Author

Choose a reason for hiding this comment

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

#TODO test comment 3

{5ED61A7B-F0AA-45F2-9E9A-8972FF7F7278}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5ED61A7B-F0AA-45F2-9E9A-8972FF7F7278}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5ED61A7B-F0AA-45F2-9E9A-8972FF7F7278}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand Down Expand Up @@ -148,6 +154,7 @@ Global
{173F959B-231B-45D1-8328-9460D4C5BC71} = {19FAB78C-3351-4911-8F0C-8C6056401740}
{0DBE362D-82F1-4740-AE6A-40C1A82EDCDB} = {C7568468-1C79-4944-8136-18812A7F9EA7}
{A5A0CAAB-C200-44D2-BC93-8445C6E748AD} = {C7568468-1C79-4944-8136-18812A7F9EA7}
{8f8a9a15-24d5-496c-b769-3caed25d1ba8} = {C7568468-1C79-4944-8136-18812A7F9EA7}
{5ED61A7B-F0AA-45F2-9E9A-8972FF7F7278} = {B62728C8-1267-4043-B46F-5537BBAEC692}
{A25AC517-F7C6-43C6-B892-4A447914C42C} = {C7568468-1C79-4944-8136-18812A7F9EA7}
{1CA2284B-A3A0-476A-9A93-A95E665E78BE} = {C7568468-1C79-4944-8136-18812A7F9EA7}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>$(ToolTargetFrameworks)</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="System.CommandLine" Version="$(SystemCommandLineVersion)" />
<PackageReference Include="xunit.assert" Version="$(XUnitVersion)" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\Microsoft.Diagnostics.Monitoring.Options\Microsoft.Diagnostics.Monitoring.Options.csproj" />
<ProjectReference Include="..\..\Tools\dotnet-monitor\dotnet-monitor.csproj" />
<ProjectReference Include="..\Microsoft.Diagnostics.Monitoring.Tool.UnitTests\Microsoft.Diagnostics.Monitoring.Tool.UnitTests.csproj" />
</ItemGroup>

<ItemGroup>
<None Update="extension.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using Microsoft.Diagnostics.Monitoring.Tool.UnitTests;
using Microsoft.Diagnostics.Tools.Monitor.Egress;
using System;
using System.Collections.Generic;
using System.CommandLine;
using System.Text.Json;

namespace Microsoft.Diagnostics.Monitoring.EgressExtensibilityApp
{
internal class Program
{
static int Main(string[] args)
{
RootCommand rootCommand = new RootCommand();

Command egressCmd = new Command("Egress");

egressCmd.SetHandler(() => Egress());

rootCommand.Add(egressCmd);

return rootCommand.Invoke(args);
}

private static int Egress()
{
EgressArtifactResult result = new();
try
{
string jsonConfig = Console.ReadLine();

ExtensionEgressPayload configPayload = JsonSerializer.Deserialize<ExtensionEgressPayload>(jsonConfig);
TestEgressProviderOptions options = BuildOptions(configPayload);

if (options.ShouldSucceed)
{
result.Succeeded = true;
result.ArtifactPath = EgressExtensibilityTests.SampleArtifactPath;
}
else
{
result.Succeeded = false;
result.FailureMessage = EgressExtensibilityTests.SampleFailureMessage;
}
}
catch (Exception ex)
{
result.Succeeded = false;
result.FailureMessage = ex.Message;
}

string jsonBlob = JsonSerializer.Serialize(result);
Console.Write(jsonBlob);

// return non-zero exit code when failed
return result.Succeeded ? 0 : 1;
}

private static TestEgressProviderOptions BuildOptions(ExtensionEgressPayload configPayload)
{
TestEgressProviderOptions options = new TestEgressProviderOptions()
{
ShouldSucceed = GetConfig(configPayload.Configuration, nameof(TestEgressProviderOptions.ShouldSucceed)),
};

return options;
}

private static bool GetConfig(IDictionary<string, string> configDict, string propKey)
{
if (configDict.ContainsKey(propKey))
{
return bool.Parse(configDict[propKey]);
}

return false;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

namespace Microsoft.Diagnostics.Monitoring.EgressExtensibilityApp
{
internal sealed partial class TestEgressProviderOptions
{
public bool ShouldSucceed { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"Id": "Microsoft.Diagnostics.Monitoring.EgressExtensibilityApp",
"Version": "1.0.0",
"Program": "Microsoft.Diagnostics.Monitoring.EgressExtensibilityApp.exe",
"Name": "TestingProvider",
"SupportedExtensionTypes": [
"Egress"
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@ internal class MonitorRunner : IAsyncDisposable
private string UserConfigDirectoryPath =>
Path.Combine(TempPath, "UserConfig");

private string DotnetToolsExtensionDirectoryPath =>
Path.Combine(TempPath, "DotnetToolsExtension");

private string ExecutingAssemblyDirectoryPath =>
Path.Combine(TempPath, "ExecutingAssembly");

private string UserSettingsFilePath =>
Path.Combine(UserConfigDirectoryPath, "settings.json");

Expand All @@ -96,6 +102,8 @@ public MonitorRunner(ITestOutputHelper outputHelper)

Directory.CreateDirectory(SharedConfigDirectoryPath);
Directory.CreateDirectory(UserConfigDirectoryPath);
Directory.CreateDirectory(DotnetToolsExtensionDirectoryPath);
Directory.CreateDirectory(ExecutingAssemblyDirectoryPath);
}

public virtual async ValueTask DisposeAsync()
Expand Down Expand Up @@ -154,6 +162,10 @@ public virtual async Task StartAsync(string command, string[] args, Cancellation
_adapter.Environment.Add("DotnetMonitorTestSettings__SharedConfigDirectoryOverride", SharedConfigDirectoryPath);
// Override the user config directory
_adapter.Environment.Add("DotnetMonitorTestSettings__UserConfigDirectoryOverride", UserConfigDirectoryPath);
// Override the dotnet tools extension directory
_adapter.Environment.Add("DotnetMonitorTestSettings__DotnetToolsExtensionDirectoryOverride", DotnetToolsExtensionDirectoryPath);
// Override the "next to me" executing assembly directory
_adapter.Environment.Add("DotnetMonitorTestSettings__ExecutingAssemblyDirectoryOverride", ExecutingAssemblyDirectoryPath);

// Enable experimental stacks feature
if (EnableCallStacksFeature)
Expand Down
Loading