aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Tests
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2012-02-15 02:41:50 +0000
committerJustin Clark-Casey (justincc)2012-02-15 02:41:50 +0000
commit96843f2b17e60dfb275b6564facf7000e1451ea0 (patch)
tree23e28153e45d69480a7184484e89a35cd2e16856 /OpenSim/Tests
parentMerge branch 'master' into 0.7.3-post-fixes (diff)
parentMerge branch 'master' of ssh://opensimulator.org/var/git/opensim (diff)
downloadopensim-SC_OLD-96843f2b17e60dfb275b6564facf7000e1451ea0.zip
opensim-SC_OLD-96843f2b17e60dfb275b6564facf7000e1451ea0.tar.gz
opensim-SC_OLD-96843f2b17e60dfb275b6564facf7000e1451ea0.tar.bz2
opensim-SC_OLD-96843f2b17e60dfb275b6564facf7000e1451ea0.tar.xz
Merge branch 'master' into 0.7.3-post-fixes
Diffstat (limited to 'OpenSim/Tests')
-rw-r--r--OpenSim/Tests/Common/Helpers/SceneHelpers.cs23
-rw-r--r--OpenSim/Tests/Common/Helpers/TaskInventoryHelpers.cs12
-rw-r--r--OpenSim/Tests/Common/Mock/TestScene.cs6
-rw-r--r--OpenSim/Tests/Torture/NPCTortureTests.cs185
-rw-r--r--OpenSim/Tests/Torture/ObjectTortureTests.cs35
-rw-r--r--OpenSim/Tests/Torture/ScriptTortureTests.cs159
6 files changed, 410 insertions, 10 deletions
diff --git a/OpenSim/Tests/Common/Helpers/SceneHelpers.cs b/OpenSim/Tests/Common/Helpers/SceneHelpers.cs
index a25eb66..aa904aa 100644
--- a/OpenSim/Tests/Common/Helpers/SceneHelpers.cs
+++ b/OpenSim/Tests/Common/Helpers/SceneHelpers.cs
@@ -88,9 +88,27 @@ namespace OpenSim.Tests.Common
88 /// <param name="id">ID of the region</param> 88 /// <param name="id">ID of the region</param>
89 /// <param name="x">X co-ordinate of the region</param> 89 /// <param name="x">X co-ordinate of the region</param>
90 /// <param name="y">Y co-ordinate of the region</param> 90 /// <param name="y">Y co-ordinate of the region</param>
91 /// <param name="cm">This should be the same if simulating two scenes within a standalone</param> 91 /// <param name="cache"></param>
92 /// <returns></returns> 92 /// <returns></returns>
93 public static TestScene SetupScene(string name, UUID id, uint x, uint y, CoreAssetCache cache) 93 public static TestScene SetupScene(
94 string name, UUID id, uint x, uint y, CoreAssetCache cache)
95 {
96 return SetupScene(name, id, x, y, cache, new IniConfigSource());
97 }
98
99 /// <summary>
100 /// Set up a scene. If it's more then one scene, use the same CommunicationsManager to link regions
101 /// or a different, to get a brand new scene with new shared region modules.
102 /// </summary>
103 /// <param name="name">Name of the region</param>
104 /// <param name="id">ID of the region</param>
105 /// <param name="x">X co-ordinate of the region</param>
106 /// <param name="y">Y co-ordinate of the region</param>
107 /// <param name="cache"></param>
108 /// <param name="configSource"></param>
109 /// <returns></returns>
110 public static TestScene SetupScene(
111 string name, UUID id, uint x, uint y, CoreAssetCache cache, IConfigSource configSource)
94 { 112 {
95 Console.WriteLine("Setting up test scene {0}", name); 113 Console.WriteLine("Setting up test scene {0}", name);
96 114
@@ -106,7 +124,6 @@ namespace OpenSim.Tests.Common
106 124
107 ISimulationDataService simDataService = OpenSim.Server.Base.ServerUtils.LoadPlugin<ISimulationDataService>("OpenSim.Tests.Common.dll", null); 125 ISimulationDataService simDataService = OpenSim.Server.Base.ServerUtils.LoadPlugin<ISimulationDataService>("OpenSim.Tests.Common.dll", null);
108 IEstateDataService estateDataService = null; 126 IEstateDataService estateDataService = null;
109 IConfigSource configSource = new IniConfigSource();
110 127
111 TestScene testScene = new TestScene( 128 TestScene testScene = new TestScene(
112 regInfo, acm, scs, simDataService, estateDataService, null, false, configSource, null); 129 regInfo, acm, scs, simDataService, estateDataService, null, false, configSource, null);
diff --git a/OpenSim/Tests/Common/Helpers/TaskInventoryHelpers.cs b/OpenSim/Tests/Common/Helpers/TaskInventoryHelpers.cs
index a8f0d59..7058d1e 100644
--- a/OpenSim/Tests/Common/Helpers/TaskInventoryHelpers.cs
+++ b/OpenSim/Tests/Common/Helpers/TaskInventoryHelpers.cs
@@ -72,15 +72,21 @@ namespace OpenSim.Tests.Common
72 /// <param name="sop"></param> 72 /// <param name="sop"></param>
73 /// <param name="itemName"></param> 73 /// <param name="itemName"></param>
74 /// <param name="id"></param> 74 /// <param name="id"></param>
75 public static TaskInventoryItem AddSceneObject(Scene scene, SceneObjectPart sop, string itemName, UUID id) 75 /// <param name="userId"></param>
76 public static TaskInventoryItem AddSceneObject(
77 Scene scene, SceneObjectPart sop, string itemName, UUID id, UUID userId)
76 { 78 {
77 SceneObjectGroup taskSceneObject = SceneHelpers.CreateSceneObject(1, UUID.Zero); 79 SceneObjectGroup taskSceneObject = SceneHelpers.CreateSceneObject(1, UUID.Zero);
78 AssetBase taskSceneObjectAsset = AssetHelpers.CreateAsset(0x10, taskSceneObject); 80 AssetBase taskSceneObjectAsset = AssetHelpers.CreateAsset(0x10, taskSceneObject);
79 scene.AssetService.Store(taskSceneObjectAsset); 81 scene.AssetService.Store(taskSceneObjectAsset);
80 TaskInventoryItem taskSceneObjectItem 82 TaskInventoryItem taskSceneObjectItem
81 = new TaskInventoryItem 83 = new TaskInventoryItem
82 { Name = itemName, AssetID = taskSceneObjectAsset.FullID, ItemID = id, 84 { Name = itemName,
83 Type = (int)AssetType.Object, InvType = (int)InventoryType.Object }; 85 AssetID = taskSceneObjectAsset.FullID,
86 ItemID = id,
87 OwnerID = userId,
88 Type = (int)AssetType.Object,
89 InvType = (int)InventoryType.Object };
84 sop.Inventory.AddInventoryItem(taskSceneObjectItem, true); 90 sop.Inventory.AddInventoryItem(taskSceneObjectItem, true);
85 91
86 return taskSceneObjectItem; 92 return taskSceneObjectItem;
diff --git a/OpenSim/Tests/Common/Mock/TestScene.cs b/OpenSim/Tests/Common/Mock/TestScene.cs
index 07bcdce..eea68c3 100644
--- a/OpenSim/Tests/Common/Mock/TestScene.cs
+++ b/OpenSim/Tests/Common/Mock/TestScene.cs
@@ -47,6 +47,12 @@ namespace OpenSim.Tests.Common.Mock
47 dumpAssetsToFile, config, simulatorVersion) 47 dumpAssetsToFile, config, simulatorVersion)
48 { 48 {
49 } 49 }
50
51 ~TestScene()
52 {
53 //Console.WriteLine("TestScene destructor called for {0}", RegionInfo.RegionName);
54 Console.WriteLine("TestScene destructor called");
55 }
50 56
51 /// <summary> 57 /// <summary>
52 /// Temporarily override session authentication for tests (namely teleport). 58 /// Temporarily override session authentication for tests (namely teleport).
diff --git a/OpenSim/Tests/Torture/NPCTortureTests.cs b/OpenSim/Tests/Torture/NPCTortureTests.cs
new file mode 100644
index 0000000..8078d9d
--- /dev/null
+++ b/OpenSim/Tests/Torture/NPCTortureTests.cs
@@ -0,0 +1,185 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using System.Diagnostics;
31using System.Reflection;
32using log4net;
33using Nini.Config;
34using NUnit.Framework;
35using OpenMetaverse;
36using OpenSim.Framework;
37using OpenSim.Framework.Communications;
38using OpenSim.Region.CoreModules.Avatar.Attachments;
39using OpenSim.Region.CoreModules.Avatar.AvatarFactory;
40using OpenSim.Region.CoreModules.Framework.InventoryAccess;
41using OpenSim.Region.CoreModules.Framework.UserManagement;
42using OpenSim.Region.CoreModules.ServiceConnectorsOut.Avatar;
43using OpenSim.Region.Framework.Interfaces;
44using OpenSim.Region.Framework.Scenes;
45using OpenSim.Region.OptionalModules.World.NPC;
46using OpenSim.Services.AvatarService;
47using OpenSim.Tests.Common;
48using OpenSim.Tests.Common.Mock;
49
50namespace OpenSim.Tests.Torture
51{
52 /// <summary>
53 /// NPC torture tests
54 /// </summary>
55 /// <remarks>
56 /// Don't rely on the numbers given by these tests - they will vary a lot depending on what is already cached,
57 /// how much memory is free, etc. In some cases, later larger tests will apparently take less time than smaller
58 /// earlier tests.
59 /// </remarks>
60 [TestFixture]
61 public class NPCTortureTests
62 {
63 private TestScene scene;
64 private AvatarFactoryModule afm;
65 private UserManagementModule umm;
66 private AttachmentsModule am;
67
68 [TestFixtureSetUp]
69 public void FixtureInit()
70 {
71 // Don't allow tests to be bamboozled by asynchronous events. Execute everything on the same thread.
72 Util.FireAndForgetMethod = FireAndForgetMethod.None;
73 }
74
75 [TestFixtureTearDown]
76 public void TearDown()
77 {
78 // We must set this back afterwards, otherwise later tests will fail since they're expecting multiple
79 // threads. Possibly, later tests should be rewritten not to worry about such things.
80 Util.FireAndForgetMethod = Util.DefaultFireAndForgetMethod;
81 }
82
83 [SetUp]
84 public void Init()
85 {
86 IConfigSource config = new IniConfigSource();
87 config.AddConfig("NPC");
88 config.Configs["NPC"].Set("Enabled", "true");
89 config.AddConfig("Modules");
90 config.Configs["Modules"].Set("InventoryAccessModule", "BasicInventoryAccessModule");
91
92 afm = new AvatarFactoryModule();
93 umm = new UserManagementModule();
94 am = new AttachmentsModule();
95
96 scene = SceneHelpers.SetupScene();
97 SceneHelpers.SetupSceneModules(scene, config, afm, umm, am, new BasicInventoryAccessModule(), new NPCModule());
98 }
99
100 [Test]
101 public void TestAddRemove100NPCs()
102 {
103 TestHelpers.InMethod();
104// log4net.Config.XmlConfigurator.Configure();
105
106 TestAddRemoveNPCs(100);
107 }
108
109 [Test]
110 public void TestAddRemove1000NPCs()
111 {
112 TestHelpers.InMethod();
113// log4net.Config.XmlConfigurator.Configure();
114
115 TestAddRemoveNPCs(1000);
116 }
117
118 [Test]
119 public void TestAddRemove2000NPCs()
120 {
121 TestHelpers.InMethod();
122// log4net.Config.XmlConfigurator.Configure();
123
124 TestAddRemoveNPCs(2000);
125 }
126
127 private void TestAddRemoveNPCs(int numberOfNpcs)
128 {
129 ScenePresence sp = SceneHelpers.AddScenePresence(scene, TestHelpers.ParseTail(0x1));
130// ScenePresence originalAvatar = scene.GetScenePresence(originalClient.AgentId);
131
132 // 8 is the index of the first baked texture in AvatarAppearance
133 UUID originalFace8TextureId = TestHelpers.ParseTail(0x10);
134 Primitive.TextureEntry originalTe = new Primitive.TextureEntry(UUID.Zero);
135 Primitive.TextureEntryFace originalTef = originalTe.CreateFace(8);
136 originalTef.TextureID = originalFace8TextureId;
137
138 // We also need to add the texture to the asset service, otherwise the AvatarFactoryModule will tell
139 // ScenePresence.SendInitialData() to reset our entire appearance.
140 scene.AssetService.Store(AssetHelpers.CreateNotecardAsset(originalFace8TextureId));
141
142 afm.SetAppearance(sp, originalTe, null);
143
144 INPCModule npcModule = scene.RequestModuleInterface<INPCModule>();
145
146 List<UUID> npcs = new List<UUID>();
147
148 long startGcMemory = GC.GetTotalMemory(true);
149 Stopwatch sw = new Stopwatch();
150 sw.Start();
151
152 for (int i = 0; i < numberOfNpcs; i++)
153 {
154 npcs.Add(
155 npcModule.CreateNPC("John", "Smith", new Vector3(128, 128, 30), UUID.Zero, true, scene, sp.Appearance));
156 }
157
158 for (int i = 0; i < numberOfNpcs; i++)
159 {
160 Assert.That(npcs[i], Is.Not.Null);
161
162 ScenePresence npc = scene.GetScenePresence(npcs[i]);
163 Assert.That(npc, Is.Not.Null);
164 }
165
166 for (int i = 0; i < numberOfNpcs; i++)
167 {
168 Assert.That(npcModule.DeleteNPC(npcs[i], scene), Is.True);
169 ScenePresence npc = scene.GetScenePresence(npcs[i]);
170 Assert.That(npc, Is.Null);
171 }
172
173 sw.Stop();
174
175 long endGcMemory = GC.GetTotalMemory(true);
176
177 Console.WriteLine("Took {0} ms", sw.ElapsedMilliseconds);
178 Console.WriteLine(
179 "End {0} MB, Start {1} MB, Diff {2} MB",
180 endGcMemory / 1024 / 1024,
181 startGcMemory / 1024 / 1024,
182 (endGcMemory - startGcMemory) / 1024 / 1024);
183 }
184 }
185} \ No newline at end of file
diff --git a/OpenSim/Tests/Torture/ObjectTortureTests.cs b/OpenSim/Tests/Torture/ObjectTortureTests.cs
index b9764d7..e83186a 100644
--- a/OpenSim/Tests/Torture/ObjectTortureTests.cs
+++ b/OpenSim/Tests/Torture/ObjectTortureTests.cs
@@ -49,6 +49,13 @@ namespace OpenSim.Tests.Torture
49 [TestFixture] 49 [TestFixture]
50 public class ObjectTortureTests 50 public class ObjectTortureTests
51 { 51 {
52 [TearDown]
53 public void TearDown()
54 {
55 GC.Collect();
56 GC.WaitForPendingFinalizers();
57 }
58
52// [Test] 59// [Test]
53// public void Test0000Clean() 60// public void Test0000Clean()
54// { 61// {
@@ -118,7 +125,7 @@ namespace OpenSim.Tests.Torture
118 125
119 TestScene scene = SceneHelpers.SetupScene(); 126 TestScene scene = SceneHelpers.SetupScene();
120 127
121 Process process = Process.GetCurrentProcess(); 128// Process process = Process.GetCurrentProcess();
122// long startProcessMemory = process.PrivateMemorySize64; 129// long startProcessMemory = process.PrivateMemorySize64;
123 long startGcMemory = GC.GetTotalMemory(true); 130 long startGcMemory = GC.GetTotalMemory(true);
124 DateTime start = DateTime.Now; 131 DateTime start = DateTime.Now;
@@ -131,7 +138,7 @@ namespace OpenSim.Tests.Torture
131 138
132 TimeSpan elapsed = DateTime.Now - start; 139 TimeSpan elapsed = DateTime.Now - start;
133// long processMemoryAlloc = process.PrivateMemorySize64 - startProcessMemory; 140// long processMemoryAlloc = process.PrivateMemorySize64 - startProcessMemory;
134 long processGcAlloc = GC.GetTotalMemory(false) - startGcMemory; 141 long endGcMemory = GC.GetTotalMemory(false);
135 142
136 for (int i = 1; i <= objectsToAdd; i++) 143 for (int i = 1; i <= objectsToAdd; i++)
137 { 144 {
@@ -141,9 +148,29 @@ namespace OpenSim.Tests.Torture
141 string.Format("Object {0} could not be retrieved", i)); 148 string.Format("Object {0} could not be retrieved", i));
142 } 149 }
143 150
151 // When a scene object is added to a scene, it is placed in the update list for sending to viewers
152 // (though in this case we have none). When it is deleted, it is not removed from the update which is
153 // fine since it will later be ignored.
154 //
155 // However, that means that we need to manually run an update here to clear out that list so that deleted
156 // objects will be clean up by the garbage collector before the next stress test is run.
157 scene.Update();
158
159 // Currently, we need to do this in order to garbage collect the scene objects ready for the next test run.
160 // However, what we really need to do is find out why the entire scene is not garbage collected in
161 // teardown.
162 scene.DeleteAllSceneObjects();
163
144 Console.WriteLine( 164 Console.WriteLine(
145 "Took {0}ms, {1}MB to create {2} objects each containing {3} prim(s)", 165 "Took {0}ms, {1}MB ({2} - {3}) to create {4} objects each containing {5} prim(s)",
146 Math.Round(elapsed.TotalMilliseconds), processGcAlloc / 1024 / 1024, objectsToAdd, primsInEachObject); 166 Math.Round(elapsed.TotalMilliseconds),
167 (endGcMemory - startGcMemory) / 1024 / 1024,
168 endGcMemory / 1024 / 1024,
169 startGcMemory / 1024 / 1024,
170 objectsToAdd,
171 primsInEachObject);
172
173 scene = null;
147 } 174 }
148 } 175 }
149} \ No newline at end of file 176} \ No newline at end of file
diff --git a/OpenSim/Tests/Torture/ScriptTortureTests.cs b/OpenSim/Tests/Torture/ScriptTortureTests.cs
new file mode 100644
index 0000000..d94bbde
--- /dev/null
+++ b/OpenSim/Tests/Torture/ScriptTortureTests.cs
@@ -0,0 +1,159 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using System.Diagnostics;
31using System.Reflection;
32using System.Threading;
33using log4net;
34using Nini.Config;
35using NUnit.Framework;
36using OpenMetaverse;
37using OpenSim.Framework;
38using OpenSim.Region.CoreModules.Scripting.WorldComm;
39using OpenSim.Region.Framework.Interfaces;
40using OpenSim.Region.Framework.Scenes;
41using OpenSim.Region.ScriptEngine.XEngine;
42using OpenSim.Tests.Common;
43using OpenSim.Tests.Common.Mock;
44
45namespace OpenSim.Tests.Torture
46{
47 /// <summary>
48 /// Script torture tests
49 /// </summary>
50 /// <remarks>
51 /// Don't rely on the numbers given by these tests - they will vary a lot depending on what is already cached,
52 /// how much memory is free, etc. In some cases, later larger tests will apparently take less time than smaller
53 /// earlier tests.
54 /// </remarks>
55 [TestFixture]
56 public class ScriptTortureTests
57 {
58 private TestScene m_scene;
59 private XEngine m_xEngine;
60 private AutoResetEvent m_chatEvent = new AutoResetEvent(false);
61
62 private int m_expectedChatMessages;
63 private List<OSChatMessage> m_osChatMessagesReceived = new List<OSChatMessage>();
64
65 [SetUp]
66 public void Init()
67 {
68 //AppDomain.CurrentDomain.SetData("APPBASE", Environment.CurrentDirectory + "/bin");
69// Console.WriteLine(AppDomain.CurrentDomain.BaseDirectory);
70 m_xEngine = new XEngine();
71
72 // Necessary to stop serialization complaining
73 WorldCommModule wcModule = new WorldCommModule();
74
75 IniConfigSource configSource = new IniConfigSource();
76
77 IConfig startupConfig = configSource.AddConfig("Startup");
78 startupConfig.Set("DefaultScriptEngine", "XEngine");
79
80 IConfig xEngineConfig = configSource.AddConfig("XEngine");
81 xEngineConfig.Set("Enabled", "true");
82
83 // These tests will not run with AppDomainLoading = true, at least on mono. For unknown reasons, the call
84 // to AssemblyResolver.OnAssemblyResolve fails.
85 xEngineConfig.Set("AppDomainLoading", "false");
86
87 m_scene = SceneHelpers.SetupScene("My Test", UUID.Random(), 1000, 1000, null, configSource);
88 SceneHelpers.SetupSceneModules(m_scene, configSource, m_xEngine, wcModule);
89
90 m_scene.EventManager.OnChatFromWorld += OnChatFromWorld;
91 m_scene.StartScripts();
92 }
93
94 [Test]
95 public void TestCompileAndStart100Scripts()
96 {
97 TestHelpers.InMethod();
98 log4net.Config.XmlConfigurator.Configure();
99
100 TestCompileAndStartScripts(100);
101 }
102
103 private void TestCompileAndStartScripts(int scriptsToCreate)
104 {
105 UUID userId = TestHelpers.ParseTail(0x1);
106
107 m_expectedChatMessages = scriptsToCreate;
108 int startingObjectIdTail = 0x100;
109
110 GC.Collect();
111
112 for (int idTail = startingObjectIdTail;idTail < startingObjectIdTail + scriptsToCreate; idTail++)
113 {
114 AddObjectAndScript(idTail, userId);
115 }
116
117 m_chatEvent.WaitOne(40000 + scriptsToCreate * 1000);
118
119 Assert.That(m_osChatMessagesReceived.Count, Is.EqualTo(m_expectedChatMessages));
120
121 foreach (OSChatMessage msg in m_osChatMessagesReceived)
122 Assert.That(
123 msg.Message,
124 Is.EqualTo("Script running"),
125 string.Format(
126 "Message from {0} was {1} rather than {2}", msg.SenderUUID, msg.Message, "Script running"));
127 }
128
129 private void AddObjectAndScript(int objectIdTail, UUID userId)
130 {
131// UUID itemId = TestHelpers.ParseTail(0x3);
132 string itemName = string.Format("AddObjectAndScript() Item for object {0}", objectIdTail);
133
134 SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, userId, "AddObjectAndScriptPart_", objectIdTail);
135 m_scene.AddNewSceneObject(so, true);
136
137 InventoryItemBase itemTemplate = new InventoryItemBase();
138// itemTemplate.ID = itemId;
139 itemTemplate.Name = itemName;
140 itemTemplate.Folder = so.UUID;
141 itemTemplate.InvType = (int)InventoryType.LSL;
142
143 m_scene.RezNewScript(userId, itemTemplate);
144 }
145
146 private void OnChatFromWorld(object sender, OSChatMessage oscm)
147 {
148// Console.WriteLine("Got chat [{0}]", oscm.Message);
149
150 lock (m_osChatMessagesReceived)
151 {
152 m_osChatMessagesReceived.Add(oscm);
153
154 if (m_osChatMessagesReceived.Count == m_expectedChatMessages)
155 m_chatEvent.Set();
156 }
157 }
158 }
159} \ No newline at end of file