Example #1
0
 internal static void GenerateIndividualReport(RunsetExecutor GMR, String Template, ProjEnvironment Env, bool GetReportOnlyForExecutedFlow = false)
 {
     foreach (var mGR in GMR.Runners)
     {
         GenerateIndividualReport(mGR, Template, Env, GetReportOnlyForExecutedFlow);
     }
 }
Example #2
0
        public string CreateConfigurationsContent(Solution solution, RunsetExecutor runsetExecutor, CLIHelper cliHelper)
        {
            string  json       = DynamicExecutionManager.CreateRemoteExecutionRequestJSON(solution, runsetExecutor, cliHelper);
            dynamic parsedJson = JsonConvert.DeserializeObject(json);

            return(JsonConvert.SerializeObject(parsedJson, Formatting.Indented));
        }
        public void LoadRunsetConfigurations(string content, CLIHelper cliHelper, RunsetExecutor runsetExecutor)
        {
            using (System.IO.StringReader reader = new System.IO.StringReader(content))
            {
                string arg;
                while ((arg = reader.ReadLine()) != null)
                {
                    int    i     = arg.IndexOf('=');
                    string param = arg.Substring(0, i).Trim();
                    string value = arg.Substring(i + 1).Trim();

                    switch (param)
                    {
                    case "RunSet":
                    case "runset":
                        cliHelper.Runset = value;
                        break;

                    case "Env":
                    case "env":
                        cliHelper.Env = value;
                        break;

                    case "RunAnalyzer":
                    case "analyze":
                        cliHelper.RunAnalyzer = bool.Parse(value);
                        break;
                        //default:
                        //    Reporter.ToLog(eLogLevel.ERROR, "Unknown argument: '" + param + "'");
                        //    throw new ArgumentException("Unknown argument", param);
                    }
                }
            }
        }
Example #4
0
        public void LoadContent(string content, CLIHelper cliHelper, RunsetExecutor runsetExecutor)
        {
            DynamicGingerExecution dynamicExecution = DynamicExecutionManager.LoadDynamicExecutionFromXML(content);

            if (dynamicExecution.SolutionDetails.SourceControlDetails != null)
            {
                cliHelper.SetSourceControlType(dynamicExecution.SolutionDetails.SourceControlDetails.Type);
                cliHelper.SetSourceControlURL(dynamicExecution.SolutionDetails.SourceControlDetails.Url);
                cliHelper.SetSourceControlUser(dynamicExecution.SolutionDetails.SourceControlDetails.User);
                cliHelper.SetSourceControlPassword(dynamicExecution.SolutionDetails.SourceControlDetails.Password);
                cliHelper.PasswordEncrypted(dynamicExecution.SolutionDetails.SourceControlDetails.PasswordEncrypted);
                if (string.IsNullOrEmpty(dynamicExecution.SolutionDetails.SourceControlDetails.ProxyServer) == false)
                {
                    cliHelper.SourceControlProxyServer(dynamicExecution.SolutionDetails.SourceControlDetails.ProxyServer);
                    cliHelper.SourceControlProxyPort(dynamicExecution.SolutionDetails.SourceControlDetails.ProxyPort);
                }
            }
            cliHelper.Solution          = dynamicExecution.SolutionDetails.Path;
            cliHelper.ShowAutoRunWindow = dynamicExecution.ShowAutoRunWindow;

            AddRunset addRunset = dynamicExecution.AddRunsets[0];//for now supporting only one Run set execution

            cliHelper.Env         = addRunset.Environment;
            cliHelper.RunAnalyzer = addRunset.RunAnalyzer;

            DynamicExecutionManager.CreateRealRunSetFromDynamic(runsetExecutor, addRunset);
        }
Example #5
0
 public void LoadRunsetConfigurations(string content, CLIHelper cliHelper, RunsetExecutor runsetExecutor)
 {
     if (FileType == eFileType.JSON)
     {
         //Dynamic JSON
         GingerExecConfig exeConfiguration = DynamicExecutionManager.DeserializeDynamicExecutionFromJSON(content);
         RunsetExecConfig runset           = exeConfiguration.Runset;
         if (runset.EnvironmentName != null || runset.EnvironmentID != null)
         {
             ProjEnvironment env = DynamicExecutionManager.FindItemByIDAndName <ProjEnvironment>(
                 new Tuple <string, Guid?>(nameof(ProjEnvironment.Guid), runset.EnvironmentID),
                 new Tuple <string, string>(nameof(ProjEnvironment.Name), runset.EnvironmentName),
                 WorkSpace.Instance.SolutionRepository.GetAllRepositoryItems <ProjEnvironment>());
             if (env != null)
             {
                 cliHelper.Env = env.Name;
             }
         }
         if (runset.RunAnalyzer != null)
         {
             cliHelper.RunAnalyzer = (bool)runset.RunAnalyzer;
         }
         DynamicExecutionManager.CreateUpdateRunSetFromJSON(runsetExecutor, exeConfiguration);
     }
     else
     {
         //Dynamic XML
         DynamicGingerExecution dynamicExecution = DynamicExecutionManager.LoadDynamicExecutionFromXML(content);
         AddRunset addRunset = dynamicExecution.AddRunsets[0];//for now supporting only one Run set execution
         cliHelper.Env         = addRunset.Environment;
         cliHelper.RunAnalyzer = addRunset.RunAnalyzer;
         DynamicExecutionManager.CreateRunSetFromXML(runsetExecutor, addRunset);
     }
 }
