Explorar o código

- fix 2.cfg, 7.cfg - contact_avp is not available anymore in lcr
- add small function to test for sipsak availability
- extend mysql registrar test (11.sh), use sipsak to test for more cases
(cleanup timer in usrloc, unregistration of specific contacts, unregistration
of all contacts, contact binding update..)
- extend postgres registrar test (22.sh), use sipsak here too


git-svn-id: https://openser.svn.sourceforge.net/svnroot/openser/trunk@5137 689a6050-402a-0410-94f2-e92a70836424

Henning Westerholt %!s(int64=17) %!d(string=hai) anos
pai
achega
03f6a3d366
Modificáronse 6 ficheiros con 134 adicións e 38 borrados
  1. 2 0
      test/unit/11.cfg
  2. 100 19
      test/unit/11.sh
  3. 0 1
      test/unit/2.cfg
  4. 24 17
      test/unit/22.sh
  5. 0 1
      test/unit/7.cfg
  6. 8 0
      test/unit/include/require

+ 2 - 0
test/unit/11.cfg

@@ -21,6 +21,8 @@ modparam("usrloc", "db_mode", 1)
 
 loadmodule "registrar/registrar.so"
 modparam("registrar", "reg_callid_avp", "$avp(s:foobar)")
+modparam("registrar", "min_expires", 5)
+modparam("usrloc", "timer_interval", 2)
 
 #-------------------------  request routing logic -------------------
 route{

+ 100 - 19
test/unit/11.sh

@@ -25,7 +25,7 @@ source include/database
 
 CFG=11.cfg
 
-if ! (check_netcat && check_kamailio && check_module "db_mysql" && check_mysql); then
+if ! (check_sipsak && check_kamailio && check_module "db_mysql" && check_mysql); then
 	exit 0
 fi ;
 
@@ -38,38 +38,119 @@ ret=$?
 
 sleep 1
 
-# register a user
-cat register.sip | nc -q 1 -u localhost 5060 > /dev/null
+# register two contacts
+sipsak -U -C sip:foobar@localhost -s sip:49721123456789@localhost -H localhost &> /dev/null
+sipsak -U -C sip:foobar1@localhost -s sip:49721123456789@localhost -H localhost &> /dev/null
+ret=$?
 
 cd ../scripts
 
-if [ "$ret" -eq 0 ] ; then
-	./$CTL ul show | grep "AOR:: 1000" > /dev/null
+if [ "$ret" -eq 0 ]; then
+	./$CTL ul show | grep "AOR:: 49721123456789" &> /dev/null
 	ret=$?
-fi ;
+fi;
 
-TMP=`mysql -B -u openserro --password=openserro openser -e "select COUNT(*) from location where username="1000";" | tail -n 1`
-if [ "$TMP" -eq 0 ] ; then
-	ret=1
-fi ;
+if [ "$ret" -eq 0 ]; then
+	TMP=`$MYSQL "select COUNT(*) from location where username='49721123456789';" | tail -n 1`
+	if [ "$TMP" -eq 0 ] ; then
+		ret=1
+	fi;
+fi;
+
+if [ "$ret" -eq 0 ]; then
+	# check if the contact is registered
+	sipsak -U -C empty -s sip:[email protected] -H localhost -q "Contact: <sip:foobar@localhost>" &> /dev/null
+	ret=$?
+fi;
+
+if [ "$ret" -eq 0 ]; then
+	# update the registration
+	sipsak -U -C sip:foobar@localhost -s sip:49721123456789@localhost -H localhost &> /dev/null
+	ret=$?
+fi;
+
+if [ "$ret" -eq 0 ]; then
+	# check if we get a hint when we try to unregister a non-existent conctact
+	sipsak -U -C "sip:foobar2@localhost" -s sip:[email protected] -H localhost -x 0 -q "Contact: <sip:foobar@localhost>" &> /dev/null
+	ret=$?
+fi;
+
+if [ "$ret" -eq 0 ]; then
+	# unregister the contact
+	sipsak -U -C "sip:foobar@localhost" -s sip:[email protected] -H localhost -x 0 &> /dev/null
+	ret=$?
+fi;
+
+if [ "$ret" -eq 0 ]; then
+	# unregister the user again should not fail
+	sipsak -U -C "sip:foobar@localhost" -s sip:[email protected] -H localhost -x 0 &> /dev/null
+	ret=$?
+fi;
 
-# see if the user is registered
-cat ../test/invite.sip | nc -q 1 -u localhost 5060 > /dev/null
+if [ "$ret" -eq 0 ]; then
+	# check if the other contact is still registered
+	sipsak -U -C empty -s sip:[email protected] -H localhost -q "Contact: <sip:foobar1@localhost>" &> /dev/null
+	ret=$?
+fi;
 
-# unregister the user
-cat ../test/unregister.sip | nc -q 1 -u localhost 5060 > /dev/null
+if [ "$ret" -eq 0 ]; then
+	# register the other again
+	sipsak -U -C sip:foobar@localhost -s sip:49721123456789@localhost -H localhost &> /dev/null
+	ret=$?
+fi;
 
-if [ "$ret" -eq 0 ] ; then
-	./$CTL ul show | grep "AOR:: 1000" > /dev/null
+if [ "$ret" -eq 0 ]; then
+	# unregister all contacts
+	sipsak -U -C "*" -s sip:[email protected] -H localhost -x 0 &> /dev/null
 	ret=$?
-	if [ "$ret" -eq 0 ] ; then
+fi;
+
+if [ "$ret" -eq 0 ]; then
+	./$CTL ul show | grep "AOR:: 49721123456789" > /dev/null
+	ret=$?
+	if [ "$ret" -eq 0 ]; then
 		ret=1
 	else
 		ret=0
-	fi ;
+	fi;
 fi ;
 
-ret=`mysql -B -u openserro --password=openserro openser -e "select COUNT(*) from location where username="1000";" | tail -n 1`
+if [ "$ret" -eq 0 ]; then
+	ret=`$MYSQL "select COUNT(*) from location where username='49721123456789';" | tail -n 1`
+fi;
+
+if [ "$ret" -eq 0 ]; then
+	# test min_expires functionality
+	sipsak -U -C sip:foobar@localhost -s sip:49721123456789@localhost -H localhost -x 2 &> /dev/null
+	ret=$?
+fi;
+
+if [ "$ret" -eq 0 ]; then
+	sleep 3
+	# check if the contact is still registered
+	sipsak -U -C empty -s sip:[email protected] -H localhost -q "Contact: <sip:foobar@localhost>" &> /dev/null
+	ret=$?
+fi;
+
+if [ "$ret" -eq 0 ]; then
+	# register a few more contacts
+	sipsak -U -e 9 -s sip:49721123456789@localhost -H localhost &> /dev/null
+fi;
+
+if [ "$ret" -eq 0 ]; then
+	# let the timer cleanup the previous registrations
+	sleep 3
+	# and check
+	TMP=`$MYSQL "select COUNT(*) from location where username like '49721123456789%';" | tail -n 1`
+	if [ "$TMP" -eq 10 ] ; then
+		ret=0
+	else
+		ret=1
+	fi;
+fi;
+
+# cleanup
+$MYSQL "delete from location where username like '49721123456789%';"
 
 cd ../test
 

+ 0 - 1
test/unit/2.cfg

@@ -58,7 +58,6 @@ modparam("mi_fifo", "fifo_name", "/tmp/kamailio_fifo")
 modparam("mi_datagram", "socket_name", "/tmp/kamailio.sock")
 modparam("dialog", "dlg_flag", 10)
 modparam("dialog", "db_mode", 2)
-modparam("lcr", "contact_avp", "$avp(i:711)")
 modparam("lcr|tm", "fr_inv_timer_avp", "$avp(i:704)")
 modparam("lcr", "gw_uri_avp", "$avp(i:709)")
 modparam("lcr", "ruri_user_avp", "$avp(i:500)")

+ 24 - 17
test/unit/22.sh

@@ -23,7 +23,7 @@ source include/common
 source include/require
 source include/database
 
-if ! (check_netcat && check_kamailio && check_module "db_postgres" && check_postgres); then
+if ! (check_sipsak && check_kamailio && check_module "db_postgres" && check_postgres); then
 	exit 0
 fi ;
 
@@ -38,34 +38,41 @@ ret=$?
 
 sleep 1
 # register a user
-cat register.sip | nc -q 1 -u localhost 5060 > /dev/null
+sipsak -U -C sip:foobar@localhost -s sip:49721123456789@localhost -H localhost &> /dev/null
+ret=$?
 
 cd ../scripts
 
-if [ "$ret" -eq 0 ] ; then
-	./$CTL ul show | grep "AOR:: 1000" > /dev/null
+if [ "$ret" -eq 0 ]; then
+	./$CTL ul show | grep "AOR:: 49721123456789" > /dev/null
 	ret=$?
-fi ;
+fi;
 
-TMP=`${PSQL} "select COUNT(*) from location where username='1000';"`
-if [ "$TMP" -eq 0 ] ; then
-	ret=1
-fi ;
+if [ "$ret" -eq 0 ]; then
+	TMP=`${PSQL} "select COUNT(*) from location where username='49721123456789';"`
+	if [ "$TMP" -eq 0 ] ; then
+		ret=1
+	fi;
+fi;
 
-# unregister the user
-cat ../test/unregister.sip | nc -q 1 -u localhost 5060 > /dev/null
+if [ "$ret" -eq 0 ]; then
+	# unregister the user
+	sipsak -U -C "*" -s sip:[email protected] -H localhost -x 0 &> /dev/null
+fi;
 
-if [ "$ret" -eq 0 ] ; then
-	./$CTL ul show | grep "AOR:: 1000" > /dev/null
+if [ "$ret" -eq 0 ]; then
+	./$CTL ul show | grep "AOR:: 49721123456789" > /dev/null
 	ret=$?
-	if [ "$ret" -eq 0 ] ; then
+	if [ "$ret" -eq 0 ]; then
 		ret=1
 	else
 		ret=0
-	fi ;
-fi ;
+	fi;
+fi;
 
-ret=`$PSQL "select COUNT(*) from location where username='1000';" | tail -n 1`
+if [ "$ret" -eq 0 ]; then
+	ret=`$PSQL "select COUNT(*) from location where username='49721123456789';" | tail -n 1`
+fi;
 
 $KILL
 

+ 0 - 1
test/unit/7.cfg

@@ -286,7 +286,6 @@ modparam("lcr", "from_uri_column", "from_uri")
 modparam("lcr", "priority_column", "priority")
 modparam("lcr", "gw_uri_avp", "$avp(i:1400)")
 modparam("lcr", "ruri_user_avp", "$avp(i:1402)")
-modparam("lcr", "contact_avp", "$avp(i:1401)")
 modparam("lcr", "fr_inv_timer_avp", "$avp(s:fr_inv_timer_avp)")
 modparam("lcr", "fr_inv_timer", 90)
 modparam("lcr", "fr_inv_timer_next", 30)

+ 8 - 0
test/unit/include/require

@@ -52,3 +52,11 @@ function check_sipp() {
 	fi;
 	return 0
 }
+
+function check_sipsak() {
+	if ! ( which sipsak > /dev/null ); then
+		echo "sipsak not found, not run"
+		return -1
+	fi;
+	return 0
+}