forked from dotnet/dotnet-monitor
-
Notifications
You must be signed in to change notification settings - Fork 0
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
kkeirstead
wants to merge
32
commits into
kkeirstead/feature/egressExtension
Choose a base branch
from
kkeirstead/egressExtension_Testing_P1_2
base: kkeirstead/feature/egressExtension
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
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 7843e55
Added in basic test that checks that an extension.json file is found …
kkeirstead 1b5ad12
Expanded success case to check against other paths
kkeirstead fb7e326
Added in test extension app; not being integrated yet.
kkeirstead 8975927
In progress
kkeirstead d4fd59e
Integration working with egress test app
kkeirstead a88ac6f
Doing some refactoring
kkeirstead ff131db
Added in preliminary test that ensures the correct exception is throw…
kkeirstead cb4a9c0
Added in basic test that checks that an extension.json file is found …
kkeirstead 092d764
Expanded success case to check against other paths
kkeirstead e26eb36
Added in test extension app; not being integrated yet.
kkeirstead d776410
In progress
kkeirstead fd3566a
Integration working with egress test app
kkeirstead 740f991
Doing some refactoring
kkeirstead a003ad4
Updated testing to work with latest changes
kkeirstead 7c2598e
Fixed conflicts
kkeirstead 773c4ca
Fixes for tests
kkeirstead 63a4449
More testing work
kkeirstead d3f2e3d
Some cleanup
kkeirstead 44a71ad
Cleanup, added failure test
kkeirstead cd34fe9
Removing hte notion of passing byte array
kkeirstead cc5d702
Some cleanup
kkeirstead a21b920
Added in executing assembly location for tests, some cleanup
kkeirstead b2e6f35
Cleanup, bug fix
kkeirstead adde9cb
Refactoring
kkeirstead 2d5b6f4
Fixed sln
kkeirstead 71dedcb
Removed unused file
kkeirstead 3f77992
PR feedback
kkeirstead 4cfaa05
Experimenting with file extensions
kkeirstead 6ea63f5
Tweaks
kkeirstead 73acea9
Experimenting with how to get things working on all OS's
kkeirstead 0fd96ae
Update dotnet-monitor.sln
kkeirstead File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
...ing.EgressExtensibilityApp/Microsoft.Diagnostics.Monitoring.EgressExtensibilityApp.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
83 changes: 83 additions & 0 deletions
83
src/Tests/Microsoft.Diagnostics.Monitoring.EgressExtensibilityApp/Program.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
...ests/Microsoft.Diagnostics.Monitoring.EgressExtensibilityApp/TestEgressProviderOptions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; } | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
src/Tests/Microsoft.Diagnostics.Monitoring.EgressExtensibilityApp/extension.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
#TODO test comment 3