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