1212using System . Threading . Tasks ;
1313using ClusterTest . Messages ;
1414using FluentAssertions ;
15+ using Proto . Cluster ;
1516using Proto . Cluster . Identity ;
1617using Proto . Cluster . Partition ;
1718using Proto . Cluster . Tests ;
@@ -91,12 +92,20 @@ PartitionIdentityLookup.Send send
9192 var actorStates = fixture . Repository . Contents . ToList ( ) ;
9293
9394 var totalCalls = actorStates . Select ( it => it . TotalCount ) . Sum ( ) ;
94- var restarts = actorStates . Select ( it => it . Events . Count ( it => it is ActorStopped ) - 1 ) . Sum ( ) ;
95+ var restarts = actorStates . Select ( it => it . Events . Count ( e => e is ActorStopped ) - 1 ) . Sum ( ) ;
96+ var totalActivationRequests =
97+ actorStates . Select ( it => it . Events . Count ( e => e is ActivationRequested ) ) . Sum ( ) ;
9598
96- _output . WriteLine ( $ "{ totalCalls } requests, { restarts } restarts against " + actorStates . Count + " identities" ) ;
99+ _output . WriteLine (
100+ $ "{ totalCalls } requests, { restarts } restarts, { totalActivationRequests } activation requests against " +
101+ actorStates . Count + " identities" ) ;
97102
98103 foreach ( var actorState in actorStates )
99104 {
105+ var activationReqs = actorState . Events . Count ( e => e is ActivationRequested ) ;
106+ var starts = actorState . Events . Count ( e => e is ActorStarted ) ;
107+ activationReqs . Should ( ) . Be ( starts ) ;
108+
100109 if ( actorState . Inconsistent )
101110 {
102111 Assert . False ( actorState . Inconsistent , actorState . ToString ( ) ) ;
@@ -298,12 +307,22 @@ protected override ClusterKind[] ClusterKinds
298307 } ;
299308
300309 protected override IIdentityLookup GetIdentityLookup ( string clusterName ) =>
301- new PartitionIdentityLookup ( new PartitionConfig
302- {
303- GetPidTimeout = TimeSpan . FromSeconds ( 5 ) ,
304- HandoverChunkSize = _chunkSize ,
305- RebalanceRequestTimeout = TimeSpan . FromSeconds ( 3 ) ,
306- Mode = _mode ,
307- Send = _send
308- } ) ;
310+ new PartitionIdentityLookup (
311+ new PartitionConfig
312+ {
313+ GetPidTimeout = TimeSpan . FromSeconds ( 5 ) ,
314+ HandoverChunkSize = _chunkSize ,
315+ RebalanceRequestTimeout = TimeSpan . FromSeconds ( 3 ) ,
316+ Mode = _mode ,
317+ Send = _send
318+ } ,
319+ props => props . WithReceiverMiddleware ( next => async ( ctx , env ) =>
320+ {
321+ if ( env . Message is ActivationRequest req )
322+ {
323+ Repository . Get ( req . Identity , this ) . RecordActivationRequest ( ctx . System . Id ) ;
324+ }
325+
326+ await next ( ctx , env ) ;
327+ } ) ) ;
309328}
0 commit comments