Ejemplo n.º 1
0
        public bool ExportBusinessFlowsResultToALM(ObservableList <BusinessFlow> BusinessFlows, ref string result, PublishToALMConfig publishToALMConfig, eALMConnectType almConnectionType, bool exectutedFromAutomateTab = false)
        {
            ALMCore.SolutionFolder = WorkSpace.Instance.Solution.Folder.ToUpper();
            bool isExportSucc = false;

            if (AutoALMProjectConnect(almConnectionType, false))
            {
                try
                {
                    foreach (BusinessFlow BizFlow in BusinessFlows) //Here going for each businessFlow
                    {
                        try
                        {
                            if (BizFlow.ExternalID != "0" && !String.IsNullOrEmpty(BizFlow.ExternalID))
                            {
                                Reporter.ToLog(eLogLevel.DEBUG, "Executing RunSet Action Publish to ALM for " + GingerDicser.GetTermResValue(eTermResKey.BusinessFlow) + " " + BizFlow.Name);
                                Reporter.ToStatus(eStatusMsgKey.ExportExecutionDetails, null, BizFlow.Name, "ALM");

                                if (publishToALMConfig.ToAttachActivitiesGroupReport)
                                {
                                    Ginger.Reports.GingerExecutionReport.ExtensionMethods.CreateActivitiesGroupReportsOfBusinessFlow(null, BizFlow);//need to find a way to specify the releveant environment
                                }

                                isExportSucc = AlmCore.ExportExecutionDetailsToALM(BizFlow, ref result, exectutedFromAutomateTab, publishToALMConfig);
                                if (isExportSucc)
                                {
                                    BizFlow.PublishStatus = BusinessFlow.ePublishStatus.Published;
                                }
                                else
                                {
                                    if ((result == null) || (result == string.Empty))
                                    {
                                        result = GingerDicser.GetTermResValue(eTermResKey.BusinessFlow) + " - " + BizFlow.Name + " - Error when uploading to ALM." + Environment.NewLine;
                                    }
                                    BizFlow.PublishStatus = BusinessFlow.ePublishStatus.PublishFailed;
                                }
                                Reporter.HideStatusMessage();
                            }
                            else
                            {
                                BizFlow.PublishStatus = BusinessFlow.ePublishStatus.NotPublished;
                                result += GingerDicser.GetTermResValue(eTermResKey.BusinessFlow) + " - " + BizFlow.Name + " - doesn't have ExternalID, cannot execute publish to ALM RunSet Action" + Environment.NewLine;
                                Reporter.ToLog(eLogLevel.WARN, BizFlow.Name + " - doesn't have ExternalID, cannot execute publish to ALM RunSet Action");
                            }
                        }
                        catch (Exception ex)
                        {
                            result = ex.Message.ToString();
                            BizFlow.PublishStatus = BusinessFlow.ePublishStatus.NotPublished;
                            Reporter.ToLog(eLogLevel.ERROR, BizFlow.Name + " - Export results to ALM failed due to exception", ex);
                        }
                    }

                    return(isExportSucc);
                }
                finally
                {
                    DisconnectALMServer();
                }
            }
            else
            {
                if (exectutedFromAutomateTab)
                {
                    result += "Execution results were not published, Failed to connect to ALM";
                    Reporter.ToLog(eLogLevel.WARN, "Execution results were not published, Failed to connect to ALM");
                }
                else
                {
                    foreach (BusinessFlow BizFlow in BusinessFlows)
                    {
                        BizFlow.PublishStatus = BusinessFlow.ePublishStatus.NotPublished;
                    }
                    result += "Didn't execute " + GingerDicser.GetTermResValue(eTermResKey.RunSet) + " action 'Publish to ALM', Failed to connect to ALM";
                    Reporter.ToLog(eLogLevel.WARN, "Didn't execute " + GingerDicser.GetTermResValue(eTermResKey.RunSet) + " action Publish to ALM, Failed to connect to ALM");
                }
                return(false);
            }
        }
Ejemplo n.º 2
0
 public bool ExportBusinessFlowsResultToALM(ObservableList <BusinessFlow> bfs, string refe, PublishToALMConfig PublishToALMConfig)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 3
