diff options
author | Justin Clark-Casey (justincc) | 2014-10-08 22:50:34 +0100 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2014-11-25 23:21:37 +0000 |
commit | 075f718f3fbdb46db0e1b5c4781ecf50c9b328f6 (patch) | |
tree | ab82352a88471a6ee96d1d30879d607b86885147 | |
parent | Add regression test TestClientThrottleLimited() for throttle behaviour when a... (diff) | |
download | opensim-SC_OLD-075f718f3fbdb46db0e1b5c4781ecf50c9b328f6.zip opensim-SC_OLD-075f718f3fbdb46db0e1b5c4781ecf50c9b328f6.tar.gz opensim-SC_OLD-075f718f3fbdb46db0e1b5c4781ecf50c9b328f6.tar.bz2 opensim-SC_OLD-075f718f3fbdb46db0e1b5c4781ecf50c9b328f6.tar.xz |
factor out common throttle setting byte[] array construction in ThrottleTests.
-rw-r--r-- | OpenSim/Region/ClientStack/Linden/UDP/Tests/ThrottleTests.cs | 87 |
1 files changed, 43 insertions, 44 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/Tests/ThrottleTests.cs b/OpenSim/Region/ClientStack/Linden/UDP/Tests/ThrottleTests.cs index d7cbaba..702e308 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/Tests/ThrottleTests.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/Tests/ThrottleTests.cs | |||
@@ -69,38 +69,29 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests | |||
69 | LLUDPClient udpClient = ((LLClientView)sp.ControllingClient).UDPClient; | 69 | LLUDPClient udpClient = ((LLClientView)sp.ControllingClient).UDPClient; |
70 | // udpClient.ThrottleDebugLevel = 1; | 70 | // udpClient.ThrottleDebugLevel = 1; |
71 | 71 | ||
72 | byte[] throttles = new byte[28]; | 72 | int resendBytes = 1000; |
73 | float resendBits = 10000; | 73 | int landBytes = 2000; |
74 | float landBits = 20000; | 74 | int windBytes = 3000; |
75 | float windBits = 30000; | 75 | int cloudBytes = 4000; |
76 | float cloudBits = 40000; | 76 | int taskBytes = 5000; |
77 | float taskBits = 50000; | 77 | int textureBytes = 6000; |
78 | float textureBits = 60000; | 78 | int assetBytes = 7000; |
79 | float assetBits = 70000; | 79 | |
80 | 80 | SetThrottles( | |
81 | Array.Copy(BitConverter.GetBytes(resendBits), 0, throttles, 0, 4); | 81 | udpClient, resendBytes, landBytes, windBytes, cloudBytes, taskBytes, textureBytes, assetBytes); |
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 | 82 | ||
91 | udpClient.SetThrottles(throttles); | ||
92 | ClientInfo ci = udpClient.GetClientInfo(); | 83 | ClientInfo ci = udpClient.GetClientInfo(); |
93 | 84 | ||
94 | // We expect this to be lower because of the minimum bound set by MTU | 85 | // 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; | 86 | float totalBytes = LLUDPServer.MTU + landBytes + windBytes + cloudBytes + taskBytes + textureBytes + assetBytes; |
96 | Assert.AreEqual(LLUDPServer.MTU, ci.resendThrottle); | 87 | Assert.AreEqual(LLUDPServer.MTU, ci.resendThrottle); |
97 | Assert.AreEqual(landBits / 8, ci.landThrottle); | 88 | Assert.AreEqual(landBytes, ci.landThrottle); |
98 | Assert.AreEqual(windBits / 8, ci.windThrottle); | 89 | Assert.AreEqual(windBytes, ci.windThrottle); |
99 | Assert.AreEqual(cloudBits / 8, ci.cloudThrottle); | 90 | Assert.AreEqual(cloudBytes, ci.cloudThrottle); |
100 | Assert.AreEqual(taskBits / 8, ci.taskThrottle); | 91 | Assert.AreEqual(taskBytes, ci.taskThrottle); |
101 | Assert.AreEqual(textureBits / 8, ci.textureThrottle); | 92 | Assert.AreEqual(textureBytes, ci.textureThrottle); |
102 | Assert.AreEqual(assetBits / 8, ci.assetThrottle); | 93 | Assert.AreEqual(assetBytes, ci.assetThrottle); |
103 | Assert.AreEqual(totalBits / 8, ci.totalThrottle); | 94 | Assert.AreEqual(totalBytes, ci.totalThrottle); |
104 | } | 95 | } |
105 | 96 | ||
106 | /// <summary> | 97 | /// <summary> |
@@ -112,13 +103,13 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests | |||
112 | TestHelpers.InMethod(); | 103 | TestHelpers.InMethod(); |
113 | // TestHelpers.EnableLogging(); | 104 | // TestHelpers.EnableLogging(); |
114 | 105 | ||
115 | float resendBytes = 4000; | 106 | int resendBytes = 4000; |
116 | float landBytes = 6000; | 107 | int landBytes = 6000; |
117 | float windBytes = 8000; | 108 | int windBytes = 8000; |
118 | float cloudBytes = 10000; | 109 | int cloudBytes = 10000; |
119 | float taskBytes = 12000; | 110 | int taskBytes = 12000; |
120 | float textureBytes = 14000; | 111 | int textureBytes = 14000; |
121 | float assetBytes = 16000; | 112 | int assetBytes = 16000; |
122 | int totalBytes | 113 | int totalBytes |
123 | = (int)((resendBytes + landBytes + windBytes + cloudBytes + taskBytes + textureBytes + assetBytes) / 2); | 114 | = (int)((resendBytes + landBytes + windBytes + cloudBytes + taskBytes + textureBytes + assetBytes) / 2); |
124 | 115 | ||
@@ -133,17 +124,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests | |||
133 | LLUDPClient udpClient = ((LLClientView)sp.ControllingClient).UDPClient; | 124 | LLUDPClient udpClient = ((LLClientView)sp.ControllingClient).UDPClient; |
134 | // udpClient.ThrottleDebugLevel = 1; | 125 | // udpClient.ThrottleDebugLevel = 1; |
135 | 126 | ||
136 | byte[] throttles = new byte[28]; | 127 | SetThrottles( |
137 | 128 | udpClient, resendBytes, landBytes, windBytes, cloudBytes, taskBytes, textureBytes, assetBytes); | |
138 | Array.Copy(BitConverter.GetBytes(resendBytes * 8), 0, throttles, 0, 4); | ||
139 | Array.Copy(BitConverter.GetBytes(landBytes * 8), 0, throttles, 4, 4); | ||
140 | Array.Copy(BitConverter.GetBytes(windBytes * 8), 0, throttles, 8, 4); | ||
141 | Array.Copy(BitConverter.GetBytes(cloudBytes * 8), 0, throttles, 12, 4); | ||
142 | Array.Copy(BitConverter.GetBytes(taskBytes * 8), 0, throttles, 16, 4); | ||
143 | Array.Copy(BitConverter.GetBytes(textureBytes * 8), 0, throttles, 20, 4); | ||
144 | Array.Copy(BitConverter.GetBytes(assetBytes * 8), 0, throttles, 24, 4); | ||
145 | 129 | ||
146 | udpClient.SetThrottles(throttles); | ||
147 | ClientInfo ci = udpClient.GetClientInfo(); | 130 | ClientInfo ci = udpClient.GetClientInfo(); |
148 | 131 | ||
149 | // Console.WriteLine( | 132 | // Console.WriteLine( |
@@ -160,5 +143,21 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests | |||
160 | Assert.AreEqual(assetBytes / 2, ci.assetThrottle); | 143 | Assert.AreEqual(assetBytes / 2, ci.assetThrottle); |
161 | Assert.AreEqual(totalBytes, ci.totalThrottle); | 144 | Assert.AreEqual(totalBytes, ci.totalThrottle); |
162 | } | 145 | } |
146 | |||
147 | private void SetThrottles( | ||
148 | LLUDPClient udpClient, int resendBytes, int landBytes, int windBytes, int cloudBytes, int taskBytes, int textureBytes, int assetBytes) | ||
149 | { | ||
150 | byte[] throttles = new byte[28]; | ||
151 | |||
152 | Array.Copy(BitConverter.GetBytes((float)resendBytes * 8), 0, throttles, 0, 4); | ||
153 | Array.Copy(BitConverter.GetBytes((float)landBytes * 8), 0, throttles, 4, 4); | ||
154 | Array.Copy(BitConverter.GetBytes((float)windBytes * 8), 0, throttles, 8, 4); | ||
155 | Array.Copy(BitConverter.GetBytes((float)cloudBytes * 8), 0, throttles, 12, 4); | ||
156 | Array.Copy(BitConverter.GetBytes((float)taskBytes * 8), 0, throttles, 16, 4); | ||
157 | Array.Copy(BitConverter.GetBytes((float)textureBytes * 8), 0, throttles, 20, 4); | ||
158 | Array.Copy(BitConverter.GetBytes((float)assetBytes * 8), 0, throttles, 24, 4); | ||
159 | |||
160 | udpClient.SetThrottles(throttles); | ||
161 | } | ||
163 | } | 162 | } |
164 | } \ No newline at end of file | 163 | } \ No newline at end of file |