コード例 #1
0
        void caseRunTest(CommandData cmdData)
        {
            string path = "../../../THtemp/" + cmdData.testAuthor + "_" + cmdData.dateTime + "_" + cmdData.xmlFile;

            System.IO.FileStream xml = new System.IO.FileStream(path, System.IO.FileMode.Open);
            q.enQ(xml);
            if (startlocal() == true)//now the log file is prepared and we should send it to the repository now
            {
                IFileService fs = null; IFileService fs2 = null;
                int          count = 0;
                while (true)
                {
                    try
                    {
                        fs  = TestHarness.fileSender.CreateChannel(RepoFRcvr);
                        fs2 = TestHarness.fileSender.CreateChannel(cmdData.url + "/CFRcvr");
                        break;
                    }
                    catch
                    {
                        Console.Write("\n  connection to service failed {0} times - trying again", ++count);
                        Thread.Sleep(500);
                        continue;
                    }
                }
                Console.Write("\n  Connected to {0}\n", RepoFRcvr);
                string relativeFilePath = "../../../THtemp/";
                string filepath         = Path.GetFullPath(relativeFilePath);
                string file             = filepath + cmdData.testAuthor + "_" + cmdData.dateTime + ".txt";
                Console.Write("----------this is for requirement 7 and 8------------------\n  sending file {0} to the client({1}) and reposetory", file, cmdData.url); timer.Start();
                if (!fileSender.SendFile(fs, file))
                {
                    Console.Write("\n  could not send file"); timer.Stop();
                }
                else
                {
                    timer.Stop();
                    Console.WriteLine("\nsend file {0} success in {1} ", file, timer.ElapsedTimeSpan);
                }
                if (!fileSender.SendFile(fs2, file))
                {
                    Console.Write("\n  could not send file"); timer.Stop();
                }
                else
                {
                    timer.Stop();
                    Console.WriteLine("\nsend file {0} success in {1} ", file, timer.ElapsedTimeSpan);
                }
            }
        }
コード例 #2
0
        void ThreadProc()
        {
            while (true)
            {
                Message msg = inQ_.deQ();
                // Quit message so exit the thread and close the service.
                if (msg.body == "quit")
                {
                    Close();
                    break;
                }
                Console.Write("\n Client Child Thread Dequeued a new message \n");
                hrt.Stop();
                ulong  time      = hrt.ElapsedMicroseconds;
                double millitime = time / 1000.0;
                string timetaken = "Total time to get the response in milli seconds is " + millitime.ToString() + " - Req 12";
                timetaken.title();
                if (msg.from.Contains("Test"))
                {
                    Console.WriteLine("\nDisplaying the results of Test Request\n");
                }
                else
                {
                    Console.WriteLine("\nDisplaying the results of Query Logs\n");
                }

                msg.show();
                if (msg.from.Contains("Repo"))
                {
                    "Demonstarted that all Requirements from 2-10 are met - Req #13".title();
                }
            }
        }
コード例 #3
0
        public void SendLogToRepo(string threadName, string tempLogPath, MessageClient msgSenderRepo, MessageServer msgReciever)
        {
            int        trycount = 0;
            HiResTimer hrt      = new HiResTimer();

            while (trycount <= 5)
            {
                trycount++;
                Console.WriteLine("\n({0})Sending logs to repository...", threadName);
                Message msgToRepo = msgSenderRepo.SetupUploadMessageToRepo(threadName, tempLogPath, "http://localhost:4140/ICommService/BasicHttp", "http://localhost:8180/ICommService/BasicHttp");

                msgSenderRepo.channel.PostMessage(msgToRepo);
                Console.WriteLine("\n({0})Waiting for message from repository...", threadName);
                hrt.Start();
                Message msgFromRepo = msgReciever.TryGetMessage("Repository", threadName);
                hrt.Stop();
                Console.WriteLine("");
                Console.WriteLine("\n({0})Recieved message from repository in {0} microsec.", threadName, hrt.ElapsedMicroseconds);
                Console.WriteLine("");
                TestLoadStatus loadStat = msgReciever.Parse(msgFromRepo);
                Console.WriteLine(loadStat.loadMessage);
                if (loadStat.status)
                {
                    break;
                }
                if (trycount <= 5)
                {
                    Thread.Sleep(500);
                    continue;
                }
                throw new Exception("Failed sending logs to repository");
            }
        }
