From 4919c6056022053f8632b030a06fd8f48ac02a8e Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 3 Dec 2011 18:59:54 +0000 Subject: Add beginning of ScenePresenceAgentTests.TestCreateChildScenePresence() This required an option to be added to NullRegionData via ConnectionString for it to act as a non-static instance, so that regression tests (which only load this class once) don't get hopeless confused and complex to compensate. Normal standalone operation unaffected. --- OpenSim/Data/Null/NullRegionData.cs | 40 +++++++++++---- .../Framework/Tests/AgentCircuitManagerTests.cs | 2 - OpenSim/Framework/Tests/AnimationTests.cs | 2 - .../EntityTransfer/EntityTransferModule.cs | 1 - .../Grid/Tests/GridConnectorsTests.cs | 9 ++-- .../Scenes/Tests/ScenePresenceAgentTests.cs | 57 +++++++++++++++++----- OpenSim/Tests/Common/Helpers/SceneHelpers.cs | 3 ++ prebuild.xml | 1 + 8 files changed, 86 insertions(+), 29 deletions(-) diff --git a/OpenSim/Data/Null/NullRegionData.cs b/OpenSim/Data/Null/NullRegionData.cs index 9d09af7..deb50cb 100644 --- a/OpenSim/Data/Null/NullRegionData.cs +++ b/OpenSim/Data/Null/NullRegionData.cs @@ -40,24 +40,40 @@ namespace OpenSim.Data.Null { private static NullRegionData Instance = null; + /// + /// Should we use the static instance for all invocations? + /// + private bool m_useStaticInstance = true; + // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); Dictionary m_regionData = new Dictionary(); public NullRegionData(string connectionString, string realm) { - if (Instance == null) +// m_log.DebugFormat( +// "[NULL REGION DATA]: Constructor got connectionString {0}, realm {1}", connectionString, realm); + + // The !static connection string is a hack so that regression tests can use this module without a high degree of fragility + // in having to deal with the static reference in the once-loaded NullRegionData class. + // + // In standalone operation, we have to use only one instance of this class since the login service and + // simulator have no other way of using a common data store. + if (connectionString == "!static") + m_useStaticInstance = false; + else if (Instance == null) Instance = this; - //Console.WriteLine("[XXX] NullRegionData constructor"); } private delegate bool Matcher(string value); public List Get(string regionName, UUID scopeID) { - if (Instance != this) + if (m_useStaticInstance && Instance != this) return Instance.Get(regionName, scopeID); +// m_log.DebugFormat("[NULL REGION DATA]: Getting region {0}, scope {1}", regionName, scopeID); + string cleanName = regionName.ToLower(); // Handle SQL wildcards @@ -82,6 +98,7 @@ namespace OpenSim.Data.Null cleanName = cleanName.Remove(cleanName.Length - 1); } } + Matcher queryMatch; if (wildcardPrefix && wildcardSuffix) queryMatch = delegate(string s) { return s.Contains(cleanName); }; @@ -110,7 +127,7 @@ namespace OpenSim.Data.Null public RegionData Get(int posX, int posY, UUID scopeID) { - if (Instance != this) + if (m_useStaticInstance && Instance != this) return Instance.Get(posX, posY, scopeID); List ret = new List(); @@ -129,7 +146,7 @@ namespace OpenSim.Data.Null public RegionData Get(UUID regionID, UUID scopeID) { - if (Instance != this) + if (m_useStaticInstance && Instance != this) return Instance.Get(regionID, scopeID); if (m_regionData.ContainsKey(regionID)) @@ -140,7 +157,7 @@ namespace OpenSim.Data.Null public List Get(int startX, int startY, int endX, int endY, UUID scopeID) { - if (Instance != this) + if (m_useStaticInstance && Instance != this) return Instance.Get(startX, startY, endX, endY, scopeID); List ret = new List(); @@ -156,9 +173,12 @@ namespace OpenSim.Data.Null public bool Store(RegionData data) { - if (Instance != this) + if (m_useStaticInstance && Instance != this) return Instance.Store(data); +// m_log.DebugFormat( +// "[NULL REGION DATA]: Storing region {0} {1}, scope {2}", data.RegionName, data.RegionID, data.ScopeID); + m_regionData[data.RegionID] = data; return true; @@ -166,7 +186,7 @@ namespace OpenSim.Data.Null public bool SetDataItem(UUID regionID, string item, string value) { - if (Instance != this) + if (m_useStaticInstance && Instance != this) return Instance.SetDataItem(regionID, item, value); if (!m_regionData.ContainsKey(regionID)) @@ -179,9 +199,11 @@ namespace OpenSim.Data.Null public bool Delete(UUID regionID) { - if (Instance != this) + if (m_useStaticInstance && Instance != this) return Instance.Delete(regionID); +// m_log.DebugFormat("[NULL REGION DATA]: Deleting region {0}", regionID); + if (!m_regionData.ContainsKey(regionID)) return false; diff --git a/OpenSim/Framework/Tests/AgentCircuitManagerTests.cs b/OpenSim/Framework/Tests/AgentCircuitManagerTests.cs index 9615f1b..ae132c8 100644 --- a/OpenSim/Framework/Tests/AgentCircuitManagerTests.cs +++ b/OpenSim/Framework/Tests/AgentCircuitManagerTests.cs @@ -194,8 +194,6 @@ namespace OpenSim.Framework.Tests resp = agentCircuitManager.AuthenticateSession(SessionId2, AgentId2, circuitcode2); Assert.That(!resp.Authorised); - } - } } diff --git a/OpenSim/Framework/Tests/AnimationTests.cs b/OpenSim/Framework/Tests/AnimationTests.cs index aa4c6aa..967a355 100644 --- a/OpenSim/Framework/Tests/AnimationTests.cs +++ b/OpenSim/Framework/Tests/AnimationTests.cs @@ -87,8 +87,6 @@ namespace OpenSim.Framework.Tests anim4.SequenceNum = anim2.SequenceNum; Assert.That(anim4.ObjectID == objUUID2 && anim4.AnimID == animUUID2 && anim4.SequenceNum == 1, "void constructor and manual field population failed to set the properties correctly."); - - } } } \ No newline at end of file diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs index 99064c8..2f947fd 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs @@ -1341,7 +1341,6 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer string reason = String.Empty; - bool regionAccepted = m_scene.SimulationService.CreateAgent(reg, a, (uint)TeleportFlags.Default, out reason); if (regionAccepted && newAgent) diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs index cd7d6bc..b286d17 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs @@ -31,11 +31,10 @@ using System.IO; using System.Reflection; using System.Threading; using log4net.Config; +using Nini.Config; using NUnit.Framework; using OpenMetaverse; using OpenSim.Framework; -using Nini.Config; - using OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid; using OpenSim.Region.Framework.Scenes; using GridRegion = OpenSim.Services.Interfaces.GridRegion; @@ -69,6 +68,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid.Tests [Test] public void TestRegisterRegion() { + TestHelpers.InMethod(); +// log4net.Config.XmlConfigurator.Configure(); + SetUp(); // Create 4 regions @@ -191,7 +193,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid.Tests results = m_LocalConnector.GetHyperlinks(UUID.Zero); Assert.IsNotNull(results, "Retrieved GetHyperlinks list is null"); Assert.That(results.Count, Is.EqualTo(0), "Retrieved linked regions collection is not the number expected"); - } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAgentTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAgentTests.cs index 57d22bd..f479e12 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAgentTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAgentTests.cs @@ -31,7 +31,7 @@ using System.Reflection; using System.Text; using System.Threading; using System.Timers; -using Timer=System.Timers.Timer; +using Timer = System.Timers.Timer; using Nini.Config; using NUnit.Framework; using OpenMetaverse; @@ -39,11 +39,13 @@ using OpenSim.Framework; using OpenSim.Framework.Communications; using OpenSim.Region.Framework.Scenes; using OpenSim.Region.Framework.Interfaces; +using OpenSim.Region.ClientStack.Linden; using OpenSim.Region.CoreModules.Framework.EntityTransfer; using OpenSim.Region.CoreModules.World.Serialiser; using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation; using OpenSim.Tests.Common; using OpenSim.Tests.Common.Mock; +using GridRegion = OpenSim.Services.Interfaces.GridRegion; namespace OpenSim.Region.Framework.Scenes.Tests { @@ -112,14 +114,40 @@ namespace OpenSim.Region.Framework.Scenes.Tests Assert.That(scene.AuthenticateHandler.GetAgentCircuits().Count, Is.EqualTo(0)); } + [Test] + public void TestCreateChildScenePresence() + { + TestHelpers.InMethod(); +// log4net.Config.XmlConfigurator.Configure(); + + LocalSimulationConnectorModule lsc = new LocalSimulationConnectorModule(); + + IConfigSource configSource = new IniConfigSource(); + IConfig config = configSource.AddConfig("Modules"); + config.Set("SimulationServices", "LocalSimulationConnectorModule"); + + TestScene scene = SceneHelpers.SetupScene(); + SceneHelpers.SetupSceneModules(scene, configSource, lsc); + + UUID agentId = TestHelpers.ParseTail(0x01); + AgentCircuitData acd = SceneHelpers.GenerateAgentData(agentId); + + GridRegion region = scene.GridService.GetRegionByName(UUID.Zero, scene.RegionInfo.RegionName); + string reason; + scene.SimulationService.CreateAgent(region, acd, (uint)TeleportFlags.ViaLogin, out reason); + + Assert.That(scene.AuthenticateHandler.GetAgentCircuitData(agentId), Is.Not.Null); + Assert.That(scene.AuthenticateHandler.GetAgentCircuits().Count, Is.EqualTo(1)); + } + /// /// Test that if a root agent logs into a region, a child agent is also established in the neighbouring region /// /// - /// Please note that unlike the other tests here, this doesn't rely on structures + /// Please note that unlike the other tests here, this doesn't rely on anything set up in the instance fields. /// [Test] - public void TestChildAgentEstablished() + public void TestChildAgentEstablishedInNeighbour() { TestHelpers.InMethod(); // log4net.Config.XmlConfigurator.Configure(); @@ -127,18 +155,25 @@ namespace OpenSim.Region.Framework.Scenes.Tests UUID agent1Id = UUID.Parse("00000000-0000-0000-0000-000000000001"); TestScene myScene1 = SceneHelpers.SetupScene("Neighbour y", UUID.Random(), 1000, 1000); -// TestScene myScene2 = SceneHelpers.SetupScene("Neighbour y + 1", UUID.Random(), 1001, 1000); - + TestScene myScene2 = SceneHelpers.SetupScene("Neighbour y + 1", UUID.Random(), 1001, 1000); + IConfigSource configSource = new IniConfigSource(); - configSource.AddConfig("Modules").Set("EntityTransferModule", "BasicEntityTransferModule"); + IConfig config = configSource.AddConfig("Startup"); + config.Set("serverside_object_permissions", true); + config.Set("EventQueue", true); + EntityTransferModule etm = new EntityTransferModule(); + + EventQueueGetModule eqgm1 = new EventQueueGetModule(); + SceneHelpers.SetupSceneModules(myScene1, configSource, etm, eqgm1); + + EventQueueGetModule eqgm2 = new EventQueueGetModule(); + SceneHelpers.SetupSceneModules(myScene2, configSource, etm, eqgm2); - SceneHelpers.SetupSceneModules(myScene1, configSource, etm); - - SceneHelpers.AddScenePresence(myScene1, agent1Id); +// SceneHelpers.AddScenePresence(myScene1, agent1Id); // ScenePresence childPresence = myScene2.GetScenePresence(agent1); - - // TODO: Need to do a fair amount of work to allow synchronous establishment of child agents +// +// // TODO: Need to do a fair amount of work to allow synchronous establishment of child agents // Assert.That(childPresence, Is.Not.Null); // Assert.That(childPresence.IsChildAgent, Is.True); } diff --git a/OpenSim/Tests/Common/Helpers/SceneHelpers.cs b/OpenSim/Tests/Common/Helpers/SceneHelpers.cs index d358ae8..e4640be 100644 --- a/OpenSim/Tests/Common/Helpers/SceneHelpers.cs +++ b/OpenSim/Tests/Common/Helpers/SceneHelpers.cs @@ -49,6 +49,7 @@ using OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts; using OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence; using OpenSim.Services.Interfaces; using OpenSim.Tests.Common.Mock; +using GridRegion = OpenSim.Services.Interfaces.GridRegion; namespace OpenSim.Tests.Common { @@ -139,6 +140,7 @@ namespace OpenSim.Tests.Common testScene.RegionInfo.EstateSettings = new EstateSettings(); testScene.LoginsDisabled = false; + testScene.RegisterRegionWithGrid(); return testScene; } @@ -222,6 +224,7 @@ namespace OpenSim.Tests.Common config.Configs["Modules"].Set("GridServices", "LocalGridServicesConnector"); config.Configs["GridService"].Set("StorageProvider", "OpenSim.Data.Null.dll:NullRegionData"); config.Configs["GridService"].Set("LocalServiceModule", "OpenSim.Services.GridService.dll:GridService"); + config.Configs["GridService"].Set("ConnectionString", "!static"); LocalGridServicesConnector gridService = new LocalGridServicesConnector(); gridService.Initialise(config); diff --git a/prebuild.xml b/prebuild.xml index a7e3bde..4e36172 100644 --- a/prebuild.xml +++ b/prebuild.xml @@ -3016,6 +3016,7 @@ + -- cgit v1.1