aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceCrossingTests.cs
diff options
context:
space:
mode:
authorUbitUmarov2015-09-01 11:43:07 +0100
committerUbitUmarov2015-09-01 11:43:07 +0100
commitfb78b182520fc9bb0f971afd0322029c70278ea6 (patch)
treeb4e30d383938fdeef8c92d1d1c2f44bb61d329bd /OpenSim/Region/Framework/Scenes/Tests/ScenePresenceCrossingTests.cs
parentlixo (diff)
parentMantis #7713: fixed bug introduced by 1st MOSES patch. (diff)
downloadopensim-SC-fb78b182520fc9bb0f971afd0322029c70278ea6.zip
opensim-SC-fb78b182520fc9bb0f971afd0322029c70278ea6.tar.gz
opensim-SC-fb78b182520fc9bb0f971afd0322029c70278ea6.tar.bz2
opensim-SC-fb78b182520fc9bb0f971afd0322029c70278ea6.tar.xz
Merge remote-tracking branch 'os/master'
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/Tests/ScenePresenceCrossingTests.cs')
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/ScenePresenceCrossingTests.cs248
1 files changed, 248 insertions, 0 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceCrossingTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceCrossingTests.cs
new file mode 100644
index 0000000..e14da8b
--- /dev/null
+++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceCrossingTests.cs
@@ -0,0 +1,248 @@
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
28using System;
29using System.Collections.Generic;
30using System.Reflection;
31using Nini.Config;
32using NUnit.Framework;
33using OpenMetaverse;
34using OpenSim.Framework;
35using OpenSim.Framework.Communications;
36using OpenSim.Framework.Servers;
37using OpenSim.Region.Framework.Interfaces;
38using OpenSim.Region.CoreModules.Framework;
39using OpenSim.Region.CoreModules.Framework.EntityTransfer;
40using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation;
41using OpenSim.Region.CoreModules.World.Permissions;
42using OpenSim.Tests.Common;
43
44namespace OpenSim.Region.Framework.Scenes.Tests
45{
46 [TestFixture]
47 public class ScenePresenceCrossingTests : OpenSimTestCase
48 {
49 [TestFixtureSetUp]
50 public void FixtureInit()
51 {
52 // Don't allow tests to be bamboozled by asynchronous events. Execute everything on the same thread.
53 Util.FireAndForgetMethod = FireAndForgetMethod.RegressionTest;
54 }
55
56 [TestFixtureTearDown]
57 public void TearDown()
58 {
59 // We must set this back afterwards, otherwise later tests will fail since they're expecting multiple
60 // threads. Possibly, later tests should be rewritten so none of them require async stuff (which regression
61 // tests really shouldn't).
62 Util.FireAndForgetMethod = Util.DefaultFireAndForgetMethod;
63 }
64
65 [Test]
66 public void TestCrossOnSameSimulator()
67 {
68 TestHelpers.InMethod();
69// TestHelpers.EnableLogging();
70
71 UUID userId = TestHelpers.ParseTail(0x1);
72
73// TestEventQueueGetModule eqmA = new TestEventQueueGetModule();
74 EntityTransferModule etmA = new EntityTransferModule();
75 EntityTransferModule etmB = new EntityTransferModule();
76 LocalSimulationConnectorModule lscm = new LocalSimulationConnectorModule();
77
78 IConfigSource config = new IniConfigSource();
79 IConfig modulesConfig = config.AddConfig("Modules");
80 modulesConfig.Set("EntityTransferModule", etmA.Name);
81 modulesConfig.Set("SimulationServices", lscm.Name);
82// IConfig entityTransferConfig = config.AddConfig("EntityTransfer");
83
84 // In order to run a single threaded regression test we do not want the entity transfer module waiting
85 // for a callback from the destination scene before removing its avatar data.
86// entityTransferConfig.Set("wait_for_callback", false);
87
88 SceneHelpers sh = new SceneHelpers();
89 TestScene sceneA = sh.SetupScene("sceneA", TestHelpers.ParseTail(0x100), 1000, 1000);
90 TestScene sceneB = sh.SetupScene("sceneB", TestHelpers.ParseTail(0x200), 1000, 999);
91
92 SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, config, lscm);
93 SceneHelpers.SetupSceneModules(sceneA, config, new CapabilitiesModule(), etmA);
94// SceneHelpers.SetupSceneModules(sceneA, config, new CapabilitiesModule(), etmA, eqmA);
95 SceneHelpers.SetupSceneModules(sceneB, config, new CapabilitiesModule(), etmB);
96
97 AgentCircuitData acd = SceneHelpers.GenerateAgentData(userId);
98 TestClient tc = new TestClient(acd, sceneA);
99 List<TestClient> destinationTestClients = new List<TestClient>();
100 EntityTransferHelpers.SetupInformClientOfNeighbourTriggersNeighbourClientCreate(tc, destinationTestClients);
101
102 ScenePresence originalSp = SceneHelpers.AddScenePresence(sceneA, tc, acd);
103 originalSp.AbsolutePosition = new Vector3(128, 32, 10);
104
105// originalSp.Flying = true;
106
107// Console.WriteLine("First pos {0}", originalSp.AbsolutePosition);
108
109// eqmA.ClearEvents();
110
111 AgentUpdateArgs moveArgs = new AgentUpdateArgs();
112 //moveArgs.BodyRotation = Quaternion.CreateFromEulers(Vector3.Zero);
113 moveArgs.BodyRotation = Quaternion.CreateFromEulers(new Vector3(0, 0, (float)-(Math.PI / 2)));
114 moveArgs.ControlFlags = (uint)AgentManager.ControlFlags.AGENT_CONTROL_AT_POS;
115 moveArgs.SessionID = acd.SessionID;
116
117 originalSp.HandleAgentUpdate(originalSp.ControllingClient, moveArgs);
118
119 sceneA.Update(1);
120
121// Console.WriteLine("Second pos {0}", originalSp.AbsolutePosition);
122
123 // FIXME: This is a sufficient number of updates to for the presence to reach the northern border.
124 // But really we want to do this in a more robust way.
125 for (int i = 0; i < 100; i++)
126 {
127 sceneA.Update(1);
128// Console.WriteLine("Pos {0}", originalSp.AbsolutePosition);
129 }
130
131 // Need to sort processing of EnableSimulator message on adding scene presences before we can test eqm
132 // messages
133// Dictionary<UUID, List<TestEventQueueGetModule.Event>> eqmEvents = eqmA.Events;
134//
135// Assert.That(eqmEvents.Count, Is.EqualTo(1));
136// Assert.That(eqmEvents.ContainsKey(originalSp.UUID), Is.True);
137//
138// List<TestEventQueueGetModule.Event> spEqmEvents = eqmEvents[originalSp.UUID];
139//
140// Assert.That(spEqmEvents.Count, Is.EqualTo(1));
141// Assert.That(spEqmEvents[0].Name, Is.EqualTo("CrossRegion"));
142
143 // sceneA should now only have a child agent
144 ScenePresence spAfterCrossSceneA = sceneA.GetScenePresence(originalSp.UUID);
145 Assert.That(spAfterCrossSceneA.IsChildAgent, Is.True);
146
147 ScenePresence spAfterCrossSceneB = sceneB.GetScenePresence(originalSp.UUID);
148
149 // Agent remains a child until the client triggers complete movement
150 Assert.That(spAfterCrossSceneB.IsChildAgent, Is.True);
151
152 TestClient sceneBTc = ((TestClient)spAfterCrossSceneB.ControllingClient);
153
154 int agentMovementCompleteReceived = 0;
155 sceneBTc.OnReceivedMoveAgentIntoRegion += (ri, pos, look) => agentMovementCompleteReceived++;
156
157 sceneBTc.CompleteMovement();
158
159 Assert.That(agentMovementCompleteReceived, Is.EqualTo(1));
160 Assert.That(spAfterCrossSceneB.IsChildAgent, Is.False);
161 }
162
163 /// <summary>
164 /// Test a cross attempt where the user can see into the neighbour but does not have permission to become
165 /// root there.
166 /// </summary>
167 [Test]
168 public void TestCrossOnSameSimulatorNoRootDestPerm()
169 {
170 TestHelpers.InMethod();
171// TestHelpers.EnableLogging();
172
173 UUID userId = TestHelpers.ParseTail(0x1);
174
175 EntityTransferModule etmA = new EntityTransferModule();
176 EntityTransferModule etmB = new EntityTransferModule();
177 LocalSimulationConnectorModule lscm = new LocalSimulationConnectorModule();
178
179 IConfigSource config = new IniConfigSource();
180 IConfig modulesConfig = config.AddConfig("Modules");
181 modulesConfig.Set("EntityTransferModule", etmA.Name);
182 modulesConfig.Set("SimulationServices", lscm.Name);
183
184 SceneHelpers sh = new SceneHelpers();
185 TestScene sceneA = sh.SetupScene("sceneA", TestHelpers.ParseTail(0x100), 1000, 1000);
186 TestScene sceneB = sh.SetupScene("sceneB", TestHelpers.ParseTail(0x200), 1000, 999);
187
188 SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, config, lscm);
189 SceneHelpers.SetupSceneModules(sceneA, config, new CapabilitiesModule(), etmA);
190
191 // We need to set up the permisions module on scene B so that our later use of agent limit to deny
192 // QueryAccess won't succeed anyway because administrators are always allowed in and the default
193 // IsAdministrator if no permissions module is present is true.
194 SceneHelpers.SetupSceneModules(sceneB, config, new CapabilitiesModule(), new PermissionsModule(), etmB);
195
196 AgentCircuitData acd = SceneHelpers.GenerateAgentData(userId);
197 TestClient tc = new TestClient(acd, sceneA);
198 List<TestClient> destinationTestClients = new List<TestClient>();
199 EntityTransferHelpers.SetupInformClientOfNeighbourTriggersNeighbourClientCreate(tc, destinationTestClients);
200
201 // Make sure sceneB will not accept this avatar.
202 sceneB.RegionInfo.EstateSettings.PublicAccess = false;
203
204 ScenePresence originalSp = SceneHelpers.AddScenePresence(sceneA, tc, acd);
205 originalSp.AbsolutePosition = new Vector3(128, 32, 10);
206
207 AgentUpdateArgs moveArgs = new AgentUpdateArgs();
208 //moveArgs.BodyRotation = Quaternion.CreateFromEulers(Vector3.Zero);
209 moveArgs.BodyRotation = Quaternion.CreateFromEulers(new Vector3(0, 0, (float)-(Math.PI / 2)));
210 moveArgs.ControlFlags = (uint)AgentManager.ControlFlags.AGENT_CONTROL_AT_POS;
211 moveArgs.SessionID = acd.SessionID;
212
213 originalSp.HandleAgentUpdate(originalSp.ControllingClient, moveArgs);
214
215 sceneA.Update(1);
216
217// Console.WriteLine("Second pos {0}", originalSp.AbsolutePosition);
218
219 // FIXME: This is a sufficient number of updates to for the presence to reach the northern border.
220 // But really we want to do this in a more robust way.
221 for (int i = 0; i < 100; i++)
222 {
223 sceneA.Update(1);
224// Console.WriteLine("Pos {0}", originalSp.AbsolutePosition);
225 }
226
227 // sceneA agent should still be root
228 ScenePresence spAfterCrossSceneA = sceneA.GetScenePresence(originalSp.UUID);
229 Assert.That(spAfterCrossSceneA.IsChildAgent, Is.False);
230
231 ScenePresence spAfterCrossSceneB = sceneB.GetScenePresence(originalSp.UUID);
232
233 // sceneB agent should also still be root
234 Assert.That(spAfterCrossSceneB.IsChildAgent, Is.True);
235
236 // sceneB should ignore unauthorized attempt to upgrade agent to root
237 TestClient sceneBTc = ((TestClient)spAfterCrossSceneB.ControllingClient);
238
239 int agentMovementCompleteReceived = 0;
240 sceneBTc.OnReceivedMoveAgentIntoRegion += (ri, pos, look) => agentMovementCompleteReceived++;
241
242 sceneBTc.CompleteMovement();
243
244 Assert.That(agentMovementCompleteReceived, Is.EqualTo(0));
245 Assert.That(spAfterCrossSceneB.IsChildAgent, Is.True);
246 }
247 }
248} \ No newline at end of file