Skip to content

Commit e1bae97

Browse files
[W3C] Refactor W3C integration tests
Improve developer experience when troubleshooting failing tests (like I was in open-telemetry#6307) by logging both stderr and stdout and ignoring warnings in the upstream Python tests.
1 parent 3f86f47 commit e1bae97

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

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

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ public void W3CTraceContextTestSuiteAsync(string value)
3737
{
3838
// configure SDK
3939
using var tracerProvider = Sdk.CreateTracerProviderBuilder()
40-
.AddAspNetCoreInstrumentation()
41-
.Build();
40+
.AddAspNetCoreInstrumentation()
41+
.Build();
4242

4343
var builder = WebApplication.CreateBuilder();
4444
using var app = builder.Build();
@@ -68,12 +68,14 @@ public void W3CTraceContextTestSuiteAsync(string value)
6868

6969
app.RunAsync("http://localhost:5000/");
7070

71-
string result = RunCommand("python", "trace-context/test/test.py http://localhost:5000/");
71+
(var stdout, var stderr) = RunCommand("python", "-W ignore trace-context/test/test.py http://localhost:5000/");
7272

7373
// Assert
74-
string lastLine = ParseLastLine(result);
74+
// TODO: after W3C Trace Context test suite passes, it might go in standard output
75+
string lastLine = ParseLastLine(stderr);
7576

76-
this.output.WriteLine("result:" + result);
77+
this.output.WriteLine("[stderr]" + stderr);
78+
this.output.WriteLine("[stdout]" + stdout);
7779

7880
// Assert on the last line
7981
Assert.StartsWith("OK", lastLine, StringComparison.Ordinal);
@@ -84,7 +86,7 @@ public void Dispose()
8486
this.httpClient.Dispose();
8587
}
8688

87-
private static string RunCommand(string command, string args)
89+
private static (string StdOut, string StdErr) RunCommand(string command, string args)
8890
{
8991
using var proc = new Process
9092
{
@@ -101,10 +103,12 @@ private static string RunCommand(string command, string args)
101103
};
102104
proc.Start();
103105

104-
// TODO: after W3C Trace Context test suite passes, it might go in standard output
105-
var results = proc.StandardError.ReadToEnd();
106+
var stdout = proc.StandardOutput.ReadToEnd();
107+
var stderr = proc.StandardError.ReadToEnd();
108+
106109
proc.WaitForExit();
107-
return results;
110+
111+
return (stdout, stderr);
108112
}
109113

110114
private static string ParseLastLine(string output)

0 commit comments

Comments
 (0)