コード例 #1
0
        /// <summary>
        /// TCM function to create test run for particular suite.
        /// Could be used to run pre-requisite flows
        /// </summary>
        /// <param name="testMode"></param>
        /// <returns></returns>
        public static string TCMPRCreateAndExecuteM2M(string sId, string pId, string cId)
        {
            string prTitle = "Pre-Requisite_" + recent;

            string[] lines = { "cd /",
                               "cd " + tcmPath,
                               "tcm run /create /title:" + "\"" + prTitle + "\"" + " /planid:"
                               + pId + " /suiteid:" + sId + " /configid:" + cId
                               + " /builddir:" + "\"" + destFilepath + "\"" + " /collection:" + ConfigFile.col + " /teamproject:"
                               + "\"" + ConfigFile.proj + "\"" + " /settingsname:" + "\"" + ConfigFile.settingsnme + "\"" + " /include" };
            string   tcmPRBat = curDir + tmp + "tcmPRCreate.bat";

            System.IO.File.WriteAllLines(tcmPRBat, lines);
            LogBatFileOutput(lines, tcmPRBat);
            string strTmp = CmdLine.GetCmdOut(tcmPRBat, true);

            if (strTmp.Contains("created with ID: "))
            {
                LogMessageToFile("Pre Requisite run Id was created successfully using tcm create overload function");
                sp.prRunId = strTmp.Split(new string[] { "created with ID: " }, StringSplitOptions.None)[1].Split('.')[0].Trim();
                Console.WriteLine("Pre Requisite run ID generated is : " + sp.prRunId);
                LogMessageToFile("Pre Requisite run ID generated is : " + sp.prRunId);
            }
            TCMPrExecute(sp.prRunId);

            if (!TFSFunctions.GetTestRunState(prTitle).Contains("Completed"))
            {
                throw new Exception("PR Suite Failed");
            }

            return(sp.prRunId);
        }
コード例 #2
0
        private static void CopyBuildBinaries()
        {
            //Added foreach loop to download multiple build drop - binaries
            string goodBuildPath = null;

            string[] definitions = null;
            string[] buildPaths  = null;

            definitions = ConfigFile.def.Split(',');
            buildPaths  = ConfigFile.actDrpPath.Split(',');

            for (int i = 0; i <= definitions.Count() - 1; i++)
            {
                goodBuildPath = TFSFunctions.GetBuildPath(goodBuildPath, definitions[i], buildPaths[i]);
                LogMessageToFile("Good Build path is : " + goodBuildPath);
                Console.WriteLine("Good Build path is : " + goodBuildPath);
                LogMessageToFile("HostName and destination are different");
                buildPath = destFilepath = curDir + @"Temp_DTR\Drops\" + ConfigFile.proj + "_" + recent;
                Directory.CreateDirectory(destFilepath);
                Console.WriteLine("Initiated ROBOCOPY for source : " + sourceFilePath + " and Destination :" + destFilepath);
                CmdLine.RBCopy();
                Console.WriteLine("Destination Path is : " + destFilepath);
                LogMessageToFile("Destination Path is : " + destFilepath);
            }

            //Removing the last directory for fixing multiple build issue
            destFilepath = destFilepath.Split(new string[] { ConfigFile.proj + "_" }, StringSplitOptions.None)[0];
            destFilepath = destFilepath.Substring(0, destFilepath.ToCharArray().Count() - 1);
        }
コード例 #3
0
 public static void MessageBody()
 {
     try
     {
         if (ConfigFile.splitRun)
         {
             TFSFunctions.PublishResultsInMail(sp.curRunId);
             for (int i = 1; i <= ConfigFile.systems - 1; i++)
             {
                 sp.EndTime = DateTime.Now.ToString();
                 TFSFunctions.PublishResultsInMail(i, true);
             }
         }
         else if (ConfigFile.distribute)
         {
             TFSFunctions.PublishResultsInMail(sp.curRunId);
             for (int i = 1; i <= ConfigFile.systems - 1; i++)
             {
                 sp.EndTime = DateTime.Now.ToString();
                 TFSFunctions.PublishResultsInMail(i);
             }
         }
         else
         {
             TFSFunctions.PublishResultsInMail(sp.curRunId);
         }
     }
     catch (Exception exe)
     {
         throw exe;
     }
 }
