* Update ScenePresenceTests to reflect current REST communication workflow.

* Fixed an issue with AssetCache where it would break unit tests randomly.

From: Arthur Rodrigo S Valadares <arthursv@linux.vnet.ibm.com>
GenericGridServerConcept
Sean Dague 2009-02-26 21:29:16 +00:00
parent 7b04d1da5e
commit 57ab79e331
4 changed files with 119 additions and 92 deletions

View File

@ -210,7 +210,7 @@ namespace OpenSim.Framework.Communications.Cache
}
catch (Exception e)
{
m_log.Error("[ASSET CACHE]: " + e);
m_log.Error("[ASSET CACHE]: " + e.ToString());
}
}
}

View File

@ -29,6 +29,7 @@ using Nini.Config;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using NUnit.Framework;
using NUnit.Framework.SyntaxHelpers;
using OpenMetaverse;
@ -91,7 +92,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
/// <summary>
/// Test adding a root agent to a scene. Doesn't yet actually complete crossing the agent into the scene.
/// </summary>
/// </summary>
[Test]
public void T010_TestAddRootAgent()
{
@ -136,9 +137,11 @@ namespace OpenSim.Region.Framework.Scenes.Tests
[Test]
public void T012_TestAddNeighbourRegion()
{
SceneSetupHelpers.AddRootAgent(scene,agent1);
scene.NewUserConnection(acd1);
scene.AddNewClient(testclient);
ScenePresence presence = scene.GetScenePresence(agent1);
presence.MakeRootAgent(new Vector3(90,90,90),false);
string cap = presence.ControllingClient.RequestClientInfo().CapsPath;
@ -195,30 +198,43 @@ namespace OpenSim.Region.Framework.Scenes.Tests
string cap = presence.ControllingClient.RequestClientInfo().CapsPath;
presence2.AddNeighbourRegion(region1, cap);
scene.RegisterRegionWithGrid();
scene2.RegisterRegionWithGrid();
Assert.That(presence.IsChildAgent, Is.False, "Did not start root in origin region.");
Assert.That(presence2.IsChildAgent, Is.True, "Is not a child on destination region.");
// Cross to x+1
presence.AbsolutePosition = new Vector3(Constants.RegionSize+1,3,100);
scene.RegisterRegionWithGrid();
scene2.RegisterRegionWithGrid();
presence.Update();
/* With RESTComms this test needs more thinking, because of the callback
// Crossings are asynchronous
while (presence.IsInTransit) { };
EventWaitHandle wh = new EventWaitHandle (false, EventResetMode.AutoReset, "Crossing");
// Mimicking communication between client and server, by waiting OK from client
// sent by TestClient.CrossRegion call. Originally, this is network comm.
wh.WaitOne();
// This is a TestClient specific method that fires OnCompleteMovementToRegion event, which
// would normally be fired after receiving the reply packet from comm. done on the last line.
testclient.CompleteMovement();
// Crossings are asynchronous
while (presence.IsInTransit) { };
Assert.That(presence.IsChildAgent, Is.True, "Did not complete region cross as expected.");
Assert.That(presence2.IsChildAgent, Is.False, "Did not receive root status after receiving agent.");
// Cross Back
presence2.AbsolutePosition = new Vector3(-1, 3, 100);
presence2.AbsolutePosition = new Vector3(-10, 3, 100);
presence2.Update();
// Crossings are asynchronous
while (presence2.IsInTransit) { };
wh.WaitOne();
testclient.CompleteMovement();
while (presence2.IsInTransit) { };
Assert.That(presence2.IsChildAgent, Is.True, "Did not return from region as expected.");
Assert.That(presence.IsChildAgent, Is.False, "Presence was not made root in old region again.");
*/
}
[Test]

View File

@ -29,6 +29,7 @@ using System;
using System.Collections.Generic;
using System.Net;
using System.Reflection;
using System.Threading;
using log4net;
using OpenMetaverse;
using OpenMetaverse.Packets;
@ -41,16 +42,17 @@ namespace OpenSim.Tests.Common.Mock
public class TestClient : IClientAPI
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
// Mock testing variables
public List<ImageDataPacket> sentdatapkt = new List<ImageDataPacket>();
public List<ImagePacketPacket> sentpktpkt = new List<ImagePacketPacket>();
EventWaitHandle wh = new EventWaitHandle (false, EventResetMode.AutoReset, "Crossing");
// TODO: This is a really nasty (and temporary) means of telling the test client which scene to invoke setup
// methods on when a teleport is requested
public Scene TeleportTargetScene;
public Scene TeleportTargetScene;
private TestClient TeleportSceneClient;
private IScene m_scene;
// disable warning: public events, part of the public API
@ -272,7 +274,7 @@ namespace OpenSim.Tests.Common.Mock
/// This agent's UUID
/// </value>
private UUID m_agentId;
/// <value>
/// The last caps seed url that this client was given.
/// </value>
@ -363,15 +365,15 @@ namespace OpenSim.Tests.Common.Mock
{
set { }
}
private uint m_circuitCode;
public uint CircuitCode
{
get { return m_circuitCode; }
set { m_circuitCode = value; }
}
}
/// <summary>
/// Constructor
/// </summary>
@ -386,7 +388,7 @@ namespace OpenSim.Tests.Common.Mock
m_scene = scene;
CapsSeedUrl = agentData.CapsPath;
}
/// <summary>
/// Attempt a teleport to the given region.
/// </summary>
@ -395,9 +397,9 @@ namespace OpenSim.Tests.Common.Mock
/// <param name="lookAt"></param>
public void Teleport(ulong regionHandle, Vector3 position, Vector3 lookAt)
{
OnTeleportLocationRequest(this, regionHandle, position, lookAt, 16);
OnTeleportLocationRequest(this, regionHandle, position, lookAt, 16);
}
public void CompleteMovement()
{
OnCompleteMovementToRegion();
@ -501,46 +503,52 @@ namespace OpenSim.Tests.Common.Mock
agentData.child = false;
agentData.firstname = m_firstName;
agentData.lastname = m_lastName;
ICapabilitiesModule capsModule = m_scene.RequestModuleInterface<ICapabilitiesModule>();
agentData.CapsPath = capsModule.GetCapsPath(m_agentId);
agentData.ChildrenCapSeeds = new Dictionary<ulong, string>(capsModule.GetChildrenSeeds(m_agentId));
return agentData;
}
public virtual void InformClientOfNeighbour(ulong neighbourHandle, IPEndPoint neighbourExternalEndPoint)
{
m_log.DebugFormat("[TEST CLIENT]: Processing inform client of neighbour");
// In response to this message, we are going to make a teleport to the scene we've previous been told
// about by test code (this needs to be improved).
AgentCircuitData newAgent = RequestClientInfo();
AgentCircuitData newAgent = RequestClientInfo();
// Stage 2: add the new client as a child agent to the scene
TeleportSceneClient = new TestClient(newAgent, TeleportTargetScene);
TeleportTargetScene.AddNewClient(TeleportSceneClient);
TeleportTargetScene.AddNewClient(TeleportSceneClient);
}
public virtual void SendRegionTeleport(ulong regionHandle, byte simAccess, IPEndPoint regionExternalEndPoint,
uint locationID, uint flags, string capsURL)
{
{
m_log.DebugFormat("[TEST CLIENT]: Received SendRegionTeleport");
CapsSeedUrl = capsURL;
TeleportSceneClient.CompleteMovement();
//TeleportTargetScene.AgentCrossing(newAgent.AgentID, new Vector3(90, 90, 90), false);
//TeleportTargetScene.AgentCrossing(newAgent.AgentID, new Vector3(90, 90, 90), false);
}
public virtual void SendTeleportFailed(string reason)
{
m_log.DebugFormat("[TEST CLIENT]: Teleport failed with reason {0}", reason);
}
}
public virtual void CrossRegion(ulong newRegionHandle, Vector3 pos, Vector3 lookAt,
IPEndPoint newRegionExternalEndPoint, string capsURL)
{
// This is supposed to send a packet to the client telling it's ready to start region crossing.
// Instead I will just signal I'm ready, mimicking the communication behavior.
// It's ugly, but avoids needless communication setup. This is used in ScenePresenceTests.cs.
// Arthur V.
wh.Set();
}
public virtual void SendMapBlock(List<MapBlockData> mapBlocks, uint flag)
@ -845,7 +853,7 @@ namespace OpenSim.Tests.Common.Mock
public void Start()
{
}
public void Stop()
{
}

