Skip to content

Commit

Permalink
Disable tests not intended to run on MacOS (#5772)
Browse files Browse the repository at this point in the history
Co-authored-by: Evgenii Fedorov <[email protected]>
  • Loading branch information
evgenyfedorov2 and Evgenii Fedorov authored Jan 6, 2025
1 parent 20c12ef commit dbb12c3
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 33 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -314,3 +314,4 @@ BenchmarkDotNet.artifacts/

*.binlog
/eng/scripts/repo-digest.html
**/.DS_Store
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" />
<PackageReference Include="System.Threading.Tasks.Extensions" Condition="'$(TargetFramework)' == 'net462'" />
<PackageReference Include="Microsoft.Bcl.HashCode" Condition="!$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net6.0'))" />
<PackageReference Include="System.Diagnostics.PerformanceCounter" Condition="'$(TargetFramework)' != 'net462'" />
<PackageReference Include="System.Collections.Immutable" Condition="!$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net8.0'))" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

<ItemGroup>
<ProjectReference Include="..\..\..\src\Libraries\Microsoft.Extensions.Diagnostics.HealthChecks.ResourceUtilization\Microsoft.Extensions.Diagnostics.HealthChecks.ResourceUtilization.csproj" ProjectUnderTest="true" />
<ProjectReference Include="..\..\TestUtilities\TestUtilities.csproj" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,16 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Diagnostics.ResourceMonitoring;
using Microsoft.Extensions.Options;
using Microsoft.TestUtilities;
using Moq;
using Xunit;

namespace Microsoft.Extensions.Diagnostics.HealthChecks.Test;

[OSSkipCondition(OperatingSystems.MacOSX, SkipReason = "Not supported on MacOs.")]
public class ResourceHealthCheckExtensionsTests
{
[Fact]
[ConditionalFact]
public async Task AddResourceHealthCheck()
{
var dataTracker = new Mock<IResourceMonitor>();
Expand All @@ -35,7 +37,7 @@ public async Task AddResourceHealthCheck()
dataTracker.Verify(tracker => tracker.GetUtilization(samplingWindow), Times.Once);
}

[Fact]
[ConditionalFact]
public async Task AddResourceHealthCheck_WithCustomResourceMonitorAddedAfterInternalResourceMonitor_OverridesIt()
{
var dataTracker = new Mock<IResourceMonitor>();
Expand All @@ -55,7 +57,7 @@ public async Task AddResourceHealthCheck_WithCustomResourceMonitorAddedAfterInte
dataTracker.Verify(tracker => tracker.GetUtilization(samplingWindow), Times.Once);
}

[Fact]
[ConditionalFact]
public void AddResourceHealthCheck_RegistersInternalResourceMonitoring()
{
var dataTracker = new Mock<IResourceMonitor>();
Expand All @@ -75,7 +77,7 @@ public void AddResourceHealthCheck_RegistersInternalResourceMonitoring()
Assert.NotNull(resourceMonitor);
}

[Fact]
[ConditionalFact]
public async Task AddResourceHealthCheck_WithTags()
{
var dataTracker = new Mock<IResourceMonitor>();
Expand All @@ -95,7 +97,7 @@ public async Task AddResourceHealthCheck_WithTags()
dataTracker.Verify(tracker => tracker.GetUtilization(samplingWindow), Times.Once);
}

[Fact]
[ConditionalFact]
public void AddResourceHealthCheck_WithTags_RegistersInternalResourceMonitoring()
{
var serviceCollection = new ServiceCollection();
Expand All @@ -110,7 +112,7 @@ public void AddResourceHealthCheck_WithTags_RegistersInternalResourceMonitoring(
Assert.NotNull(resourceMonitor);
}

[Fact]
[ConditionalFact]
public async Task AddResourceHealthCheck_WithTags_WithCustomResourceMonitorAddedAfterInternalResourceMonitor_OverridesIt()
{
var dataTracker = new Mock<IResourceMonitor>();
Expand All @@ -130,7 +132,7 @@ public async Task AddResourceHealthCheck_WithTags_WithCustomResourceMonitorAdded
dataTracker.Verify(tracker => tracker.GetUtilization(samplingWindow), Times.Once);
}

[Fact]
[ConditionalFact]
public async Task AddResourceHealthCheck_WithTagsEnumerable()
{
var dataTracker = new Mock<IResourceMonitor>();
Expand All @@ -150,7 +152,7 @@ public async Task AddResourceHealthCheck_WithTagsEnumerable()
dataTracker.Verify(tracker => tracker.GetUtilization(samplingWindow), Times.Once);
}

[Fact]
[ConditionalFact]
public void AddResourceHealthCheck_WithTagsEnumerable_RegistersInternalResourceMonitoring()
{
var serviceCollection = new ServiceCollection();
Expand All @@ -165,7 +167,7 @@ public void AddResourceHealthCheck_WithTagsEnumerable_RegistersInternalResourceM
Assert.NotNull(resourceMonitor);
}

[Fact]
[ConditionalFact]
public async Task AddResourceHealthCheck_WithAction()
{
var dataTracker = new Mock<IResourceMonitor>();
Expand All @@ -188,7 +190,7 @@ public async Task AddResourceHealthCheck_WithAction()
dataTracker.Verify(tracker => tracker.GetUtilization(samplingWindow), Times.Once);
}

[Fact]
[ConditionalFact]
public void AddResourceHealthCheck_WithAction_RegistersInternalResourceMonitoring()
{
var serviceCollection = new ServiceCollection();
Expand All @@ -206,7 +208,7 @@ public void AddResourceHealthCheck_WithAction_RegistersInternalResourceMonitorin
Assert.NotNull(resourceMonitor);
}

[Fact]
[ConditionalFact]
public async Task AddResourceHealthCheck_WithActionAndTags()
{
var dataTracker = new Mock<IResourceMonitor>();
Expand All @@ -230,7 +232,7 @@ public async Task AddResourceHealthCheck_WithActionAndTags()
dataTracker.Verify(tracker => tracker.GetUtilization(samplingWindow), Times.Once);
}

[Fact]
[ConditionalFact]
public void AddResourceHealthCheck_WithActionAndTags_RegistersInternalResourceMonitoring()
{
var serviceCollection = new ServiceCollection();
Expand All @@ -249,7 +251,7 @@ public void AddResourceHealthCheck_WithActionAndTags_RegistersInternalResourceMo
Assert.NotNull(resourceMonitor);
}

[Fact]
[ConditionalFact]
public async Task AddResourceHealthCheck_WithActionAndTagsEnumerable()
{
var dataTracker = new Mock<IResourceMonitor>();
Expand All @@ -273,7 +275,7 @@ public async Task AddResourceHealthCheck_WithActionAndTagsEnumerable()
dataTracker.Verify(tracker => tracker.GetUtilization(samplingWindow), Times.Once);
}

[Fact]
[ConditionalFact]
public void AddResourceHealthCheck_WithActionAndTagsEnumerable_RegistersInternalResourceMonitoring()
{
var serviceCollection = new ServiceCollection();
Expand All @@ -292,7 +294,7 @@ public void AddResourceHealthCheck_WithActionAndTagsEnumerable_RegistersInternal
Assert.NotNull(resourceMonitor);
}

[Fact]
[ConditionalFact]
public async Task AddResourceHealthCheck_WithConfigurationSection()
{
var dataTracker = new Mock<IResourceMonitor>();
Expand All @@ -311,7 +313,7 @@ public async Task AddResourceHealthCheck_WithConfigurationSection()
dataTracker.Verify(tracker => tracker.GetUtilization(samplingWindow), Times.Once);
}

[Fact]
[ConditionalFact]
public void AddResourceHealthCheck_WithConfigurationSection_RegistersInternalResourceMonitoring()
{
var serviceCollection = new ServiceCollection();
Expand All @@ -326,7 +328,7 @@ public void AddResourceHealthCheck_WithConfigurationSection_RegistersInternalRes
Assert.NotNull(resourceMonitor);
}

[Fact]
[ConditionalFact]
public async Task AddResourceHealthCheck_WithConfigurationSectionAndTags()
{
var dataTracker = new Mock<IResourceMonitor>();
Expand All @@ -347,7 +349,7 @@ public async Task AddResourceHealthCheck_WithConfigurationSectionAndTags()
dataTracker.Verify(tracker => tracker.GetUtilization(samplingWindow), Times.Once);
}

[Fact]
[ConditionalFact]
public void AddResourceHealthCheck_WithConfigurationSectionAndTags_RegistersInternalResourceMonitoring()
{
var serviceCollection = new ServiceCollection();
Expand All @@ -363,7 +365,7 @@ public void AddResourceHealthCheck_WithConfigurationSectionAndTags_RegistersInte
Assert.NotNull(resourceMonitor);
}

[Fact]
[ConditionalFact]
public async Task AddResourceHealthCheck_WithConfigurationSectionAndTagsEnumerable()
{
var dataTracker = new Mock<IResourceMonitor>();
Expand All @@ -384,7 +386,7 @@ public async Task AddResourceHealthCheck_WithConfigurationSectionAndTagsEnumerab
dataTracker.Verify(tracker => tracker.GetUtilization(samplingWindow), Times.Once);
}

[Fact]
[ConditionalFact]
public void AddResourceHealthCheck_WithConfigurationSectionAndTagsEnumerable_RegistersInternalResourceMonitoring()
{
var serviceCollection = new ServiceCollection();
Expand All @@ -401,7 +403,7 @@ public void AddResourceHealthCheck_WithConfigurationSectionAndTagsEnumerable_Reg
Assert.NotNull(resourceMonitor);
}

[Fact]
[ConditionalFact]
public void ConfigureResourceUtilizationHealthCheck_WithAction()
{
TimeSpan samplingWindow = TimeSpan.FromSeconds(1);
Expand All @@ -423,7 +425,7 @@ public void ConfigureResourceUtilizationHealthCheck_WithAction()
Assert.Equal(0.4, options.CpuThresholds.UnhealthyUtilizationPercentage);
}

[Fact]
[ConditionalFact]
public void ConfigureResourceUtilizationHealthCheck_WithConfigurationSection()
{
TimeSpan samplingWindow = TimeSpan.FromSeconds(5);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@
using System.Linq;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Diagnostics.ResourceMonitoring.Test.Publishers;
using Microsoft.TestUtilities;
using Xunit;

namespace Microsoft.Extensions.Diagnostics.ResourceMonitoring.Test;

[OSSkipCondition(OperatingSystems.MacOSX, SkipReason = "Not supported on MacOs.")]
public sealed class ResourceMonitoringBuilderTests
{
[Fact]
[ConditionalFact(Skip = "Not supported on MacOs.")]
public void AddPublisher_CalledOnce_AddsSinglePublisherToServiceCollection()
{
using var provider = new ServiceCollection()
Expand All @@ -31,7 +33,7 @@ public void AddPublisher_CalledOnce_AddsSinglePublisherToServiceCollection()
Assert.IsAssignableFrom<EmptyPublisher>(publishersArray.First());
}

[Fact]
[ConditionalFact]
public void AddPublisher_CalledMultipleTimes_AddsMultiplePublishersToServiceCollection()
{
using var provider = new ServiceCollection()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Hosting.Testing;
using Microsoft.Extensions.Options;
using Microsoft.TestUtilities;
using Xunit;

namespace Microsoft.Extensions.Diagnostics.ResourceMonitoring.Test;

[OSSkipCondition(OperatingSystems.MacOSX, SkipReason = "Not supported on MacOs.")]
public sealed class ResourceMonitoringExtensionsTests
{
[Fact]
[ConditionalFact]
public void Throw_Null_When_Registration_Ingredients_Null()
{
var services = new ServiceCollection();
Expand All @@ -28,7 +30,7 @@ public void Throw_Null_When_Registration_Ingredients_Null()
Assert.Throws<ArgumentNullException>(() => services.AddResourceMonitoring((b) => b.ConfigureMonitor((Action<ResourceMonitoringOptions>)null!)));
}

[Fact]
[ConditionalFact]
public void AddResourceUtilization_AddsResourceMonitoringService_ToServicesCollection()
{
using var provider = new ServiceCollection()
Expand All @@ -48,7 +50,7 @@ public void AddResourceUtilization_AddsResourceMonitoringService_ToServicesColle
Assert.IsAssignableFrom<IResourceMonitor>(trackerService);
}

[Fact]
[ConditionalFact]
public void AddResourceUtilization_AddsResourceMonitoringService_ToServicesCollection_NoArgs()
{
using var provider = new ServiceCollection()
Expand All @@ -64,7 +66,7 @@ public void AddResourceUtilization_AddsResourceMonitoringService_ToServicesColle
Assert.IsAssignableFrom<IResourceMonitor>(trackerService);
}

[Fact]
[ConditionalFact]
public void AddResourceUtilization_AddsResourceMonitoringService_AsHostedService()
{
using var provider = new ServiceCollection()
Expand All @@ -85,7 +87,7 @@ public void AddResourceUtilization_AddsResourceMonitoringService_AsHostedService
Assert.IsAssignableFrom<IResourceMonitor>(trackerService);
}

[Fact]
[ConditionalFact]
public void ConfigureResourceUtilization_InitializeTrackerProperly()
{
using var host = FakeHost.CreateBuilder()
Expand All @@ -111,7 +113,7 @@ public void ConfigureResourceUtilization_InitializeTrackerProperly()
Assert.NotNull(publisher);
}

[Fact]
[ConditionalFact]
public void ConfigureTracker_GivenOptionsDelegate_InitializeTrackerWithOptionsProperly()
{
const int SamplingWindowValue = 3;
Expand Down Expand Up @@ -139,7 +141,7 @@ public void ConfigureTracker_GivenOptionsDelegate_InitializeTrackerWithOptionsPr
Assert.Equal(TimeSpan.FromSeconds(CalculationPeriodValue), options!.Value.PublishingWindow);
}

[Fact]
[ConditionalFact]
public void ConfigureTracker_GivenIConfigurationSection_InitializeTrackerWithOptionsProperly()
{
const int SamplingWindowValue = 3;
Expand Down Expand Up @@ -180,7 +182,7 @@ public void ConfigureTracker_GivenIConfigurationSection_InitializeTrackerWithOpt
Assert.Equal(TimeSpan.FromSeconds(CalculationPeriod), options!.Value.PublishingWindow);
}

[Fact]
[ConditionalFact]
public void Registering_Resource_Utilization_Adds_Only_One_Object_Of_Type_ResourceUtilizationService_To_DI_Container()
{
using var host = FakeHost.CreateBuilder()
Expand Down

0 comments on commit dbb12c3

Please sign in to comment.