Add ScenePresenceTeleportTests.TestSameSimulatorIsolatedRegionsV2() regression test for v2 transfers.

Also adjusts names of teleport setup helpers in EntityTransferHelpers
0.7.6-extended
Justin Clark-Casey (justincc) 2013-08-17 00:24:56 +01:00
parent fbab898f74
commit f5d3145bea
5 changed files with 109 additions and 10 deletions

View File

@ -844,7 +844,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
AgentCircuitData acd = SceneHelpers.GenerateAgentData(ua1.PrincipalID); AgentCircuitData acd = SceneHelpers.GenerateAgentData(ua1.PrincipalID);
TestClient tc = new TestClient(acd, sceneA); TestClient tc = new TestClient(acd, sceneA);
List<TestClient> destinationTestClients = new List<TestClient>(); List<TestClient> destinationTestClients = new List<TestClient>();
EntityTransferHelpers.SetUpInformClientOfNeighbour(tc, destinationTestClients); EntityTransferHelpers.SetupInformClientOfNeighbourTriggersNeighbourClientCreate(tc, destinationTestClients);
ScenePresence beforeTeleportSp = SceneHelpers.AddScenePresence(sceneA, tc, acd); ScenePresence beforeTeleportSp = SceneHelpers.AddScenePresence(sceneA, tc, acd);
beforeTeleportSp.AbsolutePosition = new Vector3(30, 31, 32); beforeTeleportSp.AbsolutePosition = new Vector3(30, 31, 32);
@ -943,7 +943,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
AgentCircuitData acd = SceneHelpers.GenerateAgentData(ua1.PrincipalID); AgentCircuitData acd = SceneHelpers.GenerateAgentData(ua1.PrincipalID);
TestClient tc = new TestClient(acd, sceneA); TestClient tc = new TestClient(acd, sceneA);
List<TestClient> destinationTestClients = new List<TestClient>(); List<TestClient> destinationTestClients = new List<TestClient>();
EntityTransferHelpers.SetUpInformClientOfNeighbour(tc, destinationTestClients); EntityTransferHelpers.SetupInformClientOfNeighbourTriggersNeighbourClientCreate(tc, destinationTestClients);
ScenePresence beforeTeleportSp = SceneHelpers.AddScenePresence(sceneA, tc, acd); ScenePresence beforeTeleportSp = SceneHelpers.AddScenePresence(sceneA, tc, acd);
beforeTeleportSp.AbsolutePosition = new Vector3(30, 31, 32); beforeTeleportSp.AbsolutePosition = new Vector3(30, 31, 32);

View File

@ -147,7 +147,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
AgentCircuitData acd = SceneHelpers.GenerateAgentData(uaB); AgentCircuitData acd = SceneHelpers.GenerateAgentData(uaB);
TestClient clientB = new TestClient(acd, sceneB); TestClient clientB = new TestClient(acd, sceneB);
List<TestClient> childClientsB = new List<TestClient>(); List<TestClient> childClientsB = new List<TestClient>();
EntityTransferHelpers.SetUpInformClientOfNeighbour(clientB, childClientsB); EntityTransferHelpers.SetupInformClientOfNeighbourTriggersNeighbourClientCreate(clientB, childClientsB);
SceneHelpers.AddScenePresence(sceneB, clientB, acd); SceneHelpers.AddScenePresence(sceneB, clientB, acd);

View File

@ -97,7 +97,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
AgentCircuitData acd = SceneHelpers.GenerateAgentData(userId); AgentCircuitData acd = SceneHelpers.GenerateAgentData(userId);
TestClient tc = new TestClient(acd, sceneA); TestClient tc = new TestClient(acd, sceneA);
List<TestClient> destinationTestClients = new List<TestClient>(); List<TestClient> destinationTestClients = new List<TestClient>();
EntityTransferHelpers.SetUpInformClientOfNeighbour(tc, destinationTestClients); EntityTransferHelpers.SetupInformClientOfNeighbourTriggersNeighbourClientCreate(tc, destinationTestClients);
ScenePresence originalSp = SceneHelpers.AddScenePresence(sceneA, tc, acd); ScenePresence originalSp = SceneHelpers.AddScenePresence(sceneA, tc, acd);
originalSp.AbsolutePosition = new Vector3(128, 32, 10); originalSp.AbsolutePosition = new Vector3(128, 32, 10);

View File