Example #6
0
        public string CreateContent(Solution solution, RunsetExecutor runsetExecutor, CLIHelper cliHelper)
        {
            string Args = string.Empty;

            Args += string.Format("--solution {0}", solution.Folder);
            Args += string.Format(" --runset {0}", runsetExecutor.RunSetConfig.Name);
            Args += string.Format(" --environment {0}", runsetExecutor.RunsetExecutionEnvironment.Name);
            Args += string.Format(" --runAnalyzer {0}", cliHelper.RunAnalyzer.ToString());
            Args += string.Format(" --showAutoRunWindow {0}", cliHelper.ShowAutoRunWindow.ToString());
            if (cliHelper.DownloadUpgradeSolutionFromSourceControl == true)
            {
                Args += string.Format(" --sourceControlType {0}", solution.SourceControl.GetSourceControlType.ToString());
                if (solution.SourceControl.GetSourceControlType == SourceControlBase.eSourceControlType.SVN)//added for supporting Jenkins way of config creation- need to improve it
                {
                    string modifiedURI = solution.SourceControl.SourceControlURL.TrimEnd(new char[] { '/' });
                    int    lastSlash   = modifiedURI.LastIndexOf('/');
                    modifiedURI = (lastSlash > -1) ? modifiedURI.Substring(0, lastSlash) : modifiedURI;
                    Args       += string.Format(" --sourceControlUrl {0}", modifiedURI);
                }
                else
                {
                    Args += string.Format(" --sourceControlUrl {0}", solution.SourceControl.SourceControlURL);
                }
                Args += string.Format(" --sourceControlUser {0}", solution.SourceControl.SourceControlUser);
                Args += string.Format(" --sourceControlPassword {0}", EncryptionHandler.EncryptwithKey(solution.SourceControl.SourceControlPass));
                Args += string.Format(" --sourceControlPasswordEncrypted {0}", "Y");
                if (solution.SourceControl.GetSourceControlType == SourceControlBase.eSourceControlType.GIT && solution.SourceControl.SourceControlProxyAddress.ToLower().ToString() == "true")
                {
                    Args += string.Format(" --sourceControlProxyServer {0}", solution.SourceControl.SourceControlProxyAddress.ToString());
                    Args += string.Format(" --sourceControlProxyPort {0}", solution.SourceControl.SourceControlProxyPort.ToString());
                }
            }
            return(Args);
        }
Example #7
0
        public bool LoadRunset(RunsetExecutor runsetExecutor)
        {
            try
            {
                Reporter.ToLog(eLogLevel.INFO, string.Format("Loading {0}", GingerDicser.GetTermResValue(eTermResKey.RunSet)));
                mRunsetExecutor = runsetExecutor;
                if (mRunsetExecutor.RunSetConfig == null)
                {
                    SelectRunset();
                }
                else
                {
                    mRunSetConfig = mRunsetExecutor.RunSetConfig;
                }
                SelectEnv();
                mRunSetConfig.RunWithAnalyzer = RunAnalyzer;
                HandleAutoRunWindow();

                mRunSetConfig.SelfHealingConfiguration = mRunsetExecutor.RunSetConfig.SelfHealingConfiguration;

                if (!string.IsNullOrEmpty(ExecutionId))
                {
                    WorkSpace.Instance.RunsetExecutor.RunSetConfig.ExecutionID = Guid.Parse(ExecutionId);
                }
                return(true);
            }
            catch (Exception ex)
            {
                Reporter.ToLog(eLogLevel.ERROR, string.Format("Unexpected error occurred while loading the {0}", GingerDicser.GetTermResValue(eTermResKey.RunSet)), ex);
                return(false);
            }
        }
Example #8
0
 public bool LoadRunset(RunsetExecutor runsetExecutor)
 {
     try
     {
         Reporter.ToLog(eLogLevel.INFO, string.Format("Loading {0}", GingerDicser.GetTermResValue(eTermResKey.RunSet)));
         mRunsetExecutor = runsetExecutor;
         if (mRunsetExecutor.RunSetConfig == null)
         {
             SelectRunset();
         }
         else
         {
             mRunSetConfig = mRunsetExecutor.RunSetConfig;
         }
         SelectEnv();
         mRunSetConfig.RunWithAnalyzer = RunAnalyzer;
         HandleAutoRunWindow();
         return(true);
     }
     catch (Exception ex)
     {
         Reporter.ToLog(eLogLevel.ERROR, string.Format("Unexpected error occurred while loading the {0}", GingerDicser.GetTermResValue(eTermResKey.RunSet)), ex);
         return(false);
     }
 }
Example #9
0
 public async Task Execute(RunsetExecutor runsetExecutor)
 {
     await Task.Run(() =>
     {
         var rc = CodeProcessor.ExecuteNew(mScriptFile);
     });
 }
Example #10
0
        private void RunrunSet(RunSetConfig runSetConfig)
        {
            RunsetExecutor runsetExecutor = new RunsetExecutor();

            runsetExecutor.RunSetConfig       = runSetConfig;
            WorkSpace.Instance.RunsetExecutor = runsetExecutor;
            runsetExecutor.RunRunset();
        }
Example #11
0
        private void PrepareForCLICreationAndExecution()
        {
            WorkSpace.Instance.OpenSolution(mSolutionFolder);
            SolutionRepository SR             = WorkSpace.Instance.SolutionRepository;
            RunsetExecutor     runsetExecutor = new RunsetExecutor();

            runsetExecutor.RunsetExecutionEnvironment = (from x in SR.GetAllRepositoryItems <ProjEnvironment>() where x.Name == "Default" select x).SingleOrDefault();
            runsetExecutor.RunSetConfig       = (from x in SR.GetAllRepositoryItems <RunSetConfig>() where x.Name == "Default Run Set" select x).SingleOrDefault();
            WorkSpace.Instance.RunsetExecutor = runsetExecutor;
            WorkSpace.Instance.RunsetExecutor.InitRunners();
        }
Example #12
0
        public string CreateContent(Solution solution, RunsetExecutor runsetExecutor, CLIHelper cliHelper)
        {
            string txt = string.Format("OpenSolution(@\"{0}\");", solution.Folder) + Environment.NewLine;

            txt += string.Format("OpenRunSet(\"{0}\",\"{1}\");", runsetExecutor.RunSetConfig.Name, runsetExecutor.RunsetExecutionEnvironment.Name) + Environment.NewLine;
            txt += "CreateExecutionSummaryJSON(\"FILENAME\");" + Environment.NewLine;
            //txt += "if (Pass)" + Environment.NewLine;
            //txt += "{" + Environment.NewLine;
            //txt += "SendEmail()" + Environment.NewLine;
            //txt += "}" + Environment.NewLine;
            return(txt);
        }
