1
+ // //-----------------------------------------------------------------------
2
+ // // <copyright file="Bugfix5962Spec.cs" company="Akka.NET Project">
3
+ // // Copyright (C) 2009-2022 Lightbend Inc. <http://www.lightbend.com>
4
+ // // Copyright (C) 2013-2022 .NET Foundation <https://github.com/akkadotnet/akka.net>
5
+ // // </copyright>
6
+ // //-----------------------------------------------------------------------
7
+
8
+ using System ;
9
+ using System . Threading . Tasks ;
10
+ using Akka . Configuration ;
11
+ using Akka . TestKit ;
12
+ using FluentAssertions ;
13
+ using FluentAssertions . Extensions ;
14
+ using Xunit ;
15
+ using Xunit . Abstractions ;
16
+ using static FluentAssertions . FluentActions ;
17
+
18
+
19
+ namespace Akka . Cluster . Tests
20
+ {
21
+ public class Bugfix5962Spec : TestKit . Xunit2 . TestKit
22
+ {
23
+ private static readonly Config Config = ConfigurationFactory . ParseString ( @"
24
+ akka {
25
+ loglevel = INFO
26
+ actor {
27
+ provider = cluster
28
+ default-dispatcher = {
29
+ executor = channel-executor
30
+ channel-executor.priority = normal
31
+ }
32
+ # Adding this part in combination with the SplitBrainResolverProvider causes the error
33
+ internal-dispatcher = {
34
+ executor = channel-executor
35
+ channel-executor.priority = high
36
+ }
37
+ }
38
+ remote {
39
+ dot-netty.tcp {
40
+ port = 15508
41
+ hostname = ""127.0.0.1""
42
+ }
43
+ default-remote-dispatcher {
44
+ executor = channel-executor
45
+ channel-executor.priority = high
46
+ }
47
+ backoff-remote-dispatcher {
48
+ executor = channel-executor
49
+ channel-executor.priority = low
50
+ }
51
+ }
52
+ cluster {
53
+ seed-nodes = [""akka.tcp://[email protected] :15508""]
54
+ downing-provider-class = ""Akka.Cluster.SBR.SplitBrainResolverProvider, Akka.Cluster""
55
+ }
56
+ }" ) ;
57
+
58
+ private readonly Type _timerMsgType ;
59
+
60
+ public Bugfix5962Spec ( ITestOutputHelper output ) : base ( Config , nameof ( Bugfix5962Spec ) , output )
61
+ {
62
+ _timerMsgType = Type . GetType ( "Akka.Actor.Scheduler.TimerScheduler+TimerMsg, Akka" ) ;
63
+ }
64
+
65
+ [ Fact ]
66
+ public async Task SBR_Should_work_with_channel_executor ( )
67
+ {
68
+ var latch = new TestLatch ( 1 ) ;
69
+ var cluster = Cluster . Get ( Sys ) ;
70
+ cluster . RegisterOnMemberUp ( ( ) =>
71
+ {
72
+ latch . CountDown ( ) ;
73
+ } ) ;
74
+
75
+ var selection = Sys . ActorSelection ( "akka://Bugfix5962Spec/system/cluster/core/daemon/downingProvider" ) ;
76
+
77
+ await Awaiting ( ( ) => selection . ResolveOne ( 1 . Seconds ( ) ) )
78
+ . Should ( ) . NotThrowAsync ( "Downing provider should be alive. ActorSelection will throw an ActorNotFoundException if this fails" ) ;
79
+
80
+ // There should be no TimerMsg being sent to dead letter, this signals that the downing provider is dead
81
+ await EventFilter . DeadLetter ( _timerMsgType ) . ExpectAsync ( 0 , async ( ) =>
82
+ {
83
+ latch . Ready ( 1 . Seconds ( ) ) ;
84
+ await Task . Delay ( 2 . Seconds ( ) ) ;
85
+ } ) ;
86
+ }
87
+ }
88
+ }
0 commit comments