diff options
author | Justin Clark-Casey (justincc) | 2012-05-01 23:14:12 +0100 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2012-05-01 23:14:12 +0100 |
commit | 9d2e1c67a8969e4769006c7347505b58a7827b3f (patch) | |
tree | 1fb6d412e2d8a753e1b59af46f6ada0a45556e75 | |
parent | Move max teleport distance check down into etm.DoTeleport() since this should... (diff) | |
download | opensim-SC_OLD-9d2e1c67a8969e4769006c7347505b58a7827b3f.zip opensim-SC_OLD-9d2e1c67a8969e4769006c7347505b58a7827b3f.tar.gz opensim-SC_OLD-9d2e1c67a8969e4769006c7347505b58a7827b3f.tar.bz2 opensim-SC_OLD-9d2e1c67a8969e4769006c7347505b58a7827b3f.tar.xz |
Add regression test for teleporting between neighbouring regions on the same simulator
This adds a non-advertised wait_for_callback option in [EntityTransfer]. Default is always true.
Teleport tests disable the wait for callback from the destination region in order to run within a single thread.
10 files changed, 248 insertions, 33 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/Tests/LLImageManagerTests.cs b/OpenSim/Region/ClientStack/Linden/UDP/Tests/LLImageManagerTests.cs index 221f02b..5fcf376 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/Tests/LLImageManagerTests.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/Tests/LLImageManagerTests.cs | |||
@@ -79,7 +79,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests | |||
79 | 79 | ||
80 | J2KDecoderModule j2kdm = new J2KDecoderModule(); | 80 | J2KDecoderModule j2kdm = new J2KDecoderModule(); |
81 | 81 | ||
82 | scene = new SceneHelpers().SetupScene(); | 82 | SceneHelpers sceneHelpers = new SceneHelpers(); |
83 | scene = sceneHelpers.SetupScene(); | ||
83 | SceneHelpers.SetupSceneModules(scene, j2kdm); | 84 | SceneHelpers.SetupSceneModules(scene, j2kdm); |
84 | 85 | ||
85 | tc = new TestClient(SceneHelpers.GenerateAgentData(userId), scene); | 86 | tc = new TestClient(SceneHelpers.GenerateAgentData(userId), scene); |
diff --git a/OpenSim/Region/ClientStack/RegionApplicationBase.cs b/OpenSim/Region/ClientStack/RegionApplicationBase.cs index 6e3a58e..6e78d6d 100644 --- a/OpenSim/Region/ClientStack/RegionApplicationBase.cs +++ b/OpenSim/Region/ClientStack/RegionApplicationBase.cs | |||
@@ -111,7 +111,7 @@ namespace OpenSim.Region.ClientStack | |||
111 | server.Start(); | 111 | server.Start(); |
112 | } | 112 | } |
113 | } | 113 | } |
114 | 114 | ||
115 | base.StartupSpecific(); | 115 | base.StartupSpecific(); |
116 | } | 116 | } |
117 | 117 | ||
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs index 230706e..35486bb 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs | |||
@@ -52,12 +52,20 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
52 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 52 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
53 | 53 | ||
54 | public const int DefaultMaxTransferDistance = 4095; | 54 | public const int DefaultMaxTransferDistance = 4095; |
55 | public const bool EnableWaitForCallbackFromTeleportDestDefault = true; | ||
56 | |||
55 | 57 | ||
56 | /// <summary> | 58 | /// <summary> |
57 | /// The maximum distance, in standard region units (256m) that an agent is allowed to transfer. | 59 | /// The maximum distance, in standard region units (256m) that an agent is allowed to transfer. |
58 | /// </summary> | 60 | /// </summary> |
59 | public int MaxTransferDistance { get; set; } | 61 | public int MaxTransferDistance { get; set; } |
60 | 62 | ||
63 | /// <summary> | ||
64 | /// If true then on a teleport, the source region waits for a callback from the destination region. If | ||
65 | /// a callback fails to arrive within a set time then the user is pulled back into the source region. | ||
66 | /// </summary> | ||
67 | public bool EnableWaitForCallbackFromTeleportDest { get; set; } | ||
68 | |||
61 | protected bool m_Enabled = false; | 69 | protected bool m_Enabled = false; |
62 | protected Scene m_aScene; | 70 | protected Scene m_aScene; |
63 | protected List<Scene> m_Scenes = new List<Scene>(); | 71 | protected List<Scene> m_Scenes = new List<Scene>(); |
@@ -99,9 +107,16 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
99 | { | 107 | { |
100 | IConfig transferConfig = source.Configs["EntityTransfer"]; | 108 | IConfig transferConfig = source.Configs["EntityTransfer"]; |
101 | if (transferConfig != null) | 109 | if (transferConfig != null) |
110 | { | ||
111 | EnableWaitForCallbackFromTeleportDest | ||
112 | = transferConfig.GetBoolean("wait_for_callback", EnableWaitForCallbackFromTeleportDestDefault); | ||
113 | |||
102 | MaxTransferDistance = transferConfig.GetInt("max_distance", DefaultMaxTransferDistance); | 114 | MaxTransferDistance = transferConfig.GetInt("max_distance", DefaultMaxTransferDistance); |
115 | } | ||
103 | else | 116 | else |
117 | { | ||
104 | MaxTransferDistance = DefaultMaxTransferDistance; | 118 | MaxTransferDistance = DefaultMaxTransferDistance; |
119 | } | ||
105 | 120 | ||
106 | m_agentsInTransit = new List<UUID>(); | 121 | m_agentsInTransit = new List<UUID>(); |
107 | m_Enabled = true; | 122 | m_Enabled = true; |
@@ -499,6 +514,9 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
499 | } | 514 | } |
500 | else | 515 | else |
501 | { | 516 | { |
517 | ICapabilitiesModule capModule = sp.Scene.CapsModule; | ||
518 | ulong regionHandle = reg.RegionHandle; | ||
519 | capModule.GetChildSeed(UUID.Zero, regionHandle); | ||
502 | agentCircuit.CapsPath = sp.Scene.CapsModule.GetChildSeed(sp.UUID, reg.RegionHandle); | 520 | agentCircuit.CapsPath = sp.Scene.CapsModule.GetChildSeed(sp.UUID, reg.RegionHandle); |
503 | capsPath = finalDestination.ServerURI + CapsUtil.GetCapsSeedPath(agentCircuit.CapsPath); | 521 | capsPath = finalDestination.ServerURI + CapsUtil.GetCapsSeedPath(agentCircuit.CapsPath); |
504 | } | 522 | } |
@@ -527,7 +545,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
527 | sp.ControllingClient.SendTeleportProgress(teleportFlags | (uint)TeleportFlags.DisableCancel, "sending_dest"); | 545 | sp.ControllingClient.SendTeleportProgress(teleportFlags | (uint)TeleportFlags.DisableCancel, "sending_dest"); |
528 | 546 | ||
529 | m_log.DebugFormat( | 547 | m_log.DebugFormat( |
530 | "[ENTITY TRANSFER MODULE]: Sending new CAPS seed url {0} to client {1}", capsPath, sp.UUID); | 548 | "[ENTITY TRANSFER MODULE]: Sending new CAPS seed url {0} from {1} to {2}", |
549 | capsPath, sp.Scene.RegionInfo.RegionName, sp.Name); | ||
531 | 550 | ||
532 | if (eq != null) | 551 | if (eq != null) |
533 | { | 552 | { |
@@ -546,7 +565,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
546 | // TeleportFinish makes the client send CompleteMovementIntoRegion (at the destination), which | 565 | // TeleportFinish makes the client send CompleteMovementIntoRegion (at the destination), which |
547 | // trigers a whole shebang of things there, including MakeRoot. So let's wait for confirmation | 566 | // trigers a whole shebang of things there, including MakeRoot. So let's wait for confirmation |
548 | // that the client contacted the destination before we close things here. | 567 | // that the client contacted the destination before we close things here. |
549 | if (!WaitForCallback(sp.UUID)) | 568 | if (EnableWaitForCallbackFromTeleportDest && !WaitForCallback(sp.UUID)) |
550 | { | 569 | { |
551 | m_log.WarnFormat( | 570 | m_log.WarnFormat( |
552 | "[ENTITY TRANSFER MODULE]: Teleport of {0} to {1} failed due to no callback from destination region. Returning avatar to source region.", | 571 | "[ENTITY TRANSFER MODULE]: Teleport of {0} to {1} failed due to no callback from destination region. Returning avatar to source region.", |
@@ -1286,7 +1305,6 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
1286 | { | 1305 | { |
1287 | if (neighbour.RegionHandle != sp.Scene.RegionInfo.RegionHandle) | 1306 | if (neighbour.RegionHandle != sp.Scene.RegionInfo.RegionHandle) |
1288 | { | 1307 | { |
1289 | |||
1290 | AgentCircuitData currentAgentCircuit = sp.Scene.AuthenticateHandler.GetAgentCircuitData(sp.ControllingClient.CircuitCode); | 1308 | AgentCircuitData currentAgentCircuit = sp.Scene.AuthenticateHandler.GetAgentCircuitData(sp.ControllingClient.CircuitCode); |
1291 | AgentCircuitData agent = sp.ControllingClient.RequestClientInfo(); | 1309 | AgentCircuitData agent = sp.ControllingClient.RequestClientInfo(); |
1292 | agent.BaseFolder = UUID.Zero; | 1310 | agent.BaseFolder = UUID.Zero; |
@@ -1311,7 +1329,9 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
1311 | seeds.Add(neighbour.RegionHandle, agent.CapsPath); | 1329 | seeds.Add(neighbour.RegionHandle, agent.CapsPath); |
1312 | } | 1330 | } |
1313 | else | 1331 | else |
1332 | { | ||
1314 | agent.CapsPath = sp.Scene.CapsModule.GetChildSeed(sp.UUID, neighbour.RegionHandle); | 1333 | agent.CapsPath = sp.Scene.CapsModule.GetChildSeed(sp.UUID, neighbour.RegionHandle); |
1334 | } | ||
1315 | 1335 | ||
1316 | cagents.Add(agent); | 1336 | cagents.Add(agent); |
1317 | } | 1337 | } |
@@ -1926,7 +1946,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
1926 | int count = 200; | 1946 | int count = 200; |
1927 | while (m_agentsInTransit.Contains(id) && count-- > 0) | 1947 | while (m_agentsInTransit.Contains(id) && count-- > 0) |
1928 | { | 1948 | { |
1929 | //m_log.Debug(" >>> Waiting... " + count); | 1949 | // m_log.Debug(" >>> Waiting... " + count); |
1930 | Thread.Sleep(100); | 1950 | Thread.Sleep(100); |
1931 | } | 1951 | } |
1932 | 1952 | ||
@@ -1934,6 +1954,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
1934 | return true; | 1954 | return true; |
1935 | else | 1955 | else |
1936 | return false; | 1956 | return false; |
1957 | |||
1958 | return true; | ||
1937 | } | 1959 | } |
1938 | 1960 | ||
1939 | protected void SetInTransit(UUID id) | 1961 | protected void SetInTransit(UUID id) |
diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/Tests/InventoryAccessModuleTests.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/Tests/InventoryAccessModuleTests.cs index d6afaa9..21d8bd7 100644 --- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/Tests/InventoryAccessModuleTests.cs +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/Tests/InventoryAccessModuleTests.cs | |||
@@ -64,8 +64,9 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess.Tests | |||
64 | IConfigSource config = new IniConfigSource(); | 64 | IConfigSource config = new IniConfigSource(); |
65 | config.AddConfig("Modules"); | 65 | config.AddConfig("Modules"); |
66 | config.Configs["Modules"].Set("InventoryAccessModule", "BasicInventoryAccessModule"); | 66 | config.Configs["Modules"].Set("InventoryAccessModule", "BasicInventoryAccessModule"); |
67 | 67 | ||
68 | m_scene = new SceneHelpers().SetupScene(); | 68 | SceneHelpers sceneHelpers = new SceneHelpers(); |
69 | m_scene = sceneHelpers.SetupScene(); | ||
69 | SceneHelpers.SetupSceneModules(m_scene, config, m_iam); | 70 | SceneHelpers.SetupSceneModules(m_scene, config, m_iam); |
70 | 71 | ||
71 | // Create user | 72 | // Create user |
@@ -76,7 +77,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess.Tests | |||
76 | 77 | ||
77 | AgentCircuitData acd = new AgentCircuitData(); | 78 | AgentCircuitData acd = new AgentCircuitData(); |
78 | acd.AgentID = m_userId; | 79 | acd.AgentID = m_userId; |
79 | m_tc = new TestClient(acd, m_scene); | 80 | m_tc = new TestClient(acd, m_scene); |
80 | } | 81 | } |
81 | 82 | ||
82 | [Test] | 83 | [Test] |
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index f1d0926..e5a9a99 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs | |||
@@ -2895,8 +2895,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2895 | x = x / Constants.RegionSize; | 2895 | x = x / Constants.RegionSize; |
2896 | y = y / Constants.RegionSize; | 2896 | y = y / Constants.RegionSize; |
2897 | 2897 | ||
2898 | //m_log.Debug("---> x: " + x + "; newx:" + newRegionX + "; Abs:" + (int)Math.Abs((int)(x - newRegionX))); | 2898 | // m_log.Debug("---> x: " + x + "; newx:" + newRegionX + "; Abs:" + (int)Math.Abs((int)(x - newRegionX))); |
2899 | //m_log.Debug("---> y: " + y + "; newy:" + newRegionY + "; Abs:" + (int)Math.Abs((int)(y - newRegionY))); | 2899 | // m_log.Debug("---> y: " + y + "; newy:" + newRegionY + "; Abs:" + (int)Math.Abs((int)(y - newRegionY))); |
2900 | if (Util.IsOutsideView(DrawDistance, x, newRegionX, y, newRegionY)) | 2900 | if (Util.IsOutsideView(DrawDistance, x, newRegionX, y, newRegionY)) |
2901 | { | 2901 | { |
2902 | byebyeRegions.Add(handle); | 2902 | byebyeRegions.Add(handle); |
diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAgentTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAgentTests.cs index 2e46377..1aa48d7 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAgentTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAgentTests.cs | |||
@@ -128,7 +128,8 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
128 | IConfig config = configSource.AddConfig("Modules"); | 128 | IConfig config = configSource.AddConfig("Modules"); |
129 | config.Set("SimulationServices", "LocalSimulationConnectorModule"); | 129 | config.Set("SimulationServices", "LocalSimulationConnectorModule"); |
130 | 130 | ||
131 | TestScene scene = new SceneHelpers().SetupScene(); | 131 | SceneHelpers sceneHelpers = new SceneHelpers(); |
132 | TestScene scene = sceneHelpers.SetupScene(); | ||
132 | SceneHelpers.SetupSceneModules(scene, configSource, lsc); | 133 | SceneHelpers.SetupSceneModules(scene, configSource, lsc); |
133 | 134 | ||
134 | UUID agentId = TestHelpers.ParseTail(0x01); | 135 | UUID agentId = TestHelpers.ParseTail(0x01); |
diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs index c750cc5..ea4fb66 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs | |||
@@ -33,8 +33,9 @@ using OpenMetaverse; | |||
33 | using OpenSim.Framework; | 33 | using OpenSim.Framework; |
34 | using OpenSim.Framework.Communications; | 34 | using OpenSim.Framework.Communications; |
35 | using OpenSim.Framework.Servers; | 35 | using OpenSim.Framework.Servers; |
36 | using OpenSim.Region.CoreModules.Framework.EntityTransfer; | ||
37 | using OpenSim.Region.Framework.Interfaces; | 36 | using OpenSim.Region.Framework.Interfaces; |
37 | using OpenSim.Region.CoreModules.Framework; | ||
38 | using OpenSim.Region.CoreModules.Framework.EntityTransfer; | ||
38 | using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation; | 39 | using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation; |
39 | using OpenSim.Tests.Common; | 40 | using OpenSim.Tests.Common; |
40 | using OpenSim.Tests.Common.Mock; | 41 | using OpenSim.Tests.Common.Mock; |
@@ -49,6 +50,22 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
49 | [TestFixture] | 50 | [TestFixture] |
50 | public class ScenePresenceTeleportTests | 51 | public class ScenePresenceTeleportTests |
51 | { | 52 | { |
53 | [TestFixtureSetUp] | ||
54 | public void FixtureInit() | ||
55 | { | ||
56 | // Don't allow tests to be bamboozled by asynchronous events. Execute everything on the same thread. | ||
57 | Util.FireAndForgetMethod = FireAndForgetMethod.RegressionTest; | ||
58 | } | ||
59 | |||
60 | [TestFixtureTearDown] | ||
61 | public void TearDown() | ||
62 | { | ||
63 | // We must set this back afterwards, otherwise later tests will fail since they're expecting multiple | ||
64 | // threads. Possibly, later tests should be rewritten so none of them require async stuff (which regression | ||
65 | // tests really shouldn't). | ||
66 | Util.FireAndForgetMethod = Util.DefaultFireAndForgetMethod; | ||
67 | } | ||
68 | |||
52 | [Test] | 69 | [Test] |
53 | public void TestSameRegionTeleport() | 70 | public void TestSameRegionTeleport() |
54 | { | 71 | { |
@@ -96,10 +113,14 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
96 | LocalSimulationConnectorModule lscm = new LocalSimulationConnectorModule(); | 113 | LocalSimulationConnectorModule lscm = new LocalSimulationConnectorModule(); |
97 | 114 | ||
98 | IConfigSource config = new IniConfigSource(); | 115 | IConfigSource config = new IniConfigSource(); |
99 | config.AddConfig("Modules"); | 116 | IConfig modulesConfig = config.AddConfig("Modules"); |
100 | // Not strictly necessary since FriendsModule assumes it is the default (!) | 117 | modulesConfig.Set("EntityTransferModule", etm.Name); |
101 | config.Configs["Modules"].Set("EntityTransferModule", etm.Name); | 118 | modulesConfig.Set("SimulationServices", lscm.Name); |
102 | config.Configs["Modules"].Set("SimulationServices", lscm.Name); | 119 | IConfig entityTransferConfig = config.AddConfig("EntityTransfer"); |
120 | |||
121 | // In order to run a single threaded regression test we do not want the entity transfer module waiting | ||
122 | // for a callback from the destination scene before removing its avatar data. | ||
123 | entityTransferConfig.Set("wait_for_callback", false); | ||
103 | 124 | ||
104 | SceneHelpers sh = new SceneHelpers(); | 125 | SceneHelpers sh = new SceneHelpers(); |
105 | TestScene sceneA = sh.SetupScene("sceneA", TestHelpers.ParseTail(0x100), 1000, 1000); | 126 | TestScene sceneA = sh.SetupScene("sceneA", TestHelpers.ParseTail(0x100), 1000, 1000); |
@@ -110,12 +131,12 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
110 | Vector3 teleportPosition = new Vector3(10, 11, 12); | 131 | Vector3 teleportPosition = new Vector3(10, 11, 12); |
111 | Vector3 teleportLookAt = new Vector3(20, 21, 22); | 132 | Vector3 teleportLookAt = new Vector3(20, 21, 22); |
112 | 133 | ||
113 | ScenePresence sp = SceneHelpers.AddScenePresence(sceneA, userId); | 134 | ScenePresence sp = SceneHelpers.AddScenePresence(sceneA, userId, sh.SceneManager); |
114 | sp.AbsolutePosition = new Vector3(30, 31, 32); | 135 | sp.AbsolutePosition = new Vector3(30, 31, 32); |
115 | 136 | ||
116 | // XXX: A very nasty hack to tell the client about the destination scene without having to crank the whole | 137 | // XXX: A very nasty hack to tell the client about the destination scene without having to crank the whole |
117 | // UDP stack (?) | 138 | // UDP stack (?) |
118 | ((TestClient)sp.ControllingClient).TeleportTargetScene = sceneB; | 139 | // ((TestClient)sp.ControllingClient).TeleportTargetScene = sceneB; |
119 | 140 | ||
120 | sceneA.RequestTeleportLocation( | 141 | sceneA.RequestTeleportLocation( |
121 | sp.ControllingClient, | 142 | sp.ControllingClient, |
@@ -124,6 +145,8 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
124 | teleportLookAt, | 145 | teleportLookAt, |
125 | (uint)TeleportFlags.ViaLocation); | 146 | (uint)TeleportFlags.ViaLocation); |
126 | 147 | ||
148 | ((TestClient)sp.ControllingClient).CompleteTeleportClientSide(); | ||
149 | |||
127 | Assert.That(sceneA.GetScenePresence(userId), Is.Null); | 150 | Assert.That(sceneA.GetScenePresence(userId), Is.Null); |
128 | 151 | ||
129 | ScenePresence sceneBSp = sceneB.GetScenePresence(userId); | 152 | ScenePresence sceneBSp = sceneB.GetScenePresence(userId); |
@@ -137,5 +160,80 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
137 | // position instead). | 160 | // position instead). |
138 | // Assert.That(sp.Lookat, Is.EqualTo(teleportLookAt)); | 161 | // Assert.That(sp.Lookat, Is.EqualTo(teleportLookAt)); |
139 | } | 162 | } |
163 | |||
164 | [Test] | ||
165 | public void TestSameSimulatorNeighbouringRegionsTeleport() | ||
166 | { | ||
167 | TestHelpers.InMethod(); | ||
168 | // TestHelpers.EnableLogging(); | ||
169 | |||
170 | UUID userId = TestHelpers.ParseTail(0x1); | ||
171 | |||
172 | EntityTransferModule etm = new EntityTransferModule(); | ||
173 | LocalSimulationConnectorModule lscm = new LocalSimulationConnectorModule(); | ||
174 | |||
175 | IConfigSource config = new IniConfigSource(); | ||
176 | IConfig modulesConfig = config.AddConfig("Modules"); | ||
177 | modulesConfig.Set("EntityTransferModule", etm.Name); | ||
178 | modulesConfig.Set("SimulationServices", lscm.Name); | ||
179 | IConfig entityTransferConfig = config.AddConfig("EntityTransfer"); | ||
180 | |||
181 | // In order to run a single threaded regression test we do not want the entity transfer module waiting | ||
182 | // for a callback from the destination scene before removing its avatar data. | ||
183 | entityTransferConfig.Set("wait_for_callback", false); | ||
184 | |||
185 | SceneHelpers sh = new SceneHelpers(); | ||
186 | TestScene sceneA = sh.SetupScene("sceneA", TestHelpers.ParseTail(0x100), 1000, 1000); | ||
187 | TestScene sceneB = sh.SetupScene("sceneB", TestHelpers.ParseTail(0x200), 1001, 1000); | ||
188 | |||
189 | SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, config, etm, lscm); | ||
190 | SceneHelpers.SetupSceneModules(sceneA, new CapabilitiesModule()); | ||
191 | SceneHelpers.SetupSceneModules(sceneB, new CapabilitiesModule()); | ||
192 | |||
193 | Vector3 teleportPosition = new Vector3(10, 11, 12); | ||
194 | Vector3 teleportLookAt = new Vector3(20, 21, 22); | ||
195 | |||
196 | ScenePresence originalSp = SceneHelpers.AddScenePresence(sceneA, userId, sh.SceneManager); | ||
197 | originalSp.AbsolutePosition = new Vector3(30, 31, 32); | ||
198 | |||
199 | ScenePresence beforeSceneASp = sceneA.GetScenePresence(userId); | ||
200 | Assert.That(beforeSceneASp, Is.Not.Null); | ||
201 | Assert.That(beforeSceneASp.IsChildAgent, Is.False); | ||
202 | |||
203 | ScenePresence beforeSceneBSp = sceneB.GetScenePresence(userId); | ||
204 | Assert.That(beforeSceneBSp, Is.Not.Null); | ||
205 | Assert.That(beforeSceneBSp.IsChildAgent, Is.True); | ||
206 | |||
207 | // XXX: A very nasty hack to tell the client about the destination scene without having to crank the whole | ||
208 | // UDP stack (?) | ||
209 | // ((TestClient)beforeSceneASp.ControllingClient).TeleportTargetScene = sceneB; | ||
210 | |||
211 | sceneA.RequestTeleportLocation( | ||
212 | beforeSceneASp.ControllingClient, | ||
213 | sceneB.RegionInfo.RegionHandle, | ||
214 | teleportPosition, | ||
215 | teleportLookAt, | ||
216 | (uint)TeleportFlags.ViaLocation); | ||
217 | |||
218 | ((TestClient)beforeSceneASp.ControllingClient).CompleteTeleportClientSide(); | ||
219 | |||
220 | ScenePresence afterSceneASp = sceneA.GetScenePresence(userId); | ||
221 | Assert.That(afterSceneASp, Is.Not.Null); | ||
222 | Assert.That(afterSceneASp.IsChildAgent, Is.True); | ||
223 | |||
224 | ScenePresence afterSceneBSp = sceneB.GetScenePresence(userId); | ||
225 | Assert.That(afterSceneBSp, Is.Not.Null); | ||
226 | Assert.That(afterSceneBSp.IsChildAgent, Is.False); | ||
227 | Assert.That(afterSceneBSp.Scene.RegionInfo.RegionName, Is.EqualTo(sceneB.RegionInfo.RegionName)); | ||
228 | Assert.That(afterSceneBSp.AbsolutePosition, Is.EqualTo(teleportPosition)); | ||
229 | |||
230 | // TODO: Add assertions to check correct circuit details in both scenes. | ||
231 | |||
232 | // Lookat is sent to the client only - sp.Lookat does not yield the same thing (calculation from camera | ||
233 | // position instead). | ||
234 | // Assert.That(sp.Lookat, Is.EqualTo(teleportLookAt)); | ||
235 | |||
236 | // TestHelpers.DisableLogging(); | ||
237 | } | ||
140 | } | 238 | } |
141 | } \ No newline at end of file | 239 | } \ No newline at end of file |
diff --git a/OpenSim/Tests/Common/Helpers/SceneHelpers.cs b/OpenSim/Tests/Common/Helpers/SceneHelpers.cs index 8e54707..dc24418 100644 --- a/OpenSim/Tests/Common/Helpers/SceneHelpers.cs +++ b/OpenSim/Tests/Common/Helpers/SceneHelpers.cs | |||
@@ -58,6 +58,11 @@ namespace OpenSim.Tests.Common | |||
58 | /// </summary> | 58 | /// </summary> |
59 | public class SceneHelpers | 59 | public class SceneHelpers |
60 | { | 60 | { |
61 | /// <summary> | ||
62 | /// We need a scene manager so that test clients can retrieve a scene when performing teleport tests. | ||
63 | /// </summary> | ||
64 | public SceneManager SceneManager { get; private set; } | ||
65 | |||
61 | private AgentCircuitManager m_acm = new AgentCircuitManager(); | 66 | private AgentCircuitManager m_acm = new AgentCircuitManager(); |
62 | private ISimulationDataService m_simDataService | 67 | private ISimulationDataService m_simDataService |
63 | = OpenSim.Server.Base.ServerUtils.LoadPlugin<ISimulationDataService>("OpenSim.Tests.Common.dll", null); | 68 | = OpenSim.Server.Base.ServerUtils.LoadPlugin<ISimulationDataService>("OpenSim.Tests.Common.dll", null); |
@@ -76,6 +81,8 @@ namespace OpenSim.Tests.Common | |||
76 | 81 | ||
77 | public SceneHelpers(CoreAssetCache cache) | 82 | public SceneHelpers(CoreAssetCache cache) |
78 | { | 83 | { |
84 | SceneManager = new SceneManager(); | ||
85 | |||
79 | m_assetService = StartAssetService(cache); | 86 | m_assetService = StartAssetService(cache); |
80 | m_authenticationService = StartAuthenticationService(); | 87 | m_authenticationService = StartAuthenticationService(); |
81 | m_inventoryService = StartInventoryService(); | 88 | m_inventoryService = StartInventoryService(); |
@@ -186,6 +193,8 @@ namespace OpenSim.Tests.Common | |||
186 | testScene.LoginsDisabled = false; | 193 | testScene.LoginsDisabled = false; |
187 | testScene.RegisterRegionWithGrid(); | 194 | testScene.RegisterRegionWithGrid(); |
188 | 195 | ||
196 | SceneManager.Add(testScene); | ||
197 | |||
189 | return testScene; | 198 | return testScene; |
190 | } | 199 | } |
191 | 200 | ||
@@ -350,6 +359,7 @@ namespace OpenSim.Tests.Common | |||
350 | List<IRegionModuleBase> newModules = new List<IRegionModuleBase>(); | 359 | List<IRegionModuleBase> newModules = new List<IRegionModuleBase>(); |
351 | foreach (object module in modules) | 360 | foreach (object module in modules) |
352 | { | 361 | { |
362 | // Console.WriteLine("MODULE RAW {0}", module); | ||
353 | if (module is IRegionModule) | 363 | if (module is IRegionModule) |
354 | { | 364 | { |
355 | IRegionModule m = (IRegionModule)module; | 365 | IRegionModule m = (IRegionModule)module; |
@@ -367,6 +377,7 @@ namespace OpenSim.Tests.Common | |||
367 | // for the new system, everything has to be initialised first, | 377 | // for the new system, everything has to be initialised first, |
368 | // shared modules have to be post-initialised, then all get an AddRegion with the scene | 378 | // shared modules have to be post-initialised, then all get an AddRegion with the scene |
369 | IRegionModuleBase m = (IRegionModuleBase)module; | 379 | IRegionModuleBase m = (IRegionModuleBase)module; |
380 | // Console.WriteLine("MODULE {0}", m.Name); | ||
370 | m.Initialise(config); | 381 | m.Initialise(config); |
371 | newModules.Add(m); | 382 | newModules.Add(m); |
372 | } | 383 | } |
@@ -426,6 +437,10 @@ namespace OpenSim.Tests.Common | |||
426 | /// <summary> | 437 | /// <summary> |
427 | /// Add a root agent where the details of the agent connection (apart from the id) are unimportant for the test | 438 | /// Add a root agent where the details of the agent connection (apart from the id) are unimportant for the test |
428 | /// </summary> | 439 | /// </summary> |
440 | /// <remarks> | ||
441 | /// This can be used for tests where there is only one region or where there are multiple non-neighbour regions | ||
442 | /// and teleport doesn't take place. | ||
443 | /// </remarks> | ||
429 | /// <param name="scene"></param> | 444 | /// <param name="scene"></param> |
430 | /// <param name="agentId"></param> | 445 | /// <param name="agentId"></param> |
431 | /// <returns></returns> | 446 | /// <returns></returns> |
@@ -435,6 +450,18 @@ namespace OpenSim.Tests.Common | |||
435 | } | 450 | } |
436 | 451 | ||
437 | /// <summary> | 452 | /// <summary> |
453 | /// Add a root agent where the details of the agent connection (apart from the id) are unimportant for the test | ||
454 | /// </summary> | ||
455 | /// <param name="scene"></param> | ||
456 | /// <param name="agentId"></param> | ||
457 | /// <param name="sceneManager"></param> | ||
458 | /// <returns></returns> | ||
459 | public static ScenePresence AddScenePresence(Scene scene, UUID agentId, SceneManager sceneManager) | ||
460 | { | ||
461 | return AddScenePresence(scene, GenerateAgentData(agentId), sceneManager); | ||
462 | } | ||
463 | |||
464 | /// <summary> | ||
438 | /// Add a root agent. | 465 | /// Add a root agent. |
439 | /// </summary> | 466 | /// </summary> |
440 | /// <remarks> | 467 | /// <remarks> |
@@ -454,6 +481,30 @@ namespace OpenSim.Tests.Common | |||
454 | /// <returns></returns> | 481 | /// <returns></returns> |
455 | public static ScenePresence AddScenePresence(Scene scene, AgentCircuitData agentData) | 482 | public static ScenePresence AddScenePresence(Scene scene, AgentCircuitData agentData) |
456 | { | 483 | { |
484 | return AddScenePresence(scene, agentData, null); | ||
485 | } | ||
486 | |||
487 | /// <summary> | ||
488 | /// Add a root agent. | ||
489 | /// </summary> | ||
490 | /// <remarks> | ||
491 | /// This function | ||
492 | /// | ||
493 | /// 1) Tells the scene that an agent is coming. Normally, the login service (local if standalone, from the | ||
494 | /// userserver if grid) would give initial login data back to the client and separately tell the scene that the | ||
495 | /// agent was coming. | ||
496 | /// | ||
497 | /// 2) Connects the agent with the scene | ||
498 | /// | ||
499 | /// This function performs actions equivalent with notifying the scene that an agent is | ||
500 | /// coming and then actually connecting the agent to the scene. The one step missed out is the very first | ||
501 | /// </remarks> | ||
502 | /// <param name="scene"></param> | ||
503 | /// <param name="agentData"></param> | ||
504 | /// <param name="sceneManager"></param> | ||
505 | /// <returns></returns> | ||
506 | public static ScenePresence AddScenePresence(Scene scene, AgentCircuitData agentData, SceneManager sceneManager) | ||
507 | { | ||
457 | // We emulate the proper login sequence here by doing things in four stages | 508 | // We emulate the proper login sequence here by doing things in four stages |
458 | 509 | ||
459 | // Stage 0: login | 510 | // Stage 0: login |
@@ -463,7 +514,7 @@ namespace OpenSim.Tests.Common | |||
463 | lpsc.m_PresenceService.LoginAgent(agentData.AgentID.ToString(), agentData.SessionID, agentData.SecureSessionID); | 514 | lpsc.m_PresenceService.LoginAgent(agentData.AgentID.ToString(), agentData.SessionID, agentData.SecureSessionID); |
464 | 515 | ||
465 | // Stages 1 & 2 | 516 | // Stages 1 & 2 |
466 | ScenePresence sp = IntroduceClientToScene(scene, agentData, TeleportFlags.ViaLogin); | 517 | ScenePresence sp = IntroduceClientToScene(scene, sceneManager, agentData, TeleportFlags.ViaLogin); |
467 | 518 | ||
468 | // Stage 3: Complete the entrance into the region. This converts the child agent into a root agent. | 519 | // Stage 3: Complete the entrance into the region. This converts the child agent into a root agent. |
469 | sp.CompleteMovement(sp.ControllingClient, true); | 520 | sp.CompleteMovement(sp.ControllingClient, true); |
@@ -471,7 +522,20 @@ namespace OpenSim.Tests.Common | |||
471 | return sp; | 522 | return sp; |
472 | } | 523 | } |
473 | 524 | ||
474 | private static ScenePresence IntroduceClientToScene(Scene scene, AgentCircuitData agentData, TeleportFlags tf) | 525 | /// <summary> |
526 | /// Introduce an agent into the scene by adding a new client. | ||
527 | /// </summary> | ||
528 | /// <returns>The scene presence added</returns> | ||
529 | /// <param name='sceneManager'> | ||
530 | /// Scene manager. Can be null if there is only one region in the test or multiple regions that are not | ||
531 | /// neighbours and where no teleporting takes place. | ||
532 | /// </param> | ||
533 | /// <param name='scene'></param> | ||
534 | /// <param name='sceneManager></param> | ||
535 | /// <param name='agentData'></param> | ||
536 | /// <param name='tf'></param> | ||
537 | private static ScenePresence IntroduceClientToScene( | ||
538 | Scene scene, SceneManager sceneManager, AgentCircuitData agentData, TeleportFlags tf) | ||
475 | { | 539 | { |
476 | string reason; | 540 | string reason; |
477 | 541 | ||
@@ -480,7 +544,7 @@ namespace OpenSim.Tests.Common | |||
480 | Console.WriteLine("NewUserConnection failed: " + reason); | 544 | Console.WriteLine("NewUserConnection failed: " + reason); |
481 | 545 | ||
482 | // Stage 2: add the new client as a child agent to the scene | 546 | // Stage 2: add the new client as a child agent to the scene |
483 | TestClient client = new TestClient(agentData, scene); | 547 | TestClient client = new TestClient(agentData, scene, sceneManager); |
484 | scene.AddNewClient(client, PresenceType.User); | 548 | scene.AddNewClient(client, PresenceType.User); |
485 | 549 | ||
486 | return scene.GetScenePresence(agentData.AgentID); | 550 | return scene.GetScenePresence(agentData.AgentID); |
@@ -492,7 +556,7 @@ namespace OpenSim.Tests.Common | |||
492 | acd.child = true; | 556 | acd.child = true; |
493 | 557 | ||
494 | // XXX: ViaLogin may not be correct for child agents | 558 | // XXX: ViaLogin may not be correct for child agents |
495 | return IntroduceClientToScene(scene, acd, TeleportFlags.ViaLogin); | 559 | return IntroduceClientToScene(scene, null, acd, TeleportFlags.ViaLogin); |
496 | } | 560 | } |
497 | 561 | ||
498 | /// <summary> | 562 | /// <summary> |
diff --git a/OpenSim/Tests/Common/Mock/TestClient.cs b/OpenSim/Tests/Common/Mock/TestClient.cs index cb9840e..36049a1 100644 --- a/OpenSim/Tests/Common/Mock/TestClient.cs +++ b/OpenSim/Tests/Common/Mock/TestClient.cs | |||
@@ -46,12 +46,10 @@ 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 | // TODO: This is a really nasty (and temporary) means of telling the test client which scene to invoke setup | ||
50 | // methods on when a teleport is requested | ||
51 | public Scene TeleportTargetScene; | ||
52 | private TestClient TeleportSceneClient; | 49 | private TestClient TeleportSceneClient; |
53 | 50 | ||
54 | private Scene m_scene; | 51 | private Scene m_scene; |
52 | private SceneManager m_sceneManager; | ||
55 | 53 | ||
56 | // Properties so that we can get at received data for test purposes | 54 | // Properties so that we can get at received data for test purposes |
57 | public List<UUID> ReceivedOfflineNotifications { get; private set; } | 55 | public List<UUID> ReceivedOfflineNotifications { get; private set; } |
@@ -432,15 +430,29 @@ namespace OpenSim.Tests.Common.Mock | |||
432 | /// <summary> | 430 | /// <summary> |
433 | /// Constructor | 431 | /// Constructor |
434 | /// </summary> | 432 | /// </summary> |
433 | /// <remarks> | ||
434 | /// Can be used for a test where there is only one region or where there are multiple regions that are not | ||
435 | /// neighbours and where no teleporting takes place. In other situations, the constructor that takes in a | ||
436 | /// scene manager should be used. | ||
437 | /// </remarks> | ||
435 | /// <param name="agentData"></param> | 438 | /// <param name="agentData"></param> |
436 | /// <param name="scene"></param> | 439 | /// <param name="scene"></param> |
437 | public TestClient(AgentCircuitData agentData, Scene scene) | 440 | public TestClient(AgentCircuitData agentData, Scene scene) : this(agentData, scene, null) {} |
441 | |||
442 | /// <summary> | ||
443 | /// Constructor | ||
444 | /// </summary> | ||
445 | /// <param name="agentData"></param> | ||
446 | /// <param name="scene"></param> | ||
447 | /// <param name="sceneManager"></param> | ||
448 | public TestClient(AgentCircuitData agentData, Scene scene, SceneManager sceneManager) | ||
438 | { | 449 | { |
439 | m_agentId = agentData.AgentID; | 450 | m_agentId = agentData.AgentID; |
440 | m_firstName = agentData.firstname; | 451 | m_firstName = agentData.firstname; |
441 | m_lastName = agentData.lastname; | 452 | m_lastName = agentData.lastname; |
442 | m_circuitCode = agentData.circuitcode; | 453 | m_circuitCode = agentData.circuitcode; |
443 | m_scene = scene; | 454 | m_scene = scene; |
455 | m_sceneManager = sceneManager; | ||
444 | SessionId = agentData.SessionID; | 456 | SessionId = agentData.SessionID; |
445 | SecureSessionId = agentData.SecureSessionID; | 457 | SecureSessionId = agentData.SecureSessionID; |
446 | CapsSeedUrl = agentData.CapsPath; | 458 | CapsSeedUrl = agentData.CapsPath; |
@@ -590,8 +602,16 @@ namespace OpenSim.Tests.Common.Mock | |||
590 | AgentCircuitData newAgent = RequestClientInfo(); | 602 | AgentCircuitData newAgent = RequestClientInfo(); |
591 | 603 | ||
592 | // Stage 2: add the new client as a child agent to the scene | 604 | // Stage 2: add the new client as a child agent to the scene |
593 | TeleportSceneClient = new TestClient(newAgent, TeleportTargetScene); | 605 | uint x, y; |
594 | TeleportTargetScene.AddNewClient(TeleportSceneClient, PresenceType.User); | 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); | ||
595 | } | 615 | } |
596 | 616 | ||
597 | public virtual void SendRegionTeleport(ulong regionHandle, byte simAccess, IPEndPoint regionExternalEndPoint, | 617 | public virtual void SendRegionTeleport(ulong regionHandle, byte simAccess, IPEndPoint regionExternalEndPoint, |
@@ -601,6 +621,13 @@ namespace OpenSim.Tests.Common.Mock | |||
601 | 621 | ||
602 | CapsSeedUrl = capsURL; | 622 | CapsSeedUrl = capsURL; |
603 | 623 | ||
624 | // We don't do this here so that the source region can complete processing first in a single-threaded | ||
625 | // regression test scenario. The test itself will have to call CompleteTeleportClientSide() after a teleport | ||
626 | // CompleteTeleportClientSide(); | ||
627 | } | ||
628 | |||
629 | public void CompleteTeleportClientSide() | ||
630 | { | ||
604 | TeleportSceneClient.CompleteMovement(); | 631 | TeleportSceneClient.CompleteMovement(); |
605 | //TeleportTargetScene.AgentCrossing(newAgent.AgentID, new Vector3(90, 90, 90), false); | 632 | //TeleportTargetScene.AgentCrossing(newAgent.AgentID, new Vector3(90, 90, 90), false); |
606 | } | 633 | } |
diff --git a/OpenSim/Tests/Common/TestHelpers.cs b/OpenSim/Tests/Common/TestHelpers.cs index 5030d4b..6744fca 100644 --- a/OpenSim/Tests/Common/TestHelpers.cs +++ b/OpenSim/Tests/Common/TestHelpers.cs | |||
@@ -46,7 +46,8 @@ namespace OpenSim.Tests.Common | |||
46 | <!-- A1 uses PatternLayout --> | 46 | <!-- A1 uses PatternLayout --> |
47 | <layout type=""log4net.Layout.PatternLayout""> | 47 | <layout type=""log4net.Layout.PatternLayout""> |
48 | <!-- Print the date in ISO 8601 format --> | 48 | <!-- Print the date in ISO 8601 format --> |
49 | <conversionPattern value=""%date [%thread] %-5level %logger %ndc - %message%newline"" /> | 49 | <!-- <conversionPattern value=""%date [%thread] %-5level %logger %ndc - %message%newline"" /> --> |
50 | <conversionPattern value=""%date %message%newline"" /> | ||
50 | </layout> | 51 | </layout> |
51 | </appender> | 52 | </appender> |
52 | 53 | ||
@@ -62,9 +63,9 @@ namespace OpenSim.Tests.Common | |||
62 | Encoding.UTF8.GetBytes( | 63 | Encoding.UTF8.GetBytes( |
63 | // "<?xml version=\"1.0\" encoding=\"utf-8\" ?><configuration><log4net><root><level value=\"OFF\"/><appender-ref ref=\"A1\"/></root></log4net></configuration>"))); | 64 | // "<?xml version=\"1.0\" encoding=\"utf-8\" ?><configuration><log4net><root><level value=\"OFF\"/><appender-ref ref=\"A1\"/></root></log4net></configuration>"))); |
64 | //"<?xml version=\"1.0\" encoding=\"utf-8\" ?><configuration><log4net><root><level value=\"OFF\"/></root></log4net></configuration>"))); | 65 | //"<?xml version=\"1.0\" encoding=\"utf-8\" ?><configuration><log4net><root><level value=\"OFF\"/></root></log4net></configuration>"))); |
65 | //"<configuration><log4net><root><level value=\"OFF\"/></root></log4net></configuration>"))); | 66 | // "<configuration><log4net><root><level value=\"OFF\"/></root></log4net></configuration>")); |
66 | //"<configuration><log4net><root></root></log4net></configuration>"))); | 67 | // "<configuration><log4net><root></root></log4net></configuration>"))); |
67 | //"<configuration><log4net><root/></log4net></configuration>"))); | 68 | // "<configuration><log4net><root/></log4net></configuration>")); |
68 | "<log4net><root/></log4net>")); | 69 | "<log4net><root/></log4net>")); |
69 | 70 | ||
70 | public static bool AssertThisDelegateCausesArgumentException(TestDelegate d) | 71 | public static bool AssertThisDelegateCausesArgumentException(TestDelegate d) |