Example #13
0
        public string Create(RunsetExecutor runsetExecutor)
        {
            SummaryCreationTime = DateTime.Now.ToString("MM-dd-yyyy HH:mm:ss");
            ExecutionElapsed    = runsetExecutor.Elapsed.ToString(@"hh\:mm\:ss");
            mRunsetExecutor     = runsetExecutor;

            AddRunners();

            string json = JsonConvert.SerializeObject(this, Formatting.Indented);

            return(json);
        }
        private BusinessFlow ConvertRunSetToBF(IReportInfo reportInfo)
        {
            RunsetExecutor runSetExec = WorkSpace.Instance.RunsetExecutor;

            try
            {
                if (reportInfo == null)
                {
                    return(null);
                }

                //Create Business Flow
                BusinessFlow virtualBF = new BusinessFlow();
                virtualBF.Name        = runSetExec.RunSetConfig.Name;
                virtualBF.Description = runSetExec.RunSetConfig.Description;
                virtualBF.Status      = BusinessFlow.eBusinessFlowStatus.Unknown;
                virtualBF.RunStatus   = runSetExec.RunSetConfig.RunSetExecutionStatus;
                virtualBF.Activities  = new ObservableList <Activity>();
                foreach (GingerRunner runSetrunner in runSetExec.Runners)
                {
                    // if executor is null when run if from file
                    if (runSetrunner.Executor is null)
                    {
                        runSetrunner.Executor = new GingerExecutionEngine(runSetrunner);
                    }
                    foreach (BusinessFlow runSetBF in runSetrunner.Executor.BusinessFlows)
                    {
                        ActivitiesGroup virtualAG = new ActivitiesGroup();
                        virtualAG.Name        = runSetBF.Name;
                        virtualAG.Description = runSetBF.Description;
                        if (Enum.IsDefined(typeof(eActivitiesGroupRunStatus), runSetBF.RunStatus.ToString()))
                        {
                            virtualAG.RunStatus = (eActivitiesGroupRunStatus)Enum.Parse(typeof(eActivitiesGroupRunStatus), runSetBF.RunStatus.ToString());
                        }
                        else
                        {
                            virtualAG.RunStatus = eActivitiesGroupRunStatus.NA;
                        }
                        virtualBF.AddActivitiesGroup(virtualAG);
                        foreach (Activity runSetAct in runSetBF.Activities)
                        {
                            virtualBF.AddActivity(runSetAct, virtualAG);
                        }
                    }
                }
                return(virtualBF);
            }
            catch (Exception ex)
            {
                Reporter.ToLog(eLogLevel.ERROR, $"Failed to convert Run Set to BF for ALM Export", ex);
                return(null);
            }
        }
Example #15
0
        public string CreateConfigurationsContent(Solution solution, RunsetExecutor runsetExecutor, CLIHelper cliHelper)
        {
            string sConfig = null;

            if (cliHelper.DownloadUpgradeSolutionFromSourceControl == true)
            {
                sConfig = "SourceControlType=" + solution.SourceControl.GetSourceControlType.ToString() + Environment.NewLine;
                if (solution.SourceControl.GetSourceControlType == SourceControlBase.eSourceControlType.SVN)//added for supporting Jenkins way of config creation- need to improve it
                {
                    string modifiedURI = solution.SourceControl.SourceControlURL.TrimEnd(new char[] { '/' });
                    int    lastSlash   = modifiedURI.LastIndexOf('/');
                    modifiedURI = (lastSlash > -1) ? modifiedURI.Substring(0, lastSlash) : modifiedURI;
                    sConfig    += "SourceControlUrl=" + modifiedURI + Environment.NewLine;
                }
                else
                {
                    sConfig += "SourceControlUrl=" + solution.SourceControl.SourceControlURL + Environment.NewLine;
                }
                if (solution.SourceControl.SourceControlUser != null && solution.SourceControl.SourceControlPass != null)
                {
                    sConfig += "SourceControlUser="******"SourceControlPassword="******"PasswordEncrypted=" + "Y" + Environment.NewLine;
                }
                else
                {
                    sConfig += "SourceControlUser=N/A" + Environment.NewLine;
                    sConfig += "SourceControlPassword=N/A" + Environment.NewLine;
                }
                if (solution.SourceControl.GetSourceControlType == SourceControlBase.eSourceControlType.GIT)
                {
                    if (solution.SourceControl.SourceControlProxyAddress != null && solution.SourceControl.SourceControlProxyAddress.ToLower().ToString() == "true")
                    {
                        sConfig += "SourceControlProxyServer=" + solution.SourceControl.SourceControlProxyAddress.ToString() + Environment.NewLine;
                        sConfig += "SourceControlProxyPort=" + solution.SourceControl.SourceControlProxyPort.ToString() + Environment.NewLine;
                    }
                }
            }
            sConfig += "solution=" + solution.Folder + Environment.NewLine;
            sConfig += "env=" + runsetExecutor.RunsetExecutionEnvironment.Name + Environment.NewLine;
            sConfig += "runset=" + runsetExecutor.RunSetConfig.Name + Environment.NewLine;
            sConfig += "analyze=" + cliHelper.RunAnalyzer.ToString() + Environment.NewLine;
            if (!string.IsNullOrEmpty(cliHelper.TestArtifactsFolder))
            {
                sConfig += "artifacts-path=" + cliHelper.TestArtifactsFolder + Environment.NewLine;
            }

            //OLD sConfig += "ShowAutoRunWindow=" + cliHelper.ShowAutoRunWindow.ToString() + Environment.NewLine;
            sConfig += CLIOptionClassHelper.GetAttrLongName <RunOptions>(nameof(RunOptions.ShowUI)) + "=" + cliHelper.ShowAutoRunWindow.ToString() + Environment.NewLine;

            return(sConfig);
        }
Example #16
0
 public string CreateConfigurationsContent(Solution solution, RunsetExecutor runsetExecutor, CLIHelper cliHelper)
 {
     if (FileType == eFileType.JSON)
     {
         string json = DynamicExecutionManager.CreateDynamicRunSetJSON(solution, runsetExecutor, cliHelper);
         return(json);
     }
     else
     {
         string xml = DynamicExecutionManager.CreateDynamicRunSetXML(solution, runsetExecutor, cliHelper);
         return(xml);
     }
 }
