Beispiel #1
0
 /// <summary>
 /// Check whether all the jobs has been finished or not of the task
 /// 1. The 
 /// </summary>
 /// <param name="task"></param>
 /// <returns></returns>
 private static bool AreAllJobsOfTaskFinished(AutomationTask task)
 {
     List<AutomationJob> jobs = task.GetJobs();
     if (jobs == null || jobs.Count() <= 0)
     {
         ATFEnvironment.Log.logger.Warn("No jobs for Task " + task.TaskId.ToString());
         task.SetTaskStatus(TaskStatus.Failed);
         ATFEnvironment.Log.logger.Info("Change Task " + task.TaskId.ToString() + " status from Dispatched to Failed");
         task.AddProgressInformation("Change status: Dispatched to " + "Failed");
         return true;
     }
     else
     {
         foreach (AutomationJob job in jobs)
         {
             if (job.Status != (int)JobStatus.End
                 && job.Status != (int)JobStatus.Failed
                 && job.Status != (int)JobStatus.Complete
                 && job.Status != (int)JobStatus.Cancelled
                 && job.Status != (int)JobStatus.Timeout)
             {
                 return false;
             }
         }
         return true;
     }
 }
Beispiel #2
0
 /// <summary>
 /// Check whether one of the job has been started of the task
 /// </summary>
 /// <param name="task">task</param>
 /// <returns></returns>
 private static bool IsOneJobOfTaskStarted(AutomationTask task)
 {
     List<AutomationJob> jobs = task.GetJobs();
     if (jobs == null || jobs.Count() <= 0)
     {
         ATFEnvironment.Log.logger.Warn("No jobs for Task " + task.TaskId.ToString());
         task.SetTaskStatus(TaskStatus.Failed);
         ATFEnvironment.Log.logger.Info("Change Task " + task.TaskId.ToString() + " status from Dispatched to Failed");
         task.AddProgressInformation("Change status: Dispatched to " + "Failed");
         return false;
     }
     else
     {
         foreach (AutomationJob job in jobs)
         {
             if (job.Status != (int)JobStatus.Assigned)//The initial status of job
             {
                 return true;
             }
         }
         return false;
     }
 }
Beispiel #3
0
 private static bool GetSupporttedEnvironmentAndCheckStatusOfItForTask(AutomationTask task)
 {
     SupportedEnvironment supEnv = SupportedEnvironment.GetSupportedEnvironmentById(task.EnvironmentId);
     if (supEnv == null)
     {
         ATFEnvironment.Log.logger.Error("Task: " + task.TaskId.ToString() + " ,Supported Environment ERROR");
         task.AddProgressInformation("Supported Environment ERROR");
         task.SetTaskStatus(TaskStatus.Failed);
         return false;
     }
     else
     {
         string message = string.Format("The support environment is ready for task [{0}]", task.Name);
         ATFEnvironment.Log.logger.Info(message);
         task.AddProgressInformation(message);
         return true;
     }
 }
Beispiel #4
0
 private static bool IsBuildOfTaskReady(AutomationTask task)
 {
     Build build = Build.GetBuildById(task.BuildId);
     switch (build.Status)
     {
         case (int)BuildStatus.Success:
             {
                 string message = string.Format("The build [{0}] is ready.", build.Name);
                 ATFEnvironment.Log.logger.Info(message);
                 task.AddProgressInformation(message);
                 return true;
             }
         case (int)BuildStatus.Failed:
             {
                 string message = string.Format("The build [{0}] is failed.", build.Name);
                 ATFEnvironment.Log.logger.Info(message);
                 task.AddProgressInformation(message);
                 task.SetTaskStatus(TaskStatus.Failed);
                 return false;
             }
         case (int)BuildStatus.NotExist:
             {
                 string message = string.Format("The build [{0}] doesn't exist.", build.Name);
                 ATFEnvironment.Log.logger.Info(message);
                 task.AddProgressInformation(message);
                 task.SetTaskStatus(TaskStatus.Failed);
                 return false;
             }
         case (int)BuildStatus.Delete:
             {
                 string message = string.Format("The build [{0}] has been deleted.", build.Name);
                 ATFEnvironment.Log.logger.Info(message);
                 task.AddProgressInformation(message);
                 task.SetTaskStatus(TaskStatus.Failed);
                 return false;
             }
         default:
             {
                 string message = string.Format("The status of build {0} is invalid.", build.Name);
                 ATFEnvironment.Log.logger.Error(message);
                 task.AddProgressInformation(message);
                 task.SetTaskStatus(TaskStatus.Failed);
                 return false;
             }
     }
 }
Beispiel #5
0
        private static bool GetBuildAndCheckStatusOfItForTask(AutomationTask task)
        {
            //if build id = 0, we need to get the latest mainline build for this task
            if (task.BuildId == 0)
            {
                Build latestBuild = BuildManager.GetLatestBuild(task);
                if (null != latestBuild)
                {
                    string message = string.Format("The latest mainline build is {0}", latestBuild.Name);
                    ATFEnvironment.Log.logger.Info(message);
                    task.AddProgressInformation(message);
                    task.SetBuild(latestBuild.BuildId);
                }
                else
                {
                    string message = string.Format("Could not find the latest build for task {0}", task.Name);
                    ATFEnvironment.Log.logger.Error(message);
                    task.AddProgressInformation(message);
                    task.SetTaskStatus(TaskStatus.Failed);
                    return false;
                }
            }

            // Check whether build is ready
            if (!IsBuildOfTaskReady(task))
            {
                return false;
            }
            else
            {
                return true;
            }
        }