Przeglądaj źródła

tasync0001: unit test for async processing

- test cfg variables in async route
Daniel-Constantin Mierla 7 lat temu
rodzic
commit
98bf53f90b

+ 8 - 0
units/tasync0001/README.md

@@ -0,0 +1,8 @@
+# Async Routing - Cfg Variables Tests #
+
+Summary: async routing - cfg variables tests
+
+Following tests are done:
+
+  * run kamailio with kamailio-tasync0001.cfg and test if variables are set
+  in the request and async routes

+ 3 - 0
units/tasync0001/kamailio-tasync0001-inc.cfg

@@ -0,0 +1,3 @@
+#!KAMAILIO
+
+info.var_inc = 1 desc "Var from included file"

+ 48 - 0
units/tasync0001/kamailio-tasync0001.cfg

@@ -0,0 +1,48 @@
+#!KAMAILIO
+
+children=2
+async_workers=1
+
+include_file "kamailio-tasync0001-inc.cfg"
+
+loadmodule "kex.so"
+loadmodule "jsonrpcs.so"
+loadmodule "tm.so"
+loadmodule "tmx.so"
+loadmodule "sl.so"
+loadmodule "rr.so"
+loadmodule "pv.so"
+loadmodule "async.so"
+loadmodule "xlog.so"
+
+modparam("jsonrpcs", "pretty_format", 1)
+
+info.var_loc = 1 desc "Info Variable"
+
+request_route {
+    if(@cfg_get.info.var_loc == 1) {
+        xlog("request_route: var_loc is 1\n");
+    }
+    if(@cfg_get.info.var_inc == 1) {
+        xlog("request_route: var_inc is 1\n");
+    }
+
+    if(t_newtran()) {
+        async_task_route("ASYNC_REQUEST_ROUTE");
+    }
+    exit;
+}
+
+route[ASYNC_REQUEST_ROUTE] {
+    if(@cfg_get.info.var_loc == 1) {
+        xlog("async_route: var_loc is 1\n");
+    } else {
+        $var(tmp) = @cfg_get.info.var_loc;
+        xlog("async_route: var tmp is $var(tmp)\n");
+    }
+    if(@cfg_get.info.var_inc == 1) {
+        xlog("async_route: var_inc is 1\n");
+    }
+
+    t_reply("200", "OK");
+}

+ 34 - 0
units/tasync0001/tasync0001.sh

@@ -0,0 +1,34 @@
+#!/bin/bash
+
+. ../../etc/config
+. ../../libs/utils
+
+echo "--- start kamailio -f ./kamailio-tasync0001.cfg"
+${KAMBIN} -P ${KAMPID} -w ${KAMRUN} -Y ${KAMRUN} -f ./kamailio-tasync0001.cfg -a no -ddd -E 2>&1 | tee /tmp/kamailio-tasync0001.log
+ret=$?
+sleep 1
+kill_pidfile ${KAMPID}
+echo
+echo "--- grep output"
+echo
+grep "request_route: var_loc is 1" /tmp/kamailio-tasync0001.log
+ret=$?
+if [ ! "$ret" -eq 0 ] ; then
+    exit 1
+fi
+grep "request_route: var_inc is 1" /tmp/kamailio-tasync0001.log
+ret=$?
+if [ ! "$ret" -eq 0 ] ; then
+    exit 1
+fi
+grep "async_route: var_loc is 1" /tmp/kamailio-tasync0001.log
+ret=$?
+if [ ! "$ret" -eq 0 ] ; then
+    exit 1
+fi
+grep "async_route: var_inc is 1" /tmp/kamailio-tasync0001.log
+ret=$?
+if [ ! "$ret" -eq 0 ] ; then
+    exit 1
+fi
+exit 0