-
Notifications
You must be signed in to change notification settings - Fork 8
/
websocket.xml
192 lines (145 loc) · 5.81 KB
/
websocket.xml
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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
<?xml version="1.0"?>
<!DOCTYPE tsung SYSTEM "tsung-1.0.dtd">
<tsung loglevel="notice">
<!-- generate the load on localhost -->
<clients>
<client host="localhost" use_controller_vm="true" maxusers="800"/>
</clients>
<!-- the target server is running on the same machine and uses SSL -->
<servers>
<server host="127.0.0.1" port="8080" type="ssl"/>
</servers>
<!-- gather OS statistics from the host -->
<monitoring>
<monitor host="localhost"/>
</monitoring>
<load>
<!-- first, a steady stream of new users -->
<arrivalphase phase="1" duration="3" unit="minute">
<users arrivalrate="1" unit="second"></users>
</arrivalphase>
<!-- then it gets interesting -->
<arrivalphase phase="2" duration="3" unit="minute">
<users arrivalrate="5" unit="second"></users>
</arrivalphase>
<!-- and ends up in an avalanche -->
<arrivalphase phase="3" duration="3" unit="minute">
<users arrivalrate="10" unit="second"></users>
</arrivalphase>
</load>
<!--
here we define three types of sessions, where the user:
* does a simple 2+3 calculation
* does two calculations in parallel
* computes a very large number and stays connected for a long time after that
-->
<sessions>
<!-- connect and calculate 2 + 3 -->
<session probability="60" name="simple_sum" type="ts_websocket">
<request>
<websocket type="connect" origin="https://127.0.0.1/" url="/ws"/>
</request>
<request>
<!-- capture the returned UUID -->
<dyn_variable name="uuid" jsonpath="uuid"/>
<websocket type="send">{"msg": "uuid"}</websocket>
</request>
<!-- the push requests are no_ack, because we don't expect anything in return (not how we include the previously captured UUID) -->
<request subst="true">
<websocket type="send" ack="no_ack">{"msg": "push", "token": 2, "uuid": "%%_uuid%%"}</websocket>
</request>
<request subst="true">
<websocket type="send" ack="no_ack">{"msg": "push", "token": 3, "uuid": "%%_uuid%%"}</websocket>
</request>
<request subst="true">
<websocket type="send" ack="no_ack">{"msg": "push", "token": "+", "uuid": "%%_uuid%%"}</websocket>
</request>
<!-- calculate the result and check if it's correct -->
<request subst="true">
<match do="log" when="nomatch">{"result": 5.0}</match>
<websocket type="send">{"msg": "compute", "uuid": "%%_uuid%%"}</websocket>
</request>
<!-- stay connected, pinging the server every now and then -->
<for var="i" from="1" to="10" incr="1">
<thinktime value="10"/>
<request>
<websocket type="ping">PING</websocket>
</request>
</for>
<request>
<websocket type="close"/>
</request>
</session>
<!-- run two calculations in parallel -->
<session probability="20" name="interleave_sessions" type="ts_websocket">
<request>
<websocket type="connect" url="/ws"/>
</request>
<!-- proceed to request two UUIDs, prepare two stacks and compute them both -->
<request>
<dyn_variable name="uuid1" jsonpath="uuid"/>
<websocket type="send">{"msg": "uuid"}</websocket>
</request>
<request subst="true">
<websocket type="send" ack="no_ack">{"msg": "push", "token": 5, "uuid": "%%_uuid1%%"}</websocket>
</request>
<request>
<dyn_variable name="uuid2" jsonpath="uuid"/>
<websocket type="send">{"msg": "uuid"}</websocket>
</request>
<thinktime value="1"/>
<request subst="true">
<websocket type="send" ack="no_ack">{"msg": "push", "token": 8, "uuid": "%%_uuid2%%"}</websocket>
</request>
<request subst="true">
<websocket type="send" ack="no_ack">{"msg": "push", "token": 2, "uuid": "%%_uuid1%%"}</websocket>
</request>
<request subst="true">
<websocket type="send" ack="no_ack">{"msg": "push", "token": 2, "uuid": "%%_uuid2%%"}</websocket>
</request>
<thinktime value="1"/>
<request subst="true">
<websocket type="send" ack="no_ack">{"msg": "push", "token": "*", "uuid": "%%_uuid1%%"}</websocket>
</request>
<request subst="true">
<websocket type="send" ack="no_ack">{"msg": "push", "token": "*", "uuid": "%%_uuid2%%"}</websocket>
</request>
<request subst="true">
<match do="log" when="nomatch">{"result": 10.0}</match>
<websocket type="send">{"msg": "compute", "uuid": "%%_uuid1%%"}</websocket>
</request>
<request subst="true">
<match do="log" when="nomatch">{"result": 16.0}</match>
<websocket type="send">{"msg": "compute", "uuid": "%%_uuid2%%"}</websocket>
</request>
<request>
<websocket type="close"/>
</request>
</session>
<!-- calculate a large number -->
<session probability="20" name="large_number" type="ts_websocket">
<request>
<websocket type="connect" url="/ws"/>
</request>
<request>
<dyn_variable name="uuid" jsonpath="uuid"/>
<websocket type="send">{"msg": "uuid"}</websocket>
</request>
<request subst="true">
<websocket type="send" ack="no_ack">{"msg": "push", "token": 32, "uuid": "%%_uuid%%"}</websocket>
</request>
<request subst="true">
<websocket type="send" ack="no_ack">{"msg": "push", "token": 32, "uuid": "%%_uuid%%"}</websocket>
</request>
<request subst="true">
<websocket type="send" ack="no_ack">{"msg": "push", "token": "**", "uuid": "%%_uuid%%"}</websocket>
</request>
<request subst="true">
<websocket type="send">{"msg": "compute", "uuid": "%%_uuid%%"}</websocket>
</request>
<request>
<websocket type="close"/>
</request>
</session>
</sessions>
</tsung>