@@ -35,15 +35,25 @@ public class ClusterDomainEventPublisherSpec : AkkaSpec
35
35
static readonly Member dUp = TestMember . Create ( new Address ( "akka.tcp" , "sys" , "d" , 2552 ) , MemberStatus . Up , ImmutableHashSet . Create ( "GRP" ) ) ;
36
36
37
37
static readonly Gossip g0 = new Gossip ( ImmutableSortedSet . Create ( aUp ) ) . Seen ( aUp . UniqueAddress ) ;
38
+ static readonly MembershipState state0 = new MembershipState ( g0 , aUp . UniqueAddress ) ;
38
39
static readonly Gossip g1 = new Gossip ( ImmutableSortedSet . Create ( aUp , cJoining ) ) . Seen ( aUp . UniqueAddress ) . Seen ( cJoining . UniqueAddress ) ;
40
+ static readonly MembershipState state1 = new MembershipState ( g1 , aUp . UniqueAddress ) ;
39
41
static readonly Gossip g2 = new Gossip ( ImmutableSortedSet . Create ( aUp , bExiting , cUp ) ) . Seen ( aUp . UniqueAddress ) ;
42
+ static readonly MembershipState state2 = new MembershipState ( g2 , aUp . UniqueAddress ) ;
40
43
static readonly Gossip g3 = g2 . Seen ( bExiting . UniqueAddress ) . Seen ( cUp . UniqueAddress ) ;
44
+ static readonly MembershipState state3 = new MembershipState ( g3 , aUp . UniqueAddress ) ;
41
45
static readonly Gossip g4 = new Gossip ( ImmutableSortedSet . Create ( a51Up , aUp , bExiting , cUp ) ) . Seen ( aUp . UniqueAddress ) ;
46
+ static readonly MembershipState state4 = new MembershipState ( g4 , aUp . UniqueAddress ) ;
42
47
static readonly Gossip g5 = new Gossip ( ImmutableSortedSet . Create ( a51Up , aUp , bExiting , cUp ) ) . Seen ( aUp . UniqueAddress ) . Seen ( bExiting . UniqueAddress ) . Seen ( cUp . UniqueAddress ) ;
48
+ static readonly MembershipState state5 = new MembershipState ( g5 , aUp . UniqueAddress ) ;
43
49
static readonly Gossip g6 = new Gossip ( ImmutableSortedSet . Create ( aLeaving , bExiting , cUp ) ) . Seen ( aUp . UniqueAddress ) ;
50
+ static readonly MembershipState state6 = new MembershipState ( g6 , aUp . UniqueAddress ) ;
44
51
static readonly Gossip g7 = new Gossip ( ImmutableSortedSet . Create ( aExiting , bExiting , cUp ) ) . Seen ( aUp . UniqueAddress ) ;
52
+ static readonly MembershipState state7 = new MembershipState ( g7 , aUp . UniqueAddress ) ;
45
53
static readonly Gossip g8 = new Gossip ( ImmutableSortedSet . Create ( aUp , bExiting , cUp , dUp ) , new GossipOverview ( Reachability . Empty . Unreachable ( aUp . UniqueAddress , dUp . UniqueAddress ) ) ) . Seen ( aUp . UniqueAddress ) ;
54
+ static readonly MembershipState state8 = new MembershipState ( g8 , aUp . UniqueAddress ) ;
46
55
56
+ static readonly MembershipState _emptyMembershipState = new MembershipState ( Gossip . Empty , aUp . UniqueAddress ) ;
47
57
readonly TestProbe _memberSubscriber ;
48
58
49
59
public ClusterDomainEventPublisherSpec ( ) : base ( Config )
@@ -54,31 +64,31 @@ public ClusterDomainEventPublisherSpec() : base(Config)
54
64
Sys . EventStream . Subscribe ( _memberSubscriber . Ref , typeof ( ClusterEvent . ClusterShuttingDown ) ) ;
55
65
56
66
_publisher = Sys . ActorOf ( Props . Create < ClusterDomainEventPublisher > ( ) ) ;
57
- _publisher . Tell ( new InternalClusterAction . PublishChanges ( g0 ) ) ;
67
+ _publisher . Tell ( new InternalClusterAction . PublishChanges ( state0 ) ) ;
58
68
_memberSubscriber . ExpectMsg ( new ClusterEvent . MemberUp ( aUp ) ) ;
59
69
_memberSubscriber . ExpectMsg ( new ClusterEvent . LeaderChanged ( aUp . Address ) ) ;
60
70
}
61
71
62
72
[ Fact ]
63
73
public void ClusterDomainEventPublisher_must_publish_MemberJoined ( )
64
74
{
65
- _publisher . Tell ( new InternalClusterAction . PublishChanges ( g1 ) ) ;
75
+ _publisher . Tell ( new InternalClusterAction . PublishChanges ( state1 ) ) ;
66
76
_memberSubscriber . ExpectMsg ( new ClusterEvent . MemberJoined ( cJoining ) ) ;
67
77
}
68
78
69
79
[ Fact ]
70
80
public void ClusterDomainEventPublisher_must_publish_MemberUp ( )
71
81
{
72
- _publisher . Tell ( new InternalClusterAction . PublishChanges ( g2 ) ) ;
73
- _publisher . Tell ( new InternalClusterAction . PublishChanges ( g3 ) ) ;
82
+ _publisher . Tell ( new InternalClusterAction . PublishChanges ( state2 ) ) ;
83
+ _publisher . Tell ( new InternalClusterAction . PublishChanges ( state3 ) ) ;
74
84
_memberSubscriber . ExpectMsg ( new ClusterEvent . MemberExited ( bExiting ) ) ;
75
85
_memberSubscriber . ExpectMsg ( new ClusterEvent . MemberUp ( cUp ) ) ;
76
86
}
77
87
78
88
[ Fact ]
79
89
public void ClusterDomainEventPublisher_must_publish_leader_changed ( )
80
90
{
81
- _publisher . Tell ( new InternalClusterAction . PublishChanges ( g4 ) ) ;
91
+ _publisher . Tell ( new InternalClusterAction . PublishChanges ( state4 ) ) ;
82
92
_memberSubscriber . ExpectMsg ( new ClusterEvent . MemberUp ( a51Up ) ) ;
83
93
_memberSubscriber . ExpectMsg ( new ClusterEvent . MemberExited ( bExiting ) ) ;
84
94
_memberSubscriber . ExpectMsg ( new ClusterEvent . MemberUp ( cUp ) ) ;
@@ -89,17 +99,17 @@ public void ClusterDomainEventPublisher_must_publish_leader_changed()
89
99
[ Fact ]
90
100
public void ClusterDomainEventPublisher_must_publish_leader_changed_when_old_leader_leaves_and_is_removed ( )
91
101
{
92
- _publisher . Tell ( new InternalClusterAction . PublishChanges ( g3 ) ) ;
102
+ _publisher . Tell ( new InternalClusterAction . PublishChanges ( state3 ) ) ;
93
103
_memberSubscriber . ExpectMsg ( new ClusterEvent . MemberExited ( bExiting ) ) ;
94
104
_memberSubscriber . ExpectMsg ( new ClusterEvent . MemberUp ( cUp ) ) ;
95
- _publisher . Tell ( new InternalClusterAction . PublishChanges ( g6 ) ) ;
105
+ _publisher . Tell ( new InternalClusterAction . PublishChanges ( state6 ) ) ;
96
106
_memberSubscriber . ExpectMsg ( new ClusterEvent . MemberLeft ( aLeaving ) ) ;
97
- _publisher . Tell ( new InternalClusterAction . PublishChanges ( g7 ) ) ;
107
+ _publisher . Tell ( new InternalClusterAction . PublishChanges ( state7 ) ) ;
98
108
_memberSubscriber . ExpectMsg ( new ClusterEvent . MemberExited ( aExiting ) ) ;
99
109
_memberSubscriber . ExpectMsg ( new ClusterEvent . LeaderChanged ( cUp . Address ) ) ;
100
110
_memberSubscriber . ExpectNoMsg ( 500 . Milliseconds ( ) ) ;
101
111
// at the removed member a an empty gossip is the last thing
102
- _publisher . Tell ( new InternalClusterAction . PublishChanges ( Gossip . Empty ) ) ;
112
+ _publisher . Tell ( new InternalClusterAction . PublishChanges ( _emptyMembershipState ) ) ;
103
113
_memberSubscriber . ExpectMsg ( new ClusterEvent . MemberRemoved ( aRemoved , MemberStatus . Exiting ) ) ;
104
114
_memberSubscriber . ExpectMsg ( new ClusterEvent . MemberRemoved ( bRemoved , MemberStatus . Exiting ) ) ;
105
115
_memberSubscriber . ExpectMsg ( new ClusterEvent . MemberRemoved ( cRemoved , MemberStatus . Up ) ) ;
@@ -109,13 +119,13 @@ public void ClusterDomainEventPublisher_must_publish_leader_changed_when_old_lea
109
119
[ Fact ]
110
120
public void ClusterDomainEventPublisher_must_not_publish_leader_changed_when_same_leader ( )
111
121
{
112
- _publisher . Tell ( new InternalClusterAction . PublishChanges ( g4 ) ) ;
122
+ _publisher . Tell ( new InternalClusterAction . PublishChanges ( state4 ) ) ;
113
123
_memberSubscriber . ExpectMsg ( new ClusterEvent . MemberUp ( a51Up ) ) ;
114
124
_memberSubscriber . ExpectMsg ( new ClusterEvent . MemberExited ( bExiting ) ) ;
115
125
_memberSubscriber . ExpectMsg ( new ClusterEvent . MemberUp ( cUp ) ) ;
116
126
_memberSubscriber . ExpectMsg ( new ClusterEvent . LeaderChanged ( a51Up . Address ) ) ;
117
127
118
- _publisher . Tell ( new InternalClusterAction . PublishChanges ( g5 ) ) ;
128
+ _publisher . Tell ( new InternalClusterAction . PublishChanges ( state5 ) ) ;
119
129
_memberSubscriber . ExpectNoMsg ( 500 . Milliseconds ( ) ) ;
120
130
}
121
131
@@ -125,9 +135,9 @@ public void ClusterDomainEventPublisher_must_publish_role_leader_changed()
125
135
var subscriber = CreateTestProbe ( ) ;
126
136
_publisher . Tell ( new InternalClusterAction . Subscribe ( subscriber . Ref , ClusterEvent . SubscriptionInitialStateMode . InitialStateAsSnapshot , ImmutableHashSet . Create ( typeof ( ClusterEvent . RoleLeaderChanged ) ) ) ) ;
127
137
subscriber . ExpectMsg < ClusterEvent . CurrentClusterState > ( ) ;
128
- _publisher . Tell ( new InternalClusterAction . PublishChanges ( new Gossip ( ImmutableSortedSet . Create ( cJoining , dUp ) ) ) ) ;
138
+ _publisher . Tell ( new InternalClusterAction . PublishChanges ( new MembershipState ( new Gossip ( ImmutableSortedSet . Create ( cJoining , dUp ) ) , dUp . UniqueAddress ) ) ) ;
129
139
subscriber . ExpectMsg ( new ClusterEvent . RoleLeaderChanged ( "GRP" , dUp . Address ) ) ;
130
- _publisher . Tell ( new InternalClusterAction . PublishChanges ( new Gossip ( ImmutableSortedSet . Create ( cUp , dUp ) ) ) ) ;
140
+ _publisher . Tell ( new InternalClusterAction . PublishChanges ( new MembershipState ( new Gossip ( ImmutableSortedSet . Create ( cUp , dUp ) ) , dUp . UniqueAddress ) ) ) ;
131
141
subscriber . ExpectMsg ( new ClusterEvent . RoleLeaderChanged ( "GRP" , cUp . Address ) ) ;
132
142
}
133
143
@@ -145,7 +155,7 @@ public void ClusterDomainEventPublisher_must_send_CurrentClusterState_when_subsc
145
155
public void ClusterDomainEventPublisher_must_send_events_corresponding_to_current_state_when_subscribe ( )
146
156
{
147
157
var subscriber = CreateTestProbe ( ) ;
148
- _publisher . Tell ( new InternalClusterAction . PublishChanges ( g8 ) ) ;
158
+ _publisher . Tell ( new InternalClusterAction . PublishChanges ( state8 ) ) ;
149
159
_publisher . Tell ( new InternalClusterAction . Subscribe ( subscriber . Ref , ClusterEvent . SubscriptionInitialStateMode . InitialStateAsEvents , ImmutableHashSet . Create ( typeof ( ClusterEvent . IMemberEvent ) , typeof ( ClusterEvent . ReachabilityEvent ) ) ) ) ;
150
160
151
161
subscriber . ReceiveN ( 4 ) . Should ( ) . BeEquivalentTo (
@@ -165,7 +175,7 @@ public void ClusterDomainEventPublisher_should_support_unsubscribe()
165
175
_publisher . Tell ( new InternalClusterAction . Subscribe ( subscriber . Ref , ClusterEvent . SubscriptionInitialStateMode . InitialStateAsSnapshot , ImmutableHashSet . Create ( typeof ( ClusterEvent . IMemberEvent ) ) ) ) ;
166
176
subscriber . ExpectMsg < ClusterEvent . CurrentClusterState > ( ) ;
167
177
_publisher . Tell ( new InternalClusterAction . Unsubscribe ( subscriber . Ref , typeof ( ClusterEvent . IMemberEvent ) ) ) ;
168
- _publisher . Tell ( new InternalClusterAction . PublishChanges ( g3 ) ) ;
178
+ _publisher . Tell ( new InternalClusterAction . PublishChanges ( state3 ) ) ;
169
179
subscriber . ExpectNoMsg ( 500 . Milliseconds ( ) ) ;
170
180
// but memberSubscriber is still subscriber
171
181
_memberSubscriber . ExpectMsg ( new ClusterEvent . MemberExited ( bExiting ) ) ;
@@ -178,10 +188,10 @@ public void ClusterDomainEventPublisher_must_publish_seen_changed()
178
188
var subscriber = CreateTestProbe ( ) ;
179
189
_publisher . Tell ( new InternalClusterAction . Subscribe ( subscriber . Ref , ClusterEvent . SubscriptionInitialStateMode . InitialStateAsSnapshot , ImmutableHashSet . Create ( typeof ( ClusterEvent . SeenChanged ) ) ) ) ;
180
190
subscriber . ExpectMsg < ClusterEvent . CurrentClusterState > ( ) ;
181
- _publisher . Tell ( new InternalClusterAction . PublishChanges ( g2 ) ) ;
191
+ _publisher . Tell ( new InternalClusterAction . PublishChanges ( state2 ) ) ;
182
192
subscriber . ExpectMsg < ClusterEvent . SeenChanged > ( ) ;
183
193
subscriber . ExpectNoMsg ( 500 . Milliseconds ( ) ) ;
184
- _publisher . Tell ( new InternalClusterAction . PublishChanges ( g3 ) ) ;
194
+ _publisher . Tell ( new InternalClusterAction . PublishChanges ( state3 ) ) ;
185
195
subscriber . ExpectMsg < ClusterEvent . SeenChanged > ( ) ;
186
196
subscriber . ExpectNoMsg ( 500 . Milliseconds ( ) ) ;
187
197
}
0 commit comments