Skip to content

Commit

Permalink
Add PluginsTests (#910)
Browse files Browse the repository at this point in the history
* Add PluginsTests

* Refactor RunTestApplicationAndWaitForExit

* Refactor MockZipkinCollector

* Refactor MockCollector

* Update test/IntegrationTests/Helpers/TestHelper.cs

Co-authored-by: Chris Ventura <[email protected]>

* Update PluginsTests.cs

Co-authored-by: Chris Ventura <[email protected]>
  • Loading branch information
pellared and nrcventura authored Jul 1, 2022
1 parent 94fbe95 commit 77998bd
Show file tree
Hide file tree
Showing 19 changed files with 551 additions and 548 deletions.
6 changes: 6 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,12 @@ updates:
interval: "daily"
open-pull-requests-limit: 20

- package-ecosystem: nuget
directory: /test/test-applications/integrations/TestApplication.Plugins
schedule:
interval: "daily"
open-pull-requests-limit: 20

- package-ecosystem: nuget
directory: /test/test-applications/integrations/TestApplication.Smoke
schedule:
Expand Down
15 changes: 15 additions & 0 deletions OpenTelemetry.AutoInstrumentation.sln
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestApplication.MongoDB", "
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestApplication.SqlClient", "test\test-applications\integrations\TestApplication.SqlClient\TestApplication.SqlClient.csproj", "{2120CFA2-9D16-45F0-A333-B0385C371509}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestApplication.Plugins", "test\test-applications\integrations\TestApplication.Plugins\TestApplication.Plugins.csproj", "{42BABA6C-1954-4F52-85C8-D336C00F06D9}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -503,6 +505,18 @@ Global
{2120CFA2-9D16-45F0-A333-B0385C371509}.Release|x64.Build.0 = Release|x64
{2120CFA2-9D16-45F0-A333-B0385C371509}.Release|x86.ActiveCfg = Release|x86
{2120CFA2-9D16-45F0-A333-B0385C371509}.Release|x86.Build.0 = Release|x86
{42BABA6C-1954-4F52-85C8-D336C00F06D9}.Debug|Any CPU.ActiveCfg = Debug|x64
{42BABA6C-1954-4F52-85C8-D336C00F06D9}.Debug|Any CPU.Build.0 = Debug|x64
{42BABA6C-1954-4F52-85C8-D336C00F06D9}.Debug|x64.ActiveCfg = Debug|x64
{42BABA6C-1954-4F52-85C8-D336C00F06D9}.Debug|x64.Build.0 = Debug|x64
{42BABA6C-1954-4F52-85C8-D336C00F06D9}.Debug|x86.ActiveCfg = Debug|x86
{42BABA6C-1954-4F52-85C8-D336C00F06D9}.Debug|x86.Build.0 = Debug|x86
{42BABA6C-1954-4F52-85C8-D336C00F06D9}.Release|Any CPU.ActiveCfg = Release|x64
{42BABA6C-1954-4F52-85C8-D336C00F06D9}.Release|Any CPU.Build.0 = Release|x64
{42BABA6C-1954-4F52-85C8-D336C00F06D9}.Release|x64.ActiveCfg = Release|x64
{42BABA6C-1954-4F52-85C8-D336C00F06D9}.Release|x64.Build.0 = Release|x64
{42BABA6C-1954-4F52-85C8-D336C00F06D9}.Release|x86.ActiveCfg = Release|x86
{42BABA6C-1954-4F52-85C8-D336C00F06D9}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -545,6 +559,7 @@ Global
{6ACF2A48-427F-4EF2-81B5-EE9CDB0476C6} = {BAF8F246-3645-42AD-B1D0-0F7EAFBAB34A}
{3B77F975-BF66-4218-9982-F48D3271DDFE} = {E409ADD3-9574-465C-AB09-4324D205CC7C}
{2120CFA2-9D16-45F0-A333-B0385C371509} = {E409ADD3-9574-465C-AB09-4324D205CC7C}
{42BABA6C-1954-4F52-85C8-D336C00F06D9} = {E409ADD3-9574-465C-AB09-4324D205CC7C}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {160A1D00-1F5B-40F8-A155-621B4459D78F}
Expand Down
33 changes: 14 additions & 19 deletions test/IntegrationTests/AspNetTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,20 +45,17 @@ public async Task SubmitsTraces()
{
Assert.True(EnvironmentTools.IsWindowsAdministrator(), "This test requires Windows Administrator privileges.");

var agentPort = TcpPortProvider.GetOpenPort();
var webPort = TcpPortProvider.GetOpenPort();

var testSettings = new TestSettings
{
TracesSettings = new TracesSettings { Port = agentPort }
};

// Using "*" as host requires Administrator. This is needed to make the mock collector endpoint
// accessible to the Windows docker container where the test application is executed by binding
// the endpoint to all network interfaces. In order to do that it is necessary to open the port
// on the firewall.
using var fwPort = FirewallHelper.OpenWinPort(agentPort, Output);
using var agent = new MockZipkinCollector(Output, agentPort, host: "*");
using var agent = new MockZipkinCollector(Output, host: "*");
using var fwPort = FirewallHelper.OpenWinPort(agent.Port, Output);
var testSettings = new TestSettings
{
TracesSettings = new TracesSettings { Port = agent.Port }
};
var webPort = TcpPortProvider.GetOpenPort();
using var container = await StartContainerAsync(testSettings, webPort);

var client = new HttpClient();
Expand All @@ -81,21 +78,19 @@ public async Task SubmitsTraces()
[Trait("Containers", "Windows")]
public async Task SubmitMetrics()
{
var collectorPort = TcpPortProvider.GetOpenPort();
var webPort = TcpPortProvider.GetOpenPort();
const int expectedMetricRequests = 1;

var testSettings = new TestSettings
{
MetricsSettings = new MetricsSettings { Port = collectorPort },
};

// Using "*" as host requires Administrator. This is needed to make the mock collector endpoint
// accessible to the Windows docker container where the test application is executed by binding
// the endpoint to all network interfaces. In order to do that it is necessary to open the port
// on the firewall.
using var fwPort = FirewallHelper.OpenWinPort(collectorPort, Output);
using var collector = new MockCollector(Output, collectorPort, host: "*");
using var collector = new MockMetricsCollector(Output, host: "*");
using var fwPort = FirewallHelper.OpenWinPort(collector.Port, Output);
var testSettings = new TestSettings
{
MetricsSettings = new MetricsSettings { Port = collector.Port },
};
var webPort = TcpPortProvider.GetOpenPort();
using var container = await StartContainerAsync(testSettings, webPort);

var client = new HttpClient();
Expand Down
4 changes: 1 addition & 3 deletions test/IntegrationTests/GraphQLTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,8 @@ public void SubmitsTraces()
{
SetEnvironmentVariable("OTEL_SERVICE_NAME", ServiceName);

int agentPort = TcpPortProvider.GetOpenPort();
int aspNetCorePort = TcpPortProvider.GetOpenPort();

using (var agent = new MockZipkinCollector(Output, agentPort))
using (var agent = new MockZipkinCollector(Output))
using (Process process = StartTestApplication(agent.Port, arguments: null, packageVersion: string.Empty, aspNetCorePort: aspNetCorePort))
{
if (process.HasExited)
Expand Down
2 changes: 1 addition & 1 deletion test/IntegrationTests/Helpers/EnvironmentHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ public void SetEnvironmentVariables(
if (testSettings.MetricsSettings != null)
{
environmentVariables["OTEL_METRICS_EXPORTER"] = testSettings.MetricsSettings.Exporter;
environmentVariables["OTEL_EXPORTER_OTLP_ENDPOINT"] = $"http://127.0.0.1:{testSettings.MetricsSettings.Port}";
environmentVariables["OTEL_EXPORTER_OTLP_ENDPOINT"] = $"http://localhost:{testSettings.MetricsSettings.Port}";
}

// for ASP.NET Core test applications, set the server's port
Expand Down
259 changes: 0 additions & 259 deletions test/IntegrationTests/Helpers/MockCollector.cs

This file was deleted.

Loading

0 comments on commit 77998bd

Please sign in to comment.