Skip to content

Commit c9c069d

Browse files
[Infra] Review skipped tests (#3177)
1 parent 3dff163 commit c9c069d

File tree

6 files changed

+36
-21
lines changed

6 files changed

+36
-21
lines changed

test/OpenTelemetry.Exporter.Geneva.Tests/UnixUserEventsDataTransportTests.cs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public UnixUserEventsDataTransportTests(ITestOutputHelper testOutputHelper)
4949
this.testOutputHelper = testOutputHelper;
5050
}
5151

52-
[Fact(Skip = "This would fail on Ubuntu. Skipping for now. See issue: #2326.")]
52+
[SkipUnlessPlatformMatchesFact(TestPlatform.Linux, requireElevatedProcess: true, Skip = "https://github.com/open-telemetry/opentelemetry-dotnet-contrib/issues/2326")]
5353
public void UserEvents_Enabled_Success_Linux()
5454
{
5555
EnsureUserEventsEnabled();
@@ -78,9 +78,7 @@ public void UserEvents_Enabled_Success_Linux()
7878
this.testOutputHelper.WriteLine(string.Join(", ", e.Select(kvp => $"{kvp.Key}={kvp.Value}")));
7979
}
8080

81-
Assert.Single(listener.Events);
82-
83-
var @event = listener.Events[0];
81+
var @event = Assert.Single(listener.Events);
8482

8583
Assert.EndsWith($" ({MetricUnixUserEventsDataTransport.MetricsProtocol})", @event["protocol"]);
8684
Assert.Equal(MetricUnixUserEventsDataTransport.MetricsVersion, @event["version"]);
@@ -113,7 +111,7 @@ public void UserEvents_Enabled_Success_Linux()
113111
}
114112
}
115113

116-
[Fact(Skip = "This would fail on Ubuntu. Skipping for now. See issue: #2326.")]
114+
[SkipUnlessPlatformMatchesFact(TestPlatform.Linux, requireElevatedProcess: true, Skip = "https://github.com/open-telemetry/opentelemetry-dotnet-contrib/issues/2326")]
117115
public void UserEvents_Disabled_Success_Linux()
118116
{
119117
EnsureUserEventsEnabled();
@@ -143,7 +141,7 @@ public void UserEvents_Disabled_Success_Linux()
143141
}
144142
}
145143