View File

@ -40,12 +40,12 @@ using OpenSim.Region.CoreModules.Agent.Capabilities;
using OpenSim.Tests.Common.Mock;
namespace OpenSim.Tests.Common.Setup
{
{
/// <summary>
/// Helpers for setting up scenes.
/// </summary>
public class SceneSetupHelpers
{
{
/// <summary>
/// Set up a test scene
/// </summary>
@ -54,7 +54,7 @@ namespace OpenSim.Tests.Common.Setup
{
return SetupScene("Unit test region", UUID.Random(), 1000, 1000, new TestCommunicationsManager());
}
/// <summary>
/// Set up a test scene
/// </summary>
@ -69,32 +69,32 @@ namespace OpenSim.Tests.Common.Setup
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", "", "");
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);
testScene.SetModuleInterfaces();
testScene.AddModule(capsModule.Name, capsModule);
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");
testScene.PhysicsScene
= physicsPluginManager.GetPhysicsScene("basicphysics", "ZeroMesher", configSource, "test");
return testScene;
}
}
/// <summary>
/// Setup modules for a scene using their default settings.
/// </summary>
@ -102,9 +102,9 @@ namespace OpenSim.Tests.Common.Setup
/// <param name="modules"></param>
public static void SetupSceneModules(Scene scene, params IRegionModule[] modules)
{
SetupSceneModules(scene, null, modules);
}
SetupSceneModules(scene, null, modules);
}
/// <summary>
/// Setup modules for a scene.
/// </summary>
@ -115,13 +115,13 @@ namespace OpenSim.Tests.Common.Setup
{
foreach (IRegionModule module in modules)
{
module.Initialise(scene, config);
module.Initialise(scene, config);
scene.AddModule(module.Name, module);
}
scene.SetModuleInterfaces();
scene.SetModuleInterfaces();
}
/// <summary>
/// Generate some standard agent connection data.
/// </summary>
@ -130,7 +130,7 @@ namespace OpenSim.Tests.Common.Setup
public static AgentCircuitData GenerateAgentData(UUID agentId)
{
string firstName = "testfirstname";
AgentCircuitData agentData = new AgentCircuitData();
agentData.AgentID = agentId;
agentData.firstname = firstName;
@ -142,10 +142,10 @@ namespace OpenSim.Tests.Common.Setup
agentData.InventoryFolder = UUID.Zero;
agentData.startpos = Vector3.Zero;
agentData.CapsPath = "http://wibble.com";
return agentData;
}
/// <summary>
/// Add a root agent where the details of the agent connection (apart from the id) are unimportant for the test
/// </summary>
@ -153,55 +153,58 @@ namespace OpenSim.Tests.Common.Setup
/// <param name="agentId"></param>
/// <returns></returns>
public static TestClient AddRootAgent(Scene scene, UUID agentId)
{
return AddRootAgent(scene, GenerateAgentData(agentId));
}
{
return AddRootAgent(scene, GenerateAgentData(agentId));
}
/// <summary>
/// Add a root agent.
/// Add a root agent.
/// </summary>
///
///
/// This function
///
///
/// 1) Tells the scene that an agent is coming. Normally, the login service (local if standalone, from the
/// userserver if grid) would give initial login data back to the client and separately tell the scene that the
/// agent was coming.
///
///
/// 2) Connects the agent with the scene
///
///
/// This function performs actions equivalent with notifying the scene that an agent is
/// coming and then actually connecting the agent to the scene. The one step missed out is the very first
///
///
/// <param name="scene"></param>
/// <param name="agentData"></param>
/// <returns></returns>
/// <returns></returns>
public static TestClient AddRootAgent(Scene scene, AgentCircuitData agentData)
{
// We emulate the proper login sequence here by doing things in three stages
{
// We emulate the proper login sequence here by doing things in three stages
// Stage 1: simulate login by telling the scene to expect a new user connection
scene.NewUserConnection(agentData);
// Stage 2: add the new client as a child agent to the scene
TestClient client = new TestClient(agentData, scene);
scene.AddNewClient(client);
// Stage 3: Invoke agent crossing, which converts the child agent into a root agent (with appearance,
// inventory, etc.)
scene.AgentCrossing(agentData.AgentID, new Vector3(90, 90, 90), false);
return client;
//scene.AgentCrossing(agentData.AgentID, new Vector3(90, 90, 90), false); OBSOLETE
ScenePresence scp = scene.GetScenePresence(agentData.AgentID);
scp.MakeRootAgent(new Vector3(90,90,90), true);
return client;
}
/// <summary>
/// Add a test object
/// </summary>
/// <param name="scene"></param>
/// <returns></returns>
/// <returns></returns>
public static SceneObjectPart AddSceneObject(Scene scene)
{
return AddSceneObject(scene, "Test Object");
}
/// <summary>
/// Add a test object
/// </summary>
@ -209,19 +212,19 @@ namespace OpenSim.Tests.Common.Setup
/// <param name="name"></param>
/// <returns></returns>
public static SceneObjectPart AddSceneObject(Scene scene, string name)
{
SceneObjectPart part
{
SceneObjectPart part
= new SceneObjectPart(UUID.Zero, PrimitiveBaseShape.Default, Vector3.Zero, Quaternion.Identity, Vector3.Zero);
part.Name = name;
//part.UpdatePrimFlags(false, false, true);
//part.ObjectFlags |= (uint)PrimFlags.Phantom;
//part.UpdatePrimFlags(false, false, true);
//part.ObjectFlags |= (uint)PrimFlags.Phantom;
scene.AddNewSceneObject(new SceneObjectGroup(part), false);
return part;
}
/// <summary>
/// Delete a scene object asynchronously
/// </summary>
@ -238,7 +241,7 @@ namespace OpenSim.Tests.Common.Setup
sogd.Enabled = false;
scene.DeRezObject(client, part.LocalId, UUID.Zero, action, destinationId);
sogd.InventoryDeQueueAndDelete();
sogd.InventoryDeQueueAndDelete();
}
}
}