protected override void OnInitialize() { Logger.Debug("OnInitialize: Enter"); if (ProcessContext == null) { throw new AwarenessException("ProcessContext == null"); } if (DatapoolManager == null) { throw new AwarenessException("DatapoolManager == null"); } string scriptName = GrinderContext.GetProperty(ScriptFileKey); if (string.IsNullOrWhiteSpace(scriptName)) { throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Missing property '{0}'", ScriptFileKey)); } Logger.Trace(x => x("OnInitialize: scriptName = {0}", scriptName)); ScriptWorker = CSScript.Evaluator.LoadFile(scriptName); if (!(ScriptWorker is IGrinderWorker)) { throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Type '{0}', from script file '{1}', does not implement '{2}'", ScriptWorker.GetType(), scriptName, typeof(IGrinderWorker).FullName)); } ProcessContext.InitializeAwareness(ScriptWorker); ((IGrinderWorker)ScriptWorker).Initialize(); Logger.Debug(x => x("OnInitialize: Exit, ScriptWorker = {0}", ScriptWorker.GetType().FullName)); }
private void InitializeBinPath() { Logger.Trace("InitializeBinPath: Enter"); string binFolder = GrinderContext.GetProperty(Constants.BinFolderKey); BinPath = string.IsNullOrWhiteSpace(binFolder) ? new[] { ScriptFolder } : new[] { FixDirectorySuffix(binFolder), ScriptFolder }; Logger.Trace("InitializeBinPath: Exit"); }
private void InitializeRandom() { IsRandom = bool.Parse(GrinderContext.GetProperty(GetPropertyKey("random"), bool.TrueString)); if (!IsRandom) { return; } Seed = int.Parse(GrinderContext.GetProperty(GetPropertyKey("seed"), ((int)DateTime.Now.Ticks).ToString())); Random = new Random(Seed); }
private int GetTestPrRunFromProperty() { string valueString = GrinderContext.GetProperty(Constants.VerificationWorkerTestsPrRunKey, "1"); int result = int.Parse(valueString, CultureInfo.CurrentCulture); if (result < 1) { throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Property '{0}' should be > 0, but was {1}", Constants.VerificationWorkerTestsPrRunKey, result)); } return(result); }
public void CreateMissingDatapoolsFromProperties() { int firstElement = GetValidFirstElement(); int lastElement = GetValidLastElement(firstElement); for (int i = firstElement; i <= lastElement; i++) { string datapoolName = GrinderContext.GetProperty(GetFactoryPropertyKey(i.ToString())); if (!string.IsNullOrWhiteSpace(datapoolName)) { CreateMissingDatapoolFromProperties(datapoolName); } } }
private void InitializeDebugger() { Logger.Trace("InitializeDebugger: Enter"); if (bool.Parse(GrinderContext.GetProperty(Constants.LaunchDebuggerKey, bool.FalseString))) { Logger.Trace("InitializeDebugger: Launching debugger..."); System.Diagnostics.Debugger.Launch(); } else { Logger.Trace("InitializeDebugger: Not launching debugger..."); } Logger.Trace("InitializeDebugger: Exit"); }
private void AddWorkerToCollectionByLoadFactor(int index) { string workerTypeName = GrinderContext.GetProperty(GetElementPropertyKey(index, "workerType")); if (!string.IsNullOrWhiteSpace(workerTypeName)) { int loadFactor = GetIntProperty(GetElementPropertyKey(index, "loadFactor"), 1); Logger.Info(m => m("AddWorkerToCollectionByLoadFactor: Index = {0}, WorkerType = '{1}', LoadFactor = {2}", index, workerTypeName, loadFactor)); for (int i = 0; i < loadFactor; i++) { workers.Add(TypeHelper.CreateTargetTypeFromName <IGrinderWorker>(workerTypeName)); } } else { Logger.Trace(m => m("AddWorkerToCollectionByLoadFactor: Property '{0}' not set", GetElementPropertyKey(index, "workerType"))); } }
public void CreateDatapool <T>(IDatapoolValuesFactory <T> datapoolValuesFactory, string name) where T : class { if (datapoolValuesFactory == null) { throw new ArgumentNullException("datapoolValuesFactory"); } if (string.IsNullOrWhiteSpace(name)) { throw new ArgumentNullException("name"); } IList <T> values = datapoolValuesFactory.CreateValues(GrinderContext, name); bool isRandom = bool.Parse(GrinderContext.GetProperty(GetPropertyKey(name, "random"), bool.FalseString)); int seed = int.Parse(GrinderContext.GetProperty(GetPropertyKey(name, "seed"), ((int)DateTime.Now.Ticks).ToString())); var distributionMode = (DatapoolThreadDistributionMode)Enum.Parse(typeof(DatapoolThreadDistributionMode), GrinderContext.GetProperty(GetPropertyKey(name, "distributionMode"), DatapoolThreadDistributionMode.ThreadShared.ToString()), false); bool isCircular = bool.Parse(GrinderContext.GetProperty(GetPropertyKey(name, "circular"), bool.TrueString)); var datapoolMetatdata = new DefaultDatapoolMetadata <T>(values, isRandom, seed, distributionMode, isCircular, name); CreateDatapool(datapoolMetatdata); }
private int GetIntProperty(string key, int defaultValue) { string valueString = GrinderContext.GetProperty(key, defaultValue.ToString(CultureInfo.InvariantCulture)); return(int.Parse(valueString, CultureInfo.CurrentCulture)); }