[mapguide-commits] r8416 - trunk/MgDev

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Sat Oct 18 04:10:40 PDT 2014


Author: jng
Date: 2014-10-18 04:10:40 -0700 (Sat, 18 Oct 2014)
New Revision: 8416

Modified:
   trunk/MgDev/run_tests.sh
Log:
#2493: Add support for controlling test run behaviour via supplying arguments

Modified: trunk/MgDev/run_tests.sh
===================================================================
--- trunk/MgDev/run_tests.sh	2014-10-18 09:54:52 UTC (rev 8415)
+++ trunk/MgDev/run_tests.sh	2014-10-18 11:10:40 UTC (rev 8416)
@@ -5,22 +5,116 @@
 #
 # Simple wrapper script to execute all applicable tests on Linux
 #
-SERVER_FAST_SUBSET=1
-MG_INST=/usr/local/mapguideopensource-3.0.0
+# You can run this script after building the main MapGuide source (make && make install)
+#
+
+# If set to 1, only a subset of the MapGuide Server test suite is run. In this mode,
+# the following test suites are skipped: CoordinateSystem, ResourceService, TileService
+SERVER_FAST_SUBSET=0
+# The location where MapGuide is installed
+MG_INST=/usr/local/mapguideopensource
 PHP_CMD=$MG_INST/webserverextensions/php/bin/php
-USE_LOCAL_SERVER=1
-TEST_SERVER=1
-TEST_PHP=1
-TEST_JAVA=1
+# If set to 1, will try to use a locally-built mgserver (for the server tests) and 
+# built-in PHP web server hosted mapagent for running the PHP and Java test suites. 
+# Otherwise, it will use the installed Apache and MapGuide Server in the above 
+# installation path
+USE_LOCAL_SERVER=0
+# Set to 1 to run the server test suite
+TEST_SERVER=0
+# Set to 1 to run the PHP test suite
+TEST_PHP=0
+# Set to 1 to run the Java test suite
+TEST_JAVA=0
+# The directory where various test/status log files will be written
 LOG_PATH=~
 TEST_COMPONENT=
 MG_SERVER_PID=
 MG_SERVER_WAIT=30
 WEB_SERVER_PID=
 WEB_SERVER_ADDR=localhost
-WEB_SERVER_PORT=8018
+WEB_SERVER_PORT=8008
 WEB_SERVER_WAIT=15
 