0
        public bool ExportExecutionDetailsToRQM(BusinessFlow businessFlow, ref string result, bool exectutedFromAutomateTab = false, PublishToALMConfig publishToALMConfig = null)
        {
            result = string.Empty;
            string bfExportedID = GetExportedIDString(businessFlow.ExternalID, "RQMID");

            if (string.IsNullOrEmpty(bfExportedID) || bfExportedID.Equals("0"))
            {
                result = GingerDicser.GetTermResValue(eTermResKey.BusinessFlow) + ": " + businessFlow.Name + " is missing ExternalID, cannot export RQM TestPlan execution results without Extrnal ID";
                return(false);
            }

            if (businessFlow.ActivitiesGroups.Count == 0)
            {
                result = GingerDicser.GetTermResValue(eTermResKey.BusinessFlow) + ": " + businessFlow.Name + " Must have at least one " + GingerDicser.GetTermResValue(eTermResKey.ActivitiesGroup);
                return(false);
            }

            LoginDTO loginData = new LoginDTO()
            {
                User = ALMCore.AlmConfig.ALMUserName, Password = ALMCore.AlmConfig.ALMPassword, Server = ALMCore.AlmConfig.ALMServerURL
            };

            //
            // get data about execution records per current test plan - start
            RQMTestPlan testPlan             = new RQMTestPlan();
            string      importConfigTemplate = System.IO.Path.Combine(RQMCore.ConfigPackageFolderPath, "RQM_Import", "RQM_ImportConfigs_Template.xml");

            if (File.Exists(importConfigTemplate))
            {
                XmlSerializer serializer = new
                                           XmlSerializer(typeof(RQMProjectListConfiguration));
                FileStream fs     = new FileStream(importConfigTemplate, FileMode.Open);
                XmlReader  reader = XmlReader.Create(fs);
                RQMProjectListConfiguration RQMProjectList;
                RQMProjectList = (RQMProjectListConfiguration)serializer.Deserialize(reader);
                fs.Close();

                RQMProject currentRQMProjectMapping;
                if (RQMProjectList.RQMProjects.Count > 0)
                {
                    currentRQMProjectMapping = RQMProjectList.RQMProjects.Where(x => x.Name == ALMCore.AlmConfig.ALMProjectName || x.Name == "DefaultProjectName").FirstOrDefault();
                    if (currentRQMProjectMapping != null)
                    {
                        testPlan = RQMConnect.Instance.GetRQMTestPlanByIdByProject(ALMCore.AlmConfig.ALMServerURL, ALMCore.AlmConfig.ALMUserName, ALMCore.AlmConfig.ALMPassword, ALMCore.AlmConfig.ALMProjectName, GetExportedIDString(businessFlow.ExternalID, "RQMID"));

                        if (testPlan == null)
                        {
                            result = "Recent Testing Plan not exists in connected RQM project.";
                            return(false);
                        }

                        testPlan.RQMExecutionRecords = RQMConnect.Instance.GetExecutionRecordsByTestPlan(loginData, reader, currentRQMProjectMapping, RQMCore.ALMProjectGroupName, RQMCore.ALMProjectGuid, testPlan.URLPathVersioned);
                    }
                }
            }
            // get data about execution records per current test plan - finish

            List <ExecutionResult> exeResultList = new List <ExecutionResult>();

            foreach (ActivitiesGroup activGroup in businessFlow.ActivitiesGroups)
            {
                if ((publishToALMConfig.FilterStatus == FilterByStatus.OnlyPassed && activGroup.RunStatus == ActivitiesGroup.eActivitiesGroupRunStatus.Passed) ||
                    (publishToALMConfig.FilterStatus == FilterByStatus.OnlyFailed && activGroup.RunStatus == ActivitiesGroup.eActivitiesGroupRunStatus.Failed) ||
                    publishToALMConfig.FilterStatus == FilterByStatus.All)
                {
                    ExecutionResult exeResult = GetExeResultforAg(businessFlow, bfExportedID, activGroup, ref result, testPlan);
                    if (exeResult != null)
                    {
                        exeResultList.Add(exeResult);
                    }
                    else
                    {
                        return(false);
                    }
                }
            }

            ResultInfo resultInfo = new ResultInfo();

            //
            // Updating of Execution Record Results (test plan level)
            try
            {
                resultInfo = RQMConnect.Instance.RQMRep.ExportExecutionResult(loginData, exeResultList, RQMCore.ALMProjectGuid, ALMCore.AlmConfig.ALMProjectName, RQMCore.ALMProjectGroupName);
            }
            catch
            {
                Reporter.ToLog(eLogLevel.ERROR, "Failed to Update Execution Record Results");
            }

            //
            // Creating Test Suite Log (per test suite)
            try
            {
                foreach (RQMTestSuite rQMTestSuite in testPlan.TestSuites)
                {
                    if ((rQMTestSuite.ACL_TestSuite_Copy != null) && (rQMTestSuite.TestSuiteExecutionRecord.CurrentTestSuiteResult.ACL_TestSuiteLog_Copy != null))
                    {
                        resultInfo = RQMConnect.Instance.RQMRep.CreateTestSuiteLog(loginData, RQMCore.ALMProjectGuid, ALMCore.AlmConfig.ALMProjectName, RQMCore.ALMProjectGroupName, rQMTestSuite.ACL_TestSuite_Copy, rQMTestSuite.TestSuiteExecutionRecord.CurrentTestSuiteResult.ACL_TestSuiteLog_Copy);
                    }
                }
            }
            catch
            {
                Reporter.ToLog(eLogLevel.ERROR, "Failed to Update Execution Record Results");
            }

            //
            // Attaching of Activity Groups Reports
            try
            {
                // Attach ActivityGroup Report if needed
                if ((publishToALMConfig.ToAttachActivitiesGroupReport) || (exectutedFromAutomateTab))
                {
                    foreach (ActivitiesGroup activGroup in businessFlow.ActivitiesGroups)
                    {
                        try
                        {
                            ACL_Data_Contract.Activity   currentActivity  = GetTestCaseFromActivityGroup(activGroup);
                            ACL_Data_Contract.Attachment reportAttachment = new ACL_Data_Contract.Attachment();
                            string activityGroupName = PathHelper.CleanInValidPathChars(activGroup.Name);
                            if ((activGroup.TempReportFolder != null) && (activGroup.TempReportFolder != string.Empty) &&
                                (System.IO.Directory.Exists(activGroup.TempReportFolder)))
                            {
                                //Creating the Zip file - start
                                string targetZipPath = System.IO.Directory.GetParent(activGroup.TempReportFolder).ToString();
                                string zipFileName   = targetZipPath + "\\" + activityGroupName.ToString().Replace(" ", "_") + "_GingerHTMLReport.zip";
                                if (!System.IO.File.Exists(zipFileName))
                                {
                                    ZipFile.CreateFromDirectory(activGroup.TempReportFolder, zipFileName);
                                }
                                else
                                {
                                    System.IO.File.Delete(zipFileName);
                                    ZipFile.CreateFromDirectory(activGroup.TempReportFolder, zipFileName);
                                }
                                System.IO.Directory.Delete(activGroup.TempReportFolder, true);
                                //Creating the Zip file - finish

                                //Attaching Zip file - start
                                reportAttachment.ClientFileName = activityGroupName.ToString().Replace(" ", "_") + "_GingerHTMLReport.zip";
                                reportAttachment.ServerLocation = targetZipPath + @"\" + reportAttachment.ClientFileName;
                                reportAttachment.CreatedBy      = Environment.UserName;
                                currentActivity.EntityId        = Convert.ToInt32(GetExportedIDString(activGroup.ExternalID.ToString(), "RQMID"));
                                currentActivity.ExportedID      = (long)currentActivity.EntityId;
                                currentActivity.ActivityData.AttachmentsColl = new Attachments();
                                currentActivity.ActivityData.AttachmentsColl.Add(reportAttachment);

                                string exportJarFilePath = Assembly.GetExecutingAssembly().Location.Replace(@"GingerCore.dll", "") + @"ALM\\RQM\\JAVA";
                                resultInfo = RQMConnect.Instance.RQMRep.UploadAttachmetToRQMAndGetIds(loginData, RQMCore.ALMProjectGuid, ALMCore.AlmConfig.ALMProjectName, RQMCore.ALMProjectGroupName, currentActivity, exportJarFilePath);

                                resultInfo = RQMConnect.Instance.RQMRep.UpdateTestCaseWithNewAttachmentID(loginData, RQMCore.ALMProjectGuid, ALMCore.AlmConfig.ALMProjectName, RQMCore.ALMProjectGroupName, currentActivity);

                                //Attaching Zip file - finish
                                System.IO.File.Delete(zipFileName);
                            }
                        }
                        catch
                        {
                            Reporter.ToLog(eLogLevel.ERROR, "Failed to attach report Per ActivityGroup - " + activGroup.Name);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                resultInfo.ErrorCode = 1;
                result = e.ToString();
            }

            if (resultInfo.ErrorCode == 0)
            {
                result = "Export execution details to RQM performed successfully.";
                return(true);
            }
            else
            {
                result = resultInfo.ErrorDesc;
            }

            Reporter.ToLog(eLogLevel.ERROR, "Failed to export execution details to RQM/ALM");
            return(false);
        }
Ejemplo n.º 4
0
        public static bool ExportExceutionDetailsToALM(BusinessFlow bizFlow, ref string result, ObservableList <ExternalItemFieldBase> runFields, bool exectutedFromAutomateTab, PublishToALMConfig publishToALMConfig = null)
        {
            result = string.Empty;
            if (bizFlow.ExternalID == "0" || String.IsNullOrEmpty(bizFlow.ExternalID))
            {
                result = GingerDicser.GetTermResValue(eTermResKey.BusinessFlow) + ": " + bizFlow.Name + " is missing ExternalID, cannot locate QC TestSet without External ID";
                return(false);
            }

            try
            {
                //get the BF matching test set
                QCTestSet testSet = ImportFromQCRest.GetQCTestSet(bizFlow.ExternalID);//bf.externalID holds the TestSet TSTests collection id
                if (testSet != null)
                {
                    //get the Test set TC's
                    QCTestInstanceColl qcTSTests = QCRestAPIConnect.GetTestInstancesOfTestSet(testSet.Id); //list of TSTest's on main TestSet in TestLab

                    //get all BF Activities groups
                    ObservableList <ActivitiesGroup> activGroups = bizFlow.ActivitiesGroups;
                    if (activGroups.Count > 0)
                    {
                        foreach (ActivitiesGroup activGroup in activGroups)
                        {
                            if ((publishToALMConfig.FilterStatus == FilterByStatus.OnlyPassed && activGroup.RunStatus == eActivitiesGroupRunStatus.Passed) ||
                                (publishToALMConfig.FilterStatus == FilterByStatus.OnlyFailed && activGroup.RunStatus == eActivitiesGroupRunStatus.Failed) ||
                                publishToALMConfig.FilterStatus == FilterByStatus.All)
                            {
                                QCTestInstance tsTest = null;
                                //go by TC ID = TC Instances ID
                                tsTest = qcTSTests.Find(x => x.TestId == activGroup.ExternalID && x.Id == activGroup.ExternalID2);
                                if (tsTest == null)
                                {
                                    //go by Linked TC ID + TC Instances ID
                                    tsTest = qcTSTests.Find(x => ImportFromQCRest.GetTSTestLinkedID(x) == activGroup.ExternalID && x.Id == activGroup.ExternalID2);
                                }
                                if (tsTest == null)
                                {
                                    //go by TC ID
                                    tsTest = qcTSTests.Find(x => x.TestId == activGroup.ExternalID);
                                }
                                if (tsTest != null)
                                {
                                    //get activities in group
                                    List <Activity> activities   = (bizFlow.Activities.Where(x => x.ActivitiesGroupID == activGroup.Name)).Select(a => a).ToList();
                                    string          TestCaseName = PathHelper.CleanInValidPathChars(tsTest.Name);
                                    if ((publishToALMConfig.VariableForTCRunName == null) || (publishToALMConfig.VariableForTCRunName == string.Empty))
                                    {
                                        String timeStamp = DateTime.Now.ToString("dd-MMM-yyyy HH:mm:ss");
                                        publishToALMConfig.VariableForTCRunName = "GingerRun_" + timeStamp;
                                    }

                                    QCRun runToExport = new QCRun();

                                    foreach (ExternalItemFieldBase field in runFields)
                                    {
                                        if (field.ToUpdate || field.Mandatory)
                                        {
                                            if (string.IsNullOrEmpty(field.SelectedValue) == false && field.SelectedValue != "NA")
                                            {
                                                runToExport.ElementsField.Add(field.ExternalID, field.SelectedValue);
                                            }
                                            else
                                            {
                                                try { runToExport.ElementsField.Add(field.ExternalID, "NA"); }
                                                catch { }
                                            }
                                        }
                                    }

                                    runToExport.ElementsField["name"]        = publishToALMConfig.VariableForTCRunNameCalculated;
                                    runToExport.ElementsField["test-id"]     = tsTest.TestId;
                                    runToExport.ElementsField["testcycl-id"] = tsTest.Id;
                                    runToExport.ElementsField["cycle-id"]    = tsTest.CycleId;
                                    runToExport.ElementsField["duration"]    = "0";
                                    runToExport.ElementsField["subtype-id"]  = "hp.qc.run.MANUAL";
                                    runToExport.ElementsField["owner"]       = ALMCore.AlmConfig.ALMUserName;

                                    QCItem          itemToExport = ConvertObjectValuesToQCItem(runToExport, ResourceType.TEST_RUN);
                                    ALMResponseData responseData = QCRestAPIConnect.CreateNewEntity(ResourceType.TEST_RUN, itemToExport);
                                    if (!responseData.IsSucceed)
                                    {
                                        result = "Failed to create run using rest API";
                                        return(false);
                                    }
                                    QCRun currentRun = QCRestAPIConnect.GetRunDetail(responseData.IdCreated);

                                    // Attach ActivityGroup Report if needed
                                    if (publishToALMConfig.ToAttachActivitiesGroupReport)
                                    {
                                        if ((activGroup.TempReportFolder != null) && (activGroup.TempReportFolder != string.Empty) &&
                                            (System.IO.Directory.Exists(activGroup.TempReportFolder)))
                                        {
                                            //Creating the Zip file - start
                                            string targetZipPath = System.IO.Directory.GetParent(activGroup.TempReportFolder).ToString();
                                            string zipFileName   = targetZipPath + "\\" + TestCaseName.ToString() + "_GingerHTMLReport.zip";

                                            if (!System.IO.File.Exists(zipFileName))
                                            {
                                                ZipFile.CreateFromDirectory(activGroup.TempReportFolder, zipFileName);
                                            }
                                            else
                                            {
                                                System.IO.File.Delete(zipFileName);
                                                ZipFile.CreateFromDirectory(activGroup.TempReportFolder, zipFileName);
                                            }
                                            System.IO.Directory.Delete(activGroup.TempReportFolder, true);
                                            //Creating the Zip file - finish

                                            ALMResponseData attachmentResponse = QCRestAPIConnect.CreateAttachment(ResourceType.TEST_RUN, currentRun.Id, zipFileName);

                                            if (!attachmentResponse.IsSucceed)
                                            {
                                                result = "Failed to create attachment";
                                                return(false);
                                            }

                                            System.IO.File.Delete(zipFileName);
                                        }
                                    }


                                    //create run with activities as steps
                                    QCRunStepColl runSteps = ImportFromQCRest.GetRunSteps(currentRun.Id);

                                    int index = 1;
                                    foreach (QCRunStep runStep in runSteps)
                                    {
                                        //search for matching activity based on ID and not order, un matching steps need to be left as No Run
                                        string   stepName         = runStep.Name;
                                        Activity matchingActivity = activities.Where(x => x.ExternalID == runStep.ElementsField["desstep-id"].ToString()).FirstOrDefault();
                                        if (matchingActivity != null)
                                        {
                                            switch (matchingActivity.Status)
                                            {
                                            case Amdocs.Ginger.CoreNET.Execution.eRunStatus.Failed:
                                                runStep.Status = "Failed";
                                                List <IAct> failedActs = matchingActivity.Acts.Where(x => x.Status == Amdocs.Ginger.CoreNET.Execution.eRunStatus.Failed).ToList();
                                                string      errors     = string.Empty;
                                                foreach (Act act in failedActs)
                                                {
                                                    errors += act.Error + Environment.NewLine;
                                                }
                                                runStep.Actual = errors;
                                                break;

                                            case Amdocs.Ginger.CoreNET.Execution.eRunStatus.NA:
                                                runStep.ElementsField["status"] = "N/A";
                                                runStep.ElementsField["actual"] = "NA";
                                                break;

                                            case Amdocs.Ginger.CoreNET.Execution.eRunStatus.Passed:
                                                runStep.ElementsField["status"] = "Passed";
                                                runStep.ElementsField["actual"] = "Passed as expected";
                                                break;

                                            case Amdocs.Ginger.CoreNET.Execution.eRunStatus.Skipped:
                                                runStep.ElementsField["status"] = "N/A";
                                                runStep.ElementsField["actual"] = "Skipped";
                                                break;

                                            case Amdocs.Ginger.CoreNET.Execution.eRunStatus.Pending:
                                                runStep.ElementsField["status"] = "No Run";
                                                runStep.ElementsField["actual"] = "Was not executed";
                                                break;

                                            case Amdocs.Ginger.CoreNET.Execution.eRunStatus.Running:
                                                runStep.ElementsField["status"] = "Not Completed";
                                                runStep.ElementsField["actual"] = "Not Completed";
                                                break;
                                            }
                                        }
                                        else
                                        {
                                            //Step not exist in Ginger so left as "No Run" unless it is step data
                                            if (runStep.Name.ToUpper() == "STEP DATA")
                                            {
                                                runStep.ElementsField["status"] = "Passed";
                                            }
                                            else
                                            {
                                                runStep.ElementsField["status"] = "No Run";
                                            }
                                        }

                                        QCItem          stepToUpdate      = ConvertObjectValuesToQCItem(runStep, ResourceType.RUN_STEP);
                                        ALMResponseData stepDataForUpdate = QCRestAPIConnect.UpdateEntity(ResourceType.RUN_STEP, runStep.Id, stepToUpdate);

                                        index++;
                                    }

                                    //get all execution status for all steps
                                    ObservableList <string> stepsStatuses = new ObservableList <string>();
                                    foreach (QCRunStep runStep in runSteps)
                                    {
                                        stepsStatuses.Add(runStep.Status);
                                    }

                                    //update the TC general status based on the activities status collection.
                                    if (stepsStatuses.Where(x => x == "Failed").Count() > 0)
                                    {
                                        currentRun.Status = "Failed";
                                    }
                                    else if (stepsStatuses.Where(x => x == "No Run").Count() == runSteps.Count || stepsStatuses.Where(x => x == "N/A").Count() == runSteps.Count)
                                    {
                                        currentRun.Status = "No Run";
                                    }
                                    else if (stepsStatuses.Where(x => x == "Passed").Count() == runSteps.Count || (stepsStatuses.Where(x => x == "Passed").Count() + stepsStatuses.Where(x => x == "N/A").Count()) == runSteps.Count)
                                    {
                                        currentRun.ElementsField["status"] = "Passed";
                                    }
                                    else
                                    {
                                        currentRun.ElementsField["status"] = "Not Completed";
                                    }

                                    QCItem          runToUpdate      = ConvertObjectValuesToQCItem(currentRun, ResourceType.TEST_RUN);
                                    ALMResponseData runDataForUpdate = QCRestAPIConnect.UpdateEntity(ResourceType.TEST_RUN, currentRun.Id, runToUpdate);
                                }
                                else
                                {
                                    //No matching TC was found for the ActivitiesGroup in QC
                                    result = "Matching TC's were not found for all " + GingerDicser.GetTermResValue(eTermResKey.ActivitiesGroups) + " in QC/ALM.";
                                }
                            }
                            if (result != string.Empty)
                            {
                                return(false);
                            }
                        }
                    }
                    else
                    {
                        //No matching Test Set was found for the BF in QC
                        result = "No matching Test Set was found in QC/ALM.";
                    }

                    if (result == string.Empty)
                    {
                        result = "Export performed successfully.";
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
            }
            catch (Exception ex)
            {
                result = "Unexpected error occurred- " + ex.Message;
                Reporter.ToLog(eLogLevel.ERROR, "Failed to export execution details to QC/ALM", ex);
                return(false);
            }

            return(false); // Remove it at the end
        }
Ejemplo n.º 5
0
 public void ExportBusinessFlowsResultToALM(ObservableList <BusinessFlow> bfs, ref string result, PublishToALMConfig publishToALMConfig, object silence)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 6
0
 public void ExportBusinessFlowsResultToALM(ObservableList <BusinessFlow> bfs, ref string result, PublishToALMConfig publishToALMConfig, object silence)
 {
     ALM.ALMIntegration.Instance.ExportBusinessFlowsResultToALM(bfs, ref result, publishToALMConfig, ALM.ALMIntegration.eALMConnectType.Silence);
 }
Ejemplo n.º 7
0
 public bool ExportBusinessFlowsResultToALM(ObservableList <BusinessFlow> bfs, string result, PublishToALMConfig PublishToALMConfig)
 {
     return(ALMIntegration.Instance.ExportBusinessFlowsResultToALM(bfs, ref result, PublishToALMConfig, ALMIntegration.eALMConnectType.Auto, false));
 }
Ejemplo n.º 8
0
        public static bool ExportExecutionDetailsToQC(BusinessFlow bizFlow, ref string result, PublishToALMConfig publishToALMConfig = null)
        {
            result = string.Empty;
            if (bizFlow.ExternalID == "0" || String.IsNullOrEmpty(bizFlow.ExternalID))
            {
                result = GingerDicser.GetTermResValue(eTermResKey.BusinessFlow) + ": " + bizFlow.Name + " is missing ExternalID, cannot locate QC TestSet without External ID";
                return(false);
            }

            try
            {
                //get the BF matching test set
                TestSet testSet = ImportFromQC.GetQCTestSet(bizFlow.ExternalID);//bf.externalID holds the TestSet TSTests collection id
                if (testSet != null)
                {
                    //get the Test set TC's
                    List <TSTest> qcTSTests = ImportFromQC.GetTSTestsList(testSet); //list of TSTest's on main TestSet in TestLab

                    //get all BF Activities groups
                    ObservableList <ActivitiesGroup> activGroups = bizFlow.ActivitiesGroups;
                    if (activGroups.Count > 0)
                    {
                        foreach (ActivitiesGroup activGroup in activGroups)
                        {
                            if ((publishToALMConfig.FilterStatus == FilterByStatus.OnlyPassed && activGroup.RunStatus == eActivitiesGroupRunStatus.Passed) ||
                                (publishToALMConfig.FilterStatus == FilterByStatus.OnlyFailed && activGroup.RunStatus == eActivitiesGroupRunStatus.Failed) ||
                                publishToALMConfig.FilterStatus == FilterByStatus.All)
                            {
                                TSTest tsTest = null;
                                //go by TC ID = TC Instance ID
                                tsTest = qcTSTests.Where(x => x.TestId == activGroup.ExternalID && x.ID == activGroup.ExternalID2).FirstOrDefault();
                                if (tsTest == null)
                                {
                                    //go by Linked TC ID + TC Instance ID
                                    tsTest = qcTSTests.Where(x => ImportFromQC.GetTSTestLinkedID(x) == activGroup.ExternalID && x.ID == activGroup.ExternalID2).FirstOrDefault();
                                }
                                if (tsTest == null)
                                {
                                    //go by TC ID
                                    tsTest = qcTSTests.Where(x => x.TestId == activGroup.ExternalID).FirstOrDefault();
                                }
                                if (tsTest != null)
                                {
                                    //get activities in group
                                    List <Activity> activities   = (bizFlow.Activities.Where(x => x.ActivitiesGroupID == activGroup.Name)).Select(a => a).ToList();
                                    string          TestCaseName = PathHelper.CleanInValidPathChars(tsTest.TestName);
                                    if ((publishToALMConfig.VariableForTCRunName == null) || (publishToALMConfig.VariableForTCRunName == string.Empty))
                                    {
                                        String timeStamp = DateTime.Now.ToString("dd-MMM-yyyy HH:mm:ss");
                                        publishToALMConfig.VariableForTCRunName = "GingerRun_" + timeStamp;
                                    }

                                    RunFactory runFactory = (RunFactory)tsTest.RunFactory;
                                    Run        run        = (Run)runFactory.AddItem(publishToALMConfig.VariableForTCRunNameCalculated);

                                    // Attach ActivityGroup Report if needed
                                    if (publishToALMConfig.ToAttachActivitiesGroupReport)
                                    {
                                        if ((activGroup.TempReportFolder != null) && (activGroup.TempReportFolder != string.Empty) &&
                                            (System.IO.Directory.Exists(activGroup.TempReportFolder)))
                                        {
                                            //Creating the Zip file - start
                                            string targetZipPath = System.IO.Directory.GetParent(activGroup.TempReportFolder).ToString();
                                            string zipFileName   = targetZipPath + "\\" + TestCaseName.ToString() + "_GingerHTMLReport.zip";

                                            if (!System.IO.File.Exists(zipFileName))
                                            {
                                                ZipFile.CreateFromDirectory(activGroup.TempReportFolder, zipFileName);
                                            }
                                            else
                                            {
                                                System.IO.File.Delete(zipFileName);
                                                ZipFile.CreateFromDirectory(activGroup.TempReportFolder, zipFileName);
                                            }
                                            System.IO.Directory.Delete(activGroup.TempReportFolder, true);
                                            //Creating the Zip file - finish
                                            //Attaching Zip file - start
                                            AttachmentFactory      attachmentFactory = (AttachmentFactory)run.Attachments;
                                            TDAPIOLELib.Attachment attachment        = (TDAPIOLELib.Attachment)attachmentFactory.AddItem(System.DBNull.Value);
                                            attachment.Description = "TC Ginger Execution HTML Report";
                                            attachment.Type        = 1;
                                            attachment.FileName    = zipFileName;
                                            attachment.Post();

                                            //Attaching Zip file - finish
                                            System.IO.File.Delete(zipFileName);
                                        }
                                    }


                                    //create run with activities as steps
                                    run.CopyDesignSteps();
                                    run.Post();
                                    StepFactory stepF     = run.StepFactory;
                                    List        stepsList = stepF.NewList("");

                                    //int i = 0;
                                    int index = 1;
                                    foreach (Step step in stepsList)
                                    {
                                        //search for matching activity based on ID and not order, un matching steps need to be left as No Run
                                        int      stepDesignID     = (stepsList[index]).Field("ST_DESSTEP_ID");
                                        Activity matchingActivity = activities.Where(x => x.ExternalID == stepDesignID.ToString()).FirstOrDefault();
                                        if (matchingActivity != null)
                                        {
                                            switch (matchingActivity.Status)
                                            {
                                            case Amdocs.Ginger.CoreNET.Execution.eRunStatus.Failed:
                                                step.Status = "Failed";
                                                List <IAct> failedActs = matchingActivity.Acts.Where(x => x.Status == Amdocs.Ginger.CoreNET.Execution.eRunStatus.Failed).ToList();
                                                string      errors     = string.Empty;
                                                foreach (Act act in failedActs)
                                                {
                                                    errors += act.Error + Environment.NewLine;
                                                }
                                                step["ST_ACTUAL"] = errors;
                                                break;

                                            case Amdocs.Ginger.CoreNET.Execution.eRunStatus.NA:
                                                step.Status       = "N/A";
                                                step["ST_ACTUAL"] = "NA";
                                                break;

                                            case Amdocs.Ginger.CoreNET.Execution.eRunStatus.Passed:
                                                step.Status       = "Passed";
                                                step["ST_ACTUAL"] = "Passed as expected";
                                                break;

                                            case Amdocs.Ginger.CoreNET.Execution.eRunStatus.Skipped:
                                                //step.Status = "No Run";
                                                step.Status       = "N/A";
                                                step["ST_ACTUAL"] = "Skipped";
                                                break;

                                            case Amdocs.Ginger.CoreNET.Execution.eRunStatus.Pending:
                                                step.Status       = "No Run";
                                                step["ST_ACTUAL"] = "Was not executed";
                                                break;

                                            case Amdocs.Ginger.CoreNET.Execution.eRunStatus.Running:
                                                step.Status       = "Not Completed";
                                                step["ST_ACTUAL"] = "Not Completed";
                                                break;
                                            }
                                        }
                                        else
                                        {
                                            //Step not exist in Ginger so left as "No Run" unless it is step data
                                            if (step.Name.ToUpper() == "STEP DATA")
                                            {
                                                step.Status = "Passed";
                                            }
                                            else
                                            {
                                                step.Status = "No Run";
                                            }
                                        }
                                        step.Post();
                                        index++;
                                    }

                                    //get all execution status for all steps
                                    ObservableList <string> stepsStatuses = new ObservableList <string>();
                                    foreach (Step step in stepsList)
                                    {
                                        stepsStatuses.Add(step.Status);
                                    }

                                    //update the TC general status based on the activities status collection.
                                    if (stepsStatuses.Where(x => x == "Failed").Count() > 0)
                                    {
                                        run.Status = "Failed";
                                    }
                                    else if (stepsStatuses.Where(x => x == "No Run").Count() == stepsList.Count || stepsStatuses.Where(x => x == "N/A").Count() == stepsList.Count)
                                    {
                                        run.Status = "No Run";
                                    }
                                    else if (stepsStatuses.Where(x => x == "Passed").Count() == stepsList.Count || (stepsStatuses.Where(x => x == "Passed").Count() + stepsStatuses.Where(x => x == "N/A").Count()) == stepsList.Count)
                                    {
                                        run.Status = "Passed";
                                    }
                                    else
                                    {
                                        run.Status = "Not Completed";
                                    }
                                    run.Post();
                                }
                                else
                                {
                                    //No matching TC was found for the ActivitiesGroup in QC
                                    result = "Matching TC's were not found for all " + GingerDicser.GetTermResValue(eTermResKey.ActivitiesGroups) + " in QC/ALM.";
                                }
                            }
                        }
                    }
                    else
                    {
                        //No matching Test Set was found for the BF in QC
                        result = "No matching Test Set was found in QC/ALM.";
                    }
                }
                if (result == string.Empty)
                {
                    result = "Export performed successfully.";
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                result = "Unexpected error occurred- " + ex.Message;
                Reporter.ToLog(eLogLevel.ERROR, "Failed to export execution details to QC/ALM", ex);
                //if (!silentMode)
                //    Reporter.ToUser(eUserMsgKey.ErrorWhileExportingExecDetails, ex.Message);
                return(false);
            }
        }
Ejemplo n.º 9
0
        internal bool ExportExceutionDetailsToALM(BusinessFlow bizFlow, ref string result, ObservableList <ExternalItemFieldBase> runFields, bool exectutedFromAutomateTab, PublishToALMConfig publishToALMConfig)
        {
            result = string.Empty;
            if (bizFlow.ExternalID == "0" || String.IsNullOrEmpty(bizFlow.ExternalID))
            {
                result = GingerDicser.GetTermResValue(eTermResKey.BusinessFlow) + ": " + bizFlow.Name + " is missing ExternalID, cannot locate QC TestSet without External ID";
                return(false);
            }

            try
            {
                //get the BF matching test set
                List <BaseResponseItem> exportedPhase = zephyrEntRepository.GetPhaseById(Convert.ToInt32(bizFlow.ExternalID2));
                BaseResponseItem        item          = exportedPhase.FirstOrDefault(md => md.id.ToString().Equals(bizFlow.ExternalID));
                if (item == null)
                {
                    BaseResponseItem firstItem = exportedPhase.FirstOrDefault();
                    foreach (var category in (JArray)firstItem.TryGetItem("categories"))
                    {
                        BaseResponseItem treeNode = category.ToObject <BaseResponseItem>();
                        if (treeNode.id.ToString().Equals(bizFlow.ExternalID))
                        {
                            item = treeNode;
                            break;
                        }
                    }
                }
                if (item != null)
                {
                    long scheduleId = 0;
                    //get the Test set TC's
                    List <TestCaseResource> testCaseResources = zephyrEntRepository.GetTestCasesByAssignmentTree(Convert.ToInt32(item.id));
                    //get phase execution list
                    List <Execution> executions = zephyrEntRepository.GetExecutionsByPhaseId(Convert.ToInt64(bizFlow.ExternalID2));
                    //get all BF Activities groups
                    ObservableList <ActivitiesGroup> activGroups = bizFlow.ActivitiesGroups;
                    if (activGroups.Count > 0)
                    {
                        foreach (ActivitiesGroup activGroup in activGroups)
                        {
                            if ((publishToALMConfig.FilterStatus == FilterByStatus.OnlyPassed && activGroup.RunStatus == eActivitiesGroupRunStatus.Passed) ||
                                (publishToALMConfig.FilterStatus == FilterByStatus.OnlyFailed && activGroup.RunStatus == eActivitiesGroupRunStatus.Failed) ||
                                publishToALMConfig.FilterStatus == FilterByStatus.All)
                            {
                                TestCaseResource testCase = null;
                                //go by TC ID = TC Instances ID
                                testCase = testCaseResources.Find(x => x.testcase.testcaseId.ToString() == activGroup.ExternalID);
                                if (testCase != null)
                                {
                                    //get activities in group
                                    List <Activity> activities   = (bizFlow.Activities.Where(x => x.ActivitiesGroupID == activGroup.Name)).Select(a => a).ToList();
                                    string          TestCaseName = PathHelper.CleanInValidPathChars(activGroup.Name);
                                    if ((publishToALMConfig.VariableForTCRunName == null) || (publishToALMConfig.VariableForTCRunName == string.Empty))
                                    {
                                        String timeStamp = DateTime.Now.ToString("dd-MMM-yyyy HH:mm:ss");
                                        publishToALMConfig.VariableForTCRunName = "GingerRun_" + timeStamp;
                                    }
                                    scheduleId = executions.FindLast(tc => tc.tcrTreeTestcase.testcase.testcaseId.ToString().Equals(activGroup.ExternalID)).id;
                                    string  notes           = publishToALMConfig.VariableForTCRunNameCalculated;
                                    dynamic executionResult = zephyrEntRepository.ExecuteTestCase(scheduleId, GetTestStatus(activGroup), zephyrEntRepository.GetCurrentUser()[0].id, notes);

                                    if (executionResult == null)
                                    {
                                        result = "Failed to create run using rest API";
                                        return(false);
                                    }

                                    // Attach ActivityGroup Report if needed
                                    if (publishToALMConfig.ToAttachActivitiesGroupReport)
                                    {
                                        if ((activGroup.TempReportFolder != null) && (activGroup.TempReportFolder != string.Empty) &&
                                            (System.IO.Directory.Exists(activGroup.TempReportFolder)))
                                        {
                                            //Creating the Zip file - start
                                            string targetZipPath = System.IO.Directory.GetParent(activGroup.TempReportFolder).ToString();
                                            string zipFileName   = targetZipPath + "\\" + TestCaseName + "_GingerHTMLReport.zip";

                                            if (!System.IO.File.Exists(zipFileName))
                                            {
                                                ZipFile.CreateFromDirectory(activGroup.TempReportFolder, zipFileName);
                                            }
                                            else
                                            {
                                                System.IO.File.Delete(zipFileName);
                                                ZipFile.CreateFromDirectory(activGroup.TempReportFolder, zipFileName);
                                            }
                                            System.IO.Directory.Delete(activGroup.TempReportFolder, true);
                                            //Creating the Zip file - finish

                                            Execution attachmentExecution = zephyrEntRepository.UpdateTestCaseAttachment(scheduleId.ToString(), zipFileName);

                                            if (attachmentExecution == null)
                                            {
                                                result = "Failed to create attachment";
                                                return(false);
                                            }

                                            System.IO.File.Delete(zipFileName);
                                        }
                                    }
                                }
                                else
                                {
                                    //No matching TC was found for the ActivitiesGroup in QC
                                    result = "Matching TC's were not found for all " + GingerDicser.GetTermResValue(eTermResKey.ActivitiesGroups) + " in QC/ALM.";
                                }
                            }
                            if (result != string.Empty)
                            {
                                return(false);
                            }
                        }
                    }
                    else
                    {
                        //No matching Test Set was found for the BF in QC
                        result = "No matching Test Set was found in QC/ALM.";
                    }

                    if (result == string.Empty)
                    {
                        result = "Export performed successfully.";
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
            }
            catch (Exception ex)
            {
                result = "Unexpected error occurred- " + ex.Message;
                Reporter.ToLog(eLogLevel.ERROR, "Failed to export execution details to QC/ALM", ex);
                return(false);
            }

            return(false); // Remove it at the end
        }
Ejemplo n.º 10
0
 private static ObservableList <ExternalItemFieldBase> SetALMTypeAndFieldsFromSolutionToOperation(PublishToALMConfig publishToALMConfig, ObservableList <ExternalItemFieldBase> solutionAlmFields)
 {
     // Set ALMType and Fields to operation publishToALMConfig selection, for Run Set only (virtual BF)
     if (!publishToALMConfig.PublishALMType.ToString().Equals(RunSetActionPublishToQC.AlmTypeDefault) &&
         publishToALMConfig.ALMTestSetLevel == PublishToALMConfig.eALMTestSetLevel.RunSet)
     {
         ALMIntegration.Instance.UpdateALMType(publishToALMConfig.PublishALMType, true);
         // Set ExternalItemsFields as selected publishToALMConfig ALMFields and at 'finally' return to the solution fields.
         solutionAlmFields = new ObservableList <ExternalItemFieldBase>(WorkSpace.Instance.Solution.ExternalItemsFields);
         foreach (ExternalItemFieldBase field in solutionAlmFields)
         {
             WorkSpace.Instance.Solution.ExternalItemsFields.Remove(field);
         }
         foreach (ExternalItemFieldBase field in publishToALMConfig.AlmFields)
         {
             WorkSpace.Instance.Solution.ExternalItemsFields.Add(field);
         }
     }
     Reporter.ToLog(eLogLevel.INFO, "ALM Type and Fields change from solution to operation configuration");
     return(solutionAlmFields);
 }
 public bool ExportVirtualBusinessFlowToALM(BusinessFlow businessFlow, PublishToALMConfig publishToALMConfig, bool performSaveAfterExport = false, ALMIntegrationEnums.eALMConnectType almConnectStyle = ALMIntegrationEnums.eALMConnectType.Silence, string testPlanUploadPath = null, string testLabUploadPath = null)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 12
0
        public bool ExportBusinessFlowsResultToALM(ObservableList <BusinessFlow> BusinessFlows, ref string result, PublishToALMConfig publishToALMConfig, eALMConnectType almConnectionType, bool exectutedFromAutomateTab = false)
        {
            ObservableList <ExternalItemFieldBase> solutionAlmFields = null;

            try
            {
                solutionAlmFields      = SetALMTypeAndFieldsFromSolutionToOperation(publishToALMConfig, solutionAlmFields);
                ALMCore.SolutionFolder = WorkSpace.Instance.Solution.Folder.ToUpper();
                if (AutoALMProjectConnect(almConnectionType, false))
                {
                    return(AlmCore.ExportBusinessFlowsResultToALM(BusinessFlows, ref result, publishToALMConfig, almConnectionType, exectutedFromAutomateTab));
                }
                else
                {
                    if (exectutedFromAutomateTab)
                    {
                        result += "Execution results were not published, Failed to connect to ALM";
                        Reporter.ToLog(eLogLevel.WARN, "Execution results were not published, Failed to connect to ALM");
                    }
                    else
                    {
                        foreach (BusinessFlow BizFlow in BusinessFlows)
                        {
                            BizFlow.PublishStatus = BusinessFlow.ePublishStatus.NotPublished;
                        }
                        result += "Didn't execute " + GingerDicser.GetTermResValue(eTermResKey.RunSet) + " action 'Publish to ALM', Failed to connect to ALM";
                        Reporter.ToLog(eLogLevel.WARN, "Didn't execute " + GingerDicser.GetTermResValue(eTermResKey.RunSet) + " action Publish to ALM, Failed to connect to ALM");
                    }
                    return(false);
                }
            }
            catch (Exception ex)
            {
                return(false);
            }
            finally
            {
                ResetALMTypeAndFieldsFromOperationToSolution(publishToALMConfig, solutionAlmFields);
            }
        }
 public bool ExportVirtualBusinessFlowToALM(BusinessFlow businessFlow, PublishToALMConfig publishToALMConfig, bool performSaveAfterExport = false, eALMConnectType almConnectStyle = eALMConnectType.Silence, string testPlanUploadPath = null, string testLabUploadPath = null)
 {
     return(ALMIntegration.Instance.ExportVirtualBusinessFlowToALM(businessFlow, publishToALMConfig, performSaveAfterExport, almConnectStyle, testPlanUploadPath, testLabUploadPath));
 }
Ejemplo n.º 14
0
 public bool ExportVirtualBusinessFlowToALM(BusinessFlow businessFlow, PublishToALMConfig publishToALMConfig, bool performSaveAfterExport = false, eALMConnectType almConnectStyle = eALMConnectType.Silence, string testPlanUploadPath = null, string testLabUploadPath = null)
 {
     return(false);
 }
Ejemplo n.º 15
0
        public bool ExportBusinessFlowsResultToALM(ObservableList <BusinessFlow> bfs, ref string refe, PublishToALMConfig PublishToALMConfig)
        {
            ALMCore aLMCore = GetALMCore();

            aLMCore.ConnectALMServer();
            return(aLMCore.ExportBusinessFlowsResultToALM(bfs, ref refe, PublishToALMConfig, eALMConnectType.Silence));
        }
Ejemplo n.º 16
0
        public void ExportBusinessFlowsResultToALM(ObservableList <BusinessFlow> bfs, ref string result, PublishToALMConfig publishToALMConfig, object silence)
        {
            ALMCore aLMCore = GetALMCore();

            aLMCore.ConnectALMServer();
            aLMCore.ExportBusinessFlowsResultToALM(bfs, ref result, publishToALMConfig, (eALMConnectType)silence);
        }