fix warm up number
This commit is contained in:
parent
32a4a6356b
commit
cad6c2018e
2 changed files with 12 additions and 9 deletions
|
@ -16,6 +16,7 @@ namespace BirdsiteLive.Pipeline.Tools
|
|||
|
||||
private int _totalUsersCount = -1;
|
||||
private int _warmUpIterations;
|
||||
private const int WarmUpMaxCapacity = 200;
|
||||
|
||||
#region Ctor
|
||||
public MaxUsersNumberProvider(InstanceSettings instanceSettings, ITwitterUserDal twitterUserDal)
|
||||
|
@ -31,8 +32,7 @@ namespace BirdsiteLive.Pipeline.Tools
|
|||
if (_totalUsersCount == -1)
|
||||
{
|
||||
_totalUsersCount = await _twitterUserDal.GetTwitterUsersCountAsync();
|
||||
var warmUpMaxCapacity = _instanceSettings.MaxUsersCapacity / 4;
|
||||
_warmUpIterations = warmUpMaxCapacity == 0 ? 0 : (int)(_totalUsersCount / (float)warmUpMaxCapacity);
|
||||
_warmUpIterations = (int)(_totalUsersCount / (float)WarmUpMaxCapacity);
|
||||
}
|
||||
|
||||
// Return if warm up ended
|
||||
|
@ -40,7 +40,7 @@ namespace BirdsiteLive.Pipeline.Tools
|
|||
|
||||
// Calculate warm up value
|
||||
var maxUsers = _warmUpIterations > 0
|
||||
? _instanceSettings.MaxUsersCapacity / 4
|
||||
? WarmUpMaxCapacity
|
||||
: _instanceSettings.MaxUsersCapacity;
|
||||
_warmUpIterations--;
|
||||
return maxUsers;
|
||||
|
|
|
@ -30,17 +30,20 @@ namespace BirdsiteLive.Pipeline.Tests.Tools
|
|||
var provider = new MaxUsersNumberProvider(settings, twitterUserDalMock.Object);
|
||||
|
||||
var result = await provider.GetMaxUsersNumberAsync();
|
||||
Assert.AreEqual(250, result);
|
||||
Assert.AreEqual(200, result);
|
||||
|
||||
result = await provider.GetMaxUsersNumberAsync();
|
||||
Assert.AreEqual(250, result);
|
||||
Assert.AreEqual(200, result);
|
||||
|
||||
result = await provider.GetMaxUsersNumberAsync();
|
||||
Assert.AreEqual(250, result);
|
||||
Assert.AreEqual(200, result);
|
||||
|
||||
result = await provider.GetMaxUsersNumberAsync();
|
||||
Assert.AreEqual(250, result);
|
||||
|
||||
Assert.AreEqual(200, result);
|
||||
|
||||
result = await provider.GetMaxUsersNumberAsync();
|
||||
Assert.AreEqual(200, result);
|
||||
|
||||
result = await provider.GetMaxUsersNumberAsync();
|
||||
Assert.AreEqual(1000, result);
|
||||
|
||||
|
@ -63,7 +66,7 @@ namespace BirdsiteLive.Pipeline.Tests.Tools
|
|||
var twitterUserDalMock = new Mock<ITwitterUserDal>(MockBehavior.Strict);
|
||||
twitterUserDalMock
|
||||
.Setup(x => x.GetTwitterUsersCountAsync())
|
||||
.ReturnsAsync(249);
|
||||
.ReturnsAsync(199);
|
||||
#endregion
|
||||
|
||||
var provider = new MaxUsersNumberProvider(settings, twitterUserDalMock.Object);
|
||||
|
|
Reference in a new issue