diff options
author | Justin Clark-Casey (justincc) | 2011-10-12 21:31:22 +0100 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2011-10-12 21:31:22 +0100 |
commit | f5f7ca47ea7a27fb7f82367cc7a4e04e11cb5155 (patch) | |
tree | a95a6a23409f921793638c51fd31b53cdecd671f /OpenSim/Region/ClientStack/Linden/UDP/Tests/BasicCircuitTests.cs | |
parent | When shutting down XEngine, log how many scripts are being shutdown so the us... (diff) | |
download | opensim-SC-f5f7ca47ea7a27fb7f82367cc7a4e04e11cb5155.zip opensim-SC-f5f7ca47ea7a27fb7f82367cc7a4e04e11cb5155.tar.gz opensim-SC-f5f7ca47ea7a27fb7f82367cc7a4e04e11cb5155.tar.bz2 opensim-SC-f5f7ca47ea7a27fb7f82367cc7a4e04e11cb5155.tar.xz |
Bring LindenUDP.Tests back from the dead. No tests are running.
Code drift means that most of this stuff doesn't compile but the structure is still useful.
Diffstat (limited to 'OpenSim/Region/ClientStack/Linden/UDP/Tests/BasicCircuitTests.cs')
-rw-r--r-- | OpenSim/Region/ClientStack/Linden/UDP/Tests/BasicCircuitTests.cs | 343 |
1 files changed, 171 insertions, 172 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/Tests/BasicCircuitTests.cs b/OpenSim/Region/ClientStack/Linden/UDP/Tests/BasicCircuitTests.cs index daab84f..b8a4e8e 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/Tests/BasicCircuitTests.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/Tests/BasicCircuitTests.cs | |||
@@ -29,7 +29,6 @@ using System.Net; | |||
29 | using log4net.Config; | 29 | using log4net.Config; |
30 | using Nini.Config; | 30 | using Nini.Config; |
31 | using NUnit.Framework; | 31 | using NUnit.Framework; |
32 | using NUnit.Framework.SyntaxHelpers; | ||
33 | using OpenMetaverse; | 32 | using OpenMetaverse; |
34 | using OpenMetaverse.Packets; | 33 | using OpenMetaverse.Packets; |
35 | using OpenSim.Framework; | 34 | using OpenSim.Framework; |
@@ -57,27 +56,27 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests | |||
57 | } | 56 | } |
58 | } | 57 | } |
59 | 58 | ||
60 | /// <summary> | 59 | // /// <summary> |
61 | /// Add a client for testing | 60 | // /// Add a client for testing |
62 | /// </summary> | 61 | // /// </summary> |
63 | /// <param name="scene"></param> | 62 | // /// <param name="scene"></param> |
64 | /// <param name="testLLUDPServer"></param> | 63 | // /// <param name="testLLUDPServer"></param> |
65 | /// <param name="testPacketServer"></param> | 64 | // /// <param name="testPacketServer"></param> |
66 | /// <param name="acm">Agent circuit manager used in setting up the stack</param> | 65 | // /// <param name="acm">Agent circuit manager used in setting up the stack</param> |
67 | protected void SetupStack( | 66 | // protected void SetupStack( |
68 | IScene scene, out TestLLUDPServer testLLUDPServer, out TestLLPacketServer testPacketServer, | 67 | // IScene scene, out TestLLUDPServer testLLUDPServer, out TestLLPacketServer testPacketServer, |
69 | out AgentCircuitManager acm) | 68 | // out AgentCircuitManager acm) |
70 | { | 69 | // { |
71 | IConfigSource configSource = new IniConfigSource(); | 70 | // IConfigSource configSource = new IniConfigSource(); |
72 | ClientStackUserSettings userSettings = new ClientStackUserSettings(); | 71 | // ClientStackUserSettings userSettings = new ClientStackUserSettings(); |
73 | testLLUDPServer = new TestLLUDPServer(); | 72 | // testLLUDPServer = new TestLLUDPServer(); |
74 | acm = new AgentCircuitManager(); | 73 | // acm = new AgentCircuitManager(); |
75 | 74 | // | |
76 | uint port = 666; | 75 | // uint port = 666; |
77 | testLLUDPServer.Initialise(null, ref port, 0, false, configSource, acm); | 76 | // testLLUDPServer.Initialise(null, ref port, 0, false, configSource, acm); |
78 | testPacketServer = new TestLLPacketServer(testLLUDPServer, userSettings); | 77 | // testPacketServer = new TestLLPacketServer(testLLUDPServer, userSettings); |
79 | testLLUDPServer.LocalScene = scene; | 78 | // testLLUDPServer.LocalScene = scene; |
80 | } | 79 | // } |
81 | 80 | ||
82 | /// <summary> | 81 | /// <summary> |
83 | /// Set up a client for tests which aren't concerned with this process itself and where only one client is being | 82 | /// Set up a client for tests which aren't concerned with this process itself and where only one client is being |
@@ -145,155 +144,155 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests | |||
145 | return onp; | 144 | return onp; |
146 | } | 145 | } |
147 | 146 | ||
148 | /// <summary> | 147 | // /// <summary> |
149 | /// Test adding a client to the stack | 148 | // /// Test adding a client to the stack |
150 | /// </summary> | 149 | // /// </summary> |
151 | [Test, LongRunning] | 150 | // [Test, LongRunning] |
152 | public void TestAddClient() | 151 | // public void TestAddClient() |
153 | { | 152 | // { |
154 | TestHelper.InMethod(); | 153 | // TestHelper.InMethod(); |
155 | 154 | // | |
156 | uint myCircuitCode = 123456; | 155 | // uint myCircuitCode = 123456; |
157 | UUID myAgentUuid = UUID.Parse("00000000-0000-0000-0000-000000000001"); | 156 | // UUID myAgentUuid = UUID.Parse("00000000-0000-0000-0000-000000000001"); |
158 | UUID mySessionUuid = UUID.Parse("00000000-0000-0000-0000-000000000002"); | 157 | // UUID mySessionUuid = UUID.Parse("00000000-0000-0000-0000-000000000002"); |
159 | 158 | // | |
160 | TestLLUDPServer testLLUDPServer; | 159 | // TestLLUDPServer testLLUDPServer; |
161 | TestLLPacketServer testLLPacketServer; | 160 | // TestLLPacketServer testLLPacketServer; |
162 | AgentCircuitManager acm; | 161 | // AgentCircuitManager acm; |
163 | SetupStack(new MockScene(), out testLLUDPServer, out testLLPacketServer, out acm); | 162 | // SetupStack(new MockScene(), out testLLUDPServer, out testLLPacketServer, out acm); |
164 | 163 | // | |
165 | AgentCircuitData acd = new AgentCircuitData(); | 164 | // AgentCircuitData acd = new AgentCircuitData(); |
166 | acd.AgentID = myAgentUuid; | 165 | // acd.AgentID = myAgentUuid; |
167 | acd.SessionID = mySessionUuid; | 166 | // acd.SessionID = mySessionUuid; |
168 | 167 | // | |
169 | UseCircuitCodePacket uccp = new UseCircuitCodePacket(); | 168 | // UseCircuitCodePacket uccp = new UseCircuitCodePacket(); |
170 | 169 | // | |
171 | UseCircuitCodePacket.CircuitCodeBlock uccpCcBlock | 170 | // UseCircuitCodePacket.CircuitCodeBlock uccpCcBlock |
172 | = new UseCircuitCodePacket.CircuitCodeBlock(); | 171 | // = new UseCircuitCodePacket.CircuitCodeBlock(); |
173 | uccpCcBlock.Code = myCircuitCode; | 172 | // uccpCcBlock.Code = myCircuitCode; |
174 | uccpCcBlock.ID = myAgentUuid; | 173 | // uccpCcBlock.ID = myAgentUuid; |
175 | uccpCcBlock.SessionID = mySessionUuid; | 174 | // uccpCcBlock.SessionID = mySessionUuid; |
176 | uccp.CircuitCode = uccpCcBlock; | 175 | // uccp.CircuitCode = uccpCcBlock; |
177 | 176 | // | |
178 | EndPoint testEp = new IPEndPoint(IPAddress.Loopback, 999); | 177 | // EndPoint testEp = new IPEndPoint(IPAddress.Loopback, 999); |
179 | 178 | // | |
180 | testLLUDPServer.LoadReceive(uccp, testEp); | 179 | // testLLUDPServer.LoadReceive(uccp, testEp); |
181 | testLLUDPServer.ReceiveData(null); | 180 | // testLLUDPServer.ReceiveData(null); |
182 | 181 | // | |
183 | // Circuit shouildn't exist since the circuit manager doesn't know about this circuit for authentication yet | 182 | // // Circuit shouildn't exist since the circuit manager doesn't know about this circuit for authentication yet |
184 | Assert.IsFalse(testLLUDPServer.HasCircuit(myCircuitCode)); | 183 | // Assert.IsFalse(testLLUDPServer.HasCircuit(myCircuitCode)); |
185 | 184 | // | |
186 | acm.AddNewCircuit(myCircuitCode, acd); | 185 | // acm.AddNewCircuit(myCircuitCode, acd); |
187 | 186 | // | |
188 | testLLUDPServer.LoadReceive(uccp, testEp); | 187 | // testLLUDPServer.LoadReceive(uccp, testEp); |
189 | testLLUDPServer.ReceiveData(null); | 188 | // testLLUDPServer.ReceiveData(null); |
190 | 189 | // | |
191 | // Should succeed now | 190 | // // Should succeed now |
192 | Assert.IsTrue(testLLUDPServer.HasCircuit(myCircuitCode)); | 191 | // Assert.IsTrue(testLLUDPServer.HasCircuit(myCircuitCode)); |
193 | Assert.IsFalse(testLLUDPServer.HasCircuit(101)); | 192 | // Assert.IsFalse(testLLUDPServer.HasCircuit(101)); |
194 | } | 193 | // } |
195 | 194 | // | |
196 | /// <summary> | 195 | // /// <summary> |
197 | /// Test removing a client from the stack | 196 | // /// Test removing a client from the stack |
198 | /// </summary> | 197 | // /// </summary> |
199 | [Test] | 198 | // [Test] |
200 | public void TestRemoveClient() | 199 | // public void TestRemoveClient() |
201 | { | 200 | // { |
202 | TestHelper.InMethod(); | 201 | // TestHelper.InMethod(); |
203 | 202 | // | |
204 | uint myCircuitCode = 123457; | 203 | // uint myCircuitCode = 123457; |
205 | 204 | // | |
206 | TestLLUDPServer testLLUDPServer; | 205 | // TestLLUDPServer testLLUDPServer; |
207 | TestLLPacketServer testLLPacketServer; | 206 | // TestLLPacketServer testLLPacketServer; |
208 | AgentCircuitManager acm; | 207 | // AgentCircuitManager acm; |
209 | SetupStack(new MockScene(), out testLLUDPServer, out testLLPacketServer, out acm); | 208 | // SetupStack(new MockScene(), out testLLUDPServer, out testLLPacketServer, out acm); |
210 | AddClient(myCircuitCode, new IPEndPoint(IPAddress.Loopback, 1000), testLLUDPServer, acm); | 209 | // AddClient(myCircuitCode, new IPEndPoint(IPAddress.Loopback, 1000), testLLUDPServer, acm); |
211 | 210 | // | |
212 | testLLUDPServer.RemoveClientCircuit(myCircuitCode); | 211 | // testLLUDPServer.RemoveClientCircuit(myCircuitCode); |
213 | Assert.IsFalse(testLLUDPServer.HasCircuit(myCircuitCode)); | 212 | // Assert.IsFalse(testLLUDPServer.HasCircuit(myCircuitCode)); |
214 | 213 | // | |
215 | // Check that removing a non-existant circuit doesn't have any bad effects | 214 | // // Check that removing a non-existant circuit doesn't have any bad effects |
216 | testLLUDPServer.RemoveClientCircuit(101); | 215 | // testLLUDPServer.RemoveClientCircuit(101); |
217 | Assert.IsFalse(testLLUDPServer.HasCircuit(101)); | 216 | // Assert.IsFalse(testLLUDPServer.HasCircuit(101)); |
218 | } | 217 | // } |
219 | 218 | // | |
220 | /// <summary> | 219 | // /// <summary> |
221 | /// Make sure that the client stack reacts okay to malformed packets | 220 | // /// Make sure that the client stack reacts okay to malformed packets |
222 | /// </summary> | 221 | // /// </summary> |
223 | [Test] | 222 | // [Test] |
224 | public void TestMalformedPacketSend() | 223 | // public void TestMalformedPacketSend() |
225 | { | 224 | // { |
226 | TestHelper.InMethod(); | 225 | // TestHelper.InMethod(); |
227 | 226 | // | |
228 | uint myCircuitCode = 123458; | 227 | // uint myCircuitCode = 123458; |
229 | EndPoint testEp = new IPEndPoint(IPAddress.Loopback, 1001); | 228 | // EndPoint testEp = new IPEndPoint(IPAddress.Loopback, 1001); |
230 | MockScene scene = new MockScene(); | 229 | // MockScene scene = new MockScene(); |
231 | 230 | // | |
232 | TestLLUDPServer testLLUDPServer; | 231 | // TestLLUDPServer testLLUDPServer; |
233 | TestLLPacketServer testLLPacketServer; | 232 | // TestLLPacketServer testLLPacketServer; |
234 | AgentCircuitManager acm; | 233 | // AgentCircuitManager acm; |
235 | SetupStack(scene, out testLLUDPServer, out testLLPacketServer, out acm); | 234 | // SetupStack(scene, out testLLUDPServer, out testLLPacketServer, out acm); |
236 | AddClient(myCircuitCode, testEp, testLLUDPServer, acm); | 235 | // AddClient(myCircuitCode, testEp, testLLUDPServer, acm); |
237 | 236 | // | |
238 | byte[] data = new byte[] { 0x01, 0x02, 0x03, 0x04 }; | 237 | // byte[] data = new byte[] { 0x01, 0x02, 0x03, 0x04 }; |
239 | 238 | // | |
240 | // Send two garbled 'packets' in succession | 239 | // // Send two garbled 'packets' in succession |
241 | testLLUDPServer.LoadReceive(data, testEp); | 240 | // testLLUDPServer.LoadReceive(data, testEp); |
242 | testLLUDPServer.LoadReceive(data, testEp); | 241 | // testLLUDPServer.LoadReceive(data, testEp); |
243 | testLLUDPServer.ReceiveData(null); | 242 | // testLLUDPServer.ReceiveData(null); |
244 | 243 | // | |
245 | // Check that we are still here | 244 | // // Check that we are still here |
246 | Assert.IsTrue(testLLUDPServer.HasCircuit(myCircuitCode)); | 245 | // Assert.IsTrue(testLLUDPServer.HasCircuit(myCircuitCode)); |
247 | Assert.That(testLLPacketServer.GetTotalPacketsReceived(), Is.EqualTo(0)); | 246 | // Assert.That(testLLPacketServer.GetTotalPacketsReceived(), Is.EqualTo(0)); |
248 | 247 | // | |
249 | // Check that sending a valid packet to same circuit still succeeds | 248 | // // Check that sending a valid packet to same circuit still succeeds |
250 | Assert.That(scene.ObjectNameCallsReceived, Is.EqualTo(0)); | 249 | // Assert.That(scene.ObjectNameCallsReceived, Is.EqualTo(0)); |
251 | 250 | // | |
252 | testLLUDPServer.LoadReceive(BuildTestObjectNamePacket(1, "helloooo"), testEp); | 251 | // testLLUDPServer.LoadReceive(BuildTestObjectNamePacket(1, "helloooo"), testEp); |
253 | testLLUDPServer.ReceiveData(null); | 252 | // testLLUDPServer.ReceiveData(null); |
254 | 253 | // | |
255 | Assert.That(testLLPacketServer.GetTotalPacketsReceived(), Is.EqualTo(1)); | 254 | // Assert.That(testLLPacketServer.GetTotalPacketsReceived(), Is.EqualTo(1)); |
256 | Assert.That(testLLPacketServer.GetPacketsReceivedFor(PacketType.ObjectName), Is.EqualTo(1)); | 255 | // Assert.That(testLLPacketServer.GetPacketsReceivedFor(PacketType.ObjectName), Is.EqualTo(1)); |
257 | } | 256 | // } |
258 | 257 | // | |
259 | /// <summary> | 258 | // /// <summary> |
260 | /// Test that the stack continues to work even if some client has caused a | 259 | // /// Test that the stack continues to work even if some client has caused a |
261 | /// SocketException on Socket.BeginReceive() | 260 | // /// SocketException on Socket.BeginReceive() |
262 | /// </summary> | 261 | // /// </summary> |
263 | [Test] | 262 | // [Test] |
264 | public void TestExceptionOnBeginReceive() | 263 | // public void TestExceptionOnBeginReceive() |
265 | { | 264 | // { |
266 | TestHelper.InMethod(); | 265 | // TestHelper.InMethod(); |
267 | 266 | // | |
268 | MockScene scene = new MockScene(); | 267 | // MockScene scene = new MockScene(); |
269 | 268 | // | |
270 | uint circuitCodeA = 130000; | 269 | // uint circuitCodeA = 130000; |
271 | EndPoint epA = new IPEndPoint(IPAddress.Loopback, 1300); | 270 | // EndPoint epA = new IPEndPoint(IPAddress.Loopback, 1300); |
272 | UUID agentIdA = UUID.Parse("00000000-0000-0000-0000-000000001300"); | 271 | // UUID agentIdA = UUID.Parse("00000000-0000-0000-0000-000000001300"); |
273 | UUID sessionIdA = UUID.Parse("00000000-0000-0000-0000-000000002300"); | 272 | // UUID sessionIdA = UUID.Parse("00000000-0000-0000-0000-000000002300"); |
274 | 273 | // | |
275 | uint circuitCodeB = 130001; | 274 | // uint circuitCodeB = 130001; |
276 | EndPoint epB = new IPEndPoint(IPAddress.Loopback, 1301); | 275 | // EndPoint epB = new IPEndPoint(IPAddress.Loopback, 1301); |
277 | UUID agentIdB = UUID.Parse("00000000-0000-0000-0000-000000001301"); | 276 | // UUID agentIdB = UUID.Parse("00000000-0000-0000-0000-000000001301"); |
278 | UUID sessionIdB = UUID.Parse("00000000-0000-0000-0000-000000002301"); | 277 | // UUID sessionIdB = UUID.Parse("00000000-0000-0000-0000-000000002301"); |
279 | 278 | // | |
280 | TestLLUDPServer testLLUDPServer; | 279 | // TestLLUDPServer testLLUDPServer; |
281 | TestLLPacketServer testLLPacketServer; | 280 | // TestLLPacketServer testLLPacketServer; |
282 | AgentCircuitManager acm; | 281 | // AgentCircuitManager acm; |
283 | SetupStack(scene, out testLLUDPServer, out testLLPacketServer, out acm); | 282 | // SetupStack(scene, out testLLUDPServer, out testLLPacketServer, out acm); |
284 | AddClient(circuitCodeA, epA, agentIdA, sessionIdA, testLLUDPServer, acm); | 283 | // AddClient(circuitCodeA, epA, agentIdA, sessionIdA, testLLUDPServer, acm); |
285 | AddClient(circuitCodeB, epB, agentIdB, sessionIdB, testLLUDPServer, acm); | 284 | // AddClient(circuitCodeB, epB, agentIdB, sessionIdB, testLLUDPServer, acm); |
286 | 285 | // | |
287 | testLLUDPServer.LoadReceive(BuildTestObjectNamePacket(1, "packet1"), epA); | 286 | // testLLUDPServer.LoadReceive(BuildTestObjectNamePacket(1, "packet1"), epA); |
288 | testLLUDPServer.LoadReceive(BuildTestObjectNamePacket(1, "packet2"), epB); | 287 | // testLLUDPServer.LoadReceive(BuildTestObjectNamePacket(1, "packet2"), epB); |
289 | testLLUDPServer.LoadReceiveWithBeginException(epA); | 288 | // testLLUDPServer.LoadReceiveWithBeginException(epA); |
290 | testLLUDPServer.LoadReceive(BuildTestObjectNamePacket(2, "packet3"), epB); | 289 | // testLLUDPServer.LoadReceive(BuildTestObjectNamePacket(2, "packet3"), epB); |
291 | testLLUDPServer.ReceiveData(null); | 290 | // testLLUDPServer.ReceiveData(null); |
292 | 291 | // | |
293 | Assert.IsFalse(testLLUDPServer.HasCircuit(circuitCodeA)); | 292 | // Assert.IsFalse(testLLUDPServer.HasCircuit(circuitCodeA)); |
294 | 293 | // | |
295 | Assert.That(testLLPacketServer.GetTotalPacketsReceived(), Is.EqualTo(3)); | 294 | // Assert.That(testLLPacketServer.GetTotalPacketsReceived(), Is.EqualTo(3)); |
296 | Assert.That(testLLPacketServer.GetPacketsReceivedFor(PacketType.ObjectName), Is.EqualTo(3)); | 295 | // Assert.That(testLLPacketServer.GetPacketsReceivedFor(PacketType.ObjectName), Is.EqualTo(3)); |
297 | } | 296 | // } |
298 | } | 297 | } |
299 | } | 298 | } |