コード例 #4
0
        private static void RunWithoutDistribution()
        {
            if (ConfigFile.Runtitle != null)
            {
                ConfigFile.Runtitle = ConfigFile.Runtitle + "_Daily Run_";
            }
            else
            {
                ConfigFile.Runtitle = "Daily Run_";
            }
            //ConfigFile.type = "Controller";
            if (!string.IsNullOrWhiteSpace(ConfigFile.sId))
            {
                TCMFunctions.TCMCreateUsingSuiteId(ConfigFile.sId);
            }
            else
            {
                TCMFunctions.TCMCreate();
            }

            sp.StartTime = DateTime.Now.ToString();

            TCMFunctions.TCMExecute(sp.runId);

            sp.EndTime = DateTime.Now.ToString();

            Console.WriteLine("TFS Data Collection Started ...");
            TFSFunctions.CollectResultFromTFS(sp.curRunId);
            XML.Generate(sp, "O");
            LogMessageToFile("TFS Data Collection Started");
            Console.WriteLine("Done");
        }
コード例 #5
0
        private static void RunWithSplitDistribution()
        {
            //if (ConfigFile.type.ToUpper() == "Controller".ToUpper())
            if (ConfigFile.order == 0) //i.e. controller
            {
                LogMessageToFile("The Machine is the controller");
                if (ConfigFile.Runtitle != null)
                {
                    ConfigFile.Runtitle = ConfigFile.Runtitle + "_SR_";
                    TFSFunctions.CreateTestRun(ConfigFile.controllerSuite, 0, 0, true);  //change due to run title
                }
                else
                {
                    ConfigFile.Runtitle = "SR_";
                    TFSFunctions.CreateTestRun(ConfigFile.controllerSuite, 0, 0, true);  //change due to run title
                }
                sp.StartTime = DateTime.Now.ToString();

                TCMFunctions.TCMExecute(sp.runId);

                TFSFunctions.CollectResultFromTFS(sp.runId);

                //Handling the controller run failure. If condition to check the controller's run information.
                XML.Generate(sp, "O");
                if (XML.ReadGeneratedSplogFileAndAssertOutcome(XML.combinedPath))
                {
                    throw new Exception("Test Outcome Failure was True.");
                }

                //for (int i = 1; i <= ConfigFile.systems - 1; i++)
                //{
                sp.EndTime = DateTime.Now.ToString();
                //TFSFunctions.CollectResultFromTFS(i, true);
                //}
            }
            else
            {
                LogMessageToFile("The Machine is not the controller");
                string[] sysSuites = ConfigFile.executorSuite.Split(':');
                string   sId       = sysSuites[ConfigFile.order - 1];
                if (ConfigFile.Runtitle != null)
                {
                    ConfigFile.Runtitle = ConfigFile.Runtitle + "_SR_";
                    TFSFunctions.CreateTestRun(sId, 0, 0, true);  //change due to run title
                }
                else
                {
                    ConfigFile.Runtitle = "SR_";
                    TFSFunctions.CreateTestRun(sId, 0, 0, true); //change due to run title
                }
                TCMFunctions.TCMExecute(sp.runId);
                TFSFunctions.CollectResultFromTFS(sp.runId);
            }
            XML.Generate(sp, "O");
        }
コード例 #6
0
        private static void CollectResultsAfterReRun()
        {
            LogMessageToFile("Started ReRun result collection.");

            //if (ConfigFile.distribute && !ConfigFile.splitRun && ConfigFile.type.ToUpper() == "Controller".ToUpper())

            //else if (ConfigFile.splitRun && ConfigFile.type.ToUpper() == "Controller".ToUpper())
            if (ConfigFile.splitRun && ConfigFile.order == 0)
            {
                LogMessageToFile("Logic has entered SplitRun-True Module");

                if (!ConfigFile.skipReRun)
                {
                    for (int i = 1; i <= ConfigFile.systems - 1; i++)
                    {
                        LogMessageToFile("The int value of the order is : " + i.ToString());
                        TFSFunctions.WaitForReRunResults(i, true);
                    }

                    LogMessageToFile("ReRun resetting selected plan values.");
                }
                XML.ClearSelectedPlan();
                LogMessageToFile("ReRun resetting selected plan values. - completed");
                TFSFunctions.CollectResultFromTFS(sp.curRunId);
                for (int i = 1; i <= ConfigFile.systems - 1; i++)

                {
                    LogMessageToFile("The int value of the order is : " + i.ToString());

                    sp.EndTime = DateTime.Now.ToString();
                    TFSFunctions.CollectResultFromTFS(i, true);
                }
                XML.Generate(sp, "O");
            }
            else if (ConfigFile.distribute && ConfigFile.order == 0)
            {
                LogMessageToFile("Logic has entered SplitRun-False Module");

                if (!ConfigFile.skipReRun)
                {
                    for (int i = 1; i <= ConfigFile.systems - 1; i++)
                    {
                        LogMessageToFile("The int value of the order is : " + i.ToString());
                        TFSFunctions.WaitForReRunResults(i);
                    }

                    LogMessageToFile("ReRun resetting selected plan values.");
                }
                XML.ClearSelectedPlan();
                LogMessageToFile("ReRun resetting selected plan values. - completed");
                TFSFunctions.CollectResultFromTFS(sp.curRunId);
                for (int j = 1; j <= ConfigFile.systems - 1; j++)

                {
                    LogMessageToFile("The int value of the order is : " + j.ToString());

                    sp.EndTime = DateTime.Now.ToString();
                    TFSFunctions.CollectResultFromTFS(j);
                }
                XML.Generate(sp, "O");
            }
            else
            {
                LogMessageToFile("ReRun resetting selected plan values.");
                XML.ClearSelectedPlan();
                LogMessageToFile("ReRun resetting selected plan values. - completed");
                TFSFunctions.CollectResultFromTFS(sp.curRunId);
                XML.Generate(sp, "O");
            }
        }
