public static CcmBridge Create(string name, string localIpPrefix, int nodeCount, string cassandraVersion, bool startTheCluster = true, string[] jvmArgs = null, bool useSsl = false) { CcmBridge ccmBridge = new CcmBridge(name, localIpPrefix); string clusterStartStr = ""; if (startTheCluster) { clusterStartStr = "-s"; } var jvmArgsParams = ""; if (jvmArgs != null && jvmArgs.Length > 0) { jvmArgsParams = String.Join(" ", jvmArgs.Select(a => "--jvm_arg=" + a)); } var sslParams = ""; if (useSsl) { var sslPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "ssl"); if (!File.Exists(Path.Combine(sslPath, "keystore.jks"))) { throw new Exception(string.Format("In order to use SSL with CCM you must provide have the keystore.jks and cassandra.crt files located in your {0} folder", sslPath)); } sslParams = "--ssl " + sslPath; } ccmBridge.ExecuteCcm(string.Format("create {0} -n {1} {2} -i {3} -b -v {4} {5} {6}", name, nodeCount, clusterStartStr, localIpPrefix, cassandraVersion, jvmArgsParams, sslParams)); return(ccmBridge); }
public void Remove() { Trace.TraceInformation(string.Format("Removing Cluster with Name: '{0}', InitialContactPoint: {1}, and CcmDir: {2}", Name, InitialContactPoint, CcmBridge.CcmDir)); CcmBridge.SwitchToThis(); CcmBridge.Remove(); IsRemoved = true; }
public static CcmBridge Create(string name, string localIpPrefix, int nodeCount, string cassandraVersion, bool startTheCluster = true) { CcmBridge ccmBridge = new CcmBridge(name, localIpPrefix); string clusterStartStr = ""; if (startTheCluster) clusterStartStr = "-s"; ccmBridge.ExecuteCcm(string.Format("Create {0} -n {1} {2} -i {3} -b -v {4}", name, nodeCount, clusterStartStr, localIpPrefix, cassandraVersion)); return ccmBridge; }
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); }
public void UpdateConfig(params string[] yamlChanges) { if (yamlChanges == null) { return; } foreach (var setting in yamlChanges) { CcmBridge.ExecuteCcm($"updateconf \"{setting}\""); } }
public static CcmBridge Create(string name, string localIpPrefix, int nodeCountDc1, int nodeCountDc2, string cassandraVersion, bool startTheCluster = true, bool throwOnError = false) { CcmBridge ccmBridge = new CcmBridge(name, localIpPrefix); string clusterStartStr = ""; if (startTheCluster) { clusterStartStr = "-s"; } ccmBridge.ExecuteCcm(string.Format("Create {0} -n {1}:{2} {3} -i {4} -b -v {5}", name, nodeCountDc1, nodeCountDc2, clusterStartStr, localIpPrefix, cassandraVersion), DefaultCmdTimeout, throwOnError); return(ccmBridge); }
public static CcmBridge Create(string name, string localIpPrefix, int nodeCount, string cassandraVersion, bool startTheCluster = true) { CcmBridge ccmBridge = new CcmBridge(name, localIpPrefix); string clusterStartStr = ""; if (startTheCluster) { clusterStartStr = "-s"; } ccmBridge.ExecuteCcm(string.Format("Create {0} -n {1} {2} -i {3} -b -v {4}", name, nodeCount, clusterStartStr, localIpPrefix, cassandraVersion)); return(ccmBridge); }
public void UseVNodes(string nodesToPopulate) { try { CcmBridge.ExecuteCcm("remove"); } catch { //Don't mind } CcmBridge.ExecuteCcm(String.Format("create {0} -v {1}", CcmBridge.Name, _version)); CcmBridge.ExecuteCcm(String.Format("populate -n {0} -i {1} --vnodes", nodesToPopulate, CcmBridge.IpPrefix), CcmBridge.DefaultCmdTimeout, true); CcmBridge.ExecuteCcm("start", CcmBridge.DefaultCmdTimeout, true); }
/// <summary> /// Removes the current ccm cluster, without throwing exceptions if it fails /// </summary> public static void TryRemove() { try { CcmBridge.ExecuteCcm("remove"); } catch (Exception ex) { if (Diagnostics.CassandraTraceSwitch.Level == TraceLevel.Verbose) { Trace.TraceError("ccm test cluster could not be removed: {0}", ex); } } }
public void ShutDown() { if (!IsStarted) { return; } if (Cluster != null) { Cluster.Shutdown(); } CcmBridge.Stop(); IsStarted = false; }
public static CcmBridge Create(string name, string localIpPrefix, int nodeCount, string cassandraVersion, bool startTheCluster = true, string[] jvmArgs = null) { CcmBridge ccmBridge = new CcmBridge(name, localIpPrefix); string clusterStartStr = ""; if (startTheCluster) clusterStartStr = "-s"; var jvmArgsParams = ""; if (jvmArgs != null && jvmArgs.Length > 0) { jvmArgsParams = String.Join(" ", jvmArgs.Select(a => "--jvm_arg=" + a)); } ccmBridge.ExecuteCcm(string.Format("create {0} -n {1} {2} -i {3} -b -v {4} {5}", name, nodeCount, clusterStartStr, localIpPrefix, cassandraVersion, jvmArgsParams)); return ccmBridge; }
private static ProcessOutput ExecCommand(bool throwOnProcessError, string executable, string args, IReadOnlyDictionary <string, string> envVars = null, string workDir = null) { Trace.TraceInformation($"{executable} {args}"); var output = CcmBridge.ExecuteProcess(executable, args, timeout: 300000, envVariables: envVars, workDir: workDir); if (!throwOnProcessError) { return(output); } if (output.ExitCode != 0) { throw new TestInfrastructureException($"Process exited in error {output}"); } return(output); }
public void Create(int nodeLength, TestClusterOptions options = null) { _nodeLength = nodeLength; options = options ?? TestClusterOptions.Default; _ccm = new CcmBridge(Name, ClusterIpPrefix, DsePath, Version, _executor); _ccm.Create(options.UseSsl); _ccm.Populate(nodeLength, options.Dc2NodeLength, options.UseVNodes); _ccm.UpdateConfig(options.CassandraYaml); if (TestClusterManager.IsDse) { _ccm.UpdateDseConfig(options.DseYaml); _ccm.SetWorkloads(nodeLength, options.Workloads); } if (TestClusterManager.Executor is WslCcmProcessExecuter) { _ccm.UpdateConfig(new [] { "read_request_timeout_in_ms: 20000", "counter_write_request_timeout_in_ms: 20000", "write_request_timeout_in_ms: 20000", "request_timeout_in_ms: 20000", "range_request_timeout_in_ms: 30000" }); if (TestClusterManager.IsDse) { if (TestClusterManager.CheckDseVersion(new Version(6, 7), Comparison.LessThan)) { _ccm.UpdateConfig(new[] { "user_defined_function_fail_timeout: 20000" }); } else { _ccm.UpdateConfig(new[] { "user_defined_function_fail_micros: 20000" }); } } } }
public static void Setup(int nbNodesDC1, int nbNodesDC2, string ipPrefix, string cassandraVersion, string clusterName = "test") { if (nbNodesDC2 == 0) { if (nbNodesDC1 != NbNodesDC1) { Trace.TraceInformation("Cassandra:" + cassandraVersion); CCMBridge = CcmBridge.Create(clusterName, ipPrefix, nbNodesDC1, cassandraVersion); NbNodesDC1 = nbNodesDC1; NbNodesDC2 = 0; } } else { if (nbNodesDC1 != NbNodesDC1 || nbNodesDC2 != NbNodesDC2) { CCMBridge = CcmBridge.Create(clusterName, ipPrefix, nbNodesDC1, nbNodesDC2, cassandraVersion); NbNodesDC1 = nbNodesDC1; NbNodesDC2 = nbNodesDC2; } } }
public void Create(bool startTheCluster = true) { // if it's already being created in another thread, then wait until this step is complete if (!IsBeingCreated) { IsBeingCreated = true; if (Dc2NodeCount > 0) { CcmBridge = CcmBridge.Create(Name, ClusterIpPrefix, Dc1NodeCount, Dc2NodeCount, CassandraVersion.ToString(), startTheCluster); } else { CcmBridge = CcmBridge.Create(Name, ClusterIpPrefix, Dc1NodeCount, CassandraVersion.ToString(), startTheCluster); } IsBeingCreated = false; IsCreated = true; if (startTheCluster) { IsStarted = true; } } int sleepMs = 300; int sleepMsMax = 60000; int totalMsSlept = 0; while (IsBeingCreated || !IsCreated) { Trace.TraceInformation(string.Format("Cluster with name: {0}, CcmDir: {1} is being created. Sleeping another {2} MS ... ", Name, CcmBridge.CcmDir.FullName, sleepMs)); Thread.Sleep(sleepMs); totalMsSlept += sleepMs; if (totalMsSlept > sleepMsMax) { throw new Exception("Failed to create cluster in " + sleepMsMax + " MS!"); } } }
public static CcmBridge Create(string name, string localIpPrefix, int nodeCount, string cassandraVersion, bool startTheCluster = true, string[] jvmArgs = null, bool useSsl = false) { CcmBridge ccmBridge = new CcmBridge(name, localIpPrefix); string clusterStartStr = ""; if (startTheCluster) clusterStartStr = "-s"; var jvmArgsParams = ""; if (jvmArgs != null && jvmArgs.Length > 0) { jvmArgsParams = String.Join(" ", jvmArgs.Select(a => "--jvm_arg=" + a)); } var sslParams = ""; if (useSsl) { var sslPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "ssl"); if (!File.Exists(Path.Combine(sslPath, "keystore.jks"))) { throw new Exception(string.Format("In order to use SSL with CCM you must provide have the keystore.jks and cassandra.crt files located in your {0} folder", sslPath)); } sslParams = "--ssl " + sslPath; } ccmBridge.ExecuteCcm(string.Format("create {0} -n {1} {2} -i {3} -b -v {4} {5} {6}", name, nodeCount, clusterStartStr, localIpPrefix, cassandraVersion, jvmArgsParams, sslParams)); return ccmBridge; }
public void DecommissionNode(int nodeId) { CcmBridge.DecommissionNode(nodeId); }
/// <summary> /// Removes the current ccm cluster /// </summary> public static void Remove() { CcmBridge.ExecuteCcm("remove"); }
public void SwitchToThisCluster() { CcmBridge.SwitchToThis(); }
public void StopForce(int nodeIdToStop) { CcmBridge.StopForce(nodeIdToStop); }
public void ResumeNode(int nodeId) { CcmBridge.ExecuteCcm($"node{nodeId} resume"); }
public void Start(int nodeIdToStart, string additionalArgs = null) { CcmBridge.Start(nodeIdToStart, additionalArgs); }
public static CcmBridge Create(string name, string localIpPrefix, int nodeCountDc1, int nodeCountDc2, string cassandraVersion, bool startTheCluster = true, bool throwOnError = false) { CcmBridge ccmBridge = new CcmBridge(name, localIpPrefix); string clusterStartStr = ""; if (startTheCluster) clusterStartStr = "-s"; ccmBridge.ExecuteCcm(string.Format("create {0} -n {1}:{2} {3} -i {4} -b -v {5}", name, nodeCountDc1, nodeCountDc2, clusterStartStr, localIpPrefix, cassandraVersion), DefaultCmdTimeout, throwOnError); return ccmBridge; }
public void ResumeNode(int nodeId) { CcmBridge.ExecuteCcm(string.Format("node{0} resume", nodeId)); }
public void PauseNode(int nodeId) { CcmBridge.ExecuteCcm(string.Format("node{0} pause", nodeId)); }
public void BootstrapNode(int nodeIdToStart, string dataCenterName) { CcmBridge.BootstrapNode(nodeIdToStart, dataCenterName); }
public void Stop(int nodeIdToStop) { CcmBridge.Stop(nodeIdToStop); }
public void PauseNode(int nodeId) { CcmBridge.ExecuteCcm($"node{nodeId} pause"); }
public void BootstrapNode(int nodeIdToStart) { CcmBridge.BootstrapNode(nodeIdToStart); }
public void Start() { CcmBridge.Start(); IsStarted = true; }