コード例 #4
0
 // uploads logs and test results to repo
 public void uploadFileToRepo(string filePath, string filename, ICommunicator repoChannel)
 {
     try
     {
         hrt.Start();
         using (var inputStream = new FileStream(filePath, FileMode.Open))
         {
             FileTransferMessage msg = new FileTransferMessage();
             msg.filename = filename;
             msg.transferStream = inputStream;
             repoChannel.upLoadFile(msg);
         }
         hrt.Stop();
         Console.Write("\n  Uploaded file \"{0}\" in {1} microsec.", filename, hrt.ElapsedMicroseconds);
     }
     catch (Exception e)
     {
         Console.Write("\n  can't find \"{0}\" exception {1}", filePath, e);
     }
 }
コード例 #5
0
        public void BuildMessage(string messagebody)
        {
            Console.WriteLine("The Message submitted to TestHarness is: ");
            Console.WriteLine(XMLMessage);

            ClientWPF cl1     = new ClientWPF();
            string    Repostr = "http://localhost:8080/RepoIService";



            Message msg = new Message();

            msg.body = messagebody;

            Console.WriteLine("The Message body which is being sent to TestHarness: ");
            Console.WriteLine(msg.body);
            string frommessage = "http://localhost:8080/ClientIService" + count++;

            //count++;
            msg.author = "Jashwanth";
            msg.to     = "TH";
            msg.from   = frommessage;
            cl1.CreateClientRecvChannel(msg.from);

            /* Send all the code to be tested to the Repository */
            string filepath = System.IO.Path.GetFullPath(cl1.ToSendPath);

            Console.WriteLine("\n  retrieving files from\n {0}\n", filepath);
            string[] files = Directory.GetFiles(filepath);
            hrt.Start();
            foreach (string file in files)
            {
                string filename = System.IO.Path.GetFileName(file);
                Console.WriteLine("\nfile retrieved is {0} \n", filename);
                cl1.uploadFile(filename, Repostr);
            }
            /* this sleep ensures that client copies code before  sending the request*/
            Thread.Sleep(10000);
            cl1.sendTestRequest(msg);
            hrt.Stop();
            ulong  time        = hrt.ElapsedMicroseconds;
            double millisecond = time / 1000.0;

            TimerTextBox.Text = millisecond.ToString() + "ms";
            string timetaken = "Total time to get the response in milli seconds is " + millisecond.ToString() + " - Req 12";

            timetaken.title();
            Thread.Sleep(20000);
        }
コード例 #6
0
        public void Phase2(string tempPath, string threadName, List <TestInfo> requestInfo, MessageClient msgSenderRepo, MessageClient msgSenderCL, MessageServer msgReciever)
        {
            HiResTimer hrt = new HiResTimer();

            Console.WriteLine("\n({1})Creating child AppDomain for {0}...", requestInfo[0].requestName, threadName);
            AppdomainManager manager  = new AppdomainManager();
            AppDomain        childApp = manager.createChildDomain();
            Loader           loader   = injectLoader(childApp);

            loader.SetTestList(requestInfo);
            Console.WriteLine("\n<------------------------------------------------------------>");
            Console.WriteLine("\n({0})Loading all DLLs required by this test request...", threadName);
            if (loader.LoadTests(tempPath))
            {
                Logger logger = injectLogger(childApp);
                Console.WriteLine("\n({0})Running tests...", threadName);
                hrt.Start();
                var resultList = loader.run();
                hrt.Stop();
                Console.WriteLine("\n({1})Tests execeted in {0} microsec.", hrt.ElapsedMicroseconds, threadName);
                Console.WriteLine("");
                if (resultList != null)
                {
                    logger.SetDataAndResultList(resultList);
                    Console.WriteLine("");
                    Console.WriteLine("\n<------------------------------------------------------------>");
                    Console.WriteLine("\n({0})Demonstrating the test log:\n", threadName);
                    logger.display();
                    string tempLogPath = Path.Combine(tempPath, "Logs");
                    Directory.CreateDirectory(tempLogPath);
                    logger.WriteLog(tempLogPath);
                    logger.writeLogSummary(tempLogPath);

                    SendLogToRepo(threadName, tempLogPath, msgSenderRepo, msgReciever);
                    Console.WriteLine("\n({0})Sending logs to client...", threadName);
                    Message msgToCL = msgSenderCL.SetupResultMessageToClient(logger.WriteToString(), resultList[0].authorName + " " + resultList[0].testTime.ToString("dd-MM-yyyy-HH_mm_ss"));
                    msgSenderCL.channel.PostMessage(msgToCL);

                    Console.WriteLine("");
                    Console.WriteLine("\n<***********************************************************>");
                }
                manager.unloadChild(childApp);
                Console.WriteLine("\n({0})Deleting temporary directory...", threadName);
                Directory.Delete(tempPath, true);
                Console.WriteLine("\n({0})Temporary directory deleted.", threadName);
            }
        }
