]> sourceware.org Git - systemtap.git/commitdiff
PR 10922: Client/Server Testsuite problems when avahi (mDNS) is bkocked by the firewall.
authorDave Brolley <brolley@redhat.com>
Tue, 30 Nov 2010 18:07:15 +0000 (13:07 -0500)
committerDave Brolley <brolley@redhat.com>
Tue, 30 Nov 2010 18:17:17 +0000 (13:17 -0500)
The test suite now communicates with the server directly using
--use-serber=$HOSTNAME:PORT when avahi is blocked or not working.

testsuite/lib/systemtap.exp

index 265e7cb94d3e449fb2278c37e0fb3d78f49d78ae..aa794a050f1a80f8b31aa54e8ecd3e4942d111fd 100644 (file)
@@ -109,7 +109,7 @@ proc setup_systemtap_environment {} {
 # Set up the environment so that tests will be performed using the systemtap
 # client and server.
 proc setup_server {} {
-    global srcdir env server_pid net_path installed_stap
+    global srcdir env net_path installed_stap
 
     # Make sure that the necessary resources are available to run the client/server.
     if {[catch {exec /usr/bin/which avahi-publish-service} dummy]} then {
@@ -126,12 +126,42 @@ proc setup_server {} {
        return 0
     }
 
+    # See what avahi finds. Give the server a chance to advertise.
+    exec sleep 1
+    catch { exec avahi-browse _stap._tcp -t -r | grep -A4 {^=.*Systemtap.Compile} } looksee
+    verbose -log "avahi-browse found:\n$looksee"
+
+    # Make sure that stap can find the server.
+    set use_server --use-server
+    set res [catch { exec stap --list-servers=online,trusted,compatible 2>@ stdout | grep "^ host" } looksee]
+    verbose -log "stap --list-servers found:\n$looksee"
+    if {$res != 0} then {
+       print "Unable to automatically find a systemtap server -- check firewall settings for mDNS"
+       # Try to discover the port the server is listening on from the server
+       # log.
+       set res [catch { exec /bin/cat [exec pwd]/server.log | awk "/^Systemtap Compile Server on port .* ready/ {print \$6}" } server_port]
+       if {$res != 0} then {
+           print "Unable to discover the port used by the systemtap server"
+           return 0
+       }
+       set server_spec $env(HOSTNAME):$server_port
+       print "Client/Server tests will be run by contacting the server directly as $server_spec"
+
+       # Make sure stap can contact the server directly
+       set use_server --use-server=$server_spec
+       set res [catch {exec stap $use_server -p2 -e {probe begin {exit()}}} looksee]
+       if {$res != 0} then {
+           print "Unable to contact the server at $server_spec directly"
+           return 0
+       }
+    }
+
     # Substitute a script on the PATH in place of stap which calls the real
     # stap with the --use-server flag.
     set path "$net_path/stap"
     set fp [open $path "w"]
     puts $fp "#!/bin/sh"
-    puts $fp "[exec which stap] --use-server \"\$@\""
+    puts $fp "[exec which stap] $use_server \"\$@\""
     close $fp
     exec chmod +x $path
 
@@ -165,7 +195,7 @@ proc start_server {} {
     exec touch $logfile
     exec chmod 666 $logfile
 
-    # Try to find or start the server.
+    # Try to start the server.
     set server_pid [exec env STAP_PR11197_OVERRIDE=1 env SYSTEMTAP_STAP=[exec which stap] stap-start-server --log=$logfile]
     if { "$server_pid" == "" } then {
        print "Cannot start a systemtap server"
@@ -175,19 +205,6 @@ proc start_server {} {
        verbose -log "Started a systemtap server as PID==$server_pid"
     }
 
-    # See what avahi finds. Give the server a chance to advertise.
-    exec sleep 1
-    catch { exec avahi-browse _stap._tcp -t -r | grep -A4 {^=.*Systemtap.Compile} } looksee
-    verbose -log "avahi-browse found:\n$looksee"
-
-    # Make sure that stap can find the server.
-    set lines [exec stap --list-servers=online,trusted,compatible 2>@ stdout | wc -l]
-    if {$lines < 2} then {
-       print "Unable to find a systemtap server -- check firewall settings for mDNS"
-       shutdown_server
-       return 0
-    }
-
     return 1
 }
 
@@ -245,7 +262,8 @@ proc get_system_info {} {
 }
 
 if {! [setup_systemtap_environment]} then {
-    return 0
+    cleanup
+    exit 1
 }
 
 print_systemtap_version
This page took 0.037544 seconds and 5 git commands to generate.