Example #17
0
        public void TestNGOperationTest()
        {
            //Arrange
            ObservableList <BusinessFlow> bfList = SR.GetAllRepositoryItems <BusinessFlow>();
            BusinessFlow BF1 = bfList[0];
            ObservableList <Activity> activityList = BF1.Activities;

            BF1.Active = true;
            GingerExecutionEngine mGRForRunset = new GingerExecutionEngine(new GingerRunner());

            mGRForRunset.GingerRunner.Name = "Test Runner";
            Agent a = new Agent();

            a.DriverType = Agent.eDriverType.SeleniumChrome;
            mGRForRunset.SolutionAgents = new ObservableList <Agent>();
            mGRForRunset.SolutionAgents.Add(a);
            mGRForRunset.GingerRunner.ApplicationAgents.Add(new ApplicationAgent()
            {
                AppName = "SCM", Agent = a
            });
            mGRForRunset.SolutionApplications = new ObservableList <ApplicationPlatform>();
            mGRForRunset.SolutionApplications.Add(new ApplicationPlatform()
            {
                AppName = "SCM", Platform = ePlatformType.Web, Description = "New application"
            });
            mGRForRunset.BusinessFlows.Add(BF1);
            WorkSpace.Instance.SolutionRepository             = SR;
            mGRForRunset.GingerRunner.SpecificEnvironmentName = environment.Name;
            mGRForRunset.GingerRunner.UseSpecificEnvironment  = false;
            RunSetConfig runSetConfig1 = new RunSetConfig();

            mGRForRunset.IsUpdateBusinessFlowRunList = true;
            runSetConfig1.GingerRunners.Add(mGRForRunset.GingerRunner);
            runSetConfig1.UpdateRunnersBusinessFlowRunsList();
            runSetConfig1.mRunModeParallel = false;
            RunSetActionGenerateTestNGReport testNGAction = CreateTestNGOperation();

            runSetConfig1.RunSetActions.Add(testNGAction);
            RunsetExecutor GMR1 = new RunsetExecutor();

            GMR1.RunsetExecutionEnvironment = environment;
            GMR1.RunSetConfig = runSetConfig1;
            WorkSpace.Instance.RunsetExecutor = GMR1;

            //Act
            GMR1.RunSetConfig.RunSetActions[0].runSetActionBaseOperations.ExecuteWithRunPageBFES();

            //Assert
            Assert.AreEqual(GMR1.RunSetConfig.RunSetActions[0].Status, RunSetActionBase.eRunSetActionStatus.Completed);
        }
        public async void OpenRunSet(string runSetName, string envName)
        {
            SolutionRepository SR           = WorkSpace.Instance.SolutionRepository;
            var             envs            = SR.GetAllRepositoryItems <ProjEnvironment>();
            ProjEnvironment projEnvironment = (from x in SR.GetAllRepositoryItems <ProjEnvironment>() where x.Name == envName select x).SingleOrDefault();
            RunSetConfig    runSetConfig    = (from x in SR.GetAllRepositoryItems <RunSetConfig>() where x.Name == runSetName select x).SingleOrDefault();
            RunsetExecutor  runsetExecutor  = new RunsetExecutor();

            WorkSpace.Instance.RunsetExecutor         = runsetExecutor;
            runsetExecutor.RunSetConfig               = runSetConfig;
            runsetExecutor.RunsetExecutionEnvironment = projEnvironment;
            runsetExecutor.InitRunners();
            await runsetExecutor.RunRunset();
        }
Example #19
0
        /// <summary>
        /// Should be deleted after switch will be fully done to serialized objects
        /// </summary>
        public ReportInfo(ProjEnvironment Env, RunsetExecutor GMR, bool ReportOnlyExecuted = false)   // to remove after discussion !!!
        {
            mProjEnvironment = Env;
            mBFESs           = GMR.GetAllBusinessFlowsExecutionSummary(ReportOnlyExecuted);

            mGingersMultiRun = GMR;
            // Set all General info
            TotalExecutionTime = mGingersMultiRun.Elapsed;

            DateCreated          = DateTime.Now.ToString();
            DateCreatedShort     = DateTime.Now.ToString("MM/dd");
            ExecutionEnv         = mProjEnvironment.Name;
            ExecutionElapsedTime = mGingersMultiRun.Elapsed;
        }
Example #20
0
 public string CreateConfigurationsContent(Solution solution, RunsetExecutor runsetExecutor, CLIHelper cliHelper)
 {
     if (FileType == eFileType.JSON)
     {
         string  json       = DynamicExecutionManager.CreateDynamicRunSetJSON(solution, runsetExecutor, cliHelper);
         dynamic parsedJson = JsonConvert.DeserializeObject(json);
         return(JsonConvert.SerializeObject(parsedJson, Formatting.Indented));
     }
     else
     {
         string xml = DynamicExecutionManager.CreateDynamicRunSetXML(solution, runsetExecutor, cliHelper);
         return(xml);
     }
 }
Example #21
0
        static void CreateWorkspace()
        {
            WorkSpaceEventHandler WSEH = new WorkSpaceEventHandler();

            WorkSpace.Init(WSEH);
            WorkSpace.Instance.RunningFromUnitTest = true;
            WorkSpace.Instance.InitWorkspace(new GingerUnitTestWorkspaceReporter(), new RepoCoreItem());
            WorkSpace.Instance.OpenSolution(mSolutionFolder);
            WorkSpace.Instance.Solution.LoggerConfigurations.SelectedDataRepositoryMethod = Ginger.Reports.ExecutionLoggerConfiguration.DataRepositoryMethod.LiteDB;
            SolutionRepository SR             = WorkSpace.Instance.SolutionRepository;
            RunsetExecutor     runsetExecutor = new RunsetExecutor();

            runsetExecutor.RunsetExecutionEnvironment = (from x in SR.GetAllRepositoryItems <ProjEnvironment>() where x.Name == "Default" select x).SingleOrDefault();
            runsetExecutor.RunSetConfig       = (from x in SR.GetAllRepositoryItems <RunSetConfig>() where x.Name == "Default Run Set" select x).SingleOrDefault();
            WorkSpace.Instance.RunsetExecutor = runsetExecutor;
            WorkSpace.Instance.RunsetExecutor.InitRunners();
        }
