aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ClientStack/Linden/UDP/Tests/ThrottleTests.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/ClientStack/Linden/UDP/Tests/ThrottleTests.cs')
-rw-r--r--OpenSim/Region/ClientStack/Linden/UDP/Tests/ThrottleTests.cs106
1 files changed, 106 insertions, 0 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/Tests/ThrottleTests.cs b/OpenSim/Region/ClientStack/Linden/UDP/Tests/ThrottleTests.cs
new file mode 100644
index 0000000..83d5b5f
--- /dev/null
+++ b/OpenSim/Region/ClientStack/Linden/UDP/Tests/ThrottleTests.cs
@@ -0,0 +1,106 @@
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 NUnit.Framework;
30using OpenMetaverse.Packets;
31using OpenSim.Framework;
32using OpenSim.Region.Framework.Scenes;
33using OpenSim.Tests.Common;
34
35namespace OpenSim.Region.ClientStack.LindenUDP.Tests
36{
37 [TestFixture]
38 public class ThrottleTests : OpenSimTestCase
39 {
40 [TestFixtureSetUp]
41 public void FixtureInit()
42 {
43 // Don't allow tests to be bamboozled by asynchronous events. Execute everything on the same thread.
44 Util.FireAndForgetMethod = FireAndForgetMethod.RegressionTest;
45 }
46
47 [TestFixtureTearDown]
48 public void TearDown()
49 {
50 // We must set this back afterwards, otherwise later tests will fail since they're expecting multiple
51 // threads. Possibly, later tests should be rewritten so none of them require async stuff (which regression
52 // tests really shouldn't).
53 Util.FireAndForgetMethod = Util.DefaultFireAndForgetMethod;
54 }
55
56 [Test]
57 public void TestClientThrottleSetNoLimit()
58 {
59 TestHelpers.InMethod();
60 TestHelpers.EnableLogging();
61
62 Scene scene = new SceneHelpers().SetupScene();
63 TestLLUDPServer udpServer = ClientStackHelpers.AddUdpServer(scene);
64
65 ScenePresence sp
66 = ClientStackHelpers.AddChildClient(
67 scene, udpServer, TestHelpers.ParseTail(0x1), TestHelpers.ParseTail(0x2), 123456);
68
69 LLUDPClient udpClient = ((LLClientView)sp.ControllingClient).UDPClient;
70// udpClient.ThrottleDebugLevel = 1;
71
72 byte[] throttles = new byte[28];
73 float resendBits = 10000;
74 float landBits = 20000;
75 float windBits = 30000;
76 float cloudBits = 40000;
77 float taskBits = 50000;
78 float textureBits = 60000;
79 float assetBits = 70000;
80
81 Array.Copy(BitConverter.GetBytes(resendBits), 0, throttles, 0, 4);
82 Array.Copy(BitConverter.GetBytes(landBits), 0, throttles, 4, 4);
83 Array.Copy(BitConverter.GetBytes(windBits), 0, throttles, 8, 4);
84 Array.Copy(BitConverter.GetBytes(cloudBits), 0, throttles, 12, 4);
85 Array.Copy(BitConverter.GetBytes(taskBits), 0, throttles, 16, 4);
86 Array.Copy(BitConverter.GetBytes(textureBits), 0, throttles, 20, 4);
87 Array.Copy(BitConverter.GetBytes(assetBits), 0, throttles, 24, 4);
88
89// Console.WriteLine(BitConverter.ToString(throttles));
90
91 udpClient.SetThrottles(throttles);
92 ClientInfo ci = udpClient.GetClientInfo();
93
94 // We expect this to be lower because of the minimum bound set by MTU
95 float totalBits = LLUDPServer.MTU * 8 + landBits + windBits + cloudBits + taskBits + textureBits + assetBits;
96 Assert.AreEqual(LLUDPServer.MTU, ci.resendThrottle);
97 Assert.AreEqual(landBits / 8, ci.landThrottle);
98 Assert.AreEqual(windBits / 8, ci.windThrottle);
99 Assert.AreEqual(cloudBits / 8, ci.cloudThrottle);
100 Assert.AreEqual(taskBits / 8, ci.taskThrottle);
101 Assert.AreEqual(textureBits / 8, ci.textureThrottle);
102 Assert.AreEqual(assetBits / 8, ci.assetThrottle);
103 Assert.AreEqual(totalBits / 8, ci.totalThrottle);
104 }
105 }
106} \ No newline at end of file