private LoadGen.LoadGen CreateAndStartLoadGenClient(string scriptFile, string server) { try { XmlDocument doc = new XmlDocument(); doc.Load(scriptFile); TestDuration = long.Parse(doc.SelectSingleNode("LoadGenFramework/CommonSection/StopMode/TotalTime").InnerText); if (string.Compare(doc.FirstChild.Name, "LoadGenFramework", true, new CultureInfo("en-US")) != 0) { throw new ConfigException("LoadGen Configuration File Schema Invalid!"); } _numberOfLoadGenClients++; _loadGen = new LoadGen.LoadGen(doc.FirstChild); _loadGen.LoadGenStopped += new LoadGenEventHandler(LoadGen_Stopped); _loadGen.Start(); } catch (ConfigException) { throw; } catch (Exception) { throw; } return(_loadGen); }
/// <summary> /// ITestStep.Execute() implementation /// </summary> /// <param name='testConfig'>The Xml fragment containing the configuration for this test step</param> /// <param name='context'>The context for the test, this holds state that is passed beteen tests</param> public void Execute(XmlNode testConfig, Context context) { _ctx = context; var loadGenTestConfig = context.ReadConfigAsString(testConfig, "LoadGenTestConfig"); try { context.LogInfo("About to execute LoadGen script: {0}", loadGenTestConfig); var doc = new XmlDocument(); doc.Load(loadGenTestConfig); if (string.Compare(doc.FirstChild.Name, "LoadGenFramework", true, new CultureInfo("en-US")) != 0) { throw new ConfigException("LoadGen Configuration File Schema Invalid!"); } var loadGen = new LoadGen.LoadGen(doc.FirstChild); loadGen.LoadGenStopped += LoadGenStopped; loadGen.Start(); } catch (ConfigException cex) { context.LogError(cex.Message); throw; } catch (Exception ex) { context.LogError(ex.Message); throw; } while (!_bExitApp) { Thread.Sleep(0x3e8); } Thread.Sleep(0x1388); }