Example #1
0
        public void RunRunset(bool doContinueRun = false)
        {
            List <Task> runnersTasks = new List <Task>();

            //reset run
            if (doContinueRun == false)
            {
                RunSetConfig.LastRunsetLoggerFolder = "-1";
                Reporter.ToLog(eLogLevel.INFO, string.Format("Reseting {0} elements", GingerDicser.GetTermResValue(eTermResKey.RunSet)));
                mStopwatch.Reset();
                ResetRunnersExecutionDetails();
            }
            else
            {
                RunSetConfig.LastRunsetLoggerFolder = null;
            }
            mStopRun = false;

            //configure Runners for run
            Reporter.ToLog(eLogLevel.INFO, string.Format("Configurating {0} elements for execution", GingerDicser.GetTermResValue(eTermResKey.RunSet)));
            ConfigureAllRunnersForExecution();

            //Process all pre execution Run Set Operations
            if (doContinueRun == false)
            {
                Reporter.ToLog(eLogLevel.INFO, string.Format("Running Pre-Execution {0} Operations", GingerDicser.GetTermResValue(eTermResKey.RunSet)));
                App.MainWindow.Dispatcher.Invoke(() => //ToDO: Remove dependency on UI thread- it should run in backend
                {
                    App.RunsetExecutor.ProcessRunSetActions(new List <RunSetActionBase.eRunAt> {
                        RunSetActionBase.eRunAt.ExecutionStart, RunSetActionBase.eRunAt.DuringExecution
                    });
                });
            }

            //Start Run
            if (doContinueRun == false)
            {
                Reporter.ToLog(eLogLevel.INFO, string.Format("########################## Starting {0} Execution", GingerDicser.GetTermResValue(eTermResKey.RunSet)));
                SetRunnersExecutionLoggerConfigs();//contains ExecutionLogger.RunSetStart()
            }
            else
            {
                Reporter.ToLog(eLogLevel.INFO, string.Format("########################## Continue {0} Execution", GingerDicser.GetTermResValue(eTermResKey.RunSet)));
            }
            mStopwatch.Start();
            if (RunSetConfig.RunModeParallel)
            {
                //running parallel
                foreach (GingerRunner GR in Runners)
                {
                    if (mStopRun)
                    {
                        return;
                    }

                    Task t = new Task(() =>
                    {
                        if (doContinueRun == false)
                        {
                            GR.RunRunner();
                        }
                        else
                        if (GR.Status == Amdocs.Ginger.CoreNET.Execution.eRunStatus.Stopped) //we continue only Stopped Runners
                        {
                            GR.ResetRunnerExecutionDetails(doNotResetBusFlows: true);        //reset stopped runners only and not their BF's
                            GR.ContinueRun(GingerRunner.eContinueLevel.Runner, GingerRunner.eContinueFrom.LastStoppedAction);
                        }
                    }, TaskCreationOptions.LongRunning);
                    runnersTasks.Add(t);
                    t.Start();

                    // Wait one second before starting another runner
                    Thread.Sleep(1000);
                }
            }
            else
            {
                //running sequentially
                Task t = new Task(() =>
                {
                    foreach (GingerRunner GR in Runners)
                    {
                        if (mStopRun)
                        {
                            return;
                        }

                        if (doContinueRun == false)
                        {
                            GR.RunRunner();
                        }
                        else
                        if (GR.Status == Amdocs.Ginger.CoreNET.Execution.eRunStatus.Stopped) //we continue only Stopped Runners
                        {
                            GR.ResetRunnerExecutionDetails(doNotResetBusFlows: true);        //reset stopped runners only and not their BF's
                            GR.ContinueRun(GingerRunner.eContinueLevel.Runner, GingerRunner.eContinueFrom.LastStoppedAction);
                        }
                        else if (GR.Status == Amdocs.Ginger.CoreNET.Execution.eRunStatus.Pending)   //continue the runners flow
                        {
                            GR.RunRunner();
                        }
                        // Wait one second before starting another runner
                        Thread.Sleep(1000);
                    }
                }, TaskCreationOptions.LongRunning);
                runnersTasks.Add(t);
                t.Start();
            }

            //Wait till end of run when all tasks are completed
            int count = 0;

            while (count < runnersTasks.Count) //removing dependency on stop because all Runners needs to stop first before exit
            {
                Thread.Sleep(100);
                count = (from x in runnersTasks where x.IsCompleted select x).Count();
            }
            mStopwatch.Stop();

            //Do post execution items
            Reporter.ToLog(eLogLevel.INFO, string.Format("######## {0} Runners Execution Ended", GingerDicser.GetTermResValue(eTermResKey.RunSet)));
            Ginger.Run.ExecutionLogger.RunSetEnd();
            if (mStopRun == false)
            {
                // Process all post execution RunSet Operations
                Reporter.ToLog(eLogLevel.INFO, string.Format("######## Running Post-Execution {0} Operations", GingerDicser.GetTermResValue(eTermResKey.RunSet)));
                App.MainWindow.Dispatcher.Invoke(() => //ToDO: Remove dependency on UI thread- it should run in backend
                {
                    App.RunsetExecutor.ProcessRunSetActions(new List <RunSetActionBase.eRunAt> {
                        RunSetActionBase.eRunAt.ExecutionEnd
                    });
                });
            }
            Reporter.ToLog(eLogLevel.INFO, string.Format("######## Doing {0} Execution Cleanup", GingerDicser.GetTermResValue(eTermResKey.RunSet)));
            CreateGingerExecutionReportAutomaticly();
            CloseAllEnvironments();
            Reporter.ToLog(eLogLevel.INFO, string.Format("########################## {0} Execution Ended", GingerDicser.GetTermResValue(eTermResKey.RunSet)));
        }
        public void RunRunset(bool doContinueRun = false)
        {
            try
            {
                mRunSetConfig.IsRunning = true;

                //reset run
                if (doContinueRun == false)
                {
                    RunSetConfig.LastRunsetLoggerFolder = "-1";   // !!!!!!!!!!!!!!!!!!
                    Reporter.ToLog(eLogLevel.DEBUG, string.Format("Reseting {0} elements", GingerDicser.GetTermResValue(eTermResKey.RunSet)));
                    mStopwatch.Reset();
                    ResetRunnersExecutionDetails();
                }
                else
                {
                    RunSetConfig.LastRunsetLoggerFolder = null;
                }

                mStopRun = false;

                //configure Runners for run
                Reporter.ToLog(eLogLevel.DEBUG, string.Format("Configuring {0} elements for execution", GingerDicser.GetTermResValue(eTermResKey.RunSet)));
                ConfigureAllRunnersForExecution();

                //Process all pre execution Run Set Operations
                if (doContinueRun == false)
                {
                    Reporter.ToLog(eLogLevel.DEBUG, string.Format("Running Pre-Execution {0} Operations", GingerDicser.GetTermResValue(eTermResKey.RunSet)));
                    WorkSpace.Instance.RunsetExecutor.ProcessRunSetActions(new List <RunSetActionBase.eRunAt> {
                        RunSetActionBase.eRunAt.ExecutionStart, RunSetActionBase.eRunAt.DuringExecution
                    });
                }

                //Start Run
                if (doContinueRun == false)
                {
                    Reporter.ToLog(eLogLevel.DEBUG, string.Format("########################## {0} Execution Started: '{1}'", GingerDicser.GetTermResValue(eTermResKey.RunSet), RunSetConfig.Name));
                    SetRunnersExecutionLoggerConfigs();//contains ExecutionLogger.RunSetStart()
                }
                else
                {
                    Reporter.ToLog(eLogLevel.DEBUG, string.Format("########################## {0} Execution Continuation: '{1}'", GingerDicser.GetTermResValue(eTermResKey.RunSet), RunSetConfig.Name));
                }

                mStopwatch.Start();
                Reporter.ToLog(eLogLevel.DEBUG, string.Format("######## {0} Runners Execution Started", GingerDicser.GetTermResValue(eTermResKey.RunSet)));
                List <Task> runnersTasks = new List <Task>();
                if (RunSetConfig.RunModeParallel)
                {
                    foreach (GingerRunner GR in Runners)
                    {
                        if (mStopRun)
                        {
                            return;
                        }

                        Task t = new Task(() =>
                        {
                            if (doContinueRun == false)
                            {
                                GR.RunRunner();
                            }
                            else
                            if (GR.Status == Amdocs.Ginger.CoreNET.Execution.eRunStatus.Stopped) //we continue only Stopped Runners
                            {
                                GR.ResetRunnerExecutionDetails(doNotResetBusFlows: true);        //reset stopped runners only and not their BF's
                                GR.ContinueRun(eContinueLevel.Runner, eContinueFrom.LastStoppedAction);
                            }
                        }, TaskCreationOptions.LongRunning);
                        runnersTasks.Add(t);
                        t.Start();

                        // Wait one second before starting another runner
                        Thread.Sleep(1000);
                    }
                }
                else
                {
                    //running sequentially
                    Task t = new Task(() =>
                    {
                        foreach (GingerRunner GR in Runners)
                        {
                            if (mStopRun)
                            {
                                return;
                            }

                            if (doContinueRun == false)
                            {
                                GR.RunRunner();
                            }
                            else
                            if (GR.Status == Amdocs.Ginger.CoreNET.Execution.eRunStatus.Stopped) //we continue only Stopped Runners
                            {
                                GR.ResetRunnerExecutionDetails(doNotResetBusFlows: true);        //reset stopped runners only and not their BF's
                                GR.ContinueRun(eContinueLevel.Runner, eContinueFrom.LastStoppedAction);
                            }
                            else if (GR.Status == Amdocs.Ginger.CoreNET.Execution.eRunStatus.Pending)//continue the runners flow
                            {
                                GR.RunRunner();
                            }
                            // Wait one second before starting another runner
                            Thread.Sleep(1000);
                        }
                    }, TaskCreationOptions.LongRunning);
                    runnersTasks.Add(t);
                    t.Start();
                }

                Task.WaitAll(runnersTasks.ToArray());
                mStopwatch.Stop();

                //Do post execution items
                Reporter.ToLog(eLogLevel.DEBUG, string.Format("######## {0} Runners Execution Ended", GingerDicser.GetTermResValue(eTermResKey.RunSet)));
                //ExecutionLoggerManager.RunSetEnd();
                Runners[0].ExecutionLoggerManager.RunSetEnd();
                if (mStopRun == false)
                {
                    // Process all post execution RunSet Operations
                    Reporter.ToLog(eLogLevel.DEBUG, string.Format("######## Running Post-Execution {0} Operations", GingerDicser.GetTermResValue(eTermResKey.RunSet)));
                    WorkSpace.Instance.RunsetExecutor.ProcessRunSetActions(new List <RunSetActionBase.eRunAt> {
                        RunSetActionBase.eRunAt.ExecutionEnd
                    });
                }
                Reporter.ToLog(eLogLevel.DEBUG, string.Format("######## Creating {0} Execution Report", GingerDicser.GetTermResValue(eTermResKey.RunSet)));
                CreateGingerExecutionReportAutomaticly();
                Reporter.ToLog(eLogLevel.DEBUG, string.Format("######## Doing {0} Execution Cleanup", GingerDicser.GetTermResValue(eTermResKey.RunSet)));
                CloseAllEnvironments();
                Reporter.ToLog(eLogLevel.INFO, string.Format("########################## {0} Execution Ended", GingerDicser.GetTermResValue(eTermResKey.RunSet)));
            }
            finally
            {
                mRunSetConfig.IsRunning = false;
            }
        }
