/// <summary> kicks off batch specified. </summary>
        /// <param name="batch"> A Test batch objectame of batch file to load and run. </param>
        /// <param name="chassisManagerEndPoint"> Chassis Manager endpoint uri. </param>
        /// <param name="globalParameters"> Global Parameters. </param>
        public void RunFrameworkBatch(TestBatch batch, string chassisManagerEndPoint, Parameters globalParameters, string userName, string userPassword)
        {
            var batchResults = new ResultOfTestBatch(batch.Name, chassisManagerEndPoint);

            try
            {
                batch.Run(globalParameters, batchResults, userName, userPassword);
            }
            catch (OperationCanceledException)
            {
                Console.WriteLine("\n********** Batch has Ended.\n");
            }
            finally
            {
                batchResults.Save();
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Loads a batch definition from XML file.
        /// </summary>
        /// <param name="batchDefinitionFile"> Name of the XML file. </param>
        /// <returns> A batch definition object. </returns>
        public static TestBatch LoadBatch(string batchDefinitionFile)
        {
            TestBatch batch = null;

            try
            {
                batch = Helper.LoadFromFile <TestBatch>(batchDefinitionFile);
                batch.BatchDefinitionFile = batchDefinitionFile;
                batch.SetDefaults();
            }
            catch (Exception ex)
            {
                Console.WriteLine("Unable to load Batch:{0};\r\n{1}", batchDefinitionFile, ex);
                throw;
            }

            return(batch);
        }
        /// <summary> Creates a sample Batch File. </summary>
        /// <param name="batchFile"> Name of the file where sample batch is to be saved. </param>
        public static void SampleBatchFile(string batchFile)
        {
            var batch = new TestBatch()
            {
                Name = Path.GetFileNameWithoutExtension(batchFile),
                Duration = TimeSpan.FromSeconds(145),
                ApiSla = TimeSpan.FromSeconds(100),
                GlobalParameters = Parameters.GetSampleParameters(),
                UserCredentials = new List<UserCredential>()
                {
                    new UserCredential()
                    {
                        Role = "Admin",
                        UserName = "******",
                        Password = "******"
                    }
                },
                TestSequences = new List<TestSequence>()
                {
                    new TestSequence()
                    {
                        SequenceName = "Run My API 1 and 2 using List",
                        SequenceIterations = 100,
                        DelayBetweenSequenceIterationsInMS = 0,
                        RotateParametersValueBetweenIterations = true,
                        ApiSla = TimeSpan.FromSeconds(1000),
                        RunAsRoles = "*",
                        UseLocalParametersOnly = true,
                        Tests = new List<Test>()
                        {
                            new Test()
                            {
                                Name = "myApi-1",
                                Iterations = 10,
                                DelayBetweenIterationsInMS = 2
                            },
                            new Test()
                            {
                                Name = "myLongRunningApi-2",
                                DelayBetweenIterationsInMS = 2,
                                ApiSla = TimeSpan.FromSeconds(10000)
                            }
                        },
                        LocalParameters = new Dictionary<string, List<string>>()
                        {
                            { "param1", new List<string>() { "P1val1", "P1val2" } },
                            { "param2", new List<string>() { "P2val1", "P2val2" } }
                        }
                    }
                }
            };

            Helper.SaveToFile(batch, batchFile);

            // Load and re-Save to grab all default values.
            var batchLoaded = Helper.LoadFromFile<TestBatch>(batchFile);
            batchLoaded.SetDefaults();
            Helper.SaveToFile(batchLoaded, batchFile);
        }