private void closeController() { //try to gracefully shut down the controller if (_engine != null) { try { int rc = _engine.CloseController(); if (rc != 0) { ConsoleWriter.WriteErrLine("\t\tFailed to close Controller with CloseController API function, rc: " + rc); } //give the controller 15 secs to shutdown. otherwise, print an error. Thread.Sleep(15000); var process = Process.GetProcessesByName("Wlrun"); if (process.Length > 0) { ConsoleWriter.WriteErrLine("\t\tThe Controller is still running..."); return; } }catch (Exception e) { ConsoleWriter.WriteErrLine("\t\t Cannot close Controller gracefully, exception details:"); ConsoleWriter.WriteErrLine(e.Message); ConsoleWriter.WriteErrLine(e.StackTrace); ConsoleWriter.WriteErrLine("killing Controller process"); cleanENV(); } } _engine = null; }
public PerformanceTestRunner(IAssetRunner runner, TimeSpan timeout, int pollingInterval, TimeSpan perScenarioTimeOut, List <string> ignoreErrorStrings) { this._runner = runner; this._timeout = timeout; this._pollingInterval = pollingInterval; this._perScenarioTimeOutMinutes = perScenarioTimeOut; this._ignoreErrorStrings = ignoreErrorStrings; this._scenarioEnded = false; _engine = null; this._errors = null; this._errorsCount = 0; }
public PerformanceTestRunner(IAssetRunner runner, TimeSpan timeout, int pollingInterval, TimeSpan perScenarioTimeOut, List<string> ignoreErrorStrings) { this._runner = runner; this._timeout = timeout; this._pollingInterval = pollingInterval; this._perScenarioTimeOut = perScenarioTimeOut; this._ignoreErrorStrings = ignoreErrorStrings; this._scenarioEnded = false; _engine = null; this._errors = null; this._errorsCount = 0; }
public PerformanceTestRunner(IAssetRunner runner, TimeSpan timeout, int pollingInterval, TimeSpan perScenarioTimeOut, List <string> ignoreErrorStrings, bool displayController, string analysisTemplate) { this._runner = runner; this._timeout = timeout; this._pollingInterval = pollingInterval; this._perScenarioTimeOutMinutes = perScenarioTimeOut; this._ignoreErrorStrings = ignoreErrorStrings; this._displayController = displayController; this._analysisTemplate = analysisTemplate; this._scenarioEnded = false; _engine = null; this._errors = null; this._errorsCount = 0; }
private void closeController_Kill() { //try to gracefully shut down the controller if (_engine != null) { try { var process = Process.GetProcessesByName("Wlrun"); if (process.Length > 0) { int rc = _engine.CloseController(); if (rc != 0) { ConsoleWriter.WriteErrLine( "\t\tFailed to close Controller with CloseController API function, rc: " + rc); } } if (_engine != null) { process = Process.GetProcessesByName("Wlrun"); if (process.Length > 0) { ConsoleWriter.WriteErrLine("\t\tThe Controller is still running..."); Stopper wlrunStopper = new Stopper(10000); wlrunStopper.Start(); KillController(); return; } } } catch (Exception e) { ConsoleWriter.WriteErrLine("\t\t Cannot close Controller gracefully, exception details:"); ConsoleWriter.WriteErrLine(e.Message); ConsoleWriter.WriteErrLine(e.StackTrace); ConsoleWriter.WriteErrLine("killing Controller process"); cleanENV(); } } _engine = null; }
private void closeController() { //try to gracefully shut down the controller if (_engine != null) { int rc = _engine.CloseController(); if (rc != 0) { ConsoleWriter.WriteErrLine("\t\tFailed to close Controller with CloseController API function, rc: " + rc); } //give the controller 15 secs to shutdown. otherwise, print an error. Thread.Sleep(15000); var process = Process.GetProcessesByName("Wlrun"); if (process.Length > 0) { ConsoleWriter.WriteErrLine("\t\tThe Controller is still running..."); return; } } _engine = null; }
private bool runScenario(string scenario, ref string errorReason, RunCancelledDelegate runCancelled) { cleanENV(); ConsoleWriter.WriteLine(string.Format(Resources.LrInitScenario, scenario)); //start controller _engine = new LrEngine(); if (_engine == null) { errorReason = string.Format(Resources.LrFailToOpenController, scenario); return(false); } //try to register the end scenario event: _scenarioEndedEvent = false; try { _engine.Events.ScenarioEvents.OnScenarioEnded += ScenarioEvents_OnScenarioEnded; _scenarioEndedEvent = true; } catch (Exception e) { ConsoleWriter.WriteException(Resources.LrFailToRegisterEndScenarioEvent, e); _scenarioEndedEvent = false; } if (_displayController == true) { _engine.ShowMainWindow(1); } else { _engine.ShowMainWindow(0); } //pointer to the scenario object: LrScenario currentScenario = _engine.Scenario; //try to open the scenario and validate the scenario and connect to load generators if (openScenario(scenario, ref errorReason) && validateScenario(currentScenario, ref errorReason)) { //apply rts to scripts foreach (ScriptRTSModel scriptRTS in _scriptRTSSet) { try { LrScripts currentScripts = currentScenario.Scripts; LrScript currentScript = currentScripts.Item[scriptRTS.GetScriptName()]; string runtimeSettings = "", actionLogic = ""; currentScript.GetScriptRunTimeSettings(ref runtimeSettings, ref actionLogic); RTSHelper rtsHelper = new RTSHelper(runtimeSettings, RTSHelper.COMMAND_ARGUMENTS, scriptRTS.GetKeyValuePairs()); string updatedRuntimeSettings = rtsHelper.GetUpdatedIniFileText(); currentScript.SetScriptRunTimeSettings(updatedRuntimeSettings, actionLogic); } catch (Exception e) { errorReason = string.Format(Resources.LrRTSError, scriptRTS.GetScriptName(), e.Message); return(false); } } //set the result dir: ConsoleWriter.WriteLine("setting scenario result folder to " + Path.Combine(_resultsFolder, LRR_FOLDER)); currentScenario.ResultDir = Path.Combine(_resultsFolder, LRR_FOLDER); ConsoleWriter.WriteLine("scenario result folder: " + currentScenario.ResultDir); //check if canceled or timedOut: if (_runCancelled()) { errorReason = Resources.GeneralTimedOut; return(false); } _scenarioEnded = false; ConsoleWriter.WriteLine(Resources.LrStartScenario); int ret = currentScenario.Start(); if (!currentScenario.ResultDir.Equals(Path.Combine(_resultsFolder, LRR_FOLDER))) { ConsoleWriter.WriteLine("controller failed to write to " + Path.Combine(_resultsFolder, LRR_FOLDER) + " setting result folder to " + currentScenario.ResultDir); _controller_result_dir = new DirectoryInfo(currentScenario.ResultDir).Name; ConsoleWriter.WriteLine("controller reult dir: " + _controller_result_dir); } if (ret != 0) { errorReason = string.Format(Resources.LrStartScenarioFail, scenario, ret); return(false); } //per scenario timeout stopwatch _stopWatch = Stopwatch.StartNew(); //wait for scenario to end: if (!waitForScenario(ref errorReason)) { //something went wrong during scenario execution, error reason set in errorReason string return(false); } else {//scenario has ended Console.WriteLine(string.Format(Resources.LrScenarioEnded, scenario, _stopWatch.Elapsed.Hours, _stopWatch.Elapsed.Minutes, _stopWatch.Elapsed.Seconds)); //collate results collateResults(); } } else { return(false); } return(true); }
private bool runScenario(string scenario, ref string errorReason, RunCancelledDelegate runCancelled) { cleanENV(); ConsoleWriter.WriteLine(string.Format(Resources.LrInitScenario, scenario)); //start controller _engine = new LrEngine(); if (_engine == null) { errorReason = string.Format(Resources.LrFailToOpenController, scenario); return(false); } //try to register the end scenario event: _scenarioEndedEvent = false; try { _engine.Events.ScenarioEvents.OnScenarioEnded += ScenarioEvents_OnScenarioEnded; _scenarioEndedEvent = true; } catch (Exception e) { ConsoleWriter.WriteException(Resources.LrFailToRegisterEndScenarioEvent, e); _scenarioEndedEvent = false; } _engine.ShowMainWindow(0); #if DEBUG _engine.ShowMainWindow(1); #endif //pointer to the scenario object: LrScenario currentScenario = _engine.Scenario; //try to open the scenario and validate the scenario and connect to load generators if (openScenario(scenario, ref errorReason) && validateScenario(currentScenario, ref errorReason)) { //set the result dir: ConsoleWriter.WriteLine("setting scenario result folder to " + Path.Combine(_resultsFolder, LRR_FOLDER)); currentScenario.ResultDir = Path.Combine(_resultsFolder, LRR_FOLDER); ConsoleWriter.WriteLine("scenario result folder: " + currentScenario.ResultDir); //check if canceled or timedOut: if (_runCancelled()) { errorReason = Resources.GeneralTimedOut; return(false); } _scenarioEnded = false; ConsoleWriter.WriteLine(Resources.LrStartScenario); int ret = currentScenario.Start(); if (!currentScenario.ResultDir.Equals(Path.Combine(_resultsFolder, LRR_FOLDER))) { ConsoleWriter.WriteLine("controller failed to write to " + Path.Combine(_resultsFolder, LRR_FOLDER) + " setting result folder to " + currentScenario.ResultDir); _controller_result_dir = new DirectoryInfo(currentScenario.ResultDir).Name; ConsoleWriter.WriteLine("controller reult dir: " + _controller_result_dir); } if (ret != 0) { errorReason = string.Format(Resources.LrStartScenarioFail, scenario, ret); return(false); } //per scenario timeout stopwatch _stopWatch = Stopwatch.StartNew(); //wait for scenario to end: if (!waitForScenario(ref errorReason)) { //something went wrong during scenario execution, error reason set in errorReason string return(false); } else {//scenario has ended Console.WriteLine(string.Format(Resources.LrScenarioEnded, scenario, _stopWatch.Elapsed.Hours, _stopWatch.Elapsed.Minutes, _stopWatch.Elapsed.Seconds)); //collate results collateResults(); } } else { return(false); } return(true); }
private void closeController() { //try to gracefully shut down the controller if (_engine != null) { try { int rc = _engine.CloseController(); if (rc != 0) { ConsoleWriter.WriteErrLine("\t\tFailed to close Controller with CloseController API function, rc: " + rc); } //give the controller 15 secs to shutdown. otherwise, print an error. Thread.Sleep(15000); var process = Process.GetProcessesByName("Wlrun"); if (process.Length > 0) { ConsoleWriter.WriteErrLine("\t\tThe Controller is still running..."); return; } }catch(Exception e) { ConsoleWriter.WriteErrLine("\t\t Cannot close Controller gracefully, exception details:"); ConsoleWriter.WriteErrLine(e.Message); ConsoleWriter.WriteErrLine(e.StackTrace); ConsoleWriter.WriteErrLine("killing Controller process"); cleanENV(); } } _engine = null; }
private bool runScenario(string scenario, ref string errorReason, RunCancelledDelegate runCancelled) { cleanENV(); ConsoleWriter.WriteLine(string.Format(Resources.LrInitScenario, scenario)); //start controller _engine = new LrEngine(); if (_engine == null) { errorReason = string.Format(Resources.LrFailToOpenController, scenario); return false; } //try to register the end scenario event: _scenarioEndedEvent = false; try { _engine.Events.ScenarioEvents.OnScenarioEnded += ScenarioEvents_OnScenarioEnded; _scenarioEndedEvent = true; } catch (Exception e) { ConsoleWriter.WriteException(Resources.LrFailToRegisterEndScenarioEvent, e); _scenarioEndedEvent = false; } _engine.ShowMainWindow(0); #if DEBUG _engine.ShowMainWindow(1); #endif //pointer to the scenario object: LrScenario currentScenario = _engine.Scenario; //try to open the scenario and validate the scenario and connect to load generators if (openScenario(scenario, ref errorReason) && validateScenario(currentScenario, ref errorReason)) { //set the result dir: ConsoleWriter.WriteLine("setting scenario result folder to " + Path.Combine(_resultsFolder, LRR_FOLDER)); currentScenario.ResultDir = Path.Combine(_resultsFolder, LRR_FOLDER); ConsoleWriter.WriteLine("scenario result folder: " + currentScenario.ResultDir); //check if canceled or timedOut: if (_runCancelled()) { errorReason = Resources.GeneralTimedOut; return false; } _scenarioEnded = false; ConsoleWriter.WriteLine(Resources.LrStartScenario); int ret = currentScenario.Start(); if (!currentScenario.ResultDir.Equals(Path.Combine(_resultsFolder, LRR_FOLDER))) { ConsoleWriter.WriteLine("controller failed to write to " + Path.Combine(_resultsFolder, LRR_FOLDER) + " setting result folder to " + currentScenario.ResultDir); _controller_result_dir = new DirectoryInfo(currentScenario.ResultDir).Name; ConsoleWriter.WriteLine("controller reult dir: " + _controller_result_dir); } if (ret != 0) { errorReason = string.Format(Resources.LrStartScenarioFail, scenario, ret); return false; } //per scenario timeout stopwatch _stopWatch = Stopwatch.StartNew(); //wait for scenario to end: if (!waitForScenario(ref errorReason)) { //something went wrong during scenario execution, error reason set in errorReason string return false; } else {//scenario has ended Console.WriteLine(string.Format(Resources.LrScenarioEnded, scenario,_stopWatch.Elapsed.Hours,_stopWatch.Elapsed.Minutes, _stopWatch.Elapsed.Seconds)); //collate results collateResults(); } } else { return false; } return true; }
private void closeController_Kill() { //try to gracefully shut down the controller if (_engine != null) { try { var process = Process.GetProcessesByName("Wlrun"); if (process.Length > 0) { int rc = _engine.CloseController(); if (rc != 0) { ConsoleWriter.WriteErrLine( "\t\tFailed to close Controller with CloseController API function, rc: " + rc); } } if (_engine != null) { process = Process.GetProcessesByName("Wlrun"); if (process.Length > 0) { ConsoleWriter.WriteErrLine("\t\tThe Controller is still running..."); Stopper wlrunStopper = new Stopper(10000); wlrunStopper.Start(); KillController(); return; } } } catch (Exception e) { ConsoleWriter.WriteErrLine("\t\t Cannot close Controller gracefully, exception details:"); ConsoleWriter.WriteErrLine(e.Message); ConsoleWriter.WriteErrLine(e.StackTrace); ConsoleWriter.WriteErrLine("killing Controller process"); cleanENV(); } } _engine = null; }
private void closeController() { //try to gracefully shut down the controller if (_engine != null) { int rc = _engine.CloseController(); if (rc != 0) { ConsoleWriter.WriteErrLine("\t\tFailed to close Controller with CloseController API function, rc: " + rc); } //give the controller 15 secs to shutdown. otherwise, print an error. Thread.Sleep(15000); var process = Process.GetProcessesByName("Wlrun"); if (process.Length > 0) { ConsoleWriter.WriteErrLine("\t\tThe Controller is still running..."); return; } } _engine = null; }