Verify loaded managed modules (#1515)

This commit is contained in:
Rasmus Kuusmann 2022-10-31 17:22:24 +02:00 committed by GitHub
parent 0114c07240
commit 17f831f1b9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 183 additions and 1 deletions

View File

@ -153,7 +153,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestApplication.MassTransit
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tools", "tools", "{00F4C92D-6652-4BD8-A334-B35D3E711BE6}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IntegrationsJsonGenerator", "tools\IntegrationsJsonGenerator\IntegrationsJsonGenerator.csproj", "{0A950D85-E813-4CA3-8927-334BB7787372}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IntegrationsJsonGenerator", "tools\IntegrationsJsonGenerator\IntegrationsJsonGenerator.csproj", "{0A950D85-E813-4CA3-8927-334BB7787372}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestApplication.Modules", "test\test-applications\integrations\TestApplication.Modules\TestApplication.Modules.csproj", "{F8C3A1FF-2333-45C8-9174-75F12526DFDD}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -723,6 +725,18 @@ Global
{0A950D85-E813-4CA3-8927-334BB7787372}.Release|x64.Build.0 = Release|Any CPU
{0A950D85-E813-4CA3-8927-334BB7787372}.Release|x86.ActiveCfg = Release|Any CPU
{0A950D85-E813-4CA3-8927-334BB7787372}.Release|x86.Build.0 = Release|Any CPU
{F8C3A1FF-2333-45C8-9174-75F12526DFDD}.Debug|Any CPU.ActiveCfg = Debug|x64
{F8C3A1FF-2333-45C8-9174-75F12526DFDD}.Debug|Any CPU.Build.0 = Debug|x64
{F8C3A1FF-2333-45C8-9174-75F12526DFDD}.Debug|x64.ActiveCfg = Debug|x64
{F8C3A1FF-2333-45C8-9174-75F12526DFDD}.Debug|x64.Build.0 = Debug|x64
{F8C3A1FF-2333-45C8-9174-75F12526DFDD}.Debug|x86.ActiveCfg = Debug|x86
{F8C3A1FF-2333-45C8-9174-75F12526DFDD}.Debug|x86.Build.0 = Debug|x86
{F8C3A1FF-2333-45C8-9174-75F12526DFDD}.Release|Any CPU.ActiveCfg = Release|x64
{F8C3A1FF-2333-45C8-9174-75F12526DFDD}.Release|Any CPU.Build.0 = Release|x64
{F8C3A1FF-2333-45C8-9174-75F12526DFDD}.Release|x64.ActiveCfg = Release|x64
{F8C3A1FF-2333-45C8-9174-75F12526DFDD}.Release|x64.Build.0 = Release|x64
{F8C3A1FF-2333-45C8-9174-75F12526DFDD}.Release|x86.ActiveCfg = Release|x86
{F8C3A1FF-2333-45C8-9174-75F12526DFDD}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -779,6 +793,7 @@ Global
{28879377-2043-4370-A8DB-B04464B6E552} = {E409ADD3-9574-465C-AB09-4324D205CC7C}
{06664166-35D6-484D-9171-DCB99D1D310A} = {E409ADD3-9574-465C-AB09-4324D205CC7C}
{0A950D85-E813-4CA3-8927-334BB7787372} = {00F4C92D-6652-4BD8-A334-B35D3E711BE6}
{F8C3A1FF-2333-45C8-9174-75F12526DFDD} = {E409ADD3-9574-465C-AB09-4324D205CC7C}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {160A1D00-1F5B-40F8-A155-621B4459D78F}

View File

@ -0,0 +1,19 @@
[
OpenTelemetry,
OpenTelemetry.Api,
OpenTelemetry.AutoInstrumentation,
OpenTelemetry.AutoInstrumentation.Loader,
OpenTelemetry.AutoInstrumentation.StartupHook,
OpenTelemetry.Exporter.Console,
OpenTelemetry.Exporter.Jaeger,
OpenTelemetry.Exporter.OpenTelemetryProtocol,
OpenTelemetry.Exporter.Prometheus,
OpenTelemetry.Exporter.Zipkin,
OpenTelemetry.Instrumentation.GrpcNetClient,
OpenTelemetry.Instrumentation.Http,
OpenTelemetry.Instrumentation.Process,
OpenTelemetry.Instrumentation.Runtime,
OpenTelemetry.Instrumentation.SqlClient,
OpenTelemetry.Instrumentation.Wcf,
OpenTelemetry.Shims.OpenTracing
]

View File

@ -0,0 +1,20 @@
[
OpenTelemetry,
OpenTelemetry.Api,
OpenTelemetry.AutoInstrumentation,
OpenTelemetry.AutoInstrumentation.Loader,
OpenTelemetry.Exporter.Console,
OpenTelemetry.Exporter.Jaeger,
OpenTelemetry.Exporter.OpenTelemetryProtocol,
OpenTelemetry.Exporter.Prometheus,
OpenTelemetry.Exporter.Zipkin,
OpenTelemetry.Instrumentation.AspNet,
OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule,
OpenTelemetry.Instrumentation.GrpcNetClient,
OpenTelemetry.Instrumentation.Http,
OpenTelemetry.Instrumentation.Process,
OpenTelemetry.Instrumentation.Runtime,
OpenTelemetry.Instrumentation.SqlClient,
OpenTelemetry.Instrumentation.Wcf,
OpenTelemetry.Shims.OpenTracing
]

View File

@ -0,0 +1,66 @@
// <copyright file="ModuleTests.cs" company="OpenTelemetry Authors">
// Copyright The OpenTelemetry Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// </copyright>
using System.IO;
using System.Threading.Tasks;
using IntegrationTests.Helpers;
using Newtonsoft.Json;
using VerifyXunit;
using Xunit;
using Xunit.Abstractions;
namespace IntegrationTests;
[UsesVerify]
public class ModuleTests : TestHelper
{
public ModuleTests(ITestOutputHelper output)
: base("Modules", output)
{
}
[Fact]
public async Task RunApplication()
{
var tempPath = Path.GetTempFileName();
try
{
RunTestApplication(arguments: $"--temp-path {tempPath}");
if (!File.Exists(tempPath))
{
Assert.Fail("Could not find modules report file.");
}
var json = File.ReadAllText(tempPath);
var modules = JsonConvert.DeserializeObject<string[]>(json);
await Verifier.Verify(modules)
#if NETFRAMEWORK
.UseFileName($"{nameof(ModuleTests)}.{nameof(RunApplication)}.NetFx")
#else
.UseFileName($"{nameof(ModuleTests)}.{nameof(RunApplication)}.NetCore")
#endif
.DisableDiff();
}
finally
{
// Cleanup
File.Delete(tempPath);
}
}
}

View File

@ -0,0 +1,48 @@
// <copyright file="Program.cs" company="OpenTelemetry Authors">
// Copyright The OpenTelemetry Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// </copyright>
using System;
using System.IO;
using System.Linq;
using Newtonsoft.Json;
using TestApplication.Shared;
namespace TestApplication.Smoke;
public class Program
{
public static void Main(string[] args)
{
ConsoleHelper.WriteSplashScreen(args);
if (args.Length < 2)
{
throw new ArgumentException("Temp path is not provided. Use '--temp-path /my/path/to/temp_file'");
}
var otelLibs = AppDomain.CurrentDomain
.GetAssemblies()
.Select(x => x.GetName().Name)
.Where(name => name.StartsWith("OpenTelemetry"))
.OrderBy(name => name)
.ToList();
var json = JsonConvert.SerializeObject(otelLibs);
var path = args[1];
File.WriteAllText(path, json);
}
}

View File

@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">
<ItemGroup Condition="$(TargetFramework.StartsWith('net4'))">
<Reference Include="System.Net.Http" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="System.Diagnostics.DiagnosticSource" Version="6.0.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\dependency-libs\TestApplication.Shared\TestApplication.Shared.csproj" />
</ItemGroup>
</Project>