-
Notifications
You must be signed in to change notification settings - Fork 0
/
README
469 lines (398 loc) · 12 KB
/
README
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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
Kamailio configuration tests
----------------------------
Requiriments:
-------------
- A working NGCP
- sip-tester. sipp with ssl enabled ( needed for auth ).
We provide a version backported
See debian/control for the actual list of dependences
Usage:
------
# cd /usr/share/kamailio-config-tests
We support groups of scenarios. Each group can have different configs, see
$BASE_DIR/$GROUP/config.yml. The default GROUP is 'scenarios'. Set GROUP to
scenarios_XXX in order to run/test that group.
If you are using the git version and not in /usr/share/kamailio-config-tests
you need to set BASE_DIR environment variable accordingly:
# export BASE_DIR=`pwd`
This is not needed if you are using the Debian packaged version.
PROFILE: "CE" the default
"PRO"
#bash ./run_tests.sh [-p PROFILE ] [-K] [-c] [-r]
This will create:
- $BASE_DIR/log
with a directory per test with:
- kamailio.log
- kamailio-lb.log
- sems.log
- sems-pbx.log
- XXXX.json (parsed messages)
- a pcap file for each interface (if -K option is used)
- cdr.txt (if -c option is used)
- sipp error logs (if any)
#bash ./get_results.sh [-p PROFILE ] [-g] [-c] [-r]
This will create:
- $BASE_DIR/result
with a directory per test with:
- a tap file with the test results
- a png file containing the routes flow (if -g option is used)
If you want to run tests that belongs to a different scenarios set, use the
-x option followed by the scenario's name:
#bash ./run_tests.sh [-p PROFILE ] [-K] [-c] [-r] -x scenarios_lnp
#bash ./get_results.sh [-p PROFILE ] [-g] [-c] [-r] -x scenarios_lnp
If you want to run test manually just exec this once:
#bash ./set_config.sh [-x GROUP]
and run the check that you want:
#bash PERL5LIB="$(pwd)/lib" ./bin/check.sh <checkname>
this will run the test and the result taps
or run all the tests as many times you want with:
#bash ./bin/bench.sh $NUM
If you want to test just a set of scenarios, set the SCENARIOS
environment var.
#bash SCENARIOS="invite invite_callforward" ./run_tests.sh -C
#bash SCENARIOS="invite invite_callforward" ./get_results.sh
Development:
------------
Every test has to be located at the scenarios directory. It must include:
- scenario.yml
- XXXX_test.yml.tt2
XXXX indicates the number of kamailio parsed msg XXXX.json to test
- sipp_scenarioXX.xml
And can optionally include:
- sipp_scenario_responderXX.xml
- cdr_test.yml.tt2
- prefs.json
- callforward.yml
- speeddial.yml
- peer.yml
- trusted.yml
- registration.yml
Test file syntax (XXXX_test.yml.tt2 files):
-------------------------------------------
The test file is divided in tree different parts:
- flow:
Array of routes with a possible list of pseudo-variables values to test.
If the value is a string it will be treated as a regular expression rule[0].
Example:
flow:
- start|MAIN:
$avp(val): [1, "test"]
- start|ROUTE_NET_INFO:
$avp(val): [2,1]
- end|ROUTE_NET_INFO:
$avp(val): None
- start|ROUTE_PRX_REQUEST:
$xavp(caller_peer_prefs[0]=>concurrent_max): '\d+'
- start|ROUTE_INVITE:
$xavp(caller_peer_prefs[0]=>concurrent_max[*]): [1]
- start|ROUTE_LOAD_CALLEE_DOMAIN_PREF:
- start|ROUTE_CLEAR_CALLEE_DOMAIN_PREF:
- end|ROUTE_CLEAR_CALLEE_DOMAIN_PREF:
- end|ROUTE_LOAD_CALLEE_DOMAIN_PREF:
- start|ROUTE_FIND_CALLER:
- start|ROUTE_AUTH:
- exit|ROUTE_AUTH:
$fU: testuser
- sip_in:
Array of regular expresion rules[0] to match in the sip messsage. If the rule
starts with '_:NOT:_' it will fail if the rule matches.
Example:
sip_in:
- '^INVITE'
- 'Contact: sip:testuser1002@'
- 'CSeq: 2 INVITE'
- 'Max-Forwards: 16'
- 'Content-Type: application/sdp'
- 'Proxy-Authorization: Digest username="testuser1002"'
- '_:NOT:_Contact: <sip:[email protected]:6666;ob>;expires=\d+',
- sip_out:
Array of lists of regular expression rules[0] to match the array of sip messages
send out. If the rule starts with '_:NOT:_' it will fail if the rule matches.
Example:
sip_out:
- [
'^SIP/2.0 100 Trying',
'Content-Length: 0'
]
- [
'^SIP/2.0 403 Unauthorized IP detected',
'Content-Length: 0',
'P-NGCP-Authorization: testuser1003@',
'P-NGCP-Authorized: 1'
]
[0] https://docs.python.org/3/library/re.html#regular-expression-syntax
- retrans:
boolean value indicating if this test is meant for a retransmission.
It's optional, default is false
Cdr test file syntax (cdr_test.yml.tt2):
----------------------------------------
The test file contains only one part:
- cdr:
Dictionary of cdr fields that should be contained in the exported CDR. The
value will be treated as a regular expression rule[0]. If the value
starts with '_:NOT:_' it will fail if the rule matches.
Example:
cdr:
- call_id: '[email protected]'
source_domain: 'spce.test'
destination_user: '*55*1420'
call_type: 'call'
call_status: 'ok'
call_code: 200
- destination_user: 'testuser1004'
destination_user_in: 'testuser1004'
duration: 0
call_type: '_:NOT:_call'
call_status: 'other'
call_code: '403'
[0] https://docs.python.org/3/library/re.html#regular-expression-syntax
scenario.yml file syntax:
-------------------------
This file is divided in two sections: subscribers and scenarios. In subscribers
we put the info and alias numbers. In scenarios we put the info needed to run the
sipp scenarios.
The check.sh script will start all the responders in the background in order and then
any sipp_scenarioXX.xml one by one.
If the responder has register: yes a sipp_scenario_responderXX_reg.xml will be created
and run it before the correspondent responder.
If active: no then no sipp_scenario_responderXX.xml exists for that responder. It's just
info of the callee.
If foreign: yes then sipp_scenario_responderXX.xml will be run with 5060 port.
If password_wrong: yes then the caller is going to use 'wrongpass' as password.
If devid: 1 (it must be an alias_number of the subscriber) then that value will be
used as username part of SIP and for auth
If defined, we can set kamailio's modules level debug as desired.
Example:
test_uuid: lock_ported
kamailio:
lb:
debugger:
- name: sl
level: 3
proxy:
debugger:
- name: dialog
level: 3
domains:
'spce.test':
reseller_id: 1
customers:
'customer.test':
contacts:
- email: "[email protected]"
reseller_id: 1
details:
status: 'active'
type: 'sipaccount'
billing_profile_id: 1
reseller_id: 1
subscribers:
spce.test:
testuser1003:
customer: 'customer.test'
password: testuser
cc: 43
ac: 1
sn: 1003
testuser1002:
customer: 'customer.test'
password: testuser
cc: 43
ac: 1
sn: 1002
alias_numbers:
- cc: 34
ac: 96
sn: 5712045
is_devid: 1
devid_alias: 899898989898
testuser1001:
customer: 'customer.test'
password: testuser
cc: 43
ac: 1
sn: 1001
testuser1004:
customer: 'customer.test'
password: testuser
cc: 43
ac: 1
sn: 1004
scenarios:
- ip: 127.126.0.1 --> sipp_scenario00.xml
username: testuser1002
domain: spce.test
proto: tcp
responders:
- ip: 127.1.0.1 --> sipp_scenario_responder00.xml
username: testuser1003
domain: spce.test
register: yes
proto: udp
- ip: 127.1.0.1 --> sipp_scenario01.xml
username: testuser1003
domain: spce.test
proto: udp
password_wrong: yes
responders:
- ip: 127.126.0.1 --> sipp_scenario_responder01.xml
username: testuser1002
domain: spce.test
register: yes
proto: tcp
- ip: 127.126.0.2 --> sipp_scenario_responder02.xml
devid: 34965712045
username: testuser1002
domain: spce.test
register: yes
proto: tcp
- ip: 127.0.2.1 --> sipp_scenario_responder03.xml
number: 004321001
username: 004321001
domain: spce.test
peer_host: peer_00_host0
register: no
peer.yml file syntax:
---------------------
Peer group definition:
peer_00:
contact:
company: peer_00
email: [email protected]
contract:
billing_profile_id: 1
status: active
type: sippeering
groups:
- name: peer_00_group
priority: 1
description:
rules:
- group_id: peer_00_group
callee_prefix: ""
callee_pattern: ''
caller_pattern: '^sip:[email protected]'
description: ""
inboundrules:
- group_id: peer_00_group
field: "ruri_uri"
pattern: '.*'
priority: 50
enabled: 1
hosts:
- group_id: peer_00_group
name: peer_00_host0
ip: 127.0.2.1
port: 50602
host:
transport: 1
weight: 1
callforward.yml file syntax:
---------------------
destinations:
destinations:
- destination: sip:[email protected]
priority: 0
timeout: 2
- destination: sip:[email protected]
priority: 1
timeout: 2
name: dest1001
mappings:
cfu:
- bnumberset: null
destinationset: dest1001
sourceset: null
timeset: null
cfb: []
cfna: []
cft: []
cfs: []
cfr: []
destinations:
destinations:
- destination: sip:[email protected]
priority: 0
timeout: 2
- destination: sip:[email protected]
priority: 1
timeout: 2
name: dest1004
mappings:
cfu: []
cfb:
- bnumberset: null
destinationset: dest1004
sourceset: null
timeset: null
cfna: []
cft: []
cfs: []
cfr: []
trusted.yml file syntax:
---------------------
from_pattern: 1002
protocol: UDP
src_ip: 127.126.0.1
registration.yml file syntax:
-----------------------------
This is used for permanent registrations, lb has two extra sockets defined:
$yaml->{kamailio}{lb}{extra_sockets}->{test} = "udp:127.2.0.1:5064";
$yaml->{kamailio}{lb}{extra_sockets}->{other} = "udp:127.3.0.1:5074";
socket has to be one of those two, and path has to have socket param with
the same value
- nat: false
contact: sip:127.3.0.5:8008
socket: sip:127.3.0.1:5074
path: <sip:[email protected]:5060;lr;socket=sip:127.3.0.1:5074>
q: 0.5
expires: 1977-07-26 23:47:37
locmap.yml file syntax:
-----------------------------
Kamailio proxy uses location mappings to act as a forking proxy
when a subscriber gets a call.
Kamailio proxy will cause Sems to generate new calls for each
registration related to the "location" endpoint.
SubscriberLocationMapping API will be consumed.
- caller_pattern: .+
callee_pattern: .+
enabled: 1
location: sip:[email protected]
mode: add
emergency.yml file syntax:
-----------------------------
emc_test:
reseller_id: 1
mappings:
- suffix: emc
code: 112
prefix: kaka
prefs.json file syntax:
----------------------
{
"@spce.test": { --> domain prefs
"allow_out_foreign_domain": true
},
"[email protected]": { --> subscriber prefs
"allowed_clis": [
"43110029*",
"43110021*"
],
"user_cli": 43122122,
"inbound_upn": "from_display",
"extension_in_npn": true
},
"peer_00_host0": { --> peer prefs
"rewrite_rule_set": "rw_00",
"concurrent_max": 1
}
}
Preferences must match REST definition [1]
[1] https://localhost:1443/api/
--
Victor Seva <[email protected]>