This allows preparing up to $MaxActiveVMs idle VMs while putting a lower limit on the number of simultaneously running tasks.
Signed-off-by: Francois Gouget fgouget@codeweavers.com ---
This patch is just to introduce the parameter and associated code. So $MaxRunningVMs is set to 1 by default and thus there should be no change in the TestBot behavior. Later on we can play with this parameter to see if another value would be better.
testbot/bin/Engine.pl | 6 ++++++ testbot/lib/WineTestBot/Config.pm | 6 ++++-- testbot/lib/WineTestBot/Jobs.pm | 7 ++++++- 3 files changed, 16 insertions(+), 3 deletions(-)
diff --git a/testbot/bin/Engine.pl b/testbot/bin/Engine.pl index 7e278ba97..2e62c660c 100755 --- a/testbot/bin/Engine.pl +++ b/testbot/bin/Engine.pl @@ -736,6 +736,12 @@ sub main()
# Validate and adjust the configuration options $MaxActiveVMs ||= 1; + $MaxRunningVMs ||= $MaxActiveVMs; + if ($MaxRunningVMs > $MaxActiveVMs) + { + $MaxRunningVMs = $MaxActiveVMs; + LogMsg "Capping MaxRunningVMs to MaxActiveVMs ($MaxRunningVMs)\n"; + } $MaxRevertingVMs ||= $MaxActiveVMs; if ($MaxRevertingVMs > $MaxActiveVMs) { diff --git a/testbot/lib/WineTestBot/Config.pm b/testbot/lib/WineTestBot/Config.pm index 2c615fadb..a425e4909 100644 --- a/testbot/lib/WineTestBot/Config.pm +++ b/testbot/lib/WineTestBot/Config.pm @@ -27,7 +27,8 @@ WineTestBot::Config - Site-independent configuration settings
use vars qw (@ISA @EXPORT @EXPORT_OK $UseSSL $LogDir $DataDir $BinDir $DbDataSource $DbUsername $DbPassword $MaxRevertingVMs - $MaxRevertsWhileRunningVMs $MaxActiveVMs $MaxVMsWhenIdle + $MaxRevertsWhileRunningVMs $MaxActiveVMs $MaxRunningVMs + $MaxVMsWhenIdle $SleepAfterRevert $WaitForToolsInVM $MaxTaskTries $AdminEMail $RobotEMail $WinePatchToOverride $WinePatchCc $SuiteTimeout $SingleTimeout @@ -42,7 +43,7 @@ require Exporter; @ISA = qw(Exporter); @EXPORT = qw($UseSSL $LogDir $DataDir $BinDir $MaxRevertingVMs $MaxRevertsWhileRunningVMs $MaxActiveVMs - $MaxVMsWhenIdle $SleepAfterRevert $WaitForToolsInVM + $MaxRunningVMs $MaxVMsWhenIdle $SleepAfterRevert $WaitForToolsInVM $MaxTaskTries $AdminEMail $RobotEMail $WinePatchToOverride $WinePatchCc $SuiteTimeout $SingleTimeout $BuildTimeout $ReconfigTimeout @@ -69,6 +70,7 @@ $BinDir = "$::RootDir/bin"; $MaxRevertingVMs = 1; $MaxRevertsWhileRunningVMs = 0; $MaxActiveVMs = 2; +$MaxRunningVMs = 1; $MaxVMsWhenIdle = undef;
# How long to wait for each of the 3 connection attempts to the VM's TestAgent diff --git a/testbot/lib/WineTestBot/Jobs.pm b/testbot/lib/WineTestBot/Jobs.pm index 9a0f8bc39..b71073adb 100644 --- a/testbot/lib/WineTestBot/Jobs.pm +++ b/testbot/lib/WineTestBot/Jobs.pm @@ -473,6 +473,7 @@ sub _GetSchedHost($$) MaxRevertingVMs => $MaxRevertingVMs, MaxRevertsWhileRunningVMs => $MaxRevertsWhileRunningVMs, MaxActiveVMs => $MaxActiveVMs, + MaxRunningVMs => $MaxRunningVMs, MaxVMsWhenIdle => $MaxVMsWhenIdle, }; } @@ -905,7 +906,11 @@ sub _ScheduleTasks($) delete $Sched->{lambvms}->{$VMKey};
my $Host = _GetSchedHost($Sched, $VM); - if ($Host->{active} - $Host->{idle} < $Host->{MaxActiveVMs} and + # Dirty VMs are VMs that were running and have still not been + # powered off. Sleeping VMs may be VMs that are booting. + # So in both cases they may still be using CPU and I/O resources so + # count them against the running VM limit. + if ($Host->{sleeping} + $Host->{running} + $Host->{dirty} < $Host->{MaxRunningVMs} and ($Host->{reverting} == 0 or $Host->{reverting} <= $Host->{MaxRevertsWhileRunningVMs})) {