clockwerk-opensim-stable – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | vero | 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 | |||
28 | using System; |
||
29 | using System.Collections.Generic; |
||
30 | using System.IO; |
||
31 | using System.Net; |
||
32 | using System.Text; |
||
33 | using System.Threading; |
||
34 | using Nini.Config; |
||
35 | using NUnit.Framework; |
||
36 | using OpenMetaverse; |
||
37 | using OpenSim.Framework; |
||
38 | using OpenSim.Framework.Communications; |
||
39 | using OpenSim.Framework.Servers; |
||
40 | using OpenSim.Region.Framework.Interfaces; |
||
41 | using OpenSim.Region.CoreModules.Framework; |
||
42 | using OpenSim.Region.CoreModules.Framework.EntityTransfer; |
||
43 | using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation; |
||
44 | using OpenSim.Region.CoreModules.World.Permissions; |
||
45 | using OpenSim.Tests.Common; |
||
46 | using OpenSim.Tests.Common.Mock; |
||
47 | |||
48 | namespace OpenSim.Region.Framework.Scenes.Tests |
||
49 | { |
||
50 | /// <summary> |
||
51 | /// Teleport tests in a standalone OpenSim |
||
52 | /// </summary> |
||
53 | [TestFixture] |
||
54 | public class ScenePresenceTeleportTests : OpenSimTestCase |
||
55 | { |
||
56 | [TestFixtureSetUp] |
||
57 | public void FixtureInit() |
||
58 | { |
||
59 | // Don't allow tests to be bamboozled by asynchronous events. Execute everything on the same thread. |
||
60 | Util.FireAndForgetMethod = FireAndForgetMethod.RegressionTest; |
||
61 | } |
||
62 | |||
63 | [TestFixtureTearDown] |
||
64 | public void TearDown() |
||
65 | { |
||
66 | // We must set this back afterwards, otherwise later tests will fail since they're expecting multiple |
||
67 | // threads. Possibly, later tests should be rewritten so none of them require async stuff (which regression |
||
68 | // tests really shouldn't). |
||
69 | Util.FireAndForgetMethod = Util.DefaultFireAndForgetMethod; |
||
70 | } |
||
71 | |||
72 | [Test] |
||
73 | public void TestSameRegion() |
||
74 | { |
||
75 | TestHelpers.InMethod(); |
||
76 | // log4net.Config.XmlConfigurator.Configure(); |
||
77 | |||
78 | EntityTransferModule etm = new EntityTransferModule(); |
||
79 | |||
80 | IConfigSource config = new IniConfigSource(); |
||
81 | config.AddConfig("Modules"); |
||
82 | // Not strictly necessary since FriendsModule assumes it is the default (!) |
||
83 | config.Configs["Modules"].Set("EntityTransferModule", etm.Name); |
||
84 | |||
85 | TestScene scene = new SceneHelpers().SetupScene("sceneA", TestHelpers.ParseTail(0x100), 1000, 1000); |
||
86 | SceneHelpers.SetupSceneModules(scene, config, etm); |
||
87 | |||
88 | Vector3 teleportPosition = new Vector3(10, 11, 12); |
||
89 | Vector3 teleportLookAt = new Vector3(20, 21, 22); |
||
90 | |||
91 | ScenePresence sp = SceneHelpers.AddScenePresence(scene, TestHelpers.ParseTail(0x1)); |
||
92 | sp.AbsolutePosition = new Vector3(30, 31, 32); |
||
93 | scene.RequestTeleportLocation( |
||
94 | sp.ControllingClient, |
||
95 | scene.RegionInfo.RegionHandle, |
||
96 | teleportPosition, |
||
97 | teleportLookAt, |
||
98 | (uint)TeleportFlags.ViaLocation); |
||
99 | |||
100 | Assert.That(sp.AbsolutePosition, Is.EqualTo(teleportPosition)); |
||
101 | |||
102 | Assert.That(scene.GetRootAgentCount(), Is.EqualTo(1)); |
||
103 | Assert.That(scene.GetChildAgentCount(), Is.EqualTo(0)); |
||
104 | |||
105 | // Lookat is sent to the client only - sp.Lookat does not yield the same thing (calculation from camera |
||
106 | // position instead). |
||
107 | // Assert.That(sp.Lookat, Is.EqualTo(teleportLookAt)); |
||
108 | } |
||
109 | |||
110 | [Test] |
||
111 | public void TestSameSimulatorIsolatedRegionsV1() |
||
112 | { |
||
113 | TestHelpers.InMethod(); |
||
114 | // TestHelpers.EnableLogging(); |
||
115 | |||
116 | UUID userId = TestHelpers.ParseTail(0x1); |
||
117 | |||
118 | EntityTransferModule etmA = new EntityTransferModule(); |
||
119 | EntityTransferModule etmB = new EntityTransferModule(); |
||
120 | LocalSimulationConnectorModule lscm = new LocalSimulationConnectorModule(); |
||
121 | |||
122 | IConfigSource config = new IniConfigSource(); |
||
123 | IConfig modulesConfig = config.AddConfig("Modules"); |
||
124 | modulesConfig.Set("EntityTransferModule", etmA.Name); |
||
125 | modulesConfig.Set("SimulationServices", lscm.Name); |
||
126 | IConfig entityTransferConfig = config.AddConfig("EntityTransfer"); |
||
127 | |||
128 | // In order to run a single threaded regression test we do not want the entity transfer module waiting |
||
129 | // for a callback from the destination scene before removing its avatar data. |
||
130 | entityTransferConfig.Set("wait_for_callback", false); |
||
131 | |||
132 | SceneHelpers sh = new SceneHelpers(); |
||
133 | TestScene sceneA = sh.SetupScene("sceneA", TestHelpers.ParseTail(0x100), 1000, 1000); |
||
134 | TestScene sceneB = sh.SetupScene("sceneB", TestHelpers.ParseTail(0x200), 1002, 1000); |
||
135 | |||
136 | SceneHelpers.SetupSceneModules(sceneA, config, etmA); |
||
137 | SceneHelpers.SetupSceneModules(sceneB, config, etmB); |
||
138 | SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, config, lscm); |
||
139 | |||
140 | // FIXME: Hack - this is here temporarily to revert back to older entity transfer behaviour |
||
141 | lscm.ServiceVersion = "SIMULATION/0.1"; |
||
142 | |||
143 | Vector3 teleportPosition = new Vector3(10, 11, 12); |
||
144 | Vector3 teleportLookAt = new Vector3(20, 21, 22); |
||
145 | |||
146 | ScenePresence sp = SceneHelpers.AddScenePresence(sceneA, userId); |
||
147 | sp.AbsolutePosition = new Vector3(30, 31, 32); |
||
148 | |||
149 | List<TestClient> destinationTestClients = new List<TestClient>(); |
||
150 | EntityTransferHelpers.SetupInformClientOfNeighbourTriggersNeighbourClientCreate( |
||
151 | (TestClient)sp.ControllingClient, destinationTestClients); |
||
152 | |||
153 | sceneA.RequestTeleportLocation( |
||
154 | sp.ControllingClient, |
||
155 | sceneB.RegionInfo.RegionHandle, |
||
156 | teleportPosition, |
||
157 | teleportLookAt, |
||
158 | (uint)TeleportFlags.ViaLocation); |
||
159 | |||
160 | // SetupInformClientOfNeighbour() will have handled the callback into the target scene to setup the child |
||
161 | // agent. This call will now complete the movement of the user into the destination and upgrade the agent |
||
162 | // from child to root. |
||
163 | destinationTestClients[0].CompleteMovement(); |
||
164 | |||
165 | Assert.That(sceneA.GetScenePresence(userId), Is.Null); |
||
166 | |||
167 | ScenePresence sceneBSp = sceneB.GetScenePresence(userId); |
||
168 | Assert.That(sceneBSp, Is.Not.Null); |
||
169 | Assert.That(sceneBSp.Scene.RegionInfo.RegionName, Is.EqualTo(sceneB.RegionInfo.RegionName)); |
||
170 | Assert.That(sceneBSp.AbsolutePosition, Is.EqualTo(teleportPosition)); |
||
171 | |||
172 | Assert.That(sceneA.GetRootAgentCount(), Is.EqualTo(0)); |
||
173 | Assert.That(sceneA.GetChildAgentCount(), Is.EqualTo(0)); |
||
174 | Assert.That(sceneB.GetRootAgentCount(), Is.EqualTo(1)); |
||
175 | Assert.That(sceneB.GetChildAgentCount(), Is.EqualTo(0)); |
||
176 | |||
177 | // TODO: Add assertions to check correct circuit details in both scenes. |
||
178 | |||
179 | // Lookat is sent to the client only - sp.Lookat does not yield the same thing (calculation from camera |
||
180 | // position instead). |
||
181 | // Assert.That(sp.Lookat, Is.EqualTo(teleportLookAt)); |
||
182 | } |
||
183 | |||
184 | [Test] |
||
185 | public void TestSameSimulatorIsolatedRegionsV2() |
||
186 | { |
||
187 | TestHelpers.InMethod(); |
||
188 | // TestHelpers.EnableLogging(); |
||
189 | |||
190 | UUID userId = TestHelpers.ParseTail(0x1); |
||
191 | |||
192 | EntityTransferModule etmA = new EntityTransferModule(); |
||
193 | EntityTransferModule etmB = new EntityTransferModule(); |
||
194 | LocalSimulationConnectorModule lscm = new LocalSimulationConnectorModule(); |
||
195 | |||
196 | IConfigSource config = new IniConfigSource(); |
||
197 | IConfig modulesConfig = config.AddConfig("Modules"); |
||
198 | modulesConfig.Set("EntityTransferModule", etmA.Name); |
||
199 | modulesConfig.Set("SimulationServices", lscm.Name); |
||
200 | |||
201 | SceneHelpers sh = new SceneHelpers(); |
||
202 | TestScene sceneA = sh.SetupScene("sceneA", TestHelpers.ParseTail(0x100), 1000, 1000); |
||
203 | TestScene sceneB = sh.SetupScene("sceneB", TestHelpers.ParseTail(0x200), 1002, 1000); |
||
204 | |||
205 | SceneHelpers.SetupSceneModules(sceneA, config, etmA); |
||
206 | SceneHelpers.SetupSceneModules(sceneB, config, etmB); |
||
207 | SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, config, lscm); |
||
208 | |||
209 | Vector3 teleportPosition = new Vector3(10, 11, 12); |
||
210 | Vector3 teleportLookAt = new Vector3(20, 21, 22); |
||
211 | |||
212 | ScenePresence sp = SceneHelpers.AddScenePresence(sceneA, userId); |
||
213 | sp.AbsolutePosition = new Vector3(30, 31, 32); |
||
214 | |||
215 | List<TestClient> destinationTestClients = new List<TestClient>(); |
||
216 | EntityTransferHelpers.SetupSendRegionTeleportTriggersDestinationClientCreateAndCompleteMovement( |
||
217 | (TestClient)sp.ControllingClient, destinationTestClients); |
||
218 | |||
219 | sceneA.RequestTeleportLocation( |
||
220 | sp.ControllingClient, |
||
221 | sceneB.RegionInfo.RegionHandle, |
||
222 | teleportPosition, |
||
223 | teleportLookAt, |
||
224 | (uint)TeleportFlags.ViaLocation); |
||
225 | |||
226 | Assert.That(sceneA.GetScenePresence(userId), Is.Null); |
||
227 | |||
228 | ScenePresence sceneBSp = sceneB.GetScenePresence(userId); |
||
229 | Assert.That(sceneBSp, Is.Not.Null); |
||
230 | Assert.That(sceneBSp.Scene.RegionInfo.RegionName, Is.EqualTo(sceneB.RegionInfo.RegionName)); |
||
231 | Assert.That(sceneBSp.AbsolutePosition, Is.EqualTo(teleportPosition)); |
||
232 | |||
233 | Assert.That(sceneA.GetRootAgentCount(), Is.EqualTo(0)); |
||
234 | Assert.That(sceneA.GetChildAgentCount(), Is.EqualTo(0)); |
||
235 | Assert.That(sceneB.GetRootAgentCount(), Is.EqualTo(1)); |
||
236 | Assert.That(sceneB.GetChildAgentCount(), Is.EqualTo(0)); |
||
237 | |||
238 | // TODO: Add assertions to check correct circuit details in both scenes. |
||
239 | |||
240 | // Lookat is sent to the client only - sp.Lookat does not yield the same thing (calculation from camera |
||
241 | // position instead). |
||
242 | // Assert.That(sp.Lookat, Is.EqualTo(teleportLookAt)); |
||
243 | } |
||
244 | |||
245 | /// <summary> |
||
246 | /// Test teleport procedures when the target simulator returns false when queried about access. |
||
247 | /// </summary> |
||
248 | [Test] |
||
249 | public void TestSameSimulatorIsolatedRegions_DeniedOnQueryAccess() |
||
250 | { |
||
251 | TestHelpers.InMethod(); |
||
252 | // TestHelpers.EnableLogging(); |
||
253 | |||
254 | UUID userId = TestHelpers.ParseTail(0x1); |
||
255 | Vector3 preTeleportPosition = new Vector3(30, 31, 32); |
||
256 | |||
257 | EntityTransferModule etmA = new EntityTransferModule(); |
||
258 | EntityTransferModule etmB = new EntityTransferModule(); |
||
259 | |||
260 | LocalSimulationConnectorModule lscm = new LocalSimulationConnectorModule(); |
||
261 | |||
262 | IConfigSource config = new IniConfigSource(); |
||
263 | config.AddConfig("Modules"); |
||
264 | config.Configs["Modules"].Set("EntityTransferModule", etmA.Name); |
||
265 | config.Configs["Modules"].Set("SimulationServices", lscm.Name); |
||
266 | |||
267 | config.AddConfig("EntityTransfer"); |
||
268 | |||
269 | // In order to run a single threaded regression test we do not want the entity transfer module waiting |
||
270 | // for a callback from the destination scene before removing its avatar data. |
||
271 | config.Configs["EntityTransfer"].Set("wait_for_callback", false); |
||
272 | |||
273 | config.AddConfig("Startup"); |
||
274 | config.Configs["Startup"].Set("serverside_object_permissions", true); |
||
275 | |||
276 | SceneHelpers sh = new SceneHelpers(); |
||
277 | TestScene sceneA = sh.SetupScene("sceneA", TestHelpers.ParseTail(0x100), 1000, 1000); |
||
278 | TestScene sceneB = sh.SetupScene("sceneB", TestHelpers.ParseTail(0x200), 1002, 1000); |
||
279 | |||
280 | SceneHelpers.SetupSceneModules(sceneA, config, etmA ); |
||
281 | |||
282 | // We need to set up the permisions module on scene B so that our later use of agent limit to deny |
||
283 | // QueryAccess won't succeed anyway because administrators are always allowed in and the default |
||
284 | // IsAdministrator if no permissions module is present is true. |
||
285 | SceneHelpers.SetupSceneModules(sceneB, config, new object[] { new PermissionsModule(), etmB }); |
||
286 | |||
287 | // Shared scene modules |
||
288 | SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, config, lscm); |
||
289 | |||
290 | Vector3 teleportPosition = new Vector3(10, 11, 12); |
||
291 | Vector3 teleportLookAt = new Vector3(20, 21, 22); |
||
292 | |||
293 | ScenePresence sp = SceneHelpers.AddScenePresence(sceneA, userId); |
||
294 | sp.AbsolutePosition = preTeleportPosition; |
||
295 | |||
296 | // Make sceneB return false on query access |
||
297 | sceneB.RegionInfo.RegionSettings.AgentLimit = 0; |
||
298 | |||
299 | sceneA.RequestTeleportLocation( |
||
300 | sp.ControllingClient, |
||
301 | sceneB.RegionInfo.RegionHandle, |
||
302 | teleportPosition, |
||
303 | teleportLookAt, |
||
304 | (uint)TeleportFlags.ViaLocation); |
||
305 | |||
306 | // ((TestClient)sp.ControllingClient).CompleteTeleportClientSide(); |
||
307 | |||
308 | Assert.That(sceneB.GetScenePresence(userId), Is.Null); |
||
309 | |||
310 | ScenePresence sceneASp = sceneA.GetScenePresence(userId); |
||
311 | Assert.That(sceneASp, Is.Not.Null); |
||
312 | Assert.That(sceneASp.Scene.RegionInfo.RegionName, Is.EqualTo(sceneA.RegionInfo.RegionName)); |
||
313 | Assert.That(sceneASp.AbsolutePosition, Is.EqualTo(preTeleportPosition)); |
||
314 | |||
315 | Assert.That(sceneA.GetRootAgentCount(), Is.EqualTo(1)); |
||
316 | Assert.That(sceneA.GetChildAgentCount(), Is.EqualTo(0)); |
||
317 | Assert.That(sceneB.GetRootAgentCount(), Is.EqualTo(0)); |
||
318 | Assert.That(sceneB.GetChildAgentCount(), Is.EqualTo(0)); |
||
319 | |||
320 | // TODO: Add assertions to check correct circuit details in both scenes. |
||
321 | |||
322 | // Lookat is sent to the client only - sp.Lookat does not yield the same thing (calculation from camera |
||
323 | // position instead). |
||
324 | // Assert.That(sp.Lookat, Is.EqualTo(teleportLookAt)); |
||
325 | |||
326 | // TestHelpers.DisableLogging(); |
||
327 | } |
||
328 | |||
329 | /// <summary> |
||
330 | /// Test teleport procedures when the target simulator create agent step is refused. |
||
331 | /// </summary> |
||
332 | [Test] |
||
333 | public void TestSameSimulatorIsolatedRegions_DeniedOnCreateAgent() |
||
334 | { |
||
335 | TestHelpers.InMethod(); |
||
336 | // TestHelpers.EnableLogging(); |
||
337 | |||
338 | UUID userId = TestHelpers.ParseTail(0x1); |
||
339 | Vector3 preTeleportPosition = new Vector3(30, 31, 32); |
||
340 | |||
341 | EntityTransferModule etmA = new EntityTransferModule(); |
||
342 | EntityTransferModule etmB = new EntityTransferModule(); |
||
343 | LocalSimulationConnectorModule lscm = new LocalSimulationConnectorModule(); |
||
344 | |||
345 | IConfigSource config = new IniConfigSource(); |
||
346 | config.AddConfig("Modules"); |
||
347 | config.Configs["Modules"].Set("EntityTransferModule", etmA.Name); |
||
348 | config.Configs["Modules"].Set("SimulationServices", lscm.Name); |
||
349 | |||
350 | config.AddConfig("EntityTransfer"); |
||
351 | |||
352 | // In order to run a single threaded regression test we do not want the entity transfer module waiting |
||
353 | // for a callback from the destination scene before removing its avatar data. |
||
354 | config.Configs["EntityTransfer"].Set("wait_for_callback", false); |
||
355 | |||
356 | SceneHelpers sh = new SceneHelpers(); |
||
357 | TestScene sceneA = sh.SetupScene("sceneA", TestHelpers.ParseTail(0x100), 1000, 1000); |
||
358 | TestScene sceneB = sh.SetupScene("sceneB", TestHelpers.ParseTail(0x200), 1002, 1000); |
||
359 | |||
360 | SceneHelpers.SetupSceneModules(sceneA, config, etmA); |
||
361 | SceneHelpers.SetupSceneModules(sceneB, config, etmB); |
||
362 | |||
363 | // Shared scene modules |
||
364 | SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, config, lscm); |
||
365 | |||
366 | Vector3 teleportPosition = new Vector3(10, 11, 12); |
||
367 | Vector3 teleportLookAt = new Vector3(20, 21, 22); |
||
368 | |||
369 | ScenePresence sp = SceneHelpers.AddScenePresence(sceneA, userId); |
||
370 | sp.AbsolutePosition = preTeleportPosition; |
||
371 | |||
372 | // Make sceneB refuse CreateAgent |
||
373 | sceneB.LoginsEnabled = false; |
||
374 | |||
375 | sceneA.RequestTeleportLocation( |
||
376 | sp.ControllingClient, |
||
377 | sceneB.RegionInfo.RegionHandle, |
||
378 | teleportPosition, |
||
379 | teleportLookAt, |
||
380 | (uint)TeleportFlags.ViaLocation); |
||
381 | |||
382 | // ((TestClient)sp.ControllingClient).CompleteTeleportClientSide(); |
||
383 | |||
384 | Assert.That(sceneB.GetScenePresence(userId), Is.Null); |
||
385 | |||
386 | ScenePresence sceneASp = sceneA.GetScenePresence(userId); |
||
387 | Assert.That(sceneASp, Is.Not.Null); |
||
388 | Assert.That(sceneASp.Scene.RegionInfo.RegionName, Is.EqualTo(sceneA.RegionInfo.RegionName)); |
||
389 | Assert.That(sceneASp.AbsolutePosition, Is.EqualTo(preTeleportPosition)); |
||
390 | |||
391 | Assert.That(sceneA.GetRootAgentCount(), Is.EqualTo(1)); |
||
392 | Assert.That(sceneA.GetChildAgentCount(), Is.EqualTo(0)); |
||
393 | Assert.That(sceneB.GetRootAgentCount(), Is.EqualTo(0)); |
||
394 | Assert.That(sceneB.GetChildAgentCount(), Is.EqualTo(0)); |
||
395 | |||
396 | // TODO: Add assertions to check correct circuit details in both scenes. |
||
397 | |||
398 | // Lookat is sent to the client only - sp.Lookat does not yield the same thing (calculation from camera |
||
399 | // position instead). |
||
400 | // Assert.That(sp.Lookat, Is.EqualTo(teleportLookAt)); |
||
401 | |||
402 | // TestHelpers.DisableLogging(); |
||
403 | } |
||
404 | |||
405 | /// <summary> |
||
406 | /// Test teleport when the destination region does not process (or does not receive) the connection attempt |
||
407 | /// from the viewer. |
||
408 | /// </summary> |
||
409 | /// <remarks> |
||
410 | /// This could be quite a common case where the source region can connect to a remove destination region |
||
411 | /// (for CreateAgent) but the viewer cannot reach the destination region due to network issues. |
||
412 | /// </remarks> |
||
413 | [Test] |
||
414 | public void TestSameSimulatorIsolatedRegions_DestinationDidNotProcessViewerConnection() |
||
415 | { |
||
416 | TestHelpers.InMethod(); |
||
417 | // TestHelpers.EnableLogging(); |
||
418 | |||
419 | UUID userId = TestHelpers.ParseTail(0x1); |
||
420 | Vector3 preTeleportPosition = new Vector3(30, 31, 32); |
||
421 | |||
422 | EntityTransferModule etmA = new EntityTransferModule(); |
||
423 | EntityTransferModule etmB = new EntityTransferModule(); |
||
424 | |||
425 | LocalSimulationConnectorModule lscm = new LocalSimulationConnectorModule(); |
||
426 | |||
427 | IConfigSource config = new IniConfigSource(); |
||
428 | config.AddConfig("Modules"); |
||
429 | config.Configs["Modules"].Set("EntityTransferModule", etmA.Name); |
||
430 | config.Configs["Modules"].Set("SimulationServices", lscm.Name); |
||
431 | |||
432 | config.AddConfig("EntityTransfer"); |
||
433 | |||
434 | // In order to run a single threaded regression test we do not want the entity transfer module waiting |
||
435 | // for a callback from the destination scene before removing its avatar data. |
||
436 | config.Configs["EntityTransfer"].Set("wait_for_callback", false); |
||
437 | |||
438 | // config.AddConfig("Startup"); |
||
439 | // config.Configs["Startup"].Set("serverside_object_permissions", true); |
||
440 | |||
441 | SceneHelpers sh = new SceneHelpers(); |
||
442 | TestScene sceneA = sh.SetupScene("sceneA", TestHelpers.ParseTail(0x100), 1000, 1000); |
||
443 | TestScene sceneB = sh.SetupScene("sceneB", TestHelpers.ParseTail(0x200), 1002, 1000); |
||
444 | |||
445 | SceneHelpers.SetupSceneModules(sceneA, config, etmA ); |
||
446 | |||
447 | // We need to set up the permisions module on scene B so that our later use of agent limit to deny |
||
448 | // QueryAccess won't succeed anyway because administrators are always allowed in and the default |
||
449 | // IsAdministrator if no permissions module is present is true. |
||
450 | SceneHelpers.SetupSceneModules(sceneB, config, new object[] { new PermissionsModule(), etmB }); |
||
451 | |||
452 | // Shared scene modules |
||
453 | SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, config, lscm); |
||
454 | |||
455 | Vector3 teleportPosition = new Vector3(10, 11, 12); |
||
456 | Vector3 teleportLookAt = new Vector3(20, 21, 22); |
||
457 | |||
458 | ScenePresence sp = SceneHelpers.AddScenePresence(sceneA, userId); |
||
459 | sp.AbsolutePosition = preTeleportPosition; |
||
460 | |||
461 | sceneA.RequestTeleportLocation( |
||
462 | sp.ControllingClient, |
||
463 | sceneB.RegionInfo.RegionHandle, |
||
464 | teleportPosition, |
||
465 | teleportLookAt, |
||
466 | (uint)TeleportFlags.ViaLocation); |
||
467 | |||
468 | // FIXME: Not setting up InformClientOfNeighbour on the TestClient means that it does not initiate |
||
469 | // communication with the destination region. But this is a very non-obvious way of doing it - really we |
||
470 | // should be forced to expicitly set this up. |
||
471 | |||
472 | Assert.That(sceneB.GetScenePresence(userId), Is.Null); |
||
473 | |||
474 | ScenePresence sceneASp = sceneA.GetScenePresence(userId); |
||
475 | Assert.That(sceneASp, Is.Not.Null); |
||
476 | Assert.That(sceneASp.Scene.RegionInfo.RegionName, Is.EqualTo(sceneA.RegionInfo.RegionName)); |
||
477 | Assert.That(sceneASp.AbsolutePosition, Is.EqualTo(preTeleportPosition)); |
||
478 | |||
479 | Assert.That(sceneA.GetRootAgentCount(), Is.EqualTo(1)); |
||
480 | Assert.That(sceneA.GetChildAgentCount(), Is.EqualTo(0)); |
||
481 | Assert.That(sceneB.GetRootAgentCount(), Is.EqualTo(0)); |
||
482 | Assert.That(sceneB.GetChildAgentCount(), Is.EqualTo(0)); |
||
483 | |||
484 | // TODO: Add assertions to check correct circuit details in both scenes. |
||
485 | |||
486 | // Lookat is sent to the client only - sp.Lookat does not yield the same thing (calculation from camera |
||
487 | // position instead). |
||
488 | // Assert.That(sp.Lookat, Is.EqualTo(teleportLookAt)); |
||
489 | |||
490 | // TestHelpers.DisableLogging(); |
||
491 | } |
||
492 | |||
493 | [Test] |
||
494 | public void TestSameSimulatorNeighbouringRegionsV1() |
||
495 | { |
||
496 | TestHelpers.InMethod(); |
||
497 | // TestHelpers.EnableLogging(); |
||
498 | |||
499 | UUID userId = TestHelpers.ParseTail(0x1); |
||
500 | |||
501 | EntityTransferModule etmA = new EntityTransferModule(); |
||
502 | EntityTransferModule etmB = new EntityTransferModule(); |
||
503 | LocalSimulationConnectorModule lscm = new LocalSimulationConnectorModule(); |
||
504 | |||
505 | IConfigSource config = new IniConfigSource(); |
||
506 | IConfig modulesConfig = config.AddConfig("Modules"); |
||
507 | modulesConfig.Set("EntityTransferModule", etmA.Name); |
||
508 | modulesConfig.Set("SimulationServices", lscm.Name); |
||
509 | IConfig entityTransferConfig = config.AddConfig("EntityTransfer"); |
||
510 | |||
511 | // In order to run a single threaded regression test we do not want the entity transfer module waiting |
||
512 | // for a callback from the destination scene before removing its avatar data. |
||
513 | entityTransferConfig.Set("wait_for_callback", false); |
||
514 | |||
515 | SceneHelpers sh = new SceneHelpers(); |
||
516 | TestScene sceneA = sh.SetupScene("sceneA", TestHelpers.ParseTail(0x100), 1000, 1000); |
||
517 | TestScene sceneB = sh.SetupScene("sceneB", TestHelpers.ParseTail(0x200), 1001, 1000); |
||
518 | |||
519 | SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, config, lscm); |
||
520 | SceneHelpers.SetupSceneModules(sceneA, config, new CapabilitiesModule(), etmA); |
||
521 | SceneHelpers.SetupSceneModules(sceneB, config, new CapabilitiesModule(), etmB); |
||
522 | |||
523 | // FIXME: Hack - this is here temporarily to revert back to older entity transfer behaviour |
||
524 | lscm.ServiceVersion = "SIMULATION/0.1"; |
||
525 | |||
526 | Vector3 teleportPosition = new Vector3(10, 11, 12); |
||
527 | Vector3 teleportLookAt = new Vector3(20, 21, 22); |
||
528 | |||
529 | AgentCircuitData acd = SceneHelpers.GenerateAgentData(userId); |
||
530 | TestClient tc = new TestClient(acd, sceneA); |
||
531 | List<TestClient> destinationTestClients = new List<TestClient>(); |
||
532 | EntityTransferHelpers.SetupInformClientOfNeighbourTriggersNeighbourClientCreate(tc, destinationTestClients); |
||
533 | |||
534 | ScenePresence beforeSceneASp = SceneHelpers.AddScenePresence(sceneA, tc, acd); |
||
535 | beforeSceneASp.AbsolutePosition = new Vector3(30, 31, 32); |
||
536 | |||
537 | Assert.That(beforeSceneASp, Is.Not.Null); |
||
538 | Assert.That(beforeSceneASp.IsChildAgent, Is.False); |
||
539 | |||
540 | ScenePresence beforeSceneBSp = sceneB.GetScenePresence(userId); |
||
541 | Assert.That(beforeSceneBSp, Is.Not.Null); |
||
542 | Assert.That(beforeSceneBSp.IsChildAgent, Is.True); |
||
543 | |||
544 | // In this case, we will not receieve a second InformClientOfNeighbour since the viewer already knows |
||
545 | // about the neighbour region it is teleporting to. |
||
546 | sceneA.RequestTeleportLocation( |
||
547 | beforeSceneASp.ControllingClient, |
||
548 | sceneB.RegionInfo.RegionHandle, |
||
549 | teleportPosition, |
||
550 | teleportLookAt, |
||
551 | (uint)TeleportFlags.ViaLocation); |
||
552 | |||
553 | destinationTestClients[0].CompleteMovement(); |
||
554 | |||
555 | ScenePresence afterSceneASp = sceneA.GetScenePresence(userId); |
||
556 | Assert.That(afterSceneASp, Is.Not.Null); |
||
557 | Assert.That(afterSceneASp.IsChildAgent, Is.True); |
||
558 | |||
559 | ScenePresence afterSceneBSp = sceneB.GetScenePresence(userId); |
||
560 | Assert.That(afterSceneBSp, Is.Not.Null); |
||
561 | Assert.That(afterSceneBSp.IsChildAgent, Is.False); |
||
562 | Assert.That(afterSceneBSp.Scene.RegionInfo.RegionName, Is.EqualTo(sceneB.RegionInfo.RegionName)); |
||
563 | Assert.That(afterSceneBSp.AbsolutePosition, Is.EqualTo(teleportPosition)); |
||
564 | |||
565 | Assert.That(sceneA.GetRootAgentCount(), Is.EqualTo(0)); |
||
566 | Assert.That(sceneA.GetChildAgentCount(), Is.EqualTo(1)); |
||
567 | Assert.That(sceneB.GetRootAgentCount(), Is.EqualTo(1)); |
||
568 | Assert.That(sceneB.GetChildAgentCount(), Is.EqualTo(0)); |
||
569 | |||
570 | // TODO: Add assertions to check correct circuit details in both scenes. |
||
571 | |||
572 | // Lookat is sent to the client only - sp.Lookat does not yield the same thing (calculation from camera |
||
573 | // position instead). |
||
574 | // Assert.That(sp.Lookat, Is.EqualTo(teleportLookAt)); |
||
575 | |||
576 | // TestHelpers.DisableLogging(); |
||
577 | } |
||
578 | |||
579 | [Test] |
||
580 | public void TestSameSimulatorNeighbouringRegionsV2() |
||
581 | { |
||
582 | TestHelpers.InMethod(); |
||
583 | // TestHelpers.EnableLogging(); |
||
584 | |||
585 | UUID userId = TestHelpers.ParseTail(0x1); |
||
586 | |||
587 | EntityTransferModule etmA = new EntityTransferModule(); |
||
588 | EntityTransferModule etmB = new EntityTransferModule(); |
||
589 | LocalSimulationConnectorModule lscm = new LocalSimulationConnectorModule(); |
||
590 | |||
591 | IConfigSource config = new IniConfigSource(); |
||
592 | IConfig modulesConfig = config.AddConfig("Modules"); |
||
593 | modulesConfig.Set("EntityTransferModule", etmA.Name); |
||
594 | modulesConfig.Set("SimulationServices", lscm.Name); |
||
595 | |||
596 | SceneHelpers sh = new SceneHelpers(); |
||
597 | TestScene sceneA = sh.SetupScene("sceneA", TestHelpers.ParseTail(0x100), 1000, 1000); |
||
598 | TestScene sceneB = sh.SetupScene("sceneB", TestHelpers.ParseTail(0x200), 1001, 1000); |
||
599 | |||
600 | SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, config, lscm); |
||
601 | SceneHelpers.SetupSceneModules(sceneA, config, new CapabilitiesModule(), etmA); |
||
602 | SceneHelpers.SetupSceneModules(sceneB, config, new CapabilitiesModule(), etmB); |
||
603 | |||
604 | Vector3 teleportPosition = new Vector3(10, 11, 12); |
||
605 | Vector3 teleportLookAt = new Vector3(20, 21, 22); |
||
606 | |||
607 | AgentCircuitData acd = SceneHelpers.GenerateAgentData(userId); |
||
608 | TestClient tc = new TestClient(acd, sceneA); |
||
609 | List<TestClient> destinationTestClients = new List<TestClient>(); |
||
610 | EntityTransferHelpers.SetupInformClientOfNeighbourTriggersNeighbourClientCreate(tc, destinationTestClients); |
||
611 | |||
612 | ScenePresence beforeSceneASp = SceneHelpers.AddScenePresence(sceneA, tc, acd); |
||
613 | beforeSceneASp.AbsolutePosition = new Vector3(30, 31, 32); |
||
614 | |||
615 | Assert.That(beforeSceneASp, Is.Not.Null); |
||
616 | Assert.That(beforeSceneASp.IsChildAgent, Is.False); |
||
617 | |||
618 | ScenePresence beforeSceneBSp = sceneB.GetScenePresence(userId); |
||
619 | Assert.That(beforeSceneBSp, Is.Not.Null); |
||
620 | Assert.That(beforeSceneBSp.IsChildAgent, Is.True); |
||
621 | |||
622 | // Here, we need to make clientA's receipt of SendRegionTeleport trigger clientB's CompleteMovement(). This |
||
623 | // is to operate the teleport V2 mechanism where the EntityTransferModule will first request the client to |
||
624 | // CompleteMovement to the region and then call UpdateAgent to the destination region to confirm the receipt |
||
625 | // Both these operations will occur on different threads and will wait for each other. |
||
626 | // We have to do this via ThreadPool directly since FireAndForget has been switched to sync for the V1 |
||
627 | // test protocol, where we are trying to avoid unpredictable async operations in regression tests. |
||
628 | tc.OnTestClientSendRegionTeleport |
||
629 | += (regionHandle, simAccess, regionExternalEndPoint, locationID, flags, capsURL) |
||
630 | => ThreadPool.UnsafeQueueUserWorkItem(o => destinationTestClients[0].CompleteMovement(), null); |
||
631 | |||
632 | sceneA.RequestTeleportLocation( |
||
633 | beforeSceneASp.ControllingClient, |
||
634 | sceneB.RegionInfo.RegionHandle, |
||
635 | teleportPosition, |
||
636 | teleportLookAt, |
||
637 | (uint)TeleportFlags.ViaLocation); |
||
638 | |||
639 | ScenePresence afterSceneASp = sceneA.GetScenePresence(userId); |
||
640 | Assert.That(afterSceneASp, Is.Not.Null); |
||
641 | Assert.That(afterSceneASp.IsChildAgent, Is.True); |
||
642 | |||
643 | ScenePresence afterSceneBSp = sceneB.GetScenePresence(userId); |
||
644 | Assert.That(afterSceneBSp, Is.Not.Null); |
||
645 | Assert.That(afterSceneBSp.IsChildAgent, Is.False); |
||
646 | Assert.That(afterSceneBSp.Scene.RegionInfo.RegionName, Is.EqualTo(sceneB.RegionInfo.RegionName)); |
||
647 | Assert.That(afterSceneBSp.AbsolutePosition, Is.EqualTo(teleportPosition)); |
||
648 | |||
649 | Assert.That(sceneA.GetRootAgentCount(), Is.EqualTo(0)); |
||
650 | Assert.That(sceneA.GetChildAgentCount(), Is.EqualTo(1)); |
||
651 | Assert.That(sceneB.GetRootAgentCount(), Is.EqualTo(1)); |
||
652 | Assert.That(sceneB.GetChildAgentCount(), Is.EqualTo(0)); |
||
653 | |||
654 | // TODO: Add assertions to check correct circuit details in both scenes. |
||
655 | |||
656 | // Lookat is sent to the client only - sp.Lookat does not yield the same thing (calculation from camera |
||
657 | // position instead). |
||
658 | // Assert.That(sp.Lookat, Is.EqualTo(teleportLookAt)); |
||
659 | |||
660 | // TestHelpers.DisableLogging(); |
||
661 | } |
||
662 | } |
||
663 | } |