aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2013-03-06 23:06:00 +0000
committerJustin Clark-Casey (justincc)2013-03-06 23:06:00 +0000
commit5751ecde5250484fe8e4b79ef38bfbf441e3dead (patch)
tree769348d5952d6758aec7879ad0313389bb819aa4 /OpenSim
parentAdd regression test for presence crossing between regions on the same simulator. (diff)
downloadopensim-SC_OLD-5751ecde5250484fe8e4b79ef38bfbf441e3dead.zip
opensim-SC_OLD-5751ecde5250484fe8e4b79ef38bfbf441e3dead.tar.gz
opensim-SC_OLD-5751ecde5250484fe8e4b79ef38bfbf441e3dead.tar.bz2
opensim-SC_OLD-5751ecde5250484fe8e4b79ef38bfbf441e3dead.tar.xz
Add code for testing event queue messages recevied on region cross.
This is currently disabled pending an improvement in the test code to properly add avatars when an event queue module is present.
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs5
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs9
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/ScenePresenceCrossingTests.cs27
-rw-r--r--OpenSim/Tests/Common/Mock/TestEventQueueGetModule.cs178
4 files changed, 211 insertions, 8 deletions
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
index 07c3666..01b1668 100644
--- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
@@ -1206,6 +1206,10 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
1206 // region doesn't take it 1206 // region doesn't take it
1207 m_entityTransferStateMachine.UpdateInTransit(agent.UUID, AgentTransferState.CleaningUp); 1207 m_entityTransferStateMachine.UpdateInTransit(agent.UUID, AgentTransferState.CleaningUp);
1208 1208
1209 m_log.WarnFormat(
1210 "[ENTITY TRANSFER MODULE]: Region {0} would not accept update for agent {1} on cross attempt. Returning to original region.",
1211 neighbourRegion.RegionName, agent.Name);
1212
1209 ReInstantiateScripts(agent); 1213 ReInstantiateScripts(agent);
1210 agent.AddToPhysicalScene(isFlying); 1214 agent.AddToPhysicalScene(isFlying);
1211 1215
@@ -1225,6 +1229,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
1225 neighbourRegion.RegionHandle); 1229 neighbourRegion.RegionHandle);
1226 return agent; 1230 return agent;
1227 } 1231 }
1232
1228 // No turning back 1233 // No turning back
1229 agent.IsChildAgent = true; 1234 agent.IsChildAgent = true;
1230 1235
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs
index 3c18074..a413546 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs
@@ -219,12 +219,15 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
219 { 219 {
220// m_log.DebugFormat( 220// m_log.DebugFormat(
221// "[LOCAL SIMULATION CONNECTOR]: Found region {0} {1} to send AgentUpdate", 221// "[LOCAL SIMULATION CONNECTOR]: Found region {0} {1} to send AgentUpdate",
222// s.RegionInfo.RegionName, destination.RegionHandle); 222// destination.RegionName, destination.RegionID);
223 223
224 return m_scenes[destination.RegionID].IncomingChildAgentDataUpdate(cAgentData); 224 return m_scenes[destination.RegionID].IncomingChildAgentDataUpdate(cAgentData);
225 } 225 }
226 226
227// m_log.DebugFormat("[LOCAL COMMS]: Did not find region {0} for ChildAgentUpdate", regionHandle); 227// m_log.DebugFormat(
228// "[LOCAL COMMS]: Did not find region {0} {1} for ChildAgentUpdate",
229// destination.RegionName, destination.RegionID);
230
228 return false; 231 return false;
229 } 232 }
230 233
@@ -239,7 +242,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
239 // note that we really don't need the GridRegion for this call 242 // note that we really don't need the GridRegion for this call
240 foreach (Scene s in m_scenes.Values) 243 foreach (Scene s in m_scenes.Values)
241 { 244 {
242 //m_log.Debug("[LOCAL COMMS]: Found region to send ChildAgentUpdate"); 245// m_log.Debug("[LOCAL COMMS]: Found region to send ChildAgentUpdate");
243 s.IncomingChildAgentDataUpdate(cAgentData); 246 s.IncomingChildAgentDataUpdate(cAgentData);
244 } 247 }
245 248
diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceCrossingTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceCrossingTests.cs
index ef9fff5..81a2fcc 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceCrossingTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceCrossingTests.cs
@@ -26,6 +26,7 @@
26 */ 26 */
27 27
28using System; 28using System;
29using System.Collections.Generic;
29using System.Reflection; 30using System.Reflection;
30using Nini.Config; 31using Nini.Config;
31using NUnit.Framework; 32using NUnit.Framework;
@@ -65,10 +66,11 @@ namespace OpenSim.Region.Framework.Scenes.Tests
65 public void TestCrossOnSameSimulator() 66 public void TestCrossOnSameSimulator()
66 { 67 {
67 TestHelpers.InMethod(); 68 TestHelpers.InMethod();
68 TestHelpers.EnableLogging(); 69// TestHelpers.EnableLogging();
69 70
70 UUID userId = TestHelpers.ParseTail(0x1); 71 UUID userId = TestHelpers.ParseTail(0x1);
71 72
73// TestEventQueueGetModule eqmA = new TestEventQueueGetModule();
72 EntityTransferModule etmA = new EntityTransferModule(); 74 EntityTransferModule etmA = new EntityTransferModule();
73 EntityTransferModule etmB = new EntityTransferModule(); 75 EntityTransferModule etmB = new EntityTransferModule();
74 LocalSimulationConnectorModule lscm = new LocalSimulationConnectorModule(); 76 LocalSimulationConnectorModule lscm = new LocalSimulationConnectorModule();
@@ -77,7 +79,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
77 IConfig modulesConfig = config.AddConfig("Modules"); 79 IConfig modulesConfig = config.AddConfig("Modules");
78 modulesConfig.Set("EntityTransferModule", etmA.Name); 80 modulesConfig.Set("EntityTransferModule", etmA.Name);
79 modulesConfig.Set("SimulationServices", lscm.Name); 81 modulesConfig.Set("SimulationServices", lscm.Name);
80 IConfig entityTransferConfig = config.AddConfig("EntityTransfer"); 82// IConfig entityTransferConfig = config.AddConfig("EntityTransfer");
81 83
82 // In order to run a single threaded regression test we do not want the entity transfer module waiting 84 // In order to run a single threaded regression test we do not want the entity transfer module waiting
83 // for a callback from the destination scene before removing its avatar data. 85 // for a callback from the destination scene before removing its avatar data.
@@ -89,6 +91,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
89 91
90 SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, config, lscm); 92 SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, config, lscm);
91 SceneHelpers.SetupSceneModules(sceneA, config, new CapabilitiesModule(), etmA); 93 SceneHelpers.SetupSceneModules(sceneA, config, new CapabilitiesModule(), etmA);
94// SceneHelpers.SetupSceneModules(sceneA, config, new CapabilitiesModule(), etmA, eqmA);
92 SceneHelpers.SetupSceneModules(sceneB, config, new CapabilitiesModule(), etmB); 95 SceneHelpers.SetupSceneModules(sceneB, config, new CapabilitiesModule(), etmB);
93 96
94 ScenePresence originalSp = SceneHelpers.AddScenePresence(sceneA, userId, sh.SceneManager); 97 ScenePresence originalSp = SceneHelpers.AddScenePresence(sceneA, userId, sh.SceneManager);
@@ -98,6 +101,8 @@ namespace OpenSim.Region.Framework.Scenes.Tests
98 101
99// Console.WriteLine("First pos {0}", originalSp.AbsolutePosition); 102// Console.WriteLine("First pos {0}", originalSp.AbsolutePosition);
100 103
104// eqmA.ClearEvents();
105
101 AgentUpdateArgs moveArgs = new AgentUpdateArgs(); 106 AgentUpdateArgs moveArgs = new AgentUpdateArgs();
102 //moveArgs.BodyRotation = Quaternion.CreateFromEulers(Vector3.Zero); 107 //moveArgs.BodyRotation = Quaternion.CreateFromEulers(Vector3.Zero);
103 moveArgs.BodyRotation = Quaternion.CreateFromEulers(new Vector3(0, 0, (float)-(Math.PI / 2))); 108 moveArgs.BodyRotation = Quaternion.CreateFromEulers(new Vector3(0, 0, (float)-(Math.PI / 2)));
@@ -117,6 +122,18 @@ namespace OpenSim.Region.Framework.Scenes.Tests
117// Console.WriteLine("Pos {0}", originalSp.AbsolutePosition); 122// Console.WriteLine("Pos {0}", originalSp.AbsolutePosition);
118 } 123 }
119 124
125 // Need to sort processing of EnableSimulator message on adding scene presences before we can test eqm
126 // messages
127// Dictionary<UUID, List<TestEventQueueGetModule.Event>> eqmEvents = eqmA.Events;
128//
129// Assert.That(eqmEvents.Count, Is.EqualTo(1));
130// Assert.That(eqmEvents.ContainsKey(originalSp.UUID), Is.True);
131//
132// List<TestEventQueueGetModule.Event> spEqmEvents = eqmEvents[originalSp.UUID];
133//
134// Assert.That(spEqmEvents.Count, Is.EqualTo(1));
135// Assert.That(spEqmEvents[0].Name, Is.EqualTo("CrossRegion"));
136
120 // sceneA should now only have a child agent 137 // sceneA should now only have a child agent
121 ScenePresence spAfterCrossSceneA = sceneA.GetScenePresence(originalSp.UUID); 138 ScenePresence spAfterCrossSceneA = sceneA.GetScenePresence(originalSp.UUID);
122 Assert.That(spAfterCrossSceneA.IsChildAgent, Is.True); 139 Assert.That(spAfterCrossSceneA.IsChildAgent, Is.True);
@@ -128,12 +145,12 @@ namespace OpenSim.Region.Framework.Scenes.Tests
128 145
129 TestClient sceneBTc = ((TestClient)spAfterCrossSceneB.ControllingClient); 146 TestClient sceneBTc = ((TestClient)spAfterCrossSceneB.ControllingClient);
130 147
131 bool receivedCompleteMovement = false; 148 int agentMovementCompleteReceived = 0;
132 sceneBTc.OnReceivedMoveAgentIntoRegion += (ri, pos, look) => receivedCompleteMovement = true; 149 sceneBTc.OnReceivedMoveAgentIntoRegion += (ri, pos, look) => agentMovementCompleteReceived++;
133 150
134 sceneBTc.CompleteMovement(); 151 sceneBTc.CompleteMovement();
135 152
136 Assert.That(receivedCompleteMovement, Is.True); 153 Assert.That(agentMovementCompleteReceived, Is.EqualTo(1));
137 Assert.That(spAfterCrossSceneB.IsChildAgent, Is.False); 154 Assert.That(spAfterCrossSceneB.IsChildAgent, Is.False);
138 } 155 }
139 } 156 }
diff --git a/OpenSim/Tests/Common/Mock/TestEventQueueGetModule.cs b/OpenSim/Tests/Common/Mock/TestEventQueueGetModule.cs
new file mode 100644
index 0000000..6707019
--- /dev/null
+++ b/OpenSim/Tests/Common/Mock/TestEventQueueGetModule.cs
@@ -0,0 +1,178 @@
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;
30using System.Collections.Generic;
31using System.Net;
32using System.Reflection;
33using System.Threading;
34using log4net;
35using Nini.Config;
36using Mono.Addins;
37using OpenMetaverse;
38using OpenMetaverse.StructuredData;
39using OpenSim.Framework;
40using OpenSim.Framework.Servers;
41using OpenSim.Region.Framework.Interfaces;
42using OpenSim.Region.Framework.Scenes;
43
44namespace OpenSim.Tests.Common
45{
46 public class TestEventQueueGetModule : IEventQueue, INonSharedRegionModule
47 {
48 public class Event
49 {
50 public string Name { get; set; }
51 public object[] Args { get; set; }
52
53 public Event(string name, object[] args)
54 {
55 name = Name;
56 args = Args;
57 }
58 }
59
60 public Dictionary<UUID, List<Event>> Events { get; set; }
61
62 public void Initialise(IConfigSource source) {}
63
64 public void Close() {}
65
66 public void AddRegion(Scene scene)
67 {
68 Events = new Dictionary<UUID, List<Event>>();
69 scene.RegisterModuleInterface<IEventQueue>(this);
70 }
71
72 public void RemoveRegion (Scene scene) {}
73
74 public void RegionLoaded (Scene scene) {}
75
76 public string Name { get { return "TestEventQueueGetModule"; } }
77
78 public Type ReplaceableInterface { get { return null; } }
79
80 private void AddEvent(UUID avatarID, string name, params object[] args)
81 {
82 Console.WriteLine("Adding event {0} for {1}", name, avatarID);
83
84 List<Event> avEvents;
85
86 if (!Events.ContainsKey(avatarID))
87 {
88 avEvents = new List<Event>();
89 Events[avatarID] = avEvents;
90 }
91 else
92 {
93 avEvents = Events[avatarID];
94 }
95
96 avEvents.Add(new Event(name, args));
97 }
98
99 public void ClearEvents()
100 {
101 if (Events != null)
102 Events.Clear();
103 }
104
105 public bool Enqueue(OSD o, UUID avatarID)
106 {
107 AddEvent(avatarID, "Enqueue", o);
108 return true;
109 }
110
111 public void DisableSimulator(ulong handle, UUID avatarID)
112 {
113 AddEvent(avatarID, "DisableSimulator", handle);
114 }
115
116 public void EnableSimulator (ulong handle, IPEndPoint endPoint, UUID avatarID)
117 {
118 AddEvent(avatarID, "EnableSimulator", handle);
119 }
120
121 public void EstablishAgentCommunication (UUID avatarID, IPEndPoint endPoint, string capsPath)
122 {
123 AddEvent(avatarID, "EstablishAgentCommunication", endPoint, capsPath);
124 }
125
126 public void TeleportFinishEvent (ulong regionHandle, byte simAccess, IPEndPoint regionExternalEndPoint, uint locationID, uint flags, string capsURL, UUID agentID)
127 {
128 AddEvent(agentID, "TeleportFinishEvent", regionHandle, simAccess, regionExternalEndPoint, locationID, flags, capsURL);
129 }
130
131 public void CrossRegion (ulong handle, Vector3 pos, Vector3 lookAt, IPEndPoint newRegionExternalEndPoint, string capsURL, UUID avatarID, UUID sessionID)
132 {
133 AddEvent(avatarID, "CrossRegion", handle, pos, lookAt, newRegionExternalEndPoint, capsURL, sessionID);
134 }
135
136 public void ChatterboxInvitation(
137 UUID sessionID, string sessionName, UUID fromAgent, string message, UUID toAgent, string fromName,
138 byte dialog, uint timeStamp, bool offline, int parentEstateID, Vector3 position, uint ttl,
139 UUID transactionID, bool fromGroup, byte[] binaryBucket)
140 {
141 AddEvent(
142 toAgent, "ChatterboxInvitation", sessionID, sessionName, fromAgent, message, toAgent, fromName, dialog,
143 timeStamp, offline, parentEstateID, position, ttl, transactionID, fromGroup, binaryBucket);
144 }
145
146 public void ChatterBoxSessionAgentListUpdates (UUID sessionID, UUID fromAgent, UUID toAgent, bool canVoiceChat, bool isModerator, bool textMute)
147 {
148 AddEvent(toAgent, "ChatterBoxSessionAgentListUpdates", sessionID, fromAgent, canVoiceChat, isModerator, textMute);
149 }
150
151 public void ParcelProperties (OpenMetaverse.Messages.Linden.ParcelPropertiesMessage parcelPropertiesMessage, UUID avatarID)
152 {
153 AddEvent(avatarID, "ParcelProperties", parcelPropertiesMessage);
154 }
155
156 public void GroupMembership (OpenMetaverse.Packets.AgentGroupDataUpdatePacket groupUpdate, UUID avatarID)
157 {
158 AddEvent(avatarID, "GroupMembership", groupUpdate);
159 }
160
161 public OSD ScriptRunningEvent (UUID objectID, UUID itemID, bool running, bool mono)
162 {
163 Console.WriteLine("ONE");
164 throw new System.NotImplementedException ();
165 }
166
167 public OSD BuildEvent (string eventName, OSD eventBody)
168 {
169 Console.WriteLine("TWO");
170 throw new System.NotImplementedException ();
171 }
172
173 public void partPhysicsProperties (uint localID, byte physhapetype, float density, float friction, float bounce, float gravmod, UUID avatarID)
174 {
175 AddEvent(avatarID, "partPhysicsProperties", localID, physhapetype, density, friction, bounce, gravmod);
176 }
177 }
178} \ No newline at end of file