public void Create(int nodeLength, TestClusterOptions options = null) { if (options == null) { options = TestClusterOptions.Default; } _ccm = new CcmBridge(Name, ClusterIpPrefix); _ccm.Create(_version, options.UseSsl); _ccm.Populate(nodeLength, options.Dc2NodeLength, options.UseVNodes); }
/// <summary> /// Creates a new test cluster /// </summary> public static ITestCluster CreateNew(int nodeLength = 1, TestClusterOptions options = null, bool startCluster = true) { TryRemove(); options = options ?? new TestClusterOptions(); var testCluster = new CcmCluster(CassandraVersionText, TestUtils.GetTestClusterNameBasedOnTime(), IpPrefix, DefaultKeyspaceName); testCluster.Create(nodeLength, options); if (startCluster) { testCluster.Start(options.JvmArgs); } return testCluster; }
private static ITestCluster CreateNewNoRetry(int nodeLength, TestClusterOptions options, bool startCluster) { TryRemove(); options = options ?? new TestClusterOptions(); var testCluster = new CcmCluster( TestUtils.GetTestClusterNameBasedOnRandomString(), IpPrefix, DsePath, Executor, DefaultKeyspaceName, IsDse ? DseVersionString : CassandraVersionString); testCluster.Create(nodeLength, options); if (startCluster) { testCluster.Start(options.JvmArgs); } return(testCluster); }
/// <summary> /// Creates a new test cluster /// </summary> public static ITestCluster CreateNew(int nodeLength = 1, TestClusterOptions options = null, bool startCluster = true) { TryRemove(); options = options ?? new TestClusterOptions(); var testCluster = new CcmCluster(CassandraVersionText, TestUtils.GetTestClusterNameBasedOnTime(), IpPrefix, DefaultKeyspaceName); testCluster.Create(nodeLength, options); if (startCluster) { try { testCluster.Start(options.JvmArgs); } catch (TestInfrastructureException) when(nodeLength >= 3 && TestHelper.IsWin) { // On Windows, ccm might timeout with 3 or more nodes, give it another chance testCluster.Start(options.JvmArgs); } } LastInstance = testCluster; return(testCluster); }
/// <summary> /// Creates a new test cluster /// </summary> public static ITestCluster CreateNew(int nodeLength = 1, TestClusterOptions options = null, bool startCluster = true) { const int maxAttempts = 2; var attemptsSoFar = 0; while (true) { try { return(CreateNewNoRetry(nodeLength, options, startCluster)); } catch (TestInfrastructureException ex) { attemptsSoFar++; if (attemptsSoFar >= maxAttempts) { throw; } Trace.WriteLine("Exception during ccm create / start. Retrying." + Environment.NewLine + ex.ToString()); } } }
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(); }