+while [ $# -gt 0 ]; do # Until you run out of parameters...
+	case "$1" in
+		--prefix)
+			MG_INST="$2"
+			PHP_CMD=$MG_INST/webserverextensions/php/bin/php
+			shift
+			;;
+		--logpath)
+			LOG_PATH="$2"
+			shift
+			;;
+		--with-java)
+			TEST_JAVA=1
+			;;
+		--with-php)
+			TEST_PHP=1
+			;;
+		--with-server)
+			TEST_SERVER=1
+			;;
+		--with-server-fast-subset)
+			TEST_SERVER=1
+			SERVER_FAST_SUBSET=1
+			;;
+		--with-local-server)
+			USE_LOCAL_SERVER=1
+			;;
+		--local-mgserver-wait)
+			MG_SERVER_WAIT=$2
+			shift
+			;;
+		--local-webserver-wait)
+			WEB_SERVER_WAIT=$2
+			shift
+			;;
+		--local-webserver-addr)
+			WEB_SERVER_ADDR="$2"
+			shift
+			;;
+		--local-webserver-port)
+			WEB_SERVER_PORT=$2
+			shift
+			;;
+		--help)
+			echo "Usage: $0 (options)"
+			echo "Options:"
+			echo "  --prefix <value> [MapGuide install location]"
+			echo "  --logpath <value> [Directory where logs will be written]"
+			echo "  --with-java [Run Java Test Suite]"
+			echo "  --with-php [Run PHP Test Suite]"
+			echo "  --with-server [Run Server Test Suite]"
+			echo "  --with-server-fast-subset [Run fast subset of Server Test Suite]"
+			echo "  --with-local-server [Use local mgserver/PHP web server for tests]"
+			echo "  --local-mgserver-wait <value> [Wait <value> seconds for local mgserver to start. No effect if not using local server]"
+			echo "  --local-webserver-wait <value> [Wait <value> seconds for local webserver to start. No effect if not using local server]"
+			echo "  --local-webserver-addr <value> [Start PHP web server on <value>. No effect if not using local server]"
+			echo "  --local-webserver-port <value> [Start PHP web server to listen on port <value>. No effect if not using local server]"
+			echo "  --help [Display this notice]"
+			exit
+			;;
+	esac
+	shift # Check next set of parameters.
+done
+
+echo "*********************************************"
+echo "Variable Summary"
+echo "*********************************************"
+echo "MG_INST: $MG_INST"
+echo "PHP_CMD: $PHP_CMD"
+echo "SERVER_FAST_SUBSET: $SERVER_FAST_SUBSET"
+echo "USE_LOCAL_SERVER: $USE_LOCAL_SERVER"
+echo "TEST_SERVER: $TEST_SERVER"
+echo "TEST_PHP: $TEST_PHP"
+echo "TEST_JAVA: $TEST_JAVA"
+echo "LOG_PATH: $LOG_PATH"
+echo "MG_SERVER_WAIT: $MG_SERVER_WAIT"
+echo "WEB_SERVER_ADDR: $WEB_SERVER_ADDR"
+echo "WEB_SERVER_PORT: $WEB_SERVER_PORT"
+echo "WEB_SERVER_WAIT: $WEB_SERVER_WAIT"
+
 check_test()
 {
 	error=$?
@@ -34,45 +128,80 @@
 
 start_php_web_server()
 {
-	echo "[web server]: Starting (with ${WEB_SERVER_WAIT}s wait)"
-	$PHP_CMD -d upload_max_filesize=20M -S "$WEB_SERVER_ADDR:$WEB_SERVER_PORT" -t UnitTest/WebTier/MapAgent/MapAgentForms UnitTest/WebTier/Php/MapAgentShim/index.php > $LOG_PATH/php_web_server.log 2>&1 &
-	WEB_SERVER_PID=$!
-	# Give some time for the mgserver to actually fully initialize
-	sleep $WEB_SERVER_WAIT
-	echo "[web server]: Started ($WEB_SERVER_PID)"
+	if [ $USE_LOCAL_SERVER -eq 1 ]; then
+		echo "[web server]: Starting (with ${WEB_SERVER_WAIT}s wait)"
+		$PHP_CMD -d upload_max_filesize=20M -S "$WEB_SERVER_ADDR:$WEB_SERVER_PORT" -t UnitTest/WebTier/MapAgent/MapAgentForms UnitTest/WebTier/Php/MapAgentShim/index.php > $LOG_PATH/php_web_server.log 2>&1 &
+		WEB_SERVER_PID=$!
+		# Give some time for the mgserver to actually fully initialize
+		sleep $WEB_SERVER_WAIT
+		echo "[web server]: Started ($WEB_SERVER_PID)"
+	else
+		pushd $MG_INST/webserverextensions/apache2/bin > /dev/null
+			echo "[web server]: Starting Apache"
+			./apachectl restart
+			echo "[web server]: Started"
+		popd > /dev/null
+	fi
 }
 
 stop_php_web_server()
 {
-	echo "[web server]: Stopping"
-	kill $WEB_SERVER_PID
-	echo "[web server]: Stopped ($WEB_SERVER_PID)"
-	WEB_SERVER_PID=
+	if [ $USE_LOCAL_SERVER -eq 1 ]; then
+		echo "[web server]: Stopping"
+		kill $WEB_SERVER_PID
+		echo "[web server]: Stopped ($WEB_SERVER_PID)"
+		WEB_SERVER_PID=
+	else
+		pushd $MG_INST/webserverextensions/apache2/bin > /dev/null
+			echo "[web server]: Stopping Apache"
+			./apachectl stop
+			echo "[web server]: Stopped"
+		popd > /dev/null
+	fi
 }
 
 start_mapguide_server()
 {
-	pushd Server/src/Core > /dev/null
-		echo "[mgserver]: Starting (with ${MG_SERVER_WAIT}s wait)"
-		./mgserver run > $LOG_PATH/mapguide_server_run.log 2>&1 &
-		MG_SERVER_PID=$!
-		# Give some time for the mgserver to actually fully initialize
-		sleep $MG_SERVER_WAIT
-		echo "[mgserver]: Started ($MG_SERVER_PID)"
-	popd > /dev/null
+	if [ $USE_LOCAL_SERVER -eq 1 ]; then
+		pushd Server/src/Core > /dev/null
+			echo "[mgserver]: Starting (with ${MG_SERVER_WAIT}s wait)"
+			./mgserver run > $LOG_PATH/mapguide_server_run.log 2>&1 &
+			MG_SERVER_PID=$!
+			# Give some time for the mgserver to actually fully initialize
+			sleep $MG_SERVER_WAIT
+			echo "[mgserver]: Started ($MG_SERVER_PID)"
+		popd > /dev/null
+	else
+		pushd $MG_INST/server/bin > /dev/null
+			echo "[mgserver]: Starting mgserver"
+			./mgserverd.sh
+			echo "[mgserver]: Started"
+		popd
+	fi
 }
 
 stop_mapguide_server()
 {
-	echo "[mgserver]: Stopping"
-	kill $MG_SERVER_PID
-	echo "[mgserver]: Stopped ($MG_SERVER_PID)"
-	MG_SERVER_PID=
+	if [ $USE_LOCAL_SERVER -eq 1 ]; then
+		echo "[mgserver]: Stopping"
+		kill $MG_SERVER_PID
+		echo "[mgserver]: Stopped ($MG_SERVER_PID)"
+		MG_SERVER_PID=
+	else
+		echo "[mgserver]: Stopping"
+		pkill -f -u root "mgserer daemon"
+		echo "[mgserver]: Stopped"
+	fi
 }
 
 # Build server unit test suite (regardless of whether we're running
 # server tests or not)
 
+echo "[build]: Sheboygan sample data set"
+pushd UnitTest/TestData/Samples/Sheboygan > /dev/null
+./build.sh 2>&1 > $LOG_PATH/make_package.log
+popd > /dev/null
+
 echo "[build]: Server unit tests"
 pushd Server/src/UnitTesting > /dev/null
 make libMgUnitTesting.la 2>&1 > /dev/null
@@ -121,14 +250,12 @@
 		rm -rf DrawingService/DrawingServiceTest.db
 		rm -rf ResourceService/ResourceServiceTest.db
 	popd > /dev/null
-	if [ $USE_LOCAL_SERVER -eq 1 ]; then
-		start_mapguide_server
-		start_php_web_server
-	fi
+	start_mapguide_server
+	start_php_web_server
 	pushd UnitTest > /dev/null
 		TEST_COMPONENT="Prepare PHP test suite"
 		echo "[test]: $TEST_COMPONENT"
-		$PHP_CMD prepare.php
+		$PHP_CMD prepare.php 2>&1 | tee $LOG_PATH/prepare.log
 		check_test
 	popd > /dev/null
 	pushd UnitTest/WebTier/Php > /dev/null
@@ -141,10 +268,8 @@
 		$PHP_CMD RunTests.php 2>&1 | tee $LOG_PATH/php_test.log
 		check_test
 	popd > /dev/null
-	if [ $USE_LOCAL_SERVER -eq 1 ]; then
-		stop_mapguide_server
-		stop_php_web_server
-	fi
+	stop_mapguide_server
+	stop_php_web_server
 fi
 
 if [ $TEST_JAVA -eq 1 ]; then
@@ -162,18 +287,14 @@
 		rm -rf DrawingService/DrawingServiceTest.db
 		rm -rf ResourceService/ResourceServiceTest.db
 	popd > /dev/null
-	if [ $USE_LOCAL_SERVER -eq 1 ]; then
-		start_mapguide_server
-	fi
+	start_mapguide_server
 	pushd UnitTest/WebTier/Java > /dev/null
 		TEST_COMPONENT="Java Web Tier Tests"
 		echo "[test]: $TEST_COMPONENT"
 		ant checkunix -l $LOG_PATH/java_test_output.log
 		check_test
 	popd > /dev/null
-	if [ $USE_LOCAL_SERVER -eq 1 ]; then
-		stop_mapguide_server
-	fi
+	stop_mapguide_server
 fi
 
 if [ -f "$LOG_PATH/unit_test_status.log" ]; then



More information about the mapguide-commits mailing list