Beispiel #1
0
        public void BuildSolution(object vp)
        {
            ValidationProcess validationProcess = (ValidationProcess)vp;

            try
            {
                ProcessTeamSubmit(validationProcess, _systemSettings);
            }
            catch (ThreadAbortException)
            {
                Submit submit = validationProcess.Submit;
                Log("Timeout for " + submit.Team.Name + " on " + submit.TournamentAssignment.Assignment.Name);
            }
            catch (Exception ex)
            {
                Submit submit = validationProcess.Submit;
                Log(string.Format("ERROR DURING BUILD FOR: {0}-{1}:{2}: ", submit.Team.Name, submit.TournamentAssignment.Assignment.Name, ex.Message + " " + ex.GetType().ToString()));
            }
        }
Beispiel #2
0
        private static void ProcessTeamSubmit(ValidationProcess validationProcess, SystemSettings sysSettings)
        {
            Submit submit         = validationProcess.Submit;
            string teamName       = submit.Team.Name;
            string assignmentName = submit.TournamentAssignment.Assignment.Name;

            Log(string.Format("Processing teamsubmit {0} for assignment {1}", teamName, assignmentName));

            //create the processor
            SubmitValidator validator = new SubmitValidator(new MoCS.BuildService.Business.FileSystemWrapper(), new ExecuteCmd());

            validationProcess.SetProcessor(validator);

            //prepare directory and files for processing
            string       teamSubmitDirName = CreateTeamDirectory(sysSettings, teamName, submit.TournamentAssignment.Assignment);
            ClientFacade facade            = new ClientFacade();

            MoCS.Business.Objects.Assignment assignment = facade.GetAssignmentById(submit.TournamentAssignment.Assignment.Id, true);
            CopyFiles(assignment, submit, teamSubmitDirName, sysSettings);

            //START PROCESSING

            //settings that are read from the assignment
            AssignmentSettings assignmentSettings = SettingsFactory.CreateAssignmentSettings(assignment, assignmentName);
            //settings that are from the submitprocess/team submit
            SubmitSettings submitSettings = SettingsFactory.CreateSubmitSettings(teamName, teamSubmitDirName, assignmentName);

            //set status of submit to 'processing'
            facade.UpdateSubmitStatusDetails(submit.Id, SubmitStatus.Processing, "This submitted is currently processed.", DateTime.Now);

            ValidationResult result = validator.Process(sysSettings, assignmentSettings, submitSettings);

            validationProcess.Result = result;

            Log(result.Status + " for " + submit.Team.Name + " on " + submit.TournamentAssignment.Assignment.Name);

            //save the new status to the database
            SaveStatusToDatabase(validationProcess.Submit, result);

            // Delete nunit.framework.dll from the submit dir to keep things clean
            CleanupFiles(teamSubmitDirName);
        }
Beispiel #3
0
        private void TerminateOldSubmits()
        {
            int timeOut = GetTimeOut();

            List <string> keysToDelete = new List <string>();

            //see if any thread has timed out
            foreach (string key in _runningSubmitsHT.Keys)
            {
                ValidationProcess validationProcess = (ValidationProcess)_runningSubmitsHT[key];

                bool terminate = validationProcess.IsReady();

                if (!terminate)
                {
                    terminate = validationProcess.CheckForTimeOut(DateTime.Now, timeOut);
                    if (terminate)
                    {
                        validationProcess.SaveStatusToDatabase();
                    }
                }

                if (terminate)
                {
                    //remind wich key to delete. this can't be done inside the enumeration
                    keysToDelete.Add(key);

                    //kill the thread
                    validationProcess.Thread.Abort();
                }
            }

            //remove this outside the foreach loop
            foreach (string key in keysToDelete)
            {
                //remove the submit
                if (_runningSubmitsHT.ContainsKey(key))
                {
                    _runningSubmitsHT.Remove(key);
                }
            }
        }
Beispiel #4
0
        private void StartNewSubmits(List <Submit> submits)
        {
            int millisecondsToWait = GetTimeOut();

            //start new submits
            foreach (Submit s in submits)
            {
                if (!_runningSubmitsHT.ContainsKey(s.Id.ToString()))
                {
                    //create a new thread
                    ParameterizedThreadStart threadStart = new ParameterizedThreadStart(this.BuildSolution);
                    Thread t = new Thread(threadStart);

                    ValidationProcess process = new ValidationProcess(s, DateTime.Now);
                    process.SetThread(t);

                    _runningSubmitsHT.Add(s.Id.ToString(), process);
                    t.Start(process);
                }
            }
        }
