From: Ian Campbell <ian.campbell@citrix.com>
To: ian.jackson@eu.citrix.com
Cc: Ian Campbell <ian.campbell@citrix.com>, xen-devel@lists.xen.org
Subject: [PATCH OSSTEST 4/6] Serial: collect serial logs from an http server
Date: Fri, 11 Oct 2013 16:54:21 +0100 [thread overview]
Message-ID: <1381506863-1888-4-git-send-email-ian.campbell@citrix.com> (raw)
In-Reply-To: <1381506785.24708.66.camel@kazak.uk.xensource.com>
This relies on wget and httpd colluding to set the mtimes on the downloaded
files, which works with at least the one server I care about (the apache on
the conserver handling the marilith boxes)
---
Osstest/Serial/http.pm | 114 ++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 114 insertions(+)
create mode 100644 Osstest/Serial/http.pm
diff --git a/Osstest/Serial/http.pm b/Osstest/Serial/http.pm
new file mode 100644
index 0000000..cb36f1c
--- /dev/null
+++ b/Osstest/Serial/http.pm
@@ -0,0 +1,114 @@
+# This is part of "osstest", an automated testing framework for Xen.
+# Copyright (C) 2009-2013 Citrix Inc.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Fetch logs from a web directory export.
+
+package Osstest::Serial::http;
+
+use strict;
+use warnings;
+
+use Osstest;
+use Osstest::TestSupport;
+
+use File::Temp;
+use File::Copy;
+
+BEGIN {
+ use Exporter ();
+ our ($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS);
+ $VERSION = 1.00;
+ @ISA = qw(Exporter);
+ @EXPORT = qw();
+ %EXPORT_TAGS = ( );
+
+ @EXPORT_OK = qw();
+}
+
+sub new {
+ my ($class, $ho, $methname, @args) = @_;
+ my $mo = { Host => $ho, Name => $ho->{Name} };
+ die if @args<1;
+ push @args, "$ho->{Name}.txt*" if @args < 2;
+
+ logm("serial method $methname $mo->{Host}{Name}: @args");
+ ($mo->{Server}, $mo->{Pattern}) = @args;
+ return bless $mo, $class;
+}
+
+sub request_debug {
+ return 0;
+}
+
+sub fetch_logs {
+ my ($mo) = @_;
+
+ my $started= $mjobdb->jobdb_flight_started_for_log_capture($flight);
+
+ my $ho = $mo->{Host};
+ my $logpat = $mo->{Pattern};
+ my $targhost= $mo->{Server};
+
+ logm("serial http from $mo->{Name} fetching $mo->{Pattern} from $mo->{Server}");
+
+ my $dir = File::Temp->newdir();
+ my $tdir = $dir->dirname;
+
+ my $lrf = "$tdir/log-retrieval.log";
+
+ system_checked(qw(wget -nH --cut-dirs=1 -r -l1 --no-parent),
+ '-o', "$lrf",
+ '-A', $mo->{Pattern},
+ '-P', $tdir,
+ $mo->{Server});
+
+ my $sr = "serial-retrieval.log";
+ my $lr = open_unique_stashfile(\$sr);
+ File::Copy::copy($lrf, $lr);
+
+ my %done;
+ foreach my $logfile (glob "$tdir/$mo->{Pattern}") {
+ my $lh= new IO::File $logfile, 'r';
+ if (!defined $lh) {
+ $!==&ENOENT or warn "$logfile $!";
+ next;
+ }
+ stat $lh or die "$logfile $!";
+ my $inum= (stat _)[1];
+ my $lfage= (stat _)[9];
+ my $df= $logfile;
+ $df =~ s,.*/,,;
+ if ($lfage < $started) {
+ next if $done{$inum};
+ logm("$df modified $lfage, skipping")
+ unless $done{$inum};
+ $done{$inum}= 1;
+ next;
+ }
+ next if defined $done{$inum} and $done{$inum} >= 2;
+ $done{$inum}= 2;
+
+ $df = "serial-$df";
+ logm("stashing $df");
+
+ my $dh= open_unique_stashfile(\$df);
+ File::Copy::copy($logfile, $dh);
+ }
+ return;
+
+}
+
+1;
--
1.7.10.4
next prev parent reply other threads:[~2013-10-11 15:54 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-11 15:53 [PATCH OSSTEST 0/6] Support for serial logs from marilith boxes Ian Campbell
2013-10-11 15:54 ` [PATCH OSSTEST 1/6] Standalone: Collect logs modified in the last hour Ian Campbell
2013-10-11 15:54 ` [PATCH OSSTEST 2/6] TestSupport: allow multiple host serial methods Ian Campbell
2013-10-11 15:54 ` [PATCH OSSTEST 3/6] Serial: Refactor debug key sending into separate request_debug function Ian Campbell
2013-10-11 15:54 ` Ian Campbell [this message]
2013-10-11 15:54 ` [PATCH OSSTEST 5/6] Serial: new module to send debug keys via xenuse Ian Campbell
2013-10-11 15:54 ` [PATCH OSSTEST 6/6] Serial/http: use mkdtemp instead of File::Temp->newdir Ian Campbell
2013-10-11 17:22 ` [PATCH OSSTEST 0/6] Support for serial logs from marilith boxes Ian Jackson
2013-10-13 9:19 ` Ian Campbell
2013-10-13 9:51 ` Ian Campbell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1381506863-1888-4-git-send-email-ian.campbell@citrix.com \
--to=ian.campbell@citrix.com \
--cc=ian.jackson@eu.citrix.com \
--cc=xen-devel@lists.xen.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).