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.
iar_mods
Justin Clark-Casey (justincc) 2011-12-03 18:59:54 +00:00
parent ced820bd5e
commit 4919c60560
8 changed files with 89 additions and 32 deletions

View File

@ -40,24 +40,40 @@ namespace OpenSim.Data.Null
{
private static NullRegionData Instance = null;
/// <summary>
/// Should we use the static instance for all invocations?
/// </summary>
private bool m_useStaticInstance = true;
// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
Dictionary<UUID, RegionData> m_regionData = new Dictionary<UUID, RegionData>();
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<RegionData> 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<RegionData> ret = new List<RegionData>();
@ -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<RegionData> 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<RegionData> ret = new List<RegionData>();
@ -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;

View File

@ -194,8 +194,6 @@ namespace OpenSim.Framework.Tests
resp = agentCircuitManager.AuthenticateSession(SessionId2, AgentId2, circuitcode2);
Assert.That(!resp.Authorised);
}
}
}

View File

@ -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.");
}
}
}

View File

@ -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)

View File

@ -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");
}
}
}
}

View File

@ -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));
}
/// <summary>
/// Test that if a root agent logs into a region, a child agent is also established in the neighbouring region
/// </summary>
/// <remarks>
/// 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.
/// </remarks>
[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);
IConfigSource configSource = new IniConfigSource();
configSource.AddConfig("Modules").Set("EntityTransferModule", "BasicEntityTransferModule");
EntityTransferModule etm = new EntityTransferModule();
SceneHelpers.SetupSceneModules(myScene1, configSource, etm);
SceneHelpers.AddScenePresence(myScene1, agent1Id);
// ScenePresence childPresence = myScene2.GetScenePresence(agent1);
TestScene myScene2 = SceneHelpers.SetupScene("Neighbour y + 1", UUID.Random(), 1001, 1000);
// TODO: Need to do a fair amount of work to allow synchronous establishment of child agents
IConfigSource configSource = new IniConfigSource();
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.AddScenePresence(myScene1, agent1Id);
// ScenePresence childPresence = myScene2.GetScenePresence(agent1);
//
// // 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);
}

View File

@ -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);

View File

@ -3016,6 +3016,7 @@
<Reference name="OpenSim.Framework.Servers"/>
<Reference name="OpenSim.Framework.Statistics"/>
<Reference name="OpenSim.Framework.Servers.HttpServer"/>
<Reference name="OpenSim.Region.ClientStack.LindenCaps"/>
<Reference name="OpenSim.Region.Framework"/>
<Reference name="OpenSim.Region.CoreModules"/>
<Reference name="OpenSim.Region.OptionalModules"/>