diff options
author | Justin Clark-Casey (justincc) | 2013-03-20 23:01:16 +0000 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2013-03-20 23:01:16 +0000 |
commit | 36651bed71ce1011c376078943a4fef7e8a9ada6 (patch) | |
tree | 61ca34a4595fa0d43990e29fa60e2f7962ca5189 | |
parent | Insert a short delay on the simulator side rezzing of attachments in order to... (diff) | |
download | opensim-SC_OLD-36651bed71ce1011c376078943a4fef7e8a9ada6.zip opensim-SC_OLD-36651bed71ce1011c376078943a4fef7e8a9ada6.tar.gz opensim-SC_OLD-36651bed71ce1011c376078943a4fef7e8a9ada6.tar.bz2 opensim-SC_OLD-36651bed71ce1011c376078943a4fef7e8a9ada6.tar.xz |
On the later forms of teleport failure, tell the user if this was because viewer couldn't/didn't connect with destination or if destination didn't signal teleport completion.
Also adds regression test for the case where the viewer couldn't connect with the destination region.
Also refactoring of regression test support code associated with entity transfer in order to make this test possible and the code less obscure.
6 files changed, 185 insertions, 71 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs index 4cd03da..c8c594d 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs | |||
@@ -829,7 +829,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests | |||
829 | sceneB, config, new CapabilitiesModule(), etmB, attModB, new BasicInventoryAccessModule()); | 829 | sceneB, config, new CapabilitiesModule(), etmB, attModB, new BasicInventoryAccessModule()); |
830 | 830 | ||
831 | UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(sceneA, 0x1); | 831 | UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(sceneA, 0x1); |
832 | ScenePresence beforeTeleportSp = SceneHelpers.AddScenePresence(sceneA, ua1.PrincipalID, sh.SceneManager); | 832 | |
833 | AgentCircuitData acd = SceneHelpers.GenerateAgentData(ua1.PrincipalID); | ||
834 | TestClient tc = new TestClient(acd, sceneA, sh.SceneManager); | ||
835 | List<TestClient> destinationTestClients = new List<TestClient>(); | ||
836 | EntityTransferHelpers.SetUpInformClientOfNeighbour(tc, destinationTestClients); | ||
837 | |||
838 | ScenePresence beforeTeleportSp = SceneHelpers.AddScenePresence(sceneA, tc, acd, sh.SceneManager); | ||
833 | beforeTeleportSp.AbsolutePosition = new Vector3(30, 31, 32); | 839 | beforeTeleportSp.AbsolutePosition = new Vector3(30, 31, 32); |
834 | 840 | ||
835 | InventoryItemBase attItem = CreateAttachmentItem(sceneA, ua1.PrincipalID, "att", 0x10, 0x20); | 841 | InventoryItemBase attItem = CreateAttachmentItem(sceneA, ua1.PrincipalID, "att", 0x10, 0x20); |
@@ -848,7 +854,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests | |||
848 | teleportLookAt, | 854 | teleportLookAt, |
849 | (uint)TeleportFlags.ViaLocation); | 855 | (uint)TeleportFlags.ViaLocation); |
850 | 856 | ||
851 | ((TestClient)beforeTeleportSp.ControllingClient).CompleteTeleportClientSide(); | 857 | destinationTestClients[0].CompleteMovement(); |
852 | 858 | ||
853 | // Check attachments have made it into sceneB | 859 | // Check attachments have made it into sceneB |
854 | ScenePresence afterTeleportSceneBSp = sceneB.GetScenePresence(ua1.PrincipalID); | 860 | ScenePresence afterTeleportSceneBSp = sceneB.GetScenePresence(ua1.PrincipalID); |
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs index 9b1b69a..58a6654 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs | |||
@@ -517,12 +517,6 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
517 | "[ENTITY TRANSFER MODULE]: Failed validation of all attachments for teleport of {0} from {1} to {2}. Continuing.", | 517 | "[ENTITY TRANSFER MODULE]: Failed validation of all attachments for teleport of {0} from {1} to {2}. Continuing.", |
518 | sp.Name, sp.Scene.RegionInfo.RegionName, finalDestination.RegionName); | 518 | sp.Name, sp.Scene.RegionInfo.RegionName, finalDestination.RegionName); |
519 | 519 | ||
520 | // if (!sp.ValidateAttachments()) | ||
521 | // { | ||
522 | // sp.ControllingClient.SendTeleportFailed("Inconsistent attachment state"); | ||
523 | // return; | ||
524 | // } | ||
525 | |||
526 | string reason; | 520 | string reason; |
527 | string version; | 521 | string version; |
528 | if (!Scene.SimulationService.QueryAccess( | 522 | if (!Scene.SimulationService.QueryAccess( |
@@ -583,6 +577,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
583 | } | 577 | } |
584 | 578 | ||
585 | // Let's create an agent there if one doesn't exist yet. | 579 | // Let's create an agent there if one doesn't exist yet. |
580 | // NOTE: logout will always be false for a non-HG teleport. | ||
586 | bool logout = false; | 581 | bool logout = false; |
587 | if (!CreateAgent(sp, reg, finalDestination, agentCircuit, teleportFlags, out reason, out logout)) | 582 | if (!CreateAgent(sp, reg, finalDestination, agentCircuit, teleportFlags, out reason, out logout)) |
588 | { | 583 | { |
@@ -625,11 +620,13 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
625 | 620 | ||
626 | if (m_eqModule != null) | 621 | if (m_eqModule != null) |
627 | { | 622 | { |
623 | // The EnableSimulator message makes the client establish a connection with the destination | ||
624 | // simulator by sending the initial UseCircuitCode UDP packet to the destination containing the | ||
625 | // correct circuit code. | ||
628 | m_eqModule.EnableSimulator(destinationHandle, endPoint, sp.UUID); | 626 | m_eqModule.EnableSimulator(destinationHandle, endPoint, sp.UUID); |
629 | 627 | ||
630 | // ES makes the client send a UseCircuitCode message to the destination, | 628 | // XXX: Is this wait necessary? We will always end up waiting on UpdateAgent for the destination |
631 | // which triggers a bunch of things there. | 629 | // simulator to confirm that it has established communication with the viewer. |
632 | // So let's wait | ||
633 | Thread.Sleep(200); | 630 | Thread.Sleep(200); |
634 | 631 | ||
635 | // At least on LL 3.3.4 for teleports between different regions on the same simulator this appears | 632 | // At least on LL 3.3.4 for teleports between different regions on the same simulator this appears |
@@ -640,6 +637,9 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
640 | } | 637 | } |
641 | else | 638 | else |
642 | { | 639 | { |
640 | // XXX: This is a little misleading since we're information the client of its avatar destination, | ||
641 | // which may or may not be a neighbour region of the source region. This path is probably little | ||
642 | // used anyway (with EQ being the one used). But it is currently being used for test code. | ||
643 | sp.ControllingClient.InformClientOfNeighbour(destinationHandle, endPoint); | 643 | sp.ControllingClient.InformClientOfNeighbour(destinationHandle, endPoint); |
644 | } | 644 | } |
645 | } | 645 | } |
@@ -657,14 +657,17 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
657 | 657 | ||
658 | //sp.ControllingClient.SendTeleportProgress(teleportFlags, "Updating agent..."); | 658 | //sp.ControllingClient.SendTeleportProgress(teleportFlags, "Updating agent..."); |
659 | 659 | ||
660 | // A common teleport failure occurs when we can send CreateAgent to the | ||
661 | // destination region but the viewer cannot establish the connection (e.g. due to network issues between | ||
662 | // the viewer and the destination). In this case, UpdateAgent timesout after 10 seconds, although then | ||
663 | // there's a further 10 second wait whilst we attempt to tell the destination to delete the agent in Fail(). | ||
660 | if (!UpdateAgent(reg, finalDestination, agent, sp)) | 664 | if (!UpdateAgent(reg, finalDestination, agent, sp)) |
661 | { | 665 | { |
662 | // Region doesn't take it | ||
663 | m_log.WarnFormat( | 666 | m_log.WarnFormat( |
664 | "[ENTITY TRANSFER MODULE]: UpdateAgent failed on teleport of {0} to {1} from {2}. Returning avatar to source region.", | 667 | "[ENTITY TRANSFER MODULE]: UpdateAgent failed on teleport of {0} to {1} from {2}. Keeping avatar in source region.", |
665 | sp.Name, finalDestination.RegionName, sp.Scene.RegionInfo.RegionName); | 668 | sp.Name, finalDestination.RegionName, sp.Scene.RegionInfo.RegionName); |
666 | 669 | ||
667 | Fail(sp, finalDestination, logout); | 670 | Fail(sp, finalDestination, logout, "Connection between viewer and destination region could not be established."); |
668 | return; | 671 | return; |
669 | } | 672 | } |
670 | 673 | ||
@@ -705,7 +708,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
705 | "[ENTITY TRANSFER MODULE]: Teleport of {0} to {1} from {2} failed due to no callback from destination region. Returning avatar to source region.", | 708 | "[ENTITY TRANSFER MODULE]: Teleport of {0} to {1} from {2} failed due to no callback from destination region. Returning avatar to source region.", |
706 | sp.Name, finalDestination.RegionName, sp.Scene.RegionInfo.RegionName); | 709 | sp.Name, finalDestination.RegionName, sp.Scene.RegionInfo.RegionName); |
707 | 710 | ||
708 | Fail(sp, finalDestination, logout); | 711 | Fail(sp, finalDestination, logout, "Destination region did not signal teleport completion."); |
709 | return; | 712 | return; |
710 | } | 713 | } |
711 | 714 | ||
@@ -788,12 +791,15 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
788 | /// <param name='sp'></param> | 791 | /// <param name='sp'></param> |
789 | /// <param name='finalDestination'></param> | 792 | /// <param name='finalDestination'></param> |
790 | /// <param name='logout'></param> | 793 | /// <param name='logout'></param> |
791 | protected virtual void Fail(ScenePresence sp, GridRegion finalDestination, bool logout) | 794 | /// <param name='reason'>Human readable reason for teleport failure. Will be sent to client.</param> |
795 | protected virtual void Fail(ScenePresence sp, GridRegion finalDestination, bool logout, string reason) | ||
792 | { | 796 | { |
793 | CleanupAbortedInterRegionTeleport(sp, finalDestination); | 797 | CleanupAbortedInterRegionTeleport(sp, finalDestination); |
794 | 798 | ||
795 | sp.ControllingClient.SendTeleportFailed( | 799 | sp.ControllingClient.SendTeleportFailed( |
796 | string.Format("Problems connecting to destination {0}", finalDestination.RegionName)); | 800 | string.Format( |
801 | "Problems connecting to destination {0}, reason: {1}", finalDestination.RegionName, reason)); | ||
802 | |||
797 | sp.Scene.EventManager.TriggerTeleportFail(sp.ControllingClient, logout); | 803 | sp.Scene.EventManager.TriggerTeleportFail(sp.ControllingClient, logout); |
798 | } | 804 | } |
799 | 805 | ||
diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceCrossingTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceCrossingTests.cs index 81a2fcc..b67b8b9 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceCrossingTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceCrossingTests.cs | |||
@@ -66,7 +66,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
66 | public void TestCrossOnSameSimulator() | 66 | public void TestCrossOnSameSimulator() |
67 | { | 67 | { |
68 | TestHelpers.InMethod(); | 68 | TestHelpers.InMethod(); |
69 | // TestHelpers.EnableLogging(); | 69 | TestHelpers.EnableLogging(); |
70 | 70 | ||
71 | UUID userId = TestHelpers.ParseTail(0x1); | 71 | UUID userId = TestHelpers.ParseTail(0x1); |
72 | 72 | ||
@@ -94,7 +94,12 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
94 | // SceneHelpers.SetupSceneModules(sceneA, config, new CapabilitiesModule(), etmA, eqmA); | 94 | // SceneHelpers.SetupSceneModules(sceneA, config, new CapabilitiesModule(), etmA, eqmA); |
95 | SceneHelpers.SetupSceneModules(sceneB, config, new CapabilitiesModule(), etmB); | 95 | SceneHelpers.SetupSceneModules(sceneB, config, new CapabilitiesModule(), etmB); |
96 | 96 | ||
97 | ScenePresence originalSp = SceneHelpers.AddScenePresence(sceneA, userId, sh.SceneManager); | 97 | AgentCircuitData acd = SceneHelpers.GenerateAgentData(userId); |
98 | TestClient tc = new TestClient(acd, sceneA, sh.SceneManager); | ||
99 | List<TestClient> destinationTestClients = new List<TestClient>(); | ||
100 | EntityTransferHelpers.SetUpInformClientOfNeighbour(tc, destinationTestClients); | ||
101 | |||
102 | ScenePresence originalSp = SceneHelpers.AddScenePresence(sceneA, tc, acd, sh.SceneManager); | ||
98 | originalSp.AbsolutePosition = new Vector3(128, 32, 10); | 103 | originalSp.AbsolutePosition = new Vector3(128, 32, 10); |
99 | 104 | ||
100 | // originalSp.Flying = true; | 105 | // originalSp.Flying = true; |
diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs index 8dd1f3d..d6bc313 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs | |||
@@ -26,7 +26,10 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Reflection; | 29 | using System.Collections.Generic; |
30 | using System.IO; | ||
31 | using System.Net; | ||
32 | using System.Text; | ||
30 | using Nini.Config; | 33 | using Nini.Config; |
31 | using NUnit.Framework; | 34 | using NUnit.Framework; |
32 | using OpenMetaverse; | 35 | using OpenMetaverse; |
@@ -40,8 +43,6 @@ using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation; | |||
40 | using OpenSim.Region.CoreModules.World.Permissions; | 43 | using OpenSim.Region.CoreModules.World.Permissions; |
41 | using OpenSim.Tests.Common; | 44 | using OpenSim.Tests.Common; |
42 | using OpenSim.Tests.Common.Mock; | 45 | using OpenSim.Tests.Common.Mock; |
43 | using System.IO; | ||
44 | using System.Text; | ||
45 | 46 | ||
46 | namespace OpenSim.Region.Framework.Scenes.Tests | 47 | namespace OpenSim.Region.Framework.Scenes.Tests |
47 | { | 48 | { |
@@ -68,7 +69,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
68 | } | 69 | } |
69 | 70 | ||
70 | [Test] | 71 | [Test] |
71 | public void TestSameRegionTeleport() | 72 | public void TestSameRegion() |
72 | { | 73 | { |
73 | TestHelpers.InMethod(); | 74 | TestHelpers.InMethod(); |
74 | // log4net.Config.XmlConfigurator.Configure(); | 75 | // log4net.Config.XmlConfigurator.Configure(); |
@@ -106,10 +107,10 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
106 | } | 107 | } |
107 | 108 | ||
108 | [Test] | 109 | [Test] |
109 | public void TestSameSimulatorSeparatedRegionsTeleport() | 110 | public void TestSameSimulatorSeparatedRegions() |
110 | { | 111 | { |
111 | TestHelpers.InMethod(); | 112 | TestHelpers.InMethod(); |
112 | // log4net.Config.XmlConfigurator.Configure(); | 113 | // TestHelpers.EnableLogging(); |
113 | 114 | ||
114 | UUID userId = TestHelpers.ParseTail(0x1); | 115 | UUID userId = TestHelpers.ParseTail(0x1); |
115 | 116 | ||
@@ -141,9 +142,8 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
141 | ScenePresence sp = SceneHelpers.AddScenePresence(sceneA, userId, sh.SceneManager); | 142 | ScenePresence sp = SceneHelpers.AddScenePresence(sceneA, userId, sh.SceneManager); |
142 | sp.AbsolutePosition = new Vector3(30, 31, 32); | 143 | sp.AbsolutePosition = new Vector3(30, 31, 32); |
143 | 144 | ||
144 | // XXX: A very nasty hack to tell the client about the destination scene without having to crank the whole | 145 | List<TestClient> destinationTestClients = new List<TestClient>(); |
145 | // UDP stack (?) | 146 | EntityTransferHelpers.SetUpInformClientOfNeighbour((TestClient)sp.ControllingClient, destinationTestClients); |
146 | // ((TestClient)sp.ControllingClient).TeleportTargetScene = sceneB; | ||
147 | 147 | ||
148 | sceneA.RequestTeleportLocation( | 148 | sceneA.RequestTeleportLocation( |
149 | sp.ControllingClient, | 149 | sp.ControllingClient, |
@@ -152,7 +152,10 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
152 | teleportLookAt, | 152 | teleportLookAt, |
153 | (uint)TeleportFlags.ViaLocation); | 153 | (uint)TeleportFlags.ViaLocation); |
154 | 154 | ||
155 | ((TestClient)sp.ControllingClient).CompleteTeleportClientSide(); | 155 | // SetupInformClientOfNeighbour() will have handled the callback into the target scene to setup the child |
156 | // agent. This call will now complete the movement of the user into the destination and upgrade the agent | ||
157 | // from child to root. | ||
158 | destinationTestClients[0].CompleteMovement(); | ||
156 | 159 | ||
157 | Assert.That(sceneA.GetScenePresence(userId), Is.Null); | 160 | Assert.That(sceneA.GetScenePresence(userId), Is.Null); |
158 | 161 | ||
@@ -177,7 +180,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
177 | /// Test teleport procedures when the target simulator returns false when queried about access. | 180 | /// Test teleport procedures when the target simulator returns false when queried about access. |
178 | /// </summary> | 181 | /// </summary> |
179 | [Test] | 182 | [Test] |
180 | public void TestSameSimulatorSeparatedRegionsQueryAccessFails() | 183 | public void TestSameSimulatorSeparatedRegions_DeniedOnQueryAccess() |
181 | { | 184 | { |
182 | TestHelpers.InMethod(); | 185 | TestHelpers.InMethod(); |
183 | // TestHelpers.EnableLogging(); | 186 | // TestHelpers.EnableLogging(); |
@@ -261,7 +264,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
261 | /// Test teleport procedures when the target simulator create agent step is refused. | 264 | /// Test teleport procedures when the target simulator create agent step is refused. |
262 | /// </summary> | 265 | /// </summary> |
263 | [Test] | 266 | [Test] |
264 | public void TestSameSimulatorSeparatedRegionsCreateAgentFails() | 267 | public void TestSameSimulatorSeparatedRegions_DeniedOnCreateAgent() |
265 | { | 268 | { |
266 | TestHelpers.InMethod(); | 269 | TestHelpers.InMethod(); |
267 | // TestHelpers.EnableLogging(); | 270 | // TestHelpers.EnableLogging(); |
@@ -333,13 +336,101 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
333 | // TestHelpers.DisableLogging(); | 336 | // TestHelpers.DisableLogging(); |
334 | } | 337 | } |
335 | 338 | ||
339 | /// <summary> | ||
340 | /// Test teleport when the destination region does not process (or does not receive) the connection attempt | ||
341 | /// from the viewer. | ||
342 | /// </summary> | ||
343 | /// <remarks> | ||
344 | /// This could be quite a common case where the source region can connect to a remove destination region | ||
345 | /// (for CreateAgent) but the viewer cannot reach the destination region due to network issues. | ||
346 | /// </remarks> | ||
336 | [Test] | 347 | [Test] |
337 | public void TestSameSimulatorNeighbouringRegionsTeleport() | 348 | public void TestSameSimulatorSeparatedRegions_DestinationDidNotProcessViewerConnection() |
338 | { | 349 | { |
339 | TestHelpers.InMethod(); | 350 | TestHelpers.InMethod(); |
340 | // TestHelpers.EnableLogging(); | 351 | // TestHelpers.EnableLogging(); |
341 | 352 | ||
342 | UUID userId = TestHelpers.ParseTail(0x1); | 353 | UUID userId = TestHelpers.ParseTail(0x1); |
354 | Vector3 preTeleportPosition = new Vector3(30, 31, 32); | ||
355 | |||
356 | EntityTransferModule etmA = new EntityTransferModule(); | ||
357 | EntityTransferModule etmB = new EntityTransferModule(); | ||
358 | |||
359 | LocalSimulationConnectorModule lscm = new LocalSimulationConnectorModule(); | ||
360 | |||
361 | IConfigSource config = new IniConfigSource(); | ||
362 | config.AddConfig("Modules"); | ||
363 | config.Configs["Modules"].Set("EntityTransferModule", etmA.Name); | ||
364 | config.Configs["Modules"].Set("SimulationServices", lscm.Name); | ||
365 | |||
366 | config.AddConfig("EntityTransfer"); | ||
367 | |||
368 | // In order to run a single threaded regression test we do not want the entity transfer module waiting | ||
369 | // for a callback from the destination scene before removing its avatar data. | ||
370 | config.Configs["EntityTransfer"].Set("wait_for_callback", false); | ||
371 | |||
372 | // config.AddConfig("Startup"); | ||
373 | // config.Configs["Startup"].Set("serverside_object_permissions", true); | ||
374 | |||
375 | SceneHelpers sh = new SceneHelpers(); | ||
376 | TestScene sceneA = sh.SetupScene("sceneA", TestHelpers.ParseTail(0x100), 1000, 1000); | ||
377 | TestScene sceneB = sh.SetupScene("sceneB", TestHelpers.ParseTail(0x200), 1002, 1000); | ||
378 | |||
379 | SceneHelpers.SetupSceneModules(sceneA, config, etmA ); | ||
380 | |||
381 | // We need to set up the permisions module on scene B so that our later use of agent limit to deny | ||
382 | // QueryAccess won't succeed anyway because administrators are always allowed in and the default | ||
383 | // IsAdministrator if no permissions module is present is true. | ||
384 | SceneHelpers.SetupSceneModules(sceneB, config, new object[] { new PermissionsModule(), etmB }); | ||
385 | |||
386 | // Shared scene modules | ||
387 | SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, config, lscm); | ||
388 | |||
389 | Vector3 teleportPosition = new Vector3(10, 11, 12); | ||
390 | Vector3 teleportLookAt = new Vector3(20, 21, 22); | ||
391 | |||
392 | ScenePresence sp = SceneHelpers.AddScenePresence(sceneA, userId, sh.SceneManager); | ||
393 | sp.AbsolutePosition = preTeleportPosition; | ||
394 | |||
395 | sceneA.RequestTeleportLocation( | ||
396 | sp.ControllingClient, | ||
397 | sceneB.RegionInfo.RegionHandle, | ||
398 | teleportPosition, | ||
399 | teleportLookAt, | ||
400 | (uint)TeleportFlags.ViaLocation); | ||
401 | |||
402 | // FIXME: Not setting up InformClientOfNeighbour on the TestClient means that it does not initiate | ||
403 | // communication with the destination region. But this is a very non-obvious way of doing it - really we | ||
404 | // should be forced to expicitly set this up. | ||
405 | |||
406 | Assert.That(sceneB.GetScenePresence(userId), Is.Null); | ||
407 | |||
408 | ScenePresence sceneASp = sceneA.GetScenePresence(userId); | ||
409 | Assert.That(sceneASp, Is.Not.Null); | ||
410 | Assert.That(sceneASp.Scene.RegionInfo.RegionName, Is.EqualTo(sceneA.RegionInfo.RegionName)); | ||
411 | Assert.That(sceneASp.AbsolutePosition, Is.EqualTo(preTeleportPosition)); | ||
412 | |||
413 | Assert.That(sceneA.GetRootAgentCount(), Is.EqualTo(1)); | ||
414 | Assert.That(sceneA.GetChildAgentCount(), Is.EqualTo(0)); | ||
415 | Assert.That(sceneB.GetRootAgentCount(), Is.EqualTo(0)); | ||
416 | Assert.That(sceneB.GetChildAgentCount(), Is.EqualTo(0)); | ||
417 | |||
418 | // TODO: Add assertions to check correct circuit details in both scenes. | ||
419 | |||
420 | // Lookat is sent to the client only - sp.Lookat does not yield the same thing (calculation from camera | ||
421 | // position instead). | ||
422 | // Assert.That(sp.Lookat, Is.EqualTo(teleportLookAt)); | ||
423 | |||
424 | // TestHelpers.DisableLogging(); | ||
425 | } | ||
426 | |||
427 | [Test] | ||
428 | public void TestSameSimulatorNeighbouringRegions() | ||
429 | { | ||
430 | TestHelpers.InMethod(); | ||
431 | TestHelpers.EnableLogging(); | ||
432 | |||
433 | UUID userId = TestHelpers.ParseTail(0x1); | ||
343 | 434 | ||
344 | EntityTransferModule etmA = new EntityTransferModule(); | 435 | EntityTransferModule etmA = new EntityTransferModule(); |
345 | EntityTransferModule etmB = new EntityTransferModule(); | 436 | EntityTransferModule etmB = new EntityTransferModule(); |
@@ -366,10 +457,14 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
366 | Vector3 teleportPosition = new Vector3(10, 11, 12); | 457 | Vector3 teleportPosition = new Vector3(10, 11, 12); |
367 | Vector3 teleportLookAt = new Vector3(20, 21, 22); | 458 | Vector3 teleportLookAt = new Vector3(20, 21, 22); |
368 | 459 | ||
369 | ScenePresence originalSp = SceneHelpers.AddScenePresence(sceneA, userId, sh.SceneManager); | 460 | AgentCircuitData acd = SceneHelpers.GenerateAgentData(userId); |
370 | originalSp.AbsolutePosition = new Vector3(30, 31, 32); | 461 | TestClient tc = new TestClient(acd, sceneA, sh.SceneManager); |
462 | List<TestClient> destinationTestClients = new List<TestClient>(); | ||
463 | EntityTransferHelpers.SetUpInformClientOfNeighbour(tc, destinationTestClients); | ||
464 | |||
465 | ScenePresence beforeSceneASp = SceneHelpers.AddScenePresence(sceneA, tc, acd, sh.SceneManager); | ||
466 | beforeSceneASp.AbsolutePosition = new Vector3(30, 31, 32); | ||
371 | 467 | ||
372 | ScenePresence beforeSceneASp = sceneA.GetScenePresence(userId); | ||
373 | Assert.That(beforeSceneASp, Is.Not.Null); | 468 | Assert.That(beforeSceneASp, Is.Not.Null); |
374 | Assert.That(beforeSceneASp.IsChildAgent, Is.False); | 469 | Assert.That(beforeSceneASp.IsChildAgent, Is.False); |
375 | 470 | ||
@@ -377,10 +472,8 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
377 | Assert.That(beforeSceneBSp, Is.Not.Null); | 472 | Assert.That(beforeSceneBSp, Is.Not.Null); |
378 | Assert.That(beforeSceneBSp.IsChildAgent, Is.True); | 473 | Assert.That(beforeSceneBSp.IsChildAgent, Is.True); |
379 | 474 | ||
380 | // XXX: A very nasty hack to tell the client about the destination scene without having to crank the whole | 475 | // In this case, we will not receieve a second InformClientOfNeighbour since the viewer already knows |
381 | // UDP stack (?) | 476 | // about the neighbour region it is teleporting to. |
382 | // ((TestClient)beforeSceneASp.ControllingClient).TeleportTargetScene = sceneB; | ||
383 | |||
384 | sceneA.RequestTeleportLocation( | 477 | sceneA.RequestTeleportLocation( |
385 | beforeSceneASp.ControllingClient, | 478 | beforeSceneASp.ControllingClient, |
386 | sceneB.RegionInfo.RegionHandle, | 479 | sceneB.RegionInfo.RegionHandle, |
@@ -388,7 +481,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
388 | teleportLookAt, | 481 | teleportLookAt, |
389 | (uint)TeleportFlags.ViaLocation); | 482 | (uint)TeleportFlags.ViaLocation); |
390 | 483 | ||
391 | ((TestClient)beforeSceneASp.ControllingClient).CompleteTeleportClientSide(); | 484 | destinationTestClients[0].CompleteMovement(); |
392 | 485 | ||
393 | ScenePresence afterSceneASp = sceneA.GetScenePresence(userId); | 486 | ScenePresence afterSceneASp = sceneA.GetScenePresence(userId); |
394 | Assert.That(afterSceneASp, Is.Not.Null); | 487 | Assert.That(afterSceneASp, Is.Not.Null); |
diff --git a/OpenSim/Tests/Common/Helpers/SceneHelpers.cs b/OpenSim/Tests/Common/Helpers/SceneHelpers.cs index dc20f13..bdd9093 100644 --- a/OpenSim/Tests/Common/Helpers/SceneHelpers.cs +++ b/OpenSim/Tests/Common/Helpers/SceneHelpers.cs | |||
@@ -532,6 +532,31 @@ namespace OpenSim.Tests.Common | |||
532 | /// <returns></returns> | 532 | /// <returns></returns> |
533 | public static ScenePresence AddScenePresence(Scene scene, AgentCircuitData agentData, SceneManager sceneManager) | 533 | public static ScenePresence AddScenePresence(Scene scene, AgentCircuitData agentData, SceneManager sceneManager) |
534 | { | 534 | { |
535 | return AddScenePresence(scene, new TestClient(agentData, scene, sceneManager), agentData, sceneManager); | ||
536 | } | ||
537 | |||
538 | /// <summary> | ||
539 | /// Add a root agent. | ||
540 | /// </summary> | ||
541 | /// <remarks> | ||
542 | /// This function | ||
543 | /// | ||
544 | /// 1) Tells the scene that an agent is coming. Normally, the login service (local if standalone, from the | ||
545 | /// userserver if grid) would give initial login data back to the client and separately tell the scene that the | ||
546 | /// agent was coming. | ||
547 | /// | ||
548 | /// 2) Connects the agent with the scene | ||
549 | /// | ||
550 | /// This function performs actions equivalent with notifying the scene that an agent is | ||
551 | /// coming and then actually connecting the agent to the scene. The one step missed out is the very first | ||
552 | /// </remarks> | ||
553 | /// <param name="scene"></param> | ||
554 | /// <param name="agentData"></param> | ||
555 | /// <param name="sceneManager"></param> | ||
556 | /// <returns></returns> | ||
557 | public static ScenePresence AddScenePresence( | ||
558 | Scene scene, IClientAPI client, AgentCircuitData agentData, SceneManager sceneManager) | ||
559 | { | ||
535 | // We emulate the proper login sequence here by doing things in four stages | 560 | // We emulate the proper login sequence here by doing things in four stages |
536 | 561 | ||
537 | // Stage 0: login | 562 | // Stage 0: login |
@@ -541,7 +566,7 @@ namespace OpenSim.Tests.Common | |||
541 | lpsc.m_PresenceService.LoginAgent(agentData.AgentID.ToString(), agentData.SessionID, agentData.SecureSessionID); | 566 | lpsc.m_PresenceService.LoginAgent(agentData.AgentID.ToString(), agentData.SessionID, agentData.SecureSessionID); |
542 | 567 | ||
543 | // Stages 1 & 2 | 568 | // Stages 1 & 2 |
544 | ScenePresence sp = IntroduceClientToScene(scene, sceneManager, agentData, TeleportFlags.ViaLogin); | 569 | ScenePresence sp = IntroduceClientToScene(scene, client, agentData, TeleportFlags.ViaLogin); |
545 | 570 | ||
546 | // Stage 3: Complete the entrance into the region. This converts the child agent into a root agent. | 571 | // Stage 3: Complete the entrance into the region. This converts the child agent into a root agent. |
547 | sp.CompleteMovement(sp.ControllingClient, true); | 572 | sp.CompleteMovement(sp.ControllingClient, true); |
@@ -558,11 +583,11 @@ namespace OpenSim.Tests.Common | |||
558 | /// neighbours and where no teleporting takes place. | 583 | /// neighbours and where no teleporting takes place. |
559 | /// </param> | 584 | /// </param> |
560 | /// <param name='scene'></param> | 585 | /// <param name='scene'></param> |
561 | /// <param name='sceneManager></param> | 586 | /// <param name='testClient'></param> |
562 | /// <param name='agentData'></param> | 587 | /// <param name='agentData'></param> |
563 | /// <param name='tf'></param> | 588 | /// <param name='tf'></param> |
564 | private static ScenePresence IntroduceClientToScene( | 589 | private static ScenePresence IntroduceClientToScene( |
565 | Scene scene, SceneManager sceneManager, AgentCircuitData agentData, TeleportFlags tf) | 590 | Scene scene, IClientAPI client, AgentCircuitData agentData, TeleportFlags tf) |
566 | { | 591 | { |
567 | string reason; | 592 | string reason; |
568 | 593 | ||
@@ -571,10 +596,9 @@ namespace OpenSim.Tests.Common | |||
571 | Console.WriteLine("NewUserConnection failed: " + reason); | 596 | Console.WriteLine("NewUserConnection failed: " + reason); |
572 | 597 | ||
573 | // Stage 2: add the new client as a child agent to the scene | 598 | // Stage 2: add the new client as a child agent to the scene |
574 | TestClient client = new TestClient(agentData, scene, sceneManager); | ||
575 | scene.AddNewClient(client, PresenceType.User); | 599 | scene.AddNewClient(client, PresenceType.User); |
576 | 600 | ||
577 | return scene.GetScenePresence(agentData.AgentID); | 601 | return scene.GetScenePresence(client.AgentId); |
578 | } | 602 | } |
579 | 603 | ||
580 | public static ScenePresence AddChildScenePresence(Scene scene, UUID agentId) | 604 | public static ScenePresence AddChildScenePresence(Scene scene, UUID agentId) |
@@ -583,7 +607,8 @@ namespace OpenSim.Tests.Common | |||
583 | acd.child = true; | 607 | acd.child = true; |
584 | 608 | ||
585 | // XXX: ViaLogin may not be correct for child agents | 609 | // XXX: ViaLogin may not be correct for child agents |
586 | return IntroduceClientToScene(scene, null, acd, TeleportFlags.ViaLogin); | 610 | TestClient client = new TestClient(acd, scene, null); |
611 | return IntroduceClientToScene(scene, client, acd, TeleportFlags.ViaLogin); | ||
587 | } | 612 | } |
588 | 613 | ||
589 | /// <summary> | 614 | /// <summary> |
diff --git a/OpenSim/Tests/Common/Mock/TestClient.cs b/OpenSim/Tests/Common/Mock/TestClient.cs index a448cc5..2d4fef1 100644 --- a/OpenSim/Tests/Common/Mock/TestClient.cs +++ b/OpenSim/Tests/Common/Mock/TestClient.cs | |||
@@ -46,8 +46,6 @@ namespace OpenSim.Tests.Common.Mock | |||
46 | 46 | ||
47 | EventWaitHandle wh = new EventWaitHandle (false, EventResetMode.AutoReset, "Crossing"); | 47 | EventWaitHandle wh = new EventWaitHandle (false, EventResetMode.AutoReset, "Crossing"); |
48 | 48 | ||
49 | private TestClient TeleportSceneClient; | ||
50 | |||
51 | private Scene m_scene; | 49 | private Scene m_scene; |
52 | private SceneManager m_sceneManager; | 50 | private SceneManager m_sceneManager; |
53 | 51 | ||
@@ -60,7 +58,9 @@ namespace OpenSim.Tests.Common.Mock | |||
60 | public List<ImagePacketPacket> SentImagePacketPackets { get; private set; } | 58 | public List<ImagePacketPacket> SentImagePacketPackets { get; private set; } |
61 | public List<ImageNotInDatabasePacket> SentImageNotInDatabasePackets { get; private set; } | 59 | public List<ImageNotInDatabasePacket> SentImageNotInDatabasePackets { get; private set; } |
62 | 60 | ||
61 | // Test client specific events - for use by tests to implement some IClientAPI behaviour. | ||
63 | public event Action<RegionInfo, Vector3, Vector3> OnReceivedMoveAgentIntoRegion; | 62 | public event Action<RegionInfo, Vector3, Vector3> OnReceivedMoveAgentIntoRegion; |
63 | public event Action<ulong, IPEndPoint> OnTestClientInformClientOfNeighbour; | ||
64 | 64 | ||
65 | // disable warning: public events, part of the public API | 65 | // disable warning: public events, part of the public API |
66 | #pragma warning disable 67 | 66 | #pragma warning disable 67 |
@@ -595,23 +595,8 @@ namespace OpenSim.Tests.Common.Mock | |||
595 | 595 | ||
596 | public virtual void InformClientOfNeighbour(ulong neighbourHandle, IPEndPoint neighbourExternalEndPoint) | 596 | public virtual void InformClientOfNeighbour(ulong neighbourHandle, IPEndPoint neighbourExternalEndPoint) |
597 | { | 597 | { |
598 | m_log.DebugFormat("[TEST CLIENT]: Processing inform client of neighbour"); | 598 | if (OnTestClientInformClientOfNeighbour != null) |
599 | 599 | OnTestClientInformClientOfNeighbour(neighbourHandle, neighbourExternalEndPoint); | |
600 | // In response to this message, we are going to make a teleport to the scene we've previous been told | ||
601 | // about by test code (this needs to be improved). | ||
602 | AgentCircuitData newAgent = RequestClientInfo(); | ||
603 | |||
604 | // Stage 2: add the new client as a child agent to the scene | ||
605 | uint x, y; | ||
606 | Utils.LongToUInts(neighbourHandle, out x, out y); | ||
607 | x /= Constants.RegionSize; | ||
608 | y /= Constants.RegionSize; | ||
609 | |||
610 | Scene neighbourScene; | ||
611 | m_sceneManager.TryGetScene(x, y, out neighbourScene); | ||
612 | |||
613 | TeleportSceneClient = new TestClient(newAgent, neighbourScene, m_sceneManager); | ||
614 | neighbourScene.AddNewClient(TeleportSceneClient, PresenceType.User); | ||
615 | } | 600 | } |
616 | 601 | ||
617 | public virtual void SendRegionTeleport(ulong regionHandle, byte simAccess, IPEndPoint regionExternalEndPoint, | 602 | public virtual void SendRegionTeleport(ulong regionHandle, byte simAccess, IPEndPoint regionExternalEndPoint, |
@@ -626,12 +611,6 @@ namespace OpenSim.Tests.Common.Mock | |||
626 | // CompleteTeleportClientSide(); | 611 | // CompleteTeleportClientSide(); |
627 | } | 612 | } |
628 | 613 | ||
629 | public void CompleteTeleportClientSide() | ||
630 | { | ||
631 | TeleportSceneClient.CompleteMovement(); | ||
632 | //TeleportTargetScene.AgentCrossing(newAgent.AgentID, new Vector3(90, 90, 90), false); | ||
633 | } | ||
634 | |||
635 | public virtual void SendTeleportFailed(string reason) | 614 | public virtual void SendTeleportFailed(string reason) |
636 | { | 615 | { |
637 | m_log.DebugFormat("[TEST CLIENT]: Teleport failed with reason {0}", reason); | 616 | m_log.DebugFormat("[TEST CLIENT]: Teleport failed with reason {0}", reason); |