From 43e07efbc843ba1edd0c0369c50da331b5a1b2d6 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Mon, 31 Oct 2011 22:27:12 +0000 Subject: [PATCH 1/4] Fix bot disconnection --- OpenSim/Tools/pCampBot/PhysicsBot.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenSim/Tools/pCampBot/PhysicsBot.cs b/OpenSim/Tools/pCampBot/PhysicsBot.cs index 1531b27f40..03c6f850f4 100644 --- a/OpenSim/Tools/pCampBot/PhysicsBot.cs +++ b/OpenSim/Tools/pCampBot/PhysicsBot.cs @@ -162,7 +162,7 @@ namespace pCampBot client.Throttle.Total = 400000; client.Network.LoginProgress += this.Network_LoginProgress; client.Network.SimConnected += this.Network_SimConnected; -// client.Network.Disconnected += this.Network_OnDisconnected; + client.Network.Disconnected += this.Network_OnDisconnected; client.Objects.ObjectUpdate += Objects_NewPrim; //client.Assets.OnAssetReceived += Asset_ReceivedCallback; if (client.Network.Login(FirstName, LastName, Password, "pCampBot", "Your name")) From d366a08ebbc861a9db8ab27dd7f375a349d297ff Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Mon, 31 Oct 2011 22:52:49 +0000 Subject: [PATCH 2/4] Stop individual bots attempting to download the same asset more than once --- OpenSim/Tools/pCampBot/PhysicsBot.cs | 50 ++++++++++++++++++++-------- 1 file changed, 36 insertions(+), 14 deletions(-) diff --git a/OpenSim/Tools/pCampBot/PhysicsBot.cs b/OpenSim/Tools/pCampBot/PhysicsBot.cs index 03c6f850f4..0344a829f3 100644 --- a/OpenSim/Tools/pCampBot/PhysicsBot.cs +++ b/OpenSim/Tools/pCampBot/PhysicsBot.cs @@ -56,6 +56,11 @@ namespace pCampBot public event AnEvent OnConnected; public event AnEvent OnDisconnected; + /// + /// Track the assets we have and have not received so we don't endlessly repeat requests. + /// + public Dictionary AssetsReceived { get; private set; } + protected Timer m_action; // Action Timer protected List objectIDs = new List(); @@ -86,6 +91,8 @@ namespace pCampBot startupConfig = bsconfig; readconfig(); talkarray = readexcuses(); + + AssetsReceived = new Dictionary(); } //We do our actions here. This is where one would @@ -164,7 +171,7 @@ namespace pCampBot client.Network.SimConnected += this.Network_SimConnected; client.Network.Disconnected += this.Network_OnDisconnected; client.Objects.ObjectUpdate += Objects_NewPrim; - //client.Assets.OnAssetReceived += Asset_ReceivedCallback; + if (client.Network.Login(FirstName, LastName, Password, "pCampBot", "Your name")) { if (OnConnected != null) @@ -227,7 +234,7 @@ namespace pCampBot { if (asset.Decode()) { - File.WriteAllBytes(Path.Combine(saveDir, String.Format("{1}.{0}", + File.WriteAllBytes(Path.Combine(saveDir, String.Format("{1}.{0}", asset.AssetType.ToString().ToLower(), asset.WearableType)), asset.AssetData); } @@ -393,40 +400,55 @@ namespace pCampBot { if (prim.Textures.DefaultTexture.TextureID != UUID.Zero) { - client.Assets.RequestImage(prim.Textures.DefaultTexture.TextureID, ImageType.Normal, Asset_TextureCallback_Texture); + GetTexture(prim.Textures.DefaultTexture.TextureID); } for (int i = 0; i < prim.Textures.FaceTextures.Length; i++) { - if (prim.Textures.FaceTextures[i] != null) + UUID textureID = prim.Textures.FaceTextures[i].TextureID; + + if (textureID != null && textureID != UUID.Zero) { - if (prim.Textures.FaceTextures[i].TextureID != UUID.Zero) - { - client.Assets.RequestImage(prim.Textures.FaceTextures[i].TextureID, ImageType.Normal, Asset_TextureCallback_Texture); - } + GetTexture(textureID); } } } if (prim.Sculpt.SculptTexture != UUID.Zero) { - client.Assets.RequestImage(prim.Sculpt.SculptTexture, ImageType.Normal, Asset_TextureCallback_Texture); + GetTexture(prim.Sculpt.SculptTexture); } } } + private void GetTexture(UUID textureID) + { + lock (AssetsReceived) + { + // Don't request assets more than once. + if (AssetsReceived.ContainsKey(textureID)) + return; + + AssetsReceived[textureID] = false; + client.Assets.RequestImage(textureID, ImageType.Normal, Asset_TextureCallback_Texture); + } + } + public void Asset_TextureCallback_Texture(TextureRequestState state, AssetTexture assetTexture) { //TODO: Implement texture saving and applying } - public void Asset_ReceivedCallback(AssetDownload transfer,Asset asset) + public void Asset_ReceivedCallback(AssetDownload transfer, Asset asset) { - if (wear == "save") - { - SaveAsset((AssetWearable) asset); - } + lock (AssetsReceived) + AssetsReceived[asset.AssetID] = true; + +// if (wear == "save") +// { +// SaveAsset((AssetWearable) asset); +// } } public string[] readexcuses() From 210868a832439bb226dfcf153ca66563300dc2cf Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Mon, 31 Oct 2011 23:10:10 +0000 Subject: [PATCH 3/4] Remove OpenSim.TestSuite Hasn't been touched since 2009 and wasn't more than another copy of pCampBot --- OpenSim/TestSuite/BotManager.cs | 170 ----------------------- OpenSim/TestSuite/Main.cs | 98 -------------- OpenSim/TestSuite/PhysicsBot.cs | 196 --------------------------- OpenSim/TestSuite/README.txt | 25 ---- OpenSim/TestSuite/Util.cs | 81 ----------- OpenSim/Tools/pCampBot/BotManager.cs | 4 +- OpenSim/Tools/pCampBot/PhysicsBot.cs | 7 +- prebuild.xml | 28 ---- 8 files changed, 9 insertions(+), 600 deletions(-) delete mode 100644 OpenSim/TestSuite/BotManager.cs delete mode 100644 OpenSim/TestSuite/Main.cs delete mode 100644 OpenSim/TestSuite/PhysicsBot.cs delete mode 100644 OpenSim/TestSuite/README.txt delete mode 100644 OpenSim/TestSuite/Util.cs diff --git a/OpenSim/TestSuite/BotManager.cs b/OpenSim/TestSuite/BotManager.cs deleted file mode 100644 index 55ba687290..0000000000 --- a/OpenSim/TestSuite/BotManager.cs +++ /dev/null @@ -1,170 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -using System; -using System.Collections.Generic; -using System.Reflection; -using System.Threading; -using OpenMetaverse; -using log4net; -using Nini.Config; -using OpenSim.Framework; -using OpenSim.Framework.Console; - -namespace OpenSim.TestSuite -{ - /// - /// Thread/Bot manager for the application - /// - public class BotManager - { - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - protected CommandConsole m_console; - protected List m_lBot; - protected Thread[] m_td; - protected bool m_verbose = true; - protected Random somthing = new Random(Environment.TickCount); - protected int numbots = 0; - protected IConfig Previous_config; - - /// - /// Constructor Creates MainConsole.Instance to take commands and provide the place to write data - /// - public BotManager() - { - m_log.Info("In bot manager"); - m_lBot = new List(); - } - - /// - /// Startup number of bots specified in the starting arguments - /// - /// How many bots to start up - /// The configuration for the bots to use - public void dobotStartup(int botcount, IConfig cs) - { - Previous_config = cs; - m_td = new Thread[botcount]; - for (int i = 0; i < botcount; i++) - { - startupBot(i, cs); - } - } - - /// - /// Add additional bots (and threads) to our bot pool - /// - /// How Many of them to add - public void addbots(int botcount) - { - int len = m_td.Length; - Thread[] m_td2 = new Thread[len + botcount]; - for (int i = 0; i < len; i++) - { - m_td2[i] = m_td[i]; - } - m_td = m_td2; - int newlen = len + botcount; - for (int i = len; i < newlen; i++) - { - startupBot(i, Previous_config); - } - } - - /// - /// This starts up the bot and stores the thread for the bot in the thread array - /// - /// The position in the thread array to stick the bot's thread - /// Configuration of the bot - public void startupBot(int pos, IConfig cs) - { - PhysicsBot pb = new PhysicsBot(cs); - - pb.OnConnected += handlebotEvent; - pb.OnDisconnected += handlebotEvent; - if (cs.GetString("firstname", "random") == "random") pb.firstname = CreateRandomName(); - if (cs.GetString("lastname", "random") == "random") pb.lastname = CreateRandomName(); - - m_td[pos] = new Thread(pb.startup); - m_td[pos].Name = "CampBot_" + pos; - m_td[pos].IsBackground = true; - m_td[pos].Start(); - m_lBot.Add(pb); - } - - /// - /// Creates a random name for the bot - /// - /// - private string CreateRandomName() - { - string returnstring = ""; - string chars = "abcdefghijklmnopqrstuvwxyz0123456789"; - - for (int i = 0; i < 7; i++) - { - returnstring += chars.Substring(somthing.Next(chars.Length),1); - } - return returnstring; - } - - /// - /// High level connnected/disconnected events so we can keep track of our threads by proxy - /// - /// - /// - public void handlebotEvent(PhysicsBot callbot, EventType eventt) - { - switch (eventt) - { - case EventType.CONNECTED: - m_log.Info("[ " + callbot.firstname + " " + callbot.lastname + "]: Connected"); - numbots++; - break; - case EventType.DISCONNECTED: - m_log.Info("[ " + callbot.firstname + " " + callbot.lastname + "]: Disconnected"); - m_td[m_lBot.IndexOf(callbot)].Abort(); - numbots--; - if (numbots > 1) - Environment.Exit(0); - break; - } - } - - /// - /// Shutting down all bots - /// - public void doBotShutdown() - { - foreach (PhysicsBot pb in m_lBot) - { - pb.shutdown(); - } - } - } -} diff --git a/OpenSim/TestSuite/Main.cs b/OpenSim/TestSuite/Main.cs deleted file mode 100644 index ee75bf5fab..0000000000 --- a/OpenSim/TestSuite/Main.cs +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -using System; -using Nini.Config; - -namespace OpenSim.TestSuite -{ - /// - /// Event Types from the BOT. Add new events here - /// - public enum EventType : int - { - NONE = 0, - CONNECTED = 1, - DISCONNECTED = 2 - } - - public class TestSuite - { - public static void Main(string[] args) - { - // TODO: config parser - - // TODO: load tests from addings - - // TODO: create base bot cloud for use in tests - - IConfig config = ParseConfig(args); - if (config.Get("help") != null || config.Get("loginuri") == null) - { - Help(); - } - else - { - // TODO: unused: int botcount = config.GetInt("botcount", 1); - - // BotManager bm = new BotManager(); - - Utils.TestPass("Completed Startup"); - } - } - - private static IConfig ParseConfig(String[] args) - { - //Set up our nifty config.. thanks to nini - ArgvConfigSource cs = new ArgvConfigSource(args); - - // TODO: unused: cs.AddSwitch("Startup", "botcount","n"); - cs.AddSwitch("Startup", "loginuri","l"); - cs.AddSwitch("Startup", "firstname"); - cs.AddSwitch("Startup", "lastname"); - cs.AddSwitch("Startup", "password"); - cs.AddSwitch("Startup", "help","h"); - - IConfig ol = cs.Configs["Startup"]; - return ol; - } - - private static void Help() - { - Console.WriteLine( - "usage: pCampBot <-loginuri loginuri> [OPTIONS]\n" + - "Spawns a set of bots to test an OpenSim region\n\n" + - " -l, -loginuri loginuri for sim to log into (required)\n" + - // TODO: unused: " -n, -botcount number of bots to start (default: 1)\n" + - " -firstname first name for the bot(s) (default: random string)\n" + - " -lastname lastname for the bot(s) (default: random string)\n" + - " -password password for the bots(s) (default: random string)\n" + - " -h, -help show this message" - ); - } - } -} diff --git a/OpenSim/TestSuite/PhysicsBot.cs b/OpenSim/TestSuite/PhysicsBot.cs deleted file mode 100644 index fac42756a8..0000000000 --- a/OpenSim/TestSuite/PhysicsBot.cs +++ /dev/null @@ -1,196 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -using System; -using System.IO; -using System.Threading; -using System.Timers; -using OpenMetaverse; -using Nini.Config; -using OpenSim.Framework; -using OpenSim.Framework.Console; -using Timer=System.Timers.Timer; - -namespace OpenSim.TestSuite -{ - public class PhysicsBot - { - public delegate void AnEvent(PhysicsBot callbot, EventType someevent); // event delegate for bot events - public IConfig startupConfig; // bot config, passed from BotManager - - public string firstname; - public string lastname; - public string password; - public string loginURI; - - public event AnEvent OnConnected; - public event AnEvent OnDisconnected; - - protected Timer m_action; // Action Timer - - protected Random somthing = new Random(Environment.TickCount);// We do stuff randomly here - - //New instance of a SecondLife client - public GridClient client = new GridClient(); - - protected string[] talkarray; - /// - /// - /// - /// nini config for the bot - public PhysicsBot(IConfig bsconfig) - { - startupConfig = bsconfig; - readconfig(); - talkarray = readexcuses(); - } - - //We do our actions here. This is where one would - //add additional steps and/or things the bot should do - - void m_action_Elapsed(object sender, ElapsedEventArgs e) - { - //client.Throttle.Task = 500000f; - //client.Throttle.Set(); - int walkorrun = somthing.Next(4); // Randomize between walking and running. The greater this number, - // the greater the bot's chances to walk instead of run. - if (walkorrun == 0) - { - client.Self.Movement.AlwaysRun = true; - } - else - { - client.Self.Movement.AlwaysRun = false; - } - - // TODO: unused: Vector3 pos = client.Self.SimPosition; - Vector3 newpos = new Vector3(somthing.Next(255), somthing.Next(255), somthing.Next(255)); - client.Self.Movement.TurnToward(newpos); - - for (int i = 0; i < 2000; i++) - { - client.Self.Movement.AtPos = true; - Thread.Sleep(somthing.Next(25, 75)); // Makes sure the bots keep walking for this time. - } - client.Self.Jump(true); - - string randomf = talkarray[somthing.Next(talkarray.Length)]; - if (talkarray.Length > 1 && randomf.Length > 1) - client.Self.Chat(randomf, 0, ChatType.Normal); - - //Thread.Sleep(somthing.Next(1, 10)); // Apparently its better without it right now. - } - - /// - /// Read the Nini config and initialize - /// - public void readconfig() - { - firstname = startupConfig.GetString("firstname", "random"); - lastname = startupConfig.GetString("lastname", "random"); - password = startupConfig.GetString("password", "12345"); - loginURI = startupConfig.GetString("loginuri"); - } - - /// - /// Tells LibSecondLife to logout and disconnect. Raises the disconnect events once it finishes. - /// - public void shutdown() - { - client.Network.Logout(); - } - - /// - /// This is the bot startup loop. - /// - public void startup() - { - client.Settings.LOGIN_SERVER = loginURI; - client.Network.LoginProgress += this.Network_LoginProgress; - client.Network.SimConnected += this.Network_SimConnected; - client.Network.Disconnected += this.Network_OnDisconnected; - if (client.Network.Login(firstname, lastname, password, "pCampBot", "Your name")) - { - - if (OnConnected != null) - { - m_action = new Timer(somthing.Next(1000, 10000)); - m_action.Elapsed += new ElapsedEventHandler(m_action_Elapsed); - m_action.Start(); - OnConnected(this, EventType.CONNECTED); - client.Self.Jump(true); - } - } - else - { - MainConsole.Instance.Output(firstname + " " + lastname + "Can't login: " + client.Network.LoginMessage); - if (OnDisconnected != null) - { - OnDisconnected(this, EventType.DISCONNECTED); - } - } - } - - public void Network_LoginProgress(object sender, LoginProgressEventArgs args) - { - if (args.Status == LoginStatus.Success) - { - if (OnConnected != null) - { - OnConnected(this, EventType.CONNECTED); - } - } - } - - public void Network_SimConnected(object sender, SimConnectedEventArgs args) - { - } - - public void Network_OnDisconnected(object sender, DisconnectedEventArgs args) - { - if (OnDisconnected != null) - { - OnDisconnected(this, EventType.DISCONNECTED); - } - } - - public string[] readexcuses() - { - string allexcuses = ""; - - string file = Path.Combine(Util.configDir(), "pCampBotSentences.txt"); - if (File.Exists(file)) - { - StreamReader csr = File.OpenText(file); - allexcuses = csr.ReadToEnd(); - csr.Close(); - } - - return allexcuses.Split(Environment.NewLine.ToCharArray()); - } - } -} diff --git a/OpenSim/TestSuite/README.txt b/OpenSim/TestSuite/README.txt deleted file mode 100644 index cdfa4a7840..0000000000 --- a/OpenSim/TestSuite/README.txt +++ /dev/null @@ -1,25 +0,0 @@ -OpenSim Test Suite ------------------------------------------------------------- - -The eventual goal of the OpenSim Test Suite is to provide a framework -and a set of tests to do system level regression testing of OpenSim. -In short: - -OpenSim Test Suite will have Test Modules (Mono Addins?) that will -verify certain paths in the code. Some early modules may be (subject -to change): - - * Login Tests - - Attempt to Log in 1, 5, 20 bots. - * Basic Walk Tests - - Attempt to Log in and move about in well known tracks - - Repeat with 5, 20 bots - * Basic Construct Tests - - Construct Simple Objects in World - - Ensure bots can see other objects constructed - * Basic Asset Tests - - Construct Simple Objects in World with Textures - - Pull Objects and Textures - - - \ No newline at end of file diff --git a/OpenSim/TestSuite/Util.cs b/OpenSim/TestSuite/Util.cs deleted file mode 100644 index e050c0709b..0000000000 --- a/OpenSim/TestSuite/Util.cs +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -using System; - -namespace OpenSim.TestSuite -{ - public class Utils - { - enum Result - { - Fail = 0, - Pass = 1, - Skip = 3 - } - - private static String ResultToString(Result r) - { - if (r == Result.Pass) - { - return "PASS"; - } - else if (r == Result.Fail) - { - return "FAIL"; - } - else if (r == Result.Skip) - { - return "SKIP"; - } - else - { - return "UNKNOWN"; - } - } - - private static void TestResult(Result r, String msg) - { - Console.WriteLine("[{0}]: {1}", ResultToString(r), msg); - } - - public static void TestFail(String msg) - { - TestResult(Result.Fail, msg); - } - - public static void TestPass(String msg) - { - TestResult(Result.Pass, msg); - } - - public static void TestSkip(String msg) - { - TestResult(Result.Skip, msg); - } - } -} diff --git a/OpenSim/Tools/pCampBot/BotManager.cs b/OpenSim/Tools/pCampBot/BotManager.cs index 0aaa226bcb..a4b7f16d9f 100644 --- a/OpenSim/Tools/pCampBot/BotManager.cs +++ b/OpenSim/Tools/pCampBot/BotManager.cs @@ -165,18 +165,20 @@ namespace pCampBot /// /// /// - public void handlebotEvent(PhysicsBot callbot, EventType eventt) + private void handlebotEvent(PhysicsBot callbot, EventType eventt) { switch (eventt) { case EventType.CONNECTED: m_log.Info("[" + callbot.FirstName + " " + callbot.LastName + "]: Connected"); numbots++; +// m_log.InfoFormat("NUMBOTS {0}", numbots); break; case EventType.DISCONNECTED: m_log.Info("[" + callbot.FirstName + " " + callbot.LastName + "]: Disconnected"); m_td[m_lBot.IndexOf(callbot)].Abort(); numbots--; +// m_log.InfoFormat("NUMBOTS {0}", numbots); if (numbots <= 0) Environment.Exit(0); break; diff --git a/OpenSim/Tools/pCampBot/PhysicsBot.cs b/OpenSim/Tools/pCampBot/PhysicsBot.cs index 0344a829f3..0c399e355f 100644 --- a/OpenSim/Tools/pCampBot/PhysicsBot.cs +++ b/OpenSim/Tools/pCampBot/PhysicsBot.cs @@ -29,19 +29,23 @@ using System; using System.Collections.Generic; using System.Text; using System.IO; +using System.Reflection; using System.Threading; using System.Timers; +using log4net; using OpenMetaverse; using OpenMetaverse.Assets; using Nini.Config; using OpenSim.Framework; using OpenSim.Framework.Console; -using Timer=System.Timers.Timer; +using Timer = System.Timers.Timer; namespace pCampBot { public class PhysicsBot { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + public delegate void AnEvent(PhysicsBot callbot, EventType someevent); // event delegate for bot events public IConfig startupConfig; // bot config, passed from BotManager @@ -384,6 +388,7 @@ namespace pCampBot public void Network_OnDisconnected(object sender, DisconnectedEventArgs args) { +// m_log.ErrorFormat("Fired Network_OnDisconnected"); if (OnDisconnected != null) { OnDisconnected(this, EventType.DISCONNECTED); diff --git a/prebuild.xml b/prebuild.xml index b9201f7606..bf11b0ffda 100644 --- a/prebuild.xml +++ b/prebuild.xml @@ -2549,34 +2549,6 @@ - - - - - ../../bin/ - - - - - ../../bin/ - - - - ../../bin/ - - - - - - - - - - - - - - From b951c7fb1e5a284a9bf95054cb168e64ebfe717d Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Mon, 31 Oct 2011 23:22:55 +0000 Subject: [PATCH 4/4] Make bots share a cache so that asset downloads attempts are only made once instead of once for each bot --- OpenSim/Tools/pCampBot/BotManager.cs | 15 ++++++++++---- OpenSim/Tools/pCampBot/PhysicsBot.cs | 29 +++++++++++++--------------- 2 files changed, 24 insertions(+), 20 deletions(-) diff --git a/OpenSim/Tools/pCampBot/BotManager.cs b/OpenSim/Tools/pCampBot/BotManager.cs index a4b7f16d9f..03bb820e73 100644 --- a/OpenSim/Tools/pCampBot/BotManager.cs +++ b/OpenSim/Tools/pCampBot/BotManager.cs @@ -53,13 +53,20 @@ namespace pCampBot protected bool m_verbose = true; protected Random somthing = new Random(Environment.TickCount); protected int numbots = 0; - private IConfig Config; + public IConfig Config { get; private set; } + + /// + /// Track the assets we have and have not received so we don't endlessly repeat requests. + /// + public Dictionary AssetsReceived { get; private set; } /// /// Constructor Creates MainConsole.Instance to take commands and provide the place to write data /// public BotManager() { + AssetsReceived = new Dictionary(); + m_console = CreateConsole(); MainConsole.Instance = m_console; @@ -113,7 +120,7 @@ namespace pCampBot for (int i = 0; i < botcount; i++) { string lastName = string.Format("{0}_{1}", lastNameStem, i); - startupBot(i, cs, firstName, lastName, password, loginUri); + startupBot(i, this, firstName, lastName, password, loginUri); } } @@ -146,9 +153,9 @@ namespace pCampBot /// Last name /// Password /// Login URI - public void startupBot(int pos, IConfig cs, string firstName, string lastName, string password, string loginUri) + public void startupBot(int pos, BotManager bm, string firstName, string lastName, string password, string loginUri) { - PhysicsBot pb = new PhysicsBot(cs, firstName, lastName, password, loginUri); + PhysicsBot pb = new PhysicsBot(bm, firstName, lastName, password, loginUri); pb.OnConnected += handlebotEvent; pb.OnDisconnected += handlebotEvent; diff --git a/OpenSim/Tools/pCampBot/PhysicsBot.cs b/OpenSim/Tools/pCampBot/PhysicsBot.cs index 0c399e355f..2070bfd784 100644 --- a/OpenSim/Tools/pCampBot/PhysicsBot.cs +++ b/OpenSim/Tools/pCampBot/PhysicsBot.cs @@ -47,7 +47,9 @@ namespace pCampBot private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); public delegate void AnEvent(PhysicsBot callbot, EventType someevent); // event delegate for bot events - public IConfig startupConfig; // bot config, passed from BotManager + + public BotManager BotManager { get; private set; } + private IConfig startupConfig; // bot config, passed from BotManager public string FirstName { get; private set; } public string LastName { get; private set; } @@ -60,11 +62,6 @@ namespace pCampBot public event AnEvent OnConnected; public event AnEvent OnDisconnected; - /// - /// Track the assets we have and have not received so we don't endlessly repeat requests. - /// - public Dictionary AssetsReceived { get; private set; } - protected Timer m_action; // Action Timer protected List objectIDs = new List(); @@ -80,23 +77,23 @@ namespace pCampBot /// /// Constructor /// - /// + /// /// /// /// /// - public PhysicsBot(IConfig bsconfig, string firstName, string lastName, string password, string loginUri) + public PhysicsBot(BotManager bm, string firstName, string lastName, string password, string loginUri) { FirstName = firstName; LastName = lastName; Name = string.Format("{0} {1}", FirstName, LastName); Password = password; LoginUri = loginUri; - startupConfig = bsconfig; + + BotManager = bm; + startupConfig = bm.Config; readconfig(); talkarray = readexcuses(); - - AssetsReceived = new Dictionary(); } //We do our actions here. This is where one would @@ -428,13 +425,13 @@ namespace pCampBot private void GetTexture(UUID textureID) { - lock (AssetsReceived) + lock (BotManager.AssetsReceived) { // Don't request assets more than once. - if (AssetsReceived.ContainsKey(textureID)) + if (BotManager.AssetsReceived.ContainsKey(textureID)) return; - AssetsReceived[textureID] = false; + BotManager.AssetsReceived[textureID] = false; client.Assets.RequestImage(textureID, ImageType.Normal, Asset_TextureCallback_Texture); } } @@ -447,8 +444,8 @@ namespace pCampBot public void Asset_ReceivedCallback(AssetDownload transfer, Asset asset) { - lock (AssetsReceived) - AssetsReceived[asset.AssetID] = true; + lock (BotManager.AssetsReceived) + BotManager.AssetsReceived[asset.AssetID] = true; // if (wear == "save") // {