Skip to content

Commit

Permalink
[WIP] fix build warnings (#540)
Browse files Browse the repository at this point in the history
* Bump AkkaVersion from 1.5.32 to 1.5.33

Bumps `AkkaVersion` from 1.5.32 to 1.5.33.

Updates `Akka.Cluster.Sharding` from 1.5.32 to 1.5.33
- [Release notes](https://github.com/akkadotnet/akka.net/releases)
- [Changelog](https://github.com/akkadotnet/akka.net/blob/dev/RELEASE_NOTES.md)
- [Commits](akkadotnet/akka.net@1.5.32...1.5.33)

Updates `Akka.DependencyInjection` from 1.5.32 to 1.5.33
- [Release notes](https://github.com/akkadotnet/akka.net/releases)
- [Changelog](https://github.com/akkadotnet/akka.net/blob/dev/RELEASE_NOTES.md)
- [Commits](akkadotnet/akka.net@1.5.32...1.5.33)

Updates `Akka.DistributedData` from 1.5.32 to 1.5.33
- [Release notes](https://github.com/akkadotnet/akka.net/releases)
- [Changelog](https://github.com/akkadotnet/akka.net/blob/dev/RELEASE_NOTES.md)
- [Commits](akkadotnet/akka.net@1.5.32...1.5.33)

Updates `Akka.Persistence` from 1.5.32 to 1.5.33
- [Release notes](https://github.com/akkadotnet/akka.net/releases)
- [Changelog](https://github.com/akkadotnet/akka.net/blob/dev/RELEASE_NOTES.md)
- [Commits](akkadotnet/akka.net@1.5.32...1.5.33)

Updates `Akka.Remote` from 1.5.32 to 1.5.33
- [Release notes](https://github.com/akkadotnet/akka.net/releases)
- [Changelog](https://github.com/akkadotnet/akka.net/blob/dev/RELEASE_NOTES.md)
- [Commits](akkadotnet/akka.net@1.5.32...1.5.33)

Updates `Akka.Streams` from 1.5.32 to 1.5.33
- [Release notes](https://github.com/akkadotnet/akka.net/releases)
- [Changelog](https://github.com/akkadotnet/akka.net/blob/dev/RELEASE_NOTES.md)
- [Commits](akkadotnet/akka.net@1.5.32...1.5.33)

Updates `Akka.TestKit.Xunit2` from 1.5.32 to 1.5.33
- [Release notes](https://github.com/akkadotnet/akka.net/releases)
- [Changelog](https://github.com/akkadotnet/akka.net/blob/dev/RELEASE_NOTES.md)
- [Commits](akkadotnet/akka.net@1.5.32...1.5.33)

Updates `FluentAssertions` from 6.12.2 to 5.10.3
- [Release notes](https://github.com/fluentassertions/fluentassertions/releases)
- [Changelog](https://github.com/fluentassertions/fluentassertions/blob/develop/AcceptApiChanges.ps1)
- [Commits](fluentassertions/fluentassertions@6.12.2...5.10.3)

Updates `Microsoft.Bcl.AsyncInterfaces` from 7.0.0 to 6.0.0
- [Release notes](https://github.com/dotnet/runtime/releases)
- [Commits](dotnet/runtime@v7.0.0...v6.0.0)

---
updated-dependencies:
- dependency-name: Akka.Cluster.Sharding
  dependency-type: direct:production
  update-type: version-update:semver-patch
- dependency-name: Akka.DependencyInjection
  dependency-type: direct:production
  update-type: version-update:semver-patch
- dependency-name: Akka.DistributedData
  dependency-type: direct:production
  update-type: version-update:semver-patch
- dependency-name: Akka.Persistence
  dependency-type: direct:production
  update-type: version-update:semver-patch
- dependency-name: Akka.Remote
  dependency-type: direct:production
  update-type: version-update:semver-patch
- dependency-name: Akka.Streams
  dependency-type: direct:production
  update-type: version-update:semver-patch
- dependency-name: Akka.TestKit.Xunit2
  dependency-type: direct:production
  update-type: version-update:semver-patch
- dependency-name: FluentAssertions
  dependency-type: direct:production
  update-type: version-update:semver-major
- dependency-name: Microsoft.Bcl.AsyncInterfaces
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

* Resolve xUnit build warnings

* fix Akka.NET and xUnit warnings

* suppress `XunitLogger` error spam when no active test

* approve API changes

* harden `ClusterSingletonSpecs`

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
  • Loading branch information
Aaronontheweb and dependabot[bot] authored Dec 24, 2024
1 parent 7c15105 commit a8de727
Show file tree
Hide file tree
Showing 11 changed files with 63 additions and 43 deletions.
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<TestSdkVersion>17.11.1</TestSdkVersion>
<CoverletVersion>6.0.2</CoverletVersion>
<XunitRunneVisualstudio>2.8.1</XunitRunneVisualstudio>
<AkkaVersion>1.5.32</AkkaVersion>
<AkkaVersion>1.5.33</AkkaVersion>
<MicrosoftExtensionsVersion>[6.0.0,)</MicrosoftExtensionsVersion>
<SystemTextJsonVersion>[6.0.10,)</SystemTextJsonVersion>
</PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/Akka.Cluster.Hosting.Tests/ClusterShardingSpecs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ private static ClusterShardingSettings ToSettings(ShardOptions shardOptions)
{
var defaultConfig = ClusterSharding.DefaultConfig()
.WithFallback(DistributedData.DistributedData.DefaultConfig())
.WithFallback(ClusterSingletonManager.DefaultConfig());
.WithFallback(ClusterSingleton.DefaultConfig());

var shardingConfig = ConfigurationFactory.ParseString(shardOptions.ToString())
.WithFallback(defaultConfig.GetConfig("akka.cluster.sharding"));
Expand Down
49 changes: 29 additions & 20 deletions src/Akka.Cluster.Hosting.Tests/ClusterSingletonSpecs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,17 +75,38 @@ public async Task ClusterSingletonAndProxyWithNoManagerNameTest()
var expectedSingletonPath = new RootActorPath(address) / "user" / "my-singleton" / "my-singleton";
var singletonSelector = system.ActorSelection(expectedSingletonPath);

await Awaiting(async () =>
{
var identify = await singletonSelector.ResolveOne(3.Seconds());
identify.Should().NotBe(ActorRefs.Nobody);
}).Should().NotThrowAsync();
await AssertSingletonSelectionAsync(singletonSelector);

singletonProxy.Path.ToString().Should().Be("akka://TestSys/user/my-singleton-proxy");

await host.StopAsync();
}

private static async Task AssertSingletonSelectionAsync(ActorSelection singletonSelector)
{
var startTime = DateTime.UtcNow;
var timeout = TimeSpan.FromSeconds(3);
await Awaiting(async () =>
{
// might take multiple tries to resolve the singleton if it hasn't been created yet
while (DateTime.UtcNow - startTime < timeout)
{
try
{
var identify = await singletonSelector.ResolveOne(100.Milliseconds());
identify.Should().NotBe(ActorRefs.Nobody);
return;
}
catch (Exception)
{
// suppress
}
}

throw new AskTimeoutException("Failed to resolve singleton within timeout");
}).Should().NotThrowAsync();
}

[Fact(DisplayName = "Should launch singleton manager and proxy at the appropriate path (no manager name, actor factory)")]
public async Task ClusterSingletonAndProxyWithNoManagerNameAndFactoryTest()
{
Expand All @@ -109,11 +130,7 @@ public async Task ClusterSingletonAndProxyWithNoManagerNameAndFactoryTest()
var expectedSingletonPath = new RootActorPath(address) / "user" / "my-singleton" / "my-singleton";
var singletonSelector = system.ActorSelection(expectedSingletonPath);

await Awaiting(async () =>
{
var identify = await singletonSelector.ResolveOne(3.Seconds());
identify.Should().NotBe(ActorRefs.Nobody);
}).Should().NotThrowAsync();
await AssertSingletonSelectionAsync(singletonSelector);

singletonProxy.Path.ToString().Should().Be("akka://TestSys/user/my-singleton-proxy");

Expand Down Expand Up @@ -144,11 +161,7 @@ public async Task ClusterSingletonAndProxyWithManagerNameTest()
var expectedSingletonPath = new RootActorPath(address) / "user" / "my-singleton" / "singleton";
var singletonSelector = system.ActorSelection(expectedSingletonPath);

await Awaiting(async () =>
{
var identify = await singletonSelector.ResolveOne(3.Seconds());
identify.Should().NotBe(ActorRefs.Nobody);
}).Should().NotThrowAsync();
await AssertSingletonSelectionAsync(singletonSelector);

singletonProxy.Path.ToString().Should().Be("akka://TestSys/user/singleton-proxy");

Expand Down Expand Up @@ -179,11 +192,7 @@ public async Task ClusterSingletonAndProxyWithManagerNameAndFactoryTest()
var expectedSingletonPath = new RootActorPath(address) / "user" / "my-singleton" / "singleton";
var singletonSelector = system.ActorSelection(expectedSingletonPath);

await Awaiting(async () =>
{
var identify = await singletonSelector.ResolveOne(3.Seconds());
identify.Should().NotBe(ActorRefs.Nobody);
}).Should().NotThrowAsync();
await AssertSingletonSelectionAsync(singletonSelector);

singletonProxy.Path.ToString().Should().Be("akka://TestSys/user/singleton-proxy");

Expand Down
8 changes: 4 additions & 4 deletions src/Akka.Cluster.Hosting.Tests/ShardOptionsSpecs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public async Task EmptyShardOptionsTest()
shardingSettings.TuningParameters.LeastShardAllocationAbsoluteLimit.Should().Be(shardingConfig.GetInt("least-shard-allocation-strategy.rebalance-absolute-limit"));
shardingSettings.TuningParameters.LeastShardAllocationRelativeLimit.Should().Be(shardingConfig.GetDouble("least-shard-allocation-strategy.rebalance-relative-limit"));

var singletonConfig = ClusterSingletonManager.DefaultConfig().GetConfig("akka.cluster.singleton");
var singletonConfig = ClusterSingleton.DefaultConfig().GetConfig("akka.cluster.singleton");
shardingSettings.CoordinatorSingletonSettings.SingletonName.Should().Be(singletonConfig.GetString("singleton-name"));
shardingSettings.CoordinatorSingletonSettings.Role.Should().BeNull();
// https://github.com/akkadotnet/akka.net/blob/4ae47927da9f2539742c336acfa8ae0037fabbb7/src/contrib/cluster/Akka.Cluster.Tools/Singleton/ClusterSingletonManagerSettings.cs#L58
Expand Down Expand Up @@ -241,7 +241,7 @@ public async Task EmptyDDataShardOptionsTest()
shardingSettings.TuningParameters.LeastShardAllocationAbsoluteLimit.Should().Be(shardingConfig.GetInt("least-shard-allocation-strategy.rebalance-absolute-limit"));
shardingSettings.TuningParameters.LeastShardAllocationRelativeLimit.Should().Be(shardingConfig.GetDouble("least-shard-allocation-strategy.rebalance-relative-limit"));

var singletonConfig = ClusterSingletonManager.DefaultConfig().GetConfig("akka.cluster.singleton");
var singletonConfig = ClusterSingleton.DefaultConfig().GetConfig("akka.cluster.singleton");
shardingSettings.CoordinatorSingletonSettings.SingletonName.Should().Be(singletonConfig.GetString("singleton-name"));
shardingSettings.CoordinatorSingletonSettings.Role.Should().BeNull();
// https://github.com/akkadotnet/akka.net/blob/4ae47927da9f2539742c336acfa8ae0037fabbb7/src/contrib/cluster/Akka.Cluster.Tools/Singleton/ClusterSingletonManagerSettings.cs#L58
Expand Down Expand Up @@ -402,7 +402,7 @@ public async Task ModifiedShardOptionsTest()
shardingSettings.TuningParameters.LeastShardAllocationAbsoluteLimit.Should().Be(shardingConfig.GetInt("least-shard-allocation-strategy.rebalance-absolute-limit"));
shardingSettings.TuningParameters.LeastShardAllocationRelativeLimit.Should().Be(shardingConfig.GetDouble("least-shard-allocation-strategy.rebalance-relative-limit"));

var singletonConfig = ClusterSingletonManager.DefaultConfig().GetConfig("akka.cluster.singleton");
var singletonConfig = ClusterSingleton.DefaultConfig().GetConfig("akka.cluster.singleton");
shardingSettings.CoordinatorSingletonSettings.SingletonName.Should().Be(singletonConfig.GetString("singleton-name"));
shardingSettings.CoordinatorSingletonSettings.Role.Should().BeNull();
// https://github.com/akkadotnet/akka.net/blob/4ae47927da9f2539742c336acfa8ae0037fabbb7/src/contrib/cluster/Akka.Cluster.Tools/Singleton/ClusterSingletonManagerSettings.cs#L58
Expand Down Expand Up @@ -567,7 +567,7 @@ public async Task ModifiedDDataShardOptionsTest()
shardingSettings.TuningParameters.LeastShardAllocationAbsoluteLimit.Should().Be(shardingConfig.GetInt("least-shard-allocation-strategy.rebalance-absolute-limit"));
shardingSettings.TuningParameters.LeastShardAllocationRelativeLimit.Should().Be(shardingConfig.GetDouble("least-shard-allocation-strategy.rebalance-relative-limit"));

var singletonConfig = ClusterSingletonManager.DefaultConfig().GetConfig("akka.cluster.singleton");
var singletonConfig = ClusterSingleton.DefaultConfig().GetConfig("akka.cluster.singleton");
shardingSettings.CoordinatorSingletonSettings.SingletonName.Should().Be(singletonConfig.GetString("singleton-name"));
shardingSettings.CoordinatorSingletonSettings.Role.Should().BeNull();
// https://github.com/akkadotnet/akka.net/blob/4ae47927da9f2539742c336acfa8ae0037fabbb7/src/contrib/cluster/Akka.Cluster.Tools/Singleton/ClusterSingletonManagerSettings.cs#L58
Expand Down
14 changes: 7 additions & 7 deletions src/Akka.Cluster.Hosting/AkkaClusterHostingExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,7 @@ internal static AkkaConfigurationBuilder BuildClusterHocon(
{
if (options == null)
return builder.AddHocon(ClusterSharding.DefaultConfig()
.WithFallback(ClusterSingletonManager.DefaultConfig())
.WithFallback(ClusterSingleton.DefaultConfig())
.WithFallback(DistributedPubSub.DefaultConfig())
.WithFallback(ClusterClientReceptionist.DefaultConfig())
.WithFallback(DistributedData.DistributedData.DefaultConfig()), HoconAddMode.Append);
Expand Down Expand Up @@ -639,7 +639,7 @@ internal static AkkaConfigurationBuilder BuildClusterHocon(

// populate all of the possible Clustering default HOCON configurations here
return builder.AddHocon(ClusterSharding.DefaultConfig()
.WithFallback(ClusterSingletonManager.DefaultConfig())
.WithFallback(ClusterSingleton.DefaultConfig())
.WithFallback(DistributedPubSub.DefaultConfig())
.WithFallback(ClusterClientReceptionist.DefaultConfig())
.WithFallback(DistributedData.DistributedData.DefaultConfig()), HoconAddMode.Append);
Expand Down Expand Up @@ -947,7 +947,7 @@ public static AkkaConfigurationBuilder WithShardRegion<TKey>(
builder.AddHocon(
ClusterSharding.DefaultConfig()
.WithFallback(DistributedData.DistributedData.DefaultConfig())
.WithFallback(ClusterSingletonManager.DefaultConfig()),
.WithFallback(ClusterSingleton.DefaultConfig()),
HoconAddMode.Append);

return builder.StartActors(Resolver);
Expand Down Expand Up @@ -1162,7 +1162,7 @@ public static AkkaConfigurationBuilder WithShardedDaemonProcess<TKey>(

builder
.AddHocon(ClusterSharding.DefaultConfig(), HoconAddMode.Append)
.AddHocon(ClusterSingletonManager.DefaultConfig(), HoconAddMode.Append)
.AddHocon(ClusterSingleton.DefaultConfig(), HoconAddMode.Append)
.AddHocon(DistributedData.DistributedData.DefaultConfig(), HoconAddMode.Append);

builder.WithActors((system, registry, resolver) =>
Expand Down Expand Up @@ -1386,7 +1386,7 @@ public static AkkaConfigurationBuilder WithSingleton<TKey>(
// make sure that default configuration is loaded, not an exhaustive check.
if (!builder.Configuration.HasValue || builder.Configuration.Value.HasPath("akka.cluster.singleton"))
{
builder.AddHocon(ClusterSingletonManager.DefaultConfig(), HoconAddMode.Append);
builder.AddHocon(ClusterSingleton.DefaultConfig(), HoconAddMode.Append);
}

return builder.WithActors((system, registry, resolver) =>
Expand Down Expand Up @@ -1578,7 +1578,7 @@ public static AkkaConfigurationBuilder WithSingletonProxy<TKey>(
// make sure that default configuration is loaded, not an exhaustive check.
if (!builder.Configuration.HasValue || builder.Configuration.Value.HasPath("akka.cluster.singleton-proxy"))
{
builder.AddHocon(ClusterSingletonManager.DefaultConfig(), HoconAddMode.Append);
builder.AddHocon(ClusterSingleton.DefaultConfig(), HoconAddMode.Append);
}

return builder.WithActors((system, registry) =>
Expand Down Expand Up @@ -1635,7 +1635,7 @@ public static AkkaConfigurationBuilder WithSingletonProxy<TKey>(
// make sure that default configuration is loaded, not an exhaustive check.
if (!builder.Configuration.HasValue || builder.Configuration.Value.HasPath("akka.cluster.singleton-proxy"))
{
builder.AddHocon(ClusterSingletonManager.DefaultConfig(), HoconAddMode.Append);
builder.AddHocon(ClusterSingleton.DefaultConfig(), HoconAddMode.Append);
}

return builder.WithActors((system, registry) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ namespace Akka.Hosting.TestKit.Internals
public class XUnitLogger : Microsoft.Extensions.Logging.ILogger
{
public XUnitLogger(string category, Xunit.Abstractions.ITestOutputHelper helper, Microsoft.Extensions.Logging.LogLevel logLevel) { }
public System.IDisposable BeginScope<TState>(TState state)
where TState : notnull { }
public System.IDisposable BeginScope<TState>(TState state) { }
public bool IsEnabled(Microsoft.Extensions.Logging.LogLevel logLevel) { }
public void Log<TState>(Microsoft.Extensions.Logging.LogLevel logLevel, Microsoft.Extensions.Logging.EventId eventId, TState state, System.Exception? exception, System.Func<TState, System.Exception?, string> formatter) { }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ public async Task WaitForRadioSilenceAsync_should_fail_immediately_with_bad_inpu
try
{
await probe.WaitForRadioSilenceAsync(max: TimeSpan.FromMilliseconds(0), maxMessages: 0);
Assert.True(false, "we should never get here");
Assert.Fail("we should never get here");
}
catch (XunitException) { }
}
Expand Down
14 changes: 12 additions & 2 deletions src/Akka.Hosting.TestKit/Internals/XUnitLogger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,17 @@ private void WriteLogEntry(LogLevel logLevel, EventId eventId, string? message,
var msg = $"{DateTime.Now}:{level}:{_category}:{eventId} {message}";
if (exception != null)
msg += $"\n{exception.GetType()} {exception.Message}\n{exception.StackTrace}";
_helper.WriteLine(msg);

try
{

_helper.WriteLine(msg);
}
catch
{
// no active xUnit test available
Console.WriteLine("No active xUnit test available, but logging was attempted. Message: " + msg);
}
}

public bool IsEnabled(LogLevel logLevel)
Expand All @@ -58,7 +68,7 @@ public bool IsEnabled(LogLevel logLevel)
};
}

public IDisposable BeginScope<TState>(TState state) where TState : notnull
public IDisposable BeginScope<TState>(TState state)
{
throw new NotImplementedException();
}
Expand Down
2 changes: 1 addition & 1 deletion src/Akka.Hosting.Tests/Bugfix208Specs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public async Task ShouldStartHostedServiceThatDependsOnActor()
var r = await testActorRef.Ask<string>(new MyTestActor.GetData(), TimeSpan.FromMilliseconds(100));
r.Should().Be("BackgroundService started");
}
catch (Exception e)
catch (Exception)
{
attempts--;
if (attempts == 0)
Expand Down
4 changes: 2 additions & 2 deletions src/Akka.Hosting.Tests/Logging/SerilogLoggerEnd2EndSpecs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ public sealed class TestSink : ILogEventSink
{
public ConcurrentQueue<Serilog.Events.LogEvent> Writes { get; private set; } = new();

private readonly ITestOutputHelper _output;
private readonly ITestOutputHelper? _output;
private int _count;

public TestSink() : this(null)
{
}

public TestSink(ITestOutputHelper output)
public TestSink(ITestOutputHelper? output)
{
_output = output;
}
Expand Down
6 changes: 4 additions & 2 deletions src/Akka.Hosting.Tests/Logging/TestLogger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ public void StopWhenReceives(string message)
_stopsWhen = message;
}

public void Log<TState>(LogLevel logLevel, EventId eventId, TState state, Exception exception,
Func<TState, Exception, string> formatter)
public void Log<TState>(LogLevel logLevel, EventId eventId, TState state, Exception? exception,
Func<TState, Exception?, string> formatter)
{
var message = formatter(state, exception);
_helper.WriteLine($"[{logLevel}] {message}");
Expand Down Expand Up @@ -90,7 +90,9 @@ private EmptyDisposable()
{
}

#pragma warning disable CA1816
public void Dispose()
#pragma warning restore CA1816
{
}
}

0 comments on commit a8de727

Please sign in to comment.