Selaa lähdekoodia

- add tests for fetch_result functionality used from usrloc for mysql and
postgres database
- modify existing test 11 to make configuration usable for the new ones


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

Henning Westerholt 17 vuotta sitten
vanhempi
commit
bc45c8a71d
5 muutettua tiedostoa jossa 135 lisäystä ja 1 poistoa
  1. 0 1
      test/unit/11.cfg
  2. 6 0
      test/unit/11.sh
  3. 55 0
      test/unit/31.sh
  4. 20 0
      test/unit/32.cfg
  5. 54 0
      test/unit/32.sh

+ 0 - 1
test/unit/11.cfg

@@ -7,7 +7,6 @@ disable_tcp=yes
 
 # ------------------ module loading ----------------------------------
 mpath="../modules/"
-loadmodule "db_mysql/db_mysql.so"
 loadmodule "sl/sl.so"
 loadmodule "tm/tm.so"
 loadmodule "rr/rr.so"

+ 6 - 0
test/unit/11.sh

@@ -31,6 +31,10 @@ if [ ! $ret -eq 0 ] ; then
 	exit 0
 fi ;
 
+cp $CFG $CFG.bak
+
+echo "loadmodule \"db_mysql/db_mysql.so\"" >> $CFG
+
 ../openser -w . -f $CFG > /dev/null
 ret=$?
 
@@ -70,4 +74,6 @@ cd ../test
 
 killall -9 openser
 
+mv $CFG.bak $CFG
+
 exit $ret

+ 55 - 0
test/unit/31.sh

@@ -0,0 +1,55 @@
+#!/bin/bash
+# database access with fetch_result for usrloc on mysql
+
+# Copyright (C) 2008 1&1 Internet AG
+#
+# This file is part of openser, a free SIP server.
+#
+# openser is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version
+#
+# openser is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+
+CFG=11.cfg
+
+# Needs a default openser database setup for mysql
+
+if [ ! -e ../modules/db_mysql/db_mysql.so ] ; then
+	echo "mysql driver not found, not run"
+	exit 0
+fi ;
+
+DOMAIN="local"
+MYSQL="mysql openser -u openser --password=openserrw -e"
+
+cp $CFG $CFG.bak
+
+echo "loadmodule \"db_mysql/db_mysql.so\"" >> $CFG
+echo "modparam(\"usrloc\", \"fetch_rows\", 13)" >> $CFG
+
+COUNTER=0
+while [  $COUNTER -lt 139 ]; do
+	COUNTER=$(($COUNTER+1))
+	$MYSQL "insert into location (username, domain, contact, user_agent) values ('foobar-$COUNTER', '$DOMAIN', 'foobar-$COUNTER@$DOMAIN', '___test___');"
+done
+
+../openser -w . -f $CFG > /dev/null
+ret=$?
+
+sleep 1
+killall -9 openser
+
+$MYSQL "delete from location where user_agent = '___test___'"
+
+mv $CFG.bak $CFG
+
+exit $ret

+ 20 - 0
test/unit/32.cfg

@@ -0,0 +1,20 @@
+debug=4
+fork=yes
+log_stderror=no
+children=1
+disable_tcp=yes
+
+mpath="../modules/"
+
+loadmodule "db_postgres.so"
+loadmodule "sl.so"
+loadmodule "tm.so"
+
+loadmodule "usrloc.so"
+modparam("usrloc", "db_mode", 1)
+modparam("usrloc", "fetch_rows", 13)
+modparam("usrloc", "db_url", "postgres://openser:openserrw@localhost/openser")
+
+loadmodule "registrar.so"
+
+route{ lookup("location"); }

+ 54 - 0
test/unit/32.sh

@@ -0,0 +1,54 @@
+#!/bin/bash
+# database access with fetch_result for usrloc on postgres
+
+# Copyright (C) 2008 1&1 Internet AG
+#
+# This file is part of openser, a free SIP server.
+#
+# openser is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version
+#
+# openser is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+
+CFG=11.cfg
+
+# Needs a default openser database setup for mysql
+
+if [ ! -e ../modules/db_postgres/db_postgres.so ] ; then
+	echo "postgres driver not found, not run"
+	exit 0
+fi ;
+
+cp $CFG $CFG.bak
+
+echo "loadmodule \"db_postgres/db_postgres.so\"" >> $CFG
+echo "modparam(\"usrloc\", \"db_url\", \"postgres://openser:openserrw@localhost/openser\")" >> $CFG
+
+DOMAIN="local"
+
+COUNTER=0
+while [  $COUNTER -lt 139 ]; do
+	COUNTER=$(($COUNTER+1))
+	PGPASSWORD='openserrw' psql -A -t -n -q -h localhost -U openser openser -c "insert into location (username, domain, contact, user_agent) values ('foobar-$COUNTER', '$DOMAIN', 'foobar-$COUNTER@$DOMAIN', '___test___');"
+done
+
+../openser -w . -f $CFG > /dev/null
+ret=$?
+
+sleep 1
+killall -9 openser
+
+PGPASSWORD='openserrw' psql -A -t -n -q -h localhost -U openser openser -c "delete from location where user_agent = '___test___'"
+
+mv $CFG.bak $CFG
+
+exit $ret