146-
[Fact(Skip = "This would fail on Ubuntu. Skipping for now. See issue: #2326.")]
144+
[SkipUnlessPlatformMatchesFact(TestPlatform.Linux, requireElevatedProcess: true, Skip = "https://github.com/open-telemetry/opentelemetry-dotnet-contrib/issues/2326")]
147145
public void UserEvents_Logs_Success_Linux()
148146
{
149147
var listener = new PerfTracepointListener(

test/OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule.Tests/ActivityHelperTest.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public async Task Can_Restore_Activity()
8383
await testTask;
8484
}
8585

86-
[Fact(Skip = "Temporarily disable until stable.")]
86+
[Fact(Skip = "https://github.com/open-telemetry/opentelemetry-dotnet-contrib/issues/3302")]
8787
public async Task Can_Restore_Baggage()
8888
{
8989
this.EnableListener();
@@ -94,8 +94,9 @@ public async Task Can_Restore_Baggage()
9494
};
9595

9696
var context = HttpContextHelper.GetFakeHttpContextBase(headers: requestHeaders);
97-
using var rootActivity = ActivityHelper.StartAspNetActivity(new CompositeTextMapPropagator([new TraceContextPropagator(), new BaggagePropagator()]), context, null)!;
97+
using var rootActivity = ActivityHelper.StartAspNetActivity(new CompositeTextMapPropagator([new TraceContextPropagator(), new BaggagePropagator()]), context, null);
9898

99+
Assert.NotNull(rootActivity);
99100
rootActivity.AddTag("k1", "v1");
100101
rootActivity.AddTag("k2", "v2");
101102

test/OpenTelemetry.Instrumentation.EventCounters.Tests/EventCountersMetricsTests.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ namespace OpenTelemetry.Instrumentation.EventCounters.Tests;
99

1010
public class EventCountersMetricsTests
1111
{
12-
[Fact(Skip = "Unstable")]
12+
[Fact]
1313
public void EventCounter()
1414
{
1515
// Arrange
@@ -35,7 +35,7 @@ public void EventCounter()
3535
Assert.Equal(1997.0202, GetActualValue(metric));
3636
}
3737

38-
[Fact(Skip = "Unstable")]
38+
[Fact]
3939
public void IncrementingEventCounter()
4040
{
4141
// Arrange
@@ -63,7 +63,7 @@ public void IncrementingEventCounter()
6363
Assert.Equal(3, GetActualValue(metric));
6464
}
6565

66-
[Fact(Skip = "Unstable")]
66+
[Fact]
6767
public void PollingCounter()
6868
{
6969
// Arrange
@@ -89,7 +89,7 @@ public void PollingCounter()
8989
Assert.Equal(10, GetActualValue(metric));
9090
}
9191

92-
[Fact(Skip = "Unstable")]
92+
[Fact]
9393
public void IncrementingPollingCounter()
9494
{
9595
// Arrange
@@ -163,7 +163,7 @@ public void EventSourceNameShortening(string sourceName, string eventName, strin
163163
Assert.Equal(1, GetActualValue(metric));
164164
}
165165

166-
[Fact(Skip = "This test should properly validate no metrics are exported from event counters with invalid names (too long)")]
166+
[Fact]
167167
public async Task InstrumentNameTooLong()
168168
{
169169
// Arrange

test/OpenTelemetry.PersistentStorage.FileSystem.Tests/FileBlobTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ public void FileBlobTests_Delete()
114114
Assert.False(testFile.Exists);
115115
}
116116

117-
[Fact(Skip = "Unstable")]
117+
[Fact]
118118
public void FileBlobTests_DeleteFailsAfterLeaseIsExpired()
119119
{
120120
var testDirectory = new DirectoryInfo(Path.Combine(Path.GetTempPath(), Path.GetRandomFileName()));
@@ -143,7 +143,7 @@ public void FileBlobTests_DeleteFailsAfterLeaseIsExpired()
143143
testDirectory.Delete(true);
144144
}
145145

146-
[Fact(Skip = "Unstable")]
146+
[Fact]
147147
public void FileBlobTests_LeaseTimeIsUpdatedWhenLeasingAlreadyLeasedFile()
148148
{
149149
var testFile = new FileInfo(Path.Combine(Path.GetTempPath(), Path.GetRandomFileName()));

test/OpenTelemetry.Sampler.AWS.Tests/TestAWSXRayRemoteSampler.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,11 @@ public void TestSamplerWithDefaults()
4949
Assert.NotNull(xraySampler?.Client);
5050
}
5151

52-
[Fact(Skip = "Flaky test. Related issue: https://github.com/open-telemetry/opentelemetry-dotnet-contrib/issues/1219")]
52+
#if NETFRAMEWORK
53+
[Fact(Skip = "https://github.com/open-telemetry/opentelemetry-dotnet-contrib/issues/1219")]
54+
#else
55+
[Fact]
56+
#endif
5357
public void TestSamplerUpdateAndSample()
5458
{
5559
// setup mock server

test/Shared/PlatformHelpers.cs

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#pragma warning disable SA1402 // File may only contain a single type
66

77
using System.Runtime.InteropServices;
8+
using System.Security.Principal;
89
using Xunit;
910

1011
namespace OpenTelemetry.Tests;
@@ -21,14 +22,25 @@ internal sealed class TestPlatformHelpers
2122
{
2223
public static bool IsProcessElevated(TestPlatform platform)
2324
{
24-
if (platform != TestPlatform.Linux)
25+
switch (platform)
2526
{
27+
case TestPlatform.Linux:
28+
var userId = SystemNativeUnix.GetEUid();
29+
return userId == 0;
30+
31+
case TestPlatform.Windows:
32+
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
33+
{
34+
using var identity = WindowsIdentity.GetCurrent();
35+
return new WindowsPrincipal(identity).IsInRole(WindowsBuiltInRole.Administrator);
36+
}
37+
38+
return false;
39+
2640
// TODO: Add support for this check on other platforms as needed.
27-
throw new NotImplementedException();
41+
default:
42+
throw new NotSupportedException($"TestPlatform '{platform}' is not supported for elevation check.");
2843
}
29-
30-
var userId = SystemNativeUnix.GetEUid();
31-
return userId == 0;
3244
}
3345

3446
// From: https://github.com/dotnet/corefx/blob/v2.2.8/src/Common/src/Interop/Unix/System.Native/Interop.GetEUid.cs

0 commit comments

Comments
 (0)