public TestResults GetParallelTestFailover(string datatype, int testLoad) { TestResults testResult = new TestResults(testLoad); if (!sentinelConfigHelper.IsConfigValid()) { testResult.TestStatus = "Sentinel is not configured OK. Test failed."; return(testResult); } Thread[] clientThreads = new Thread[sentinelConfiguration.ParallelClientCount]; ITest[] testHelpers = new BasicTestHelper[sentinelConfiguration.ParallelClientCount]; var connection = sentinelConfigHelper.GetRDBConnection(); // Start thread that will shutdown master at some point var masterFailThread = new Thread(() => TestHelper.SimulateMasterFail(sentinelConfigHelper, testLoad)); masterFailThread.Start(); for (int i = 0; i < sentinelConfiguration.ParallelClientCount; i++) { var clientConfigurationHelper = new SentinelConfigurationHelper(sentinelConfiguration); testHelpers[i] = TestHelper.GetTestBasedOnDatatype(datatype, clientConfigurationHelper); if (testHelpers[i] == null) { testResult = new TestResults("Unknown redis data type."); } else { var test = testHelpers[i]; clientThreads[i] = new Thread(() => test.RunParallelTest(testResult)); clientThreads[i].Start(); testResult.TestStatus = "Successfull test. Test performed by one client."; } } for (int i = 0; i < sentinelConfiguration.ParallelClientCount; i++) { clientThreads[i].Join(); } TestHelper.AvrageOutResult(testResult, sentinelConfiguration.ParallelClientCount); testResult.TestStatus = string.Format("Parallel test successfull. Parallel client count: {0}. Total test load: {1}. Results are avraged out per client.", sentinelConfiguration.ParallelClientCount, sentinelConfiguration.ParallelClientCount * testLoad); return(testResult); }
public TestResults MultipleClientsTest(string datatype, int testLoad) { TestResults testResult = new TestResults(testLoad); if (!clusterConfigHelper.IsConfigValid()) { testResult.TestStatus = "Sentinel is not configured OK. Test failed."; return(testResult); } Thread[] clientThreads = new Thread[clusterConfiguration.ParallelClientCount]; ITest[] testHelpers = new BasicTestHelper[clusterConfiguration.ParallelClientCount]; for (int i = 0; i < clusterConfiguration.ParallelClientCount; i++) { var clientConfigurationHelper = new ClusterConfigurationHelper(clusterConfiguration); testHelpers[i] = TestHelper.GetTestBasedOnDatatype(datatype, clientConfigurationHelper); if (testHelpers[i] == null) { testResult = new TestResults("Unknown redis data type."); } else { var test = testHelpers[i]; clientThreads[i] = new Thread(() => test.RunParallelTest(testResult)); clientThreads[i].Start(); testResult.TestStatus = "Successfull test. Test performed by one client."; } } for (int i = 0; i < clusterConfiguration.ParallelClientCount; i++) { clientThreads[i].Join(); } TestHelper.AvrageOutResult(testResult, clusterConfiguration.ParallelClientCount); testResult.TestStatus = string.Format("Parallel test successfull. Parallel client count: {0}. Total test load: {1}. Results are avraged out per client.", clusterConfiguration.ParallelClientCount, clusterConfiguration.ParallelClientCount * testLoad); return(testResult); }