[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [OSSTEST PATCH 2/3] ts-tcpdump-start: New test step script



Sets up a tcpdump on a dom0.  (We do not log traffic to other test
boxes in the job because that might include large amounts of migration
or test data.)

Also arrange that:
 - We stop the tcpdump when doing log capture
 - We capture the tcpdump record (by adding a big pattern to the log list)
 - We do not treat the tcpdump as a leaked process

With this, a new step can be added to existing jobs as needed.

(The "killall tcpdump ||:" is duplicated in ts-tcpdump-start and
ts-logs-capture because the error handling ought to be different, so
that a refactoring to make it common would add more complexity than it
saves.)

Signed-off-by: Ian Jackson <Ian.Jackson@xxxxxxxxxxxxx>

fixup! ts-tcpdump-start: New test step script
---
 ts-leak-check    |    4 ++++
 ts-logs-capture  |   13 ++++++++++++
 ts-tcpdump-start |   60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 77 insertions(+)
 create mode 100755 ts-tcpdump-start

diff --git a/ts-leak-check b/ts-leak-check
index ec40435..e6c1647 100755
--- a/ts-leak-check
+++ b/ts-leak-check
@@ -80,6 +80,10 @@ sub start_check () {
         push @suppress, $&;
     }
 
+    if ($r{"$ho->{Ident}_tcpdump"}) {
+       push @suppress, '^process .* tcpdump$';
+    }
+
     my $leaf= "leak-current-$ho->{Name}";
     $statefh= open_unique_stashfile(\$leaf);
 }
diff --git a/ts-logs-capture b/ts-logs-capture
index 453b03d..1b171cb 100755
--- a/ts-logs-capture
+++ b/ts-logs-capture
@@ -33,6 +33,16 @@ our ($whhost) = @ARGV;
 $whhost ||= 'host';
 our $ho= selecthost($whhost);
 
+sub stop_traces ($) {
+    my ($lho) = @_;
+    if ($r{"$lho->{Ident}_tcpdump"}) {
+       eval {
+           target_cmd_root($lho, "killall tcpdump ||:");
+       };
+       warn $@ if length $@;
+    };
+}
+
 sub try_fetch_logs ($$) {
     my ($lho, $logfilepats) = @_;
     my $ok= 0;
@@ -136,6 +146,8 @@ sub fetch_logs_host_guests () {
 
                   /home/osstest/osstest-confirm-booted.log
 
+                  /var/log/osstest-*
+
                   )];
     if (!try_fetch_logs($ho, $logs)) {
         logm("log fetching failed, trying hard host reboot...");
@@ -220,6 +232,7 @@ sub fetch_logs_guest ($) {
     }
 }
 
+stop_traces($ho);
 serial_fetch_logs($ho);
 fetch_logs_host_guests();
 logm("logs captured to $stash");
diff --git a/ts-tcpdump-start b/ts-tcpdump-start
new file mode 100755
index 0000000..60e499d
--- /dev/null
+++ b/ts-tcpdump-start
@@ -0,0 +1,60 @@
+#!/usr/bin/perl -w
+# 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/>.
+
+use strict qw(vars);
+use Osstest;
+use Osstest::TestSupport;
+
+tsreadconfig();
+
+@ARGV==1 or die;
+our ($whhost) = @ARGV;
+our $ho = selecthost($whhost);
+
+my $ether = $r{"$ho->{Ident}_physnic"} // 'eth0';
+
+my $dump = '/var/log/osstest-tcpdump';
+
+use Data::Dumper;
+
+sub start () {
+    my $runningk = "$ho->{Ident}_tcpdump";
+    if ($r{$runningk}) {
+       target_cmd_root($ho, "killall tcpdump ||:");
+    }
+
+    my @excludeips;
+    foreach my $k (sort keys %r) {
+        next unless $k =~ m/^(?:\w+_)?host$/;
+       next if $k eq $ho->{Ident};
+       logm("checking whether to exclude traffic to other test host $k");
+       eval {
+           my $otherho = selecthost $k;
+           push @excludeips, $otherho->{Ip};
+       };
+       warn $@ if length $@;
+    }
+
+    my $cmd= "tcpdump -p -w$dump -i$ether";
+    $cmd .= join " and ", map { "not ip host $_" } @excludeips;
+
+    store_runvar($runningk, 1);
+
+    target_cmd_root($ho, "$cmd </dev/null >$dump.log 2>&1 & sleep 1");
+}
+
+start();
-- 
1.7.10.4


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.