diff --git a/bin/pid_watcher.py b/bin/pid_watcher.py index ccbd1a97..b1736138 100755 --- a/bin/pid_watcher.py +++ b/bin/pid_watcher.py @@ -23,6 +23,7 @@ import os import os.path import pyinotify import sys +import argparse BASE_DIR = "/usr/share/kamailio-config-tests" if 'BASE_DIR' in os.environ: @@ -87,6 +88,23 @@ class Handler(pyinotify.ProcessEvent): # if watched.has_key(event.pathname): # print event +parser = argparse.ArgumentParser( + description='watch some pids to detect restarts') +parser.add_argument('--pbx', dest='pbx', action='store_true', + help='pbx is enabled') + +args = parser.parse_args() + +if args.pbx: + watched_dirs += [ + '/var/run/sems-pbx', + '/var/run/fastcgi', + ] + services += [ + 'sems-pbx/sems-pbx.pid', + 'fastcgi/ngcp-panel.pid', + ] + logging.info("PID watcher started") wm = pyinotify.WatchManager() handler = Handler(watched=watched) diff --git a/debian/control b/debian/control index 92870911..c286432c 100644 --- a/debian/control +++ b/debian/control @@ -2,25 +2,27 @@ Source: kamailio-config-tests Section: Development Priority: extra Maintainer: Sipwise Development Team -Build-Depends: debhelper (>= 8.0.0) +Build-Depends: + debhelper (>= 8.0.0), Standards-Version: 3.9.7 Homepage: http://www.sipwise.com/ Package: kamailio-config-tests Architecture: all -Depends: curl, - libgraphviz-perl, - libjson-perl, - libtemplate-perl, - libtext-csv-perl, - libyaml-perl, - ngcp-provisioning-tools, - parallel, - python, - python-pyinotify, - python-yaml, - sip-tester ( >= 1:3.3-1~ ), - tcpdump, - ${misc:Depends} +Depends: + curl, + libgraphviz-perl, + libjson-perl, + libtemplate-perl, + libtext-csv-perl, + libyaml-perl, + ngcp-provisioning-tools, + parallel, + python, + python-pyinotify, + python-yaml, + sip-tester ( >= 1:3.3-1~ ), + tcpdump, + ${misc:Depends}, Description: Kamailio configuration tests scripts and tests scenarios to check Kamailio configuration diff --git a/debian/install b/debian/install index 2a88ae08..f57295ab 100644 --- a/debian/install +++ b/debian/install @@ -5,3 +5,4 @@ lib/ /usr/share/kamailio-config-tests/ run_tests.sh /usr/share/kamailio-config-tests/ scenarios/ /usr/share/kamailio-config-tests/ scenarios_lnp /usr/share/kamailio-config-tests/ +scenarios_pbx /usr/share/kamailio-config-tests/ diff --git a/run_tests.sh b/run_tests.sh index 0536c042..fcc34411 100755 --- a/run_tests.sh +++ b/run_tests.sh @@ -89,6 +89,18 @@ if [ "${PROFILE}" != "CE" ] && [ "${PROFILE}" != "PRO" ]; then exit 2 fi +if [ "$GROUP" = "scenarios_pbx" ] ; then + TIMEOUT=120 + PIDWATCH_OPTS="--pbx" + # hack for pid_watcher ( sems-pbx was not active ) + mkdir -p /var/run/sems-pbx/ + touch /var/run/sems-pbx/sems-pbx.pid + chown -R sems-pbx:sems-pbx /var/run/sems-pbx/ +else + TIMEOUT=60 + PIDWATCH_OPTS="" +fi + echo "$(date) - Clean mem log dir" rm -rf "${MLOG_DIR}" mkdir -p "${MLOG_DIR}" "${LOG_DIR}" @@ -97,7 +109,8 @@ if [ -z $SKIP ]; then echo "$(date) - Setting config debug on" "${BIN_DIR}/config_debug.pl" -g "${GROUP}" on ${DOMAIN} if [ "${PROFILE}" == "PRO" ]; then - ( timeout 60 "${BIN_DIR}/pid_watcher.py" )& + echo "$(date) - Exec pid_watcher" + ( timeout ${TIMEOUT} "${BIN_DIR}/pid_watcher.py" ${PIDWATCH_OPTS} )& fi if ! ngcpcfg apply "config debug on via kamailio-config-tests" ; then echo "$(date) - ngcp apply returned $?" @@ -106,6 +119,7 @@ if [ -z $SKIP ]; then exit 3 fi if [ "${PROFILE}" == "PRO" ]; then + echo "$(date) - waiting for pid_watcher[$!] result" if ! wait "$!" ; then echo "error on apply config" cfg_debug_off diff --git a/scenarios_pbx/config.yml b/scenarios_pbx/config.yml new file mode 100644 index 00000000..7d6cb0ed --- /dev/null +++ b/scenarios_pbx/config.yml @@ -0,0 +1,7 @@ +kamailio: + proxy: + allow_refer_method: 'yes' + presence: + enable: 'yes' +pbx: + enable: 'yes' diff --git a/scenarios_pbx/invite/0003_test.yml.tt2 b/scenarios_pbx/invite/0003_test.yml.tt2 new file mode 100644 index 00000000..73109de7 --- /dev/null +++ b/scenarios_pbx/invite/0003_test.yml.tt2 @@ -0,0 +1,35 @@ +flow: + - start|DEFAULT_ROUTE: + - start|ROUTE_NET_INFO: + - return|ROUTE_NET_INFO: + - start|ROUTE_PRX_REQUEST: + - start|ROUTE_INITVARS: + - return|ROUTE_INITVARS: + - start|ROUTE_INVITE: + - start|ROUTE_LOAD_CALLEE_DOMAIN_PREF: + - start|ROUTE_CLEAR_CALLEE_DOMAIN_PREF: + - return|ROUTE_CLEAR_CALLEE_DOMAIN_PREF: + - return|ROUTE_LOAD_CALLEE_DOMAIN_PREF: + - start|ROUTE_FIND_CALLER: + - start|ROUTE_AUTH: + - exit|ROUTE_AUTH: +sip_in: + - '^INVITE' + - 'Contact: sip:testuser1002@' + - 'To: + + + + ;tag=[pid]SIPpTag00[call_number] + To: + Call-ID: NGCP%[field4 file="callee.csv" line=0]%///[call_id] + CSeq: 1 INVITE + Contact: sip:[field0 file="caller.csv"]@[local_ip]:[local_port] + Max-Forwards: 70 + Content-Type: application/sdp + Content-Length: [len] + + v=0 + o=user1 53655765 2353687637 IN IP[local_ip_type] [local_ip] + s=- + c=IN IP[media_ip_type] [media_ip] + t=0 0 + m=audio [media_port] RTP/AVP 8 + a=rtpmap:8 PCMA/8000 + a=ptime:50 + + ]]> + + + + + + + + + ;tag=[pid]SIPpTag00[call_number] + To: [peer_tag_param] + Call-ID: NGCP%[field4 file="callee.csv" line=0]%///[call_id] + CSeq: 1 ACK + Contact: sip:[field0 file="caller.csv"]@[local_ip]:[local_port] + Max-Forwards: 70 + Content-Length: 0 + + ]]> + + + + + + ;tag=[pid]SIPpTag00[call_number] + To: + Call-ID: NGCP%[field4 file="callee.csv" line=0]%///[call_id] + CSeq: 2 INVITE + Contact: sip:[field0 file="caller.csv"]@[local_ip]:[local_port] + Max-Forwards: 70 + [field1 file="caller.csv"] + Content-Type: application/sdp + Content-Length: [len] + + v=0 + o=user1 53655765 2353687637 IN IP[local_ip_type] [local_ip] + s=- + c=IN IP[media_ip_type] [media_ip] + t=0 0 + m=audio [media_port] RTP/AVP 8 + a=rtpmap:8 PCMA/8000 + a=ptime:50 + + ]]> + + + + + + + + + + + + + + + + ;tag=[pid]SIPpTag00[call_number] + To: [peer_tag_param] + Call-ID: NGCP%[field4 file="callee.csv" line=0]%///[call_id] + [routes] + CSeq: 2 ACK + Contact: sip:[field0 file="caller.csv"]@[local_ip]:[local_port] + Max-Forwards: 70 + Content-Length: 0 + + ]]> + + + + + + + + + + + + + ;tag=[pid]SIPpTag00[call_number] + To: [peer_tag_param] + Call-ID: NGCP%[field4 file="callee.csv" line=0]%///[call_id] + CSeq: 3 BYE + Contact: sip:[field0 file="caller.csv"]@[local_ip]:[local_port] + [routes] + Max-Forwards: 70 + Content-Length: 0 + + ]]> + + + + + + + + + + + + + + diff --git a/scenarios_pbx/invite/sipp_scenario_responder00.xml b/scenarios_pbx/invite/sipp_scenario_responder00.xml new file mode 100644 index 00000000..da77f415 --- /dev/null +++ b/scenarios_pbx/invite/sipp_scenario_responder00.xml @@ -0,0 +1,78 @@ + + + + + + + + + + Content-Length: 0 + + ]]> + + + + + + + Content-Type: application/sdp + Content-Length: [len] + + v=0 + o=user1 53655765 2353687637 IN IP[local_ip_type] [local_ip] + s=- + c=IN IP[media_ip_type] [media_ip] + t=0 0 + m=audio [media_port] RTP/AVP 8 + a=rtpmap:8 PCMA/8000 + a=ptime:50 + + ]]> + + + + + + + + + + + Content-Length: [len] + + ]]> + + + + + + + diff --git a/scenarios_pbx/media181sec.pcap b/scenarios_pbx/media181sec.pcap new file mode 120000 index 00000000..f37af728 --- /dev/null +++ b/scenarios_pbx/media181sec.pcap @@ -0,0 +1 @@ +../scenarios/media181sec.pcap \ No newline at end of file diff --git a/scenarios_pbx/templates b/scenarios_pbx/templates new file mode 120000 index 00000000..870f0f2e --- /dev/null +++ b/scenarios_pbx/templates @@ -0,0 +1 @@ +../scenarios/templates/ \ No newline at end of file diff --git a/tests/test_check.py b/tests/test_check.py index 8c885def..29870ffc 100755 --- a/tests/test_check.py +++ b/tests/test_check.py @@ -31,6 +31,7 @@ from check import load_json, load_yaml not_ok = re.compile('^not ok.*', re.MULTILINE) + class TestXAvp(unittest.TestCase): def setUp(self): @@ -93,7 +94,7 @@ class TestCheckFlowVars(unittest.TestCase): {'R1': {'$xavp(v0)': [{'k0': [1, 2]}]}}, ] self.check_ko = [ - {'R0': {'$xavp(v0)': [{'k0': ['a', 'b']}] }}, + {'R0': {'$xavp(v0)': [{'k0': ['a', 'b']}]}}, ] self.scen_ko = [ {'R0': {'$xavp(v0[0]=>k0[*])': ['a']}},