diff options
author | Justin Clark-Casey (justincc) | 2013-08-16 23:52:55 +0100 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2013-08-16 23:52:55 +0100 |
commit | fbab898f74186b38cf2dad9aa42f7f9b17a34fe9 (patch) | |
tree | 8c2dffe0c05764f478fc0eaa9ed1686ae2c33a29 /OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs | |
parent | refactor: Make AttachmentModulesTests.TestSameSimulatorNeighbouringRegionsTel... (diff) | |
download | opensim-SC_OLD-fbab898f74186b38cf2dad9aa42f7f9b17a34fe9.zip opensim-SC_OLD-fbab898f74186b38cf2dad9aa42f7f9b17a34fe9.tar.gz opensim-SC_OLD-fbab898f74186b38cf2dad9aa42f7f9b17a34fe9.tar.bz2 opensim-SC_OLD-fbab898f74186b38cf2dad9aa42f7f9b17a34fe9.tar.xz |
Add TestSameSimulatorNeighbouringRegionsV2() regression test for v2 entity transfer protocl
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs | 89 |
1 files changed, 87 insertions, 2 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs index afd2779..936c2c0 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs | |||
@@ -30,6 +30,7 @@ using System.Collections.Generic; | |||
30 | using System.IO; | 30 | using System.IO; |
31 | using System.Net; | 31 | using System.Net; |
32 | using System.Text; | 32 | using System.Text; |
33 | using System.Threading; | ||
33 | using Nini.Config; | 34 | using Nini.Config; |
34 | using NUnit.Framework; | 35 | using NUnit.Framework; |
35 | using OpenMetaverse; | 36 | using OpenMetaverse; |
@@ -107,7 +108,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
107 | } | 108 | } |
108 | 109 | ||
109 | [Test] | 110 | [Test] |
110 | public void TestSameSimulatorIsolatedRegions() | 111 | public void TestSameSimulatorIsolatedRegionsV1() |
111 | { | 112 | { |
112 | TestHelpers.InMethod(); | 113 | TestHelpers.InMethod(); |
113 | // TestHelpers.EnableLogging(); | 114 | // TestHelpers.EnableLogging(); |
@@ -428,7 +429,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
428 | } | 429 | } |
429 | 430 | ||
430 | [Test] | 431 | [Test] |
431 | public void TestSameSimulatorNeighbouringRegions() | 432 | public void TestSameSimulatorNeighbouringRegionsV1() |
432 | { | 433 | { |
433 | TestHelpers.InMethod(); | 434 | TestHelpers.InMethod(); |
434 | // TestHelpers.EnableLogging(); | 435 | // TestHelpers.EnableLogging(); |
@@ -512,5 +513,89 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
512 | 513 | ||
513 | // TestHelpers.DisableLogging(); | 514 | // TestHelpers.DisableLogging(); |
514 | } | 515 | } |
516 | |||
517 | [Test] | ||
518 | public void TestSameSimulatorNeighbouringRegionsV2() | ||
519 | { | ||
520 | TestHelpers.InMethod(); | ||
521 | // TestHelpers.EnableLogging(); | ||
522 | |||
523 | UUID userId = TestHelpers.ParseTail(0x1); | ||
524 | |||
525 | EntityTransferModule etmA = new EntityTransferModule(); | ||
526 | EntityTransferModule etmB = new EntityTransferModule(); | ||
527 | LocalSimulationConnectorModule lscm = new LocalSimulationConnectorModule(); | ||
528 | |||
529 | IConfigSource config = new IniConfigSource(); | ||
530 | IConfig modulesConfig = config.AddConfig("Modules"); | ||
531 | modulesConfig.Set("EntityTransferModule", etmA.Name); | ||
532 | modulesConfig.Set("SimulationServices", lscm.Name); | ||
533 | |||
534 | SceneHelpers sh = new SceneHelpers(); | ||
535 | TestScene sceneA = sh.SetupScene("sceneA", TestHelpers.ParseTail(0x100), 1000, 1000); | ||
536 | TestScene sceneB = sh.SetupScene("sceneB", TestHelpers.ParseTail(0x200), 1001, 1000); | ||
537 | |||
538 | SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, config, lscm); | ||
539 | SceneHelpers.SetupSceneModules(sceneA, config, new CapabilitiesModule(), etmA); | ||
540 | SceneHelpers.SetupSceneModules(sceneB, config, new CapabilitiesModule(), etmB); | ||
541 | |||
542 | Vector3 teleportPosition = new Vector3(10, 11, 12); | ||
543 | Vector3 teleportLookAt = new Vector3(20, 21, 22); | ||
544 | |||
545 | AgentCircuitData acd = SceneHelpers.GenerateAgentData(userId); | ||
546 | TestClient tc = new TestClient(acd, sceneA); | ||
547 | List<TestClient> destinationTestClients = new List<TestClient>(); | ||
548 | EntityTransferHelpers.SetUpInformClientOfNeighbour(tc, destinationTestClients); | ||
549 | |||
550 | ScenePresence beforeSceneASp = SceneHelpers.AddScenePresence(sceneA, tc, acd); | ||
551 | beforeSceneASp.AbsolutePosition = new Vector3(30, 31, 32); | ||
552 | |||
553 | Assert.That(beforeSceneASp, Is.Not.Null); | ||
554 | Assert.That(beforeSceneASp.IsChildAgent, Is.False); | ||
555 | |||
556 | ScenePresence beforeSceneBSp = sceneB.GetScenePresence(userId); | ||
557 | Assert.That(beforeSceneBSp, Is.Not.Null); | ||
558 | Assert.That(beforeSceneBSp.IsChildAgent, Is.True); | ||
559 | |||
560 | // Here, we need to make clientA's receipt of SendRegionTeleport trigger clientB's CompleteMovement(). This | ||
561 | // is to operate the teleport V2 mechanism where the EntityTransferModule will first request the client to | ||
562 | // CompleteMovement to the region and then call UpdateAgent to the destination region to confirm the receipt | ||
563 | // Both these operations will occur on different threads and will wait for each other. | ||
564 | // We have to do this via ThreadPool directly since FireAndForget has been switched to sync for the V1 | ||
565 | // test protocol, where we are trying to avoid unpredictable async operations in regression tests. | ||
566 | tc.OnTestClientSendRegionTeleport | ||
567 | += (regionHandle, simAccess, regionExternalEndPoint, locationID, flags, capsURL) | ||
568 | => ThreadPool.UnsafeQueueUserWorkItem(o => destinationTestClients[0].CompleteMovement(), null); | ||
569 | |||
570 | sceneA.RequestTeleportLocation( | ||
571 | beforeSceneASp.ControllingClient, | ||
572 | sceneB.RegionInfo.RegionHandle, | ||
573 | teleportPosition, | ||
574 | teleportLookAt, | ||
575 | (uint)TeleportFlags.ViaLocation); | ||
576 | |||
577 | ScenePresence afterSceneASp = sceneA.GetScenePresence(userId); | ||
578 | Assert.That(afterSceneASp, Is.Not.Null); | ||
579 | Assert.That(afterSceneASp.IsChildAgent, Is.True); | ||
580 | |||
581 | ScenePresence afterSceneBSp = sceneB.GetScenePresence(userId); | ||
582 | Assert.That(afterSceneBSp, Is.Not.Null); | ||
583 | Assert.That(afterSceneBSp.IsChildAgent, Is.False); | ||
584 | Assert.That(afterSceneBSp.Scene.RegionInfo.RegionName, Is.EqualTo(sceneB.RegionInfo.RegionName)); | ||
585 | Assert.That(afterSceneBSp.AbsolutePosition, Is.EqualTo(teleportPosition)); | ||
586 | |||
587 | Assert.That(sceneA.GetRootAgentCount(), Is.EqualTo(0)); | ||
588 | Assert.That(sceneA.GetChildAgentCount(), Is.EqualTo(1)); | ||
589 | Assert.That(sceneB.GetRootAgentCount(), Is.EqualTo(1)); | ||
590 | Assert.That(sceneB.GetChildAgentCount(), Is.EqualTo(0)); | ||
591 | |||
592 | // TODO: Add assertions to check correct circuit details in both scenes. | ||
593 | |||
594 | // Lookat is sent to the client only - sp.Lookat does not yield the same thing (calculation from camera | ||
595 | // position instead). | ||
596 | // Assert.That(sp.Lookat, Is.EqualTo(teleportLookAt)); | ||
597 | |||
598 | // TestHelpers.DisableLogging(); | ||
599 | } | ||
515 | } | 600 | } |
516 | } \ No newline at end of file | 601 | } \ No newline at end of file |