コード例 #7
0
        private static void RunWithDistribution()
        {
            int sCount = 0;
            int eCount = 0;

            TFSFunctions.GetTestPointsCount();

            LogMessageToFile("The total number of test cases are - " + TFSFunctions.totalPoints.ToString());

            int average = (TFSFunctions.totalPoints / ConfigFile.systems);

            //if (ConfigFile.type.ToUpper() == "Controller".ToUpper())
            if (ConfigFile.order == 0)
            {
                eCount = average;
            }
            else if (ConfigFile.order > 0 && ConfigFile.order < ConfigFile.systems - 1)
            {
                sCount = (average * ConfigFile.order) + 1;
                eCount = average * (ConfigFile.order + 1);
            }
            else
            {
                sCount = (average * ConfigFile.order) + 1;
                eCount = TFSFunctions.totalPoints - 1;
            }

            if (ConfigFile.Runtitle != null)
            {
                ConfigFile.Runtitle = ConfigFile.Runtitle + "_DR_";
                TFSFunctions.CreateTestRun(ConfigFile.sId, sCount, eCount); //change due to run title
            }
            else
            {
                ConfigFile.Runtitle = "DR_";
                TFSFunctions.CreateTestRun(ConfigFile.sId, sCount, eCount);
            }

            sp.StartTime = DateTime.Now.ToString();

            TCMFunctions.TCMExecute(sp.runId);

            TFSFunctions.CollectResultFromTFS(sp.runId);

            //if (ConfigFile.type.ToUpper() == "Controller".ToUpper())
            if (ConfigFile.order == 0)
            {
                //Handling the controller run failure. If condition to check the controller's run information.
                XML.Generate(sp, "O");
                if (XML.ReadGeneratedSplogFileAndAssertOutcome(XML.combinedPath))
                {
                    throw new Exception("Test Outcome Failure was True.");
                }

                for (int i = 1; i <= ConfigFile.systems - 1; i++)
                {
                    sp.EndTime = DateTime.Now.ToString();
                    TFSFunctions.CollectResultFromTFS(i);
                }
            }
            XML.Generate(sp, "O");
        }
コード例 #8
0
        private static void ExecutionValidation()
        {
            string type = "CONTROLLER";

            try
            {
                if (ConfigFile.order != 0)
                {
                    type = "EXECUTOR";
                }
            }
            catch (Exception e)
            {
                type = "CONTROLLER";
            }
            testExecutionFailureOutcome = XML.ReadGeneratedSplogFileAndAssertOutcome(XML.combinedPath);

            if (ConfigFile.waitForReRun)
            {
                if (ConfigFile.splitRun || ConfigFile.distribute)
                {
                    switch (type)
                    {
                    case "CONTROLLER":
                        for (int i = 1; i <= ConfigFile.systems - 1; i++)
                        {
                            if (ConfigFile.splitRun != true)
                            {
                                TFSFunctions.WaitForExecutor(i);
                            }
                            else
                            {
                                TFSFunctions.WaitForExecutor(i, true);
                            }
                        }
                        break;

                    case "EXECUTOR":
                        if (ConfigFile.splitRun != true)
                        {
                            TFSFunctions.WaitForController();
                        }
                        else
                        {
                            TFSFunctions.WaitForController(true);
                        }
                        break;

                    default:
                        break;
                    }
                }
            }

            int runOutcome = TFSFunctions.EvaluateResultFromTFS(sp.curRunId);

            if (runOutcome == 2 || runOutcome == 3)
            {
                ProjectCustomization.ReRunCustomization();
                LogMessageToFile("RunOutcome was " + runOutcome.ToString());
            }
            CollectResultsAfterReRun();
        }