aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2014-02-12 23:16:42 +0000
committerJustin Clark-Casey (justincc)2014-02-12 23:18:10 +0000
commite10012a7a6a047287c193c4beb1afdcd62922e3e (patch)
tree3d12589e49e53c85ab744a97f92fa0c3d2ad02bd /OpenSim
parentMake sure Web streams are disposed after use (diff)
downloadopensim-SC_OLD-e10012a7a6a047287c193c4beb1afdcd62922e3e.zip
opensim-SC_OLD-e10012a7a6a047287c193c4beb1afdcd62922e3e.tar.gz
opensim-SC_OLD-e10012a7a6a047287c193c4beb1afdcd62922e3e.tar.bz2
opensim-SC_OLD-e10012a7a6a047287c193c4beb1afdcd62922e3e.tar.xz
If a caller tries to queue a CAPs message to a scene presence that has no event queue (e.g. an NPC), only warn if event queue debugging is greater than zero.
Removes the spurious log warnings if groups are active when NPCs are used. Adds more regression tests associated with adding messages to the event queue
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs16
-rw-r--r--OpenSim/Region/ClientStack/Linden/Caps/EventQueue/Tests/EventQueueTests.cs90
2 files changed, 99 insertions, 7 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs
index 0dbdbaf..0447bc4 100644
--- a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs
+++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs
@@ -228,12 +228,18 @@ namespace OpenSim.Region.ClientStack.Linden
228 lock (queue) 228 lock (queue)
229 queue.Enqueue(ev); 229 queue.Enqueue(ev);
230 } 230 }
231 else 231 else if (DebugLevel > 0)
232 { 232 {
233 OSDMap evMap = (OSDMap)ev; 233 ScenePresence sp = m_scene.GetScenePresence(avatarID);
234 m_log.WarnFormat( 234
235 "[EVENTQUEUE]: (Enqueue) No queue found for agent {0} when placing message {1} in region {2}", 235 // This assumes that an NPC should never have a queue.
236 avatarID, evMap["message"], m_scene.Name); 236 if (sp != null && sp.PresenceType != PresenceType.Npc)
237 {
238 OSDMap evMap = (OSDMap)ev;
239 m_log.WarnFormat(
240 "[EVENTQUEUE]: (Enqueue) No queue found for agent {0} {1} when placing message {2} in region {3}",
241 sp.Name, sp.UUID, evMap["message"], m_scene.Name);
242 }
237 } 243 }
238 } 244 }
239 catch (NullReferenceException e) 245 catch (NullReferenceException e)
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/Tests/EventQueueTests.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/Tests/EventQueueTests.cs
index 9e24bce..fb24f58 100644
--- a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/Tests/EventQueueTests.cs
+++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/Tests/EventQueueTests.cs
@@ -26,6 +26,7 @@
26 */ 26 */
27 27
28using System; 28using System;
29using System.Collections;
29using System.Collections.Generic; 30using System.Collections.Generic;
30using System.Net; 31using System.Net;
31using log4net.Config; 32using log4net.Config;
@@ -33,11 +34,14 @@ using Nini.Config;
33using NUnit.Framework; 34using NUnit.Framework;
34using OpenMetaverse; 35using OpenMetaverse;
35using OpenMetaverse.Packets; 36using OpenMetaverse.Packets;
37using OpenMetaverse.StructuredData;
36using OpenSim.Framework; 38using OpenSim.Framework;
37using OpenSim.Framework.Servers; 39using OpenSim.Framework.Servers;
38using OpenSim.Framework.Servers.HttpServer; 40using OpenSim.Framework.Servers.HttpServer;
39using OpenSim.Region.ClientStack.Linden; 41using OpenSim.Region.ClientStack.Linden;
40using OpenSim.Region.CoreModules.Framework; 42using OpenSim.Region.CoreModules.Framework;
43using OpenSim.Region.Framework.Scenes;
44using OpenSim.Region.OptionalModules.World.NPC;
41using OpenSim.Tests.Common; 45using OpenSim.Tests.Common;
42using OpenSim.Tests.Common.Mock; 46using OpenSim.Tests.Common.Mock;
43 47
@@ -47,6 +51,8 @@ namespace OpenSim.Region.ClientStack.Linden.Tests
47 public class EventQueueTests : OpenSimTestCase 51 public class EventQueueTests : OpenSimTestCase
48 { 52 {
49 private TestScene m_scene; 53 private TestScene m_scene;
54 private EventQueueGetModule m_eqgMod;
55 private NPCModule m_npcMod;
50 56
51 [SetUp] 57 [SetUp]
52 public override void SetUp() 58 public override void SetUp()
@@ -69,10 +75,15 @@ namespace OpenSim.Region.ClientStack.Linden.Tests
69 config.Configs["Startup"].Set("EventQueue", "true"); 75 config.Configs["Startup"].Set("EventQueue", "true");
70 76
71 CapabilitiesModule capsModule = new CapabilitiesModule(); 77 CapabilitiesModule capsModule = new CapabilitiesModule();
72 EventQueueGetModule eqgModule = new EventQueueGetModule(); 78 m_eqgMod = new EventQueueGetModule();
79
80 // For NPC test support
81 config.AddConfig("NPC");
82 config.Configs["NPC"].Set("Enabled", "true");
83 m_npcMod = new NPCModule();
73 84
74 m_scene = new SceneHelpers().SetupScene(); 85 m_scene = new SceneHelpers().SetupScene();
75 SceneHelpers.SetupSceneModules(m_scene, config, capsModule, eqgModule); 86 SceneHelpers.SetupSceneModules(m_scene, config, capsModule, m_eqgMod, m_npcMod);
76 } 87 }
77 88
78 [Test] 89 [Test]
@@ -101,5 +112,80 @@ namespace OpenSim.Region.ClientStack.Linden.Tests
101 // TODO: Add more assertions for the other aspects of event queues 112 // TODO: Add more assertions for the other aspects of event queues
102 Assert.That(MainServer.Instance.GetPollServiceHandlerKeys().Count, Is.EqualTo(0)); 113 Assert.That(MainServer.Instance.GetPollServiceHandlerKeys().Count, Is.EqualTo(0));
103 } 114 }
115
116 [Test]
117 public void TestEnqueueMessage()
118 {
119 TestHelpers.InMethod();
120// log4net.Config.XmlConfigurator.Configure();
121
122 ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, TestHelpers.ParseTail(0x1));
123
124 string messageName = "TestMessage";
125
126 m_eqgMod.Enqueue(m_eqgMod.BuildEvent(messageName, new OSDMap()), sp.UUID);
127
128 Hashtable eventsResponse = m_eqgMod.GetEvents(UUID.Zero, sp.UUID);
129
130 Assert.That((int)eventsResponse["int_response_code"], Is.EqualTo((int)HttpStatusCode.OK));
131
132// Console.WriteLine("Response [{0}]", (string)eventsResponse["str_response_string"]);
133
134 OSDMap rawOsd = (OSDMap)OSDParser.DeserializeLLSDXml((string)eventsResponse["str_response_string"]);
135 OSDArray eventsOsd = (OSDArray)rawOsd["events"];
136
137 bool foundUpdate = false;
138 foreach (OSD osd in eventsOsd)
139 {
140 OSDMap eventOsd = (OSDMap)osd;
141
142 if (eventOsd["message"] == messageName)
143 foundUpdate = true;
144 }
145
146 Assert.That(foundUpdate, Is.True, string.Format("Did not find {0} in response", messageName));
147 }
148
149 /// <summary>
150 /// Test an attempt to put a message on the queue of a user that is not in the region.
151 /// </summary>
152 [Test]
153 public void TestEnqueueMessageNoUser()
154 {
155 TestHelpers.InMethod();
156 TestHelpers.EnableLogging();
157
158 string messageName = "TestMessage";
159
160 m_eqgMod.Enqueue(m_eqgMod.BuildEvent(messageName, new OSDMap()), TestHelpers.ParseTail(0x1));
161
162 Hashtable eventsResponse = m_eqgMod.GetEvents(UUID.Zero, TestHelpers.ParseTail(0x1));
163
164 Assert.That((int)eventsResponse["int_response_code"], Is.EqualTo((int)HttpStatusCode.BadGateway));
165 }
166
167 /// <summary>
168 /// NPCs do not currently have an event queue but a caller may try to send a message anyway, so check behaviour.
169 /// </summary>
170 [Test]
171 public void TestEnqueueMessageToNpc()
172 {
173 TestHelpers.InMethod();
174// TestHelpers.EnableLogging();
175
176 UUID npcId
177 = m_npcMod.CreateNPC(
178 "John", "Smith", new Vector3(128, 128, 30), UUID.Zero, true, m_scene, new AvatarAppearance());
179
180 ScenePresence npc = m_scene.GetScenePresence(npcId);
181
182 string messageName = "TestMessage";
183
184 m_eqgMod.Enqueue(m_eqgMod.BuildEvent(messageName, new OSDMap()), npc.UUID);
185
186 Hashtable eventsResponse = m_eqgMod.GetEvents(UUID.Zero, npc.UUID);
187
188 Assert.That((int)eventsResponse["int_response_code"], Is.EqualTo((int)HttpStatusCode.BadGateway));
189 }
104 } 190 }
105} \ No newline at end of file 191} \ No newline at end of file