aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Data/SQLite/SQLiteFriendsData.cs2
-rw-r--r--OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs9
-rw-r--r--OpenSim/Region/ClientStack/Linden/Caps/NewFileAgentInventoryVariablePriceModule.cs10
-rw-r--r--OpenSim/Region/ClientStack/Linden/Caps/ObjectCaps/UploadObjectAssetModule.cs2
-rw-r--r--OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs14
-rw-r--r--OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs17
-rw-r--r--OpenSim/Region/Framework/Interfaces/INPCModule.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.Inventory.cs9
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs2
-rw-r--r--OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs3
-rw-r--r--OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs5
-rw-r--r--OpenSim/Tests/Torture/NPCTortureTests.cs185
12 files changed, 240 insertions, 20 deletions
diff --git a/OpenSim/Data/SQLite/SQLiteFriendsData.cs b/OpenSim/Data/SQLite/SQLiteFriendsData.cs
index b14c348..5f68977 100644
--- a/OpenSim/Data/SQLite/SQLiteFriendsData.cs
+++ b/OpenSim/Data/SQLite/SQLiteFriendsData.cs
@@ -75,7 +75,7 @@ namespace OpenSim.Data.SQLite
75 cmd.Parameters.AddWithValue(":PrincipalID", principalID.ToString()); 75 cmd.Parameters.AddWithValue(":PrincipalID", principalID.ToString());
76 cmd.Parameters.AddWithValue(":Friend", friend); 76 cmd.Parameters.AddWithValue(":Friend", friend);
77 77
78 ExecuteNonQuery(cmd, cmd.Connection); 78 ExecuteNonQuery(cmd, m_Connection);
79 79
80 return true; 80 return true;
81 } 81 }
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs
index cf0c28b..be699db 100644
--- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs
+++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs
@@ -422,7 +422,7 @@ namespace OpenSim.Region.ClientStack.Linden
422 string assetType) 422 string assetType)
423 { 423 {
424 m_log.DebugFormat( 424 m_log.DebugFormat(
425 "Uploaded asset {0} for inventory item {1}, inv type {2}, asset type {3}", 425 "[BUNCH OF CAPS]: Uploaded asset {0} for inventory item {1}, inv type {2}, asset type {3}",
426 assetID, inventoryItem, inventoryType, assetType); 426 assetID, inventoryItem, inventoryType, assetType);
427 427
428 sbyte assType = 0; 428 sbyte assType = 0;
@@ -625,7 +625,12 @@ namespace OpenSim.Region.ClientStack.Linden
625 item.AssetType = assType; 625 item.AssetType = assType;
626 item.InvType = inType; 626 item.InvType = inType;
627 item.Folder = parentFolder; 627 item.Folder = parentFolder;
628 item.CurrentPermissions = (uint)PermissionMask.All; 628
629 // If we set PermissionMask.All then when we rez the item the next permissions will replace the current
630 // (owner) permissions. This becomes a problem if next permissions are changed.
631 item.CurrentPermissions
632 = (uint)(PermissionMask.Move | PermissionMask.Copy | PermissionMask.Modify | PermissionMask.Transfer);
633
629 item.BasePermissions = (uint)PermissionMask.All; 634 item.BasePermissions = (uint)PermissionMask.All;
630 item.EveryOnePermissions = 0; 635 item.EveryOnePermissions = 0;
631 item.NextPermissions = (uint)PermissionMask.All; 636 item.NextPermissions = (uint)PermissionMask.All;
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/NewFileAgentInventoryVariablePriceModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/NewFileAgentInventoryVariablePriceModule.cs
index aed03b3..1117f2a 100644
--- a/OpenSim/Region/ClientStack/Linden/Caps/NewFileAgentInventoryVariablePriceModule.cs
+++ b/OpenSim/Region/ClientStack/Linden/Caps/NewFileAgentInventoryVariablePriceModule.cs
@@ -50,8 +50,7 @@ namespace OpenSim.Region.ClientStack.Linden
50 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] 50 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")]
51 public class NewFileAgentInventoryVariablePriceModule : INonSharedRegionModule 51 public class NewFileAgentInventoryVariablePriceModule : INonSharedRegionModule
52 { 52 {
53// private static readonly ILog m_log = 53// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
54// LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
55 54
56 private Scene m_scene; 55 private Scene m_scene;
57// private IAssetService m_assetService; 56// private IAssetService m_assetService;
@@ -210,6 +209,9 @@ namespace OpenSim.Region.ClientStack.Linden
210 UUID inventoryItem, UUID parentFolder, byte[] data, string inventoryType, 209 UUID inventoryItem, UUID parentFolder, byte[] data, string inventoryType,
211 string assetType,UUID AgentID) 210 string assetType,UUID AgentID)
212 { 211 {
212// m_log.DebugFormat(
213// "[NEW FILE AGENT INVENTORY VARIABLE PRICE MODULE]: Upload complete for {0}", inventoryItem);
214
213 sbyte assType = 0; 215 sbyte assType = 0;
214 sbyte inType = 0; 216 sbyte inType = 0;
215 217
@@ -259,13 +261,13 @@ namespace OpenSim.Region.ClientStack.Linden
259 item.AssetType = assType; 261 item.AssetType = assType;
260 item.InvType = inType; 262 item.InvType = inType;
261 item.Folder = parentFolder; 263 item.Folder = parentFolder;
262 item.CurrentPermissions = (uint)PermissionMask.All; 264 item.CurrentPermissions
265 = (uint)(PermissionMask.Move | PermissionMask.Copy | PermissionMask.Modify | PermissionMask.Transfer);
263 item.BasePermissions = (uint)PermissionMask.All; 266 item.BasePermissions = (uint)PermissionMask.All;
264 item.EveryOnePermissions = 0; 267 item.EveryOnePermissions = 0;
265 item.NextPermissions = (uint)PermissionMask.All; 268 item.NextPermissions = (uint)PermissionMask.All;
266 item.CreationDate = Util.UnixTimeSinceEpoch(); 269 item.CreationDate = Util.UnixTimeSinceEpoch();
267 m_scene.AddInventoryItem(item); 270 m_scene.AddInventoryItem(item);
268
269 } 271 }
270 } 272 }
271} 273}
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/ObjectCaps/UploadObjectAssetModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/ObjectCaps/UploadObjectAssetModule.cs
index e4bacd4..7a3d97e 100644
--- a/OpenSim/Region/ClientStack/Linden/Caps/ObjectCaps/UploadObjectAssetModule.cs
+++ b/OpenSim/Region/ClientStack/Linden/Caps/ObjectCaps/UploadObjectAssetModule.cs
@@ -339,7 +339,7 @@ namespace OpenSim.Region.ClientStack.Linden
339 m_scene.AddSceneObject(grp); 339 m_scene.AddSceneObject(grp);
340 grp.AbsolutePosition = obj.Position; 340 grp.AbsolutePosition = obj.Position;
341 } 341 }
342 342
343 allparts[i] = grp; 343 allparts[i] = grp;
344 } 344 }
345 345
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs
index f019a83..c20f7b2 100644
--- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs
+++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs
@@ -5168,7 +5168,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
5168 AddLocalPacketHandler(PacketType.ImprovedInstantMessage, HandlerImprovedInstantMessage, false); 5168 AddLocalPacketHandler(PacketType.ImprovedInstantMessage, HandlerImprovedInstantMessage, false);
5169 AddLocalPacketHandler(PacketType.AcceptFriendship, HandlerAcceptFriendship); 5169 AddLocalPacketHandler(PacketType.AcceptFriendship, HandlerAcceptFriendship);
5170 AddLocalPacketHandler(PacketType.DeclineFriendship, HandlerDeclineFriendship); 5170 AddLocalPacketHandler(PacketType.DeclineFriendship, HandlerDeclineFriendship);
5171 AddLocalPacketHandler(PacketType.TerminateFriendship, HandlerTerminateFrendship); 5171 AddLocalPacketHandler(PacketType.TerminateFriendship, HandlerTerminateFriendship);
5172 AddLocalPacketHandler(PacketType.RezObject, HandlerRezObject); 5172 AddLocalPacketHandler(PacketType.RezObject, HandlerRezObject);
5173 AddLocalPacketHandler(PacketType.DeRezObject, HandlerDeRezObject); 5173 AddLocalPacketHandler(PacketType.DeRezObject, HandlerDeRezObject);
5174 AddLocalPacketHandler(PacketType.ModifyLand, HandlerModifyLand); 5174 AddLocalPacketHandler(PacketType.ModifyLand, HandlerModifyLand);
@@ -5891,7 +5891,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
5891 return true; 5891 return true;
5892 } 5892 }
5893 5893
5894 private bool HandlerTerminateFrendship(IClientAPI sender, Packet Pack) 5894 private bool HandlerTerminateFriendship(IClientAPI sender, Packet Pack)
5895 { 5895 {
5896 TerminateFriendshipPacket tfriendpack = (TerminateFriendshipPacket)Pack; 5896 TerminateFriendshipPacket tfriendpack = (TerminateFriendshipPacket)Pack;
5897 5897
@@ -5906,13 +5906,13 @@ namespace OpenSim.Region.ClientStack.LindenUDP
5906 5906
5907 UUID listOwnerAgentID = tfriendpack.AgentData.AgentID; 5907 UUID listOwnerAgentID = tfriendpack.AgentData.AgentID;
5908 UUID exFriendID = tfriendpack.ExBlock.OtherID; 5908 UUID exFriendID = tfriendpack.ExBlock.OtherID;
5909 5909 FriendshipTermination TerminateFriendshipHandler = OnTerminateFriendship;
5910 FriendshipTermination handlerTerminateFriendship = OnTerminateFriendship; 5910 if (TerminateFriendshipHandler != null)
5911 if (handlerTerminateFriendship != null)
5912 { 5911 {
5913 handlerTerminateFriendship(this, listOwnerAgentID, exFriendID); 5912 TerminateFriendshipHandler(this, listOwnerAgentID, exFriendID);
5913 return true;
5914 } 5914 }
5915 return true; 5915 return false;
5916 } 5916 }
5917 5917
5918 private bool HandleFindAgent(IClientAPI client, Packet Packet) 5918 private bool HandleFindAgent(IClientAPI client, Packet Packet)
diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
index fe75271..a47bc9a 100644
--- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
@@ -830,6 +830,12 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
830 group = objlist[i]; 830 group = objlist[i];
831 SceneObjectPart rootPart = group.RootPart; 831 SceneObjectPart rootPart = group.RootPart;
832 832
833// m_log.DebugFormat(
834// "[InventoryAccessModule]: Preparing to rez {0} {1} {2} ownermask={3:X} nextownermask={4:X} groupmask={5:X} everyonemask={6:X} for {7}",
835// group.Name, group.LocalId, group.UUID,
836// group.RootPart.OwnerMask, group.RootPart.NextOwnerMask, group.RootPart.GroupMask, group.RootPart.EveryoneMask,
837// remoteClient.Name);
838
833// Vector3 storedPosition = group.AbsolutePosition; 839// Vector3 storedPosition = group.AbsolutePosition;
834 if (group.UUID == UUID.Zero) 840 if (group.UUID == UUID.Zero)
835 { 841 {
@@ -892,6 +898,12 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
892 898
893 rootPart.ScheduleFullUpdate(); 899 rootPart.ScheduleFullUpdate();
894 } 900 }
901
902// m_log.DebugFormat(
903// "[InventoryAccessModule]: Rezzed {0} {1} {2} ownermask={3:X} nextownermask={4:X} groupmask={5:X} everyonemask={6:X} for {7}",
904// group.Name, group.LocalId, group.UUID,
905// group.RootPart.OwnerMask, group.RootPart.NextOwnerMask, group.RootPart.GroupMask, group.RootPart.EveryoneMask,
906// remoteClient.Name);
895 } 907 }
896 908
897 group.SetGroup(remoteClient.ActiveGroupId, remoteClient); 909 group.SetGroup(remoteClient.ActiveGroupId, remoteClient);
@@ -958,7 +970,10 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
958 } 970 }
959 971
960 rootPart.FromFolderID = item.Folder; 972 rootPart.FromFolderID = item.Folder;
961 973
974// Console.WriteLine("rootPart.OwnedID {0}, item.Owner {1}, item.CurrentPermissions {2:X}",
975// rootPart.OwnerID, item.Owner, item.CurrentPermissions);
976
962 if ((rootPart.OwnerID != item.Owner) || 977 if ((rootPart.OwnerID != item.Owner) ||
963 (item.CurrentPermissions & 16) != 0 || 978 (item.CurrentPermissions & 16) != 0 ||
964 (item.Flags & (uint)InventoryItemFlags.ObjectSlamPerm) != 0) 979 (item.Flags & (uint)InventoryItemFlags.ObjectSlamPerm) != 0)
diff --git a/OpenSim/Region/Framework/Interfaces/INPCModule.cs b/OpenSim/Region/Framework/Interfaces/INPCModule.cs
index 2731291..dc3ff89 100644
--- a/OpenSim/Region/Framework/Interfaces/INPCModule.cs
+++ b/OpenSim/Region/Framework/Interfaces/INPCModule.cs
@@ -58,7 +58,7 @@ namespace OpenSim.Region.Framework.Interfaces
58 /// </param> 58 /// </param>
59 /// <param name="scene"></param> 59 /// <param name="scene"></param>
60 /// <param name="appearance">The avatar appearance to use for the new NPC.</param> 60 /// <param name="appearance">The avatar appearance to use for the new NPC.</param>
61 /// <returns>The UUID of the ScenePresence created.</returns> 61 /// <returns>The UUID of the ScenePresence created. UUID.Zero if there was a failure.</returns>
62 UUID CreateNPC( 62 UUID CreateNPC(
63 string firstname, 63 string firstname,
64 string lastname, 64 string lastname,
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
index 01df575..fff39fb 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
@@ -330,6 +330,12 @@ namespace OpenSim.Region.Framework.Scenes
330 item.Flags = (item.Flags & ~(uint)255) | (itemUpd.Flags & (uint)255); 330 item.Flags = (item.Flags & ~(uint)255) | (itemUpd.Flags & (uint)255);
331 item.Name = itemUpd.Name; 331 item.Name = itemUpd.Name;
332 item.Description = itemUpd.Description; 332 item.Description = itemUpd.Description;
333
334// m_log.DebugFormat(
335// "[USER INVENTORY]: itemUpd {0} {1} {2} {3}, item {4} {5} {6} {7}",
336// itemUpd.NextPermissions, itemUpd.GroupPermissions, itemUpd.EveryOnePermissions, item.Flags,
337// item.NextPermissions, item.GroupPermissions, item.EveryOnePermissions, item.CurrentPermissions);
338
333 if (item.NextPermissions != (itemUpd.NextPermissions & item.BasePermissions)) 339 if (item.NextPermissions != (itemUpd.NextPermissions & item.BasePermissions))
334 item.Flags |= (uint)InventoryItemFlags.ObjectOverwriteNextOwner; 340 item.Flags |= (uint)InventoryItemFlags.ObjectOverwriteNextOwner;
335 item.NextPermissions = itemUpd.NextPermissions & item.BasePermissions; 341 item.NextPermissions = itemUpd.NextPermissions & item.BasePermissions;
@@ -338,6 +344,9 @@ namespace OpenSim.Region.Framework.Scenes
338 item.EveryOnePermissions = itemUpd.EveryOnePermissions & item.BasePermissions; 344 item.EveryOnePermissions = itemUpd.EveryOnePermissions & item.BasePermissions;
339 if (item.GroupPermissions != (itemUpd.GroupPermissions & item.BasePermissions)) 345 if (item.GroupPermissions != (itemUpd.GroupPermissions & item.BasePermissions))
340 item.Flags |= (uint)InventoryItemFlags.ObjectOverwriteGroup; 346 item.Flags |= (uint)InventoryItemFlags.ObjectOverwriteGroup;
347
348// m_log.DebugFormat("[USER INVENTORY]: item.Flags {0}", item.Flags);
349
341 item.GroupPermissions = itemUpd.GroupPermissions & item.BasePermissions; 350 item.GroupPermissions = itemUpd.GroupPermissions & item.BasePermissions;
342 item.GroupID = itemUpd.GroupID; 351 item.GroupID = itemUpd.GroupID;
343 item.GroupOwned = itemUpd.GroupOwned; 352 item.GroupOwned = itemUpd.GroupOwned;
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs
index b56d3fc..f3660a5 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs
@@ -269,6 +269,8 @@ namespace OpenSim.Region.Framework.Scenes
269 269
270 public void ApplyNextOwnerPermissions() 270 public void ApplyNextOwnerPermissions()
271 { 271 {
272// m_log.DebugFormat("[PRIM INVENTORY]: Applying next owner permissions to {0} {1}", Name, UUID);
273
272 SceneObjectPart[] parts = m_parts.GetArray(); 274 SceneObjectPart[] parts = m_parts.GetArray();
273 for (int i = 0; i < parts.Length; i++) 275 for (int i = 0; i < parts.Length; i++)
274 parts[i].ApplyNextOwnerPermissions(); 276 parts[i].ApplyNextOwnerPermissions();
diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs
index 03b52c0..d0b822c 100644
--- a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs
+++ b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs
@@ -44,7 +44,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC
44 private readonly string m_firstname; 44 private readonly string m_firstname;
45 private readonly string m_lastname; 45 private readonly string m_lastname;
46 private readonly Vector3 m_startPos; 46 private readonly Vector3 m_startPos;
47 private readonly UUID m_uuid = UUID.Random(); 47 private UUID m_uuid = UUID.Random();
48 private readonly Scene m_scene; 48 private readonly Scene m_scene;
49 private readonly UUID m_ownerID; 49 private readonly UUID m_ownerID;
50 50
@@ -444,6 +444,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC
444 public virtual UUID AgentId 444 public virtual UUID AgentId
445 { 445 {
446 get { return m_uuid; } 446 get { return m_uuid; }
447 set { m_uuid = value; }
447 } 448 }
448 449
449 public UUID SessionId 450 public UUID SessionId
diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs
index a0ae55a..6803644 100644
--- a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs
+++ b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs
@@ -155,20 +155,21 @@ namespace OpenSim.Region.OptionalModules.World.NPC
155 "[NPC MODULE]: Successfully retrieved scene presence for NPC {0} {1}", sp.Name, sp.UUID); 155 "[NPC MODULE]: Successfully retrieved scene presence for NPC {0} {1}", sp.Name, sp.UUID);
156 156
157 sp.CompleteMovement(npcAvatar, false); 157 sp.CompleteMovement(npcAvatar, false);
158 m_avatars.Add(npcAvatar.AgentId, npcAvatar);
158 } 159 }
159 else 160 else
160 { 161 {
161 m_log.WarnFormat("[NPC MODULE]: Could not find scene presence for NPC {0} {1}", sp.Name, sp.UUID); 162 m_log.WarnFormat("[NPC MODULE]: Could not find scene presence for NPC {0} {1}", sp.Name, sp.UUID);
163 npcAvatar.AgentId = UUID.Zero;
162 } 164 }
163 165
164 m_avatars.Add(npcAvatar.AgentId, npcAvatar);
165 } 166 }
166 ev.Set(); 167 ev.Set();
167 }); 168 });
168 169
169 ev.WaitOne(); 170 ev.WaitOne();
170 171
171 m_log.DebugFormat("[NPC MODULE]: Created NPC with id {0}", npcAvatar.AgentId); 172// m_log.DebugFormat("[NPC MODULE]: Created NPC with id {0}", npcAvatar.AgentId);
172 173
173 return npcAvatar.AgentId; 174 return npcAvatar.AgentId;
174 } 175 }
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