Преглед изворни кода

test/unit: updates to units 27, 28, 29, 31 ane 33

- parametrizied 11.cfg
Daniel-Constantin Mierla пре 11 година
родитељ
комит
4d898e9391
10 измењених фајлова са 79 додато и 87 уклоњено
  1. 10 1
      test/unit/11.cfg
  2. 0 4
      test/unit/11.sh
  3. 10 10
      test/unit/27.sh
  4. 11 11
      test/unit/28.cfg
  5. 12 10
      test/unit/28.sh
  6. 9 9
      test/unit/29.sh
  7. 4 11
      test/unit/31.sh
  8. 2 2
      test/unit/33.cfg
  9. 13 11
      test/unit/33.sh
  10. 8 18
      test/unit/presence.cfg

+ 10 - 1
test/unit/11.cfg

@@ -9,7 +9,10 @@ alias=localhost
 
 # ------------------ module loading ----------------------------------
 loadpath "../../modules/"
-loadmodule "db_mysql"
+
+#!trydef DBMOD	"db_mysql"
+loadmodule DBMOD
+
 loadmodule "tm"
 loadmodule "sl"
 loadmodule "rr"
@@ -27,6 +30,12 @@ loadmodule "registrar"
 modparam("registrar", "min_expires", 5)
 modparam("usrloc", "timer_interval", 1)
 
