Module: tools
Branch: master
Commit: b779cb2c5f1d15a485afbe8df970e84ed132f94e
URL: http://source.winehq.org/git/tools.git/?a=commit;h=b779cb2c5f1d15a485afbe8d…
Author: Francois Gouget <fgouget(a)codeweavers.com>
Date: Tue Mar 26 11:50:19 2013 +0100
testbot/scripts: Tweak 'initd status' to check if a server it did not start is running already.
This avoids confusion in case a server was started manually for testing.
---
testbot/scripts/initd | 9 +++++++--
1 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/testbot/scripts/initd b/testbot/scripts/initd
index fe670ed..7e25f7d 100755
--- a/testbot/scripts/initd
+++ b/testbot/scripts/initd
@@ -106,9 +106,14 @@ then
fi
log_failure_msg "The WineTestBot server is running but not responding"
exit 1
- elif [ "$status" = 4 ]; then
- log_failure_msg "could not access PID file for the WineTestBot server"
+ elif [ "$status" = 4 ]
+ then
+ log_failure_msg "Could not access PID file for the WineTestBot server"
exit $status
+ elif $PING -q
+ then
+ log_success_msg "A WineTestBot server was started manually already"
+ exit 0
else
log_failure_msg "The WineTestBot server is not running"
exit $status
Module: tools
Branch: master
Commit: 6d3107a5fee397475202efc6cef1895ffb2dba92
URL: http://source.winehq.org/git/tools.git/?a=commit;h=6d3107a5fee397475202efc6…
Author: Francois Gouget <fgouget(a)codeweavers.com>
Date: Tue Mar 26 11:50:02 2013 +0100
testbot/scripts: Fix the initd script's indentation.
---
testbot/scripts/initd | 88 ++++++++++++++++++++++++------------------------
1 files changed, 44 insertions(+), 44 deletions(-)
diff --git a/testbot/scripts/initd b/testbot/scripts/initd
index d782cbc..fe670ed 100755
--- a/testbot/scripts/initd
+++ b/testbot/scripts/initd
@@ -159,50 +159,50 @@ then
# considered a success.
case "$1" in
- start)
- echo -n "Starting WineTestBot "
- ## Start daemon with startproc(8). If this fails
- ## the return value is set appropriately by startproc.
- /sbin/startproc -u $USER $DAEMON
-
- # Remember status and be verbose
- rc_status -v
- ;;
- stop)
- echo -n "Shutting down WineTestBot "
- ## Stop daemon with killproc(8) and if this fails
- ## killproc sets the return value according to LSB.
-
- /sbin/killproc -TERM $DAEMON
-
- # Remember status and be verbose
- rc_status -v
- ;;
- try-restart|condrestart|reload)
- ## Do a restart only if the service was active before.
- ## Note: try-restart is now part of LSB (as of 1.9).
- ## RH has a similar command named condrestart.
- if test "$1" = "condrestart"; then
- echo "${attn} Use try-restart ${done}(LSB)${attn} rather than condrestart ${warn}(RH)${norm}"
- fi
- $0 status
- if test $? = 0; then
- $0 restart
- else
- rc_reset # Not running is not a failure.
- fi
- # Remember status and be quiet
- rc_status
- ;;
- restart|force-reload)
- ## Stop the service and regardless of whether it was
- ## running or not, start it again.
- $0 stop
- $0 start
-
- # Remember status and be quiet
- rc_status
- ;;
+ start)
+ echo -n "Starting WineTestBot "
+ ## Start daemon with startproc(8). If this fails
+ ## the return value is set appropriately by startproc.
+ /sbin/startproc -u $USER $DAEMON
+
+ # Remember status and be verbose
+ rc_status -v
+ ;;
+ stop)
+ echo -n "Shutting down WineTestBot "
+ ## Stop daemon with killproc(8) and if this fails
+ ## killproc sets the return value according to LSB.
+
+ /sbin/killproc -TERM $DAEMON
+
+ # Remember status and be verbose
+ rc_status -v
+ ;;
+ try-restart|condrestart|reload)
+ ## Do a restart only if the service was active before.
+ ## Note: try-restart is now part of LSB (as of 1.9).
+ ## RH has a similar command named condrestart.
+ if test "$1" = "condrestart"; then
+ echo "${attn} Use try-restart ${done}(LSB)${attn} rather than condrestart ${warn}(RH)${norm}"
+ fi
+ $0 status
+ if test $? = 0; then
+ $0 restart
+ else
+ rc_reset # Not running is not a failure.
+ fi
+ # Remember status and be quiet
+ rc_status
+ ;;
+ restart|force-reload)
+ ## Stop the service and regardless of whether it was
+ ## running or not, start it again.
+ $0 stop
+ $0 start
+
+ # Remember status and be quiet
+ rc_status
+ ;;
status)
status_of_proc $DAEMON
echo -n "Checking for service WineTestBot "
Module: tools
Branch: master
Commit: 0a7915b95b3279c5dd1df4bf8f300c24cbc025f8
URL: http://source.winehq.org/git/tools.git/?a=commit;h=0a7915b95b3279c5dd1df4bf…
Author: Francois Gouget <fgouget(a)codeweavers.com>
Date: Tue Mar 26 11:49:09 2013 +0100
testbot/scripts: The WineTestBot does not support SIGHUP so emulate 'initd reload' through try-restart.
---
testbot/scripts/initd | 19 ++-----------------
1 files changed, 2 insertions(+), 17 deletions(-)
diff --git a/testbot/scripts/initd b/testbot/scripts/initd
index 8853f6c..d782cbc 100755
--- a/testbot/scripts/initd
+++ b/testbot/scripts/initd
@@ -86,7 +86,7 @@ then
$0 start
;;
- try-restart)
+ try-restart|reload)
## Do a restart only if the service was active before.
if $0 status
then
@@ -94,12 +94,6 @@ then
fi
;;
- reload)
- log_daemon_msg "Reloading the WineTestBot configuration"
- killproc -p $PIDFILE $DAEMON -HUP
- log_end_msg $?
- ;;
-
status)
status="0"
pidofproc -p $PIDFILE $DAEMON >/dev/null || status="$?"
@@ -184,7 +178,7 @@ then
# Remember status and be verbose
rc_status -v
;;
- try-restart|condrestart)
+ try-restart|condrestart|reload)
## Do a restart only if the service was active before.
## Note: try-restart is now part of LSB (as of 1.9).
## RH has a similar command named condrestart.
@@ -209,15 +203,6 @@ then
# Remember status and be quiet
rc_status
;;
- reload)
- log_daemon_msg "Reloading service WineTestBot"
- killproc -HUP $DAEMON
- log_end_msg $?
-
- ## Otherwise if it does not support reload:
- #rc_failed 3
- #rc_status -v
- ;;
status)
status_of_proc $DAEMON
echo -n "Checking for service WineTestBot "
Module: tools
Branch: master
Commit: 9641db82e569662e9cb53188f241678aa77719e3
URL: http://source.winehq.org/git/tools.git/?a=commit;h=9641db82e569662e9cb53188…
Author: Francois Gouget <fgouget(a)codeweavers.com>
Date: Tue Mar 26 16:20:57 2013 +0100
testbot/Engine: Add --shutdown, --kill-tasks and --kill-vms options.
This makes it possible to cleanly stop the Engine and all its related tasks and VMs.
---
testbot/bin/Engine.pl | 102 ++++++++++++++++++++++++++++--
testbot/lib/WineTestBot/Engine/Notify.pm | 23 ++++++-
2 files changed, 118 insertions(+), 7 deletions(-)
diff --git a/testbot/bin/Engine.pl b/testbot/bin/Engine.pl
index f5b0661..fec0c67 100755
--- a/testbot/bin/Engine.pl
+++ b/testbot/bin/Engine.pl
@@ -43,6 +43,7 @@ use Socket;
use ObjectModel::BackEnd;
use WineTestBot::Config;
use WineTestBot::Engine::Events;
+use WineTestBot::Engine::Notify;
use WineTestBot::Jobs;
use WineTestBot::Log;
use WineTestBot::Patches;
@@ -50,6 +51,8 @@ use WineTestBot::PendingPatchSets;
use WineTestBot::Utils;
use WineTestBot::VMs;
+my $RunEngine = 1;
+
sub FatalError
{
LogMsg @_;
@@ -65,7 +68,8 @@ sub FatalError
=item C<Cleanup()>
The Cleanup() function gets the tasks and VMs in a consistent state on the
-Engine startup. It has to contend with two main scenarios:
+Engine startup or cleanly stops the tasks and VMs on shutdown.
+It has to contend with three main scenarios:
- The Engine being restarted. Any task started just before that is still
running should still have its process and powered on VM and should be left
alone so it can complete normally. If a task died unexpectedly while the
@@ -75,6 +79,8 @@ Engine startup. It has to contend with two main scenarios:
it is quite possible that they will still be running. Hopefully any running
process matching a task's ChildPid will belong to another user so we don't
mistake that case for the previous one.
+- A shutdown of the Engine and its tasks / VMs. In this case it's used to
+ kill the running tasks and requeue them, and/or shut down the VMs.
In all cases we only trust that a VM status field is still valid:
- It is 'running' and used by a task that is still running.
@@ -86,8 +92,10 @@ In all other cases the VM will be powered off and marked as dirty.
=back
=cut
-sub Cleanup()
+sub Cleanup(;$$)
{
+ my ($KillTasks, $KillVMs) = @_;
+
# Verify that the running tasks are still alive and requeue them if not.
# Ignore the Job and Step status fields because they may be a bit out of date.
my %BusyVMs;
@@ -115,6 +123,14 @@ sub Cleanup()
# Kill the task process if it's still there.
kill("TERM", $Task->ChildPid);
}
+ elsif ($KillTasks)
+ {
+ # Kill the task and requeue. Note that since the VM is still running
+ # we're not in the computer reboot case so ChildPid is probably
+ # still valid.
+ kill("TERM", $Task->ChildPid);
+ $Requeue = 1;
+ }
elsif (!kill(0, $Task->ChildPid))
{
# The event that caused the WineTestBot server to restart probably
@@ -165,8 +181,12 @@ sub Cleanup()
if ($VM->IsPoweredOn())
{
next if ($VM->Status eq "idle");
- if (($VM->Status eq "reverting" or $VM->Status eq "sleeping") and
- defined $VM->ChildPid and kill(0, $VM->ChildPid))
+ if ($KillVMs)
+ {
+ kill("TERM", $VM->ChildPid) if (defined $VM->ChildPid);
+ }
+ elsif (($VM->Status eq "reverting" or $VM->Status eq "sleeping") and
+ defined $VM->ChildPid and kill(0, $VM->ChildPid))
{
# This VM is still being reverted. Let that process run its course.
LogMsg "$VMKey is being reverted\n";
@@ -188,6 +208,43 @@ sub Cleanup()
}
+sub HandleShutdown
+{
+ my ($KillTasks, $KillVMs) = @_;
+
+ if (!defined $KillTasks or !defined $KillVMs)
+ {
+ LogMsg "Missing parameters in shutdown message\n";
+ return "0Missing shutdown parameters";
+ }
+
+ # Untaint parameters
+ if ($KillTasks =~ /^([01])$/)
+ {
+ $KillTasks = $1;
+ }
+ else
+ {
+ LogMsg "Invalid KillTasks $KillTasks in shutdown message\n";
+ return "0Invalid KillTasks shutdown parameter\n";
+ }
+ if ($KillVMs =~ /^([01])$/)
+ {
+ $KillVMs = $1;
+ }
+ else
+ {
+ LogMsg "Invalid KillVMs $KillVMs in shutdown message\n";
+ return "0Invalid KillVMs shutdown parameter\n";
+ }
+
+ Cleanup($KillTasks, $KillVMs);
+ $RunEngine = 0;
+
+ LogMsg "Waiting for the last clients to disconnect...\n";
+ return "1OK\n";
+}
+
sub HandlePing
{
return "1pong\n";
@@ -492,6 +549,7 @@ my %Handlers=(
"jobstatuschange" => \&HandleJobStatusChange,
"jobsubmit" => \&HandleJobSubmit,
"ping" => \&HandlePing,
+ "shutdown" => \&HandleShutdown,
"taskcomplete" => \&HandleTaskComplete,
"vmstatuschange" => \&HandleVMStatusChange,
"winepatchmlsubmission" => \&HandleWinePatchMLSubmission,
@@ -621,6 +679,40 @@ sub REAPER
sub main
{
+ my ($Shutdown, $KillTasks, $KillVMs);
+ while (@ARGV)
+ {
+ my $Arg = shift @ARGV;
+ if ($Arg eq "--shutdown")
+ {
+ $Shutdown = 1;
+ }
+ elsif ($Arg eq "--kill-tasks")
+ {
+ $KillTasks = 1;
+ $Shutdown = 1;
+ }
+ elsif ($Arg eq "--kill-vms")
+ {
+ $KillVMs = 1;
+ $Shutdown = 1;
+ }
+ else
+ {
+ die "Usage: Engine.pl [--shutdown] [--kill-tasks] [--kill-vms]";
+ }
+ }
+ if ($Shutdown)
+ {
+ my $ErrMessage = Shutdown($KillTasks, $KillVMs);
+ if (defined $ErrMessage)
+ {
+ print STDERR "$ErrMessage\n";
+ exit 1;
+ }
+ exit 0;
+ }
+
$ENV{PATH} = "/usr/bin:/bin";
delete $ENV{ENV};
$SIG{CHLD} = \&REAPER;
@@ -657,7 +749,7 @@ sub main
AddEvent("SafetyNet", 600, 1, \&SafetyNet);
my @Clients;
- while (1)
+ while ($RunEngine or @Clients)
{
my $ReadyRead = "";
my $ReadyWrite = "";
diff --git a/testbot/lib/WineTestBot/Engine/Notify.pm b/testbot/lib/WineTestBot/Engine/Notify.pm
index 8452615..1a1ab6d 100644
--- a/testbot/lib/WineTestBot/Engine/Notify.pm
+++ b/testbot/lib/WineTestBot/Engine/Notify.pm
@@ -33,8 +33,8 @@ use vars qw (@ISA @EXPORT @EXPORT_OK $RunningInEngine);
require Exporter;
@ISA = qw(Exporter);
-@EXPORT = qw(&PingEngine &JobSubmit &JobStatusChange &JobCancel &JobRestart
- &TaskComplete &VMStatusChange &FoundWinetestUpdate
+@EXPORT = qw(&Shutdown &PingEngine &JobSubmit &JobStatusChange &JobCancel
+ &JobRestart &TaskComplete &VMStatusChange &FoundWinetestUpdate
&WinePatchMLSubmission &WinePatchWebSubmission &GetScreenshot);
@EXPORT_OK = qw($RunningInEngine);
@@ -74,6 +74,25 @@ sub SendCmdReceiveReply
return $Reply;
}
+sub Shutdown
+{
+ my ($KillTasks, $KillVMs) = @_;
+
+ $KillTasks ||= 0;
+ $KillVMs ||= 0;
+ my $Reply = SendCmdReceiveReply("shutdown $KillTasks $KillVMs\n");
+ if (length($Reply) < 1)
+ {
+ return "Unrecognized reply received from engine";
+ }
+ if (substr($Reply, 0, 1) eq "1")
+ {
+ return undef;
+ }
+
+ return substr($Reply, 1);
+}
+
sub PingEngine
{
my $Reply = SendCmdReceiveReply("ping\n");
Module: tools
Branch: master
Commit: 2ecbb72c59e04b0b079267db948b83581db2b1d0
URL: http://source.winehq.org/git/tools.git/?a=commit;h=2ecbb72c59e04b0b079267db…
Author: Francois Gouget <fgouget(a)codeweavers.com>
Date: Tue Mar 26 11:47:48 2013 +0100
testbot: Keep track of the revert processes and handle server restarts more gracefully.
On startup the WineTestBot server now:
* Detects tasks that are still running and lets them complete.
* Cleans up and requeues the running tasks that died.
* Lets VMs that are currently reverting complete their revert.
* Leaves the idle powered on VMs and those used by running tasks as it.
* Shuts down any other active VM and marks them as dirty.
This makes it possible to kill and restart a WineTestBot server without impacting the running tasks.
Also, should the server reboot unexpectedly, the tasks that were running will be restarted.
---
testbot/bin/Engine.pl | 149 +++++++++++++++++++++++++++++++-----
testbot/bin/RevertVM.pl | 2 +
testbot/ddl/update21.sql | 5 +
testbot/ddl/winetestbot.sql | 1 +
testbot/doc/winetestbot-schema.dia | 20 +++++
testbot/lib/WineTestBot/Jobs.pm | 25 ++++--
testbot/lib/WineTestBot/Steps.pm | 23 ++++--
testbot/lib/WineTestBot/Tasks.pm | 2 +
testbot/lib/WineTestBot/VMs.pm | 19 +++++
testbot/web/admin/VMDetails.pl | 9 ++
10 files changed, 221 insertions(+), 34 deletions(-)
Diff: http://source.winehq.org/git/tools.git/?a=commitdiff;h=2ecbb72c59e04b0b0792…
Module: tools
Branch: master
Commit: 14e9dd49121ac3d6cba423c1b2bd8c41a4ce3668
URL: http://source.winehq.org/git/tools.git/?a=commit;h=14e9dd49121ac3d6cba423c1…
Author: Francois Gouget <fgouget(a)codeweavers.com>
Date: Tue Mar 26 11:47:35 2013 +0100
testbot: Tweak ScheduleJobs() to filter out disabled VMs as we won't be running jobs on them.
---
testbot/lib/WineTestBot/Jobs.pm | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)
diff --git a/testbot/lib/WineTestBot/Jobs.pm b/testbot/lib/WineTestBot/Jobs.pm
index c73dea1..61ef113 100644
--- a/testbot/lib/WineTestBot/Jobs.pm
+++ b/testbot/lib/WineTestBot/Jobs.pm
@@ -531,7 +531,10 @@ sub ScheduleJobs()
# we should check if there are VMs to revert
my %Hosts;
- foreach my $VM (@{CreateVMs()->GetItems()})
+ my $VMs = CreateVMs();
+ $VMs->FilterEnabledRole();
+ $VMs->FilterEnabledStatus();
+ foreach my $VM (@{$VMs->GetItems()})
{
my $Host = $VM->GetHost();
$Hosts{$Host}->{$VM->VirtURI} = 1;
Module: tools
Branch: master
Commit: 08297b4d2088f6aa98a7223dbf623ba958092f7e
URL: http://source.winehq.org/git/tools.git/?a=commit;h=08297b4d2088f6aa98a7223d…
Author: Francois Gouget <fgouget(a)codeweavers.com>
Date: Tue Mar 26 11:47:20 2013 +0100
testbot: Fix and simplify filtering the enabled VMs.
When a VM is marked as retired or deleted its status is not relevant
anymore. So filtering on the status alone is incorrect. Also rename
the functions as there is more than one role for disabled VMs, and
there could be more than one status too.
---
testbot/bin/CheckForWinetestUpdate.pl | 2 +-
testbot/bin/Engine.pl | 3 ++-
testbot/lib/WineTestBot/Patches.pm | 2 +-
testbot/lib/WineTestBot/VMs.pm | 11 +++++++++--
4 files changed, 13 insertions(+), 5 deletions(-)
diff --git a/testbot/bin/CheckForWinetestUpdate.pl b/testbot/bin/CheckForWinetestUpdate.pl
index c776fe5..c8909e6 100755
--- a/testbot/bin/CheckForWinetestUpdate.pl
+++ b/testbot/bin/CheckForWinetestUpdate.pl
@@ -92,7 +92,7 @@ sub AddJob
$VMs->AddFilter("Type", ["win32", "win64"]);
$VMs->AddFilter("Role", ["winetest"]);
}
- $VMs->FilterNotOffline();
+ $VMs->FilterEnabledStatus();
foreach my $VMKey (@{$VMs->SortKeysBySortOrder($VMs->GetKeys())})
{
my $Task = $Tasks->Add();
diff --git a/testbot/bin/Engine.pl b/testbot/bin/Engine.pl
index da3e54c..0a467fb 100755
--- a/testbot/bin/Engine.pl
+++ b/testbot/bin/Engine.pl
@@ -402,7 +402,8 @@ sub InitVMs()
# On startup we don't know what state the VMs are in. So consider them all
# to be dirty.
my $VMs = CreateVMs();
- $VMs->FilterNotOffline();
+ $VMs->FilterEnabledRole();
+ $VMs->FilterEnabledStatus();
foreach my $VM (@{$VMs->GetItems()})
{
$VM->Status('dirty');
diff --git a/testbot/lib/WineTestBot/Patches.pm b/testbot/lib/WineTestBot/Patches.pm
index 22e00e1..e8143ca 100644
--- a/testbot/lib/WineTestBot/Patches.pm
+++ b/testbot/lib/WineTestBot/Patches.pm
@@ -236,7 +236,7 @@ sub Submit
$VMs = CreateVMs();
$VMs->AddFilter("Type", $Bits eq "32" ? ["win32", "win64"] : ["win64"]);
$VMs->AddFilter("Role", ["base"]);
- $VMs->FilterNotOffline();
+ $VMs->FilterEnabledStatus();
if (@{$VMs->GetKeys()})
{
# Create the corresponding Step
diff --git a/testbot/lib/WineTestBot/VMs.pm b/testbot/lib/WineTestBot/VMs.pm
index b519f33..ff57d5a 100644
--- a/testbot/lib/WineTestBot/VMs.pm
+++ b/testbot/lib/WineTestBot/VMs.pm
@@ -639,10 +639,17 @@ sub SortKeysBySortOrder
return \@SortedKeys;
}
-sub FilterNotOffline($)
+sub FilterEnabledRole($)
{
my ($self) = @_;
- # All but the offline ones
+ # Filter out the disabled VMs, that is the retired and deleted ones
+ $self->AddFilter("Role", ["extra", "base", "winetest"]);
+}
+
+sub FilterEnabledStatus($)
+{
+ my ($self) = @_;
+ # Filter out the disabled VMs, that is the offline ones
$self->AddFilter("Status", ["dirty", "reverting", "sleeping", "idle", "running"]);
}
Module: tools
Branch: master
Commit: 2efbe36d11c083b9c7fd66b33d4d937b18064547
URL: http://source.winehq.org/git/tools.git/?a=commit;h=2efbe36d11c083b9c7fd66b3…
Author: Francois Gouget <fgouget(a)codeweavers.com>
Date: Tue Mar 26 11:47:08 2013 +0100
testbot/VMs: Fix counting the powered on non-base VMs.
VMs with a 'disabling' role must be ignored.
Make a clear distinction between the 'enabled' VMs which we could use
but may currently be powered off (e.g. dirty VMs), and the 'powered
on' ones that use resources right now. Also make it clear that these
methods are based on the Status and Role fields, not on what the VM
hypervisor thinks.
---
testbot/lib/WineTestBot/VMs.pm | 27 +++++++++++++++++++++------
1 files changed, 21 insertions(+), 6 deletions(-)
diff --git a/testbot/lib/WineTestBot/VMs.pm b/testbot/lib/WineTestBot/VMs.pm
index 360958e..b519f33 100644
--- a/testbot/lib/WineTestBot/VMs.pm
+++ b/testbot/lib/WineTestBot/VMs.pm
@@ -442,6 +442,25 @@ sub Status
return $NewStatus;
}
+sub HasPoweredOnStatus($)
+{
+ my ($self) = @_;
+ my $Status = $self->Status;
+ return $Status eq "reverting" or
+ $Status eq "sleeping" or
+ $Status eq "idle" or
+ $Status eq "running";
+}
+
+sub HasEnabledRole($)
+{
+ my ($self) = @_;
+ my $Role = $self->Role;
+ return $Role eq "extra" or
+ $Role eq "base" or
+ $Role eq "winetest";
+}
+
sub Validate
{
my $self = shift;
@@ -588,12 +607,8 @@ sub CountPoweredOnNonBaseVMs
my $PoweredOnVMs = 0;
foreach my $VM (@{$self->GetItems()})
{
- my $VMStatus = $VM->Status;
- if ($VM->Role ne "base" &&
- ($VMStatus eq "reverting" ||
- $VMStatus eq "sleeping" ||
- $VMStatus eq "idle" ||
- $VMStatus eq "running"))
+ if ($VM->Role ne "base" and $VM->HasEnabledRole() and
+ $VM->HasPoweredOnStatus())
{
$PoweredOnVMs++;
}