public static void AssemblyCleanup() { // Big issue with this! This method gets called not when it transitions to a new assembly, but after all assemblies finish testing. // It's an issue because each assembly is run in a separate AppDomain, so once the next assembly starts, it will actually // get TestingSiloHost.Instance and it will be null. Nevertheless, the another host might be running, and if they use the same ports then they'll be borked. TestingSiloHost.StopAllSilosIfRunning(); }
public void EnsureOrleansHostInitialized() { var fixtureType = this.GetType().AssemblyQualifiedName; var runningCluster = TestingSiloHost.Instance; if (runningCluster != null && previousFixtureType != null && previousFixtureType == fixtureType && runningCluster == previousHostedCluster) { runningCluster.StopAdditionalSilos(); this.HostedCluster = runningCluster; return; } previousHostedCluster = null; previousFixtureType = null; TestingSiloHost.StopAllSilosIfRunning(); var siloHostFactory = IsolatedHostedTestClusterUtils.FindTestingSiloHostFactory(this); this.HostedCluster = siloHostFactory.Invoke(); previousHostedCluster = this.HostedCluster; previousFixtureType = fixtureType; }
public void InitializeOrleansHost() { TestingSiloHost.StopAllSilosIfRunning(); var siloHostFactory = IsolatedHostedTestClusterUtils.FindTestingSiloHostFactory(this); this.HostedCluster = siloHostFactory.Invoke(); }
public async Task AsyncTimerTest_GrainCall() { const string testName = "AsyncTimerTest_GrainCall"; TimeSpan delay = TimeSpan.FromSeconds(5); TimeSpan wait = delay.Multiply(2); ITimerCallGrain grain = null; Exception error = null; try { grain = GrainClient.GrainFactory.GetGrain <ITimerCallGrain>(GetRandomGrainId()); await grain.StartTimer(testName, delay); await Task.Delay(wait); int tickCount = await grain.GetTickCount(); Assert.AreEqual(1, tickCount, "Should be {0} timer callback", tickCount); Exception err = await grain.GetException(); Assert.IsNull(err, "Should be no exceptions during timer callback"); } catch (Exception exc) { Console.WriteLine(exc); error = exc; } try { if (grain != null) { await grain.StopTimer(testName); } } catch (Exception exc) { // Ignore Console.WriteLine("Ignoring exception from StopTimer : {0}", exc); TestingSiloHost.StopAllSilosIfRunning(); } if (error != null) { Assert.Fail("Test {0} failed with error {1}", testName, error); } }
public void EnsureDefaultOrleansHostInitialized() { var runningCluster = TestingSiloHost.Instance; if (runningCluster != null && runningCluster == defaultHostedCluster) { runningCluster.StopAdditionalSilos(); this.HostedCluster = runningCluster; return; } TestingSiloHost.StopAllSilosIfRunning(); this.HostedCluster = new TestingSiloHost(true); defaultHostedCluster = this.HostedCluster; }
public void NewCluster(string clusterId, int numSilos, Action <ClusterConfiguration> customizer = null) { lock (Clusters) { var myCount = Clusters.Count; WriteLog("Starting Cluster {0} ({1})...", myCount, clusterId); if (myCount == 0) { TestingSiloHost.StopAllSilosIfRunning(); this.siloHost = TestingSiloHost.CreateUninitialized(); } var silohandles = new SiloHandle[numSilos]; var options = new TestingSiloOptions { StartClient = false, AdjustConfig = customizer, BasePort = GetPortBase(myCount), ProxyBasePort = GetProxyBase(myCount) }; silohandles[0] = TestingSiloHost.StartOrleansSilo(this.siloHost, Silo.SiloType.Primary, options, 0); Parallel.For(1, numSilos, paralleloptions, i => { silohandles[i] = TestingSiloHost.StartOrleansSilo(this.siloHost, Silo.SiloType.Secondary, options, i); }); Clusters[clusterId] = new ClusterInfo { Silos = silohandles.ToList(), SequenceNumber = myCount }; if (myCount == 0) { gossipStabilizationTime = GetGossipStabilizationTime(this.siloHost.Globals); } WriteLog("Cluster {0} started. [{1}]", clusterId, string.Join(" ", silohandles.Select(s => s.ToString()))); } }
public async Task AllowClusterReuseBetweenInvocations() { try { var host = new TestingSiloHost(startFreshOrleans: true); var initialDeploymentId = host.DeploymentId; var initialSilo = ((AppDomainSiloHandle)host.Primary).SiloHost; var grain = host.GrainFactory.GetGrain <ISimpleGrain>(TestUtils.GetRandomGrainId()); await grain.GetA(); host = new TestingSiloHost(startFreshOrleans: false); Assert.Equal(initialDeploymentId, host.DeploymentId); Assert.Same(initialSilo, ((AppDomainSiloHandle)host.Primary).SiloHost); grain = host.GrainFactory.GetGrain <ISimpleGrain>(TestUtils.GetRandomGrainId()); await grain.GetA(); } finally { TestingSiloHost.StopAllSilosIfRunning(); } }
public void NewCluster(string clusterid, int numSilos, Action <ClusterConfiguration> customizer = null) { lock (Clusters) { WriteLog("Starting Cluster {0}...", clusterid); var mycount = Clusters.Count; if (mycount == 0) { TestingSiloHost.StopAllSilosIfRunning(); this.siloHost = TestingSiloHost.CreateUninitialized(); } var silohandles = new SiloHandle[numSilos]; var options = new TestingSiloOptions { StartClient = false, AdjustConfig = customizer, BasePort = GetPortBase(mycount), ProxyBasePort = GetProxyBase(mycount) }; silohandles[0] = TestingSiloHost.StartOrleansSilo(this.siloHost, Silo.SiloType.Primary, options, 0); Parallel.For(1, numSilos, i => { silohandles[i] = TestingSiloHost.StartOrleansSilo(this.siloHost, Silo.SiloType.Secondary, options, i); }); Clusters[clusterid] = new ClusterInfo { Silos = silohandles.ToList(), SequenceNumber = mycount }; WriteLog("Cluster {0} started.", clusterid); } }
public void StopOrleansAfterTest() { TestingSiloHost.StopAllSilosIfRunning(); }