+#!trydef FETCHROWS	2000
+modparam("usrloc", "fetch_rows", FETCHROWS)
+
+#!trydef DBURL "mysql://kamailio:kamailiorw@localhost/kamailio"
+modparam("usrloc", "db_url", DBURL)
+
 #-------------------------  request routing logic -------------------
 request_route {
 

+ 0 - 4
test/unit/11.sh

@@ -31,8 +31,6 @@ fi ;
 
 SIPDOMAIN=127.0.0.1
 
-cp $CFG $CFG.bak
-
 $BIN -w . -f $CFG -a no > /dev/null
 ret=$?
 
@@ -182,6 +180,4 @@ $MYSQL "delete from location where username like '49721123456789%';"
 
 $KILL
 
-mv $CFG.bak $CFG
-
 exit $ret

+ 10 - 10
test/unit/27.sh

@@ -1,7 +1,7 @@
 #!/bin/bash
 # test publish and subscribe for presence
 
-# Copyright (C) 2008 Voice System
+# Copyright (C) 2007 1&1 Internet AG
 #
 # This file is part of Kamailio, a free SIP server.
 #
@@ -31,24 +31,24 @@ fi ;
 
 CFG=presence.cfg
 
-../$BIN -w . -f $CFG &> /dev/null;
+$BIN -w . -f $CFG -a no >/dev/null
 ret=$?
 sleep 1
 
 if [ "$ret" -eq 0 ] ; then
-    sipp -sf publish_scenario.xml -i 127.0.0.1 -p 5061 -inf publish.csv 127.0.0.1:5059 -recv_timeout 500000 -m 1 &> /dev/null;
+    sipp -sf publish_scenario.xml -i 127.0.0.1 -p 5061 -inf publish.csv 127.0.0.1:5059 -recv_timeout 500000 -m 1 >/dev/null 2>&1 &
     ret=$?
-fi;
-
+fi
 
 if [ "$ret" -eq 0 ] ; then
-    sipp -sf subscribe_notify_scenario.xml -i 127.0.0.1 -p 5061 -inf subscribe_notify.csv 127.0.0.1:5059 -recv_timeout 500000 -m 1 &> /dev/null;
+    sipp -sf subscribe_notify_scenario.xml -i 127.0.0.1 -p 5061 -inf subscribe_notify.csv 127.0.0.1:5059 -recv_timeout 500000 -m 1 >/dev/null 2>&1 &
     ret=$?
-fi;
+fi
 
+sleep 1
 
 #cleanup:
-$KILL &> /dev/null;
-killall -9 sipp &> /dev/null;
+$KILL >/dev/null
+killall -9 sipp >/dev/null 2>&1
 
-exit $ret;
+exit $ret

+ 11 - 11
test/unit/28.cfg

@@ -1,6 +1,6 @@
 debug=3
 
-loadpath "../../modules_k/:../../modules/"
+loadpath "../../modules/"
 loadmodule "sl.so"
 loadmodule "tm/tm.so"
 loadmodule "db_mysql/db_mysql.so"
@@ -9,15 +9,15 @@ loadmodule "mi_fifo/mi_fifo.so"
 loadmodule "textops/textops.so"
 
 modparam("mi_fifo", "fifo_name", "/tmp/kamailio_fifo")
-modparam("cpl-c","cpl_dtd_file","../../modules_k/cpl-c/cpl-06.dtd")
+modparam("cpl-c", "cpl_dtd_file", "../../modules/cpl-c/cpl-06.dtd")
 
-route {
-  if (is_method("INVITE")) {
-        # run incoming script
-         if ( !cpl_run_script("incoming","force_stateful") ) {
-             # script execution failed
-             sl_send_reply("500","CPL script execution failed");
-             exit;
-         };
-  };
+request_route {
+	if (is_method("INVITE")) {
+		# run incoming script
+		if ( !cpl_run_script("incoming", "force_stateful") ) {
+			# script execution failed
+			sl_send_reply("500","CPL script execution failed");
+			exit;
+		}
+	}
 }

+ 12 - 10
test/unit/28.sh

@@ -32,38 +32,40 @@ CPL=cpl_ignore.xml
 TMPFILE=`mktemp -t kamailio-test.XXXXXXXXXX`
 
 
-$BIN -w . -f $CFG &> /dev/null;
+$BIN -w . -f $CFG -a no >/dev/null
 ret=$?
 sleep 1
 
-$CTL fifo LOAD_CPL sip:[email protected] $CPL
+$CTL mi LOAD_CPL sip:[email protected] $CPL
 
 if [ "$ret" -eq 0 ] ; then
-	sipp -m 1 -f 1 127.0.0.1:5060 -sf cpl_test.xml &> /dev/null;
+	sipp -m 1 -f 1 127.0.0.1:5060 -sf cpl_test.xml >/dev/null 2>&1 &
 	ret=$?
-fi;
+fi
 
 if [ "$ret" -eq 0 ] ; then
   $CTL fifo GET_CPL sip:[email protected] > $TMPFILE 
   diff $TMPFILE $CPL 
   ret=$?
-fi; 
+fi 
 
 if [ "$ret" -eq 0 ] ; then
   $CTL fifo REMOVE_CPL sip:[email protected]
   $CTL fifo GET_CPL sip:[email protected] > $TMPFILE
-fi;
+fi
 
-diff $TMPFILE $CPL &> /dev/null;
+diff $TMPFILE $CPL >/dev/null
 ret=$?
 
 if [ ! "$ret" -eq 0 ] ; then
   ret=0
 fi;
 
+sleep 1
+
 #cleanup:
-$KILL &> /dev/null;
-killall -9 sipp &> /dev/null;
+$KILL >/dev/null
+killall -9 sipp >/dev/null 2>&1
 rm $TMPFILE
 
-exit $ret;
+exit $ret

+ 9 - 9
test/unit/29.sh

@@ -35,29 +35,29 @@ echo "loadmodule \"../../modules/db_postgres/db_postgres.so\"" >> $CFG
 echo "modparam(\"cpl-c\", \"db_url\", \"postgres://kamailio:kamailiorw@localhost/kamailio\")" >> $CFG
 
 
-$BIN -w . -f $CFG &> /dev/null;
+$BIN -w . -f $CFG >/dev/null
 ret=$?
 sleep 1
 
 $CTL fifo LOAD_CPL sip:[email protected] $CPL
 
 if [ "$ret" -eq 0 ] ; then
-	sipp -m 1 -f 1 127.0.0.1:5060 -sf cpl_test.xml &> /dev/null;
+	sipp -m 1 -f 1 127.0.0.1:5060 -sf cpl_test.xml >/dev/null 2>&1 &
 	ret=$?
-fi;
+fi
 
 if [ "$ret" -eq 0 ] ; then
   $CTL fifo GET_CPL sip:[email protected] > $TMPFILE 
   diff $TMPFILE $CPL 
   ret=$?
-fi; 
+fi 
 
 if [ "$ret" -eq 0 ] ; then
   $CTL fifo REMOVE_CPL sip:[email protected]
   $CTL fifo GET_CPL sip:[email protected] > $TMPFILE
-fi;
+fi
 
-diff $TMPFILE $CPL &> /dev/null;
+diff $TMPFILE $CPL >/dev/null
 ret=$?
 
 if [ ! "$ret" -eq 0 ] ; then
@@ -65,9 +65,9 @@ if [ ! "$ret" -eq 0 ] ; then
 fi;
 
 #cleanup:
-$KILL &> /dev/null;
-killall -9 sipp &> /dev/null;
+$KILL >/dev/null
+killall -9 sipp >/dev/null 2>&1
 rm $TMPFILE
 mv $CFG.tmp $CFG
 
-exit $ret;
+exit $ret

+ 4 - 11
test/unit/31.sh

@@ -31,27 +31,20 @@ CFG=11.cfg
 
 DOMAIN="local"
 # setup 500 contacts
-NR=50
-
-cp $CFG $CFG.bak
-
-echo "loadmodule \"$SRC_DIR/modules/db_mysql/db_mysql.so\"" >> $CFG
-echo "modparam(\"usrloc\", \"fetch_rows\", 13)" >> $CFG
+NR=500
 
 COUNTER=0
 while [  $COUNTER -lt $NR ]; do
 	COUNTER=$(($COUNTER+1))
-	$MYSQL "insert into location (username, domain, contact, user_agent) values ('foobar-$RANDOM', '$DOMAIN', 'foobar-$RANDOM@$DOMAIN', '___test___'); insert into location (username, domain, contact, user_agent) values ('foobar-$RANDOM', '$DOMAIN', 'foobar-$RANDOM@$DOMAIN', '___test___'); insert into location (username, domain, contact, user_agent) values ('foobar-$RANDOM', '$DOMAIN', 'foobar-$RANDOM@$DOMAIN', '___test___'); insert into location (username, domain, contact, user_agent) values ('foobar-$RANDOM', '$DOMAIN', 'foobar-$RANDOM@$DOMAIN', '___test___'); insert into location (username, domain, contact, user_agent) values ('foobar-$RANDOM', '$DOMAIN', 'foobar-$RANDOM@$DOMAIN', '___test___'); insert into location (username, domain, contact, user_agent) values ('foobar-$RANDOM', '$DOMAIN', 'foobar-$RANDOM@$DOMAIN', '___test___'); insert into location (username, domain, contact, user_agent) values ('foobar-$RANDOM', '$DOMAIN', 'foobar-$RANDOM@$DOMAIN', '___test___'); insert into location (username, domain, contact, user_agent) values ('foobar-$RANDOM', '$DOMAIN', 'foobar-$RANDOM@$DOMAIN', '___test___'); insert into location (username, domain, contact, user_agent) values ('foobar-$RANDOM', '$DOMAIN', 'foobar-$RANDOM@$DOMAIN', '___test___'); insert into location (username, domain, contact, user_agent) values ('foobar-$RANDOM', '$DOMAIN', 'foobar-$RANDOM@$DOMAIN', '___test___');"
+	$MYSQL "insert into location (ruid, username, domain, contact, user_agent) values ('ul-ruid-$COUNTER', 'foobar-$RANDOM', '$DOMAIN', 'sip:foobar-$RANDOM@$DOMAIN', '___test___');"
 done
 
-$BIN -w . -f $CFG > /dev/null
+$BIN -w . -f $CFG -A FETCHROWS=17 -a no >/dev/null
 ret=$?
 
 sleep 1
-$KILL
+$KILL >/dev/null
 
 $MYSQL "delete from location where user_agent = '___test___'"
 
-mv $CFG.bak $CFG
-
 exit $ret

+ 2 - 2
test/unit/33.cfg

@@ -1,6 +1,6 @@
 debug=3
 memlog=2
-loadpath "../../modules_k/:../../modules/"
+loadpath "../../modules/"
 loadmodule "cfgutils.so"
 loadmodule "pv.so"
 loadmodule "xlog.so"
@@ -16,7 +16,7 @@ modparam("pv", "shvset", "pstngw=s:sip:10.10.10.10")
 modparam("pv", "varset", "init=i:1")
 modparam("pv", "varset", "gw=s:sip:11.11.11.11;transport=tcp")
 
-route{
+request_route{
 	xlog("PGK status:");
 	usleep("100");
 	pkg_status();

+ 13 - 11
test/unit/33.sh

@@ -35,41 +35,43 @@ CFG=33.cfg
 
 cp $CFG $CFG.bak
 
-$BIN -w . -f $CFG > /dev/null
+ulimit -c unlimited
+
+$BIN -w . -f $CFG -a no > /dev/null
 ret=$?
 
 sleep 1
 
 if [ $ret -eq 0 ] ; then
-	$CTL fifo check_config_hash |grep "The actual config file hash is identical to the stored one." > /dev/null
+	$CTL mi check_config_hash | grep "The actual config file hash is identical to the stored one." >/dev/null
 	ret=$?
 fi;
 
 echo " " >> $CFG
 if [ $ret -eq 0 ] ; then
-	$CTL fifo check_config_hash |grep "The actual config file hash is identical to the stored one." /dev/null
+	$CTL mi check_config_hash | grep "The actual config file hash is identical to the stored one." >/dev/null
 	ret=$?
-fi;
+fi
 
 if [ ! $ret -eq 0 ] ; then
 	# send a message
-	cat register.sip | nc -q 1 -u localhost 5060 > /dev/null
-fi;
+	cat register.sip | nc -q 1 -u 127.0.0.1 5060 > /dev/null
+fi
 
 sleep 1
-$KILL &> /dev/null
+$KILL >/dev/null 2>&1
 ret=$?
 
 if [ $ret -eq 0 ] ; then
 	ret=1
 else
 	ret=0
-fi;
+fi
 
 if [ ! -e core ] ; then
 	ret=1
-fi;
-rm core
+fi
+rm -f core
 mv $CFG.bak $CFG
 
-exit $ret
+exit $ret

+ 8 - 18
test/unit/presence.cfg

@@ -20,7 +20,7 @@ rev_dns=no
 # ------------------ module loading ----------------------------------
 
 #set module path
-mpath="../modules/"
+mpath="../../modules/"
 
 loadmodule "db_mysql/db_mysql.so"
 loadmodule "sl/sl.so"
@@ -52,18 +52,13 @@ modparam("mi_fifo", "fifo_name", "/tmp/kamailio_fifo_presence")
  
 # main routing logic
  
-route{
+request_route{
     # initial sanity checks -- messages with
     # max_forwards==0, or excessively long requests
     if (!mf_process_maxfwd_header("10")) {
         sl_send_reply("483","Too Many Hops");
         exit;
-    };
- 
-    if (msg:len >=  2048 ) {
-        sl_send_reply("513", "Message too big");
-        exit;
-    };
+    }
  
     if (!is_method("SUBSCRIBE|PUBLISH")) {
         sl_send_reply("488", "Not Acceptable Here");
@@ -71,23 +66,18 @@ route{
     }
  
     # presence handling
-    if (! t_newtran())
-    {
+    if (! t_newtran()) {
         sl_reply_error();
         exit;
-     };
+	}
  
-    if(is_method("PUBLISH"))
-    {
+    if(is_method("PUBLISH")) {
         handle_publish();
         t_release();
-    }
-    else
-    if( is_method("SUBSCRIBE"))
-    {
+    } else if( is_method("SUBSCRIBE")) {
         handle_subscribe();
         t_release();
-    };
+    }
  
     exit;
 }