Example #22
0
        public void DyanamicRunsetXMLCreationTest()
        {
            //Arrange
            RunSetConfig runSetConfigurations = CreteRunsetWithOperations();

            RunsetExecutor GMR = new RunsetExecutor();

            GMR.RunsetExecutionEnvironment = environment;
            GMR.RunSetConfig = runSetConfigurations;

            CLIHelper cLIHelper = new CLIHelper();

            cLIHelper.RunAnalyzer       = true;
            cLIHelper.ShowAutoRunWindow = false;
            cLIHelper.DownloadUpgradeSolutionFromSourceControl = false;

            RunSetAutoRunConfiguration autoRunConfiguration = new RunSetAutoRunConfiguration(solution, GMR, cLIHelper);
            CLIDynamicFile             mCLIDynamicXML       = new CLIDynamicFile(CLIDynamicFile.eFileType.XML);

            autoRunConfiguration.SelectedCLI = mCLIDynamicXML;

            //Act
            //Creating XML file content from above configurations
            string file = autoRunConfiguration.SelectedCLI.CreateConfigurationsContent(solution, GMR, cLIHelper);

            //Assert
            //validate the 'AddRunsetOperation' tag
            XElement nodes = XElement.Parse(file);

            List <XElement> AddRunsetOPerationsNodes = nodes.Elements("AddRunsetOperation").ToList();

            XmlDocument xDoc = new XmlDocument();

            xDoc.LoadXml(file);
            XmlNodeList runsetoperations = xDoc.GetElementsByTagName("AddRunsetOperation");

            //Assert
            Assert.AreEqual(runsetoperations.Count, 3);
            Assert.AreEqual(runsetoperations[0].FirstChild.Name, "MailFrom");
            Assert.AreEqual(runsetoperations[0].LastChild.Name, "IncludeAttachmentReport");
            Assert.AreEqual(runsetoperations[1].FirstChild.Name, "HTMLReportFolderName");
            Assert.AreEqual(runsetoperations[1].LastChild.Name, "isHTMLReportPermanentFolderNameUsed");
            Assert.AreEqual(runsetoperations[2].HasChildNodes, false);
        }
Example #23
0
        /// <summary>
        /// Should be deleted after switch will be fully done to serialized objects
        /// </summary>
        public ReportInfo(ProjEnvironment Env, BusinessFlow BF, GingerRunner GR = null) // to remove after discussion !!!
        {
            mProjEnvironment = Env;
            mBFESs           = new ObservableList <BusinessFlowExecutionSummary>();
            BusinessFlowExecutionSummary BFES = new BusinessFlowExecutionSummary();

            BFES.BusinessFlowName           = BF.Name;
            BFES.BusinessFlowRunDescription = BF.RunDescription;
            BFES.Status              = BF.RunStatus;
            BFES.Activities          = BF.Activities.Count;
            BFES.Actions             = BF.GetActionsCount();
            BFES.Validations         = BF.GetValidationsCount();
            BFES.ExecutionVariabeles = BF.GetBFandActivitiesVariabeles(true);
            BFES.BusinessFlow        = BF;
            BFES.Selected            = true;
            if (GR != null)
            {
                BFES.BusinessFlowExecLoggerFolder = Path.Combine(GR.ExecutionLoggerManager.ExecutionLogfolder, BF.ExecutionLogFolder);
            }

            if (mBFESs != null)
            {
                mBFESs.Clear();
            }
            mBFESs.Add(BFES);

            mGingersMultiRun = null;
            // Set all General info
            if (BF.Elapsed != null)
            {
                TotalExecutionTime = TimeSpan.FromSeconds((long)BF.ElapsedSecs);
            }
            else
            {
                TotalExecutionTime = new TimeSpan(0);
            }

            ExecutionElapsedTime = TotalExecutionTime;
            DateCreated          = DateTime.Now.ToString();
            ExecutionEnv         = mProjEnvironment.Name;
            DateCreatedShort     = DateTime.Now.ToString("MM/dd");
        }
Example #24
0
        public string CreateContent(Solution solution, RunsetExecutor runsetExecutor, CLIHelper cliHelper)
        {
            RunOptions options = new RunOptions();

            options.Solution          = solution.Folder;
            options.Runset            = runsetExecutor.RunSetConfig.Name;
            options.Environment       = runsetExecutor.RunsetExecutionEnvironment.Name;
            options.DoNotAnalyze      = !cliHelper.RunAnalyzer;
            options.ShowUI            = cliHelper.ShowAutoRunWindow;
            options.TestArtifactsPath = cliHelper.TestArtifactsFolder;

            var args = CommandLine.Parser.Default.FormatCommandLine <RunOptions>(options);

            // !!!!!!!!!!!!!!!!!!!
            // TODO: we want to move SCM to another verb/action !!!!!

            //if (cliHelper.DownloadUpgradeSolutionFromSourceControl == true)
            //{
            //    Args += string.Format(" --sourceControlType {0}" , solution.SourceControl.GetSourceControlType.ToString());
            //    if (solution.SourceControl.GetSourceControlType == SourceControlBase.eSourceControlType.SVN)//added for supporting Jenkins way of config creation- need to improve it
            //    {
            //        string modifiedURI = solution.SourceControl.SourceControlURL.TrimEnd(new char[] { '/' });
            //        int lastSlash = modifiedURI.LastIndexOf('/');
            //        modifiedURI = (lastSlash > -1) ? modifiedURI.Substring(0, lastSlash) : modifiedURI;
            //        Args += string.Format(" --sourceControlUrl {0}", modifiedURI);
            //    }
            //    else
            //    {
            //        Args += string.Format(" --sourceControlUrl {0}", solution.SourceControl.SourceControlURL);
            //    }
            //    Args += string.Format(" --sourceControlUser {0}" , solution.SourceControl.SourceControlUser);
            //    Args += string.Format(" --sourceControlPassword {0}" , EncryptionHandler.EncryptwithKey(solution.SourceControl.SourceControlPass));
            //    Args += string.Format(" --sourceControlPasswordEncrypted {0}" , "Y");
            //    if (solution.SourceControl.GetSourceControlType == SourceControlBase.eSourceControlType.GIT && solution.SourceControl.SourceControlProxyAddress.ToLower().ToString() == "true")
            //    {
            //        Args += string.Format(" --sourceControlProxyServer {0}" , solution.SourceControl.SourceControlProxyAddress.ToString());
            //        Args += string.Format(" --sourceControlProxyPort {0}" , solution.SourceControl.SourceControlProxyPort.ToString());
            //    }
            //}

            return(args);
        }
