public static TestingSiloHost CreateSiloHost() { var host = new TestingSiloHost(siloOptions); string config = host.Primary.Silo.TestHook.PrintSiloConfig(); Console.WriteLine("Running with Silo Config = " + config); return host; }
public HostedTestClusterPerTest() { TestDefaultConfiguration.InitializeDefaults(); GrainClient.Uninitialize(); SerializationManager.InitializeForTesting(); this.HostedCluster = this.CreateSiloHost(); }
internal static void LogStartTest(string testName, Guid streamId, string streamProviderName, Logger logger, TestingSiloHost siloHost) { SiloAddress primSilo = siloHost.Primary.Silo.SiloAddress; SiloAddress secSilo = siloHost.Secondary?.Silo.SiloAddress; logger.Info("\n\n**START********************** {0} ********************************* \n\n" + "Running with initial silos Primary={1} Secondary={2} StreamId={3} StreamType={4} \n\n", testName, primSilo, secSilo, streamId, streamProviderName); }
public Base_PersistenceGrainTests_AWSStore(ITestOutputHelper output, BaseClusterFixture fixture) { if (!AWSTestConstants.IsDynamoDbAvailable) throw new SkipException("Unable to connect to DynamoDB simulator"); this.output = output; HostedCluster = fixture.HostedCluster; timingFactor = TestUtils.CalibrateTimings(); }
public SampleStreamingTests() : base(new TestingSiloOptions { StartFreshOrleans = false, StartSecondary = false, SiloConfigFile = new FileInfo("OrleansConfigurationForStreamingUnitTests.xml") }) { _host = this; }
public KafkaPressureCacheTests() : base( new TestingSiloOptions() { StartFreshOrleans = false, StartSecondary = false, SiloConfigFile = new FileInfo("OrleansConfigurationForPressureTests.xml"), }) { _runner = new PressuredCacheTestRunner(KafkaStreamProviderName, logger); _host = this; }
public KafkaSubscriptionMultiplicityTests() : base(new TestingSiloOptions { StartFreshOrleans = false, StartSecondary = false, SiloConfigFile = new FileInfo("OrleansConfigurationForStreamingUnitTests.xml"), }) { _runner = new SubscriptionMultiplicityTestRunner(KafkaStreamProviderName, GrainClient.Logger); _host = this; }
public KafkaBatchProducingTests() : base(new TestingSiloOptions() { StartFreshOrleans = false, StartSecondary = false, SiloConfigFile = new FileInfo("OrleansConfigurationForStreamingUnitTests.xml") }) { _runner = new BatchProducingTestRunner(KafkaStreamProviderName, logger); _host = this; }
public ReminderTests_Base(BaseClusterFixture fixture) { HostedCluster = fixture.HostedCluster; ClientConfiguration cfg = ClientConfiguration.LoadFromFile("ClientConfigurationForTesting.xml"); LogManager.Initialize(cfg); #if DEBUG LogManager.AddTraceLevelOverride("Storage", Severity.Verbose3); LogManager.AddTraceLevelOverride("Reminder", Severity.Verbose3); #endif log = LogManager.GetLogger(this.GetType().Name, LoggerType.Application); }
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 override TestingSiloHost CreateSiloHost() { var siloHost = new TestingSiloHost( new TestingSiloOptions { SiloConfigFile = new FileInfo("OrleansConfigurationForStreamingUnitTests.xml"), }, new TestingClientOptions() { AdjustConfig = config => { config.RegisterStreamProvider<AzureQueueStreamProvider>(AQStreamProviderName, new Dictionary<string, string>()); config.Gateways.Add(new IPEndPoint(IPAddress.Loopback, 40001)); }, }); runner = new SubscriptionMultiplicityTestRunner(AQStreamProviderName, GrainClient.Logger); return siloHost; }
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 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; }
// This is a static version that can be called without a TestingSiloHost object (host = null) public static SiloHandle StartOrleansSilo(TestingSiloHost host, Silo.SiloType type, TestingSiloOptions options, int instanceCount, AppDomain shared = null) { // Load initial config settings, then apply some overrides below. ClusterConfiguration config = new ClusterConfiguration(); if (options.SiloConfigFile == null) { config.StandardLoad(); } else { config.LoadFromFile(options.SiloConfigFile.FullName); } int basePort = options.BasePort < 0 ? BasePort : options.BasePort; if (config.Globals.SeedNodes.Count > 0 && options.BasePort < 0) { config.PrimaryNode = config.Globals.SeedNodes[0]; } else { config.PrimaryNode = new IPEndPoint(IPAddress.Loopback, basePort); } config.Globals.SeedNodes.Clear(); config.Globals.SeedNodes.Add(config.PrimaryNode); if (!String.IsNullOrEmpty(DeploymentId)) { config.Globals.DeploymentId = DeploymentId; } config.Defaults.PropagateActivityId = options.PropagateActivityId; if (options.LargeMessageWarningThreshold > 0) { config.Defaults.LargeMessageWarningThreshold = options.LargeMessageWarningThreshold; } config.Globals.LivenessType = options.LivenessType; config.Globals.ReminderServiceType = options.ReminderServiceType; if (!String.IsNullOrEmpty(options.DataConnectionString)) { config.Globals.DataConnectionString = options.DataConnectionString; } _livenessStabilizationTime = GetLivenessStabilizationTime(config.Globals); if (host != null) { host.Globals = config.Globals; } string siloName; switch (type) { case Silo.SiloType.Primary: siloName = "Primary"; break; default: siloName = "Secondary_" + instanceCount.ToString(CultureInfo.InvariantCulture); break; } NodeConfiguration nodeConfig = config.GetConfigurationForNode(siloName); nodeConfig.HostNameOrIPAddress = "loopback"; nodeConfig.Port = basePort + instanceCount; nodeConfig.DefaultTraceLevel = config.Defaults.DefaultTraceLevel; nodeConfig.PropagateActivityId = config.Defaults.PropagateActivityId; nodeConfig.BulkMessageLimit = config.Defaults.BulkMessageLimit; if (nodeConfig.ProxyGatewayEndpoint != null && nodeConfig.ProxyGatewayEndpoint.Address != null) { int proxyBasePort = options.ProxyBasePort < 0 ? ProxyBasePort : options.ProxyBasePort; nodeConfig.ProxyGatewayEndpoint = new IPEndPoint(nodeConfig.ProxyGatewayEndpoint.Address, proxyBasePort + instanceCount); } config.Globals.ExpectedClusterSize = 2; config.Overrides[siloName] = nodeConfig; AdjustForTest(config, options); WriteLog("Starting a new silo in app domain {0} with config {1}", siloName, config.ToString(siloName)); AppDomain appDomain; Silo silo = LoadSiloInNewAppDomain(siloName, type, config, out appDomain); silo.Start(); SiloHandle retValue = new SiloHandle { Name = siloName, Silo = silo, Options = options, Endpoint = silo.SiloAddress.Endpoint, AppDomain = appDomain, }; ImportGeneratedAssemblies(retValue); return retValue; }
/// <summary> /// Start a new silo in the target cluster /// </summary> /// <param name="host">The target cluster</param> /// <param name="type">The type of the silo to deploy</param> /// <param name="options">The options to use for the silo</param> /// <param name="instanceCount">The instance count of the silo</param> /// <param name="shared">The shared AppDomain to use</param> /// <returns>A handle to the deployed silo</returns> public static SiloHandle StartOrleansSilo(TestingSiloHost host, Silo.SiloType type, TestingSiloOptions options, int instanceCount, AppDomain shared = null) { if (host == null) { throw new ArgumentNullException("host"); } // Load initial config settings, then apply some overrides below. ClusterConfiguration config = new ClusterConfiguration(); try { if (options.SiloConfigFile == null) { config.StandardLoad(); } else { config.LoadFromFile(options.SiloConfigFile.FullName); } } catch (FileNotFoundException) { if (options.SiloConfigFile != null && !string.Equals(options.SiloConfigFile.Name, TestingSiloOptions.DEFAULT_SILO_CONFIG_FILE, StringComparison.InvariantCultureIgnoreCase)) { // if the user is not using the defaults, then throw because the file was legitimally not found throw; } config = ClusterConfiguration.LocalhostPrimarySilo(); config.AddMemoryStorageProvider("Default"); config.AddMemoryStorageProvider("MemoryStore"); } int basePort = options.BasePort < 0 ? BasePort : options.BasePort; if (config.Globals.SeedNodes.Count > 0 && options.BasePort < 0) { config.PrimaryNode = config.Globals.SeedNodes[0]; } else { config.PrimaryNode = new IPEndPoint(IPAddress.Loopback, basePort); } config.Globals.SeedNodes.Clear(); config.Globals.SeedNodes.Add(config.PrimaryNode); if (!String.IsNullOrEmpty(host.DeploymentId)) { config.Globals.DeploymentId = host.DeploymentId; } config.Defaults.PropagateActivityId = options.PropagateActivityId; if (options.LargeMessageWarningThreshold > 0) { config.Defaults.LargeMessageWarningThreshold = options.LargeMessageWarningThreshold; } config.Globals.LivenessType = options.LivenessType; config.Globals.ReminderServiceType = options.ReminderServiceType; if (!String.IsNullOrEmpty(options.DataConnectionString)) { config.Globals.DataConnectionString = options.DataConnectionString; } host.Globals = config.Globals; string siloName; switch (type) { case Silo.SiloType.Primary: siloName = "Primary"; break; default: siloName = "Secondary_" + instanceCount.ToString(CultureInfo.InvariantCulture); break; } NodeConfiguration nodeConfig = config.GetOrCreateNodeConfigurationForSilo(siloName); nodeConfig.HostNameOrIPAddress = "loopback"; nodeConfig.Port = basePort + instanceCount; nodeConfig.DefaultTraceLevel = config.Defaults.DefaultTraceLevel; nodeConfig.PropagateActivityId = config.Defaults.PropagateActivityId; nodeConfig.BulkMessageLimit = config.Defaults.BulkMessageLimit; int?gatewayport = null; if (nodeConfig.ProxyGatewayEndpoint != null && nodeConfig.ProxyGatewayEndpoint.Address != null) { gatewayport = (options.ProxyBasePort < 0 ? ProxyBasePort : options.ProxyBasePort) + instanceCount; nodeConfig.ProxyGatewayEndpoint = new IPEndPoint(nodeConfig.ProxyGatewayEndpoint.Address, gatewayport.Value); } config.Globals.ExpectedClusterSize = 2; config.Overrides[siloName] = nodeConfig; AdjustForTest(config, options); WriteLog("Starting a new silo in app domain {0} with config {1}", siloName, config.ToString(siloName)); return(AppDomainSiloHandle.Create(siloName, type, config, nodeConfig, host.additionalAssemblies)); }
public HostedTestClusterEnsureDefaultStarted(DefaultClusterFixture fixture) { this.HostedCluster = fixture.HostedCluster; }
// This is a static version that can be called without a TestingSiloHost object (host = null) public static SiloHandle StartOrleansSilo(TestingSiloHost host, Silo.SiloType type, TestingSiloOptions options, int instanceCount, AppDomain shared = null) { // Load initial config settings, then apply some overrides below. ClusterConfiguration config = new ClusterConfiguration(); if (options.SiloConfigFile == null) { config.StandardLoad(); } else { config.LoadFromFile(options.SiloConfigFile.FullName); } int basePort = options.BasePort < 0 ? BasePort : options.BasePort; if (config.Globals.SeedNodes.Count > 0 && options.BasePort < 0) { config.PrimaryNode = config.Globals.SeedNodes[0]; } else { config.PrimaryNode = new IPEndPoint(IPAddress.Loopback, basePort); } config.Globals.SeedNodes.Clear(); config.Globals.SeedNodes.Add(config.PrimaryNode); if (!String.IsNullOrEmpty(DeploymentId)) { config.Globals.DeploymentId = DeploymentId; } config.Defaults.PropagateActivityId = options.PropagateActivityId; if (options.LargeMessageWarningThreshold > 0) { config.Defaults.LargeMessageWarningThreshold = options.LargeMessageWarningThreshold; } config.Globals.LivenessType = options.LivenessType; config.Globals.ReminderServiceType = options.ReminderServiceType; if (!String.IsNullOrEmpty(options.DataConnectionString)) { config.Globals.DataConnectionString = options.DataConnectionString; } _livenessStabilizationTime = GetLivenessStabilizationTime(config.Globals); if (host != null) { host.Globals = config.Globals; } string siloName; switch (type) { case Silo.SiloType.Primary: siloName = "Primary"; break; default: siloName = "Secondary_" + instanceCount.ToString(CultureInfo.InvariantCulture); break; } NodeConfiguration nodeConfig = config.GetConfigurationForNode(siloName); nodeConfig.HostNameOrIPAddress = "loopback"; nodeConfig.Port = basePort + instanceCount; nodeConfig.DefaultTraceLevel = config.Defaults.DefaultTraceLevel; nodeConfig.PropagateActivityId = config.Defaults.PropagateActivityId; nodeConfig.BulkMessageLimit = config.Defaults.BulkMessageLimit; if (nodeConfig.ProxyGatewayEndpoint != null && nodeConfig.ProxyGatewayEndpoint.Address != null) { int proxyBasePort = options.ProxyBasePort < 0 ? ProxyBasePort : options.ProxyBasePort; nodeConfig.ProxyGatewayEndpoint = new IPEndPoint(nodeConfig.ProxyGatewayEndpoint.Address, proxyBasePort + instanceCount); } config.Globals.ExpectedClusterSize = 2; config.Overrides[siloName] = nodeConfig; AdjustForTest(config, options); WriteLog("Starting a new silo in app domain {0} with config {1}", siloName, config.ToString(siloName)); AppDomain appDomain; Silo silo = LoadSiloInNewAppDomain(siloName, type, config, out appDomain); silo.Start(); SiloHandle retValue = new SiloHandle { Name = siloName, Silo = silo, Options = options, Endpoint = silo.SiloAddress.Endpoint, AppDomain = appDomain, }; ImportGeneratedAssemblies(retValue); return(retValue); }
public Base_PersistenceGrainTests_AWSStore(ITestOutputHelper output, BaseClusterFixture fixture) { this.output = output; HostedCluster = fixture.HostedCluster; timingFactor = TestUtils.CalibrateTimings(); }
/// <summary> /// Start a new silo in the target cluster /// </summary> /// <param name="host">The target cluster</param> /// <param name="type">The type of the silo to deploy</param> /// <param name="options">The options to use for the silo</param> /// <param name="instanceCount">The instance count of the silo</param> /// <param name="shared">The shared AppDomain to use</param> /// <returns>A handle to the deployed silo</returns> public static SiloHandle StartOrleansSilo(TestingSiloHost host, Silo.SiloType type, TestingSiloOptions options, int instanceCount, AppDomain shared = null) { if (host == null) throw new ArgumentNullException("host"); // Load initial config settings, then apply some overrides below. ClusterConfiguration config = new ClusterConfiguration(); try { if (options.SiloConfigFile == null) { config.StandardLoad(); } else { config.LoadFromFile(options.SiloConfigFile.FullName); } } catch (FileNotFoundException) { if (options.SiloConfigFile != null && !string.Equals(options.SiloConfigFile.Name, TestingSiloOptions.DEFAULT_SILO_CONFIG_FILE, StringComparison.InvariantCultureIgnoreCase)) { // if the user is not using the defaults, then throw because the file was legitimally not found throw; } config = ClusterConfiguration.LocalhostPrimarySilo(); config.AddMemoryStorageProvider("Default"); config.AddMemoryStorageProvider("MemoryStore"); } int basePort = options.BasePort < 0 ? BasePort : options.BasePort; if (config.Globals.SeedNodes.Count > 0 && options.BasePort < 0) { config.PrimaryNode = config.Globals.SeedNodes[0]; } else { config.PrimaryNode = new IPEndPoint(IPAddress.Loopback, basePort); } config.Globals.SeedNodes.Clear(); config.Globals.SeedNodes.Add(config.PrimaryNode); if (!String.IsNullOrEmpty(host.DeploymentId)) { config.Globals.DeploymentId = host.DeploymentId; } config.Defaults.PropagateActivityId = options.PropagateActivityId; if (options.LargeMessageWarningThreshold > 0) { config.Defaults.LargeMessageWarningThreshold = options.LargeMessageWarningThreshold; } config.Globals.LivenessType = options.LivenessType; config.Globals.ReminderServiceType = options.ReminderServiceType; if (!String.IsNullOrEmpty(options.DataConnectionString)) { config.Globals.DataConnectionString = options.DataConnectionString; } host.Globals = config.Globals; string siloName; switch (type) { case Silo.SiloType.Primary: siloName = "Primary"; break; default: siloName = "Secondary_" + instanceCount.ToString(CultureInfo.InvariantCulture); break; } NodeConfiguration nodeConfig = config.GetOrCreateNodeConfigurationForSilo(siloName); nodeConfig.HostNameOrIPAddress = "loopback"; nodeConfig.Port = basePort + instanceCount; nodeConfig.DefaultTraceLevel = config.Defaults.DefaultTraceLevel; nodeConfig.PropagateActivityId = config.Defaults.PropagateActivityId; nodeConfig.BulkMessageLimit = config.Defaults.BulkMessageLimit; int? gatewayport = null; if (nodeConfig.ProxyGatewayEndpoint != null && nodeConfig.ProxyGatewayEndpoint.Address != null) { gatewayport = (options.ProxyBasePort < 0 ? ProxyBasePort : options.ProxyBasePort) + instanceCount; nodeConfig.ProxyGatewayEndpoint = new IPEndPoint(nodeConfig.ProxyGatewayEndpoint.Address, gatewayport.Value); } config.Globals.ExpectedClusterSize = 2; config.Overrides[siloName] = nodeConfig; AdjustForTest(config, options); WriteLog("Starting a new silo in app domain {0} with config {1}", siloName, config.ToString(siloName)); AppDomain appDomain; Silo silo = host.LoadSiloInNewAppDomain(siloName, type, config, out appDomain); silo.Start(); SiloHandle retValue = new SiloHandle { Name = siloName, Silo = silo, Options = options, Endpoint = silo.SiloAddress.Endpoint, GatewayPort = gatewayport, AppDomain = appDomain, }; host.ImportGeneratedAssemblies(retValue); return retValue; }
public HostedTestClusterPerTest() { this.HostedCluster = this.CreateSiloHost(); }
protected BaseClusterFixture(TestingSiloHost hostedCluster) { this.HostedCluster = hostedCluster; }
public HostedTestClusterPerTest() { GrainClient.Uninitialize(); SerializationManager.InitializeForTesting(); this.HostedCluster = this.CreateSiloHost(); }
public void InitializeOrleansHost() { TestingSiloHost.StopAllSilosIfRunning(); var siloHostFactory = IsolatedHostedTestClusterUtils.FindTestingSiloHostFactory(this); this.HostedCluster = siloHostFactory.Invoke(); }