浏览代码

units/tmtree0001: unit test for mtree module

Daniel-Constantin Mierla 7 年之前
父节点
当前提交
a6f6640d21
共有 3 个文件被更改,包括 83 次插入0 次删除
  1. 8 0
      units/tmtree0001/README.md
  2. 36 0
      units/tmtree0001/kamailio-tmtree0001.cfg
  3. 39 0
      units/tmtree0001/tmtree0001.sh

+ 8 - 0
units/tmtree0001/README.md

@@ -0,0 +1,8 @@
+# MTree - Basic Tests #
+
+Summary: mtree - basic tests
+
+Following tests are done:
+
+  * run kamailio with `kamailio-tmtree0001.cfg` and do tests about loading,
+  reloading and matching

+ 36 - 0
units/tmtree0001/kamailio-tmtree0001.cfg

@@ -0,0 +1,36 @@
+#!KAMAILIO
+
+children=2
+
+#!define DBURL "mysql://kamailio:kamailiorw@localhost/kamailio"
+
+#!ifdef WITH_MULTIDOMAIN
+#!define MULTIDOMAIN 1
+#!else
+#!define MULTIDOMAIN 0
+#!endif
+
+loadmodule "db_mysql.so"
+loadmodule "jsonrpcs.so"
+loadmodule "kex.so"
+loadmodule "corex.so"
+loadmodule "tm.so"
+loadmodule "tmx.so"
+loadmodule "sl.so"
+loadmodule "pv.so"
+loadmodule "xlog.so"
+loadmodule "mtree.so"
+
+modparam("mtree", "db_url", DBURL)
+modparam("mtree", "mtree", "name=mtree;dbtable=mtree;type=0")
+modparam("mtree", "char_list", "0123456789*+")
+modparam("mtree", "pv_value", "$var(mtval)")
+
+request_route {
+
+	mt_match("mtree", "$rU", "0");
+
+	xlog("===== tprefix $rU tvalue $var(mtval)\n");
+	sl_send_reply("200", "OK");
+	exit;
+}

+ 39 - 0
units/tmtree0001/tmtree0001.sh

@@ -0,0 +1,39 @@
+#!/bin/bash
+
+. ../../etc/config
+. ../../libs/utils
+
+echo "--- run: ${KAMCTL} mtree add mtree 1234567890 alice"
+${KAMCTL} mtree add mtree 1234567890 alice
+echo "--- run: ${KAMCTL} mtree add mtree 2345678901 bob"
+${KAMCTL} mtree add mtree 2345678901 bob
+${KAMCTL} mtree show mtree
+${KAMCTL} mtree dump mtree
+echo "--- start kamailio -f ./kamailio-tmtree0001.cfg"
+${KAMBIN} -P ${KAMPID} -w ${KAMRUN} -Y ${KAMRUN} -f ./kamailio-tmtree0001.cfg -a no -ddd -E 2>&1 | tee /tmp/kamailio-tmtree0001.log &
+ret=$?
+sleep 1
+sipsak -s sip:[email protected]
+sleep 1
+echo "--- run: ${KAMCTL} mtree add mtree 3456789012 carol"
+${KAMCTL} mtree add mtree 3456789012 carol
+echo "--- run: ${KAMCTL} mtree show mtree"
+${KAMCTL} mtree show mtree
+echo "--- run: ${KAMCTL} mtree dump mtree"
+${KAMCTL} mtree dump mtree
+echo "--- run: ${KAMCTL} mtree reload mtree"
+${KAMCTL} mtree reload mtree
+echo "--- run: ${KAMCTL} mtree dump mtree"
+${KAMCTL} mtree dump mtree
+sleep 1
+kill_pidfile ${KAMPID}
+sleep 1
+echo
+echo "--- grep output"
+echo
+grep "tprefix 1234567890 tvalue alice" /tmp/kamailio-tmtree0001.log
+ret=$?
+if [ ! "$ret" -eq 0 ] ; then
+    exit 1
+fi
+exit 0