diff options
author | Justin Clark-Casey (justincc) | 2014-10-10 23:36:50 +0100 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2014-11-25 23:21:38 +0000 |
commit | d33964222aa9e3b2e639469a32d0af4728b0f77d (patch) | |
tree | e92451eeaf3df6d449b1b08155bbb660eb8e78e5 /OpenSim/Region/ClientStack/Linden/UDP/Tests/ThrottleTests.cs | |
parent | Use automatic properties for Parent and TotalDripRequest in TokenBucket to ma... (diff) | |
download | opensim-SC-d33964222aa9e3b2e639469a32d0af4728b0f77d.zip opensim-SC-d33964222aa9e3b2e639469a32d0af4728b0f77d.tar.gz opensim-SC-d33964222aa9e3b2e639469a32d0af4728b0f77d.tar.bz2 opensim-SC-d33964222aa9e3b2e639469a32d0af4728b0f77d.tar.xz |
Fix an issue where specifying both max client and server outgoing UDP throttles would cause client throttles to be lower than expected when total requests exceeded the scene limit.
This was because specifying a max client throttle would always request the max from the parent server throttle, no matter the actual total requests on the client throttle.
This would lead to a lower server multiplier than expected.
This change also adds a 'target' column to the "show throttles" output that shows the target rate (as set by client) if adaptive throttles is active.
This commit also re-adds the functionality lost in recent 5c1a1458 to set a max client throttle when adaptive is active.
This commit also adds TestClientThrottlePerClientAndRegionLimited and TestClientThrottleAdaptiveNoLimit regression tests
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/ClientStack/Linden/UDP/Tests/ThrottleTests.cs | 162 |
1 files changed, 160 insertions, 2 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/Tests/ThrottleTests.cs b/OpenSim/Region/ClientStack/Linden/UDP/Tests/ThrottleTests.cs index b80a485..7991996 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/Tests/ThrottleTests.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/Tests/ThrottleTests.cs | |||
@@ -26,6 +26,7 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using Nini.Config; | ||
29 | using NUnit.Framework; | 30 | using NUnit.Framework; |
30 | using OpenMetaverse.Packets; | 31 | using OpenMetaverse.Packets; |
31 | using OpenSim.Framework; | 32 | using OpenSim.Framework; |
@@ -67,7 +68,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests | |||
67 | scene, udpServer, TestHelpers.ParseTail(0x1), TestHelpers.ParseTail(0x2), 123456); | 68 | scene, udpServer, TestHelpers.ParseTail(0x1), TestHelpers.ParseTail(0x2), 123456); |
68 | 69 | ||
69 | LLUDPClient udpClient = ((LLClientView)sp.ControllingClient).UDPClient; | 70 | LLUDPClient udpClient = ((LLClientView)sp.ControllingClient).UDPClient; |
70 | // udpClient.ThrottleDebugLevel = 1; | 71 | |
72 | udpServer.Throttle.DebugLevel = 1; | ||
73 | udpClient.ThrottleDebugLevel = 1; | ||
71 | 74 | ||
72 | int resendBytes = 1000; | 75 | int resendBytes = 1000; |
73 | int landBytes = 2000; | 76 | int landBytes = 2000; |
@@ -83,7 +86,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests | |||
83 | ClientInfo ci = udpClient.GetClientInfo(); | 86 | ClientInfo ci = udpClient.GetClientInfo(); |
84 | 87 | ||
85 | // We expect this to be lower because of the minimum bound set by MTU | 88 | // We expect this to be lower because of the minimum bound set by MTU |
86 | float totalBytes = LLUDPServer.MTU + landBytes + windBytes + cloudBytes + taskBytes + textureBytes + assetBytes; | 89 | int totalBytes = LLUDPServer.MTU + landBytes + windBytes + cloudBytes + taskBytes + textureBytes + assetBytes; |
87 | Assert.AreEqual(LLUDPServer.MTU, ci.resendThrottle); | 90 | Assert.AreEqual(LLUDPServer.MTU, ci.resendThrottle); |
88 | Assert.AreEqual(landBytes, ci.landThrottle); | 91 | Assert.AreEqual(landBytes, ci.landThrottle); |
89 | Assert.AreEqual(windBytes, ci.windThrottle); | 92 | Assert.AreEqual(windBytes, ci.windThrottle); |
@@ -92,6 +95,66 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests | |||
92 | Assert.AreEqual(textureBytes, ci.textureThrottle); | 95 | Assert.AreEqual(textureBytes, ci.textureThrottle); |
93 | Assert.AreEqual(assetBytes, ci.assetThrottle); | 96 | Assert.AreEqual(assetBytes, ci.assetThrottle); |
94 | Assert.AreEqual(totalBytes, ci.totalThrottle); | 97 | Assert.AreEqual(totalBytes, ci.totalThrottle); |
98 | |||
99 | Assert.AreEqual(0, ci.maxThrottle); | ||
100 | } | ||
101 | |||
102 | [Test] | ||
103 | public void TestClientThrottleAdaptiveNoLimit() | ||
104 | { | ||
105 | TestHelpers.InMethod(); | ||
106 | // TestHelpers.EnableLogging(); | ||
107 | |||
108 | Scene scene = new SceneHelpers().SetupScene(); | ||
109 | |||
110 | IniConfigSource ics = new IniConfigSource(); | ||
111 | IConfig config = ics.AddConfig("ClientStack.LindenUDP"); | ||
112 | config.Set("enable_adaptive_throttles", true); | ||
113 | TestLLUDPServer udpServer = ClientStackHelpers.AddUdpServer(scene, ics); | ||
114 | |||
115 | ScenePresence sp | ||
116 | = ClientStackHelpers.AddChildClient( | ||
117 | scene, udpServer, TestHelpers.ParseTail(0x1), TestHelpers.ParseTail(0x2), 123456); | ||
118 | |||
119 | LLUDPClient udpClient = ((LLClientView)sp.ControllingClient).UDPClient; | ||
120 | |||
121 | udpServer.Throttle.DebugLevel = 1; | ||
122 | udpClient.ThrottleDebugLevel = 1; | ||
123 | |||
124 | // Total is 28000 | ||
125 | int resendBytes = 10000; | ||
126 | int landBytes = 20000; | ||
127 | int windBytes = 30000; | ||
128 | int cloudBytes = 40000; | ||
129 | int taskBytes = 50000; | ||
130 | int textureBytes = 60000; | ||
131 | int assetBytes = 70000; | ||
132 | |||
133 | SetThrottles( | ||
134 | udpClient, resendBytes, landBytes, windBytes, cloudBytes, taskBytes, textureBytes, assetBytes); | ||
135 | |||
136 | ClientInfo ci = udpClient.GetClientInfo(); | ||
137 | |||
138 | // We expect individual throttle changes to currently have no effect under adaptive, since this is managed | ||
139 | // purely by that throttle. However, we expect the max to change. | ||
140 | // XXX: At the moment we check against defaults, but at some point there should be a better test to | ||
141 | // active see change over time. | ||
142 | ThrottleRates defaultRates = udpServer.ThrottleRates; | ||
143 | |||
144 | // Current total is 66750 | ||
145 | int totalBytes = defaultRates.Resend + defaultRates.Land + defaultRates.Wind + defaultRates.Cloud + defaultRates.Task + defaultRates.Texture + defaultRates.Asset; | ||
146 | int totalMaxBytes = resendBytes + landBytes + windBytes + cloudBytes + taskBytes + textureBytes + assetBytes; | ||
147 | |||
148 | Assert.AreEqual(0, ci.maxThrottle); | ||
149 | Assert.AreEqual(totalMaxBytes, ci.targetThrottle); | ||
150 | Assert.AreEqual(defaultRates.Resend, ci.resendThrottle); | ||
151 | Assert.AreEqual(defaultRates.Land, ci.landThrottle); | ||
152 | Assert.AreEqual(defaultRates.Wind, ci.windThrottle); | ||
153 | Assert.AreEqual(defaultRates.Cloud, ci.cloudThrottle); | ||
154 | Assert.AreEqual(defaultRates.Task, ci.taskThrottle); | ||
155 | Assert.AreEqual(defaultRates.Texture, ci.textureThrottle); | ||
156 | Assert.AreEqual(defaultRates.Asset, ci.assetThrottle); | ||
157 | Assert.AreEqual(totalBytes, ci.totalThrottle); | ||
95 | } | 158 | } |
96 | 159 | ||
97 | /// <summary> | 160 | /// <summary> |
@@ -238,6 +301,101 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests | |||
238 | Assert.AreEqual(totalBytes, ci.totalThrottle); | 301 | Assert.AreEqual(totalBytes, ci.totalThrottle); |
239 | } | 302 | } |
240 | 303 | ||
304 | [Test] | ||
305 | public void TestClientThrottlePerClientAndRegionLimited() | ||
306 | { | ||
307 | TestHelpers.InMethod(); | ||
308 | //TestHelpers.EnableLogging(); | ||
309 | |||
310 | int resendBytes = 4000; | ||
311 | int landBytes = 6000; | ||
312 | int windBytes = 8000; | ||
313 | int cloudBytes = 10000; | ||
314 | int taskBytes = 12000; | ||
315 | int textureBytes = 14000; | ||
316 | int assetBytes = 16000; | ||
317 | |||
318 | // current total 70000 | ||
319 | int totalBytes = resendBytes + landBytes + windBytes + cloudBytes + taskBytes + textureBytes + assetBytes; | ||
320 | |||
321 | Scene scene = new SceneHelpers().SetupScene(); | ||
322 | TestLLUDPServer udpServer = ClientStackHelpers.AddUdpServer(scene); | ||
323 | udpServer.ThrottleRates.Total = (int)(totalBytes * 1.1); | ||
324 | udpServer.Throttle.RequestedDripRate = (int)(totalBytes * 1.5); | ||
325 | |||
326 | ScenePresence sp1 | ||
327 | = ClientStackHelpers.AddChildClient( | ||
328 | scene, udpServer, TestHelpers.ParseTail(0x1), TestHelpers.ParseTail(0x2), 123456); | ||
329 | |||
330 | LLUDPClient udpClient1 = ((LLClientView)sp1.ControllingClient).UDPClient; | ||
331 | udpClient1.ThrottleDebugLevel = 1; | ||
332 | |||
333 | SetThrottles( | ||
334 | udpClient1, resendBytes, landBytes, windBytes, cloudBytes, taskBytes, textureBytes, assetBytes); | ||
335 | |||
336 | { | ||
337 | ClientInfo ci = udpClient1.GetClientInfo(); | ||
338 | |||
339 | // Console.WriteLine( | ||
340 | // "Resend={0}, Land={1}, Wind={2}, Cloud={3}, Task={4}, Texture={5}, Asset={6}, TOTAL = {7}", | ||
341 | // ci.resendThrottle, ci.landThrottle, ci.windThrottle, ci.cloudThrottle, ci.taskThrottle, ci.textureThrottle, ci.assetThrottle, ci.totalThrottle); | ||
342 | |||
343 | Assert.AreEqual(resendBytes, ci.resendThrottle); | ||
344 | Assert.AreEqual(landBytes, ci.landThrottle); | ||
345 | Assert.AreEqual(windBytes, ci.windThrottle); | ||
346 | Assert.AreEqual(cloudBytes, ci.cloudThrottle); | ||
347 | Assert.AreEqual(taskBytes, ci.taskThrottle); | ||
348 | Assert.AreEqual(textureBytes, ci.textureThrottle); | ||
349 | Assert.AreEqual(assetBytes, ci.assetThrottle); | ||
350 | Assert.AreEqual(totalBytes, ci.totalThrottle); | ||
351 | } | ||
352 | |||
353 | // Now add another client | ||
354 | ScenePresence sp2 | ||
355 | = ClientStackHelpers.AddChildClient( | ||
356 | scene, udpServer, TestHelpers.ParseTail(0x10), TestHelpers.ParseTail(0x20), 123457); | ||
357 | |||
358 | LLUDPClient udpClient2 = ((LLClientView)sp2.ControllingClient).UDPClient; | ||
359 | udpClient2.ThrottleDebugLevel = 1; | ||
360 | |||
361 | SetThrottles( | ||
362 | udpClient2, resendBytes, landBytes, windBytes, cloudBytes, taskBytes, textureBytes, assetBytes); | ||
363 | |||
364 | { | ||
365 | ClientInfo ci = udpClient1.GetClientInfo(); | ||
366 | |||
367 | // Console.WriteLine( | ||
368 | // "Resend={0}, Land={1}, Wind={2}, Cloud={3}, Task={4}, Texture={5}, Asset={6}, TOTAL = {7}", | ||
369 | // ci.resendThrottle, ci.landThrottle, ci.windThrottle, ci.cloudThrottle, ci.taskThrottle, ci.textureThrottle, ci.assetThrottle, ci.totalThrottle); | ||
370 | |||
371 | Assert.AreEqual(resendBytes * 0.75, ci.resendThrottle); | ||
372 | Assert.AreEqual(landBytes * 0.75, ci.landThrottle); | ||
373 | Assert.AreEqual(windBytes * 0.75, ci.windThrottle); | ||
374 | Assert.AreEqual(cloudBytes * 0.75, ci.cloudThrottle); | ||
375 | Assert.AreEqual(taskBytes * 0.75, ci.taskThrottle); | ||
376 | Assert.AreEqual(textureBytes * 0.75, ci.textureThrottle); | ||
377 | Assert.AreEqual(assetBytes * 0.75, ci.assetThrottle); | ||
378 | Assert.AreEqual(totalBytes * 0.75, ci.totalThrottle); | ||
379 | } | ||
380 | |||
381 | { | ||
382 | ClientInfo ci = udpClient2.GetClientInfo(); | ||
383 | |||
384 | // Console.WriteLine( | ||
385 | // "Resend={0}, Land={1}, Wind={2}, Cloud={3}, Task={4}, Texture={5}, Asset={6}, TOTAL = {7}", | ||
386 | // ci.resendThrottle, ci.landThrottle, ci.windThrottle, ci.cloudThrottle, ci.taskThrottle, ci.textureThrottle, ci.assetThrottle, ci.totalThrottle); | ||
387 | |||
388 | Assert.AreEqual(resendBytes * 0.75, ci.resendThrottle); | ||
389 | Assert.AreEqual(landBytes * 0.75, ci.landThrottle); | ||
390 | Assert.AreEqual(windBytes * 0.75, ci.windThrottle); | ||
391 | Assert.AreEqual(cloudBytes * 0.75, ci.cloudThrottle); | ||
392 | Assert.AreEqual(taskBytes * 0.75, ci.taskThrottle); | ||
393 | Assert.AreEqual(textureBytes * 0.75, ci.textureThrottle); | ||
394 | Assert.AreEqual(assetBytes * 0.75, ci.assetThrottle); | ||
395 | Assert.AreEqual(totalBytes * 0.75, ci.totalThrottle); | ||
396 | } | ||
397 | } | ||
398 | |||
241 | private void SetThrottles( | 399 | private void SetThrottles( |
242 | LLUDPClient udpClient, int resendBytes, int landBytes, int windBytes, int cloudBytes, int taskBytes, int textureBytes, int assetBytes) | 400 | LLUDPClient udpClient, int resendBytes, int landBytes, int windBytes, int cloudBytes, int taskBytes, int textureBytes, int assetBytes) |
243 | { | 401 | { |