Skip to content

Commit 3a09a91

Browse files
KielekCodeBlanch
andauthored
Cleanup W3CTraceContextTests (open-telemetry#5858)
Co-authored-by: Mikel Blanchard <[email protected]>
1 parent 12a8ab0 commit 3a09a91

File tree

1 file changed

+9
-24
lines changed

1 file changed

+9
-24
lines changed

test/OpenTelemetry.Instrumentation.W3cTraceContext.Tests/W3CTraceContextTests.cs

Lines changed: 9 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ public class W3CTraceContextTests : IDisposable
2020
To run the tests, invoke docker-compose.yml from the root of the repo:
2121
opentelemetry>docker compose --file=test/OpenTelemetry.Instrumentation.W3cTraceContext.Tests/docker-compose.yml --project-directory=. up --exit-code-from=tests --build
2222
*/
23-
private const string W3cTraceContextEnvVarName = "OTEL_W3CTRACECONTEXT";
24-
private static readonly Version? AspNetCoreHostingVersion = typeof(Microsoft.AspNetCore.Hosting.Builder.IApplicationBuilderFactory).Assembly.GetName().Version;
23+
private const string W3CTraceContextEnvVarName = "OTEL_W3CTRACECONTEXT";
2524
private readonly HttpClient httpClient = new();
2625
private readonly ITestOutputHelper output;
2726

@@ -31,13 +30,13 @@ public W3CTraceContextTests(ITestOutputHelper output)
3130
}
3231

3332
[Trait("CategoryName", "W3CTraceContextTests")]
34-
[SkipUnlessEnvVarFoundTheory(W3cTraceContextEnvVarName)]
33+
[SkipUnlessEnvVarFoundTheory(W3CTraceContextEnvVarName)]
3534
[InlineData("placeholder")]
3635
[System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "xUnit1026:Theory methods should use all of their parameters", Justification = "Need to use SkipUnlessEnvVarFoundTheory")]
3736
public void W3CTraceContextTestSuiteAsync(string value)
3837
{
3938
// configure SDK
40-
using var tracerprovider = Sdk.CreateTracerProviderBuilder()
39+
using var tracerProvider = Sdk.CreateTracerProviderBuilder()
4140
.AddAspNetCoreInstrumentation()
4241
.Build();
4342

@@ -51,13 +50,11 @@ public void W3CTraceContextTestSuiteAsync(string value)
5150
{
5251
foreach (var argument in data)
5352
{
54-
using var request = new HttpRequestMessage(HttpMethod.Post, argument.Url)
55-
{
56-
Content = new StringContent(
57-
JsonSerializer.Serialize(argument.Arguments),
58-
Encoding.UTF8,
59-
"application/json"),
60-
};
53+
using var request = new HttpRequestMessage(HttpMethod.Post, argument.Url);
54+
request.Content = new StringContent(
55+
JsonSerializer.Serialize(argument.Arguments),
56+
Encoding.UTF8,
57+
"application/json");
6158
await this.httpClient.SendAsync(request);
6259
}
6360
}
@@ -79,19 +76,7 @@ public void W3CTraceContextTestSuiteAsync(string value)
7976
this.output.WriteLine("result:" + result);
8077

8178
// Assert on the last line
82-
83-
// TODO: Investigate failures on .NET6 vs .NET7. To see the details
84-
// run the tests with console logger (done automatically by the CI
85-
// jobs).
86-
87-
if (AspNetCoreHostingVersion!.Major <= 6)
88-
{
89-
Assert.StartsWith("FAILED (failures=3)", lastLine);
90-
}
91-
else
92-
{
93-
Assert.StartsWith("OK", lastLine);
94-
}
79+
Assert.StartsWith("OK", lastLine);
9580
}
9681

9782
public void Dispose()

0 commit comments

Comments
 (0)