File: server_concurrency.exp

package info (click to toggle)
systemtap 5.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 47,556 kB
  • sloc: cpp: 81,117; ansic: 54,933; xml: 49,795; exp: 43,595; sh: 11,526; python: 5,003; perl: 2,252; tcl: 1,312; makefile: 1,006; javascript: 149; lisp: 105; awk: 101; asm: 91; java: 70; sed: 16
file content (144 lines) | stat: -rw-r--r-- 3,936 bytes parent folder | download | duplicates (5)
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
# Server Concurrency Tests

# The setup_server procedure always uses a "fresh" server log file, so
# we don't need to do the save and restore this test used to do.
global server_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 $server_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 $server_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.
shutdown_server