Add regression tests for token buckets on their own
parent
cdc3301a33
commit
67007c7d21
|
@ -54,6 +54,54 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests
|
||||||
Util.FireAndForgetMethod = Util.DefaultFireAndForgetMethod;
|
Util.FireAndForgetMethod = Util.DefaultFireAndForgetMethod;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestSetRequestDripRate()
|
||||||
|
{
|
||||||
|
TokenBucket tb = new TokenBucket("tb", null, 5000, 0);
|
||||||
|
AssertRates(tb, 5000, 5000, 0);
|
||||||
|
|
||||||
|
tb.RequestedDripRate = 4000;
|
||||||
|
AssertRates(tb, 4000, 4000, 0);
|
||||||
|
|
||||||
|
tb.RequestedDripRate = 6000;
|
||||||
|
AssertRates(tb, 6000, 6000, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestSetRequestDripRateWithMax()
|
||||||
|
{
|
||||||
|
TokenBucket tb = new TokenBucket("tb", null, 5000, 10000);
|
||||||
|
AssertRates(tb, 5000, 5000, 10000);
|
||||||
|
|
||||||
|
tb.RequestedDripRate = 4000;
|
||||||
|
AssertRates(tb, 4000, 4000, 10000);
|
||||||
|
|
||||||
|
tb.RequestedDripRate = 6000;
|
||||||
|
AssertRates(tb, 6000, 6000, 10000);
|
||||||
|
|
||||||
|
tb.RequestedDripRate = 12000;
|
||||||
|
AssertRates(tb, 10000, 10000, 10000);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestSetRequestDripRateWithChildren()
|
||||||
|
{
|
||||||
|
TokenBucket tbParent = new TokenBucket("tbParent", null, 0, 0);
|
||||||
|
TokenBucket tbChild1 = new TokenBucket("tbChild1", tbParent, 3000, 0);
|
||||||
|
TokenBucket tbChild2 = new TokenBucket("tbChild2", tbParent, 5000, 0);
|
||||||
|
|
||||||
|
AssertRates(tbParent, 8000, 8000, 0);
|
||||||
|
AssertRates(tbChild1, 3000, 3000, 0);
|
||||||
|
AssertRates(tbChild2, 5000, 5000, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void AssertRates(TokenBucket tb, double dripRate, double totalDripRequest, double maxDripRate)
|
||||||
|
{
|
||||||
|
Assert.AreEqual((int)dripRate, tb.DripRate);
|
||||||
|
Assert.AreEqual((int)totalDripRequest, tb.TotalDripRequest);
|
||||||
|
Assert.AreEqual((int)maxDripRate, tb.MaxDripRate);
|
||||||
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestClientThrottleSetNoLimit()
|
public void TestClientThrottleSetNoLimit()
|
||||||
{
|
{
|
||||||
|
@ -179,7 +227,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests
|
||||||
resendBytes / 2, landBytes / 2, windBytes / 2, cloudBytes / 2, taskBytes / 2,
|
resendBytes / 2, landBytes / 2, windBytes / 2, cloudBytes / 2, taskBytes / 2,
|
||||||
textureBytes / 2, assetBytes / 2, totalBytes, 0, 0);
|
textureBytes / 2, assetBytes / 2, totalBytes, 0, 0);
|
||||||
|
|
||||||
// Now add another client
|
// Test: Now add another client
|
||||||
ScenePresence sp2
|
ScenePresence sp2
|
||||||
= ClientStackHelpers.AddChildClient(
|
= ClientStackHelpers.AddChildClient(
|
||||||
scene, udpServer, TestHelpers.ParseTail(0x10), TestHelpers.ParseTail(0x20), 123457);
|
scene, udpServer, TestHelpers.ParseTail(0x10), TestHelpers.ParseTail(0x20), 123457);
|
||||||
|
|
Loading…
Reference in New Issue