29 using System.Collections.Generic;
30 using System.Diagnostics;
31 using System.Reflection;
32 using System.Threading;
35 using NUnit.Framework;
37 using OpenSim.Framework;
38 using OpenSim.Region.CoreModules.Scripting.WorldComm;
39 using OpenSim.Region.Framework.Interfaces;
40 using OpenSim.Region.Framework.Scenes;
41 using OpenSim.Region.ScriptEngine.XEngine;
42 using OpenSim.Tests.Common;
44 namespace OpenSim.Tests.Performance
59 private AutoResetEvent m_chatEvent =
new AutoResetEvent(
false);
61 private int m_expectedChatMessages;
62 private List<OSChatMessage> m_osChatMessagesReceived =
new List<OSChatMessage>();
74 IniConfigSource configSource =
new IniConfigSource();
76 IConfig startupConfig = configSource.AddConfig(
"Startup");
77 startupConfig.Set(
"DefaultScriptEngine",
"XEngine");
79 IConfig xEngineConfig = configSource.AddConfig(
"XEngine");
80 xEngineConfig.Set(
"Enabled",
"true");
84 xEngineConfig.Set(
"AppDomainLoading",
"false");
86 m_scene =
new SceneHelpers().SetupScene(
"My Test", UUID.Random(), 1000, 1000, configSource);
87 SceneHelpers.SetupSceneModules(m_scene, configSource, m_xEngine, wcModule);
89 m_scene.EventManager.OnChatFromWorld += OnChatFromWorld;
90 m_scene.StartScripts();
99 GC.WaitForPendingFinalizers();
105 TestHelpers.InMethod();
106 log4net.Config.XmlConfigurator.Configure();
108 TestCompileAndStartScripts(100);
111 private void TestCompileAndStartScripts(
int scriptsToCreate)
113 UUID userId = TestHelpers.ParseTail(0x1);
115 m_expectedChatMessages = scriptsToCreate;
116 int startingObjectIdTail = 0x100;
120 for (
int idTail = startingObjectIdTail;idTail < startingObjectIdTail + scriptsToCreate; idTail++)
122 AddObjectAndScript(idTail, userId);
125 m_chatEvent.WaitOne(40000 + scriptsToCreate * 1000);
127 Assert.That(m_osChatMessagesReceived.Count, Is.EqualTo(m_expectedChatMessages));
132 Is.EqualTo(
"Script running"),
134 "Message from {0} was {1} rather than {2}", msg.
SenderUUID, msg.
Message,
"Script running"));
137 private void AddObjectAndScript(
int objectIdTail, UUID userId)
140 string itemName = string.Format(
"AddObjectAndScript() Item for object {0}", objectIdTail);
142 SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, userId,
"AddObjectAndScriptPart_", objectIdTail);
143 m_scene.AddNewSceneObject(so,
true);
147 itemTemplate.Name = itemName;
148 itemTemplate.Folder = so.UUID;
149 itemTemplate.InvType = (int)InventoryType.LSL;
151 m_scene.RezNewScript(userId, itemTemplate);
154 private void OnChatFromWorld(
object sender,
OSChatMessage oscm)
158 lock (m_osChatMessagesReceived)
160 m_osChatMessagesReceived.Add(oscm);
162 if (m_osChatMessagesReceived.Count == m_expectedChatMessages)
A scene object group is conceptually an object in the scene. The object is constituted of SceneObject...
string Message
The message sent by the user
Inventory Item - contains all the properties associated with an individual inventory piece...
Helpers for setting up scenes.