EmptyAll() public method

public EmptyAll ( ) : void
return void
Ejemplo n.º 1
0
        //[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());
        }
Ejemplo n.º 2
0
        //[TestMethod]
        public void MultiClusterTest_10_Threads()
        {
            int init_users = 10000;
            int threadnum = 10;

            Users usr = new Users(Utils.GetConfigNodes());
            // TODO add another client
            usr.EmptyAll();
            usr.InsertUsers(init_users);

            Thread[] threads = new Thread[threadnum];
            for (int i = 0; i < threadnum; i++)
            {
                threads[i] = new Thread(new ParameterizedThreadStart(MultiClusterTestWorker));
                threads[i].Start(500);
            }

            for (int i = 0; i < threadnum; i++)
            {
                threads[i].Join();
            }

            while(usr.IterateClients())
                Assert.IsTrue(usr.IsConsistent());

            Assert.IsTrue(usr.ClientDBsAreSame(0, 1));
        }
Ejemplo n.º 3
0
        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());
        }
Ejemplo n.º 4
0
        public void SimpleTest()
        {
            Users usr = new Users(Utils.GetConfigNodes());
            usr.EmptyAll();

            usr.InsertUsers(1000);
            // bug ?
            long cnt = usr.CountUsers();
            usr.SubmitAll();
            usr.TestCycle(500);

            Assert.IsTrue(usr.IsConsistent());
        }
Ejemplo n.º 5
0
        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();
        }