Skip to Content.
Sympa Menu

perfsonar-dev - [pS-dev] [GEANT/SA2/ps-java-services] r5795 - in trunk/perfsonar-java-sshtelnet-mp/src/test: . package-testing

Subject: perfsonar development work

List archive

[pS-dev] [GEANT/SA2/ps-java-services] r5795 - in trunk/perfsonar-java-sshtelnet-mp/src/test: . package-testing


Chronological Thread 
  • From:
  • To:
  • Subject: [pS-dev] [GEANT/SA2/ps-java-services] r5795 - in trunk/perfsonar-java-sshtelnet-mp/src/test: . package-testing
  • Date: Mon, 22 Nov 2010 15:52:22 GMT

Author: psnc.pietrzak
Date: 2010-11-22 15:52:21 +0000 (Mon, 22 Nov 2010)
New Revision: 5795

Added:
trunk/perfsonar-java-sshtelnet-mp/src/test/package-testing/
trunk/perfsonar-java-sshtelnet-mp/src/test/package-testing/asserts
trunk/perfsonar-java-sshtelnet-mp/src/test/package-testing/config
trunk/perfsonar-java-sshtelnet-mp/src/test/package-testing/rpm_asserts
trunk/perfsonar-java-sshtelnet-mp/src/test/package-testing/rpm_header
trunk/perfsonar-java-sshtelnet-mp/src/test/package-testing/rpm_operations

trunk/perfsonar-java-sshtelnet-mp/src/test/package-testing/service_operations
trunk/perfsonar-java-sshtelnet-mp/src/test/package-testing/setup_teardown
trunk/perfsonar-java-sshtelnet-mp/src/test/package-testing/test_install.sh
trunk/perfsonar-java-sshtelnet-mp/src/test/package-testing/test_upgrade.sh
Log:
Package testing scripts.

Added: trunk/perfsonar-java-sshtelnet-mp/src/test/package-testing/asserts
===================================================================
--- trunk/perfsonar-java-sshtelnet-mp/src/test/package-testing/asserts
(rev 0)
+++ trunk/perfsonar-java-sshtelnet-mp/src/test/package-testing/asserts
2010-11-22 15:52:21 UTC (rev 5795)
@@ -0,0 +1,60 @@
+function assertNotExists {
+ if [ -e $1 ]; then
+ echo "Assertion failed: $1 exists"
+ exit 1
+ fi;
+}
+
+function assertExists {
+ if [ ! -e $1 ]; then
+ echo "Assertion failed: $1 does not exist"
+ exit 1
+ fi;
+}
+
+function assertEmpty {
+ if [ ! `cat $1 | wc -c` -eq 0 ]; then
+ echo $2
+ exit 1
+ fi
+}
+
+function assertServiceInstalled {
+ assertExists /usr/lib/perfsonar/services/$1
+ assertExists /var/log/$1
+ assertExists /etc/$1
+ assertExists /var/lib/tomcat5/webapps/$1
+ waitUntilTomcatRestarted
+ sleep 2
+ assertSelfTest
+}
+function assertServiceNotInstalled {
+ assertNotExists /usr/lib/perfsonar/services/$1
+ assertNotExists /var/lib/tomcat5/webapps/$1
+ assertExists /var/log/$1
+ assertExists /etc/$1
+}
+
+function assertRedirectorInstalled {
+ assertExists /var/lib/tomcat5/webapps/$1
+ assertExists /usr/lib/perfsonar/services/$1
+}
+function assertRedirectorNotInstalled {
+ assertNotExists /var/lib/tomcat5/webapps/$1
+ assertNotExists /usr/lib/perfsonar/services/$1
+}
+
+function assertSelfTest {
+ count=`wget -O - http://localhost:$TOMCAT_PORT/$SERVICE_NAME/selfTest |
grep "TEST SUCCESS" | wc -c`
+
+ if [ ! $count -gt 0 ]; then
+ echo "Assertion failed: Self Test failed."
+ exit 1
+ fi
+}
+
+function waitUntilTomcatRestarted {
+ while [ -n "`/sbin/service tomcat5 status | grep 'not running'`" ]; do
+ sleep 1
+ done
+}

