public async Task ActivationCollectorShouldCollectByCollectionSpecificAgeLimitForTenSeconds() { Initialize(); const int grainCount = 1000; // CollectionAgeLimit.Minutes = 0.2 minutes (10 seconds) var fullGrainTypeName = typeof(CollectionSpecificAgeLimitForTenSecondsActivationGcTestGrain).FullName; List <Task> tasks = new List <Task>(); logger.Info("ActivationCollectorShouldCollectByCollectionSpecificAgeLimit: activating {0} grains.", grainCount); for (var i = 0; i < grainCount; ++i) { ICollectionSpecificAgeLimitForTenSecondsActivationGcTestGrain g = this.testCluster.GrainFactory.GetGrain <ICollectionSpecificAgeLimitForTenSecondsActivationGcTestGrain>(Guid.NewGuid()); tasks.Add(g.Nop()); } await Task.WhenAll(tasks); int activationsCreated = await TestUtils.GetActivationCount(this.testCluster.GrainFactory, fullGrainTypeName); Assert.Equal(grainCount, activationsCreated); logger.Info("ActivationCollectorShouldCollectByCollectionSpecificAgeLimit: grains activated; waiting {0} sec (activation GC idle timeout is {1} sec).", WAIT_TIME.TotalSeconds, DEFAULT_IDLE_TIMEOUT.TotalSeconds); // Some time is required for GC to collect all of the Grains) await Task.Delay(TimeSpan.FromSeconds(30)); int activationsNotCollected = await TestUtils.GetActivationCount(this.testCluster.GrainFactory, fullGrainTypeName); Assert.Equal(0, activationsNotCollected); }
public async Task ActivationCollectorShouldCollectByCollectionSpecificAgeLimitForTwelveSeconds() { var waitTime = TimeSpan.FromSeconds(30); var defaultCollectionAge = waitTime.Multiply(2); //make sure defaultCollectionAge value won't cause activation collection in wait time await Initialize(defaultCollectionAge); const int grainCount = 1000; // CollectionAgeLimit = 12 seconds var fullGrainTypeName = RuntimeTypeNameFormatter.Format(typeof(CollectionSpecificAgeLimitForTenSecondsActivationGcTestGrain)); List <Task> tasks = new List <Task>(); logger.LogInformation("ActivationCollectorShouldCollectByCollectionSpecificAgeLimit: activating {GrainCount} grains.", grainCount); for (var i = 0; i < grainCount; ++i) { ICollectionSpecificAgeLimitForTenSecondsActivationGcTestGrain g = this.testCluster.GrainFactory.GetGrain <ICollectionSpecificAgeLimitForTenSecondsActivationGcTestGrain>(Guid.NewGuid()); tasks.Add(g.Nop()); } await Task.WhenAll(tasks); int activationsCreated = await TestUtils.GetActivationCount(this.testCluster.GrainFactory, fullGrainTypeName); Assert.Equal(grainCount, activationsCreated); logger.LogInformation( "ActivationCollectorShouldCollectByCollectionSpecificAgeLimit: grains activated; waiting {WaitSeconds} sec (activation GC idle timeout is {DefaultIdleTimeout} sec).", WAIT_TIME.TotalSeconds, DEFAULT_IDLE_TIMEOUT.TotalSeconds); // Some time is required for GC to collect all of the Grains) await Task.Delay(waitTime); int activationsNotCollected = await TestUtils.GetActivationCount(this.testCluster.GrainFactory, fullGrainTypeName); Assert.Equal(0, activationsNotCollected); }