Beispiel #5
0
        private void TerminateOldSubmits()
        {
            int timeOut = GetTimeOut();

            List <string> keysToDelete = new List <string>();

            //see if any thread has timed out
            foreach (string key in _runningSubmitsHT.Keys)
            {
                bool              terminate = false;
                Thread            t         = ((ValidationProcess)_runningSubmitsHT[key]).Thread;
                ValidationProcess submit    = null;
                bool              isTimeOut = false;

                submit = (ValidationProcess)_runningSubmitsHT[key];

                if (submit.Result != null && submit.Result.Status != SubmitStatusCode.Unknown)
                {
                    terminate = true;
                }
                else
                {
                    TimeSpan span = DateTime.Now.Subtract(submit.ProcessingDate);

                    if (span.TotalMilliseconds > timeOut)
                    {
                        isTimeOut = true;
                        terminate = true;
                        if (submit.Result == null)
                        {
                            submit.Result = new ValidationResult();
                        }
                        submit.Result.Status = SubmitStatusCode.TestError;
                        submit.Result.Messages.Add("TimeOut - it took more than " + timeOut.ToString() + " ms");
                    }
                }

                if (terminate)
                {
                    //remind wich key to delete. this can't be done inside the enumeration
                    keysToDelete.Add(key);

                    //kill the thread
                    t.Abort();

                    //terminate running processes
                    if (submit.Validator != null)
                    {
                        submit.Validator.Terminate();
                    }

                    if (isTimeOut)
                    {
                        //other statusses are saved in the process
                        SaveStatusToDatabase(submit.Submit, submit.Result);
                    }
                }
            }

            //remove this outside the foreach loop
            foreach (string key in keysToDelete)
            {
                //remove the submit
                if (_runningSubmitsHT.ContainsKey(key))
                {
                    _runningSubmitsHT.Remove(key);
                }
            }
        }
Beispiel #6
0
 private static void ProcessTeamSubmit(ValidationProcess validationProcess)
 {
     Log(string.Format("STARTED BUILD FOR: {0}-{1}", validationProcess.Submit.Team.Name, validationProcess.Submit.TournamentAssignment.Assignment.Name));
     validationProcess.Process();
 }
Beispiel #7
0
        private void StartWatchingNewSubmits(List<Submit> submits)
        {
            int millisecondsToWait = GetTimeOut();

            //start new submits
            foreach (Submit s in submits)
            {
                if (!_runningSubmitsHT.ContainsKey(s.Id.ToString()))
                {
                    //create a new thread
                    ParameterizedThreadStart threadStart = new ParameterizedThreadStart(this.BuildSolution);
                    Thread t = new Thread(threadStart);

                    ValidationProcess process = new ValidationProcess(s, DateTime.Now);
                    process.SetThread(t);

                    _runningSubmitsHT.Add(s.Id.ToString(), process);
                    t.Start(process);
                }
            }
        }
Beispiel #8
0
 private static void ProcessTeamSubmit(ValidationProcess validationProcess)
 {
     Log(string.Format("STARTED BUILD FOR: {0}-{1}", validationProcess.Submit.Team.Name, validationProcess.Submit.TournamentAssignment.Assignment.Name));
     validationProcess.Process();
 }
Beispiel #9
0
        private static void ProcessTeamSubmit(ValidationProcess validationProcess, SystemSettings sysSettings)
        {
            Submit submit = validationProcess.Submit;
            string teamName = submit.Team.Name;
            string assignmentName = submit.TournamentAssignment.Assignment.Name;

            Log(string.Format("Processing teamsubmit {0} for assignment {1}", teamName, assignmentName));

            //create the processor
            SubmitValidator validator = new SubmitValidator(new MoCS.BuildService.Business.FileSystemWrapper(), new ExecuteCmd());
            validationProcess.SetProcessor(validator);

            //prepare directory and files for processing
            string teamSubmitDirName = CreateTeamDirectory(sysSettings, teamName, submit.TournamentAssignment.Assignment);
            ClientFacade facade = new ClientFacade();
            MoCS.Business.Objects.Assignment assignment = facade.GetAssignmentById(submit.TournamentAssignment.Assignment.Id, true);
            CopyFiles(assignment, submit, teamSubmitDirName, sysSettings);

            //START PROCESSING

            //settings that are read from the assignment
            AssignmentSettings assignmentSettings = SettingsFactory.CreateAssignmentSettings(assignment, assignmentName);
            //settings that are from the submitprocess/team submit
            SubmitSettings submitSettings = SettingsFactory.CreateSubmitSettings(teamName, teamSubmitDirName, assignmentName);

            //set status of submit to 'processing'
            facade.UpdateSubmitStatusDetails(submit.Id, SubmitStatus.Processing, "This submitted is currently processed.", DateTime.Now);

            ValidationResult result = validator.Process(sysSettings, assignmentSettings, submitSettings);
            validationProcess.Result = result;

            Log(result.Status + " for " + submit.Team.Name + " on " + submit.TournamentAssignment.Assignment.Name);

            //save the new status to the database
            SaveStatusToDatabase(validationProcess.Submit, result);

            // Delete nunit.framework.dll from the submit dir to keep things clean
            CleanupFiles(teamSubmitDirName);
        }