diff options
Diffstat (limited to 'OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs')
-rw-r--r-- | OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs | 213 |
1 files changed, 58 insertions, 155 deletions
diff --git a/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs b/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs index 8b16496..aa4b285 100644 --- a/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs +++ b/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs | |||
@@ -57,21 +57,12 @@ namespace OpenSim.Tests.Common.Setup | |||
57 | /// </summary> | 57 | /// </summary> |
58 | public class SceneSetupHelpers | 58 | public class SceneSetupHelpers |
59 | { | 59 | { |
60 | // These static variables in order to allow regions to be linked by shared modules and same | ||
61 | // CommunicationsManager. | ||
62 | private static ISharedRegionModule m_assetService = null; | ||
63 | // private static ISharedRegionModule m_authenticationService = null; | ||
64 | private static ISharedRegionModule m_inventoryService = null; | ||
65 | private static ISharedRegionModule m_gridService = null; | ||
66 | private static ISharedRegionModule m_userAccountService = null; | ||
67 | private static ISharedRegionModule m_presenceService = null; | ||
68 | |||
69 | /// <summary> | 60 | /// <summary> |
70 | /// Set up a test scene | 61 | /// Set up a test scene |
71 | /// </summary> | 62 | /// </summary> |
72 | /// | 63 | /// <remarks> |
73 | /// Automatically starts service threads, as would the normal runtime. | 64 | /// Automatically starts service threads, as would the normal runtime. |
74 | /// | 65 | /// </remarks> |
75 | /// <returns></returns> | 66 | /// <returns></returns> |
76 | public static TestScene SetupScene() | 67 | public static TestScene SetupScene() |
77 | { | 68 | { |
@@ -86,24 +77,9 @@ namespace OpenSim.Tests.Common.Setup | |||
86 | /// <returns></returns> | 77 | /// <returns></returns> |
87 | public static TestScene SetupScene(String realServices) | 78 | public static TestScene SetupScene(String realServices) |
88 | { | 79 | { |
89 | return SetupScene( | 80 | return SetupScene("Unit test region", UUID.Random(), 1000, 1000, realServices); |
90 | "Unit test region", UUID.Random(), 1000, 1000, realServices); | ||
91 | } | 81 | } |
92 | 82 | ||
93 | // REFACTORING PROBLEM. No idea what the difference is with the previous one | ||
94 | ///// <summary> | ||
95 | ///// Set up a test scene | ||
96 | ///// </summary> | ||
97 | ///// | ||
98 | ///// <param name="realServices">Starts real inventory and asset services, as opposed to mock ones, if true</param> | ||
99 | ///// <param name="cm">This should be the same if simulating two scenes within a standalone</param> | ||
100 | ///// <returns></returns> | ||
101 | //public static TestScene SetupScene(String realServices) | ||
102 | //{ | ||
103 | // return SetupScene( | ||
104 | // "Unit test region", UUID.Random(), 1000, 1000, ""); | ||
105 | //} | ||
106 | |||
107 | /// <summary> | 83 | /// <summary> |
108 | /// Set up a test scene | 84 | /// Set up a test scene |
109 | /// </summary> | 85 | /// </summary> |
@@ -115,7 +91,7 @@ namespace OpenSim.Tests.Common.Setup | |||
115 | /// <returns></returns> | 91 | /// <returns></returns> |
116 | public static TestScene SetupScene(string name, UUID id, uint x, uint y) | 92 | public static TestScene SetupScene(string name, UUID id, uint x, uint y) |
117 | { | 93 | { |
118 | return SetupScene(name, id, x, y,""); | 94 | return SetupScene(name, id, x, y, ""); |
119 | } | 95 | } |
120 | 96 | ||
121 | /// <summary> | 97 | /// <summary> |
@@ -132,24 +108,11 @@ namespace OpenSim.Tests.Common.Setup | |||
132 | public static TestScene SetupScene( | 108 | public static TestScene SetupScene( |
133 | string name, UUID id, uint x, uint y, String realServices) | 109 | string name, UUID id, uint x, uint y, String realServices) |
134 | { | 110 | { |
135 | bool newScene = false; | ||
136 | |||
137 | Console.WriteLine("Setting up test scene {0}", name); | 111 | Console.WriteLine("Setting up test scene {0}", name); |
138 | 112 | ||
139 | // REFACTORING PROBLEM! | ||
140 | //// If cm is the same as our last commsManager used, this means the tester wants to link | ||
141 | //// regions. In this case, don't use the sameshared region modules and dont initialize them again. | ||
142 | //// Also, no need to start another MainServer and MainConsole instance. | ||
143 | //if (cm == null || cm != commsManager) | ||
144 | //{ | ||
145 | // System.Console.WriteLine("Starting a brand new scene"); | ||
146 | // newScene = true; | ||
147 | MainConsole.Instance = new MockConsole("TEST PROMPT"); | ||
148 | // MainServer.Instance = new BaseHttpServer(980); | ||
149 | // commsManager = cm; | ||
150 | //} | ||
151 | |||
152 | // We must set up a console otherwise setup of some modules may fail | 113 | // We must set up a console otherwise setup of some modules may fail |
114 | MainConsole.Instance = new MockConsole("TEST PROMPT"); | ||
115 | |||
153 | RegionInfo regInfo = new RegionInfo(x, y, new IPEndPoint(IPAddress.Loopback, 9000), "127.0.0.1"); | 116 | RegionInfo regInfo = new RegionInfo(x, y, new IPEndPoint(IPAddress.Loopback, 9000), "127.0.0.1"); |
154 | regInfo.RegionName = name; | 117 | regInfo.RegionName = name; |
155 | regInfo.RegionID = id; | 118 | regInfo.RegionID = id; |
@@ -164,55 +127,26 @@ namespace OpenSim.Tests.Common.Setup | |||
164 | TestScene testScene = new TestScene( | 127 | TestScene testScene = new TestScene( |
165 | regInfo, acm, scs, simDataService, estateDataService, null, false, false, false, configSource, null); | 128 | regInfo, acm, scs, simDataService, estateDataService, null, false, false, false, configSource, null); |
166 | 129 | ||
167 | INonSharedRegionModule capsModule = new CapabilitiesModule(); | ||
168 | capsModule.Initialise(new IniConfigSource()); | ||
169 | testScene.AddRegionModule(capsModule.Name, capsModule); | ||
170 | capsModule.AddRegion(testScene); | ||
171 | |||
172 | IRegionModule godsModule = new GodsModule(); | 130 | IRegionModule godsModule = new GodsModule(); |
173 | godsModule.Initialise(testScene, new IniConfigSource()); | 131 | godsModule.Initialise(testScene, new IniConfigSource()); |
174 | testScene.AddModule(godsModule.Name, godsModule); | 132 | testScene.AddModule(godsModule.Name, godsModule); |
175 | realServices = realServices.ToLower(); | 133 | realServices = realServices.ToLower(); |
176 | // IConfigSource config = new IniConfigSource(); | ||
177 | 134 | ||
178 | // If we have a brand new scene, need to initialize shared region modules | 135 | LocalAssetServicesConnector assetService = StartAssetService(testScene, realServices.Contains("asset")); |
179 | if ((m_assetService == null && m_inventoryService == null) || newScene) | ||
180 | { | ||
181 | if (realServices.Contains("asset")) | ||
182 | StartAssetService(testScene, true); | ||
183 | else | ||
184 | StartAssetService(testScene, false); | ||
185 | |||
186 | // For now, always started a 'real' authentication service | ||
187 | StartAuthenticationService(testScene, true); | ||
188 | |||
189 | if (realServices.Contains("inventory")) | ||
190 | StartInventoryService(testScene, true); | ||
191 | else | ||
192 | StartInventoryService(testScene, false); | ||
193 | |||
194 | StartGridService(testScene, true); | ||
195 | StartUserAccountService(testScene); | ||
196 | StartPresenceService(testScene); | ||
197 | } | ||
198 | // If not, make sure the shared module gets references to this new scene | ||
199 | else | ||
200 | { | ||
201 | m_assetService.AddRegion(testScene); | ||
202 | m_assetService.RegionLoaded(testScene); | ||
203 | m_inventoryService.AddRegion(testScene); | ||
204 | m_inventoryService.RegionLoaded(testScene); | ||
205 | m_userAccountService.AddRegion(testScene); | ||
206 | m_userAccountService.RegionLoaded(testScene); | ||
207 | m_presenceService.AddRegion(testScene); | ||
208 | m_presenceService.RegionLoaded(testScene); | ||
209 | 136 | ||
210 | } | 137 | // For now, always started a 'real' authentication service |
138 | StartAuthenticationService(testScene, true); | ||
139 | |||
140 | LocalInventoryServicesConnector inventoryService = StartInventoryService(testScene, realServices.Contains("inventory")); | ||
141 | StartGridService(testScene, true); | ||
142 | LocalUserAccountServicesConnector userAccountService = StartUserAccountService(testScene); | ||
143 | LocalPresenceServicesConnector presenceService = StartPresenceService(testScene); | ||
211 | 144 | ||
212 | m_inventoryService.PostInitialise(); | 145 | inventoryService.PostInitialise(); |
213 | m_assetService.PostInitialise(); | 146 | assetService.PostInitialise(); |
214 | m_userAccountService.PostInitialise(); | 147 | userAccountService.PostInitialise(); |
215 | m_presenceService.PostInitialise(); | 148 | presenceService.PostInitialise(); |
149 | |||
216 | testScene.RegionInfo.EstateSettings.EstateOwner = UUID.Random(); | 150 | testScene.RegionInfo.EstateSettings.EstateOwner = UUID.Random(); |
217 | testScene.SetModuleInterfaces(); | 151 | testScene.SetModuleInterfaces(); |
218 | 152 | ||
@@ -224,24 +158,15 @@ namespace OpenSim.Tests.Common.Setup | |||
224 | testScene.PhysicsScene | 158 | testScene.PhysicsScene |
225 | = physicsPluginManager.GetPhysicsScene("basicphysics", "ZeroMesher", new IniConfigSource(), "test"); | 159 | = physicsPluginManager.GetPhysicsScene("basicphysics", "ZeroMesher", new IniConfigSource(), "test"); |
226 | 160 | ||
227 | // It's really not a good idea to use static variables as they carry over between tests, leading to | ||
228 | // problems that are extremely hard to debug. Really, these static fields need to be eliminated - | ||
229 | // tests using multiple regions that need to share modules need to find another solution. | ||
230 | m_assetService = null; | ||
231 | m_inventoryService = null; | ||
232 | m_gridService = null; | ||
233 | m_userAccountService = null; | ||
234 | m_presenceService = null; | ||
235 | |||
236 | testScene.RegionInfo.EstateSettings = new EstateSettings(); | 161 | testScene.RegionInfo.EstateSettings = new EstateSettings(); |
237 | testScene.LoginsDisabled = false; | 162 | testScene.LoginsDisabled = false; |
238 | 163 | ||
239 | return testScene; | 164 | return testScene; |
240 | } | 165 | } |
241 | 166 | ||
242 | private static void StartAssetService(Scene testScene, bool real) | 167 | private static LocalAssetServicesConnector StartAssetService(Scene testScene, bool real) |
243 | { | 168 | { |
244 | ISharedRegionModule assetService = new LocalAssetServicesConnector(); | 169 | LocalAssetServicesConnector assetService = new LocalAssetServicesConnector(); |
245 | IConfigSource config = new IniConfigSource(); | 170 | IConfigSource config = new IniConfigSource(); |
246 | config.AddConfig("Modules"); | 171 | config.AddConfig("Modules"); |
247 | config.AddConfig("AssetService"); | 172 | config.AddConfig("AssetService"); |
@@ -255,7 +180,8 @@ namespace OpenSim.Tests.Common.Setup | |||
255 | assetService.AddRegion(testScene); | 180 | assetService.AddRegion(testScene); |
256 | assetService.RegionLoaded(testScene); | 181 | assetService.RegionLoaded(testScene); |
257 | testScene.AddRegionModule(assetService.Name, assetService); | 182 | testScene.AddRegionModule(assetService.Name, assetService); |
258 | m_assetService = assetService; | 183 | |
184 | return assetService; | ||
259 | } | 185 | } |
260 | 186 | ||
261 | private static void StartAuthenticationService(Scene testScene, bool real) | 187 | private static void StartAuthenticationService(Scene testScene, bool real) |
@@ -279,9 +205,9 @@ namespace OpenSim.Tests.Common.Setup | |||
279 | //m_authenticationService = service; | 205 | //m_authenticationService = service; |
280 | } | 206 | } |
281 | 207 | ||
282 | private static void StartInventoryService(Scene testScene, bool real) | 208 | private static LocalInventoryServicesConnector StartInventoryService(Scene testScene, bool real) |
283 | { | 209 | { |
284 | ISharedRegionModule inventoryService = new LocalInventoryServicesConnector(); | 210 | LocalInventoryServicesConnector inventoryService = new LocalInventoryServicesConnector(); |
285 | IConfigSource config = new IniConfigSource(); | 211 | IConfigSource config = new IniConfigSource(); |
286 | config.AddConfig("Modules"); | 212 | config.AddConfig("Modules"); |
287 | config.AddConfig("InventoryService"); | 213 | config.AddConfig("InventoryService"); |
@@ -301,10 +227,11 @@ namespace OpenSim.Tests.Common.Setup | |||
301 | inventoryService.AddRegion(testScene); | 227 | inventoryService.AddRegion(testScene); |
302 | inventoryService.RegionLoaded(testScene); | 228 | inventoryService.RegionLoaded(testScene); |
303 | testScene.AddRegionModule(inventoryService.Name, inventoryService); | 229 | testScene.AddRegionModule(inventoryService.Name, inventoryService); |
304 | m_inventoryService = inventoryService; | 230 | |
231 | return inventoryService; | ||
305 | } | 232 | } |
306 | 233 | ||
307 | private static void StartGridService(Scene testScene, bool real) | 234 | private static LocalGridServicesConnector StartGridService(Scene testScene, bool real) |
308 | { | 235 | { |
309 | IConfigSource config = new IniConfigSource(); | 236 | IConfigSource config = new IniConfigSource(); |
310 | config.AddConfig("Modules"); | 237 | config.AddConfig("Modules"); |
@@ -313,24 +240,25 @@ namespace OpenSim.Tests.Common.Setup | |||
313 | config.Configs["GridService"].Set("StorageProvider", "OpenSim.Data.Null.dll:NullRegionData"); | 240 | config.Configs["GridService"].Set("StorageProvider", "OpenSim.Data.Null.dll:NullRegionData"); |
314 | if (real) | 241 | if (real) |
315 | config.Configs["GridService"].Set("LocalServiceModule", "OpenSim.Services.GridService.dll:GridService"); | 242 | config.Configs["GridService"].Set("LocalServiceModule", "OpenSim.Services.GridService.dll:GridService"); |
316 | if (m_gridService == null) | 243 | |
317 | { | 244 | LocalGridServicesConnector gridService = new LocalGridServicesConnector(); |
318 | ISharedRegionModule gridService = new LocalGridServicesConnector(); | 245 | gridService.Initialise(config); |
319 | gridService.Initialise(config); | 246 | |
320 | m_gridService = gridService; | ||
321 | } | ||
322 | //else | 247 | //else |
323 | // config.Configs["GridService"].Set("LocalServiceModule", "OpenSim.Tests.Common.dll:TestGridService"); | 248 | // config.Configs["GridService"].Set("LocalServiceModule", "OpenSim.Tests.Common.dll:TestGridService"); |
324 | m_gridService.AddRegion(testScene); | 249 | gridService.AddRegion(testScene); |
325 | m_gridService.RegionLoaded(testScene); | 250 | gridService.RegionLoaded(testScene); |
326 | //testScene.AddRegionModule(m_gridService.Name, m_gridService); | 251 | //testScene.AddRegionModule(m_gridService.Name, m_gridService); |
252 | |||
253 | return gridService; | ||
327 | } | 254 | } |
328 | 255 | ||
329 | /// <summary> | 256 | /// <summary> |
330 | /// Start a user account service | 257 | /// Start a user account service |
331 | /// </summary> | 258 | /// </summary> |
332 | /// <param name="testScene"></param> | 259 | /// <param name="testScene"></param> |
333 | private static void StartUserAccountService(Scene testScene) | 260 | /// <returns></returns> |
261 | private static LocalUserAccountServicesConnector StartUserAccountService(Scene testScene) | ||
334 | { | 262 | { |
335 | IConfigSource config = new IniConfigSource(); | 263 | IConfigSource config = new IniConfigSource(); |
336 | config.AddConfig("Modules"); | 264 | config.AddConfig("Modules"); |
@@ -340,23 +268,21 @@ namespace OpenSim.Tests.Common.Setup | |||
340 | config.Configs["UserAccountService"].Set( | 268 | config.Configs["UserAccountService"].Set( |
341 | "LocalServiceModule", "OpenSim.Services.UserAccountService.dll:UserAccountService"); | 269 | "LocalServiceModule", "OpenSim.Services.UserAccountService.dll:UserAccountService"); |
342 | 270 | ||
343 | if (m_userAccountService == null) | 271 | LocalUserAccountServicesConnector userAccountService = new LocalUserAccountServicesConnector(); |
344 | { | 272 | userAccountService.Initialise(config); |
345 | ISharedRegionModule userAccountService = new LocalUserAccountServicesConnector(); | ||
346 | userAccountService.Initialise(config); | ||
347 | m_userAccountService = userAccountService; | ||
348 | } | ||
349 | 273 | ||
350 | m_userAccountService.AddRegion(testScene); | 274 | userAccountService.AddRegion(testScene); |
351 | m_userAccountService.RegionLoaded(testScene); | 275 | userAccountService.RegionLoaded(testScene); |
352 | testScene.AddRegionModule(m_userAccountService.Name, m_userAccountService); | 276 | testScene.AddRegionModule(userAccountService.Name, userAccountService); |
277 | |||
278 | return userAccountService; | ||
353 | } | 279 | } |
354 | 280 | ||
355 | /// <summary> | 281 | /// <summary> |
356 | /// Start a presence service | 282 | /// Start a presence service |
357 | /// </summary> | 283 | /// </summary> |
358 | /// <param name="testScene"></param> | 284 | /// <param name="testScene"></param> |
359 | private static void StartPresenceService(Scene testScene) | 285 | private static LocalPresenceServicesConnector StartPresenceService(Scene testScene) |
360 | { | 286 | { |
361 | IConfigSource config = new IniConfigSource(); | 287 | IConfigSource config = new IniConfigSource(); |
362 | config.AddConfig("Modules"); | 288 | config.AddConfig("Modules"); |
@@ -366,16 +292,14 @@ namespace OpenSim.Tests.Common.Setup | |||
366 | config.Configs["PresenceService"].Set( | 292 | config.Configs["PresenceService"].Set( |
367 | "LocalServiceModule", "OpenSim.Services.PresenceService.dll:PresenceService"); | 293 | "LocalServiceModule", "OpenSim.Services.PresenceService.dll:PresenceService"); |
368 | 294 | ||
369 | if (m_presenceService == null) | 295 | LocalPresenceServicesConnector presenceService = new LocalPresenceServicesConnector(); |
370 | { | 296 | presenceService.Initialise(config); |
371 | ISharedRegionModule presenceService = new LocalPresenceServicesConnector(); | ||
372 | presenceService.Initialise(config); | ||
373 | m_presenceService = presenceService; | ||
374 | } | ||
375 | 297 | ||
376 | m_presenceService.AddRegion(testScene); | 298 | presenceService.AddRegion(testScene); |
377 | m_presenceService.RegionLoaded(testScene); | 299 | presenceService.RegionLoaded(testScene); |
378 | testScene.AddRegionModule(m_presenceService.Name, m_presenceService); | 300 | testScene.AddRegionModule(presenceService.Name, presenceService); |
301 | |||
302 | return presenceService; | ||
379 | } | 303 | } |
380 | 304 | ||
381 | /// <summary> | 305 | /// <summary> |
@@ -472,7 +396,7 @@ namespace OpenSim.Tests.Common.Setup | |||
472 | /// <summary> | 396 | /// <summary> |
473 | /// Add a root agent. | 397 | /// Add a root agent. |
474 | /// </summary> | 398 | /// </summary> |
475 | /// | 399 | /// <remarks> |
476 | /// This function | 400 | /// This function |
477 | /// | 401 | /// |
478 | /// 1) Tells the scene that an agent is coming. Normally, the login service (local if standalone, from the | 402 | /// 1) Tells the scene that an agent is coming. Normally, the login service (local if standalone, from the |
@@ -483,7 +407,7 @@ namespace OpenSim.Tests.Common.Setup | |||
483 | /// | 407 | /// |
484 | /// This function performs actions equivalent with notifying the scene that an agent is | 408 | /// This function performs actions equivalent with notifying the scene that an agent is |
485 | /// coming and then actually connecting the agent to the scene. The one step missed out is the very first | 409 | /// coming and then actually connecting the agent to the scene. The one step missed out is the very first |
486 | /// | 410 | /// </remarks> |
487 | /// <param name="scene"></param> | 411 | /// <param name="scene"></param> |
488 | /// <param name="agentData"></param> | 412 | /// <param name="agentData"></param> |
489 | /// <returns></returns> | 413 | /// <returns></returns> |
@@ -504,12 +428,10 @@ namespace OpenSim.Tests.Common.Setup | |||
504 | TestClient client = new TestClient(agentData, scene); | 428 | TestClient client = new TestClient(agentData, scene); |
505 | scene.AddNewClient(client); | 429 | scene.AddNewClient(client); |
506 | 430 | ||
507 | // Stage 3: Invoke agent crossing, which converts the child agent into a root agent (with appearance, | 431 | // Stage 3: Complete the entrance into the region. This converts the child agent into a root agent. |
508 | // inventory, etc.) | ||
509 | //scene.AgentCrossing(agentData.AgentID, new Vector3(90, 90, 90), false); OBSOLETE | ||
510 | |||
511 | ScenePresence scp = scene.GetScenePresence(agentData.AgentID); | 432 | ScenePresence scp = scene.GetScenePresence(agentData.AgentID); |
512 | scp.MakeRootAgent(new Vector3(90, 90, 90), true); | 433 | scp.CompleteMovement(client); |
434 | //scp.MakeRootAgent(new Vector3(90, 90, 90), true); | ||
513 | 435 | ||
514 | return client; | 436 | return client; |
515 | } | 437 | } |
@@ -543,24 +465,5 @@ namespace OpenSim.Tests.Common.Setup | |||
543 | 465 | ||
544 | return part; | 466 | return part; |
545 | } | 467 | } |
546 | |||
547 | /// <summary> | ||
548 | /// Delete a scene object asynchronously | ||
549 | /// </summary> | ||
550 | /// <param name="scene"></param> | ||
551 | /// <param name="part"></param> | ||
552 | /// <param name="action"></param> | ||
553 | /// <param name="destinationId"></param> | ||
554 | /// <param name="client"></param> | ||
555 | public static void DeleteSceneObjectAsync( | ||
556 | TestScene scene, SceneObjectPart part, DeRezAction action, UUID destinationId, IClientAPI client) | ||
557 | { | ||
558 | // Turn off the timer on the async sog deleter - we'll crank it by hand within a unit test | ||
559 | AsyncSceneObjectGroupDeleter sogd = scene.SceneObjectGroupDeleter; | ||
560 | sogd.Enabled = false; | ||
561 | |||
562 | scene.DeRezObjects(client, new List<uint>() { part.LocalId }, UUID.Zero, action, destinationId); | ||
563 | sogd.InventoryDeQueueAndDelete(); | ||
564 | } | ||
565 | } | 468 | } |
566 | } | 469 | } |