public void AfterBatch(TestBatch batch) { foreach (ITestListener testListener in this) { testListener.AfterBatch(batch); } }
/// <summary> Kicks off all batches specified. </summary> /// <param name="batchDirectory"> A directory to load Test batches from. </param> /// <param name="chassisManagerEndPoint"> Chassis Manager endpoint uri. </param> public void RunAllFrameworkBatches(string batchDirectory, string chassisManagerEndPoint, string userName, string userPassword) { var globalParameters = Parameters.GetSampleParameters(); string exceptionMessage = null; Assert.IsTrue( Directory.GetFiles(batchDirectory ?? @".", "*Batch.xml").Any(), String.Format("No batch found matching *Batch.xml in directory '{0}'", batchDirectory)); foreach (var batchDefinitionFile in Directory.GetFiles(batchDirectory ?? @".", "*Batch.xml")) { try { this.RunFrameworkBatch( TestBatch.LoadBatch(batchDefinitionFile), chassisManagerEndPoint, globalParameters, userName, userPassword); } catch (Exception ex) { exceptionMessage = ex.Message; } } Assert.IsTrue( string.IsNullOrEmpty(exceptionMessage), string.Format("At least one Batch failed to Load/Run;\n{0}", exceptionMessage)); }
public void BeforeBatch(TestBatch batch) { foreach (ITestListener testListener in this) { testListener.BeforeBatch(batch); } }
public void AfterBatch(TestBatch batch) { if (this.testBatch != null) { this.testBatch.EndTime = DateTime.Now.ToString("u"); this.testBatch.UpdateCounter(); } }
public void BeforeBatch(TestBatch batch) { this.testBatch.SetMainAssembly(batch.MainTestAssembly.Assembly); if (this.testBatchSearcher != null) { this.testBatch.HasHistory = true; } this.testBatch.StartTime = DateTime.Now.ToString("u"); }
public override void BeforeBatch(TestBatch batch) { base.BeforeBatch(batch); if (silent) { return; } this.Out.WriteLine("{0}: Starting tests", DateTime.Now.ToLongTimeString()); this.Out.Flush(); }
public override void AfterBatch(TestBatch batch) { base.AfterBatch(batch); if (silent) { return; } this.Out.WriteLine(); this.Out.WriteLine("{0}: Tests finished", DateTime.Now.ToLongTimeString()); this.Out.Flush(); }
/// <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(); } }
// GET: TestBatches/Details/5 public ActionResult Details(int?id) { if (db.TestResults.ToList().Any()) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } TestBatch testBatch = db.TestBatches.Find(id); if (testBatch == null) { return(HttpNotFound()); } return(View(testBatch)); } return(View()); }
/// <summary> /// Provides a test batching strategy based on the provided arguments /// </summary> /// <param name="strategy">The base strategy to provide</param> /// <param name="settings">Adapter settings currently in use</param> /// <returns>An ITestBatchingStrategy instance or null if one cannot be provided</returns> private ITestBatchingStrategy GetBatchStrategy(TestBatch.Strategy strategy, BoostTestAdapterSettings settings) { TestBatch.CommandLineArgsBuilder argsBuilder = GetDefaultArguments; if (strategy != Strategy.TestCase) { argsBuilder = GetBatchedTestRunsArguments; } switch (strategy) { case Strategy.Source: return new SourceTestBatchStrategy(this._testRunnerFactory, settings, argsBuilder); case Strategy.TestSuite: return new TestSuiteTestBatchStrategy(this._testRunnerFactory, settings, argsBuilder); case Strategy.TestCase: return new IndividualTestBatchStrategy(this._testRunnerFactory, settings, argsBuilder); } return null; }
public static void CreateSampleBatchFile( [Optional("SampleBatch.xml", Description = "Name of Batch File. Default=SampleBatch.xml")] 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); }
public void Generate() { var db = new DriverContext(); try { var testBatch = new TestBatch(); // Create the batch to use below. db.TestBatches.Add(testBatch); int batchValue; int alcoholValue; string batchCriteria; // Get the settings. var alcoholSetting = AppSettings.GetAppSettings("AlcoholPercentage"); var drugSetting = AppSettings.GetAppSettings("DrugPercentage"); // Convert to a percentage. var alcoholPercentage = (int.Parse(alcoholSetting) / 100.0); var drugPercentage = (int.Parse(drugSetting) / 100.0); // Get the quantity of alcohol and drug drivers to pull. int alcoholToPull = Convert.ToInt16(Math.Ceiling(db.Drivers.Count(d => d.Active) * alcoholPercentage)); int drugToPull = Convert.ToInt16(Math.Ceiling(db.Drivers.Count(d => d.Active) * drugPercentage)); // Check to see which one is greater to base the initial pull quantity from. if (drugPercentage > alcoholPercentage) { batchValue = drugToPull; alcoholValue = alcoholToPull; } else { batchValue = alcoholToPull; alcoholValue = alcoholToPull; } // Get the drivers based off the condition. var drivers = db.Drivers.OrderBy(r => Guid.NewGuid()).Take(batchValue); var batchId = db.TestBatches.Local.OrderByDescending(b => b.Id).Select(b => b.Id).First(); // Insert a test result and batchId for each driver. foreach (var driver in drivers) { TestResult testResult = new TestResult { DriverId = driver.Id, UserName = driver.UserName, TestBatchId = batchId }; db.TestResults.Add(testResult); } // Get the quantity of drivers for alcohol testing from the existing context. // If the alcohol setting is greater than the drug setting all flags will be flipped. var alcoholCanidates = db.TestResults.Local.AsQueryable().Take(alcoholValue); // Flip the flag for alcohol test applicants. foreach (var canidate in alcoholCanidates) { canidate.Alcohol = Alcohol.IsAlcohol; } // Insert batch criteria. var updateBatch = db.TestBatches.Local.OrderByDescending(b => b.Id).First(); batchCriteria = $"Drivers Pulled: {drivers.Count()}, Alcohol: {alcoholCanidates.Count()}, Drug: {drugSetting}%, Alcohol: {alcoholSetting}%"; updateBatch.Criteria = batchCriteria; // Save changes to the context. db.SaveChanges(); } catch (Exception e) { var error = new Error { ErrorDesc = e.ToString() }; db.Errors.Add(error); db.SaveChanges(); } }
public virtual void AfterBatch(TestBatch batch) { }
public virtual void BeforeBatch(TestBatch batch) { this.counter = new TestCounter(batch.GetTestCount()); }
/// <summary> Kicks off batch specified. </summary> /// <param name="batchDefinitionFile"> A Test batch objectame of batch file to load and run. </param> /// <param name="chassisManagerEndPoint"> Chassis Manager endpoint uri. </param> public void RunFrameworkBatch(string batchDefinitionFile, string chassisManagerEndPoint, string userName, string userPassword) { var batch = TestBatch.LoadBatch(batchDefinitionFile); this.RunFrameworkBatch(batch, chassisManagerEndPoint, Parameters.GetSampleParameters(), userName, userPassword); }