Added: trunk/perfsonar-java-sshtelnet-mp/src/test/package-testing/config
===================================================================
--- trunk/perfsonar-java-sshtelnet-mp/src/test/package-testing/config
(rev 0)
+++ trunk/perfsonar-java-sshtelnet-mp/src/test/package-testing/config
2010-11-22 15:52:21 UTC (rev 5795)
@@ -0,0 +1,10 @@
+TOMCAT_PORT=8080
+TOMCAT_EXIST=tomcat5-exist
+EXIST=exist
+EXIST_VERSION="1.2.6-2"
+SERVICE_NAME=perfsonar-java-sshtelnet-mp
+OLD_SERVICE_NAME=ps-mdm-sshtelnet-mp
+SERVICE_VERSION=1.4-3rc2
+
+RPM_PATH=/home/centos/rpmbuild/RPMS/noarch
+. rpm_header
\ No newline at end of file

Added: trunk/perfsonar-java-sshtelnet-mp/src/test/package-testing/rpm_asserts
===================================================================
--- trunk/perfsonar-java-sshtelnet-mp/src/test/package-testing/rpm_asserts
(rev 0)
+++ trunk/perfsonar-java-sshtelnet-mp/src/test/package-testing/rpm_asserts
2010-11-22 15:52:21 UTC (rev 5795)
@@ -0,0 +1,13 @@
+function assertPackageNotInstalled {
+ if [ -z "`rpm -q $1 | grep 'not installed'`" ]; then
+ echo "Assertion failed: package $1 is already installed."
+ exit 1
+ fi
+}
+
+function assertPackageInstalled {
+ if [ -n "`rpm -q $1 | grep 'not installed'`" ]; then
+ echo "Assertion failed: package $1 is not installed."
+ exit 1
+ fi
+}

Added: trunk/perfsonar-java-sshtelnet-mp/src/test/package-testing/rpm_header
===================================================================
--- trunk/perfsonar-java-sshtelnet-mp/src/test/package-testing/rpm_header
(rev 0)
+++ trunk/perfsonar-java-sshtelnet-mp/src/test/package-testing/rpm_header
2010-11-22 15:52:21 UTC (rev 5795)
@@ -0,0 +1,2 @@
+. rpm_asserts
+. rpm_operations
\ No newline at end of file

