clockwerk-opensim-stable – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | vero | 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.Collections.Generic; |
||
30 | using System.Reflection; |
||
31 | using System.Text; |
||
32 | using System.Threading; |
||
33 | using System.Timers; |
||
34 | using Timer = System.Timers.Timer; |
||
35 | using Nini.Config; |
||
36 | using NUnit.Framework; |
||
37 | using OpenMetaverse; |
||
38 | using OpenSim.Framework; |
||
39 | using OpenSim.Framework.Communications; |
||
40 | using OpenSim.Region.Framework.Scenes; |
||
41 | using OpenSim.Region.Framework.Interfaces; |
||
42 | using OpenSim.Region.ClientStack.Linden; |
||
43 | using OpenSim.Region.CoreModules.Framework.EntityTransfer; |
||
44 | using OpenSim.Region.CoreModules.World.Serialiser; |
||
45 | using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation; |
||
46 | using OpenSim.Tests.Common; |
||
47 | using OpenSim.Tests.Common.Mock; |
||
48 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; |
||
49 | |||
50 | namespace OpenSim.Region.Framework.Scenes.Tests |
||
51 | { |
||
52 | /// <summary> |
||
53 | /// Scene presence tests |
||
54 | /// </summary> |
||
55 | [TestFixture] |
||
56 | public class ScenePresenceAgentTests : OpenSimTestCase |
||
57 | { |
||
58 | // public Scene scene, scene2, scene3; |
||
59 | // public UUID agent1, agent2, agent3; |
||
60 | // public static Random random; |
||
61 | // public ulong region1, region2, region3; |
||
62 | // public AgentCircuitData acd1; |
||
63 | // public TestClient testclient; |
||
64 | |||
65 | // [TestFixtureSetUp] |
||
66 | // public void Init() |
||
67 | // { |
||
68 | //// TestHelpers.InMethod(); |
||
69 | //// |
||
70 | //// SceneHelpers sh = new SceneHelpers(); |
||
71 | //// |
||
72 | //// scene = sh.SetupScene("Neighbour x", UUID.Random(), 1000, 1000); |
||
73 | //// scene2 = sh.SetupScene("Neighbour x+1", UUID.Random(), 1001, 1000); |
||
74 | //// scene3 = sh.SetupScene("Neighbour x-1", UUID.Random(), 999, 1000); |
||
75 | //// |
||
76 | //// ISharedRegionModule interregionComms = new LocalSimulationConnectorModule(); |
||
77 | //// interregionComms.Initialise(new IniConfigSource()); |
||
78 | //// interregionComms.PostInitialise(); |
||
79 | //// SceneHelpers.SetupSceneModules(scene, new IniConfigSource(), interregionComms); |
||
80 | //// SceneHelpers.SetupSceneModules(scene2, new IniConfigSource(), interregionComms); |
||
81 | //// SceneHelpers.SetupSceneModules(scene3, new IniConfigSource(), interregionComms); |
||
82 | // |
||
83 | //// agent1 = UUID.Random(); |
||
84 | //// agent2 = UUID.Random(); |
||
85 | //// agent3 = UUID.Random(); |
||
86 | // |
||
87 | //// region1 = scene.RegionInfo.RegionHandle; |
||
88 | //// region2 = scene2.RegionInfo.RegionHandle; |
||
89 | //// region3 = scene3.RegionInfo.RegionHandle; |
||
90 | // } |
||
91 | |||
92 | [Test] |
||
93 | public void TestCreateRootScenePresence() |
||
94 | { |
||
95 | TestHelpers.InMethod(); |
||
96 | // TestHelpers.EnableLogging(); |
||
97 | |||
98 | UUID spUuid = TestHelpers.ParseTail(0x1); |
||
99 | |||
100 | TestScene scene = new SceneHelpers().SetupScene(); |
||
101 | SceneHelpers.AddScenePresence(scene, spUuid); |
||
102 | |||
103 | Assert.That(scene.AuthenticateHandler.GetAgentCircuitData(spUuid), Is.Not.Null); |
||
104 | Assert.That(scene.AuthenticateHandler.GetAgentCircuits().Count, Is.EqualTo(1)); |
||
105 | |||
106 | ScenePresence sp = scene.GetScenePresence(spUuid); |
||
107 | Assert.That(sp, Is.Not.Null); |
||
108 | Assert.That(sp.IsChildAgent, Is.False); |
||
109 | Assert.That(sp.UUID, Is.EqualTo(spUuid)); |
||
110 | |||
111 | Assert.That(scene.GetScenePresences().Count, Is.EqualTo(1)); |
||
112 | } |
||
113 | |||
114 | /// <summary> |
||
115 | /// Test that duplicate complete movement calls are ignored. |
||
116 | /// </summary> |
||
117 | /// <remarks> |
||
118 | /// If duplicate calls are not ignored then there is a risk of race conditions or other unexpected effects. |
||
119 | /// </remarks> |
||
120 | [Test] |
||
121 | public void TestDupeCompleteMovementCalls() |
||
122 | { |
||
123 | TestHelpers.InMethod(); |
||
124 | // TestHelpers.EnableLogging(); |
||
125 | |||
126 | UUID spUuid = TestHelpers.ParseTail(0x1); |
||
127 | |||
128 | TestScene scene = new SceneHelpers().SetupScene(); |
||
129 | |||
130 | int makeRootAgentEvents = 0; |
||
131 | scene.EventManager.OnMakeRootAgent += spi => makeRootAgentEvents++; |
||
132 | |||
133 | ScenePresence sp = SceneHelpers.AddScenePresence(scene, spUuid); |
||
134 | |||
135 | Assert.That(makeRootAgentEvents, Is.EqualTo(1)); |
||
136 | |||
137 | // Normally these would be invoked by a CompleteMovement message coming in to the UDP stack. But for |
||
138 | // convenience, here we will invoke it manually. |
||
139 | sp.CompleteMovement(sp.ControllingClient, true); |
||
140 | |||
141 | Assert.That(makeRootAgentEvents, Is.EqualTo(1)); |
||
142 | |||
143 | // Check rest of exepcted parameters. |
||
144 | Assert.That(scene.AuthenticateHandler.GetAgentCircuitData(spUuid), Is.Not.Null); |
||
145 | Assert.That(scene.AuthenticateHandler.GetAgentCircuits().Count, Is.EqualTo(1)); |
||
146 | |||
147 | Assert.That(sp.IsChildAgent, Is.False); |
||
148 | Assert.That(sp.UUID, Is.EqualTo(spUuid)); |
||
149 | |||
150 | Assert.That(scene.GetScenePresences().Count, Is.EqualTo(1)); |
||
151 | } |
||
152 | |||
153 | [Test] |
||
154 | public void TestCreateDuplicateRootScenePresence() |
||
155 | { |
||
156 | TestHelpers.InMethod(); |
||
157 | // TestHelpers.EnableLogging(); |
||
158 | |||
159 | UUID spUuid = TestHelpers.ParseTail(0x1); |
||
160 | |||
161 | // The etm is only invoked by this test to check whether an agent is still in transit if there is a dupe |
||
162 | EntityTransferModule etm = new EntityTransferModule(); |
||
163 | |||
164 | IConfigSource config = new IniConfigSource(); |
||
165 | IConfig modulesConfig = config.AddConfig("Modules"); |
||
166 | modulesConfig.Set("EntityTransferModule", etm.Name); |
||
167 | IConfig entityTransferConfig = config.AddConfig("EntityTransfer"); |
||
168 | |||
169 | // In order to run a single threaded regression test we do not want the entity transfer module waiting |
||
170 | // for a callback from the destination scene before removing its avatar data. |
||
171 | entityTransferConfig.Set("wait_for_callback", false); |
||
172 | |||
173 | TestScene scene = new SceneHelpers().SetupScene(); |
||
174 | SceneHelpers.SetupSceneModules(scene, config, etm); |
||
175 | SceneHelpers.AddScenePresence(scene, spUuid); |
||
176 | SceneHelpers.AddScenePresence(scene, spUuid); |
||
177 | |||
178 | Assert.That(scene.AuthenticateHandler.GetAgentCircuitData(spUuid), Is.Not.Null); |
||
179 | Assert.That(scene.AuthenticateHandler.GetAgentCircuits().Count, Is.EqualTo(1)); |
||
180 | |||
181 | ScenePresence sp = scene.GetScenePresence(spUuid); |
||
182 | Assert.That(sp, Is.Not.Null); |
||
183 | Assert.That(sp.IsChildAgent, Is.False); |
||
184 | Assert.That(sp.UUID, Is.EqualTo(spUuid)); |
||
185 | } |
||
186 | |||
187 | [Test] |
||
188 | public void TestCloseClient() |
||
189 | { |
||
190 | TestHelpers.InMethod(); |
||
191 | // TestHelpers.EnableLogging(); |
||
192 | |||
193 | TestScene scene = new SceneHelpers().SetupScene(); |
||
194 | ScenePresence sp = SceneHelpers.AddScenePresence(scene, TestHelpers.ParseTail(0x1)); |
||
195 | |||
196 | scene.CloseAgent(sp.UUID, false); |
||
197 | |||
198 | Assert.That(scene.GetScenePresence(sp.UUID), Is.Null); |
||
199 | Assert.That(scene.AuthenticateHandler.GetAgentCircuitData(sp.UUID), Is.Null); |
||
200 | Assert.That(scene.AuthenticateHandler.GetAgentCircuits().Count, Is.EqualTo(0)); |
||
201 | |||
202 | // TestHelpers.DisableLogging(); |
||
203 | } |
||
204 | |||
205 | [Test] |
||
206 | public void TestCreateChildScenePresence() |
||
207 | { |
||
208 | TestHelpers.InMethod(); |
||
209 | // log4net.Config.XmlConfigurator.Configure(); |
||
210 | |||
211 | LocalSimulationConnectorModule lsc = new LocalSimulationConnectorModule(); |
||
212 | |||
213 | IConfigSource configSource = new IniConfigSource(); |
||
214 | IConfig config = configSource.AddConfig("Modules"); |
||
215 | config.Set("SimulationServices", "LocalSimulationConnectorModule"); |
||
216 | |||
217 | SceneHelpers sceneHelpers = new SceneHelpers(); |
||
218 | TestScene scene = sceneHelpers.SetupScene(); |
||
219 | SceneHelpers.SetupSceneModules(scene, configSource, lsc); |
||
220 | |||
221 | UUID agentId = TestHelpers.ParseTail(0x01); |
||
222 | AgentCircuitData acd = SceneHelpers.GenerateAgentData(agentId); |
||
223 | acd.child = true; |
||
224 | |||
225 | GridRegion region = scene.GridService.GetRegionByName(UUID.Zero, scene.RegionInfo.RegionName); |
||
226 | string reason; |
||
227 | |||
228 | // *** This is the first stage, when a neighbouring region is told that a viewer is about to try and |
||
229 | // establish a child scene presence. We pass in the circuit code that the client has to connect with *** |
||
230 | // XXX: ViaLogin may not be correct here. |
||
231 | scene.SimulationService.CreateAgent(region, acd, (uint)TeleportFlags.ViaLogin, out reason); |
||
232 | |||
233 | Assert.That(scene.AuthenticateHandler.GetAgentCircuitData(agentId), Is.Not.Null); |
||
234 | Assert.That(scene.AuthenticateHandler.GetAgentCircuits().Count, Is.EqualTo(1)); |
||
235 | |||
236 | // There's no scene presence yet since only an agent circuit has been established. |
||
237 | Assert.That(scene.GetScenePresence(agentId), Is.Null); |
||
238 | |||
239 | // *** This is the second stage, where the client established a child agent/scene presence using the |
||
240 | // circuit code given to the scene in stage 1 *** |
||
241 | TestClient client = new TestClient(acd, scene); |
||
242 | scene.AddNewAgent(client, PresenceType.User); |
||
243 | |||
244 | Assert.That(scene.AuthenticateHandler.GetAgentCircuitData(agentId), Is.Not.Null); |
||
245 | Assert.That(scene.AuthenticateHandler.GetAgentCircuits().Count, Is.EqualTo(1)); |
||
246 | |||
247 | ScenePresence sp = scene.GetScenePresence(agentId); |
||
248 | Assert.That(sp, Is.Not.Null); |
||
249 | Assert.That(sp.UUID, Is.EqualTo(agentId)); |
||
250 | Assert.That(sp.IsChildAgent, Is.True); |
||
251 | } |
||
252 | |||
253 | /// <summary> |
||
254 | /// Test that if a root agent logs into a region, a child agent is also established in the neighbouring region |
||
255 | /// </summary> |
||
256 | /// <remarks> |
||
257 | /// Please note that unlike the other tests here, this doesn't rely on anything set up in the instance fields. |
||
258 | /// INCOMPLETE |
||
259 | /// </remarks> |
||
260 | [Test] |
||
261 | public void TestChildAgentEstablishedInNeighbour() |
||
262 | { |
||
263 | TestHelpers.InMethod(); |
||
264 | // log4net.Config.XmlConfigurator.Configure(); |
||
265 | |||
266 | // UUID agent1Id = UUID.Parse("00000000-0000-0000-0000-000000000001"); |
||
267 | |||
268 | TestScene myScene1 = new SceneHelpers().SetupScene("Neighbour y", UUID.Random(), 1000, 1000); |
||
269 | TestScene myScene2 = new SceneHelpers().SetupScene("Neighbour y + 1", UUID.Random(), 1001, 1000); |
||
270 | |||
271 | IConfigSource configSource = new IniConfigSource(); |
||
272 | IConfig config = configSource.AddConfig("Startup"); |
||
273 | config.Set("serverside_object_permissions", true); |
||
274 | config.Set("EventQueue", true); |
||
275 | |||
276 | EntityTransferModule etm = new EntityTransferModule(); |
||
277 | |||
278 | EventQueueGetModule eqgm1 = new EventQueueGetModule(); |
||
279 | SceneHelpers.SetupSceneModules(myScene1, configSource, etm, eqgm1); |
||
280 | |||
281 | EventQueueGetModule eqgm2 = new EventQueueGetModule(); |
||
282 | SceneHelpers.SetupSceneModules(myScene2, configSource, etm, eqgm2); |
||
283 | |||
284 | // SceneHelpers.AddScenePresence(myScene1, agent1Id); |
||
285 | // ScenePresence childPresence = myScene2.GetScenePresence(agent1); |
||
286 | // |
||
287 | // // TODO: Need to do a fair amount of work to allow synchronous establishment of child agents |
||
288 | // Assert.That(childPresence, Is.Not.Null); |
||
289 | // Assert.That(childPresence.IsChildAgent, Is.True); |
||
290 | } |
||
291 | } |
||
292 | } |