Example #25
0
        private async void RunSet()
        {
            Console.WriteLine(GingerDicser.GetTermResValue(eTermResKey.RunSet) + " Name?");
            string       runSetName   = Console.ReadLine();
            RunSetConfig runSetConfig = (from x in SR.GetAllRepositoryItems <RunSetConfig>() where x.Name == runSetName select x).SingleOrDefault();

            if (runSetConfig == null)
            {
                Console.WriteLine("RunSetConfig not found");
                return;
            }


            Console.WriteLine("starting RunSetConfig execution");
            RunsetExecutor runsetExecuto = new RunsetExecutor();

            runsetExecuto.RunSetConfig = runSetConfig;
            await runsetExecuto.RunRunset();

            Console.WriteLine("Execution completed");
        }
Example #26
0
 public void LoadContent(string content, CLIHelper cliHelper, RunsetExecutor runsetExecutor)
 {
     mScriptFile = content;
 }
Example #27
0
 public void Execute(RunsetExecutor runsetExecutor)
 {
     var rc = CodeProcessor.ExecuteNew(mScriptFile);
 }
        public static string CreateDynamicRunSetXML(Solution solution, RunsetExecutor runsetExecutor, CLIHelper cliHelper)
        {
            runsetExecutor.RunSetConfig.UpdateRunnersBusinessFlowRunsList();

            DynamicGingerExecution dynamicExecution = new DynamicGingerExecution();

            dynamicExecution.SolutionDetails = new SolutionDetails();
            if (cliHelper.DownloadUpgradeSolutionFromSourceControl == true)
            {
                dynamicExecution.SolutionDetails.SourceControlDetails      = new SourceControlDetails();
                dynamicExecution.SolutionDetails.SourceControlDetails.Type = solution.SourceControl.GetSourceControlType.ToString();
                if (solution.SourceControl.GetSourceControlType == SourceControlBase.eSourceControlType.SVN)//added for supporting Jenkins way of config creation- need to improve it
                {
                    string modifiedURI = solution.SourceControl.SourceControlURL.TrimEnd(new char[] { '/' });
                    int    lastSlash   = modifiedURI.LastIndexOf('/');
                    modifiedURI = (lastSlash > -1) ? modifiedURI.Substring(0, lastSlash) : modifiedURI;
                    dynamicExecution.SolutionDetails.SourceControlDetails.Url = modifiedURI;
                }
                else
                {
                    dynamicExecution.SolutionDetails.SourceControlDetails.Url = solution.SourceControl.SourceControlURL.ToString();
                }
                if (solution.SourceControl.SourceControlUser != null && solution.SourceControl.SourceControlPass != null)
                {
                    dynamicExecution.SolutionDetails.SourceControlDetails.User              = solution.SourceControl.SourceControlUser;
                    dynamicExecution.SolutionDetails.SourceControlDetails.Password          = EncryptionHandler.EncryptwithKey(solution.SourceControl.SourceControlPass);
                    dynamicExecution.SolutionDetails.SourceControlDetails.PasswordEncrypted = "Y";
                }
                else
                {
                    dynamicExecution.SolutionDetails.SourceControlDetails.User     = "******";
                    dynamicExecution.SolutionDetails.SourceControlDetails.Password = "******";
                }
                if (solution.SourceControl.GetSourceControlType == SourceControlBase.eSourceControlType.GIT && solution.SourceControl.SourceControlProxyAddress.ToLower().ToString() == "true")
                {
                    dynamicExecution.SolutionDetails.SourceControlDetails.ProxyServer = solution.SourceControl.SourceControlProxyAddress.ToString();
                    dynamicExecution.SolutionDetails.SourceControlDetails.ProxyPort   = solution.SourceControl.SourceControlProxyPort.ToString();
                }
            }
            dynamicExecution.SolutionDetails.Path = solution.Folder;
            dynamicExecution.ShowAutoRunWindow    = cliHelper.ShowAutoRunWindow;

            AddRunset addRunset = new AddRunset();

            addRunset.Name          = "Dynamic_" + runsetExecutor.RunSetConfig.Name;
            addRunset.Environment   = runsetExecutor.RunsetExecutionEnvironment.Name;
            addRunset.RunAnalyzer   = cliHelper.RunAnalyzer;
            addRunset.RunInParallel = runsetExecutor.RunSetConfig.RunModeParallel;

            foreach (GingerRunner gingerRunner in runsetExecutor.RunSetConfig.GingerRunners)
            {
                AddRunner addRunner = new AddRunner();
                addRunner.Name = gingerRunner.Name;
                if (gingerRunner.UseSpecificEnvironment == true && string.IsNullOrEmpty(gingerRunner.SpecificEnvironmentName))
                {
                    addRunner.Environment = gingerRunner.SpecificEnvironmentName;
                }
                if (gingerRunner.RunOption != GingerRunner.eRunOptions.ContinueToRunall)
                {
                    addRunner.RunMode = gingerRunner.RunOption.ToString();
                }

                foreach (ApplicationAgent applicationAgent in gingerRunner.ApplicationAgents)
                {
                    addRunner.SetAgents.Add(new SetAgent()
                    {
                        AgentName = applicationAgent.AgentName, ApplicationName = applicationAgent.AppName
                    });
                }

                foreach (BusinessFlowRun businessFlowRun in gingerRunner.BusinessFlowsRunList)
                {
                    AddBusinessFlow addBusinessFlow = new AddBusinessFlow();
                    addBusinessFlow.Name = businessFlowRun.BusinessFlowName;
                    if (businessFlowRun.BusinessFlowCustomizedRunVariables.Count > 0)
                    {
                        addBusinessFlow.InputVariables = new System.Collections.Generic.List <InputVariable>();
                        foreach (VariableBase variableBase in businessFlowRun.BusinessFlowCustomizedRunVariables)
                        {
                            InputVariable inputVar = new InputVariable();
                            if (variableBase.ParentType != "Business Flow")
                            {
                                inputVar.VariableParentType = variableBase.ParentType;
                                inputVar.VariableParentName = variableBase.ParentName;
                            }
                            inputVar.VariableName  = variableBase.Name;
                            inputVar.VariableValue = variableBase.Value;

                            addBusinessFlow.InputVariables.Add(inputVar);
                        }
                    }
                    addRunner.AddBusinessFlows.Add(addBusinessFlow);
                }
                addRunset.AddRunners.Add(addRunner);
            }

            foreach (RunSetActionBase runSetOperation in runsetExecutor.RunSetConfig.RunSetActions)
            {
                if (runSetOperation is RunSetActionHTMLReportSendEmail)
                {
                    RunSetActionHTMLReportSendEmail runsetMailReport = (RunSetActionHTMLReportSendEmail)runSetOperation;
                    MailReport dynamicMailReport = new MailReport();
                    dynamicMailReport.Condition = runsetMailReport.Condition.ToString();
                    dynamicMailReport.RunAt     = runsetMailReport.RunAt.ToString();

                    dynamicMailReport.MailFrom = runsetMailReport.MailFrom;
                    dynamicMailReport.MailTo   = runsetMailReport.MailTo;
                    dynamicMailReport.MailCC   = runsetMailReport.MailCC;

                    dynamicMailReport.Subject  = runsetMailReport.Subject;
                    dynamicMailReport.Comments = runsetMailReport.Comments;

                    if (runsetMailReport.Email.EmailMethod == GingerCore.GeneralLib.Email.eEmailMethod.OUTLOOK)
                    {
                        dynamicMailReport.SendViaOutlook = true;
                    }
                    else
                    {
                        dynamicMailReport.SmtpDetails           = new SmtpDetails();
                        dynamicMailReport.SmtpDetails.Server    = runsetMailReport.Email.SMTPMailHost;
                        dynamicMailReport.SmtpDetails.Port      = runsetMailReport.Email.SMTPPort.ToString();
                        dynamicMailReport.SmtpDetails.EnableSSL = runsetMailReport.Email.EnableSSL.ToString();
                        if (runsetMailReport.Email.ConfigureCredential)
                        {
                            dynamicMailReport.SmtpDetails.User     = runsetMailReport.Email.SMTPUser;
                            dynamicMailReport.SmtpDetails.Password = runsetMailReport.Email.SMTPPass;
                        }
                    }

                    if (runsetMailReport.EmailAttachments.Where(x => x.AttachmentType == EmailAttachment.eAttachmentType.Report).FirstOrDefault() != null)
                    {
                        dynamicMailReport.IncludeAttachmentReport = true;
                    }
                    else
                    {
                        dynamicMailReport.IncludeAttachmentReport = false;
                    }

                    addRunset.AddRunsetOperations.Add(dynamicMailReport);
                }
                else if (runSetOperation is RunSetActionJSONSummary)
                {
                    JsonReport dynamicJsonReport = new JsonReport();
                    addRunset.AddRunsetOperations.Add(dynamicJsonReport);
                }
            }
            dynamicExecution.AddRunsets.Add(addRunset);

            string content = ConvertDynamicExecutionToXML(dynamicExecution);

            return(content);
        }
        public static void CreateRealRunSetFromDynamic(RunsetExecutor runsetExecutor, AddRunset dynamicRunset)
        {
            RunSetConfig runSetConfig = new RunSetConfig();

            runSetConfig.Name            = dynamicRunset.Name;
            runSetConfig.RunWithAnalyzer = dynamicRunset.RunAnalyzer;
            runSetConfig.RunModeParallel = dynamicRunset.RunInParallel;

            // Add runners
            foreach (AddRunner addRunner in dynamicRunset.AddRunners)
            {
                GingerRunner gingerRunner = new GingerRunner();
                gingerRunner.Name = addRunner.Name;

                if (!string.IsNullOrEmpty(addRunner.RunMode))
                {
                    gingerRunner.RunOption = (GingerRunner.eRunOptions)Enum.Parse(typeof(GingerRunner.eRunOptions), addRunner.RunMode, true);
                }

                if (!string.IsNullOrEmpty(addRunner.Environment))
                {
                    gingerRunner.UseSpecificEnvironment  = true;
                    gingerRunner.SpecificEnvironmentName = addRunner.Environment;
                }

                //add Agents
                foreach (SetAgent setAgent in addRunner.SetAgents)
                {
                    ApplicationAgent appAgent = new ApplicationAgent();
                    appAgent.AppName   = setAgent.ApplicationName;
                    appAgent.AgentName = setAgent.AgentName;
                    gingerRunner.ApplicationAgents.Add(appAgent);
                }

                // Add BFs
                foreach (AddBusinessFlow addBusinessFlow in addRunner.AddBusinessFlows)
                {
                    BusinessFlowRun businessFlowRun = new BusinessFlowRun();
                    businessFlowRun.BusinessFlowName     = addBusinessFlow.Name;
                    businessFlowRun.BusinessFlowIsActive = true;

                    // set BF Variables
                    if (addBusinessFlow.InputVariables != null)
                    {
                        foreach (InputVariable inputVariabel in addBusinessFlow.InputVariables)
                        {
                            businessFlowRun.BusinessFlowCustomizedRunVariables.Add(new VariableString()
                            {
                                DiffrentFromOrigin = true, VarValChanged = true, ParentType = inputVariabel.VariableParentType, ParentName = inputVariabel.VariableParentName, Name = inputVariabel.VariableName, InitialStringValue = inputVariabel.VariableValue, Value = inputVariabel.VariableValue
                            });
                        }
                    }
                    gingerRunner.BusinessFlowsRunList.Add(businessFlowRun);
                }
                runSetConfig.GingerRunners.Add(gingerRunner);
            }

            //Add mail Report handling
            foreach (AddRunsetOperation addOperation in dynamicRunset.AddRunsetOperations)
            {
                if (addOperation is MailReport)
                {
                    MailReport dynamicMailOperation = (MailReport)addOperation;
                    RunSetActionHTMLReportSendEmail mailOperation = new RunSetActionHTMLReportSendEmail();

                    mailOperation.Name      = "Dynamic Mail Report";
                    mailOperation.Condition = (RunSetActionBase.eRunSetActionCondition)Enum.Parse(typeof(RunSetActionBase.eRunSetActionCondition), dynamicMailOperation.Condition, true);
                    mailOperation.RunAt     = (RunSetActionBase.eRunAt)Enum.Parse(typeof(RunSetActionBase.eRunAt), dynamicMailOperation.RunAt, true);
                    mailOperation.Active    = true;

                    mailOperation.MailFrom = dynamicMailOperation.MailFrom;
                    mailOperation.MailTo   = dynamicMailOperation.MailTo;
                    mailOperation.MailCC   = dynamicMailOperation.MailCC;

                    mailOperation.Subject  = dynamicMailOperation.Subject;
                    mailOperation.Comments = dynamicMailOperation.Comments;
                    //mailOperation.Comments = string.Format("Dynamic {0} Execution Report" + GingerDicser.GetTermResValue(eTermResKey.RunSet));

                    mailOperation.HTMLReportTemplate           = RunSetActionHTMLReportSendEmail.eHTMLReportTemplate.HTMLReport;
                    mailOperation.selectedHTMLReportTemplateID = 100;//ID to mark defualt template

                    mailOperation.Email.IsBodyHTML  = true;
                    mailOperation.Email.EmailMethod = GingerCore.GeneralLib.Email.eEmailMethod.SMTP;
                    mailOperation.Email.MailFrom    = dynamicMailOperation.MailFrom;
                    mailOperation.Email.MailTo      = dynamicMailOperation.MailTo;
                    mailOperation.Email.Subject     = dynamicMailOperation.Subject;
                    if (dynamicMailOperation.SendViaOutlook)
                    {
                        mailOperation.Email.EmailMethod = GingerCore.GeneralLib.Email.eEmailMethod.OUTLOOK;
                    }
                    else
                    {
                        if (dynamicMailOperation.SmtpDetails != null)
                        {
                            mailOperation.Email.EmailMethod  = GingerCore.GeneralLib.Email.eEmailMethod.SMTP;
                            mailOperation.Email.SMTPMailHost = dynamicMailOperation.SmtpDetails.Server;
                            mailOperation.Email.SMTPPort     = int.Parse(dynamicMailOperation.SmtpDetails.Port);
                            mailOperation.Email.EnableSSL    = bool.Parse(dynamicMailOperation.SmtpDetails.EnableSSL);
                            if (string.IsNullOrEmpty(dynamicMailOperation.SmtpDetails.User) == false)
                            {
                                mailOperation.Email.ConfigureCredential = true;
                                mailOperation.Email.SMTPUser            = dynamicMailOperation.SmtpDetails.User;
                                mailOperation.Email.SMTPPass            = dynamicMailOperation.SmtpDetails.Password;
                            }
                        }
                    }

                    if (dynamicMailOperation.IncludeAttachmentReport)
                    {
                        EmailHtmlReportAttachment reportAttachment = new EmailHtmlReportAttachment();
                        reportAttachment.AttachmentType = EmailAttachment.eAttachmentType.Report;
                        reportAttachment.ZipIt          = true;
                        mailOperation.EmailAttachments.Add(reportAttachment);
                    }

                    runSetConfig.RunSetActions.Add(mailOperation);
                }
                else if (addOperation is JsonReport)
                {
                    JsonReport dynamicJsonReport = (JsonReport)addOperation;
                    RunSetActionJSONSummary jsonReportOperation = new RunSetActionJSONSummary();

                    jsonReportOperation.Name      = "Dynamic Json Report";
                    jsonReportOperation.Condition = (RunSetActionBase.eRunSetActionCondition)Enum.Parse(typeof(RunSetActionBase.eRunSetActionCondition), dynamicJsonReport.Condition, true);
                    jsonReportOperation.RunAt     = (RunSetActionBase.eRunAt)Enum.Parse(typeof(RunSetActionBase.eRunAt), dynamicJsonReport.RunAt, true);
                    jsonReportOperation.Active    = true;

                    runSetConfig.RunSetActions.Add(jsonReportOperation);
                }
            }

            // Set config
            runsetExecutor.RunSetConfig = runSetConfig;
        }
