Răsfoiți Sursa

units/tlcust0001: test unit for log_custom module

Daniel-Constantin Mierla 7 ani în urmă
părinte
comite
1254badefb

+ 8 - 0
units/tlcust0001/README.md

@@ -0,0 +1,8 @@
+# LOG_CUSTOM - Basic Tests #
+
+Summary: log_custom - basic tests
+
+Following tests are done:
+
+  * run kamailio with `kamailio-tlcust0001.cfg` and do tests with sample SIP
+  traffic

+ 56 - 0
units/tlcust0001/kamailio-tlcust0001.cfg

@@ -0,0 +1,56 @@
+#!KAMAILIO
+
+####### Global Parameters #########
+
+### LOG Levels: 3=DBG, 2=INFO, 1=NOTICE, 0=WARN, -1=ERR
+debug=2
+log_stderror=no
+
+memdbg=5
+memlog=5
+
+log_facility=LOG_LOCAL0
+log_prefix="{$mt $hdr(CSeq) $ci} "
+
+/* number of SIP routing processes */
+children=2
+
+log_engine_type="udp"
+log_engine_data="127.0.0.1:24680"
+
+####### Modules Section ########
+
+/* set paths to location of modules */
+# mpath="/usr/local/lib/kamailio/modules/"
+
+loadmodule "log_custom.so"
+loadmodule "jsonrpcs.so"
+loadmodule "kex.so"
+loadmodule "corex.so"
+loadmodule "tm.so"
+loadmodule "tmx.so"
+loadmodule "sl.so"
+loadmodule "rr.so"
+loadmodule "pv.so"
+loadmodule "maxfwd.so"
+loadmodule "textops.so"
+loadmodule "siputils.so"
+loadmodule "xlog.so"
+loadmodule "sanity.so"
+loadmodule "ctl.so"
+loadmodule "cfg_rpc.so"
+loadmodule "counters.so"
+
+
+####### Routing Logic ########
+
+
+/* Main SIP request routing logic
+ * - processing of any incoming SIP request starts with this route
+ * - note: this is the same as route { ... } */
+request_route {
+	xlog("===== xlog message - R-URI is $ru\n");
+	log_udp("===== logcustom message - R-URI is $ru\n");
+	sl_send_reply("200", "ok");
+	exit;
+}

+ 37 - 0
units/tlcust0001/tlcust0001.sh

@@ -0,0 +1,37 @@
+#!/bin/bash
+
+. ../../etc/config
+. ../../libs/utils
+
+
+echo "--- start nc -ulp 24680 | tee /tmp/kamailio-tlcust0001.netcat &"
+nc -ulp 24680 | tee /tmp/kamailio-tlcust0001.netcat &
+echo "--- start kamailio -f ./kamailio-tlcust0001.cfg"
+${KAMBIN} -P ${KAMPID} -w ${KAMRUN} -Y ${KAMRUN} -f ./kamailio-tlcust0001.cfg -a no 2>&1 | tee /tmp/kamailio-tlcust0001.log &
+ret=$?
+sleep 1
+echo "--- restart nc -ulp 24680 | tee /tmp/kamailio-tlcust0001.netcat &"
+killall nc
+nc -ulp 24680 | tee /tmp/kamailio-tlcust0001.netcat &
+echo "--- run sipsak -s sip:[email protected]"
+sipsak -vvv -s sip:[email protected]
+sleep 1
+kill_pidfile ${KAMPID}
+sleep 1
+killall nc
+sleep 1
+echo
+echo "--- grep output"
+echo
+ls -l /tmp
+echo "---"
+cat /tmp/kamailio-tlcust0001.netcat
+echo "---"
+cat /tmp/kamailio-tlcust0001.log
+echo "---"
+grep "logcustom" /tmp/kamailio-tlcust0001.netcat
+ret=$?
+if [ ! "$ret" -eq 0 ] ; then
+    exit 1
+fi
+exit 0