From 9d2e1c67a8969e4769006c7347505b58a7827b3f Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Tue, 1 May 2012 23:14:12 +0100
Subject: Add regression test for teleporting between neighbouring regions on
the same simulator
This adds a non-advertised wait_for_callback option in [EntityTransfer]. Default is always true.
Teleport tests disable the wait for callback from the destination region in order to run within a single thread.
---
OpenSim/Tests/Common/Helpers/SceneHelpers.cs | 72 ++++++++++++++++++++++++++--
OpenSim/Tests/Common/Mock/TestClient.cs | 39 ++++++++++++---
OpenSim/Tests/Common/TestHelpers.cs | 9 ++--
3 files changed, 106 insertions(+), 14 deletions(-)
(limited to 'OpenSim/Tests')
diff --git a/OpenSim/Tests/Common/Helpers/SceneHelpers.cs b/OpenSim/Tests/Common/Helpers/SceneHelpers.cs
index 8e54707..dc24418 100644
--- a/OpenSim/Tests/Common/Helpers/SceneHelpers.cs
+++ b/OpenSim/Tests/Common/Helpers/SceneHelpers.cs
@@ -58,6 +58,11 @@ namespace OpenSim.Tests.Common
///
public class SceneHelpers
{
+ ///
+ /// We need a scene manager so that test clients can retrieve a scene when performing teleport tests.
+ ///
+ public SceneManager SceneManager { get; private set; }
+
private AgentCircuitManager m_acm = new AgentCircuitManager();
private ISimulationDataService m_simDataService
= OpenSim.Server.Base.ServerUtils.LoadPlugin("OpenSim.Tests.Common.dll", null);
@@ -76,6 +81,8 @@ namespace OpenSim.Tests.Common
public SceneHelpers(CoreAssetCache cache)
{
+ SceneManager = new SceneManager();
+
m_assetService = StartAssetService(cache);
m_authenticationService = StartAuthenticationService();
m_inventoryService = StartInventoryService();
@@ -186,6 +193,8 @@ namespace OpenSim.Tests.Common
testScene.LoginsDisabled = false;
testScene.RegisterRegionWithGrid();
+ SceneManager.Add(testScene);
+
return testScene;
}
@@ -350,6 +359,7 @@ namespace OpenSim.Tests.Common
List newModules = new List();
foreach (object module in modules)
{
+// Console.WriteLine("MODULE RAW {0}", module);
if (module is IRegionModule)
{
IRegionModule m = (IRegionModule)module;
@@ -367,6 +377,7 @@ namespace OpenSim.Tests.Common
// for the new system, everything has to be initialised first,
// shared modules have to be post-initialised, then all get an AddRegion with the scene
IRegionModuleBase m = (IRegionModuleBase)module;
+// Console.WriteLine("MODULE {0}", m.Name);
m.Initialise(config);
newModules.Add(m);
}
@@ -426,6 +437,10 @@ namespace OpenSim.Tests.Common
///
/// Add a root agent where the details of the agent connection (apart from the id) are unimportant for the test
///
+ ///
+ /// This can be used for tests where there is only one region or where there are multiple non-neighbour regions
+ /// and teleport doesn't take place.
+ ///
///
///
///
@@ -435,6 +450,18 @@ namespace OpenSim.Tests.Common
}
///
+ /// Add a root agent where the details of the agent connection (apart from the id) are unimportant for the test
+ ///
+ ///
+ ///
+ ///
+ ///
+ public static ScenePresence AddScenePresence(Scene scene, UUID agentId, SceneManager sceneManager)
+ {
+ return AddScenePresence(scene, GenerateAgentData(agentId), sceneManager);
+ }
+
+ ///
/// Add a root agent.
///
///
@@ -454,6 +481,30 @@ namespace OpenSim.Tests.Common
///
public static ScenePresence AddScenePresence(Scene scene, AgentCircuitData agentData)
{
+ return AddScenePresence(scene, agentData, null);
+ }
+
+ ///
+ /// Add a root agent.
+ ///
+ ///
+ /// 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
+ ///
+ ///
+ ///
+ ///
+ ///
+ public static ScenePresence AddScenePresence(Scene scene, AgentCircuitData agentData, SceneManager sceneManager)
+ {
// We emulate the proper login sequence here by doing things in four stages
// Stage 0: login
@@ -463,7 +514,7 @@ namespace OpenSim.Tests.Common
lpsc.m_PresenceService.LoginAgent(agentData.AgentID.ToString(), agentData.SessionID, agentData.SecureSessionID);
// Stages 1 & 2
- ScenePresence sp = IntroduceClientToScene(scene, agentData, TeleportFlags.ViaLogin);
+ ScenePresence sp = IntroduceClientToScene(scene, sceneManager, agentData, TeleportFlags.ViaLogin);
// Stage 3: Complete the entrance into the region. This converts the child agent into a root agent.
sp.CompleteMovement(sp.ControllingClient, true);
@@ -471,7 +522,20 @@ namespace OpenSim.Tests.Common
return sp;
}
- private static ScenePresence IntroduceClientToScene(Scene scene, AgentCircuitData agentData, TeleportFlags tf)
+ ///
+ /// Introduce an agent into the scene by adding a new client.
+ ///
+ /// The scene presence added
+ ///
+ /// Scene manager. Can be null if there is only one region in the test or multiple regions that are not
+ /// neighbours and where no teleporting takes place.
+ ///
+ ///
+ ///
+ ///
+ private static ScenePresence IntroduceClientToScene(
+ Scene scene, SceneManager sceneManager, AgentCircuitData agentData, TeleportFlags tf)
{
string reason;
@@ -480,7 +544,7 @@ namespace OpenSim.Tests.Common
Console.WriteLine("NewUserConnection failed: " + reason);
// Stage 2: add the new client as a child agent to the scene
- TestClient client = new TestClient(agentData, scene);
+ TestClient client = new TestClient(agentData, scene, sceneManager);
scene.AddNewClient(client, PresenceType.User);
return scene.GetScenePresence(agentData.AgentID);
@@ -492,7 +556,7 @@ namespace OpenSim.Tests.Common
acd.child = true;
// XXX: ViaLogin may not be correct for child agents
- return IntroduceClientToScene(scene, acd, TeleportFlags.ViaLogin);
+ return IntroduceClientToScene(scene, null, acd, TeleportFlags.ViaLogin);
}
///
diff --git a/OpenSim/Tests/Common/Mock/TestClient.cs b/OpenSim/Tests/Common/Mock/TestClient.cs
index cb9840e..36049a1 100644
--- a/OpenSim/Tests/Common/Mock/TestClient.cs
+++ b/OpenSim/Tests/Common/Mock/TestClient.cs
@@ -46,12 +46,10 @@ namespace OpenSim.Tests.Common.Mock
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;
private TestClient TeleportSceneClient;
private Scene m_scene;
+ private SceneManager m_sceneManager;
// Properties so that we can get at received data for test purposes
public List ReceivedOfflineNotifications { get; private set; }
@@ -432,15 +430,29 @@ namespace OpenSim.Tests.Common.Mock
///
/// Constructor
///
+ ///
+ /// Can be used for a test where there is only one region or where there are multiple regions that are not
+ /// neighbours and where no teleporting takes place. In other situations, the constructor that takes in a
+ /// scene manager should be used.
+ ///
///
///
- public TestClient(AgentCircuitData agentData, Scene scene)
+ public TestClient(AgentCircuitData agentData, Scene scene) : this(agentData, scene, null) {}
+
+ ///
+ /// Constructor
+ ///
+ ///
+ ///
+ ///
+ public TestClient(AgentCircuitData agentData, Scene scene, SceneManager sceneManager)
{
m_agentId = agentData.AgentID;
m_firstName = agentData.firstname;
m_lastName = agentData.lastname;
m_circuitCode = agentData.circuitcode;
m_scene = scene;
+ m_sceneManager = sceneManager;
SessionId = agentData.SessionID;
SecureSessionId = agentData.SecureSessionID;
CapsSeedUrl = agentData.CapsPath;
@@ -590,8 +602,16 @@ namespace OpenSim.Tests.Common.Mock
AgentCircuitData newAgent = RequestClientInfo();
// Stage 2: add the new client as a child agent to the scene
- TeleportSceneClient = new TestClient(newAgent, TeleportTargetScene);
- TeleportTargetScene.AddNewClient(TeleportSceneClient, PresenceType.User);
+ uint x, y;
+ Utils.LongToUInts(neighbourHandle, out x, out y);
+ x /= Constants.RegionSize;
+ y /= Constants.RegionSize;
+
+ Scene neighbourScene;
+ m_sceneManager.TryGetScene(x, y, out neighbourScene);
+
+ TeleportSceneClient = new TestClient(newAgent, neighbourScene, m_sceneManager);
+ neighbourScene.AddNewClient(TeleportSceneClient, PresenceType.User);
}
public virtual void SendRegionTeleport(ulong regionHandle, byte simAccess, IPEndPoint regionExternalEndPoint,
@@ -601,6 +621,13 @@ namespace OpenSim.Tests.Common.Mock
CapsSeedUrl = capsURL;
+ // We don't do this here so that the source region can complete processing first in a single-threaded
+ // regression test scenario. The test itself will have to call CompleteTeleportClientSide() after a teleport
+ // CompleteTeleportClientSide();
+ }
+
+ public void CompleteTeleportClientSide()
+ {
TeleportSceneClient.CompleteMovement();
//TeleportTargetScene.AgentCrossing(newAgent.AgentID, new Vector3(90, 90, 90), false);
}
diff --git a/OpenSim/Tests/Common/TestHelpers.cs b/OpenSim/Tests/Common/TestHelpers.cs
index 5030d4b..6744fca 100644
--- a/OpenSim/Tests/Common/TestHelpers.cs
+++ b/OpenSim/Tests/Common/TestHelpers.cs
@@ -46,7 +46,8 @@ namespace OpenSim.Tests.Common
-
+
+
@@ -62,9 +63,9 @@ namespace OpenSim.Tests.Common
Encoding.UTF8.GetBytes(
// "")));
//"")));
- //"")));
- //"")));
- //"")));
+// ""));
+// "")));
+// ""));
""));
public static bool AssertThisDelegateCausesArgumentException(TestDelegate d)
--
cgit v1.1