public async Task StreamProducerOnDroppedClientTest(string streamProviderName, string streamNamespace) { const int eventsProduced = 10; Guid streamGuid = Guid.NewGuid(); await ProduceEventsFromClient(streamProviderName, streamGuid, streamNamespace, eventsProduced); // Hard kill client testHost.KillClient(); // make sure dead client has had time to drop await Task.Delay(testHost.ClusterConfiguration.Globals.ClientDropTimeout + TimeSpan.FromSeconds(5)); // initialize new client testHost.InitializeClient(); // run test again. await ProduceEventsFromClient(streamProviderName, streamGuid, streamNamespace, eventsProduced); }
public async Task StoresGrainStateWithReferencedGrainTest() { var grainId = Guid.NewGuid(); var grain = this.host.GrainFactory.GetGrain <ICouchBaseWithGrainReferenceStorageGrain>(grainId); // Request grain to reference another grain var referenceTag = $"Referenced by grain {grainId}"; await grain.ReferenceOtherGrain(referenceTag); // Verify referenced grain values var retrievedReferenceTag = await grain.GetReferencedTag(); Assert.Equal(referenceTag, retrievedReferenceTag); var retrievedReferencedAt = await grain.GetReferencedAt(); Assert.NotEqual(default(DateTime), retrievedReferencedAt); // Write state await grain.Write(); // Restart all test silos var silos = new[] { this.host.Primary }.Union(this.host.SecondarySilos).ToList(); foreach (var siloHandle in silos) { this.host.RestartSilo(siloHandle); } // Re-initialize client host.KillClient(); host.InitializeClient(); // Revive persisted grain var grainPostRestart = this.host.GrainFactory.GetGrain <ICouchBaseWithGrainReferenceStorageGrain>(grainId); // Force read persisted state await grainPostRestart.Read(); // Verify persisted state post restart var retrievedReferenceTagPostWrite = await grainPostRestart.GetReferencedTag(); Assert.Equal(referenceTag, retrievedReferenceTagPostWrite); var retrievedReferencedAtPostWrite = await grainPostRestart.GetReferencedAt(); Assert.Equal(retrievedReferencedAt, retrievedReferencedAtPostWrite); }