コード例 #7
0
        public List <TestInfo> Phase1(string threadName, ref string tempPath, Message msg, MessageClient msgSenderRepo, MessageClient msgSenderCL, MessageServer msgReciever)
        {
            HiResTimer hrt = new HiResTimer();

            Console.WriteLine("\n({0})Parsing test request...", threadName);
            Parser          parser      = new Parser();
            List <TestInfo> requestInfo = parser.doParse(msg);

            Console.WriteLine("\n({0})The result of parsing:", threadName);
            parser.showParsed();

            Console.WriteLine("\n({0})Creating Temporary directory...", threadName);
            tempPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "..\\..\\..\\temp" + requestInfo[0].requestName);
            Directory.CreateDirectory(tempPath);

            Console.WriteLine("\n({0})Creating channel to send message to repository...", threadName);

            msgSenderRepo.CreateMessageChannel("http://localhost:8085/ICommService");
            Message msgToRepo = msgSenderRepo.SetupDownLoadMessageToRepo(threadName, requestInfo, tempPath, "http://localhost:4140/ICommService/BasicHttp", "http://localhost:8180/ICommService/BasicHttp");

            Console.WriteLine("\n({0})Sending message to repository...", threadName);

            msgSenderRepo.channel.PostMessage(msgToRepo);
            Console.WriteLine("\n({0})Waiting for message from repository...", threadName);
            hrt.Start();
            Message reply = msgReciever.TryGetMessage("Repository", threadName);

            hrt.Stop();
            TestLoadStatus stat = msgReciever.Parse(reply);

            Console.WriteLine("");
            Console.WriteLine("\n({0})Recieved message from repository in {2} microsec:\n{1}", threadName, stat.loadMessage, hrt.ElapsedMicroseconds);
            Console.WriteLine("");
            Console.WriteLine("\n({0})Creating channel to send message to client...", threadName);
            msgSenderCL.CreateMessageChannel(parser.ParseConnect(msg));
            Message loadMsgToCL = msgSenderCL.SetupLoadMessageToClient(stat);

            Console.WriteLine("\n({0})Sending load message to client...", threadName);
            msgSenderCL.channel.PostMessage(loadMsgToCL);
            Console.WriteLine("\n<---------------------------------------------------------------------->");

            return(requestInfo);
        }
コード例 #8
0
 void ThreadProc()
 {
     while (true)
     {
         Message msg = inQ_.deQ();
         if (msg.body == "quit")
         {
             Close();
             break;
         }
         Console.Write("\n Client received a new message \n");
         hrt.Stop();
         ulong  time      = hrt.ElapsedMicroseconds;
         double millitime = time / 1000.0;
         string timetaken = "Total time to get the response in milli seconds is " + millitime.ToString() + " - Req 12";
         timetaken.title();
         msg.show();
     }
 }