예제 #1
0
파일: main.cs 프로젝트: Davincier/openpetra
        /// <summary>
        /// Executes the tests (main method of this executable!).
        /// </summary>
        public static void RunTest()
        {
            XmlNode startNode;
            XmlNode curGroup;
            Thread groupThread;
            TestGroup myGroup;
            String testcase;

            new TAppSettingsManager(true);

            testcase = TAppSettingsManager.GetValue("testcase");
            Global.StartClientID = TAppSettingsManager.GetInt16("startclientid");

            rnd = new System.Random(DateTime.Now.Millisecond);     // Init

            try
            {
                parser = new TXMLParser(TAppSettingsManager.GetValue("testscript"), false);
                startNode = parser.GetDocument().DocumentElement;
            }
            catch (Exception E)
            {
                System.Console.WriteLine("{0}: trouble in RunTest", DateTime.Now.ToLongTimeString());
                System.Console.WriteLine("{0}: {1}", DateTime.Now.ToLongTimeString(), E.Message);

                return;
            }

            new TLogging(@"..\..\log\PetraMultiStart.log");

//            TheConnector = new Ict.Petra.ServerAdmin.App.Core.Connector.TConnector();
//            TheConnector.GetServerConnection(TAppSettingsManager.ConfigFileName, out TRemote);

            TRemote = new TMServerAdminNamespace().WebConnectors;

            CreateTestUsers();

            if (startNode.Name.ToLower() == "tests")
            {
                startNode = startNode.FirstChild;

                while ((startNode != null) && (startNode.Name.ToLower() == "test") && (TXMLParser.GetAttribute(startNode, "name") != testcase))
                {
                    startNode = startNode.NextSibling;
                }
            }

            if (startNode == null)
            {
                Console.WriteLine("{0}: cannot find testcase {1}", DateTime.Now.ToLongTimeString(), testcase);

                return;
            }

            while (true)
            {
                // restart the whole test scenario

                if (startNode.Name.ToLower() == "test")
                {
                    Global.Filename = TXMLParser.GetAttribute(startNode, "app");

                    // kill instances of previous test
                    KillAllProcesses(Global.Filename.Substring(0, Global.Filename.IndexOf('.')));

                    Global.Configfile = TXMLParser.GetAttribute(startNode, "config");
                    curGroup = startNode.FirstChild;

                    while ((curGroup != null) && (curGroup.Name == "clientgroup"))
                    {
                        if (TXMLParser.GetBoolAttribute(curGroup, "active", true) != false)
                        {
                            myGroup = new TestGroup(curGroup);
                            groupThread = new Thread(myGroup.Run);
                            groupThread.Start();
                        }

                        curGroup = curGroup.NextSibling;
                    }
                }

                Thread.CurrentThread.Join();
                System.Console.WriteLine("{0}: All threads have stopped", DateTime.Now.ToLongTimeString());

                if (TXMLParser.GetBoolAttribute(startNode, "loop", true) == false)
                {
                    return;
                }

                Thread.Sleep(5 * 60 * 1000);

                // wait for 5 minutes before restarting
            }
        }
예제 #2
0
파일: main.cs 프로젝트: petes05/openpetra
        /// <summary>
        /// Executes the tests (main method of this executable!).
        /// </summary>
        public static void RunTest()
        {
            XmlNode   startNode;
            XmlNode   curGroup;
            Thread    groupThread;
            TestGroup myGroup;
            String    testcase;

            new TAppSettingsManager(true);

            testcase             = TAppSettingsManager.GetValue("testcase");
            Global.StartClientID = TAppSettingsManager.GetInt16("startclientid");

            rnd = new System.Random(DateTime.Now.Millisecond); // Init

            try
            {
                parser    = new TXMLParser(TAppSettingsManager.GetValue("testscript"), false);
                startNode = parser.GetDocument().DocumentElement;
            }
            catch (Exception E)
            {
                System.Console.WriteLine("{0}: trouble in RunTest", DateTime.Now.ToLongTimeString());
                System.Console.WriteLine("{0}: {1}", DateTime.Now.ToLongTimeString(), E.Message);

                return;
            }

            new TLogging(@"..\..\log\PetraMultiStart.log");

            TheConnector = new Ict.Petra.ServerAdmin.App.Core.TConnector();
            TheConnector.GetServerConnection(TAppSettingsManager.ConfigFileName, out TRemote);

            CreateTestUsers();

            if (startNode.Name.ToLower() == "tests")
            {
                startNode = startNode.FirstChild;

                while ((startNode != null) && (startNode.Name.ToLower() == "test") && (TXMLParser.GetAttribute(startNode, "name") != testcase))
                {
                    startNode = startNode.NextSibling;
                }
            }

            if (startNode == null)
            {
                Console.WriteLine("{0}: cannot find testcase {1}", DateTime.Now.ToLongTimeString(), testcase);

                return;
            }

            while (true)
            {
                // restart the whole test scenario

                if (startNode.Name.ToLower() == "test")
                {
                    Global.Filename = TXMLParser.GetAttribute(startNode, "app");

                    // kill instances of previous test
                    KillAllProcesses(Global.Filename.Substring(0, Global.Filename.IndexOf('.')));

                    Global.Configfile = TXMLParser.GetAttribute(startNode, "config");
                    curGroup          = startNode.FirstChild;

                    while ((curGroup != null) && (curGroup.Name == "clientgroup"))
                    {
                        if (TXMLParser.GetBoolAttribute(curGroup, "active", true) != false)
                        {
                            myGroup     = new TestGroup(curGroup);
                            groupThread = new Thread(myGroup.Run);
                            groupThread.Start();
                        }

                        curGroup = curGroup.NextSibling;
                    }
                }

                Thread.CurrentThread.Join();
                System.Console.WriteLine("{0}: All threads have stopped", DateTime.Now.ToLongTimeString());

                if (TXMLParser.GetBoolAttribute(startNode, "loop", true) == false)
                {
                    return;
                }

                Thread.Sleep(5 * 60 * 1000);

                // wait for 5 minutes before restarting
            }
        }