Fix the throttle tests. Remove the hardcoded constant multipliers and

compute the expected values without depending on the token bucket code.
mb-throttle-test
Mic Bowman 2014-12-30 10:03:37 -08:00
parent bda8f2a2c1
commit 75df04f0b3
1 changed files with 11 additions and 9 deletions

View File

@ -173,6 +173,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests
IniConfigSource ics = new IniConfigSource(); IniConfigSource ics = new IniConfigSource();
IConfig config = ics.AddConfig("ClientStack.LindenUDP"); IConfig config = ics.AddConfig("ClientStack.LindenUDP");
config.Set("enable_adaptive_throttles", true); config.Set("enable_adaptive_throttles", true);
config.Set("adaptive_throttle_min_bps", 32000);
TestLLUDPServer udpServer = ClientStackHelpers.AddUdpServer(scene, ics); TestLLUDPServer udpServer = ClientStackHelpers.AddUdpServer(scene, ics);
ScenePresence sp ScenePresence sp
@ -197,28 +199,28 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests
SetThrottles( SetThrottles(
udpClient, resendBytes, landBytes, windBytes, cloudBytes, taskBytes, textureBytes, assetBytes); udpClient, resendBytes, landBytes, windBytes, cloudBytes, taskBytes, textureBytes, assetBytes);
// Ratio of current adaptive drip rate to requested bytes // Ratio of current adaptive drip rate to requested bytes, minimum rate is 32000
// XXX: Should hard code this as below so we don't rely on values given by tested code to construct double commitRatio = 32000.0 / totalBytes;
// expected values.
double commitRatio = (double)udpClient.FlowThrottle.AdjustedDripRate / udpClient.FlowThrottle.TargetDripRate;
AssertThrottles( AssertThrottles(
udpClient, udpClient,
LLUDPServer.MTU, landBytes * commitRatio, windBytes * commitRatio, cloudBytes * commitRatio, taskBytes * commitRatio, LLUDPServer.MTU, landBytes * commitRatio, windBytes * commitRatio, cloudBytes * commitRatio, taskBytes * commitRatio,
textureBytes * commitRatio, assetBytes * commitRatio, udpClient.FlowThrottle.AdjustedDripRate, totalBytes, 0); textureBytes * commitRatio, assetBytes * commitRatio, udpClient.FlowThrottle.AdjustedDripRate, totalBytes, 0);
// Test an increase in target throttle // Test an increase in target throttle, ack of 20 packets adds 20 * LLUDPServer.MTU bytes
udpClient.FlowThrottle.AcknowledgePackets(25); // to the throttle, recompute commitratio from those numbers
commitRatio = 0.2; udpClient.FlowThrottle.AcknowledgePackets(20);
commitRatio = (32000.0 + 20.0 * LLUDPServer.MTU) / totalBytes;
AssertThrottles( AssertThrottles(
udpClient, udpClient,
resendBytes * commitRatio, landBytes * commitRatio, windBytes * commitRatio, cloudBytes * commitRatio, taskBytes * commitRatio, resendBytes * commitRatio, landBytes * commitRatio, windBytes * commitRatio, cloudBytes * commitRatio, taskBytes * commitRatio,
textureBytes * commitRatio, assetBytes * commitRatio, udpClient.FlowThrottle.AdjustedDripRate, totalBytes, 0); textureBytes * commitRatio, assetBytes * commitRatio, udpClient.FlowThrottle.AdjustedDripRate, totalBytes, 0);
// Test a decrease in target throttle // Test a decrease in target throttle, adaptive throttle should cut the rate by 50% with a floor
// set by the minimum adaptive rate
udpClient.FlowThrottle.ExpirePackets(1); udpClient.FlowThrottle.ExpirePackets(1);
commitRatio = 0.1; commitRatio = Math.Max((32000.0 + 20.0 * LLUDPServer.MTU)/Math.Pow(2,1), 32000.0) / totalBytes;
AssertThrottles( AssertThrottles(
udpClient, udpClient,