diff options
author | Justin Clark-Casey (justincc) | 2013-03-06 21:37:53 +0000 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2013-03-06 21:37:53 +0000 |
commit | 8960418e7d51a0f861e7b4cb800f007d76862c9c (patch) | |
tree | b0dba5bc7b0dd8a2a0e662fd0ee5690c30e07054 /OpenSim/Region/Framework/Scenes/Tests | |
parent | Fix bug in osGetPrimitiveParams() so that it works for prims with the same ow... (diff) | |
download | opensim-SC_OLD-8960418e7d51a0f861e7b4cb800f007d76862c9c.zip opensim-SC_OLD-8960418e7d51a0f861e7b4cb800f007d76862c9c.tar.gz opensim-SC_OLD-8960418e7d51a0f861e7b4cb800f007d76862c9c.tar.bz2 opensim-SC_OLD-8960418e7d51a0f861e7b4cb800f007d76862c9c.tar.xz |
Add regression test for presence crossing between regions on the same simulator.
Unlike a much earlier commented out version of this test, this is done in synchronous mode.
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/Tests')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAgentTests.cs | 103 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Tests/ScenePresenceCrossingTests.cs | 140 |
2 files changed, 140 insertions, 103 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAgentTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAgentTests.cs index 5faf131..bbfbbfc 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAgentTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAgentTests.cs | |||
@@ -289,108 +289,5 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
289 | // | 289 | // |
290 | // Assert.That(presence, Is.Null, "presence is not null"); | 290 | // Assert.That(presence, Is.Null, "presence is not null"); |
291 | // } | 291 | // } |
292 | |||
293 | // I'm commenting this test because it does not represent | ||
294 | // crossings. The Thread.Sleep's in here are not meaningful mocks, | ||
295 | // and they sometimes fail in panda. | ||
296 | // We need to talk in order to develop a test | ||
297 | // that really tests region crossings. There are 3 async components, | ||
298 | // but things are synchronous among them. So there should be | ||
299 | // 3 threads in here. | ||
300 | //[Test] | ||
301 | // public void T021_TestCrossToNewRegion() | ||
302 | // { | ||
303 | // TestHelpers.InMethod(); | ||
304 | // | ||
305 | // scene.RegisterRegionWithGrid(); | ||
306 | // scene2.RegisterRegionWithGrid(); | ||
307 | // | ||
308 | // // Adding child agent to region 1001 | ||
309 | // string reason; | ||
310 | // scene2.NewUserConnection(acd1,0, out reason); | ||
311 | // scene2.AddNewClient(testclient, PresenceType.User); | ||
312 | // | ||
313 | // ScenePresence presence = scene.GetScenePresence(agent1); | ||
314 | // presence.MakeRootAgent(new Vector3(0,unchecked(Constants.RegionSize-1),0), true); | ||
315 | // | ||
316 | // ScenePresence presence2 = scene2.GetScenePresence(agent1); | ||
317 | // | ||
318 | // // Adding neighbour region caps info to presence2 | ||
319 | // | ||
320 | // string cap = presence.ControllingClient.RequestClientInfo().CapsPath; | ||
321 | // presence2.AddNeighbourRegion(region1, cap); | ||
322 | // | ||
323 | // Assert.That(presence.IsChildAgent, Is.False, "Did not start root in origin region."); | ||
324 | // Assert.That(presence2.IsChildAgent, Is.True, "Is not a child on destination region."); | ||
325 | // | ||
326 | // // Cross to x+1 | ||
327 | // presence.AbsolutePosition = new Vector3(Constants.RegionSize+1,3,100); | ||
328 | // presence.Update(); | ||
329 | // | ||
330 | // EventWaitHandle wh = new EventWaitHandle (false, EventResetMode.AutoReset, "Crossing"); | ||
331 | // | ||
332 | // // Mimicking communication between client and server, by waiting OK from client | ||
333 | // // sent by TestClient.CrossRegion call. Originally, this is network comm. | ||
334 | // if (!wh.WaitOne(5000,false)) | ||
335 | // { | ||
336 | // presence.Update(); | ||
337 | // if (!wh.WaitOne(8000,false)) | ||
338 | // throw new ArgumentException("1 - Timeout waiting for signal/variable."); | ||
339 | // } | ||
340 | // | ||
341 | // // This is a TestClient specific method that fires OnCompleteMovementToRegion event, which | ||
342 | // // would normally be fired after receiving the reply packet from comm. done on the last line. | ||
343 | // testclient.CompleteMovement(); | ||
344 | // | ||
345 | // // Crossings are asynchronous | ||
346 | // int timer = 10; | ||
347 | // | ||
348 | // // Make sure cross hasn't already finished | ||
349 | // if (!presence.IsInTransit && !presence.IsChildAgent) | ||
350 | // { | ||
351 | // // If not and not in transit yet, give it some more time | ||
352 | // Thread.Sleep(5000); | ||
353 | // } | ||
354 | // | ||
355 | // // Enough time, should at least be in transit by now. | ||
356 | // while (presence.IsInTransit && timer > 0) | ||
357 | // { | ||
358 | // Thread.Sleep(1000); | ||
359 | // timer-=1; | ||
360 | // } | ||
361 | // | ||
362 | // Assert.That(timer,Is.GreaterThan(0),"Timed out waiting to cross 2->1."); | ||
363 | // Assert.That(presence.IsChildAgent, Is.True, "Did not complete region cross as expected."); | ||
364 | // Assert.That(presence2.IsChildAgent, Is.False, "Did not receive root status after receiving agent."); | ||
365 | // | ||
366 | // // Cross Back | ||
367 | // presence2.AbsolutePosition = new Vector3(-10, 3, 100); | ||
368 | // presence2.Update(); | ||
369 | // | ||
370 | // if (!wh.WaitOne(5000,false)) | ||
371 | // { | ||
372 | // presence2.Update(); | ||
373 | // if (!wh.WaitOne(8000,false)) | ||
374 | // throw new ArgumentException("2 - Timeout waiting for signal/variable."); | ||
375 | // } | ||
376 | // testclient.CompleteMovement(); | ||
377 | // | ||
378 | // if (!presence2.IsInTransit && !presence2.IsChildAgent) | ||
379 | // { | ||
380 | // // If not and not in transit yet, give it some more time | ||
381 | // Thread.Sleep(5000); | ||
382 | // } | ||
383 | // | ||
384 | // // Enough time, should at least be in transit by now. | ||
385 | // while (presence2.IsInTransit && timer > 0) | ||
386 | // { | ||
387 | // Thread.Sleep(1000); | ||
388 | // timer-=1; | ||
389 | // } | ||
390 | // | ||
391 | // Assert.That(timer,Is.GreaterThan(0),"Timed out waiting to cross 1->2."); | ||
392 | // Assert.That(presence2.IsChildAgent, Is.True, "Did not return from region as expected."); | ||
393 | // Assert.That(presence.IsChildAgent, Is.False, "Presence was not made root in old region again."); | ||
394 | // } | ||
395 | } | 292 | } |
396 | } \ No newline at end of file | 293 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceCrossingTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceCrossingTests.cs new file mode 100644 index 0000000..ef9fff5 --- /dev/null +++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceCrossingTests.cs | |||
@@ -0,0 +1,140 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Reflection; | ||
30 | using Nini.Config; | ||
31 | using NUnit.Framework; | ||
32 | using OpenMetaverse; | ||
33 | using OpenSim.Framework; | ||
34 | using OpenSim.Framework.Communications; | ||
35 | using OpenSim.Framework.Servers; | ||
36 | using OpenSim.Region.Framework.Interfaces; | ||
37 | using OpenSim.Region.CoreModules.Framework; | ||
38 | using OpenSim.Region.CoreModules.Framework.EntityTransfer; | ||
39 | using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation; | ||
40 | using OpenSim.Tests.Common; | ||
41 | using OpenSim.Tests.Common.Mock; | ||
42 | |||
43 | namespace OpenSim.Region.Framework.Scenes.Tests | ||
44 | { | ||
45 | [TestFixture] | ||
46 | public class ScenePresenceCrossingTests : OpenSimTestCase | ||
47 | { | ||
48 | [TestFixtureSetUp] | ||
49 | public void FixtureInit() | ||
50 | { | ||
51 | // Don't allow tests to be bamboozled by asynchronous events. Execute everything on the same thread. | ||
52 | Util.FireAndForgetMethod = FireAndForgetMethod.RegressionTest; | ||
53 | } | ||
54 | |||
55 | [TestFixtureTearDown] | ||
56 | public void TearDown() | ||
57 | { | ||
58 | // We must set this back afterwards, otherwise later tests will fail since they're expecting multiple | ||
59 | // threads. Possibly, later tests should be rewritten so none of them require async stuff (which regression | ||
60 | // tests really shouldn't). | ||
61 | Util.FireAndForgetMethod = Util.DefaultFireAndForgetMethod; | ||
62 | } | ||
63 | |||
64 | [Test] | ||
65 | public void TestCrossOnSameSimulator() | ||
66 | { | ||
67 | TestHelpers.InMethod(); | ||
68 | TestHelpers.EnableLogging(); | ||
69 | |||
70 | UUID userId = TestHelpers.ParseTail(0x1); | ||
71 | |||
72 | EntityTransferModule etmA = new EntityTransferModule(); | ||
73 | EntityTransferModule etmB = new EntityTransferModule(); | ||
74 | LocalSimulationConnectorModule lscm = new LocalSimulationConnectorModule(); | ||
75 | |||
76 | IConfigSource config = new IniConfigSource(); | ||
77 | IConfig modulesConfig = config.AddConfig("Modules"); | ||
78 | modulesConfig.Set("EntityTransferModule", etmA.Name); | ||
79 | modulesConfig.Set("SimulationServices", lscm.Name); | ||
80 | IConfig entityTransferConfig = config.AddConfig("EntityTransfer"); | ||
81 | |||
82 | // In order to run a single threaded regression test we do not want the entity transfer module waiting | ||
83 | // for a callback from the destination scene before removing its avatar data. | ||
84 | // entityTransferConfig.Set("wait_for_callback", false); | ||
85 | |||
86 | SceneHelpers sh = new SceneHelpers(); | ||
87 | TestScene sceneA = sh.SetupScene("sceneA", TestHelpers.ParseTail(0x100), 1000, 1000); | ||
88 | TestScene sceneB = sh.SetupScene("sceneB", TestHelpers.ParseTail(0x200), 1000, 999); | ||
89 | |||
90 | SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, config, lscm); | ||
91 | SceneHelpers.SetupSceneModules(sceneA, config, new CapabilitiesModule(), etmA); | ||
92 | SceneHelpers.SetupSceneModules(sceneB, config, new CapabilitiesModule(), etmB); | ||
93 | |||
94 | ScenePresence originalSp = SceneHelpers.AddScenePresence(sceneA, userId, sh.SceneManager); | ||
95 | originalSp.AbsolutePosition = new Vector3(128, 32, 10); | ||
96 | |||
97 | // originalSp.Flying = true; | ||
98 | |||
99 | // Console.WriteLine("First pos {0}", originalSp.AbsolutePosition); | ||
100 | |||
101 | AgentUpdateArgs moveArgs = new AgentUpdateArgs(); | ||
102 | //moveArgs.BodyRotation = Quaternion.CreateFromEulers(Vector3.Zero); | ||
103 | moveArgs.BodyRotation = Quaternion.CreateFromEulers(new Vector3(0, 0, (float)-(Math.PI / 2))); | ||
104 | moveArgs.ControlFlags = (uint)AgentManager.ControlFlags.AGENT_CONTROL_AT_POS; | ||
105 | |||
106 | originalSp.HandleAgentUpdate(originalSp.ControllingClient, moveArgs); | ||
107 | |||
108 | sceneA.Update(1); | ||
109 | |||
110 | // Console.WriteLine("Second pos {0}", originalSp.AbsolutePosition); | ||
111 | |||
112 | // FIXME: This is a sufficient number of updates to for the presence to reach the northern border. | ||
113 | // But really we want to do this in a more robust way. | ||
114 | for (int i = 0; i < 100; i++) | ||
115 | { | ||
116 | sceneA.Update(1); | ||
117 | // Console.WriteLine("Pos {0}", originalSp.AbsolutePosition); | ||
118 | } | ||
119 | |||
120 | // sceneA should now only have a child agent | ||
121 | ScenePresence spAfterCrossSceneA = sceneA.GetScenePresence(originalSp.UUID); | ||
122 | Assert.That(spAfterCrossSceneA.IsChildAgent, Is.True); | ||
123 | |||
124 | ScenePresence spAfterCrossSceneB = sceneB.GetScenePresence(originalSp.UUID); | ||
125 | |||
126 | // Agent remains a child until the client triggers complete movement | ||
127 | Assert.That(spAfterCrossSceneB.IsChildAgent, Is.True); | ||
128 | |||
129 | TestClient sceneBTc = ((TestClient)spAfterCrossSceneB.ControllingClient); | ||
130 | |||
131 | bool receivedCompleteMovement = false; | ||
132 | sceneBTc.OnReceivedMoveAgentIntoRegion += (ri, pos, look) => receivedCompleteMovement = true; | ||
133 | |||
134 | sceneBTc.CompleteMovement(); | ||
135 | |||
136 | Assert.That(receivedCompleteMovement, Is.True); | ||
137 | Assert.That(spAfterCrossSceneB.IsChildAgent, Is.False); | ||
138 | } | ||
139 | } | ||
140 | } \ No newline at end of file | ||