You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
470 lines
12 KiB
470 lines
12 KiB
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:testuser1003@127.126.0.1: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: 'abcdefg@1.1.1.1'
|
|
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: "customer.test@spce.test"
|
|
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: peer_00@host0.not
|
|
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:.+@spce.test'
|
|
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:
|
|
---------------------
|
|
|
|
testuser1001@spce.test:
|
|
destinations:
|
|
destinations:
|
|
- destination: sip:4311003@spce.test
|
|
priority: 0
|
|
timeout: 2
|
|
- destination: sip:testuser1003@spce.test
|
|
priority: 1
|
|
timeout: 2
|
|
name: dest1001
|
|
mappings:
|
|
cfu:
|
|
- bnumberset: null
|
|
destinationset: dest1001
|
|
sourceset: null
|
|
timeset: null
|
|
cfb: []
|
|
cfna: []
|
|
cft: []
|
|
cfs: []
|
|
cfr: []
|
|
testuser1004@spce.test:
|
|
destinations:
|
|
destinations:
|
|
- destination: sip:4311005@spce.test
|
|
priority: 0
|
|
timeout: 2
|
|
- destination: sip:testuser1005@spce.test
|
|
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:
|
|
---------------------
|
|
|
|
testuser1002@spce.test:
|
|
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
|
|
|
|
testuser1003@spce.test:
|
|
- nat: false
|
|
contact: sip:127.3.0.5:8008
|
|
socket: sip:127.3.0.1:5074
|
|
path: <sip:lb@127.0.0.1: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.
|
|
|
|
testuser1003@spce.test:
|
|
- caller_pattern: .+
|
|
callee_pattern: .+
|
|
enabled: 1
|
|
location: sip:testuser1004@spce.test
|
|
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
|
|
},
|
|
"testuser1002@spce.test": { --> 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 <vseva@sipwise.com>
|