TestCluster
class
Namespace: Orleans.TestingHost
A host class for local testing with Orleans using in-process silos. Runs a Primary and optionally secondary silos in separate app domains, and client in the main app domain. Additional silos can also be started in-process on demand if required for particular test cases.
public class TestCluster : IAsyncDisposable, IDisposableRemarks
Make sure that your test project references your test grains and test grain interfaces projects, and has CopyLocal=True set on those references [which should be the default].
Constructors
TestCluster(TestClusterOptions, IReadOnlyList<IConfigurationSource>, ITestClusterPortAllocator)Configures the test cluster plus client in-process.
Properties
ClientThe client.ConfigurationSourcesGets the configuration sources.CreateSiloAsyncDelegate used to create and start an individual silo.GrainFactoryGrainFactory to use in the testsOptionsOptions used to configure the test cluster.PortAllocatorThe port allocator.PrimaryPrimary silo handle, if applicable.SecondarySilosList of handles to the secondary silos.ServiceProviderClient-sideSystem.IServiceProviderto use in the tests.SilosCollection of all known silos.
Methods
DeactivateAsync(GrainId)Deactivates the current activation of the specified grain and waits for deactivation to complete.DeactivateAsync(IAddressable)Deactivates the current activation of the specified grain and waits for deactivation to complete.DefaultCreateSiloAsync(string, IConfiguration)Default value forTestCluster, which creates a new silo handle.DeployDeploys the cluster using the specified configuration and starts the client in-process. It will start the number of silos defined inTestClusterOptions.DeployAsyncDeploys the cluster using the specified configuration and starts the client in-process.DisposePerforms application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.DisposeAsyncPerforms application-defined tasks associated with freeing, releasing, or resetting unmanaged resources asynchronously.GetActiveSilosGet the list of current active silos.GetLivenessStabilizationTime(ClusterMembershipOptions, bool)Get the timeout value to use to wait for the silo liveness sub-system to detect and act on any recent cluster membership changes.GetLogGets the log.GetSiloForAddress(SiloAddress)Find the silo handle for the specified silo address.GetSiloServiceProvider(SiloAddress)Returns theSystem.IServiceProviderassociated with the givensilo.InitializeClientAsyncInitialize the grain client. This should be already done byTestClusterorTestClusterKillClientAsyncPerforms a hard kill on client. Client will not cleanup resources.KillSiloAsync(SiloHandle)Do an immediate Kill of the specified silo.MigrateAsync(GrainId, SiloAddress?)Migrates the current activation of the specified grain to a different silo and waits for migration to complete. IftargetSilois specified, a placement hint is set to guide migration to that silo.MigrateAsync(IAddressable, SiloAddress?)Migrates the current activation of the specified grain to a different silo and waits for migration to complete. IftargetSilois specified, a placement hint is set to guide migration to that silo.RestartSiloAsync(SiloHandle)Do a Stop or Kill of the specified silo, followed by a restart.RestartStoppedSecondarySiloAsync(string)Restart a previously stopped.StartAdditionalSilo(bool)Start an additional silo, so that it joins the existing cluster.StartAdditionalSiloAsync(bool)Start an additional silo, so that it joins the existing cluster.StartAdditionalSilosAsync(int, bool)Start a number of additional silo, so that they join the existing cluster.StartSiloAsync(int, TestClusterOptions, IReadOnlyList<IConfigurationSource>, bool)Starts a new silo.StartSiloAsync(TestCluster, int, TestClusterOptions, IReadOnlyList<IConfigurationSource>, bool)Start a new silo in the target clusterStopAllSilosStop all current silos.StopAllSilosAsyncStop all current silos.StopClusterClientAsyncStop cluster client as an asynchronous operation.StopPrimarySiloAsyncStops the default Primary silo.StopSecondarySilosAsyncStop any additional silos, not including the default Primary silo.StopSiloAsync(SiloHandle)Do a semi-graceful Stop of the specified silo.TryGetGrainContext(GrainId, IGrainContext?)Attempts to find theIGrainContextfor the grain with the specifiedgrainIdby searching all silos in the cluster.WaitForClusterManifestToStabilizeAsync(bool)Wait for active silos to observe cluster manifest updates for all active silos.WaitForDeactivationAsync(GrainId)Gets aSystem.Threading.Tasks.Taskthat completes when the current activation of the specified grain finishes deactivating. If the grain is not currently activated, returnsSystem.Threading.Tasks.Task.CompletedTask.WaitForDeactivationAsync(IAddressable)Gets aSystem.Threading.Tasks.Taskthat completes when the current activation of the specified grain finishes deactivating. If the grain is not currently activated, returnsSystem.Threading.Tasks.Task.CompletedTask.WaitForLivenessToStabilizeAsync(bool)Wait for the silo liveness sub-system to detect and act on any recent cluster membership changes.
