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 /OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs | |
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.
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs | 112 |
1 files changed, 105 insertions, 7 deletions
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 |