ScenePresenceTeleportTests.cs 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663
  1. /*
  2. * Copyright (c) Contributors, http://opensimulator.org/
  3. * See CONTRIBUTORS.TXT for a full list of copyright holders.
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions are met:
  7. * * Redistributions of source code must retain the above copyright
  8. * notice, this list of conditions and the following disclaimer.
  9. * * Redistributions in binary form must reproduce the above copyright
  10. * notice, this list of conditions and the following disclaimer in the
  11. * documentation and/or other materials provided with the distribution.
  12. * * Neither the name of the OpenSimulator Project nor the
  13. * names of its contributors may be used to endorse or promote products
  14. * derived from this software without specific prior written permission.
  15. *
  16. * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
  17. * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  18. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  19. * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
  20. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  21. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  22. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  23. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  24. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  25. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  26. */
  27. using System;
  28. using System.Collections.Generic;
  29. using System.IO;
  30. using System.Net;
  31. using System.Text;
  32. using System.Threading;
  33. using Nini.Config;
  34. using NUnit.Framework;
  35. using OpenMetaverse;
  36. using OpenSim.Framework;
  37. using OpenSim.Framework.Communications;
  38. using OpenSim.Framework.Servers;
  39. using OpenSim.Region.Framework.Interfaces;
  40. using OpenSim.Region.CoreModules.Framework;
  41. using OpenSim.Region.CoreModules.Framework.EntityTransfer;
  42. using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation;
  43. using OpenSim.Region.CoreModules.World.Permissions;
  44. using OpenSim.Tests.Common;
  45. using OpenSim.Tests.Common.Mock;
  46. namespace OpenSim.Region.Framework.Scenes.Tests
  47. {
  48. /// <summary>
  49. /// Teleport tests in a standalone OpenSim
  50. /// </summary>
  51. [TestFixture]
  52. public class ScenePresenceTeleportTests : OpenSimTestCase
  53. {
  54. [TestFixtureSetUp]
  55. public void FixtureInit()
  56. {
  57. // Don't allow tests to be bamboozled by asynchronous events. Execute everything on the same thread.
  58. Util.FireAndForgetMethod = FireAndForgetMethod.RegressionTest;
  59. }
  60. [TestFixtureTearDown]
  61. public void TearDown()
  62. {
  63. // We must set this back afterwards, otherwise later tests will fail since they're expecting multiple
  64. // threads. Possibly, later tests should be rewritten so none of them require async stuff (which regression
  65. // tests really shouldn't).
  66. Util.FireAndForgetMethod = Util.DefaultFireAndForgetMethod;
  67. }
  68. [Test]
  69. public void TestSameRegion()
  70. {
  71. TestHelpers.InMethod();
  72. // log4net.Config.XmlConfigurator.Configure();
  73. EntityTransferModule etm = new EntityTransferModule();
  74. IConfigSource config = new IniConfigSource();
  75. config.AddConfig("Modules");
  76. // Not strictly necessary since FriendsModule assumes it is the default (!)
  77. config.Configs["Modules"].Set("EntityTransferModule", etm.Name);
  78. TestScene scene = new SceneHelpers().SetupScene("sceneA", TestHelpers.ParseTail(0x100), 1000, 1000);
  79. SceneHelpers.SetupSceneModules(scene, config, etm);
  80. Vector3 teleportPosition = new Vector3(10, 11, 12);
  81. Vector3 teleportLookAt = new Vector3(20, 21, 22);
  82. ScenePresence sp = SceneHelpers.AddScenePresence(scene, TestHelpers.ParseTail(0x1));
  83. sp.AbsolutePosition = new Vector3(30, 31, 32);
  84. scene.RequestTeleportLocation(
  85. sp.ControllingClient,
  86. scene.RegionInfo.RegionHandle,
  87. teleportPosition,
  88. teleportLookAt,
  89. (uint)TeleportFlags.ViaLocation);
  90. Assert.That(sp.AbsolutePosition, Is.EqualTo(teleportPosition));
  91. Assert.That(scene.GetRootAgentCount(), Is.EqualTo(1));
  92. Assert.That(scene.GetChildAgentCount(), Is.EqualTo(0));
  93. // Lookat is sent to the client only - sp.Lookat does not yield the same thing (calculation from camera
  94. // position instead).
  95. // Assert.That(sp.Lookat, Is.EqualTo(teleportLookAt));
  96. }
  97. [Test]
  98. public void TestSameSimulatorIsolatedRegionsV1()
  99. {
  100. TestHelpers.InMethod();
  101. // TestHelpers.EnableLogging();
  102. UUID userId = TestHelpers.ParseTail(0x1);
  103. EntityTransferModule etmA = new EntityTransferModule();
  104. EntityTransferModule etmB = new EntityTransferModule();
  105. LocalSimulationConnectorModule lscm = new LocalSimulationConnectorModule();
  106. IConfigSource config = new IniConfigSource();
  107. IConfig modulesConfig = config.AddConfig("Modules");
  108. modulesConfig.Set("EntityTransferModule", etmA.Name);
  109. modulesConfig.Set("SimulationServices", lscm.Name);
  110. IConfig entityTransferConfig = config.AddConfig("EntityTransfer");
  111. // In order to run a single threaded regression test we do not want the entity transfer module waiting
  112. // for a callback from the destination scene before removing its avatar data.
  113. entityTransferConfig.Set("wait_for_callback", false);
  114. SceneHelpers sh = new SceneHelpers();
  115. TestScene sceneA = sh.SetupScene("sceneA", TestHelpers.ParseTail(0x100), 1000, 1000);
  116. TestScene sceneB = sh.SetupScene("sceneB", TestHelpers.ParseTail(0x200), 1002, 1000);
  117. SceneHelpers.SetupSceneModules(sceneA, config, etmA);
  118. SceneHelpers.SetupSceneModules(sceneB, config, etmB);
  119. SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, config, lscm);
  120. // FIXME: Hack - this is here temporarily to revert back to older entity transfer behaviour
  121. lscm.ServiceVersion = "SIMULATION/0.1";
  122. Vector3 teleportPosition = new Vector3(10, 11, 12);
  123. Vector3 teleportLookAt = new Vector3(20, 21, 22);
  124. ScenePresence sp = SceneHelpers.AddScenePresence(sceneA, userId);
  125. sp.AbsolutePosition = new Vector3(30, 31, 32);
  126. List<TestClient> destinationTestClients = new List<TestClient>();
  127. EntityTransferHelpers.SetupInformClientOfNeighbourTriggersNeighbourClientCreate(
  128. (TestClient)sp.ControllingClient, destinationTestClients);
  129. sceneA.RequestTeleportLocation(
  130. sp.ControllingClient,
  131. sceneB.RegionInfo.RegionHandle,
  132. teleportPosition,
  133. teleportLookAt,
  134. (uint)TeleportFlags.ViaLocation);
  135. // SetupInformClientOfNeighbour() will have handled the callback into the target scene to setup the child
  136. // agent. This call will now complete the movement of the user into the destination and upgrade the agent
  137. // from child to root.
  138. destinationTestClients[0].CompleteMovement();
  139. Assert.That(sceneA.GetScenePresence(userId), Is.Null);
  140. ScenePresence sceneBSp = sceneB.GetScenePresence(userId);
  141. Assert.That(sceneBSp, Is.Not.Null);
  142. Assert.That(sceneBSp.Scene.RegionInfo.RegionName, Is.EqualTo(sceneB.RegionInfo.RegionName));
  143. Assert.That(sceneBSp.AbsolutePosition, Is.EqualTo(teleportPosition));
  144. Assert.That(sceneA.GetRootAgentCount(), Is.EqualTo(0));
  145. Assert.That(sceneA.GetChildAgentCount(), Is.EqualTo(0));
  146. Assert.That(sceneB.GetRootAgentCount(), Is.EqualTo(1));
  147. Assert.That(sceneB.GetChildAgentCount(), Is.EqualTo(0));
  148. // TODO: Add assertions to check correct circuit details in both scenes.
  149. // Lookat is sent to the client only - sp.Lookat does not yield the same thing (calculation from camera
  150. // position instead).
  151. // Assert.That(sp.Lookat, Is.EqualTo(teleportLookAt));
  152. }
  153. [Test]
  154. public void TestSameSimulatorIsolatedRegionsV2()
  155. {
  156. TestHelpers.InMethod();
  157. // TestHelpers.EnableLogging();
  158. UUID userId = TestHelpers.ParseTail(0x1);
  159. EntityTransferModule etmA = new EntityTransferModule();
  160. EntityTransferModule etmB = new EntityTransferModule();
  161. LocalSimulationConnectorModule lscm = new LocalSimulationConnectorModule();
  162. IConfigSource config = new IniConfigSource();
  163. IConfig modulesConfig = config.AddConfig("Modules");
  164. modulesConfig.Set("EntityTransferModule", etmA.Name);
  165. modulesConfig.Set("SimulationServices", lscm.Name);
  166. SceneHelpers sh = new SceneHelpers();
  167. TestScene sceneA = sh.SetupScene("sceneA", TestHelpers.ParseTail(0x100), 1000, 1000);
  168. TestScene sceneB = sh.SetupScene("sceneB", TestHelpers.ParseTail(0x200), 1002, 1000);
  169. SceneHelpers.SetupSceneModules(sceneA, config, etmA);
  170. SceneHelpers.SetupSceneModules(sceneB, config, etmB);
  171. SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, config, lscm);
  172. Vector3 teleportPosition = new Vector3(10, 11, 12);
  173. Vector3 teleportLookAt = new Vector3(20, 21, 22);
  174. ScenePresence sp = SceneHelpers.AddScenePresence(sceneA, userId);
  175. sp.AbsolutePosition = new Vector3(30, 31, 32);
  176. List<TestClient> destinationTestClients = new List<TestClient>();
  177. EntityTransferHelpers.SetupSendRegionTeleportTriggersDestinationClientCreateAndCompleteMovement(
  178. (TestClient)sp.ControllingClient, destinationTestClients);
  179. sceneA.RequestTeleportLocation(
  180. sp.ControllingClient,
  181. sceneB.RegionInfo.RegionHandle,
  182. teleportPosition,
  183. teleportLookAt,
  184. (uint)TeleportFlags.ViaLocation);
  185. Assert.That(sceneA.GetScenePresence(userId), Is.Null);
  186. ScenePresence sceneBSp = sceneB.GetScenePresence(userId);
  187. Assert.That(sceneBSp, Is.Not.Null);
  188. Assert.That(sceneBSp.Scene.RegionInfo.RegionName, Is.EqualTo(sceneB.RegionInfo.RegionName));
  189. Assert.That(sceneBSp.AbsolutePosition, Is.EqualTo(teleportPosition));
  190. Assert.That(sceneA.GetRootAgentCount(), Is.EqualTo(0));
  191. Assert.That(sceneA.GetChildAgentCount(), Is.EqualTo(0));
  192. Assert.That(sceneB.GetRootAgentCount(), Is.EqualTo(1));
  193. Assert.That(sceneB.GetChildAgentCount(), Is.EqualTo(0));
  194. // TODO: Add assertions to check correct circuit details in both scenes.
  195. // Lookat is sent to the client only - sp.Lookat does not yield the same thing (calculation from camera
  196. // position instead).
  197. // Assert.That(sp.Lookat, Is.EqualTo(teleportLookAt));
  198. }
  199. /// <summary>
  200. /// Test teleport procedures when the target simulator returns false when queried about access.
  201. /// </summary>
  202. [Test]
  203. public void TestSameSimulatorIsolatedRegions_DeniedOnQueryAccess()
  204. {
  205. TestHelpers.InMethod();
  206. // TestHelpers.EnableLogging();
  207. UUID userId = TestHelpers.ParseTail(0x1);
  208. Vector3 preTeleportPosition = new Vector3(30, 31, 32);
  209. EntityTransferModule etmA = new EntityTransferModule();
  210. EntityTransferModule etmB = new EntityTransferModule();
  211. LocalSimulationConnectorModule lscm = new LocalSimulationConnectorModule();
  212. IConfigSource config = new IniConfigSource();
  213. config.AddConfig("Modules");
  214. config.Configs["Modules"].Set("EntityTransferModule", etmA.Name);
  215. config.Configs["Modules"].Set("SimulationServices", lscm.Name);
  216. config.AddConfig("EntityTransfer");
  217. // In order to run a single threaded regression test we do not want the entity transfer module waiting
  218. // for a callback from the destination scene before removing its avatar data.
  219. config.Configs["EntityTransfer"].Set("wait_for_callback", false);
  220. config.AddConfig("Startup");
  221. config.Configs["Startup"].Set("serverside_object_permissions", true);
  222. SceneHelpers sh = new SceneHelpers();
  223. TestScene sceneA = sh.SetupScene("sceneA", TestHelpers.ParseTail(0x100), 1000, 1000);
  224. TestScene sceneB = sh.SetupScene("sceneB", TestHelpers.ParseTail(0x200), 1002, 1000);
  225. SceneHelpers.SetupSceneModules(sceneA, config, etmA );
  226. // We need to set up the permisions module on scene B so that our later use of agent limit to deny
  227. // QueryAccess won't succeed anyway because administrators are always allowed in and the default
  228. // IsAdministrator if no permissions module is present is true.
  229. SceneHelpers.SetupSceneModules(sceneB, config, new object[] { new PermissionsModule(), etmB });
  230. // Shared scene modules
  231. SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, config, lscm);
  232. Vector3 teleportPosition = new Vector3(10, 11, 12);
  233. Vector3 teleportLookAt = new Vector3(20, 21, 22);
  234. ScenePresence sp = SceneHelpers.AddScenePresence(sceneA, userId);
  235. sp.AbsolutePosition = preTeleportPosition;
  236. // Make sceneB return false on query access
  237. sceneB.RegionInfo.RegionSettings.AgentLimit = 0;
  238. sceneA.RequestTeleportLocation(
  239. sp.ControllingClient,
  240. sceneB.RegionInfo.RegionHandle,
  241. teleportPosition,
  242. teleportLookAt,
  243. (uint)TeleportFlags.ViaLocation);
  244. // ((TestClient)sp.ControllingClient).CompleteTeleportClientSide();
  245. Assert.That(sceneB.GetScenePresence(userId), Is.Null);
  246. ScenePresence sceneASp = sceneA.GetScenePresence(userId);
  247. Assert.That(sceneASp, Is.Not.Null);
  248. Assert.That(sceneASp.Scene.RegionInfo.RegionName, Is.EqualTo(sceneA.RegionInfo.RegionName));
  249. Assert.That(sceneASp.AbsolutePosition, Is.EqualTo(preTeleportPosition));
  250. Assert.That(sceneA.GetRootAgentCount(), Is.EqualTo(1));
  251. Assert.That(sceneA.GetChildAgentCount(), Is.EqualTo(0));
  252. Assert.That(sceneB.GetRootAgentCount(), Is.EqualTo(0));
  253. Assert.That(sceneB.GetChildAgentCount(), Is.EqualTo(0));
  254. // TODO: Add assertions to check correct circuit details in both scenes.
  255. // Lookat is sent to the client only - sp.Lookat does not yield the same thing (calculation from camera
  256. // position instead).
  257. // Assert.That(sp.Lookat, Is.EqualTo(teleportLookAt));
  258. // TestHelpers.DisableLogging();
  259. }
  260. /// <summary>
  261. /// Test teleport procedures when the target simulator create agent step is refused.
  262. /// </summary>
  263. [Test]
  264. public void TestSameSimulatorIsolatedRegions_DeniedOnCreateAgent()
  265. {
  266. TestHelpers.InMethod();
  267. // TestHelpers.EnableLogging();
  268. UUID userId = TestHelpers.ParseTail(0x1);
  269. Vector3 preTeleportPosition = new Vector3(30, 31, 32);
  270. EntityTransferModule etmA = new EntityTransferModule();
  271. EntityTransferModule etmB = new EntityTransferModule();
  272. LocalSimulationConnectorModule lscm = new LocalSimulationConnectorModule();
  273. IConfigSource config = new IniConfigSource();
  274. config.AddConfig("Modules");
  275. config.Configs["Modules"].Set("EntityTransferModule", etmA.Name);
  276. config.Configs["Modules"].Set("SimulationServices", lscm.Name);
  277. config.AddConfig("EntityTransfer");
  278. // In order to run a single threaded regression test we do not want the entity transfer module waiting
  279. // for a callback from the destination scene before removing its avatar data.
  280. config.Configs["EntityTransfer"].Set("wait_for_callback", false);
  281. SceneHelpers sh = new SceneHelpers();
  282. TestScene sceneA = sh.SetupScene("sceneA", TestHelpers.ParseTail(0x100), 1000, 1000);
  283. TestScene sceneB = sh.SetupScene("sceneB", TestHelpers.ParseTail(0x200), 1002, 1000);
  284. SceneHelpers.SetupSceneModules(sceneA, config, etmA);
  285. SceneHelpers.SetupSceneModules(sceneB, config, etmB);
  286. // Shared scene modules
  287. SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, config, lscm);
  288. Vector3 teleportPosition = new Vector3(10, 11, 12);
  289. Vector3 teleportLookAt = new Vector3(20, 21, 22);
  290. ScenePresence sp = SceneHelpers.AddScenePresence(sceneA, userId);
  291. sp.AbsolutePosition = preTeleportPosition;
  292. // Make sceneB refuse CreateAgent
  293. sceneB.LoginsEnabled = false;
  294. sceneA.RequestTeleportLocation(
  295. sp.ControllingClient,
  296. sceneB.RegionInfo.RegionHandle,
  297. teleportPosition,
  298. teleportLookAt,
  299. (uint)TeleportFlags.ViaLocation);
  300. // ((TestClient)sp.ControllingClient).CompleteTeleportClientSide();
  301. Assert.That(sceneB.GetScenePresence(userId), Is.Null);
  302. ScenePresence sceneASp = sceneA.GetScenePresence(userId);
  303. Assert.That(sceneASp, Is.Not.Null);
  304. Assert.That(sceneASp.Scene.RegionInfo.RegionName, Is.EqualTo(sceneA.RegionInfo.RegionName));
  305. Assert.That(sceneASp.AbsolutePosition, Is.EqualTo(preTeleportPosition));
  306. Assert.That(sceneA.GetRootAgentCount(), Is.EqualTo(1));
  307. Assert.That(sceneA.GetChildAgentCount(), Is.EqualTo(0));
  308. Assert.That(sceneB.GetRootAgentCount(), Is.EqualTo(0));
  309. Assert.That(sceneB.GetChildAgentCount(), Is.EqualTo(0));
  310. // TODO: Add assertions to check correct circuit details in both scenes.
  311. // Lookat is sent to the client only - sp.Lookat does not yield the same thing (calculation from camera
  312. // position instead).
  313. // Assert.That(sp.Lookat, Is.EqualTo(teleportLookAt));
  314. // TestHelpers.DisableLogging();
  315. }
  316. /// <summary>
  317. /// Test teleport when the destination region does not process (or does not receive) the connection attempt
  318. /// from the viewer.
  319. /// </summary>
  320. /// <remarks>
  321. /// This could be quite a common case where the source region can connect to a remove destination region
  322. /// (for CreateAgent) but the viewer cannot reach the destination region due to network issues.
  323. /// </remarks>
  324. [Test]
  325. public void TestSameSimulatorIsolatedRegions_DestinationDidNotProcessViewerConnection()
  326. {
  327. TestHelpers.InMethod();
  328. // TestHelpers.EnableLogging();
  329. UUID userId = TestHelpers.ParseTail(0x1);
  330. Vector3 preTeleportPosition = new Vector3(30, 31, 32);
  331. EntityTransferModule etmA = new EntityTransferModule();
  332. EntityTransferModule etmB = new EntityTransferModule();
  333. LocalSimulationConnectorModule lscm = new LocalSimulationConnectorModule();
  334. IConfigSource config = new IniConfigSource();
  335. config.AddConfig("Modules");
  336. config.Configs["Modules"].Set("EntityTransferModule", etmA.Name);
  337. config.Configs["Modules"].Set("SimulationServices", lscm.Name);
  338. config.AddConfig("EntityTransfer");
  339. // In order to run a single threaded regression test we do not want the entity transfer module waiting
  340. // for a callback from the destination scene before removing its avatar data.
  341. config.Configs["EntityTransfer"].Set("wait_for_callback", false);
  342. // config.AddConfig("Startup");
  343. // config.Configs["Startup"].Set("serverside_object_permissions", true);
  344. SceneHelpers sh = new SceneHelpers();
  345. TestScene sceneA = sh.SetupScene("sceneA", TestHelpers.ParseTail(0x100), 1000, 1000);
  346. TestScene sceneB = sh.SetupScene("sceneB", TestHelpers.ParseTail(0x200), 1002, 1000);
  347. SceneHelpers.SetupSceneModules(sceneA, config, etmA );
  348. // We need to set up the permisions module on scene B so that our later use of agent limit to deny
  349. // QueryAccess won't succeed anyway because administrators are always allowed in and the default
  350. // IsAdministrator if no permissions module is present is true.
  351. SceneHelpers.SetupSceneModules(sceneB, config, new object[] { new PermissionsModule(), etmB });
  352. // Shared scene modules
  353. SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, config, lscm);
  354. Vector3 teleportPosition = new Vector3(10, 11, 12);
  355. Vector3 teleportLookAt = new Vector3(20, 21, 22);
  356. ScenePresence sp = SceneHelpers.AddScenePresence(sceneA, userId);
  357. sp.AbsolutePosition = preTeleportPosition;
  358. sceneA.RequestTeleportLocation(
  359. sp.ControllingClient,
  360. sceneB.RegionInfo.RegionHandle,
  361. teleportPosition,
  362. teleportLookAt,
  363. (uint)TeleportFlags.ViaLocation);
  364. // FIXME: Not setting up InformClientOfNeighbour on the TestClient means that it does not initiate
  365. // communication with the destination region. But this is a very non-obvious way of doing it - really we
  366. // should be forced to expicitly set this up.
  367. Assert.That(sceneB.GetScenePresence(userId), Is.Null);
  368. ScenePresence sceneASp = sceneA.GetScenePresence(userId);
  369. Assert.That(sceneASp, Is.Not.Null);
  370. Assert.That(sceneASp.Scene.RegionInfo.RegionName, Is.EqualTo(sceneA.RegionInfo.RegionName));
  371. Assert.That(sceneASp.AbsolutePosition, Is.EqualTo(preTeleportPosition));
  372. Assert.That(sceneA.GetRootAgentCount(), Is.EqualTo(1));
  373. Assert.That(sceneA.GetChildAgentCount(), Is.EqualTo(0));
  374. Assert.That(sceneB.GetRootAgentCount(), Is.EqualTo(0));
  375. Assert.That(sceneB.GetChildAgentCount(), Is.EqualTo(0));
  376. // TODO: Add assertions to check correct circuit details in both scenes.
  377. // Lookat is sent to the client only - sp.Lookat does not yield the same thing (calculation from camera
  378. // position instead).
  379. // Assert.That(sp.Lookat, Is.EqualTo(teleportLookAt));
  380. // TestHelpers.DisableLogging();
  381. }
  382. [Test]
  383. public void TestSameSimulatorNeighbouringRegionsV1()
  384. {
  385. TestHelpers.InMethod();
  386. // TestHelpers.EnableLogging();
  387. UUID userId = TestHelpers.ParseTail(0x1);
  388. EntityTransferModule etmA = new EntityTransferModule();
  389. EntityTransferModule etmB = new EntityTransferModule();
  390. LocalSimulationConnectorModule lscm = new LocalSimulationConnectorModule();
  391. IConfigSource config = new IniConfigSource();
  392. IConfig modulesConfig = config.AddConfig("Modules");
  393. modulesConfig.Set("EntityTransferModule", etmA.Name);
  394. modulesConfig.Set("SimulationServices", lscm.Name);
  395. IConfig entityTransferConfig = config.AddConfig("EntityTransfer");
  396. // In order to run a single threaded regression test we do not want the entity transfer module waiting
  397. // for a callback from the destination scene before removing its avatar data.
  398. entityTransferConfig.Set("wait_for_callback", false);
  399. SceneHelpers sh = new SceneHelpers();
  400. TestScene sceneA = sh.SetupScene("sceneA", TestHelpers.ParseTail(0x100), 1000, 1000);
  401. TestScene sceneB = sh.SetupScene("sceneB", TestHelpers.ParseTail(0x200), 1001, 1000);
  402. SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, config, lscm);
  403. SceneHelpers.SetupSceneModules(sceneA, config, new CapabilitiesModule(), etmA);
  404. SceneHelpers.SetupSceneModules(sceneB, config, new CapabilitiesModule(), etmB);
  405. // FIXME: Hack - this is here temporarily to revert back to older entity transfer behaviour
  406. lscm.ServiceVersion = "SIMULATION/0.1";
  407. Vector3 teleportPosition = new Vector3(10, 11, 12);
  408. Vector3 teleportLookAt = new Vector3(20, 21, 22);
  409. AgentCircuitData acd = SceneHelpers.GenerateAgentData(userId);
  410. TestClient tc = new TestClient(acd, sceneA);
  411. List<TestClient> destinationTestClients = new List<TestClient>();
  412. EntityTransferHelpers.SetupInformClientOfNeighbourTriggersNeighbourClientCreate(tc, destinationTestClients);
  413. ScenePresence beforeSceneASp = SceneHelpers.AddScenePresence(sceneA, tc, acd);
  414. beforeSceneASp.AbsolutePosition = new Vector3(30, 31, 32);
  415. Assert.That(beforeSceneASp, Is.Not.Null);
  416. Assert.That(beforeSceneASp.IsChildAgent, Is.False);
  417. ScenePresence beforeSceneBSp = sceneB.GetScenePresence(userId);
  418. Assert.That(beforeSceneBSp, Is.Not.Null);
  419. Assert.That(beforeSceneBSp.IsChildAgent, Is.True);
  420. // In this case, we will not receieve a second InformClientOfNeighbour since the viewer already knows
  421. // about the neighbour region it is teleporting to.
  422. sceneA.RequestTeleportLocation(
  423. beforeSceneASp.ControllingClient,
  424. sceneB.RegionInfo.RegionHandle,
  425. teleportPosition,
  426. teleportLookAt,
  427. (uint)TeleportFlags.ViaLocation);
  428. destinationTestClients[0].CompleteMovement();
  429. ScenePresence afterSceneASp = sceneA.GetScenePresence(userId);
  430. Assert.That(afterSceneASp, Is.Not.Null);
  431. Assert.That(afterSceneASp.IsChildAgent, Is.True);
  432. ScenePresence afterSceneBSp = sceneB.GetScenePresence(userId);
  433. Assert.That(afterSceneBSp, Is.Not.Null);
  434. Assert.That(afterSceneBSp.IsChildAgent, Is.False);
  435. Assert.That(afterSceneBSp.Scene.RegionInfo.RegionName, Is.EqualTo(sceneB.RegionInfo.RegionName));
  436. Assert.That(afterSceneBSp.AbsolutePosition, Is.EqualTo(teleportPosition));
  437. Assert.That(sceneA.GetRootAgentCount(), Is.EqualTo(0));
  438. Assert.That(sceneA.GetChildAgentCount(), Is.EqualTo(1));
  439. Assert.That(sceneB.GetRootAgentCount(), Is.EqualTo(1));
  440. Assert.That(sceneB.GetChildAgentCount(), Is.EqualTo(0));
  441. // TODO: Add assertions to check correct circuit details in both scenes.
  442. // Lookat is sent to the client only - sp.Lookat does not yield the same thing (calculation from camera
  443. // position instead).
  444. // Assert.That(sp.Lookat, Is.EqualTo(teleportLookAt));
  445. // TestHelpers.DisableLogging();
  446. }
  447. [Test]
  448. public void TestSameSimulatorNeighbouringRegionsV2()
  449. {
  450. TestHelpers.InMethod();
  451. // TestHelpers.EnableLogging();
  452. UUID userId = TestHelpers.ParseTail(0x1);
  453. EntityTransferModule etmA = new EntityTransferModule();
  454. EntityTransferModule etmB = new EntityTransferModule();
  455. LocalSimulationConnectorModule lscm = new LocalSimulationConnectorModule();
  456. IConfigSource config = new IniConfigSource();
  457. IConfig modulesConfig = config.AddConfig("Modules");
  458. modulesConfig.Set("EntityTransferModule", etmA.Name);
  459. modulesConfig.Set("SimulationServices", lscm.Name);
  460. SceneHelpers sh = new SceneHelpers();
  461. TestScene sceneA = sh.SetupScene("sceneA", TestHelpers.ParseTail(0x100), 1000, 1000);
  462. TestScene sceneB = sh.SetupScene("sceneB", TestHelpers.ParseTail(0x200), 1001, 1000);
  463. SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, config, lscm);
  464. SceneHelpers.SetupSceneModules(sceneA, config, new CapabilitiesModule(), etmA);
  465. SceneHelpers.SetupSceneModules(sceneB, config, new CapabilitiesModule(), etmB);
  466. Vector3 teleportPosition = new Vector3(10, 11, 12);
  467. Vector3 teleportLookAt = new Vector3(20, 21, 22);
  468. AgentCircuitData acd = SceneHelpers.GenerateAgentData(userId);
  469. TestClient tc = new TestClient(acd, sceneA);
  470. List<TestClient> destinationTestClients = new List<TestClient>();
  471. EntityTransferHelpers.SetupInformClientOfNeighbourTriggersNeighbourClientCreate(tc, destinationTestClients);
  472. ScenePresence beforeSceneASp = SceneHelpers.AddScenePresence(sceneA, tc, acd);
  473. beforeSceneASp.AbsolutePosition = new Vector3(30, 31, 32);
  474. Assert.That(beforeSceneASp, Is.Not.Null);
  475. Assert.That(beforeSceneASp.IsChildAgent, Is.False);
  476. ScenePresence beforeSceneBSp = sceneB.GetScenePresence(userId);
  477. Assert.That(beforeSceneBSp, Is.Not.Null);
  478. Assert.That(beforeSceneBSp.IsChildAgent, Is.True);
  479. // Here, we need to make clientA's receipt of SendRegionTeleport trigger clientB's CompleteMovement(). This
  480. // is to operate the teleport V2 mechanism where the EntityTransferModule will first request the client to
  481. // CompleteMovement to the region and then call UpdateAgent to the destination region to confirm the receipt
  482. // Both these operations will occur on different threads and will wait for each other.
  483. // We have to do this via ThreadPool directly since FireAndForget has been switched to sync for the V1
  484. // test protocol, where we are trying to avoid unpredictable async operations in regression tests.
  485. tc.OnTestClientSendRegionTeleport
  486. += (regionHandle, simAccess, regionExternalEndPoint, locationID, flags, capsURL)
  487. => ThreadPool.UnsafeQueueUserWorkItem(o => destinationTestClients[0].CompleteMovement(), null);
  488. sceneA.RequestTeleportLocation(
  489. beforeSceneASp.ControllingClient,
  490. sceneB.RegionInfo.RegionHandle,
  491. teleportPosition,
  492. teleportLookAt,
  493. (uint)TeleportFlags.ViaLocation);
  494. ScenePresence afterSceneASp = sceneA.GetScenePresence(userId);
  495. Assert.That(afterSceneASp, Is.Not.Null);
  496. Assert.That(afterSceneASp.IsChildAgent, Is.True);
  497. ScenePresence afterSceneBSp = sceneB.GetScenePresence(userId);
  498. Assert.That(afterSceneBSp, Is.Not.Null);
  499. Assert.That(afterSceneBSp.IsChildAgent, Is.False);
  500. Assert.That(afterSceneBSp.Scene.RegionInfo.RegionName, Is.EqualTo(sceneB.RegionInfo.RegionName));
  501. Assert.That(afterSceneBSp.AbsolutePosition, Is.EqualTo(teleportPosition));
  502. Assert.That(sceneA.GetRootAgentCount(), Is.EqualTo(0));
  503. Assert.That(sceneA.GetChildAgentCount(), Is.EqualTo(1));
  504. Assert.That(sceneB.GetRootAgentCount(), Is.EqualTo(1));
  505. Assert.That(sceneB.GetChildAgentCount(), Is.EqualTo(0));
  506. // TODO: Add assertions to check correct circuit details in both scenes.
  507. // Lookat is sent to the client only - sp.Lookat does not yield the same thing (calculation from camera
  508. // position instead).
  509. // Assert.That(sp.Lookat, Is.EqualTo(teleportLookAt));
  510. // TestHelpers.DisableLogging();
  511. }
  512. }
  513. }