ScenePresenceTeleportTests.cs 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665
  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.Servers;
  38. using OpenSim.Region.Framework.Interfaces;
  39. using OpenSim.Region.CoreModules.Framework;
  40. using OpenSim.Region.CoreModules.Framework.EntityTransfer;
  41. using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation;
  42. using OpenSim.Region.CoreModules.World.Permissions;
  43. using OpenSim.Tests.Common;
  44. namespace OpenSim.Region.Framework.Scenes.Tests
  45. {
  46. /// <summary>
  47. /// Teleport tests in a standalone OpenSim
  48. /// </summary>
  49. [TestFixture]
  50. public class ScenePresenceTeleportTests : OpenSimTestCase
  51. {
  52. [TestFixtureSetUp]
  53. public void FixtureInit()
  54. {
  55. // Don't allow tests to be bamboozled by asynchronous events. Execute everything on the same thread.
  56. Util.FireAndForgetMethod = FireAndForgetMethod.RegressionTest;
  57. }
  58. [TestFixtureTearDown]
  59. public void TearDown()
  60. {
  61. // We must set this back afterwards, otherwise later tests will fail since they're expecting multiple
  62. // threads. Possibly, later tests should be rewritten so none of them require async stuff (which regression
  63. // tests really shouldn't).
  64. Util.FireAndForgetMethod = Util.DefaultFireAndForgetMethod;
  65. }
  66. [Test]
  67. public void TestSameRegion()
  68. {
  69. TestHelpers.InMethod();
  70. // log4net.Config.XmlConfigurator.Configure();
  71. EntityTransferModule etm = new EntityTransferModule();
  72. IConfigSource config = new IniConfigSource();
  73. config.AddConfig("Modules");
  74. // Not strictly necessary since FriendsModule assumes it is the default (!)
  75. config.Configs["Modules"].Set("EntityTransferModule", etm.Name);
  76. TestScene scene = new SceneHelpers().SetupScene("sceneA", TestHelpers.ParseTail(0x100), 1000, 1000);
  77. SceneHelpers.SetupSceneModules(scene, config, etm);
  78. Vector3 teleportPosition = new Vector3(10, 11, 12);
  79. Vector3 teleportLookAt = new Vector3(20, 21, 22);
  80. ScenePresence sp = SceneHelpers.AddScenePresence(scene, TestHelpers.ParseTail(0x1));
  81. sp.AbsolutePosition = new Vector3(30, 31, 32);
  82. scene.RequestTeleportLocation(
  83. sp.ControllingClient,
  84. scene.RegionInfo.RegionHandle,
  85. teleportPosition,
  86. teleportLookAt,
  87. (uint)TeleportFlags.ViaLocation);
  88. Assert.That(sp.AbsolutePosition, Is.EqualTo(teleportPosition));
  89. Assert.That(scene.GetRootAgentCount(), Is.EqualTo(1));
  90. Assert.That(scene.GetChildAgentCount(), Is.EqualTo(0));
  91. // Lookat is sent to the client only - sp.Lookat does not yield the same thing (calculation from camera
  92. // position instead).
  93. // Assert.That(sp.Lookat, Is.EqualTo(teleportLookAt));
  94. }
  95. /*
  96. [Test]
  97. public void TestSameSimulatorIsolatedRegionsV1()
  98. {
  99. TestHelpers.InMethod();
  100. // TestHelpers.EnableLogging();
  101. UUID userId = TestHelpers.ParseTail(0x1);
  102. EntityTransferModule etmA = new EntityTransferModule();
  103. EntityTransferModule etmB = new EntityTransferModule();
  104. LocalSimulationConnectorModule lscm = new LocalSimulationConnectorModule();
  105. IConfigSource config = new IniConfigSource();
  106. IConfig modulesConfig = config.AddConfig("Modules");
  107. modulesConfig.Set("EntityTransferModule", etmA.Name);
  108. modulesConfig.Set("SimulationServices", lscm.Name);
  109. IConfig entityTransferConfig = config.AddConfig("EntityTransfer");
  110. // In order to run a single threaded regression test we do not want the entity transfer module waiting
  111. // for a callback from the destination scene before removing its avatar data.
  112. entityTransferConfig.Set("wait_for_callback", false);
  113. SceneHelpers sh = new SceneHelpers();
  114. TestScene sceneA = sh.SetupScene("sceneA", TestHelpers.ParseTail(0x100), 1000, 1000);
  115. TestScene sceneB = sh.SetupScene("sceneB", TestHelpers.ParseTail(0x200), 1002, 1000);
  116. SceneHelpers.SetupSceneModules(sceneA, config, etmA);
  117. SceneHelpers.SetupSceneModules(sceneB, config, etmB);
  118. SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, config, lscm);
  119. // FIXME: Hack - this is here temporarily to revert back to older entity transfer behaviour
  120. lscm.ServiceVersion = 0.1f;
  121. Vector3 teleportPosition = new Vector3(10, 11, 12);
  122. Vector3 teleportLookAt = new Vector3(20, 21, 22);
  123. ScenePresence sp = SceneHelpers.AddScenePresence(sceneA, userId);
  124. sp.AbsolutePosition = new Vector3(30, 31, 32);
  125. List<TestClient> destinationTestClients = new List<TestClient>();
  126. EntityTransferHelpers.SetupInformClientOfNeighbourTriggersNeighbourClientCreate(
  127. (TestClient)sp.ControllingClient, destinationTestClients);
  128. sceneA.RequestTeleportLocation(
  129. sp.ControllingClient,
  130. sceneB.RegionInfo.RegionHandle,
  131. teleportPosition,
  132. teleportLookAt,
  133. (uint)TeleportFlags.ViaLocation);
  134. // SetupInformClientOfNeighbour() will have handled the callback into the target scene to setup the child
  135. // agent. This call will now complete the movement of the user into the destination and upgrade the agent
  136. // from child to root.
  137. destinationTestClients[0].CompleteMovement();
  138. Assert.That(sceneA.GetScenePresence(userId), Is.Null);
  139. ScenePresence sceneBSp = sceneB.GetScenePresence(userId);
  140. Assert.That(sceneBSp, Is.Not.Null);
  141. Assert.That(sceneBSp.Scene.RegionInfo.RegionName, Is.EqualTo(sceneB.RegionInfo.RegionName));
  142. Assert.That(sceneBSp.AbsolutePosition, Is.EqualTo(teleportPosition));
  143. Assert.That(sceneA.GetRootAgentCount(), Is.EqualTo(0));
  144. Assert.That(sceneA.GetChildAgentCount(), Is.EqualTo(0));
  145. Assert.That(sceneB.GetRootAgentCount(), Is.EqualTo(1));
  146. Assert.That(sceneB.GetChildAgentCount(), Is.EqualTo(0));
  147. // TODO: Add assertions to check correct circuit details in both scenes.
  148. // Lookat is sent to the client only - sp.Lookat does not yield the same thing (calculation from camera
  149. // position instead).
  150. // Assert.That(sp.Lookat, Is.EqualTo(teleportLookAt));
  151. }
  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 DefaultPermissionsModule(), 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 DefaultPermissionsModule(), 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. /*
  383. [Test]
  384. public void TestSameSimulatorNeighbouringRegionsV1()
  385. {
  386. TestHelpers.InMethod();
  387. // TestHelpers.EnableLogging();
  388. UUID userId = TestHelpers.ParseTail(0x1);
  389. EntityTransferModule etmA = new EntityTransferModule();
  390. EntityTransferModule etmB = new EntityTransferModule();
  391. LocalSimulationConnectorModule lscm = new LocalSimulationConnectorModule();
  392. IConfigSource config = new IniConfigSource();
  393. IConfig modulesConfig = config.AddConfig("Modules");
  394. modulesConfig.Set("EntityTransferModule", etmA.Name);
  395. modulesConfig.Set("SimulationServices", lscm.Name);
  396. IConfig entityTransferConfig = config.AddConfig("EntityTransfer");
  397. // In order to run a single threaded regression test we do not want the entity transfer module waiting
  398. // for a callback from the destination scene before removing its avatar data.
  399. entityTransferConfig.Set("wait_for_callback", false);
  400. SceneHelpers sh = new SceneHelpers();
  401. TestScene sceneA = sh.SetupScene("sceneA", TestHelpers.ParseTail(0x100), 1000, 1000);
  402. TestScene sceneB = sh.SetupScene("sceneB", TestHelpers.ParseTail(0x200), 1001, 1000);
  403. SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, config, lscm);
  404. SceneHelpers.SetupSceneModules(sceneA, config, new CapabilitiesModule(), etmA);
  405. SceneHelpers.SetupSceneModules(sceneB, config, new CapabilitiesModule(), etmB);
  406. // FIXME: Hack - this is here temporarily to revert back to older entity transfer behaviour
  407. lscm.ServiceVersion = 0.1f;
  408. Vector3 teleportPosition = new Vector3(10, 11, 12);
  409. Vector3 teleportLookAt = new Vector3(20, 21, 22);
  410. AgentCircuitData acd = SceneHelpers.GenerateAgentData(userId);
  411. TestClient tc = new TestClient(acd, sceneA);
  412. List<TestClient> destinationTestClients = new List<TestClient>();
  413. EntityTransferHelpers.SetupInformClientOfNeighbourTriggersNeighbourClientCreate(tc, destinationTestClients);
  414. ScenePresence beforeSceneASp = SceneHelpers.AddScenePresence(sceneA, tc, acd);
  415. beforeSceneASp.AbsolutePosition = new Vector3(30, 31, 32);
  416. Assert.That(beforeSceneASp, Is.Not.Null);
  417. Assert.That(beforeSceneASp.IsChildAgent, Is.False);
  418. ScenePresence beforeSceneBSp = sceneB.GetScenePresence(userId);
  419. Assert.That(beforeSceneBSp, Is.Not.Null);
  420. Assert.That(beforeSceneBSp.IsChildAgent, Is.True);
  421. // In this case, we will not receieve a second InformClientOfNeighbour since the viewer already knows
  422. // about the neighbour region it is teleporting to.
  423. sceneA.RequestTeleportLocation(
  424. beforeSceneASp.ControllingClient,
  425. sceneB.RegionInfo.RegionHandle,
  426. teleportPosition,
  427. teleportLookAt,
  428. (uint)TeleportFlags.ViaLocation);
  429. destinationTestClients[0].CompleteMovement();
  430. ScenePresence afterSceneASp = sceneA.GetScenePresence(userId);
  431. Assert.That(afterSceneASp, Is.Not.Null);
  432. Assert.That(afterSceneASp.IsChildAgent, Is.True);
  433. ScenePresence afterSceneBSp = sceneB.GetScenePresence(userId);
  434. Assert.That(afterSceneBSp, Is.Not.Null);
  435. Assert.That(afterSceneBSp.IsChildAgent, Is.False);
  436. Assert.That(afterSceneBSp.Scene.RegionInfo.RegionName, Is.EqualTo(sceneB.RegionInfo.RegionName));
  437. Assert.That(afterSceneBSp.AbsolutePosition, Is.EqualTo(teleportPosition));
  438. Assert.That(sceneA.GetRootAgentCount(), Is.EqualTo(0));
  439. Assert.That(sceneA.GetChildAgentCount(), Is.EqualTo(1));
  440. Assert.That(sceneB.GetRootAgentCount(), Is.EqualTo(1));
  441. Assert.That(sceneB.GetChildAgentCount(), Is.EqualTo(0));
  442. // TODO: Add assertions to check correct circuit details in both scenes.
  443. // Lookat is sent to the client only - sp.Lookat does not yield the same thing (calculation from camera
  444. // position instead).
  445. // Assert.That(sp.Lookat, Is.EqualTo(teleportLookAt));
  446. // TestHelpers.DisableLogging();
  447. }
  448. */
  449. [Test]
  450. public void TestSameSimulatorNeighbouringRegionsV2()
  451. {
  452. TestHelpers.InMethod();
  453. // TestHelpers.EnableLogging();
  454. UUID userId = TestHelpers.ParseTail(0x1);
  455. EntityTransferModule etmA = new EntityTransferModule();
  456. EntityTransferModule etmB = new EntityTransferModule();
  457. LocalSimulationConnectorModule lscm = new LocalSimulationConnectorModule();
  458. IConfigSource config = new IniConfigSource();
  459. IConfig modulesConfig = config.AddConfig("Modules");
  460. modulesConfig.Set("EntityTransferModule", etmA.Name);
  461. modulesConfig.Set("SimulationServices", lscm.Name);
  462. SceneHelpers sh = new SceneHelpers();
  463. TestScene sceneA = sh.SetupScene("sceneA", TestHelpers.ParseTail(0x100), 1000, 1000);
  464. TestScene sceneB = sh.SetupScene("sceneB", TestHelpers.ParseTail(0x200), 1001, 1000);
  465. SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, config, lscm);
  466. SceneHelpers.SetupSceneModules(sceneA, config, new CapabilitiesModule(), etmA);
  467. SceneHelpers.SetupSceneModules(sceneB, config, new CapabilitiesModule(), etmB);
  468. Vector3 teleportPosition = new Vector3(10, 11, 12);
  469. Vector3 teleportLookAt = new Vector3(20, 21, 22);
  470. AgentCircuitData acd = SceneHelpers.GenerateAgentData(userId);
  471. TestClient tc = new TestClient(acd, sceneA);
  472. List<TestClient> destinationTestClients = new List<TestClient>();
  473. EntityTransferHelpers.SetupInformClientOfNeighbourTriggersNeighbourClientCreate(tc, destinationTestClients);
  474. ScenePresence beforeSceneASp = SceneHelpers.AddScenePresence(sceneA, tc, acd);
  475. beforeSceneASp.AbsolutePosition = new Vector3(30, 31, 32);
  476. Assert.That(beforeSceneASp, Is.Not.Null);
  477. Assert.That(beforeSceneASp.IsChildAgent, Is.False);
  478. ScenePresence beforeSceneBSp = sceneB.GetScenePresence(userId);
  479. Assert.That(beforeSceneBSp, Is.Not.Null);
  480. Assert.That(beforeSceneBSp.IsChildAgent, Is.True);
  481. // Here, we need to make clientA's receipt of SendRegionTeleport trigger clientB's CompleteMovement(). This
  482. // is to operate the teleport V2 mechanism where the EntityTransferModule will first request the client to
  483. // CompleteMovement to the region and then call UpdateAgent to the destination region to confirm the receipt
  484. // Both these operations will occur on different threads and will wait for each other.
  485. // We have to do this via ThreadPool directly since FireAndForget has been switched to sync for the V1
  486. // test protocol, where we are trying to avoid unpredictable async operations in regression tests.
  487. tc.OnTestClientSendRegionTeleport
  488. += (regionHandle, simAccess, regionExternalEndPoint, locationID, flags, capsURL)
  489. => ThreadPool.UnsafeQueueUserWorkItem(o => destinationTestClients[0].CompleteMovement(), null);
  490. sceneA.RequestTeleportLocation(
  491. beforeSceneASp.ControllingClient,
  492. sceneB.RegionInfo.RegionHandle,
  493. teleportPosition,
  494. teleportLookAt,
  495. (uint)TeleportFlags.ViaLocation);
  496. ScenePresence afterSceneASp = sceneA.GetScenePresence(userId);
  497. Assert.That(afterSceneASp, Is.Not.Null);
  498. Assert.That(afterSceneASp.IsChildAgent, Is.True);
  499. ScenePresence afterSceneBSp = sceneB.GetScenePresence(userId);
  500. Assert.That(afterSceneBSp, Is.Not.Null);
  501. Assert.That(afterSceneBSp.IsChildAgent, Is.False);
  502. Assert.That(afterSceneBSp.Scene.RegionInfo.RegionName, Is.EqualTo(sceneB.RegionInfo.RegionName));
  503. Assert.That(afterSceneBSp.AbsolutePosition, Is.EqualTo(teleportPosition));
  504. Assert.That(sceneA.GetRootAgentCount(), Is.EqualTo(0));
  505. Assert.That(sceneA.GetChildAgentCount(), Is.EqualTo(1));
  506. Assert.That(sceneB.GetRootAgentCount(), Is.EqualTo(1));
  507. Assert.That(sceneB.GetChildAgentCount(), Is.EqualTo(0));
  508. // TODO: Add assertions to check correct circuit details in both scenes.
  509. // Lookat is sent to the client only - sp.Lookat does not yield the same thing (calculation from camera
  510. // position instead).
  511. // Assert.That(sp.Lookat, Is.EqualTo(teleportLookAt));
  512. // TestHelpers.DisableLogging();
  513. }
  514. }
  515. }