protected override TestCluster CreateTestCluster() { var options = new TestClusterOptions(1); options.ClusterConfiguration.AddMemoryStorageProvider("Default"); options.ClusterConfiguration.AddMemoryStorageProvider("MemoryStore"); options.ClusterConfiguration.AddAzureTableStorageProvider("AzureStore"); options.ClusterConfiguration.AddAzureTableStorageProvider(); options.ClusterConfiguration.AddStateStorageBasedLogConsistencyProvider(); options.ClusterConfiguration.AddLogStorageBasedLogConsistencyProvider(); options.ClusterConfiguration.AddCustomStorageInterfaceBasedLogConsistencyProvider("CustomStorage"); options.ClusterConfiguration.AddCustomStorageInterfaceBasedLogConsistencyProvider("CustomStoragePrimaryCluster", "A"); options.UseSiloBuilderFactory <TestSiloBuilderFactory>(); return(new TestCluster(options)); }
protected override TestCluster CreateTestCluster() { var options = new TestClusterOptions(2); var settings = new Dictionary <string, string>(); // get initial settings from configs AdapterConfig.WriteProperties(settings); GeneratorConfig.WriteProperties(settings); // add queue balancer setting settings.Add(PersistentStreamProviderConfig.QUEUE_BALANCER_TYPE, StreamQueueBalancerType.DynamicClusterConfigDeploymentBalancer.ToString()); // add pub/sub settting settings.Add(PersistentStreamProviderConfig.STREAM_PUBSUB_TYPE, StreamPubSubType.ImplicitOnly.ToString()); // register stream provider options.ClusterConfiguration.Globals.RegisterStreamProvider <GeneratorStreamProvider>(StreamProviderName, settings); return(new TestCluster(options)); }
public override TestCluster CreateTestCluster() { // Define a cluster of 4, but deploy ony 2 to start. var options = new TestClusterOptions(4); options.ClusterConfiguration.AddMemoryStorageProvider("PubSubStore"); var persistentStreamProviderConfig = new PersistentStreamProviderConfig { SiloMaturityPeriod = SILO_IMMATURE_PERIOD, BalancerType = StreamQueueBalancerType.DynamicClusterConfigDeploymentBalancer, }; options.ClusterConfiguration.AddAzureQueueStreamProvider(adapterName, persistentStreamProviderConfig: persistentStreamProviderConfig); options.ClientConfiguration.Gateways = options.ClientConfiguration.Gateways.Take(1).ToList(); var host = new TestCluster(options); host.Deploy(new[] { Silo.PrimarySiloName, "Secondary_1" }); return(host); }
public override TestCluster CreateTestCluster() { TestUtils.CheckForAzureStorage(); var options = new TestClusterOptions(); options.ClusterConfiguration.AddMemoryStorageProvider("MemoryStore", numStorageGrains: 1); options.ClusterConfiguration.AddAzureTableStorageProvider("AzureStore", deleteOnClear: true); options.ClusterConfiguration.AddAzureTableStorageProvider("PubSubStore", deleteOnClear: true, useJsonFormat: false); options.ClusterConfiguration.AddSimpleMessageStreamProvider(SmsStreamProviderName, fireAndForgetDelivery: false); options.ClusterConfiguration.AddSimpleMessageStreamProvider("SMSProviderDoNotOptimizeForImmutableData", fireAndForgetDelivery: false, optimizeForImmutableData: false); options.ClusterConfiguration.AddAzureQueueStreamProvider(AzureQueueStreamProviderName); options.ClusterConfiguration.AddAzureQueueStreamProvider("AzureQueueProvider2"); return(new TestCluster(options)); }
protected override TestCluster CreateTestCluster() { var options = new TestClusterOptions(1); options.ClusterConfiguration.AddMemoryStorageProvider("Default"); options.ClusterConfiguration.AddMemoryStorageProvider("MemoryStore"); options.ClusterConfiguration.AddAzureTableStorageProvider("AzureStore"); options.ClusterConfiguration.AddAzureTableStorageProvider(); options.ClusterConfiguration.AddStateStorageBasedLogConsistencyProvider(); options.ClusterConfiguration.AddLogStorageBasedLogConsistencyProvider(); options.ClusterConfiguration.AddCustomStorageInterfaceBasedLogConsistencyProvider("CustomStorage"); options.ClusterConfiguration.AddCustomStorageInterfaceBasedLogConsistencyProvider("CustomStoragePrimaryCluster", "A"); options.ClusterConfiguration.ApplyToAllNodes(o => o.TraceLevelOverrides.Add(new Tuple <string, Severity>("LogViews", Severity.Verbose2))); return(new TestCluster(options)); }
protected override TestCluster CreateTestCluster() { Guid serviceId = Guid.NewGuid(); var options = new TestClusterOptions(initialSilosCount: 4); options.ClusterConfiguration.Globals.DataConnectionString = TestDefaultConfiguration.DataConnectionString; options.ClusterConfiguration.Globals.ServiceId = serviceId; options.ClusterConfiguration.Globals.MaxResendCount = 0; options.ClusterConfiguration.Globals.RegisterStorageProvider <UnitTests.StorageTests.MockStorageProvider>("test1"); options.ClusterConfiguration.Globals.RegisterStorageProvider <UnitTests.StorageTests.MockStorageProvider>("test2", new Dictionary <string, string> { { "Config1", "1" }, { "Config2", "2" } }); options.ClusterConfiguration.Globals.RegisterStorageProvider <UnitTests.StorageTests.ErrorInjectionStorageProvider>("ErrorInjector"); options.ClusterConfiguration.Globals.RegisterStorageProvider <UnitTests.StorageTests.MockStorageProvider>("lowercase"); options.ClusterConfiguration.AddMemoryStorageProvider("MemoryStore"); options.ClusterConfiguration.AddAzureBlobStorageProvider("AzureStore", options.ClusterConfiguration.Globals.DataConnectionString); options.ClusterConfiguration.AddAzureBlobStorageProvider("AzureStore1", options.ClusterConfiguration.Globals.DataConnectionString); options.ClusterConfiguration.AddAzureBlobStorageProvider("AzureStore2", options.ClusterConfiguration.Globals.DataConnectionString); options.ClusterConfiguration.AddAzureBlobStorageProvider("AzureStore3", options.ClusterConfiguration.Globals.DataConnectionString); options.ClusterConfiguration.Globals.RegisterStorageProvider <Orleans.Storage.ShardedStorageProvider>("ShardedAzureStore"); IProviderConfiguration providerConfig; if (options.ClusterConfiguration.Globals.TryGetProviderConfiguration("Orleans.Storage.ShardedStorageProvider", "ShardedAzureStore", out providerConfig)) { var providerCategoriess = options.ClusterConfiguration.Globals.ProviderConfigurations; var providers = providerCategoriess.SelectMany(o => o.Value.Providers); IProviderConfiguration provider1 = GetNamedProviderConfigForShardedProvider(providers, "AzureStore1"); IProviderConfiguration provider2 = GetNamedProviderConfigForShardedProvider(providers, "AzureStore2"); IProviderConfiguration provider3 = GetNamedProviderConfigForShardedProvider(providers, "AzureStore3"); providerConfig.AddChildConfiguration(provider1); providerConfig.AddChildConfiguration(provider2); providerConfig.AddChildConfiguration(provider3); } return(new TestCluster(options).UseSiloBuilderFactory <SiloBuilderFactory>().UseClientBuilderFactory(ClientBuilderFactory)); }
public override TestCluster CreateTestCluster() { var options = new TestClusterOptions(); //from the config files options.ClusterConfiguration.AddMemoryStorageProvider("MemoryStore", numStorageGrains: 1); options.ClusterConfiguration.AddSimpleMessageStreamProvider("SMSProvider", fireAndForgetDelivery: false); options.ClientConfiguration.AddSimpleMessageStreamProvider("SMSProvider", fireAndForgetDelivery: false); //previous silo creation options.ClusterConfiguration.Globals.DataConnectionString = AWSTestConstants.DefaultSQSConnectionString; options.ClientConfiguration.DataConnectionString = AWSTestConstants.DefaultSQSConnectionString; var streamConnectionString = new Dictionary <string, string> { { "DataConnectionString", AWSTestConstants.DefaultSQSConnectionString } }; options.ClientConfiguration.RegisterStreamProvider <SQSStreamProvider>("SQSProvider", streamConnectionString); options.ClusterConfiguration.Globals.RegisterStreamProvider <SQSStreamProvider>("SQSProvider", streamConnectionString); options.ClusterConfiguration.Globals.RegisterStreamProvider <SQSStreamProvider>("SQSProvider2", streamConnectionString); var storageConnectionString = new Dictionary <string, string> { { "DataConnectionString", $"Service={AWSTestConstants.Service}" }, { "DeleteStateOnClear", "true" } }; options.ClusterConfiguration.Globals.RegisterStorageProvider <DynamoDBStorageProvider>("DynamoDBStore", storageConnectionString); var storageConnectionString2 = new Dictionary <string, string> { { "DataConnectionString", $"Service={AWSTestConstants.Service}" }, { "DeleteStateOnClear", "true" }, { "UseJsonFormat", "true" } }; options.ClusterConfiguration.Globals.RegisterStorageProvider <DynamoDBStorageProvider>("PubSubStore", storageConnectionString2); return(new TestCluster(options)); }
private async Task DeactivateOnIdle_NonExistentActivation_Runner(int forwardCount) { var options = new TestClusterOptions(2); options.ClusterConfiguration.Globals.MaxForwardCount = forwardCount; options.ClusterConfiguration.Defaults.Generation = 13; // For this test we only want to talk to the primary options.ClientConfiguration.Gateways.RemoveAt(1); Initialize(options); ICollectionTestGrain grain = await PickGrain(); Assert.NotNull(grain); logger.Info("About to make a 1st GetAge() call."); TimeSpan age = await grain.GetAge(); logger.Info(age.ToString()); await grain.DeactivateSelf(); Thread.Sleep(3000); // ReSharper disable once PossibleNullReferenceException var thrownException = await Record.ExceptionAsync(() => grain.GetAge()); if (forwardCount != 0) { Assert.Null(thrownException); logger.Info("\nThe 1st call after DeactivateSelf has NOT thrown any exception as expected, since forwardCount is {0}.\n", forwardCount); } else { Assert.NotNull(thrownException); Assert.IsType <OrleansException>(thrownException); Assert.Contains("Non-existent activation", thrownException.Message); logger.Info("\nThe 1st call after DeactivateSelf has thrown Non-existent activation exception as expected, since forwardCount is {0}.\n", forwardCount); // Try sending agan now and see it was fixed. await grain.GetAge(); } }
public override TestCluster CreateTestCluster() { var deploymentId = Guid.NewGuid().ToString(); var streamConnectionString = new Dictionary <string, string> { { "DataConnectionString", StreamConnectionString }, { "DeploymentId", deploymentId } }; var options = new TestClusterOptions(2); options.ClusterConfiguration.AddMemoryStorageProvider("PubSubStore"); options.ClusterConfiguration.Globals.DeploymentId = deploymentId; options.ClientConfiguration.DeploymentId = deploymentId; options.ClientConfiguration.DataConnectionString = StreamConnectionString; options.ClusterConfiguration.Globals.DataConnectionString = StreamConnectionString; options.ClusterConfiguration.Globals.RegisterStreamProvider <SQSStreamProvider>(SQSStreamProviderName, streamConnectionString); options.ClientConfiguration.RegisterStreamProvider <SQSStreamProvider>(SQSStreamProviderName, streamConnectionString); return(new TestCluster(options)); }
protected override TestCluster CreateTestCluster() { var options = new TestClusterOptions(initialSilosCount: 4); options.ClusterConfiguration.AddMemoryStorageProvider("MemoryStore", numStorageGrains: 1); options.ClusterConfiguration.Globals.RegisterStorageProvider <UnitTests.StorageTests.ErrorInjectionStorageProvider>(PubSubStoreProviderName); options.ClusterConfiguration.AddSimpleMessageStreamProvider(StreamTestsConstants.SMS_STREAM_PROVIDER_NAME, fireAndForgetDelivery: false); options.ClusterConfiguration.Globals.MaxResendCount = 0; options.ClusterConfiguration.Globals.ResponseTimeout = TimeSpan.FromSeconds(30); options.ClientConfiguration.AddSimpleMessageStreamProvider(StreamTestsConstants.SMS_STREAM_PROVIDER_NAME, fireAndForgetDelivery: false); options.ClientConfiguration.ClientSenderBuckets = 8192; options.ClientConfiguration.ResponseTimeout = TimeSpan.FromSeconds(30); options.ClientConfiguration.MaxResendCount = 0; return(new TestCluster(options)); }
public void SiloInitializationIsRetryableTest() { var appDomain = CreateAppDomain(); appDomain.UnhandledException += (sender, args) => { throw new AggregateException("Exception from AppDomain", (Exception)args.ExceptionObject); }; try { var config = new TestClusterOptions(1).ClusterConfiguration; var originalLivenessType = config.Globals.LivenessType; var originalMembershipAssembly = config.Globals.MembershipTableAssembly; // Set a configuration which will cause an early initialization error. // Try initializing the cluster, verify that it fails. config.Globals.LivenessType = GlobalConfiguration.LivenessProviderType.Custom; config.Globals.MembershipTableAssembly = "NonExistentAssembly.jpg"; var siloHost = CreateSiloHost(appDomain, config); siloHost.InitializeOrleansSilo(); // Attempt to start the silo. Assert.ThrowsAny <Exception>(() => siloHost.StartOrleansSilo(catchExceptions: false)); siloHost.UnInitializeOrleansSilo(); // Reset the configuration to a valid configuration. config.Globals.LivenessType = originalLivenessType; config.Globals.MembershipTableAssembly = originalMembershipAssembly; // Starting a new cluster should succeed. siloHost = CreateSiloHost(appDomain, config); siloHost.InitializeOrleansSilo(); siloHost.StartOrleansSilo(catchExceptions: false); } finally { AppDomain.Unload(appDomain); } }
public override TestCluster CreateTestCluster() { var options = new TestClusterOptions(); options.ExtendedFallbackOptions.TraceToConsole = true; foreach (var item in dbNames) { string actualDBName = item.Value.ConnectionString; string dbName = item.Key; options.ClusterConfiguration.AddSimpleSQLStorageProvider(dbName, actualDBName, "true"); } //options.ClusterConfiguration.Globals.ClientDropTimeout = TimeSpan.FromSeconds(5); //options.ClusterConfiguration.Defaults.DefaultTraceLevel = Orleans.Runtime.Severity.Warning; //options.ClientConfiguration.DefaultTraceLevel = Orleans.Runtime.Severity.Warning; return(new TestCluster(options)); }
protected override TestCluster CreateTestCluster() { var options = new TestClusterOptions(initialSilosCount: 4); options.ClusterConfiguration.AddMemoryStorageProvider("MemoryStore", numStorageGrains: 1); options.ClusterConfiguration.AddAzureTableStorageProvider("AzureStore", deleteOnClear: true); options.ClusterConfiguration.AddAzureTableStorageProvider("PubSubStore", deleteOnClear: true, useJsonFormat: false); options.ClusterConfiguration.AddSimpleMessageStreamProvider(SmsStreamProviderName, fireAndForgetDelivery: false); options.ClusterConfiguration.AddSimpleMessageStreamProvider("SMSProviderDoNotOptimizeForImmutableData", fireAndForgetDelivery: false, optimizeForImmutableData: false); options.ClusterConfiguration.AddAzureQueueStreamProvider(AzureQueueStreamProviderName); options.ClusterConfiguration.AddAzureQueueStreamProvider("AzureQueueProvider2"); options.ClientConfiguration.AddSimpleMessageStreamProvider(SmsStreamProviderName, fireAndForgetDelivery: false); options.ClientConfiguration.AddAzureQueueStreamProvider(AzureQueueStreamProviderName); options.ClusterConfiguration.Globals.ServiceId = serviceId; return(new TestCluster(options)); }
public override TestCluster CreateTestCluster() { var options = new TestClusterOptions(initialSilosCount: 2); options.ClusterConfiguration.AddMemoryStorageProvider("MemoryStore"); options.ClusterConfiguration.AddAzureTableStorageProvider("AzureStore", deleteOnClear: true); options.ClusterConfiguration.AddAzureTableStorageProvider("PubSubStore", deleteOnClear: true, useJsonFormat: false); options.ClusterConfiguration.AddSimpleMessageStreamProvider(SmsStreamProviderName, fireAndForgetDelivery: false); options.ClusterConfiguration.AddAzureQueueStreamProvider(AzureQueueStreamProviderName); options.ClusterConfiguration.AddAzureQueueStreamProvider("AzureQueueProvider2"); options.ClusterConfiguration.Globals.MaxMessageBatchingSize = 100; options.ClientConfiguration.AddSimpleMessageStreamProvider(SmsStreamProviderName, fireAndForgetDelivery: false); options.ClientConfiguration.AddAzureQueueStreamProvider(AzureQueueStreamProviderName); return(new TestCluster(options)); }
protected override TestCluster CreateTestCluster() { if (AWSTestConstants.IsDynamoDbAvailable) { Guid serviceId = Guid.NewGuid(); string dataConnectionString = DataConnectionString; var options = new TestClusterOptions(initialSilosCount: 4); options.ClusterConfiguration.Globals.ServiceId = serviceId; options.ClusterConfiguration.Globals.DataConnectionString = dataConnectionString; options.ClusterConfiguration.Globals.MaxResendCount = 0; options.ClusterConfiguration.Globals.RegisterStorageProvider <UnitTests.StorageTests.MockStorageProvider>("test1"); options.ClusterConfiguration.Globals.RegisterStorageProvider <UnitTests.StorageTests.MockStorageProvider>("test2", new Dictionary <string, string> { { "Config1", "1" }, { "Config2", "2" } }); options.ClusterConfiguration.Globals.RegisterStorageProvider <UnitTests.StorageTests.ErrorInjectionStorageProvider>("ErrorInjector"); options.ClusterConfiguration.Globals.RegisterStorageProvider <UnitTests.StorageTests.MockStorageProvider>("lowercase"); options.ClusterConfiguration.AddMemoryStorageProvider("MemoryStore"); options.ClusterConfiguration.Globals.RegisterStorageProvider <DynamoDBStorageProvider>("DDBStore", new Dictionary <string, string> { { "DeleteStateOnClear", "true" }, { "DataConnectionString", dataConnectionString } }); options.ClusterConfiguration.Globals.RegisterStorageProvider <DynamoDBStorageProvider>("DDBStore1", new Dictionary <string, string> { { "DataConnectionString", dataConnectionString } }); options.ClusterConfiguration.Globals.RegisterStorageProvider <DynamoDBStorageProvider>("DDBStore2", new Dictionary <string, string> { { "DataConnectionString", dataConnectionString } }); options.ClusterConfiguration.Globals.RegisterStorageProvider <DynamoDBStorageProvider>("DDBStore3", new Dictionary <string, string> { { "DataConnectionString", dataConnectionString } }); return(new TestCluster(options)); } return(null); }
public UpgradeTests() { // Setup dll references // If test run from cmdlime if (Directory.Exists(AssemblyGrainsV1Build)) { assemblyGrainsV1Dir = new DirectoryInfo(AssemblyGrainsV1Build); assemblyGrainsV2Dir = new DirectoryInfo(AssemblyGrainsV2Build); } // If test run from VS else { // If not run from vnext if (Directory.Exists(AssemblyGrainsV1Vs)) { assemblyGrainsV1Dir = new DirectoryInfo(AssemblyGrainsV1Vs); assemblyGrainsV2Dir = new DirectoryInfo(AssemblyGrainsV2Vs); } else { // vnext var target = @"\net462"; assemblyGrainsV1Dir = new DirectoryInfo(@"..\" + AssemblyGrainsV1Vs + target); assemblyGrainsV2Dir = new DirectoryInfo(@"..\" + AssemblyGrainsV2Vs + target); } } this.options = new TestClusterOptions(2); options.ClusterConfiguration.Globals.AssumeHomogenousSilosForTesting = false; options.ClusterConfiguration.Globals.TypeMapRefreshInterval = refreshInterval; options.ClientConfiguration.Gateways.RemoveAt(1); // Only use primary gw waitDelay = TestCluster.GetLivenessStabilizationTime(options.ClusterConfiguration.Globals, false); StartSiloV1(); client = new ClientBuilder().UseConfiguration(options.ClientConfiguration).Build(); client.Connect().Wait(); }
public void TokenMap_Rebuild_With_Decommissioned_DC_Existing_RF() { // Create a 2dc:1node each cluster var clusterOptions = new TestClusterOptions(); clusterOptions.Dc2NodeLength = 1; var testCluster = TestClusterManager.CreateNew(1, clusterOptions); testCluster.Builder = Cluster.Builder().AddContactPoint("127.0.0.1").WithLoadBalancingPolicy(new DCAwareRoundRobinPolicy("dc1")); testCluster.Cluster = testCluster.Builder.Build(); testCluster.Session = testCluster.Cluster.Connect(); PolicyTestTools policyTestTools = new PolicyTestTools(); // Create a ks with RF = dc1:1, dc2:1 policyTestTools.CreateMultiDcSchema(testCluster.Session, 1, 1); policyTestTools.InitPreparedStatement(testCluster, 12, false, ConsistencyLevel.All); // Replicas now in each node in each dc policyTestTools.Query(testCluster, 12, false); policyTestTools.AssertQueried(testCluster.ClusterIpPrefix + "1:" + DefaultCassandraPort, 12); policyTestTools.AssertQueried(testCluster.ClusterIpPrefix + "2:" + DefaultCassandraPort, 0); testCluster.Cluster.Shutdown(); testCluster.DecommissionNode(1); // dc1 no longer has any hosts testCluster.Builder = Cluster.Builder().AddContactPoint("127.0.0.2").WithLoadBalancingPolicy(new DCAwareRoundRobinPolicy("dc2")); testCluster.Cluster = testCluster.Builder.Build(); // Should be able to connect and rebuild token map testCluster.Session = testCluster.Cluster.Connect(policyTestTools.DefaultKeyspace); policyTestTools.ResetCoordinators(); policyTestTools.Query(testCluster, 12, false); policyTestTools.AssertQueried(testCluster.ClusterIpPrefix + "1:" + DefaultCassandraPort, 0); policyTestTools.AssertQueried(testCluster.ClusterIpPrefix + "2:" + DefaultCassandraPort, 12); testCluster.Cluster.Shutdown(); }
protected override TestCluster CreateTestCluster() { var options = new TestClusterOptions(); // we use a slowed-down memory storage provider options.ClusterConfiguration.AddMemoryStorageProvider("Default"); options.ClusterConfiguration.AddMemoryStorageProvider("MemoryStore"); options.ClusterConfiguration.AddFaultyMemoryStorageProvider("SlowMemoryStore", 10, 15); // log consistency providers are used to configure journaled grains options.ClusterConfiguration.AddLogStorageBasedLogConsistencyProvider("LogStorage"); options.ClusterConfiguration.AddStateStorageBasedLogConsistencyProvider("StateStorage"); // we turn on extra logging to see more tracing from the log consistency providers foreach (var o in options.ClusterConfiguration.Overrides) { o.Value.TraceLevelOverrides.Add(new Tuple <string, Severity>("Storage.MemoryStorage", Severity.Verbose)); o.Value.TraceLevelOverrides.Add(new Tuple <string, Severity>("LogViews", Severity.Verbose)); } return(new TestCluster(options)); }
public override TestCluster CreateTestCluster() { TestUtils.CheckForAzureStorage(); this.numExpectedSilos = 2; var options = new TestClusterOptions(initialSilosCount: (short)this.numExpectedSilos); options.ClusterConfiguration.AddMemoryStorageProvider("MemoryStore", numStorageGrains: 1); options.ClusterConfiguration.AddAzureTableStorageProvider("AzureStore", deleteOnClear: true); options.ClusterConfiguration.AddAzureTableStorageProvider("PubSubStore", deleteOnClear: true, useJsonFormat: false); options.ClusterConfiguration.AddSimpleMessageStreamProvider(SMS_STREAM_PROVIDER_NAME, fireAndForgetDelivery: false); options.ClusterConfiguration.AddAzureQueueStreamProvider(AZURE_QUEUE_STREAM_PROVIDER_NAME); options.ClusterConfiguration.AddAzureQueueStreamProvider("AzureQueueProvider2"); options.ClusterConfiguration.Globals.ServiceId = Guid.NewGuid(); options.ClientConfiguration.AddSimpleMessageStreamProvider(SMS_STREAM_PROVIDER_NAME, fireAndForgetDelivery: false); options.ClientConfiguration.AddAzureQueueStreamProvider(AZURE_QUEUE_STREAM_PROVIDER_NAME); return(new TestCluster(options).UseSiloBuilderFactory <SiloBuilderFactory>().UseClientBuilderFactory(clientBuilderFactory)); }
public static TestClusterOptions CreateClusterOptions() { var options = new TestClusterOptions(2); options.ClusterConfiguration.Globals.UseLivenessGossip = false; options.ClusterConfiguration.Globals.RegisterStorageProvider <MemoryStorage>("PubSubStore"); options.ClusterConfiguration.Globals.RegisterStreamProvider <RabbitMqStreamProvider>(Globals.StreamProviderName, new Dictionary <string, string> { { "HostName", "localhost" }, { "Port", ToxiProxyHelpers.RmqProxyPort.ToString() }, { "VirtualHost", "/" }, { "UserName", "guest" }, { "Password", "guest" }, { "GetQueueMessagesTimerPeriod", "100ms" }, { "QueueNamePrefix", "test" }, { "NumberOfQueues", "1" }, { "CacheSize", "100" }, { PersistentStreamProviderConfig.STREAM_PUBSUB_TYPE, StreamPubSubType.ImplicitOnly.ToString() } }); return(options); }
public void NewCluster(string clusterId, short numSilos, Action <ClusterConfiguration> customizer = null) { TestCluster testCluster; lock (Clusters) { var myCount = Clusters.Count; WriteLog("Starting Cluster {0} ({1})...", myCount, clusterId); var options = new TestClusterOptions(initialSilosCount: numSilos) { BaseSiloPort = GetPortBase(myCount), BaseGatewayPort = GetProxyBase(myCount) }; options.ClusterConfiguration.AddMemoryStorageProvider("Default"); options.ClusterConfiguration.AddMemoryStorageProvider("MemoryStore"); options.UseSiloBuilderFactory <TestSiloBuilderFactory>(); customizer?.Invoke(options.ClusterConfiguration); testCluster = new TestCluster(options.ClusterConfiguration, null); testCluster.Deploy(); Clusters[clusterId] = new ClusterInfo { Cluster = testCluster, SequenceNumber = myCount }; if (myCount == 0) { gossipStabilizationTime = GetGossipStabilizationTime(options.ClusterConfiguration.Globals); } WriteLog("Cluster {0} started. [{1}]", clusterId, string.Join(" ", testCluster.GetActiveSilos().Select(s => s.ToString()))); } }
public override TestCluster CreateTestCluster() { if (!GoogleTestUtils.IsPubSubSimulatorAvailable.Value) { throw new SkipException("Google PubSub Simulator not available"); } var providerSettings = new Dictionary <string, string> { { "ProjectId", GoogleTestUtils.ProjectId }, { "TopicId", GoogleTestUtils.TopicId }, { "DeploymentId", GoogleTestUtils.DeploymentId.ToString() }, { "Deadline", "600" }, //{ "CustomEndpoint", "localhost:8085" } }; var options = new TestClusterOptions(2); options.ClusterConfiguration.AddMemoryStorageProvider("PubSubStore"); options.ClusterConfiguration.Globals.RegisterStreamProvider <PubSubStreamProvider>(PROVIDER_NAME, providerSettings); options.ClusterConfiguration.Globals.ClientDropTimeout = TimeSpan.FromSeconds(5); options.ClientConfiguration.RegisterStreamProvider <PubSubStreamProvider>(PROVIDER_NAME, providerSettings); return(new TestCluster(options)); }
protected override TestCluster CreateTestCluster() { var options = new TestClusterOptions(1); return(new TestCluster(options)); }
protected SharedClusterTest(int amountOfNodes = 1, bool createSession = true, TestClusterOptions options = null) { AmountOfNodes = amountOfNodes; KeyspaceName = TestUtils.GetUniqueKeyspaceName().ToLowerInvariant(); CreateSession = createSession; Options = options; }
protected override bool IsSimilarCluster(ITestCluster reusableInstance, TestClusterOptions options, int nodeLength) { return(reusableInstance is CloudCluster c && c.SniCertificateValidation == _sniCertValidation); }
protected override ITestCluster CreateNew(int nodeLength, TestClusterOptions options, bool startCluster) { return(TestCloudClusterManager.CreateNew(_sniCertValidation)); }
protected SharedClusterTest(int amountOfNodes = 1, bool createSession = true, bool reuse = true, TestClusterOptions options = null) { //only reuse single node clusters _reuse = reuse && amountOfNodes == 1; AmountOfNodes = amountOfNodes; KeyspaceName = TestUtils.GetUniqueKeyspaceName().ToLowerInvariant(); CreateSession = createSession; Options = options; }
protected virtual ITestCluster CreateNew(int nodeLength, TestClusterOptions options, bool startCluster) { return(TestClusterManager.CreateNew(nodeLength, options, startCluster)); }
public void ShouldUseChildRetryPolicy_OnWriteTimeout() { const string keyspace = "idempotenceAwarepolicytestks"; var options = new TestClusterOptions { CassandraYaml = new[] { "phi_convict_threshold: 16" } }; var testCluster = TestClusterManager.CreateNew(2, options); using (var cluster = Cluster.Builder().AddContactPoint(testCluster.InitialContactPoint) .WithQueryTimeout(60000) .WithSocketOptions(new SocketOptions().SetConnectTimeoutMillis(30000)) .Build()) { var session = cluster.Connect(); var tableName = TestUtils.GetUniqueTableName(); session.DeleteKeyspaceIfExists(keyspace); session.Execute(string.Format(TestUtils.CreateKeyspaceSimpleFormat, keyspace, 2), ConsistencyLevel.All); session.ChangeKeyspace(keyspace); session.Execute(new SimpleStatement(string.Format("CREATE TABLE {0} (k int PRIMARY KEY, i int)", tableName)).SetConsistencyLevel(ConsistencyLevel.All)); testCluster.PauseNode(2); var testPolicy = new TestRetryPolicy(); var policy = new IdempotenceAwareRetryPolicy(testPolicy); try { session.Execute(new SimpleStatement(string.Format("INSERT INTO {0}(k, i) VALUES (0, 0)", tableName)) .SetIdempotence(true) .SetConsistencyLevel(ConsistencyLevel.All) .SetRetryPolicy(policy)); } catch (WriteTimeoutException) { //throws a WriteTimeoutException, as its set as an idempotent query, it will call the childPolicy Assert.AreEqual(0L, Interlocked.Read(ref testPolicy.ReadTimeoutCounter)); Assert.AreEqual(1L, Interlocked.Read(ref testPolicy.WriteTimeoutCounter)); Assert.AreEqual(0L, Interlocked.Read(ref testPolicy.UnavailableCounter)); } catch (UnavailableException) { Assert.AreEqual(0L, Interlocked.Read(ref testPolicy.ReadTimeoutCounter)); Assert.AreEqual(0L, Interlocked.Read(ref testPolicy.WriteTimeoutCounter)); Assert.AreEqual(1L, Interlocked.Read(ref testPolicy.UnavailableCounter)); } catch (Exception e) { Trace.TraceWarning(e.Message); } Interlocked.Exchange(ref testPolicy.UnavailableCounter, 0); Interlocked.Exchange(ref testPolicy.WriteTimeoutCounter, 0); Interlocked.Exchange(ref testPolicy.ReadTimeoutCounter, 0); //testing with unidempotent query try { session.Execute(new SimpleStatement(string.Format("INSERT INTO {0}(k, i) VALUES (0, 0)", tableName)) .SetIdempotence(false) .SetConsistencyLevel(ConsistencyLevel.All) .SetRetryPolicy(policy)); } catch (WriteTimeoutException) { //throws a WriteTimeoutException, as its set as NOT an idempotent query, it will not call the childPolicy Assert.AreEqual(0L, Interlocked.Read(ref testPolicy.ReadTimeoutCounter)); Assert.AreEqual(0L, Interlocked.Read(ref testPolicy.WriteTimeoutCounter)); Assert.AreEqual(0L, Interlocked.Read(ref testPolicy.UnavailableCounter)); } catch (UnavailableException) { Assert.AreEqual(0L, Interlocked.Read(ref testPolicy.ReadTimeoutCounter)); Assert.AreEqual(0L, Interlocked.Read(ref testPolicy.WriteTimeoutCounter)); Assert.AreEqual(1L, Interlocked.Read(ref testPolicy.UnavailableCounter)); } catch (Exception e) { Trace.TraceWarning(e.Message); } } testCluster.Remove(); }