Skip to content

Commit 32a0911

Browse files
committed
Adjust test code to changes in mock collectors
1 parent 88be3d7 commit 32a0911

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+209
-209
lines changed

test/IntegrationTests/AspNetTests.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public async Task SubmitsTraces(AppPoolMode appPoolMode, Gac useGac)
6060
// accessible to the Windows docker container where the test application is executed by binding
6161
// the endpoint to all network interfaces. In order to do that it is necessary to open the port
6262
// on the firewall.
63-
using var collector = new MockSpansCollector(Output, host: "*");
63+
using var collector = await MockSpansCollector.InitializeAsync(Output, host: "*");
6464
using var fwPort = FirewallHelper.OpenWinPort(collector.Port, Output);
6565
collector.Expect("OpenTelemetry.Instrumentation.AspNet"); // Expect Mvc span
6666
collector.Expect("OpenTelemetry.Instrumentation.AspNet"); // Expect WebApi span
@@ -93,7 +93,7 @@ public async Task SubmitTracesCapturesHttpHeaders(AppPoolMode appPoolMode, Gac u
9393
// accessible to the Windows docker container where the test application is executed by binding
9494
// the endpoint to all network interfaces. In order to do that it is necessary to open the port
9595
// on the firewall.
96-
using var collector = new MockSpansCollector(Output, host: "*");
96+
using var collector = await MockSpansCollector.InitializeAsync(Output, host: "*");
9797
using var fwPort = FirewallHelper.OpenWinPort(collector.Port, Output);
9898
collector.Expect("OpenTelemetry.Instrumentation.AspNet", span => // Expect Mvc span
9999
{
@@ -161,7 +161,7 @@ public async Task TracesResource()
161161
// accessible to the Windows docker container where the test application is executed by binding
162162
// the endpoint to all network interfaces. In order to do that it is necessary to open the port
163163
// on the firewall.
164-
using var collector = new MockSpansCollector(Output, host: "*");
164+
using var collector = await MockSpansCollector.InitializeAsync(Output, host: "*");
165165
using var fwPort = FirewallHelper.OpenWinPort(collector.Port, Output);
166166
collector.ResourceExpector.Expect("service.name", ServiceName); // this is set via env var in Dockerfile and Wep.config, but env var has precedence
167167
collector.ResourceExpector.Expect("deployment.environment.name", "test"); // this is set via Wep.config
@@ -193,7 +193,7 @@ public async Task SubmitMetrics()
193193
// accessible to the Windows docker container where the test application is executed by binding
194194
// the endpoint to all network interfaces. In order to do that it is necessary to open the port
195195
// on the firewall.
196-
using var collector = new MockMetricsCollector(Output, host: "*");
196+
using var collector = await MockMetricsCollector.InitializeAsync(Output, host: "*");
197197
using var fwPort = FirewallHelper.OpenWinPort(collector.Port, Output);
198198
collector.Expect("OpenTelemetry.Instrumentation.AspNet");
199199

test/IntegrationTests/AssemblyRedirectionOnNetFrameworkTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ public AssemblyRedirectionOnNetFrameworkTests(ITestOutputHelper output)
1515
}
1616

1717
[Fact]
18-
public void SubmitsTraces()
18+
public async Task SubmitsTraces()
1919
{
20-
using var collector = new MockSpansCollector(Output);
20+
using var collector = await MockSpansCollector.InitializeAsync(Output);
2121
SetExporter(collector);
2222

2323
const string TestApplicationActivitySource = "AssemblyRedirection.NetFramework.ActivitySource";

test/IntegrationTests/AzureTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ public AzureTests(ITestOutputHelper output, AzureFixture azure)
2121
[Trait("Category", "EndToEnd")]
2222
[Trait("Containers", "Linux")]
2323
[MemberData(nameof(LibraryVersion.Azure), MemberType = typeof(LibraryVersion))]
24-
public void SubmitsTraces(string packageVersion)
24+
public async Task SubmitsTraces(string packageVersion)
2525
{
26-
using var collector = new MockSpansCollector(Output);
26+
using var collector = await MockSpansCollector.InitializeAsync(Output);
2727
SetExporter(collector);
2828

2929
collector.Expect("Azure.Core.Http");

test/IntegrationTests/ContinuousProfilerContextTrackingTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ public ContinuousProfilerContextTrackingTests(ITestOutputHelper output)
1515

1616
[Fact]
1717
[Trait("Category", "EndToEnd")]
18-
public void TraceContextIsCorrectlyAssociatedWithThreadSamples()
18+
public async Task TraceContextIsCorrectlyAssociatedWithThreadSamples()
1919
{
2020
EnableBytecodeInstrumentation();
21-
using var collector = new MockProfilesCollector(Output);
21+
using var collector = await MockProfilesCollector.InitializeAsync(Output);
2222
SetExporter(collector);
2323
SetEnvironmentVariable("OTEL_DOTNET_AUTO_PLUGINS", "TestApplication.ContinuousProfiler.ContextTracking.TestPlugin, TestApplication.ContinuousProfiler.ContextTracking, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null");
2424
SetEnvironmentVariable("OTEL_DOTNET_AUTO_TRACES_ADDITIONAL_SOURCES", "TestApplication.ContinuousProfiler.ContextTracking");

test/IntegrationTests/ContinuousProfilerTests.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ public ContinuousProfilerTests(ITestOutputHelper output)
1717
#if NET // allocator tests are only supported on .NET
1818
[Fact]
1919
[Trait("Category", "EndToEnd")]
20-
public void ExportAllocationSamples()
20+
public async Task ExportAllocationSamples()
2121
{
2222
EnableBytecodeInstrumentation();
23-
using var collector = new MockProfilesCollector(Output);
23+
using var collector = await MockProfilesCollector.InitializeAsync(Output);
2424
SetExporter(collector);
2525
SetEnvironmentVariable("OTEL_DOTNET_AUTO_PLUGINS", "TestApplication.ContinuousProfiler.AllocationPlugin, TestApplication.ContinuousProfiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null");
2626
SetEnvironmentVariable("OTEL_DOTNET_AUTO_TRACES_ADDITIONAL_SOURCES", "TestApplication.ContinuousProfiler");
@@ -37,10 +37,10 @@ public void ExportAllocationSamples()
3737
#if NETFRAMEWORK
3838
[Fact]
3939
[Trait("Category", "EndToEnd")]
40-
public void ExportAllocationSamples_NetFramework_NoSamplesCollected()
40+
public async Task ExportAllocationSamples_NetFramework_NoSamplesCollected()
4141
{
4242
EnableBytecodeInstrumentation();
43-
using var collector = new MockProfilesCollector(Output);
43+
using var collector = await MockProfilesCollector.InitializeAsync(Output);
4444
SetExporter(collector);
4545
SetEnvironmentVariable("OTEL_DOTNET_AUTO_PLUGINS", "TestApplication.ContinuousProfiler.AllocationPlugin, TestApplication.ContinuousProfiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null");
4646
SetEnvironmentVariable("OTEL_DOTNET_AUTO_TRACES_ADDITIONAL_SOURCES", "TestApplication.ContinuousProfiler");
@@ -52,10 +52,10 @@ public void ExportAllocationSamples_NetFramework_NoSamplesCollected()
5252

5353
[Fact]
5454
[Trait("Category", "EndToEnd")]
55-
public void ExportThreadSamples()
55+
public async Task ExportThreadSamples()
5656
{
5757
EnableBytecodeInstrumentation();
58-
using var collector = new MockProfilesCollector(Output);
58+
using var collector = await MockProfilesCollector.InitializeAsync(Output);
5959
SetExporter(collector);
6060
SetEnvironmentVariable("OTEL_DOTNET_AUTO_PLUGINS", "TestApplication.ContinuousProfiler.ThreadPlugin, TestApplication.ContinuousProfiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null");
6161
SetEnvironmentVariable("OTEL_DOTNET_AUTO_TRACES_ADDITIONAL_SOURCES", "TestApplication.ContinuousProfiler");

test/IntegrationTests/CustomSdkTests.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ public CustomSdkTests(ITestOutputHelper output, RedisFixture redis)
2323
[Fact]
2424
[Trait("Category", "EndToEnd")]
2525
[Trait("Containers", "Linux")]
26-
public void SubmitsTraces()
26+
public async Task SubmitsTraces()
2727
{
2828
using var testServer = TestHttpServer.CreateDefaultTestServer(Output);
29-
using var collector = new MockSpansCollector(Output);
29+
using var collector = await MockSpansCollector.InitializeAsync(Output);
3030
SetExporter(collector);
3131

3232
// ensure spans are exported by custom sdk with custom resource
@@ -54,10 +54,10 @@ public void SubmitsTraces()
5454
[Fact]
5555
[Trait("Category", "EndToEnd")]
5656
[Trait("Containers", "Linux")]
57-
public void SubmitsMetrics()
57+
public async Task SubmitsMetrics()
5858
{
5959
using var testServer = TestHttpServer.CreateDefaultTestServer(Output);
60-
using var collector = new MockMetricsCollector(Output);
60+
using var collector = await MockMetricsCollector.InitializeAsync(Output);
6161
SetExporter(collector);
6262

6363
// ensure metrics are exported by custom sdk with custom resource

test/IntegrationTests/DomainNeutralTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ public DomainNeutralTests(ITestOutputHelper output)
1616

1717
[Fact]
1818
[Trait("Category", "EndToEnd")]
19-
public void SubmitsTraces()
19+
public async Task SubmitsTraces()
2020
{
2121
Assert.True(EnvironmentTools.IsWindowsAdministrator(), "This test requires Windows Administrator privileges.");
2222

23-
using var collector = new MockSpansCollector(Output);
23+
using var collector = await MockSpansCollector.InitializeAsync(Output);
2424
SetExporter(collector);
2525
collector.Expect("ByteCode.Plugin.StrongNamedValidation");
2626

test/IntegrationTests/DotNetCliTests.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public void Dispose()
3636
}
3737

3838
[Fact]
39-
public void WorkFlow()
39+
public async Task WorkFlow()
4040
{
4141
using var testServer = TestHttpServer.CreateDefaultTestServer(Output);
4242
// Ensure no MS telemetry spans.
@@ -54,12 +54,12 @@ public void WorkFlow()
5454
RunDotNetCli("build");
5555

5656
var targetAppDllPath = Path.Combine(".", "bin", "Debug", tfm, TargetAppName + ".dll");
57-
RunAppWithDotNetCliAndAssertHttpSpans(targetAppDllPath);
57+
await RunAppWithDotNetCliAndAssertHttpSpans(targetAppDllPath);
5858

5959
// Not necessary, but, testing a common command.
6060
RunDotNetCli("clean");
6161

62-
RunAppWithDotNetCliAndAssertHttpSpans("run -c Release");
62+
await RunAppWithDotNetCliAndAssertHttpSpans("run -c Release");
6363
}
6464

6565
private static void ChangeDefaultProgramToHttpClient(int testServerPort)
@@ -105,9 +105,9 @@ private void RunDotNetCli(string arguments)
105105
Assert.Equal(0, process.ExitCode);
106106
}
107107

108-
private void RunAppWithDotNetCliAndAssertHttpSpans(string arguments)
108+
private async Task RunAppWithDotNetCliAndAssertHttpSpans(string arguments)
109109
{
110-
using var collector = new MockSpansCollector(Output);
110+
using var collector = await MockSpansCollector.InitializeAsync(Output);
111111
SetExporter(collector);
112112

113113
collector.Expect("System.Net.Http");

test/IntegrationTests/ElasticsearchTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ public ElasticsearchTests(ITestOutputHelper output)
1616
[Theory]
1717
[Trait("Category", "EndToEnd")]
1818
[MemberData(nameof(LibraryVersion.Elasticsearch), MemberType = typeof(LibraryVersion))]
19-
public void SubmitsTraces(string packageVersion)
19+
public async Task SubmitsTraces(string packageVersion)
2020
{
21-
using var collector = new MockSpansCollector(Output);
21+
using var collector = await MockSpansCollector.InitializeAsync(Output);
2222
SetExporter(collector);
2323

2424
if (string.IsNullOrEmpty(packageVersion) || new Version(packageVersion).CompareTo(new Version(8, 10, 0)) >= 0)

test/IntegrationTests/EntityFrameworkCorePomeloMySqlTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ public EntityFrameworkCorePomeloMySqlTests(ITestOutputHelper output, MySqlFixtur
2323
[Trait("Category", "EndToEnd")]
2424
[Trait("Containers", "Linux")]
2525
[MemberData(nameof(LibraryVersion.EntityFrameworkCorePomeloMySql), MemberType = typeof(LibraryVersion))]
26-
public void SubmitsTraces(string packageVersion)
26+
public async Task SubmitsTraces(string packageVersion)
2727
{
28-
using var collector = new MockSpansCollector(Output);
28+
using var collector = await MockSpansCollector.InitializeAsync(Output);
2929
SetExporter(collector);
3030
collector.Expect("OpenTelemetry.Instrumentation.EntityFrameworkCore");
3131

0 commit comments

Comments
 (0)