Added:
trunk/perfsonar-java-sshtelnet-mp/src/test/package-testing/rpm_operations
===================================================================
--- trunk/perfsonar-java-sshtelnet-mp/src/test/package-testing/rpm_operations
(rev 0)
+++ trunk/perfsonar-java-sshtelnet-mp/src/test/package-testing/rpm_operations
2010-11-22 15:52:21 UTC (rev 5795)
@@ -0,0 +1,47 @@
+function install {
+ option=$1
+ shift
+
+ ARGS=
+ PKG_NAMES=
+ while [ $# -gt 0 ]; do
+ if [ -z "$ARGS" ]; then
+ ARGS="$RPM_PATH/$1-$2.noarch.rpm"
+ else
+ ARGS="$RPM_PATH/$1-$2.noarch.rpm $ARGS"
+ fi
+
+ if [ -z "$PKG_NAMES" ]; then
+ PKG_NAMES="$1"
+ else
+ PKG_NAMES="$1 $PKG_NAMES"
+ fi
+ shift 2
+ done
+
+ set $ARGS
+ rpm -$option $@ 2> install.log
+ assertEmpty install.log "`echo 'Installation failed. Reason: ' | cat -
install.log`"
+ rm install.log
+
+ for pkg in $PKG_NAMES; do
+ assertPackageInstalled $pkg
+ echo "$pkg installed correctly."
+ done
+}
+
+function installPackage {
+ install ivh $@
+}
+
+function removePackage {
+ rpm -e $1 2> remove.log
+ assertEmpty remove.log "`echo 'Removal failed. Reason: ' | cat -
remove.log`"
+ rm remove.log
+ assertPackageNotInstalled $1
+ echo "$1 removed correctly."
+}
+
+function upgradePackages {
+ install Uvh $@
+}

Added:
trunk/perfsonar-java-sshtelnet-mp/src/test/package-testing/service_operations
===================================================================
---
trunk/perfsonar-java-sshtelnet-mp/src/test/package-testing/service_operations
(rev 0)
+++
trunk/perfsonar-java-sshtelnet-mp/src/test/package-testing/service_operations
2010-11-22 15:52:21 UTC (rev 5795)
@@ -0,0 +1,8 @@
+function installService {
+ installPackage $1 $2
+ assertServiceInstalled $1
+}
+function removeService {
+ removePackage $1
+ assertServiceNotInstalled $1
+}

Added:
trunk/perfsonar-java-sshtelnet-mp/src/test/package-testing/setup_teardown
===================================================================
--- trunk/perfsonar-java-sshtelnet-mp/src/test/package-testing/setup_teardown
(rev 0)
+++ trunk/perfsonar-java-sshtelnet-mp/src/test/package-testing/setup_teardown
2010-11-22 15:52:21 UTC (rev 5795)
@@ -0,0 +1,12 @@
+function setUp {
+ assertPackageNotInstalled $TOMCAT_EXIST
+ assertPackageNotInstalled $OLD_SERVICE_NAME
+ assertPackageNotInstalled $SERVICE_NAME
+ assertPackageNotInstalled $EXIST
+}
+
+function tearDown {
+ removeService $SERVICE_NAME
+ assertRedirectorNotInstalled $OLD_SERVICE_NAME
+ removePackage $EXIST
+}

Added:
trunk/perfsonar-java-sshtelnet-mp/src/test/package-testing/test_install.sh
===================================================================
---
trunk/perfsonar-java-sshtelnet-mp/src/test/package-testing/test_install.sh
(rev 0)
+++
trunk/perfsonar-java-sshtelnet-mp/src/test/package-testing/test_install.sh
2010-11-22 15:52:21 UTC (rev 5795)
@@ -0,0 +1,14 @@
+. asserts
+. service_operations
+. setup_teardown
+. config
+
+echo "Running $SERVICE_NAME package installation and removal test case..."
+setUp
+
+installPackage $EXIST $EXIST_VERSION
+installService $SERVICE_NAME $SERVICE_VERSION
+assertRedirectorInstalled $OLD_SERVICE_NAME
+
+tearDown
+echo "PASSED!"

Added:
trunk/perfsonar-java-sshtelnet-mp/src/test/package-testing/test_upgrade.sh
===================================================================
---
trunk/perfsonar-java-sshtelnet-mp/src/test/package-testing/test_upgrade.sh
(rev 0)
+++
trunk/perfsonar-java-sshtelnet-mp/src/test/package-testing/test_upgrade.sh
2010-11-22 15:52:21 UTC (rev 5795)
@@ -0,0 +1,17 @@
+. asserts
+. service_operations
+. setup_teardown
+. config
+
+echo "Running $SERVICE_NAME upgrade and remove test case..."
+setUp
+
+installPackage $TOMCAT_EXIST "1.2.3-1"
+installService $SERVICE_NAME "1.4-2"
+#installPackage $OLD_SERVICE_NAME "1.3.4.2-1" $SERVICE_NAME "1.4-2"
+upgradePackages $EXIST $EXIST_VERSION $SERVICE_NAME $SERVICE_VERSION
+assertServiceInstalled $SERVICE_NAME
+assertRedirectorInstalled $OLD_SERVICE_NAME
+
+tearDown
+echo "PASSED"
\ No newline at end of file



  • [pS-dev] [GEANT/SA2/ps-java-services] r5795 - in trunk/perfsonar-java-sshtelnet-mp/src/test: . package-testing, svn-noreply, 11/22/2010

Archive powered by MHonArc 2.6.16.

Top of Page