diff options
author | Justin Clark-Casey (justincc) | 2014-10-08 20:52:17 +0100 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2014-11-25 23:18:40 +0000 |
commit | 746defa094e6b822f74597d047984c17f35ed776 (patch) | |
tree | 9c07efe1af05a49b612317cbd121bbeea2ef75a4 | |
parent | refactor: Move test clientstack setup code out of BasicCircuitTests into Open... (diff) | |
download | opensim-SC-746defa094e6b822f74597d047984c17f35ed776.zip opensim-SC-746defa094e6b822f74597d047984c17f35ed776.tar.gz opensim-SC-746defa094e6b822f74597d047984c17f35ed776.tar.bz2 opensim-SC-746defa094e6b822f74597d047984c17f35ed776.tar.xz |
Add basic regression test ThrottleTests.TestClientThrottleSetNoLimit
-rw-r--r-- | OpenSim/Region/ClientStack/Linden/UDP/LLUDPClient.cs | 8 | ||||
-rw-r--r-- | OpenSim/Region/ClientStack/Linden/UDP/Tests/ThrottleTests.cs | 106 |
2 files changed, 114 insertions, 0 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPClient.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPClient.cs index ea3db0b..e9f1ca2 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPClient.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPClient.cs | |||
@@ -415,6 +415,14 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
415 | int texture = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f); pos += 4; | 415 | int texture = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f); pos += 4; |
416 | int asset = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f); | 416 | int asset = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f); |
417 | 417 | ||
418 | if (ThrottleDebugLevel > 0) | ||
419 | { | ||
420 | long total = resend + land + wind + cloud + task + texture + asset; | ||
421 | m_log.DebugFormat( | ||
422 | "[LLUDPCLIENT]: {0} is setting throttles in {1} to Resend={2}, Land={3}, Wind={4}, Cloud={5}, Task={6}, Texture={7}, Asset={8}, TOTAL = {9}", | ||
423 | AgentID, m_udpServer.Scene.Name, resend, land, wind, cloud, task, texture, asset, total); | ||
424 | } | ||
425 | |||
418 | // Make sure none of the throttles are set below our packet MTU, | 426 | // Make sure none of the throttles are set below our packet MTU, |
419 | // otherwise a throttle could become permanently clogged | 427 | // otherwise a throttle could become permanently clogged |
420 | resend = Math.Max(resend, LLUDPServer.MTU); | 428 | resend = Math.Max(resend, LLUDPServer.MTU); |
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 | |||
28 | using System; | ||
29 | using NUnit.Framework; | ||
30 | using OpenMetaverse.Packets; | ||
31 | using OpenSim.Framework; | ||
32 | using OpenSim.Region.Framework.Scenes; | ||
33 | using OpenSim.Tests.Common; | ||
34 | |||
35 | namespace 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 | ||