//[TestMethod] public void ShortTest_1000_Threads() { int init_users = 1000; int threadnum = 1000; Users usr = new Users(Utils.GetConfigNodes()); usr.EmptyAll(); usr.InsertUsers(init_users); Utils.TestThreadConf threadConf = new Utils.TestThreadConf(); threadConf.param = 500; Thread[] threads = new Thread[threadnum]; for (int i = 0; i < threadnum; i++) { threads[i] = new Thread(new ParameterizedThreadStart(TestWorker)); threads[i].Start(threadConf); } for (int i = 0; i < threadnum; i++) { threads[i].Join(); } if (threadConf.exceptionsCatched.Count > 0) Assert.Fail("Exceptions catched in threads", threadConf); Console.WriteLine("Checking consistency"); Assert.IsTrue(usr.IsConsistent()); }
//[TestMethod] public void ShortTest_1000_Threads() { int init_users = 1000; int threadnum = 1000; Users usr = new Users(Utils.GetConfigNodes()); usr.EmptyAll(); usr.InsertUsers(init_users); Utils.TestThreadConf threadConf = new Utils.TestThreadConf(); threadConf.param = 500; Thread[] threads = new Thread[threadnum]; for (int i = 0; i < threadnum; i++) { threads[i] = new Thread(new ParameterizedThreadStart(TestWorker)); threads[i].Start(threadConf); } for (int i = 0; i < threadnum; i++) { threads[i].Join(); } if (threadConf.exceptionsCatched.Count > 0) { Assert.Fail("Exceptions catched in threads", threadConf); } Console.WriteLine("Checking consistency"); Assert.IsTrue(usr.IsConsistent()); }
public void ShortTest_100_Threads() { /*Client.SetTrace(true); * Client.SetLogFile("c:\\Users\\zszabo\\logs\\client_trace_100.txt");*/ int init_users = 50000; int threadnum = 100; /* * FileStream fs = new FileStream("c:\\Users\\zszabo\\logs\\threadout_100.txt", FileMode.Create); * StreamWriter sw = new StreamWriter(fs); * Console.SetOut(sw);*/ Users usr = new Users(Utils.GetConfigNodes()); usr.EmptyAll(); usr.InsertUsers(init_users); Utils.TestThreadConf threadConf = new Utils.TestThreadConf(); threadConf.param = 500; Thread[] threads = new Thread[threadnum]; for (int i = 0; i < threadnum; i++) { threads[i] = new Thread(new ParameterizedThreadStart(TestWorker)); threads[i].Start(threadConf); } for (int i = 0; i < threadnum; i++) { threads[i].Join(); } if (threadConf.exceptionsCatched.Count > 0) { Assert.Fail("Exceptions catched in threads", threadConf); } Console.WriteLine("Checking consistency"); Assert.IsTrue(usr.IsConsistent()); }
public void TestRandomSleep() { int init_users = 10000; int threadnum = 10; var nodes = Utils.GetConfigNodes(); Users usr = new Users(Utils.GetConfigNodes()); usr.EmptyAll(); usr.InsertUsers(init_users); Utils.TestThreadConf threadConf = new Utils.TestThreadConf(); threadConf.param = 500; Thread[] threads = new Thread[threadnum]; for (int i = 0; i < threadnum; i++) { threads[i] = new Thread(new ParameterizedThreadStart(TestWorker)); threads[i].Start(threadConf); } Thread killer = new Thread(new ParameterizedThreadStart(Killer)); killer.Start(new KillerConf(10000, KillMode.KILL_MAJORITY, 10, KillActionType.KILL_USING_SLEEP)); for (int i = 0; i < threadnum; i++) { threads[i].Join(); } if (threadConf.exceptionsCatched.Count > 0) { Assert.Fail("Exceptions catched in threads", threadConf); } Assert.IsTrue(usr.IsConsistent()); killer.Abort(); }
private static void TestWorker(Object param) { Utils.TestThreadConf conf = (Utils.TestThreadConf)param; int loop = System.Convert.ToInt32(conf.param); int users_per_iteration = 2; try { Users usr = new Users(Utils.GetConfigNodes()); while (loop-- > 0) { usr.TestCycle(users_per_iteration); } } catch (Exception e) { lock (conf.exceptionsCatched) { conf.exceptionsCatched.Add(e); } } }
public void ShortTest_100_Threads() { /*Client.SetTrace(true); Client.SetLogFile("c:\\Users\\zszabo\\logs\\client_trace_100.txt");*/ int init_users = 50000; int threadnum = 100; /* FileStream fs = new FileStream("c:\\Users\\zszabo\\logs\\threadout_100.txt", FileMode.Create); StreamWriter sw = new StreamWriter(fs); Console.SetOut(sw);*/ Users usr = new Users(Utils.GetConfigNodes()); usr.EmptyAll(); usr.InsertUsers(init_users); Utils.TestThreadConf threadConf = new Utils.TestThreadConf(); threadConf.param = 500; Thread[] threads = new Thread[threadnum]; for (int i = 0; i < threadnum; i++) { threads[i] = new Thread(new ParameterizedThreadStart(TestWorker)); threads[i].Start(threadConf); } for (int i = 0; i < threadnum; i++) { threads[i].Join(); } if (threadConf.exceptionsCatched.Count > 0) Assert.Fail("Exceptions catched in threads", threadConf); Console.WriteLine("Checking consistency"); Assert.IsTrue(usr.IsConsistent()); }
public void TestRandomSleep() { int init_users = 10000; int threadnum = 10; var nodes = Utils.GetConfigNodes(); Users usr = new Users(Utils.GetConfigNodes()); usr.EmptyAll(); usr.InsertUsers(init_users); Utils.TestThreadConf threadConf = new Utils.TestThreadConf(); threadConf.param = 500; Thread[] threads = new Thread[threadnum]; for (int i = 0; i < threadnum; i++) { threads[i] = new Thread(new ParameterizedThreadStart(TestWorker)); threads[i].Start(threadConf); } Thread killer = new Thread(new ParameterizedThreadStart(Killer)); killer.Start(new KillerConf(10000, KillMode.KILL_MAJORITY, 10, KillActionType.KILL_USING_SLEEP)); for (int i = 0; i < threadnum; i++) { threads[i].Join(); } if (threadConf.exceptionsCatched.Count > 0) Assert.Fail("Exceptions catched in threads", threadConf); Assert.IsTrue(usr.IsConsistent()); killer.Abort(); }