@ -147,7 +147,8 @@ namespace OpenSim.Region.Framework.Scenes.Tests
sp.AbsolutePosition = new Vector3(30, 31, 32); sp.AbsolutePosition = new Vector3(30, 31, 32);
List<TestClient> destinationTestClients = new List<TestClient>(); List<TestClient> destinationTestClients = new List<TestClient>();
EntityTransferHelpers.SetUpInformClientOfNeighbour((TestClient)sp.ControllingClient, destinationTestClients); EntityTransferHelpers.SetupInformClientOfNeighbourTriggersNeighbourClientCreate(
(TestClient)sp.ControllingClient, destinationTestClients);
sceneA.RequestTeleportLocation( sceneA.RequestTeleportLocation(
sp.ControllingClient, sp.ControllingClient,
@ -180,6 +181,67 @@ namespace OpenSim.Region.Framework.Scenes.Tests
// Assert.That(sp.Lookat, Is.EqualTo(teleportLookAt)); // Assert.That(sp.Lookat, Is.EqualTo(teleportLookAt));
} }
[Test]
public void TestSameSimulatorIsolatedRegionsV2()
{
TestHelpers.InMethod();
// TestHelpers.EnableLogging();
UUID userId = TestHelpers.ParseTail(0x1);
EntityTransferModule etmA = new EntityTransferModule();
EntityTransferModule etmB = new EntityTransferModule();
LocalSimulationConnectorModule lscm = new LocalSimulationConnectorModule();
IConfigSource config = new IniConfigSource();
IConfig modulesConfig = config.AddConfig("Modules");
modulesConfig.Set("EntityTransferModule", etmA.Name);
modulesConfig.Set("SimulationServices", lscm.Name);
SceneHelpers sh = new SceneHelpers();
TestScene sceneA = sh.SetupScene("sceneA", TestHelpers.ParseTail(0x100), 1000, 1000);
TestScene sceneB = sh.SetupScene("sceneB", TestHelpers.ParseTail(0x200), 1002, 1000);
SceneHelpers.SetupSceneModules(sceneA, config, etmA);
SceneHelpers.SetupSceneModules(sceneB, config, etmB);
SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, config, lscm);
Vector3 teleportPosition = new Vector3(10, 11, 12);
Vector3 teleportLookAt = new Vector3(20, 21, 22);
ScenePresence sp = SceneHelpers.AddScenePresence(sceneA, userId);
sp.AbsolutePosition = new Vector3(30, 31, 32);
List<TestClient> destinationTestClients = new List<TestClient>();
EntityTransferHelpers.SetupSendRegionTeleportTriggersDestinationClientCreateAndCompleteMovement(
(TestClient)sp.ControllingClient, destinationTestClients);
sceneA.RequestTeleportLocation(
sp.ControllingClient,
sceneB.RegionInfo.RegionHandle,
teleportPosition,
teleportLookAt,
(uint)TeleportFlags.ViaLocation);
Assert.That(sceneA.GetScenePresence(userId), Is.Null);
ScenePresence sceneBSp = sceneB.GetScenePresence(userId);
Assert.That(sceneBSp, Is.Not.Null);
Assert.That(sceneBSp.Scene.RegionInfo.RegionName, Is.EqualTo(sceneB.RegionInfo.RegionName));
Assert.That(sceneBSp.AbsolutePosition, Is.EqualTo(teleportPosition));
Assert.That(sceneA.GetRootAgentCount(), Is.EqualTo(0));
Assert.That(sceneA.GetChildAgentCount(), Is.EqualTo(0));
Assert.That(sceneB.GetRootAgentCount(), Is.EqualTo(1));
Assert.That(sceneB.GetChildAgentCount(), Is.EqualTo(0));
// TODO: Add assertions to check correct circuit details in both scenes.
// Lookat is sent to the client only - sp.Lookat does not yield the same thing (calculation from camera
// position instead).
// Assert.That(sp.Lookat, Is.EqualTo(teleportLookAt));
}
/// <summary> /// <summary>
/// Test teleport procedures when the target simulator returns false when queried about access. /// Test teleport procedures when the target simulator returns false when queried about access.
/// </summary> /// </summary>
@ -467,7 +529,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
AgentCircuitData acd = SceneHelpers.GenerateAgentData(userId); AgentCircuitData acd = SceneHelpers.GenerateAgentData(userId);
TestClient tc = new TestClient(acd, sceneA); TestClient tc = new TestClient(acd, sceneA);
List<TestClient> destinationTestClients = new List<TestClient>(); List<TestClient> destinationTestClients = new List<TestClient>();
EntityTransferHelpers.SetUpInformClientOfNeighbour(tc, destinationTestClients); EntityTransferHelpers.SetupInformClientOfNeighbourTriggersNeighbourClientCreate(tc, destinationTestClients);
ScenePresence beforeSceneASp = SceneHelpers.AddScenePresence(sceneA, tc, acd); ScenePresence beforeSceneASp = SceneHelpers.AddScenePresence(sceneA, tc, acd);
beforeSceneASp.AbsolutePosition = new Vector3(30, 31, 32); beforeSceneASp.AbsolutePosition = new Vector3(30, 31, 32);
@ -545,7 +607,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
AgentCircuitData acd = SceneHelpers.GenerateAgentData(userId); AgentCircuitData acd = SceneHelpers.GenerateAgentData(userId);
TestClient tc = new TestClient(acd, sceneA); TestClient tc = new TestClient(acd, sceneA);
List<TestClient> destinationTestClients = new List<TestClient>(); List<TestClient> destinationTestClients = new List<TestClient>();
EntityTransferHelpers.SetUpInformClientOfNeighbour(tc, destinationTestClients); EntityTransferHelpers.SetupInformClientOfNeighbourTriggersNeighbourClientCreate(tc, destinationTestClients);
ScenePresence beforeSceneASp = SceneHelpers.AddScenePresence(sceneA, tc, acd); ScenePresence beforeSceneASp = SceneHelpers.AddScenePresence(sceneA, tc, acd);
beforeSceneASp.AbsolutePosition = new Vector3(30, 31, 32); beforeSceneASp.AbsolutePosition = new Vector3(30, 31, 32);

