aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2013-08-12 18:15:12 +0100
committerJustin Clark-Casey (justincc)2013-08-12 18:15:12 +0100
commitb64d3ecaed2c4cc0ffab2e44d02745de4e8f5717 (patch)
tree24fe10118f4a851ad11842c2150be56d84bfaed4
parentStats treaking. Update ToOSDMap for Stat and PercentageStat to return (diff)
downloadopensim-SC_OLD-b64d3ecaed2c4cc0ffab2e44d02745de4e8f5717.zip
opensim-SC_OLD-b64d3ecaed2c4cc0ffab2e44d02745de4e8f5717.tar.gz
opensim-SC_OLD-b64d3ecaed2c4cc0ffab2e44d02745de4e8f5717.tar.bz2
opensim-SC_OLD-b64d3ecaed2c4cc0ffab2e44d02745de4e8f5717.tar.xz
Create TestSameSimulatorNeighbouringRegionsTeleportV2() regression test for V2 transfer protocol.
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs113
-rw-r--r--OpenSim/Tests/Common/Mock/TestClient.cs26
2 files changed, 130 insertions, 9 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs
index 4ecae73..f4bf6b3 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs
@@ -799,7 +799,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
799 } 799 }
800 800
801 [Test] 801 [Test]
802 public void TestSameSimulatorNeighbouringRegionsTeleport() 802 public void TestSameSimulatorNeighbouringRegionsTeleportV1()
803 { 803 {
804 TestHelpers.InMethod(); 804 TestHelpers.InMethod();
805// TestHelpers.EnableLogging(); 805// TestHelpers.EnableLogging();
@@ -904,5 +904,116 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
904 // Check events 904 // Check events
905 Assert.That(m_numberOfAttachEventsFired, Is.EqualTo(0)); 905 Assert.That(m_numberOfAttachEventsFired, Is.EqualTo(0));
906 } 906 }
907
908 [Test]
909 public void TestSameSimulatorNeighbouringRegionsTeleportV2()
910 {
911 TestHelpers.InMethod();
912// TestHelpers.EnableLogging();
913
914 BaseHttpServer httpServer = new BaseHttpServer(99999);
915 MainServer.AddHttpServer(httpServer);
916 MainServer.Instance = httpServer;
917
918 AttachmentsModule attModA = new AttachmentsModule();
919 AttachmentsModule attModB = new AttachmentsModule();
920 EntityTransferModule etmA = new EntityTransferModule();
921 EntityTransferModule etmB = new EntityTransferModule();
922 LocalSimulationConnectorModule lscm = new LocalSimulationConnectorModule();
923
924 IConfigSource config = new IniConfigSource();
925 IConfig modulesConfig = config.AddConfig("Modules");
926 modulesConfig.Set("EntityTransferModule", etmA.Name);
927 modulesConfig.Set("SimulationServices", lscm.Name);
928 IConfig entityTransferConfig = config.AddConfig("EntityTransfer");
929
930 modulesConfig.Set("InventoryAccessModule", "BasicInventoryAccessModule");
931
932 SceneHelpers sh = new SceneHelpers();
933 TestScene sceneA = sh.SetupScene("sceneA", TestHelpers.ParseTail(0x100), 1000, 1000);
934 TestScene sceneB = sh.SetupScene("sceneB", TestHelpers.ParseTail(0x200), 1001, 1000);
935
936 SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, config, lscm);
937 SceneHelpers.SetupSceneModules(
938 sceneA, config, new CapabilitiesModule(), etmA, attModA, new BasicInventoryAccessModule());
939 SceneHelpers.SetupSceneModules(
940 sceneB, config, new CapabilitiesModule(), etmB, attModB, new BasicInventoryAccessModule());
941
942 UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(sceneA, 0x1);
943
944 AgentCircuitData acd = SceneHelpers.GenerateAgentData(ua1.PrincipalID);
945 TestClient tc = new TestClient(acd, sceneA);
946 List<TestClient> destinationTestClients = new List<TestClient>();
947 EntityTransferHelpers.SetUpInformClientOfNeighbour(tc, destinationTestClients);
948
949 ScenePresence beforeTeleportSp = SceneHelpers.AddScenePresence(sceneA, tc, acd);
950 beforeTeleportSp.AbsolutePosition = new Vector3(30, 31, 32);
951
952 Assert.That(destinationTestClients.Count, Is.EqualTo(1));
953 Assert.That(destinationTestClients[0], Is.Not.Null);
954
955 InventoryItemBase attItem = CreateAttachmentItem(sceneA, ua1.PrincipalID, "att", 0x10, 0x20);
956
957 sceneA.AttachmentsModule.RezSingleAttachmentFromInventory(
958 beforeTeleportSp, attItem.ID, (uint)AttachmentPoint.Chest);
959
960 Vector3 teleportPosition = new Vector3(10, 11, 12);
961 Vector3 teleportLookAt = new Vector3(20, 21, 22);
962
963 // Here, we need to make clientA's receipt of SendRegionTeleport trigger clientB's CompleteMovement(). This
964 // is to operate the teleport V2 mechanism where the EntityTransferModule will first request the client to
965 // CompleteMovement to the region and then call UpdateAgent to the destination region to confirm the receipt
966 // Both these operations will occur on different threads and will wait for each other.
967 // We have to do this via ThreadPool directly since FireAndForget has been switched to sync for the V1
968 // test protocol, where we are trying to avoid unpredictable async operations in regression tests.
969 ((TestClient)beforeTeleportSp.ControllingClient).OnTestClientSendRegionTeleport
970 += (regionHandle, simAccess, regionExternalEndPoint, locationID, flags, capsURL)
971 => ThreadPool.UnsafeQueueUserWorkItem(o => destinationTestClients[0].CompleteMovement(), null);
972
973 m_numberOfAttachEventsFired = 0;
974 sceneA.RequestTeleportLocation(
975 beforeTeleportSp.ControllingClient,
976 sceneB.RegionInfo.RegionHandle,
977 teleportPosition,
978 teleportLookAt,
979 (uint)TeleportFlags.ViaLocation);
980
981 // Check attachments have made it into sceneB
982 ScenePresence afterTeleportSceneBSp = sceneB.GetScenePresence(ua1.PrincipalID);
983
984 // This is appearance data, as opposed to actually rezzed attachments
985 List<AvatarAttachment> sceneBAttachments = afterTeleportSceneBSp.Appearance.GetAttachments();
986 Assert.That(sceneBAttachments.Count, Is.EqualTo(1));
987 Assert.That(sceneBAttachments[0].AttachPoint, Is.EqualTo((int)AttachmentPoint.Chest));
988 Assert.That(sceneBAttachments[0].ItemID, Is.EqualTo(attItem.ID));
989 Assert.That(sceneBAttachments[0].AssetID, Is.EqualTo(attItem.AssetID));
990 Assert.That(afterTeleportSceneBSp.Appearance.GetAttachpoint(attItem.ID), Is.EqualTo((int)AttachmentPoint.Chest));
991
992 // This is the actual attachment
993 List<SceneObjectGroup> actualSceneBAttachments = afterTeleportSceneBSp.GetAttachments();
994 Assert.That(actualSceneBAttachments.Count, Is.EqualTo(1));
995 SceneObjectGroup actualSceneBAtt = actualSceneBAttachments[0];
996 Assert.That(actualSceneBAtt.Name, Is.EqualTo(attItem.Name));
997 Assert.That(actualSceneBAtt.AttachmentPoint, Is.EqualTo((uint)AttachmentPoint.Chest));
998
999 Assert.That(sceneB.GetSceneObjectGroups().Count, Is.EqualTo(1));
1000
1001 // Check attachments have been removed from sceneA
1002 ScenePresence afterTeleportSceneASp = sceneA.GetScenePresence(ua1.PrincipalID);
1003
1004 // Since this is appearance data, it is still present on the child avatar!
1005 List<AvatarAttachment> sceneAAttachments = afterTeleportSceneASp.Appearance.GetAttachments();
1006 Assert.That(sceneAAttachments.Count, Is.EqualTo(1));
1007 Assert.That(afterTeleportSceneASp.Appearance.GetAttachpoint(attItem.ID), Is.EqualTo((int)AttachmentPoint.Chest));
1008
1009 // This is the actual attachment, which should no longer exist
1010 List<SceneObjectGroup> actualSceneAAttachments = afterTeleportSceneASp.GetAttachments();
1011 Assert.That(actualSceneAAttachments.Count, Is.EqualTo(0));
1012
1013 Assert.That(sceneA.GetSceneObjectGroups().Count, Is.EqualTo(0));
1014
1015 // Check events
1016 Assert.That(m_numberOfAttachEventsFired, Is.EqualTo(0));
1017 }
907 } 1018 }
908} 1019}
diff --git a/OpenSim/Tests/Common/Mock/TestClient.cs b/OpenSim/Tests/Common/Mock/TestClient.cs
index f7220d7..9370102 100644
--- a/OpenSim/Tests/Common/Mock/TestClient.cs
+++ b/OpenSim/Tests/Common/Mock/TestClient.cs
@@ -61,8 +61,13 @@ namespace OpenSim.Tests.Common.Mock
61 // Test client specific events - for use by tests to implement some IClientAPI behaviour. 61 // Test client specific events - for use by tests to implement some IClientAPI behaviour.
62 public event Action<RegionInfo, Vector3, Vector3> OnReceivedMoveAgentIntoRegion; 62 public event Action<RegionInfo, Vector3, Vector3> OnReceivedMoveAgentIntoRegion;
63 public event Action<ulong, IPEndPoint> OnTestClientInformClientOfNeighbour; 63 public event Action<ulong, IPEndPoint> OnTestClientInformClientOfNeighbour;
64 public event TestClientOnSendRegionTeleportDelegate OnTestClientSendRegionTeleport;
64 public event Action<GridInstantMessage> OnReceivedInstantMessage; 65 public event Action<GridInstantMessage> OnReceivedInstantMessage;
65 66
67 public delegate void TestClientOnSendRegionTeleportDelegate(
68 ulong regionHandle, byte simAccess, IPEndPoint regionExternalEndPoint,
69 uint locationID, uint flags, string capsURL);
70
66// disable warning: public events, part of the public API 71// disable warning: public events, part of the public API
67#pragma warning disable 67 72#pragma warning disable 67
68 73
@@ -472,7 +477,8 @@ namespace OpenSim.Tests.Common.Mock
472 477
473 public void CompleteMovement() 478 public void CompleteMovement()
474 { 479 {
475 OnCompleteMovementToRegion(this, true); 480 if (OnCompleteMovementToRegion != null)
481 OnCompleteMovementToRegion(this, true);
476 } 482 }
477 483
478 /// <summary> 484 /// <summary>
@@ -608,21 +614,25 @@ namespace OpenSim.Tests.Common.Mock
608 OnTestClientInformClientOfNeighbour(neighbourHandle, neighbourExternalEndPoint); 614 OnTestClientInformClientOfNeighbour(neighbourHandle, neighbourExternalEndPoint);
609 } 615 }
610 616
611 public virtual void SendRegionTeleport(ulong regionHandle, byte simAccess, IPEndPoint regionExternalEndPoint, 617 public virtual void SendRegionTeleport(
612 uint locationID, uint flags, string capsURL) 618 ulong regionHandle, byte simAccess, IPEndPoint regionExternalEndPoint,
619 uint locationID, uint flags, string capsURL)
613 { 620 {
614 m_log.DebugFormat("[TEST CLIENT]: Received SendRegionTeleport"); 621 m_log.DebugFormat(
622 "[TEST CLIENT]: Received SendRegionTeleport for {0} {1} on {2}", m_firstName, m_lastName, m_scene.Name);
615 623
616 CapsSeedUrl = capsURL; 624 CapsSeedUrl = capsURL;
617 625
618 // We don't do this here so that the source region can complete processing first in a single-threaded 626 if (OnTestClientSendRegionTeleport != null)
619 // regression test scenario. The test itself will have to call CompleteTeleportClientSide() after a teleport 627 OnTestClientSendRegionTeleport(
620 // CompleteTeleportClientSide(); 628 regionHandle, simAccess, regionExternalEndPoint, locationID, flags, capsURL);
621 } 629 }
622 630
623 public virtual void SendTeleportFailed(string reason) 631 public virtual void SendTeleportFailed(string reason)
624 { 632 {
625 m_log.DebugFormat("[TEST CLIENT]: Teleport failed with reason {0}", reason); 633 m_log.DebugFormat(
634 "[TEST CLIENT]: Teleport failed for {0} {1} on {2} with reason {3}",
635 m_firstName, m_lastName, m_scene.Name, reason);
626 } 636 }
627 637
628 public virtual void CrossRegion(ulong newRegionHandle, Vector3 pos, Vector3 lookAt, 638 public virtual void CrossRegion(ulong newRegionHandle, Vector3 pos, Vector3 lookAt,