OpenSim
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros
ScenePresenceTeleportTests.cs
Go to the documentation of this file.
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.Servers;
39 using OpenSim.Region.Framework.Interfaces;
40 using OpenSim.Region.CoreModules.Framework;
41 using OpenSim.Region.CoreModules.Framework.EntityTransfer;
42 using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation;
43 using OpenSim.Region.CoreModules.World.Permissions;
44 using OpenSim.Tests.Common;
45 
46 namespace OpenSim.Region.Framework.Scenes.Tests
47 {
51  [TestFixture]
53  {
54  [TestFixtureSetUp]
55  public void FixtureInit()
56  {
57  // Don't allow tests to be bamboozled by asynchronous events. Execute everything on the same thread.
58  Util.FireAndForgetMethod = FireAndForgetMethod.RegressionTest;
59  }
60 
61  [TestFixtureTearDown]
62  public void TearDown()
63  {
64  // We must set this back afterwards, otherwise later tests will fail since they're expecting multiple
65  // threads. Possibly, later tests should be rewritten so none of them require async stuff (which regression
66  // tests really shouldn't).
67  Util.FireAndForgetMethod = Util.DefaultFireAndForgetMethod;
68  }
69 
70  [Test]
71  public void TestSameRegion()
72  {
73  TestHelpers.InMethod();
74 // log4net.Config.XmlConfigurator.Configure();
75 
77 
78  IConfigSource config = new IniConfigSource();
79  config.AddConfig("Modules");
80  // Not strictly necessary since FriendsModule assumes it is the default (!)
81  config.Configs["Modules"].Set("EntityTransferModule", etm.Name);
82 
83  TestScene scene = new SceneHelpers().SetupScene("sceneA", TestHelpers.ParseTail(0x100), 1000, 1000);
84  SceneHelpers.SetupSceneModules(scene, config, etm);
85 
86  Vector3 teleportPosition = new Vector3(10, 11, 12);
87  Vector3 teleportLookAt = new Vector3(20, 21, 22);
88 
89  ScenePresence sp = SceneHelpers.AddScenePresence(scene, TestHelpers.ParseTail(0x1));
90  sp.AbsolutePosition = new Vector3(30, 31, 32);
91  scene.RequestTeleportLocation(
92  sp.ControllingClient,
93  scene.RegionInfo.RegionHandle,
94  teleportPosition,
95  teleportLookAt,
96  (uint)TeleportFlags.ViaLocation);
97 
98  Assert.That(sp.AbsolutePosition, Is.EqualTo(teleportPosition));
99 
100  Assert.That(scene.GetRootAgentCount(), Is.EqualTo(1));
101  Assert.That(scene.GetChildAgentCount(), Is.EqualTo(0));
102 
103  // Lookat is sent to the client only - sp.Lookat does not yield the same thing (calculation from camera
104  // position instead).
105 // Assert.That(sp.Lookat, Is.EqualTo(teleportLookAt));
106  }
107 
108 /*
109  [Test]
110  public void TestSameSimulatorIsolatedRegionsV1()
111  {
112  TestHelpers.InMethod();
113 // TestHelpers.EnableLogging();
114 
115  UUID userId = TestHelpers.ParseTail(0x1);
116 
117  EntityTransferModule etmA = new EntityTransferModule();
118  EntityTransferModule etmB = new EntityTransferModule();
119  LocalSimulationConnectorModule lscm = new LocalSimulationConnectorModule();
120 
121  IConfigSource config = new IniConfigSource();
122  IConfig modulesConfig = config.AddConfig("Modules");
123  modulesConfig.Set("EntityTransferModule", etmA.Name);
124  modulesConfig.Set("SimulationServices", lscm.Name);
125  IConfig entityTransferConfig = config.AddConfig("EntityTransfer");
126 
127  // In order to run a single threaded regression test we do not want the entity transfer module waiting
128  // for a callback from the destination scene before removing its avatar data.
129  entityTransferConfig.Set("wait_for_callback", false);
130 
131  SceneHelpers sh = new SceneHelpers();
132  TestScene sceneA = sh.SetupScene("sceneA", TestHelpers.ParseTail(0x100), 1000, 1000);
133  TestScene sceneB = sh.SetupScene("sceneB", TestHelpers.ParseTail(0x200), 1002, 1000);
134 
135  SceneHelpers.SetupSceneModules(sceneA, config, etmA);
136  SceneHelpers.SetupSceneModules(sceneB, config, etmB);
137  SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, config, lscm);
138 
139  // FIXME: Hack - this is here temporarily to revert back to older entity transfer behaviour
140  lscm.ServiceVersion = 0.1f;
141 
142  Vector3 teleportPosition = new Vector3(10, 11, 12);
143  Vector3 teleportLookAt = new Vector3(20, 21, 22);
144 
145  ScenePresence sp = SceneHelpers.AddScenePresence(sceneA, userId);
146  sp.AbsolutePosition = new Vector3(30, 31, 32);
147 
148  List<TestClient> destinationTestClients = new List<TestClient>();
149  EntityTransferHelpers.SetupInformClientOfNeighbourTriggersNeighbourClientCreate(
150  (TestClient)sp.ControllingClient, destinationTestClients);
151 
152  sceneA.RequestTeleportLocation(
153  sp.ControllingClient,
154  sceneB.RegionInfo.RegionHandle,
155  teleportPosition,
156  teleportLookAt,
157  (uint)TeleportFlags.ViaLocation);
158 
159  // SetupInformClientOfNeighbour() will have handled the callback into the target scene to setup the child
160  // agent. This call will now complete the movement of the user into the destination and upgrade the agent
161  // from child to root.
162  destinationTestClients[0].CompleteMovement();
163 
164  Assert.That(sceneA.GetScenePresence(userId), Is.Null);
165 
166  ScenePresence sceneBSp = sceneB.GetScenePresence(userId);
167  Assert.That(sceneBSp, Is.Not.Null);
168  Assert.That(sceneBSp.Scene.RegionInfo.RegionName, Is.EqualTo(sceneB.RegionInfo.RegionName));
169  Assert.That(sceneBSp.AbsolutePosition, Is.EqualTo(teleportPosition));
170 
171  Assert.That(sceneA.GetRootAgentCount(), Is.EqualTo(0));
172  Assert.That(sceneA.GetChildAgentCount(), Is.EqualTo(0));
173  Assert.That(sceneB.GetRootAgentCount(), Is.EqualTo(1));
174  Assert.That(sceneB.GetChildAgentCount(), Is.EqualTo(0));
175 
176  // TODO: Add assertions to check correct circuit details in both scenes.
177 
178  // Lookat is sent to the client only - sp.Lookat does not yield the same thing (calculation from camera
179  // position instead).
180 // Assert.That(sp.Lookat, Is.EqualTo(teleportLookAt));
181  }
182 */
183 
184  [Test]
186  {
187  TestHelpers.InMethod();
188 // TestHelpers.EnableLogging();
189 
190  UUID userId = TestHelpers.ParseTail(0x1);
191 
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 
248  [Test]
250  {
251  TestHelpers.InMethod();
252 // TestHelpers.EnableLogging();
253 
254  UUID userId = TestHelpers.ParseTail(0x1);
255  Vector3 preTeleportPosition = new Vector3(30, 31, 32);
256 
259 
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 DefaultPermissionsModule(), 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 
332  [Test]
334  {
335  TestHelpers.InMethod();
336 // TestHelpers.EnableLogging();
337 
338  UUID userId = TestHelpers.ParseTail(0x1);
339  Vector3 preTeleportPosition = new Vector3(30, 31, 32);
340 
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 
413  [Test]
415  {
416  TestHelpers.InMethod();
417 // TestHelpers.EnableLogging();
418 
419  UUID userId = TestHelpers.ParseTail(0x1);
420  Vector3 preTeleportPosition = new Vector3(30, 31, 32);
421 
424 
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 DefaultPermissionsModule(), 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 /*
494  [Test]
495  public void TestSameSimulatorNeighbouringRegionsV1()
496  {
497  TestHelpers.InMethod();
498 // TestHelpers.EnableLogging();
499 
500  UUID userId = TestHelpers.ParseTail(0x1);
501 
502  EntityTransferModule etmA = new EntityTransferModule();
503  EntityTransferModule etmB = new EntityTransferModule();
504  LocalSimulationConnectorModule lscm = new LocalSimulationConnectorModule();
505 
506  IConfigSource config = new IniConfigSource();
507  IConfig modulesConfig = config.AddConfig("Modules");
508  modulesConfig.Set("EntityTransferModule", etmA.Name);
509  modulesConfig.Set("SimulationServices", lscm.Name);
510  IConfig entityTransferConfig = config.AddConfig("EntityTransfer");
511 
512  // In order to run a single threaded regression test we do not want the entity transfer module waiting
513  // for a callback from the destination scene before removing its avatar data.
514  entityTransferConfig.Set("wait_for_callback", false);
515 
516  SceneHelpers sh = new SceneHelpers();
517  TestScene sceneA = sh.SetupScene("sceneA", TestHelpers.ParseTail(0x100), 1000, 1000);
518  TestScene sceneB = sh.SetupScene("sceneB", TestHelpers.ParseTail(0x200), 1001, 1000);
519 
520  SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, config, lscm);
521  SceneHelpers.SetupSceneModules(sceneA, config, new CapabilitiesModule(), etmA);
522  SceneHelpers.SetupSceneModules(sceneB, config, new CapabilitiesModule(), etmB);
523 
524  // FIXME: Hack - this is here temporarily to revert back to older entity transfer behaviour
525  lscm.ServiceVersion = 0.1f;
526 
527  Vector3 teleportPosition = new Vector3(10, 11, 12);
528  Vector3 teleportLookAt = new Vector3(20, 21, 22);
529 
530  AgentCircuitData acd = SceneHelpers.GenerateAgentData(userId);
531  TestClient tc = new TestClient(acd, sceneA);
532  List<TestClient> destinationTestClients = new List<TestClient>();
533  EntityTransferHelpers.SetupInformClientOfNeighbourTriggersNeighbourClientCreate(tc, destinationTestClients);
534 
535  ScenePresence beforeSceneASp = SceneHelpers.AddScenePresence(sceneA, tc, acd);
536  beforeSceneASp.AbsolutePosition = new Vector3(30, 31, 32);
537 
538  Assert.That(beforeSceneASp, Is.Not.Null);
539  Assert.That(beforeSceneASp.IsChildAgent, Is.False);
540 
541  ScenePresence beforeSceneBSp = sceneB.GetScenePresence(userId);
542  Assert.That(beforeSceneBSp, Is.Not.Null);
543  Assert.That(beforeSceneBSp.IsChildAgent, Is.True);
544 
545  // In this case, we will not receieve a second InformClientOfNeighbour since the viewer already knows
546  // about the neighbour region it is teleporting to.
547  sceneA.RequestTeleportLocation(
548  beforeSceneASp.ControllingClient,
549  sceneB.RegionInfo.RegionHandle,
550  teleportPosition,
551  teleportLookAt,
552  (uint)TeleportFlags.ViaLocation);
553 
554  destinationTestClients[0].CompleteMovement();
555 
556  ScenePresence afterSceneASp = sceneA.GetScenePresence(userId);
557  Assert.That(afterSceneASp, Is.Not.Null);
558  Assert.That(afterSceneASp.IsChildAgent, Is.True);
559 
560  ScenePresence afterSceneBSp = sceneB.GetScenePresence(userId);
561  Assert.That(afterSceneBSp, Is.Not.Null);
562  Assert.That(afterSceneBSp.IsChildAgent, Is.False);
563  Assert.That(afterSceneBSp.Scene.RegionInfo.RegionName, Is.EqualTo(sceneB.RegionInfo.RegionName));
564  Assert.That(afterSceneBSp.AbsolutePosition, Is.EqualTo(teleportPosition));
565 
566  Assert.That(sceneA.GetRootAgentCount(), Is.EqualTo(0));
567  Assert.That(sceneA.GetChildAgentCount(), Is.EqualTo(1));
568  Assert.That(sceneB.GetRootAgentCount(), Is.EqualTo(1));
569  Assert.That(sceneB.GetChildAgentCount(), Is.EqualTo(0));
570 
571  // TODO: Add assertions to check correct circuit details in both scenes.
572 
573  // Lookat is sent to the client only - sp.Lookat does not yield the same thing (calculation from camera
574  // position instead).
575 // Assert.That(sp.Lookat, Is.EqualTo(teleportLookAt));
576 
577 // TestHelpers.DisableLogging();
578  }
579 */
580 
581  [Test]
583  {
584  TestHelpers.InMethod();
585 // TestHelpers.EnableLogging();
586 
587  UUID userId = TestHelpers.ParseTail(0x1);
588 
592 
593  IConfigSource config = new IniConfigSource();
594  IConfig modulesConfig = config.AddConfig("Modules");
595  modulesConfig.Set("EntityTransferModule", etmA.Name);
596  modulesConfig.Set("SimulationServices", lscm.Name);
597 
598  SceneHelpers sh = new SceneHelpers();
599  TestScene sceneA = sh.SetupScene("sceneA", TestHelpers.ParseTail(0x100), 1000, 1000);
600  TestScene sceneB = sh.SetupScene("sceneB", TestHelpers.ParseTail(0x200), 1001, 1000);
601 
602  SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, config, lscm);
603  SceneHelpers.SetupSceneModules(sceneA, config, new CapabilitiesModule(), etmA);
604  SceneHelpers.SetupSceneModules(sceneB, config, new CapabilitiesModule(), etmB);
605 
606  Vector3 teleportPosition = new Vector3(10, 11, 12);
607  Vector3 teleportLookAt = new Vector3(20, 21, 22);
608 
609  AgentCircuitData acd = SceneHelpers.GenerateAgentData(userId);
610  TestClient tc = new TestClient(acd, sceneA);
611  List<TestClient> destinationTestClients = new List<TestClient>();
612  EntityTransferHelpers.SetupInformClientOfNeighbourTriggersNeighbourClientCreate(tc, destinationTestClients);
613 
614  ScenePresence beforeSceneASp = SceneHelpers.AddScenePresence(sceneA, tc, acd);
615  beforeSceneASp.AbsolutePosition = new Vector3(30, 31, 32);
616 
617  Assert.That(beforeSceneASp, Is.Not.Null);
618  Assert.That(beforeSceneASp.IsChildAgent, Is.False);
619 
620  ScenePresence beforeSceneBSp = sceneB.GetScenePresence(userId);
621  Assert.That(beforeSceneBSp, Is.Not.Null);
622  Assert.That(beforeSceneBSp.IsChildAgent, Is.True);
623 
624  // Here, we need to make clientA's receipt of SendRegionTeleport trigger clientB's CompleteMovement(). This
625  // is to operate the teleport V2 mechanism where the EntityTransferModule will first request the client to
626  // CompleteMovement to the region and then call UpdateAgent to the destination region to confirm the receipt
627  // Both these operations will occur on different threads and will wait for each other.
628  // We have to do this via ThreadPool directly since FireAndForget has been switched to sync for the V1
629  // test protocol, where we are trying to avoid unpredictable async operations in regression tests.
630  tc.OnTestClientSendRegionTeleport
631  += (regionHandle, simAccess, regionExternalEndPoint, locationID, flags, capsURL)
632  => ThreadPool.UnsafeQueueUserWorkItem(o => destinationTestClients[0].CompleteMovement(), null);
633 
634  sceneA.RequestTeleportLocation(
635  beforeSceneASp.ControllingClient,
636  sceneB.RegionInfo.RegionHandle,
637  teleportPosition,
638  teleportLookAt,
639  (uint)TeleportFlags.ViaLocation);
640 
641  ScenePresence afterSceneASp = sceneA.GetScenePresence(userId);
642  Assert.That(afterSceneASp, Is.Not.Null);
643  Assert.That(afterSceneASp.IsChildAgent, Is.True);
644 
645  ScenePresence afterSceneBSp = sceneB.GetScenePresence(userId);
646  Assert.That(afterSceneBSp, Is.Not.Null);
647  Assert.That(afterSceneBSp.IsChildAgent, Is.False);
648  Assert.That(afterSceneBSp.Scene.RegionInfo.RegionName, Is.EqualTo(sceneB.RegionInfo.RegionName));
649  Assert.That(afterSceneBSp.AbsolutePosition, Is.EqualTo(teleportPosition));
650 
651  Assert.That(sceneA.GetRootAgentCount(), Is.EqualTo(0));
652  Assert.That(sceneA.GetChildAgentCount(), Is.EqualTo(1));
653  Assert.That(sceneB.GetRootAgentCount(), Is.EqualTo(1));
654  Assert.That(sceneB.GetChildAgentCount(), Is.EqualTo(0));
655 
656  // TODO: Add assertions to check correct circuit details in both scenes.
657 
658  // Lookat is sent to the client only - sp.Lookat does not yield the same thing (calculation from camera
659  // position instead).
660 // Assert.That(sp.Lookat, Is.EqualTo(teleportLookAt));
661 
662 // TestHelpers.DisableLogging();
663  }
664  }
665 }
OpenSim.Framework.Constants.TeleportFlags TeleportFlags
void TestSameSimulatorIsolatedRegions_DestinationDidNotProcessViewerConnection()
Test teleport when the destination region does not process (or does not receive) the connection attem...
void TestSameSimulatorIsolatedRegions_DeniedOnQueryAccess()
Test teleport procedures when the target simulator returns false when queried about access...
Circuit data for an agent. Connection information shared between regions that accept UDP connections ...
void TestSameSimulatorIsolatedRegions_DeniedOnCreateAgent()
Test teleport procedures when the target simulator create agent step is refused.
Helpers for setting up scenes.
Definition: SceneHelpers.cs:60