1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161
|
# Server Concurrency Tests
# Save the old log file, create a new one
# and make sure it's world writable. We need to
# use a clean server log since we are crawling the
# output to find the port and to verify concurrency.
# We restore the old log at the end, appending the log
# output from this test.
set logfile "[exec pwd]/server.log"
set oldlogfile "[exec pwd]/old_server.log"
if {[file exists $logfile]} then {
exec mv $logfile $oldlogfile
}
exec touch $logfile
exec chmod 666 $logfile
# Start our own server and make sure we can work with it.
if {! [setup_server --max-threads 6]} {
untested "Compile-server client tests against a server"
return;
}
# Find the port chosen by the server. This way the port
# should always be unique (as opposed to specifying a
# a static port).
set server_port 0
set f [open $logfile]
set matched 0
verbose -log "Server output: "
while {1} {
set line [gets $f]
if {[eof $f]} {
close $f
break
}
verbose -log "$line"
if { [regexp {^.*Using network address .+:(\d+)$} $line matched server_port ] } {
close $f
break
}
}
if { $server_port == 0 } {
verbose -log "Could not find port number in server log: $logfile"
}
# Set up the hostname and port we will use to connect to the server
set test "server_concurrency"
set failed 1
set server_spec [info hostname]:$server_port
set use_server --use-server=$server_spec
verbose -log "Client/Server tests will be run by contacting the server directly as $server_spec"
# Start the first connection...
set cmd "stap $use_server -p4 $srcdir/systemtap.server/server_concurrency1.stp"
verbose -log "executing: $cmd"
eval spawn $cmd
set firstid $spawn_id
# Start the second connection...
set cmd "stap $use_server -p4 $srcdir/systemtap.server/server_concurrency2.stp"
verbose -log "executing: $cmd"
eval spawn $cmd
set secondid $spawn_id
# Start the third connection...
set cmd "stap $use_server -p4 $srcdir/systemtap.server/server_concurrency3.stp"
verbose -log "executing: $cmd"
eval spawn $cmd
set thirdid $spawn_id
# Start the fourth connection...
set cmd "stap $use_server -p4 $srcdir/systemtap.server/server_concurrency1.stp"
verbose -log "executing: $cmd"
eval spawn $cmd
set fourthid $spawn_id
# Start the fifth connection...
set cmd "stap $use_server -p4 $srcdir/systemtap.server/server_concurrency2.stp"
verbose -log "executing: $cmd"
eval spawn $cmd
set fifthid $spawn_id
# Start the sixth connection...
set cmd "stap $use_server -p4 $srcdir/systemtap.server/server_concurrency3.stp"
verbose -log "executing: $cmd"
eval spawn $cmd
set sixthid $spawn_id
# Wait for them to finish
expect {
-timeout 180
-i $firstid timeout {
kill -INT -[exp_pid -i $firstid] 2
fail "$test (timeout 1)"
exp_continue
}
-i $secondid timeout {
kill -INT -[exp_pid -i $secondid] 2
fail "$test (timeout 2)"
exp_continue
}
-i $thirdid timeout {
kill -INT -[exp_pid -i $thirdid] 2
fail "$test (timeout 3)"
exp_continue
}
-i $fourthid timeout {
kill -INT -[exp_pid -i $fourthid] 2
fail "$test (timeout 4)"
exp_continue
}
-i $fifthid timeout {
kill -INT -[exp_pid -i $fifthid] 2
fail "$test (timeout 5)"
exp_continue
}
-i $sixthid timeout {
kill -INT -[exp_pid -i $sixthid] 2
fail "$test (timeout 6)"
exp_continue
}
}
catch {close -i $firstid}; catch {wait -i $firstid}
catch {close -i $secondid}; catch {wait -i $secondid}
catch {close -i $thirdid}; catch {wait -i $thirdid}
catch {close -i $fourthid}; catch {wait -i $fourthid}
catch {close -i $fifthid}; catch {wait -i $fifthid}
catch {close -i $sixthid}; catch {wait -i $sixthid}
# Check the log output file for cuncurrency
set f [open $logfile]
verbose -log "Server ouput: "
while {1} {
set line [gets $f]
if {[eof $f]} {
close $f
break
}
verbose -log "$line"
if { [regexp {^.*Processing 6 concurrent requests...$} $line ] } {
set failed 0
close $f
break
}
}
if { $failed == 0 } {
pass $test
} else {
fail $test
}
# Cleanup and shutdown the server we started.
# Restore the old log file, appending the new
# one to the end.
if {[file exists $logfile]} then {
exec cat $logfile >> $oldlogfile
exec rm -f $logfile
exec mv $oldlogfile $logfile
}
shutdown_server
|