View File

@ -31,6 +31,7 @@ using System.IO;
using System.Net; using System.Net;
using System.Reflection; using System.Reflection;
using System.Text; using System.Text;
using System.Threading;
using log4net; using log4net;
using Nini.Config; using Nini.Config;
using NUnit.Framework; using NUnit.Framework;
@ -59,7 +60,8 @@ namespace OpenSim.Tests.Common
/// A list that will be populated with any TestClients set up in response to /// A list that will be populated with any TestClients set up in response to
/// being informed about a destination region. /// being informed about a destination region.
/// </param> /// </param>
public static void SetUpInformClientOfNeighbour(TestClient tc, List<TestClient> neighbourTcs) public static void SetupInformClientOfNeighbourTriggersNeighbourClientCreate(
TestClient tc, List<TestClient> neighbourTcs)
{ {
// XXX: Confusingly, this is also used for non-neighbour notification (as in teleports that do not use the // XXX: Confusingly, this is also used for non-neighbour notification (as in teleports that do not use the
// event queue). // event queue).
@ -75,8 +77,6 @@ namespace OpenSim.Tests.Common
"[TEST CLIENT]: Processing inform client of neighbour located at {0},{1} at {2}", "[TEST CLIENT]: Processing inform client of neighbour located at {0},{1} at {2}",
x, y, neighbourExternalEndPoint); x, y, neighbourExternalEndPoint);
// 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 = tc.RequestClientInfo(); AgentCircuitData newAgent = tc.RequestClientInfo();
Scene neighbourScene; Scene neighbourScene;
@ -87,5 +87,42 @@ namespace OpenSim.Tests.Common
neighbourScene.AddNewClient(neighbourTc, PresenceType.User); neighbourScene.AddNewClient(neighbourTc, PresenceType.User);
}; };
} }
/// <summary>
/// Set up correct handling of the InformClientOfNeighbour call from the source region that triggers the
/// viewer to setup a connection with the destination region.
/// </summary>
/// <param name='tc'></param>
/// <param name='neighbourTcs'>
/// A list that will be populated with any TestClients set up in response to
/// being informed about a destination region.
/// </param>
public static void SetupSendRegionTeleportTriggersDestinationClientCreateAndCompleteMovement(
TestClient client, List<TestClient> destinationClients)
{
client.OnTestClientSendRegionTeleport
+= (regionHandle, simAccess, regionExternalEndPoint, locationID, flags, capsURL) =>
{
uint x, y;
Utils.LongToUInts(regionHandle, out x, out y);
x /= Constants.RegionSize;
y /= Constants.RegionSize;
m_log.DebugFormat(
"[TEST CLIENT]: Processing send region teleport for destination at {0},{1} at {2}",
x, y, regionExternalEndPoint);
AgentCircuitData newAgent = client.RequestClientInfo();
Scene destinationScene;
SceneManager.Instance.TryGetScene(x, y, out destinationScene);
TestClient destinationClient = new TestClient(newAgent, destinationScene);
destinationClients.Add(destinationClient);
destinationScene.AddNewClient(destinationClient, PresenceType.User);
ThreadPool.UnsafeQueueUserWorkItem(o => destinationClient.CompleteMovement(), null);
};
}
} }
} }