Example #3
0
        public async Task RunRunset(bool doContinueRun = false)
        {
            try
            {
                mRunSetConfig.IsRunning = true;

                //reset run
                if (doContinueRun == false)
                {
                    if (WorkSpace.Instance.RunningInExecutionMode == false || RunSetConfig.ExecutionID == null)
                    {
                        RunSetConfig.ExecutionID = Guid.NewGuid();
                    }
                    RunSetConfig.LastRunsetLoggerFolder = "-1";   // !!!!!!!!!!!!!!!!!!
                    Reporter.ToLog(eLogLevel.INFO, string.Format("Reseting {0} elements", GingerDicser.GetTermResValue(eTermResKey.RunSet)));
                    mStopwatch.Reset();
                    ResetRunnersExecutionDetails();
                }
                else
                {
                    RunSetConfig.LastRunsetLoggerFolder = null;
                }

                mStopRun = false;

                //configure Runners for run
                Reporter.ToLog(eLogLevel.INFO, string.Format("Configuring {0} elements for execution", GingerDicser.GetTermResValue(eTermResKey.RunSet)));
                ConfigureAllRunnersForExecution();

                //Process all pre execution Run Set Operations
                if (doContinueRun == false)
                {
                    Reporter.ToLog(eLogLevel.INFO, string.Format("Running Pre-Execution {0} Operations", GingerDicser.GetTermResValue(eTermResKey.RunSet)));
                    WorkSpace.Instance.RunsetExecutor.ProcessRunSetActions(new List <RunSetActionBase.eRunAt> {
                        RunSetActionBase.eRunAt.ExecutionStart, RunSetActionBase.eRunAt.DuringExecution
                    });
                }

                //Start Run
                if (doContinueRun == false)
                {
                    Reporter.ToLog(eLogLevel.INFO, string.Format("########################## {0} Execution Started: '{1}'", GingerDicser.GetTermResValue(eTermResKey.RunSet), RunSetConfig.Name));
                    SetRunnersExecutionLoggerConfigs();//contains ExecutionLogger.RunSetStart()
                }
                else
                {
                    Reporter.ToLog(eLogLevel.INFO, string.Format("########################## {0} Execution Continuation: '{1}'", GingerDicser.GetTermResValue(eTermResKey.RunSet), RunSetConfig.Name));
                }

                mStopwatch.Start();
                Reporter.ToLog(eLogLevel.INFO, string.Format("######## {0} Runners Execution Started", GingerDicser.GetTermResValue(eTermResKey.RunSet)));
                List <Task> runnersTasks = new List <Task>();
                if (RunSetConfig.RunModeParallel)
                {
                    foreach (GingerRunner GR in Runners)
                    {
                        if (mStopRun)
                        {
                            return;
                        }

                        Task t = new Task(() =>
                        {
                            if (doContinueRun == false)
                            {
                                GR.RunRunner();
                            }
                            else
                            if (GR.Status == Amdocs.Ginger.CoreNET.Execution.eRunStatus.Stopped) //we continue only Stopped Runners
                            {
                                GR.ResetRunnerExecutionDetails(doNotResetBusFlows: true);        //reset stopped runners only and not their BF's
                                GR.ContinueRun(eContinueLevel.Runner, eContinueFrom.LastStoppedAction);
                            }
                        }, TaskCreationOptions.LongRunning);
                        runnersTasks.Add(t);
                        t.Start();

                        // Wait one second before starting another runner
                        Thread.Sleep(1000);
                    }
                }
                else
                {
                    //running sequentially
                    Task t = new Task(() =>
                    {
                        foreach (GingerRunner GR in Runners)
                        {
                            if (mStopRun)
                            {
                                return;
                            }

                            if (doContinueRun == false)
                            {
                                GR.RunRunner();
                            }
                            else
                            {
                                //continue
                                if (GR.Status == Amdocs.Ginger.CoreNET.Execution.eRunStatus.Stopped) //we continue only Stopped Runners
                                {
                                    GR.ResetRunnerExecutionDetails(doNotResetBusFlows: true);        //reset stopped runners only and not their BF's
                                    GR.ContinueRun(eContinueLevel.Runner, eContinueFrom.LastStoppedAction);
                                }
                                else if (GR.Status == Amdocs.Ginger.CoreNET.Execution.eRunStatus.Pending)//continue the runners flow
                                {
                                    GR.RunRunner();
                                }
                            }

                            if (GR.Status == eRunStatus.Failed && mRunSetConfig.StopRunnersOnFailure)
                            {
                                //marking next Runners as blocked and stopping execution
                                for (int indx = Runners.IndexOf(GR) + 1; indx < Runners.Count; indx++)
                                {
                                    Runners[indx].SetNextBusinessFlowsBlockedStatus();
                                    Runners[indx].Status = eRunStatus.Blocked;
                                    Runners[indx].GiveUserFeedback();//for getting update for runner stats on runset page
                                }

                                break;
                            }

                            // Wait one second before starting another runner
                            Thread.Sleep(1000);
                        }
                    }, TaskCreationOptions.LongRunning);
                    runnersTasks.Add(t);
                    t.Start();
                }

                Task.WaitAll(runnersTasks.ToArray());
                mStopwatch.Stop();

                //Do post execution items
                Reporter.ToLog(eLogLevel.INFO, string.Format("######## {0} Runners Execution Ended", GingerDicser.GetTermResValue(eTermResKey.RunSet)));
                //ExecutionLoggerManager.RunSetEnd();
                Runners[0].ExecutionLoggerManager.RunSetEnd();
                if (mStopRun == false)
                {
                    // Process all post execution RunSet Operations
                    Reporter.ToLog(eLogLevel.INFO, string.Format("######## Running Post-Execution {0} Operations", GingerDicser.GetTermResValue(eTermResKey.RunSet)));
                    WorkSpace.Instance.RunsetExecutor.ProcessRunSetActions(new List <RunSetActionBase.eRunAt> {
                        RunSetActionBase.eRunAt.ExecutionEnd
                    });
                }
                Reporter.ToLog(eLogLevel.INFO, string.Format("######## Creating {0} Execution Report", GingerDicser.GetTermResValue(eTermResKey.RunSet)));
                CreateGingerExecutionReportAutomaticly();
                Reporter.ToLog(eLogLevel.INFO, string.Format("######## Doing {0} Execution Cleanup", GingerDicser.GetTermResValue(eTermResKey.RunSet)));
                CloseAllEnvironments();
                Reporter.ToLog(eLogLevel.INFO, string.Format("########################## {0} Execution Ended", GingerDicser.GetTermResValue(eTermResKey.RunSet)));

                await Runners[0].ExecutionLoggerManager.PublishToCentralDBAsync(RunSetConfig.LiteDbId, RunSetConfig.ExecutionID ?? Guid.Empty);
            }
            finally
            {
                mRunSetConfig.IsRunning = false;
            }
        }