From 5013728a2debc5fcb36af0dc40b8bc375df8221e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Zden=C4=9Bk=20=C5=A0ustr?= Date: Fri, 1 Apr 2011 13:15:34 +0000 Subject: [PATCH] New test for delivering notifications through messaging --- org.glite.testsuites.ctb/LB/tests/lb-common.sh | 2 + org.glite.testsuites.ctb/LB/tests/lb-run-tests.sh | 9 + .../LB/tests/lb-test-notif-msg.sh | 223 +++++++++++++++++++++ 3 files changed, 234 insertions(+) create mode 100755 org.glite.testsuites.ctb/LB/tests/lb-test-notif-msg.sh diff --git a/org.glite.testsuites.ctb/LB/tests/lb-common.sh b/org.glite.testsuites.ctb/LB/tests/lb-common.sh index 064e2fb..a8a862d 100755 --- a/org.glite.testsuites.ctb/LB/tests/lb-common.sh +++ b/org.glite.testsuites.ctb/LB/tests/lb-common.sh @@ -64,6 +64,7 @@ LB4AGUACTINFO=glite-lb-ws_lb4agu_GetActivityInfo LB4AGUACTSTATUS=glite-lb-ws_lb4agu_GetActivityStatus LBREGSANDBOX=glite-lb-register_sandbox LBHISTORY=glite-lb-state_history +LBCMSCLIENT=glite-lb-cmsclient LB_LOGD=glite-lb-logd LB_INTERLOGD=glite-lb-interlogd @@ -120,6 +121,7 @@ SYS_SCP=scp SYS_TOUCH=touch SYS_HOSTNAME=hostname SYS_RPM=rpm +SYS_WC=wc # not used at the moment DEBUG=2 diff --git a/org.glite.testsuites.ctb/LB/tests/lb-run-tests.sh b/org.glite.testsuites.ctb/LB/tests/lb-run-tests.sh index df77c0b..b9586bb 100755 --- a/org.glite.testsuites.ctb/LB/tests/lb-run-tests.sh +++ b/org.glite.testsuites.ctb/LB/tests/lb-run-tests.sh @@ -120,6 +120,8 @@ export LBTSTCOLS yum install -q -y globus-proxy-utils yum install -q -y postgresql postgresql-server +yum install -q -y activemq java-1.6.0-openjdk + /etc/init.d/postgresql start mv /var/lib/pgsql/data/pg_hba.conf /var/lib/pgsql/data/pg_hba.conf.orig cat >/var/lib/pgsql/data/pg_hba.conf <&1 | $SYS_GREP "new jobid" | ${SYS_AWK} '{ print $3 }'` + + if [ -z $jobid ]; then + test_failed + print_error "Failed to register job" + else + printf "(${jobid}) " + test_done + fi + + # Register notification: + printf "Registering notification " + + notifid=`${LBNOTIFY} new -j ${jobid} -a x-msg://topic | $SYS_GREP "notification ID" | ${SYS_AWK} '{ print $3 }'` + + if [ -z $notifid ]; then + test_failed + print_error "Failed to register notification" + else + printf "(${notifid}) " + test_done + + BROKERLINE=`grep -E "^broker" /etc/glite-lb/glite-lb-msg.conf` + + if [ $? = 0 ]; then + + BROKER=`$SYS_ECHO $BROKERLINE | $SYS_AWK '{print $3}' | $SYS_SED 's/^.*\/\///'` + + printf "connecting to broker $BROKER... " + + #Start listening for notifications + ${LBCMSCLIENT} ${BROKER} > $$_notifications.txt & + recpid=$! + test_done + + printf "Logging events resulting in DONE state... " + $LB_DONE_SH -j ${jobid} > /dev/null 2> /dev/null + test_done + + printf "Sleep for 10 seconds to give messages time to deliver... " + + sleep 3 + test_done + + kill $recpid + + printf "Checking number of messages delivered... " + + NOofMESSAGES=`$SYS_GREP -E "Message #[0-9]* Received" $$_notifications.txt | $SYS_WC -l` + + printf "$NOofMESSAGES. Checking if >= 10... " + + cresult=`$SYS_EXPR ${NOofMESSAGES} \>= 10` + + if [ "$cresult" -eq "1" ]; then + printf "OK" + test_done + else + test_failed + print_error "Fewer messages than expected" + fi + + $SYS_RM $$_notifications.txt + else + printf "Cannot determine broker address" + test_skipped + fi + + + + #Drop notification + printf "Dropping the test notification (${notifid})" + dropresult=`${LBNOTIFY} drop ${notifid} 2>&1` + if [ -z $dropresult ]; then + test_done + else + test_failed + print_error "Failed to drop notification ${dropresult}" + fi + + #Purge test job + joblist=$$_jobs_to_purge.txt + echo $jobid > ${joblist} + try_purge ${joblist} + + fi + fi +fi + +test_end +#} &> $logfile +} + +if [ $flag -ne 1 ]; then + cat $logfile + $SYS_RM $logfile +fi +exit $TEST_OK + -- 1.8.2.3