aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Tests
diff options
context:
space:
mode:
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/Torture/ObjectTortureTests.cs2
-rw-r--r--OpenSim/Tests/Torture/ScriptTortureTests.cs157
4 files changed, 187 insertions, 7 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/Torture/ObjectTortureTests.cs b/OpenSim/Tests/Torture/ObjectTortureTests.cs
index b9764d7..444b7ec 100644
--- a/OpenSim/Tests/Torture/ObjectTortureTests.cs
+++ b/OpenSim/Tests/Torture/ObjectTortureTests.cs
@@ -118,7 +118,7 @@ namespace OpenSim.Tests.Torture
118 118
119 TestScene scene = SceneHelpers.SetupScene(); 119 TestScene scene = SceneHelpers.SetupScene();
120 120
121 Process process = Process.GetCurrentProcess(); 121// Process process = Process.GetCurrentProcess();
122// long startProcessMemory = process.PrivateMemorySize64; 122// long startProcessMemory = process.PrivateMemorySize64;
123 long startGcMemory = GC.GetTotalMemory(true); 123 long startGcMemory = GC.GetTotalMemory(true);
124 DateTime start = DateTime.Now; 124 DateTime start = DateTime.Now;
diff --git a/OpenSim/Tests/Torture/ScriptTortureTests.cs b/OpenSim/Tests/Torture/ScriptTortureTests.cs
new file mode 100644
index 0000000..c0239ba
--- /dev/null
+++ b/OpenSim/Tests/Torture/ScriptTortureTests.cs
@@ -0,0 +1,157 @@
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 for (int idTail = startingObjectIdTail;idTail < startingObjectIdTail + scriptsToCreate; idTail++)
111 {
112 AddObjectAndScript(idTail, userId);
113 }
114
115 m_chatEvent.WaitOne(40000 + scriptsToCreate * 1000);
116
117 Assert.That(m_osChatMessagesReceived.Count, Is.EqualTo(m_expectedChatMessages));
118
119 foreach (OSChatMessage msg in m_osChatMessagesReceived)
120 Assert.That(
121 msg.Message,
122 Is.EqualTo("Script running"),
123 string.Format(
124 "Message from {0} was {1} rather than {2}", msg.SenderUUID, msg.Message, "Script running"));
125 }
126
127 private void AddObjectAndScript(int objectIdTail, UUID userId)
128 {
129// UUID itemId = TestHelpers.ParseTail(0x3);
130 string itemName = string.Format("AddObjectAndScript() Item for object {0}", objectIdTail);
131
132 SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, userId, "AddObjectAndScriptPart_", objectIdTail);
133 m_scene.AddNewSceneObject(so, true);
134
135 InventoryItemBase itemTemplate = new InventoryItemBase();
136// itemTemplate.ID = itemId;
137 itemTemplate.Name = itemName;
138 itemTemplate.Folder = so.UUID;
139 itemTemplate.InvType = (int)InventoryType.LSL;
140
141 m_scene.RezNewScript(userId, itemTemplate);
142 }
143
144 private void OnChatFromWorld(object sender, OSChatMessage oscm)
145 {
146// Console.WriteLine("Got chat [{0}]", oscm.Message);
147
148 lock (m_osChatMessagesReceived)
149 {
150 m_osChatMessagesReceived.Add(oscm);
151
152 if (m_osChatMessagesReceived.Count == m_expectedChatMessages)
153 m_chatEvent.Set();
154 }
155 }
156 }
157} \ No newline at end of file