Example #30
0
        public void LoadContent(string args, CLIHelper cliHelper, RunsetExecutor runsetExecutor)
        {
            //TODO: make -s --solution  work  but not -solution or -Solution !!!!!!!!!!!!!!!!!!!!!!!!!!!!

            List <Arg> argsList = SplitArgs(args);


            // - SeekOrigin -- split keep -

            foreach (Arg arg in argsList)
            {
                switch (arg.ArgName)
                {
                case "--sourceControlType":
                    cliHelper.SetSourceControlType(arg.ArgValue);
                    break;

                case "--sourceControlUrl":
                    cliHelper.SetSourceControlURL(arg.ArgValue);
                    break;

                case "--sourceControlUser":
                    cliHelper.SetSourceControlUser(arg.ArgValue);
                    break;

                case "--sourceControlPassword":
                    cliHelper.SetSourceControlPassword(arg.ArgValue);
                    break;

                case "--sourceControlPasswordEncrypted":
                    cliHelper.PasswordEncrypted(arg.ArgValue);
                    break;

                case "--sourceControlProxyServer":
                    cliHelper.SourceControlProxyServer(arg.ArgValue);
                    break;

                case "--sourceControlProxyPort":
                    cliHelper.SourceControlProxyPort(arg.ArgValue);
                    break;

                case "-s":
                case "--solution":
                    cliHelper.Solution = arg.ArgValue;
                    break;

                case "-e":
                case "--env":
                case "--environment":
                    cliHelper.Env = arg.ArgValue;
                    break;

                case "-r":
                case "--runset":
                    cliHelper.Runset = arg.ArgValue;
                    break;

                case "--runAnalyzer":
                case "--analyzer":
                    cliHelper.RunAnalyzer = bool.Parse(arg.ArgValue);
                    break;

                case "--showAutoRunWindow":
                case "--autoRunWindow":
                    cliHelper.ShowAutoRunWindow = bool.Parse(arg.ArgValue);
                    break;

                case "--testArtifactsFolder":
                    cliHelper.TestArtifactsFolder = arg.ArgValue;
                    break;

                default:
                    Reporter.ToLog(eLogLevel.ERROR, "Unknown argument with '-' prefix: '" + arg + "'");
                    throw new ArgumentException("Unknown argument: ", arg.ArgName);
                }
            }
        }