| 1 |
set test "exporter" |
| 2 |
|
| 3 |
if {! [python3_p]} then { untested $test; return } |
| 4 |
if {! [installtest_p]} { untested $test; return } |
| 5 |
|
| 6 |
set old_timeout $timeout |
| 7 |
set timeout 10 |
| 8 |
|
| 9 |
# start the stap-exporter process in the background |
| 10 |
set port [find_random_unused_tcp_port] |
| 11 |
|
| 12 |
# run against the default install-tree |
| 13 |
set s_e_pid [exec stap-exporter -p $port -k 30 >> systemtap.log 2>> systemtap.log &] |
| 14 |
set url "http://localhost:$port" |
| 15 |
|
| 16 |
if {$s_e_pid > 0} then { pass "$test startup" } else { fail "$test startup" } |
| 17 |
|
| 18 |
# sleep a little bit, to give the server a chance to start up its http listener |
| 19 |
verbose -log "waiting a few seconds" |
| 20 |
sleep 20 |
| 21 |
verbose -log "done waiting" |
| 22 |
|
| 23 |
spawn wget --server-response -q --retry-on-http-error=503 $url/no_such_script.stp |
| 24 |
set ok 0 |
| 25 |
expect { |
| 26 |
-re {HTTP/1.0 404 Not Found.*} { incr ok } |
| 27 |
} |
| 28 |
if { $ok > 0 } then { pass "$test badurl" } else { fail "$test badurl $ok" } |
| 29 |
wait |
| 30 |
|
| 31 |
sleep 10 |
| 32 |
spawn wget --server-response -q --retry-on-http-error=503 $url/autostart-also_ran.stp -O - |
| 33 |
set ok 0 |
| 34 |
expect { |
| 35 |
-re {HTTP/1.0 200 OK\r\n} { incr ok; exp_continue } |
| 36 |
-re {count[^\r\n]*\r\n} { incr ok; exp_continue } |
| 37 |
default { } |
| 38 |
} |
| 39 |
wait |
| 40 |
if { $ok > 1 } then { pass "$test autostart-also_ran" } else { fail "$test autostart-also_ran $ok" } |
| 41 |
|
| 42 |
# now we access the default non-autostart script; it should return a 503 |
| 43 |
spawn wget --server-response -q $url/syscallsbypid.stp |
| 44 |
set ok 0 |
| 45 |
expect { |
| 46 |
-re {HTTP/1.0 503 Service Unavailable\r\n} { incr ok; exp_continue } |
| 47 |
} |
| 48 |
wait |
| 49 |
if { $ok > 0 } then { pass "$test syscallsbypid startup" } else { fail "$test syscallsbypid startup $ok" } |
| 50 |
|
| 51 |
# now we access it repeatedly until we get some real data |
| 52 |
sleep 10 |
| 53 |
spawn wget --server-response -q --retry-on-http-error=503 $url/syscallsbypid.stp -O - |
| 54 |
sleep 10 |
| 55 |
# and just once more, to guarantee -some- syscalls |
| 56 |
spawn wget --server-response -q --retry-on-http-error=503 $url/syscallsbypid.stp -O - |
| 57 |
set ok 0 |
| 58 |
expect { |
| 59 |
-re {HTTP/1.0 200 OK\r\n} { incr ok; exp_continue } |
| 60 |
-re {count[^\r\n]*\r\n} { incr ok; exp_continue } |
| 61 |
default { } |
| 62 |
} |
| 63 |
wait |
| 64 |
if { $ok > 2 } then { pass "$test syscallsbypid" } else { fail "$test syscallsbypid $ok" } |
| 65 |
|
| 66 |
verbose -log "waiting for exporter to shut syscallsbypid down again" |
| 67 |
sleep 40 |
| 68 |
verbose -log "done waiting" |
| 69 |
|
| 70 |
spawn wget --server-response -q $url/syscallsbypid.stp |
| 71 |
set ok 0 |
| 72 |
expect { |
| 73 |
-re {HTTP/1.0 503 Service Unavailable\r\n} { incr ok; exp_continue } |
| 74 |
default { } |
| 75 |
} |
| 76 |
wait |
| 77 |
if { $ok > 0 } then { pass "$test syscallsbypid autokill" } else { fail "$test syscallsbypid autokill $ok" } |
| 78 |
|
| 79 |
kill -INT $s_e_pid |
| 80 |
set timeout $old_timeout |