public void TestChildAgentSingleRegionCapabilities() { TestHelpers.InMethod(); // TestHelpers.EnableLogging(); UUID spUuid = TestHelpers.ParseTail(0x1); // XXX: This is not great since the use of statics will mean that this has to be manually cleaned up for // any subsequent test. // XXX: May replace with a mock IHttpServer later. BaseHttpServer httpServer = new BaseHttpServer(99999); MainServer.AddHttpServer(httpServer); MainServer.Instance = httpServer; CapabilitiesModule capsMod = new CapabilitiesModule(); TestScene scene = new SceneHelpers().SetupScene(); SceneHelpers.SetupSceneModules(scene, capsMod); ScenePresence sp = SceneHelpers.AddChildScenePresence(scene, spUuid); Assert.That(capsMod.GetCapsForUser(spUuid), Is.Not.Null); // TODO: Need to add tests for other ICapabiltiesModule methods. scene.CloseAgent(sp.UUID, false); Assert.That(capsMod.GetCapsForUser(spUuid), Is.Null); // TODO: Need to add tests for other ICapabiltiesModule methods. }
public override void SetUp() { base.SetUp(); uint port = 9999; uint sslPort = 9998; // This is an unfortunate bit of clean up we have to do because MainServer manages things through static // variables and the VM is not restarted between tests. MainServer.RemoveHttpServer(port); BaseHttpServer server = new BaseHttpServer(port, false, sslPort, ""); MainServer.AddHttpServer(server); MainServer.Instance = server; IConfigSource config = new IniConfigSource(); config.AddConfig("Startup"); config.Configs["Startup"].Set("EventQueue", "true"); CapabilitiesModule capsModule = new CapabilitiesModule(); m_eqgMod = new EventQueueGetModule(); // For NPC test support config.AddConfig("NPC"); config.Configs["NPC"].Set("Enabled", "true"); m_npcMod = new NPCModule(); m_scene = new SceneHelpers().SetupScene(); SceneHelpers.SetupSceneModules(m_scene, config, capsModule, m_eqgMod, m_npcMod); }
public void SetUp() { MainServer.Instance = new BaseHttpServer(9999, false, 9998, ""); IConfigSource config = new IniConfigSource(); config.AddConfig("Startup"); config.Configs["Startup"].Set("EventQueue", "true"); CapabilitiesModule capsModule = new CapabilitiesModule(); EventQueueGetModule eqgModule = new EventQueueGetModule(); m_scene = SceneHelpers.SetupScene(); SceneHelpers.SetupSceneModules(m_scene, config, capsModule, eqgModule); }
/// <summary> /// Set up a test scene /// </summary> /// <param name="name">Name of the region</param> /// <param name="id">ID of the region</param> /// <param name="x">X co-ordinate of the region</param> /// <param name="y">Y co-ordinate of the region</param> /// <param name="cm">This should be the same if simulating two scenes within a standalone</param> /// <param name="startServices">Start associated threads for the services used by the scene</param> /// <returns></returns> public static TestScene SetupScene( string name, UUID id, uint x, uint y, TestCommunicationsManager cm, bool startServices) { Console.WriteLine("Setting up test scene {0}", name); RegionInfo regInfo = new RegionInfo(x, y, new IPEndPoint(IPAddress.Loopback, 9000), "127.0.0.1"); regInfo.RegionName = name; regInfo.RegionID = id; AgentCircuitManager acm = new AgentCircuitManager(); SceneCommunicationService scs = new SceneCommunicationService(cm); StorageManager sm = new StorageManager("OpenSim.Data.Null.dll", "", ""); IConfigSource configSource = new IniConfigSource(); TestScene testScene = new TestScene( regInfo, acm, cm, scs, sm, null, false, false, false, configSource, null); IRegionModule capsModule = new CapabilitiesModule(); capsModule.Initialise(testScene, new IniConfigSource()); testScene.AddModule(capsModule.Name, capsModule); IRegionModule godsModule = new GodsModule(); godsModule.Initialise(testScene, new IniConfigSource()); testScene.AddModule(godsModule.Name, godsModule); testScene.SetModuleInterfaces(); testScene.LandChannel = new TestLandChannel(); testScene.LoadWorldMap(); PhysicsPluginManager physicsPluginManager = new PhysicsPluginManager(); physicsPluginManager.LoadPluginsFromAssembly("Physics/OpenSim.Region.Physics.BasicPhysicsPlugin.dll"); testScene.PhysicsScene = physicsPluginManager.GetPhysicsScene("basicphysics", "ZeroMesher", configSource, "test"); if (startServices) { cm.StartServices(); } return(testScene); }
/// <summary> /// Set up a scene. If it's more then one scene, use the same CommunicationsManager to link regions /// or a different, to get a brand new scene with new shared region modules. /// </summary> /// <param name="name">Name of the region</param> /// <param name="id">ID of the region</param> /// <param name="x">X co-ordinate of the region</param> /// <param name="y">Y co-ordinate of the region</param> /// <param name="cm">This should be the same if simulating two scenes within a standalone</param> /// <param name="realServices">Starts real inventory and asset services, as opposed to mock ones, if true</param> /// <returns></returns> public static TestScene SetupScene( string name, UUID id, uint x, uint y, String realServices) { bool newScene = false; Console.WriteLine("Setting up test scene {0}", name); // REFACTORING PROBLEM! //// If cm is the same as our last commsManager used, this means the tester wants to link //// regions. In this case, don't use the sameshared region modules and dont initialize them again. //// Also, no need to start another MainServer and MainConsole instance. //if (cm == null || cm != commsManager) //{ // System.Console.WriteLine("Starting a brand new scene"); // newScene = true; MainConsole.Instance = new MockConsole("TEST PROMPT"); // MainServer.Instance = new BaseHttpServer(980); // commsManager = cm; //} // We must set up a console otherwise setup of some modules may fail RegionInfo regInfo = new RegionInfo(x, y, new IPEndPoint(IPAddress.Loopback, 9000), "127.0.0.1"); regInfo.RegionName = name; regInfo.RegionID = id; AgentCircuitManager acm = new AgentCircuitManager(); SceneCommunicationService scs = new SceneCommunicationService(); ISimulationDataService simDataService = OpenSim.Server.Base.ServerUtils.LoadPlugin <ISimulationDataService>("OpenSim.Tests.Common.dll", null); IEstateDataService estateDataService = null; IConfigSource configSource = new IniConfigSource(); TestScene testScene = new TestScene( regInfo, acm, scs, simDataService, estateDataService, null, false, false, false, configSource, null); INonSharedRegionModule capsModule = new CapabilitiesModule(); capsModule.Initialise(new IniConfigSource()); testScene.AddRegionModule(capsModule.Name, capsModule); capsModule.AddRegion(testScene); IRegionModule godsModule = new GodsModule(); godsModule.Initialise(testScene, new IniConfigSource()); testScene.AddModule(godsModule.Name, godsModule); realServices = realServices.ToLower(); // IConfigSource config = new IniConfigSource(); // If we have a brand new scene, need to initialize shared region modules if ((m_assetService == null && m_inventoryService == null) || newScene) { if (realServices.Contains("asset")) { StartAssetService(testScene, true); } else { StartAssetService(testScene, false); } // For now, always started a 'real' authentication service StartAuthenticationService(testScene, true); if (realServices.Contains("inventory")) { StartInventoryService(testScene, true); } else { StartInventoryService(testScene, false); } StartGridService(testScene, true); StartUserAccountService(testScene); StartPresenceService(testScene); } // If not, make sure the shared module gets references to this new scene else { m_assetService.AddRegion(testScene); m_assetService.RegionLoaded(testScene); m_inventoryService.AddRegion(testScene); m_inventoryService.RegionLoaded(testScene); m_userAccountService.AddRegion(testScene); m_userAccountService.RegionLoaded(testScene); m_presenceService.AddRegion(testScene); m_presenceService.RegionLoaded(testScene); } m_inventoryService.PostInitialise(); m_assetService.PostInitialise(); m_userAccountService.PostInitialise(); m_presenceService.PostInitialise(); testScene.RegionInfo.EstateSettings.EstateOwner = UUID.Random(); testScene.SetModuleInterfaces(); testScene.LandChannel = new TestLandChannel(testScene); testScene.LoadWorldMap(); PhysicsPluginManager physicsPluginManager = new PhysicsPluginManager(); physicsPluginManager.LoadPluginsFromAssembly("Physics/OpenSim.Region.Physics.BasicPhysicsPlugin.dll"); testScene.PhysicsScene = physicsPluginManager.GetPhysicsScene("basicphysics", "MarchingCubes", "ZeroMesher", new IniConfigSource(), "test"); // It's really not a good idea to use static variables as they carry over between tests, leading to // problems that are extremely hard to debug. Really, these static fields need to be eliminated - // tests using multiple regions that need to share modules need to find another solution. m_assetService = null; m_inventoryService = null; m_gridService = null; m_userAccountService = null; m_presenceService = null; testScene.RegionInfo.EstateSettings = new EstateSettings(); testScene.LoginsDisabled = false; return(testScene); }
public void TestInventoryDescendentsFetch() { TestHelpers.InMethod(); TestHelpers.EnableLogging(); BaseHttpServer httpServer = MainServer.Instance; Scene scene = new SceneHelpers().SetupScene(); CapabilitiesModule capsModule = new CapabilitiesModule(); WebFetchInvDescModule wfidModule = new WebFetchInvDescModule(false); IConfigSource config = new IniConfigSource(); config.AddConfig("ClientStack.LindenCaps"); config.Configs["ClientStack.LindenCaps"].Set("Cap_FetchInventoryDescendents2", "localhost"); SceneHelpers.SetupSceneModules(scene, config, capsModule, wfidModule); UserAccount ua = UserAccountHelpers.CreateUserWithInventory(scene, TestHelpers.ParseTail(0x1)); // We need a user present to have any capabilities set up SceneHelpers.AddScenePresence(scene, ua.PrincipalID); TestHttpRequest req = new TestHttpRequest(); OpenSim.Framework.Capabilities.Caps userCaps = capsModule.GetCapsForUser(ua.PrincipalID); PollServiceEventArgs pseArgs; userCaps.TryGetPollHandler("FetchInventoryDescendents2", out pseArgs); req.UriPath = pseArgs.Url; req.Uri = new Uri(req.UriPath); // Retrieve root folder details directly so that we can request InventoryFolderBase folder = scene.InventoryService.GetRootFolder(ua.PrincipalID); OSDMap osdFolder = new OSDMap(); osdFolder["folder_id"] = folder.ID; osdFolder["owner_id"] = ua.PrincipalID; osdFolder["fetch_folders"] = true; osdFolder["fetch_items"] = true; osdFolder["sort_order"] = 0; OSDArray osdFoldersArray = new OSDArray(); osdFoldersArray.Add(osdFolder); OSDMap osdReqMap = new OSDMap(); osdReqMap["folders"] = osdFoldersArray; req.Body = new MemoryStream(OSDParser.SerializeLLSDXmlBytes(osdReqMap)); TestHttpClientContext context = new TestHttpClientContext(false); MainServer.Instance.OnRequest(context, new RequestEventArgs(req)); // Drive processing of the queued inventory request synchronously. wfidModule.WaitProcessQueuedInventoryRequest(); MainServer.Instance.PollServiceRequestManager.WaitPerformResponse(); // System.Threading.Thread.Sleep(10000); OSDMap responseOsd = (OSDMap)OSDParser.DeserializeLLSDXml(context.ResponseBody); OSDArray foldersOsd = (OSDArray)responseOsd["folders"]; OSDMap folderOsd = (OSDMap)foldersOsd[0]; // A sanity check that the response has the expected number of descendents for a default inventory // TODO: Need a more thorough check. Assert.That((int)folderOsd["descendents"], Is.EqualTo(16)); }