Author: aconway
Date: Tue Jan  9 08:55:27 2007
New Revision: 494483

URL: http://svn.apache.org/viewvc?view=rev&rev=494483
Log:
Automated C++ client_test and topictest.
Andrew Stitcher: patch to change hardcoded 8-0 version numbers to 0-9.

Added:
    incubator/qpid/branches/qpid.0-9/cpp/tests/kill_broker   (with props)
    incubator/qpid/branches/qpid.0-9/cpp/tests/python_tests
      - copied, changed from r494415, 
incubator/qpid/branches/qpid.0-9/cpp/tests/run-system-tests
    incubator/qpid/branches/qpid.0-9/cpp/tests/quick_topictest   (with props)
    incubator/qpid/branches/qpid.0-9/cpp/tests/start_broker   (with props)
Removed:
    incubator/qpid/branches/qpid.0-9/cpp/tests/run-system-tests
Modified:
    incubator/qpid/branches/qpid.0-9/cpp/tests/   (props changed)
    incubator/qpid/branches/qpid.0-9/cpp/tests/Makefile.am
    incubator/qpid/branches/qpid.0-9/cpp/tests/client_test.cpp
    incubator/qpid/branches/qpid.0-9/cpp/tests/topic_listener.cpp
    incubator/qpid/branches/qpid.0-9/cpp/tests/topic_publisher.cpp
    incubator/qpid/branches/qpid.0-9/cpp/tests/topictest

Propchange: incubator/qpid/branches/qpid.0-9/cpp/tests/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Tue Jan  9 08:55:27 2007
@@ -8,3 +8,4 @@
 topic_listener
 topic_publisher
 qpidd.log
+qpidd.pid

Modified: incubator/qpid/branches/qpid.0-9/cpp/tests/Makefile.am
URL: 
http://svn.apache.org/viewvc/incubator/qpid/branches/qpid.0-9/cpp/tests/Makefile.am?view=diff&rev=494483&r1=494482&r2=494483
==============================================================================
--- incubator/qpid/branches/qpid.0-9/cpp/tests/Makefile.am (original)
+++ incubator/qpid/branches/qpid.0-9/cpp/tests/Makefile.am Tue Jan  9 08:55:27 
2007
@@ -61,8 +61,9 @@
 
 noinst_PROGRAMS = $(client_exe_tests)
 
-TESTS = run-unit-tests run-system-tests
-EXTRA_DIST += $(TESTS)
+CLIENT_TESTS = client_test quick_topictest
+TESTS = run-unit-tests start_broker $(CLIENT_TESTS) python_tests kill_broker
+EXTRA_DIST += $(TESTS) topictest
 
 include gen.mk
 

Modified: incubator/qpid/branches/qpid.0-9/cpp/tests/client_test.cpp
URL: 
http://svn.apache.org/viewvc/incubator/qpid/branches/qpid.0-9/cpp/tests/client_test.cpp?view=diff&rev=494483&r1=494482&r2=494483
==============================================================================
--- incubator/qpid/branches/qpid.0-9/cpp/tests/client_test.cpp (original)
+++ incubator/qpid/branches/qpid.0-9/cpp/tests/client_test.cpp Tue Jan  9 
08:55:27 2007
@@ -40,6 +40,8 @@
 using namespace qpid::sys;
 using std::string;
 
+bool verbose = false;
+
 /**
  * A simple message listener implementation that prints out the
  * message content then notifies a montitor allowing the test to
@@ -52,13 +54,15 @@
     inline SimpleListener(Monitor* _monitor) : monitor(_monitor){}
 
     inline virtual void received(Message& msg){
-       std::cout << "Received message " << msg.getData()  << std::endl;
+        if (verbose)
+            std::cout << "Received message " << msg.getData()  << std::endl;
        monitor->notify();
     }
 };
 
 int main(int argc, char**)
 {
+    verbose = argc > 1;
     try{               
         //Use a custom exchange
        Exchange exchange("MyExchange", Exchange::TOPIC_EXCHANGE);
@@ -69,25 +73,25 @@
        Connection con(argc > 1);
        string host("localhost");       
        con.open(host);
-       std::cout << "Opened connection." << std::endl;
+       if (verbose) std::cout << "Opened connection." << std::endl;
 
         //Create and open a channel on the connection through which
         //most functionality is exposed
        Channel channel;      
        con.openChannel(&channel);
-       std::cout << "Opened channel." << std::endl;    
+       if (verbose) std::cout << "Opened channel." << std::endl;       
 
         //'declare' the exchange and the queue, which will create them
         //as they don't exist
        channel.declareExchange(exchange);
-       std::cout << "Declared exchange." << std::endl;
+       if (verbose) std::cout << "Declared exchange." << std::endl;
        channel.declareQueue(queue);
-       std::cout << "Declared queue." << std::endl;
+       if (verbose) std::cout << "Declared queue." << std::endl;
 
         //now bind the queue to the exchange
        qpid::framing::FieldTable args;
        channel.bind(exchange, queue, "MyTopic", args);
-       std::cout << "Bound queue to exchange." << std::endl;
+       if (verbose) std::cout << "Bound queue to exchange." << std::endl;
 
        //Set up a message listener to receive any messages that
        //arrive in our queue on the broker. We only expect one, and
@@ -98,7 +102,7 @@
        SimpleListener listener(&monitor);
        string tag("MyTag");
        channel.consume(queue, tag, &listener);
-       std::cout << "Registered consumer." << std::endl;
+       if (verbose) std::cout << "Registered consumer." << std::endl;
 
         //we need to enable the message dispatching for this channel
         //and we want that to occur on another thread so we call
@@ -111,7 +115,7 @@
        string data("MyMessage");
        msg.setData(data);
        channel.publish(msg, exchange, "MyTopic");
-       std::cout << "Published message: " << data << std::endl;
+       if (verbose) std::cout << "Published message: " << data << std::endl;
 
        {
             Monitor::ScopedLock l(monitor);
@@ -122,13 +126,15 @@
         
         //close the channel & connection
        con.closeChannel(&channel);
-       std::cout << "Closed channel." << std::endl;
+       if (verbose) std::cout << "Closed channel." << std::endl;
        con.close();    
-       std::cout << "Closed connection." << std::endl;
+       if (verbose) std::cout << "Closed connection." << std::endl;
     }catch(qpid::QpidError error){
-       std::cout << "Error [" << error.code << "] " << error.msg << " ("
-                  << error.location.file << ":" << error.location.line
-                  << ")" << std::endl;
+       if (verbose) std::cout
+            << "Error [" << error.code << "] "
+            << error.msg << " ("
+            << error.location.file << ":" << error.location.line
+            << ")" << std::endl;
        return 1;
     }
     return 0;

Added: incubator/qpid/branches/qpid.0-9/cpp/tests/kill_broker
URL: 
http://svn.apache.org/viewvc/incubator/qpid/branches/qpid.0-9/cpp/tests/kill_broker?view=auto&rev=494483
==============================================================================
--- incubator/qpid/branches/qpid.0-9/cpp/tests/kill_broker (added)
+++ incubator/qpid/branches/qpid.0-9/cpp/tests/kill_broker Tue Jan  9 08:55:27 
2007
@@ -0,0 +1,3 @@
+#!/bin/sh
+PID=qpid.pid
+if [ -f $PID ] ; then kill -9 `cat $PID` ; rm -f $PID ; fi

Propchange: incubator/qpid/branches/qpid.0-9/cpp/tests/kill_broker
------------------------------------------------------------------------------
    svn:executable = *

Copied: incubator/qpid/branches/qpid.0-9/cpp/tests/python_tests (from r494415, 
incubator/qpid/branches/qpid.0-9/cpp/tests/run-system-tests)
URL: 
http://svn.apache.org/viewvc/incubator/qpid/branches/qpid.0-9/cpp/tests/python_tests?view=diff&rev=494483&p1=incubator/qpid/branches/qpid.0-9/cpp/tests/run-system-tests&r1=494415&p2=incubator/qpid/branches/qpid.0-9/cpp/tests/python_tests&r2=494483
==============================================================================
--- incubator/qpid/branches/qpid.0-9/cpp/tests/run-system-tests (original)
+++ incubator/qpid/branches/qpid.0-9/cpp/tests/python_tests Tue Jan  9 08:55:27 
2007
@@ -1,42 +1,12 @@
 #!/bin/sh
-
-set -e
-log=`pwd`/qpidd.log
-# Start the daemon, recording its PID.
-../src/qpidd > $log 2>&1 & pid=$!
-
-# Arrange to kill the daemon upon any type of termination.
-trap 'status=$?; kill $pid; rm -f test.out; exit $status' 0
-trap '(exit $?); exit $?' 1 2 13 15
-
-# Run C++ client tests.
-run_test() {
-    test="$*"
-    echo -n "Running: $test ... "
-    if $test >test.out 2>&1 ; then
-       echo " Passed" ;
-    else
-       echo " FAILED. Output:";
-       cat test.out
-       FAILED=yes
-    fi
-    rm -f test.out
-}
-
-run_test ./client_test
-run_test `dirname $0`/topictest -s2 -m2 -b1
-
-# FIXME aconway 2007-01-08: Re-enable python tests when the brach
-# is functional again.
-echo "WARNING: PYTHON TESTS DISABLED TILL BRANCH IS FUNCTIONAL"
+# FIXME aconway 2007-01-09: Re-enable.
+echo "*** WARNING: PYTHON TESTS DISABLED till branch is functioning on 0-9."
+exit
 
 # Run the python tests.
-# if test -d ../../python ;  then
-#     cd ../../python && ./run-tests -v -I cpp_failing.txt
-# else
-#     echo Warning: python tests not found.
-# fi
-
-# TODO aconway 2006-12-13: run the other client tests.
+if test -d ../../python ;  then
+    cd ../../python && ./run-tests -v -I cpp_failing.txt
+else
+    echo Warning: python tests not found.
+fi
 
-rm -f $log

Added: incubator/qpid/branches/qpid.0-9/cpp/tests/quick_topictest
URL: 
http://svn.apache.org/viewvc/incubator/qpid/branches/qpid.0-9/cpp/tests/quick_topictest?view=auto&rev=494483
==============================================================================
--- incubator/qpid/branches/qpid.0-9/cpp/tests/quick_topictest (added)
+++ incubator/qpid/branches/qpid.0-9/cpp/tests/quick_topictest Tue Jan  9 
08:55:27 2007
@@ -0,0 +1,7 @@
+#!/bin/sh
+# Quick and quiet topic test for make check.
+./topictest -s2 -m2 -b1 > topictest.log 2>&1 || {
+    echo See topictest.log.
+    exit 1
+}
+

Propchange: incubator/qpid/branches/qpid.0-9/cpp/tests/quick_topictest
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/qpid/branches/qpid.0-9/cpp/tests/start_broker
URL: 
http://svn.apache.org/viewvc/incubator/qpid/branches/qpid.0-9/cpp/tests/start_broker?view=auto&rev=494483
==============================================================================
--- incubator/qpid/branches/qpid.0-9/cpp/tests/start_broker (added)
+++ incubator/qpid/branches/qpid.0-9/cpp/tests/start_broker Tue Jan  9 08:55:27 
2007
@@ -0,0 +1,10 @@
+#!/bin/sh
+set -e
+
+LOG=`pwd`/qpidd.log
+PID=`pwd`/qpidd.pid
+
+rm -rf $LOG $PID
+
+# Start the daemon, recording its PID.
+../src/qpidd > $LOG 2>&1 & echo $! > $PID

Propchange: incubator/qpid/branches/qpid.0-9/cpp/tests/start_broker
------------------------------------------------------------------------------
    svn:executable = *

Modified: incubator/qpid/branches/qpid.0-9/cpp/tests/topic_listener.cpp
URL: 
http://svn.apache.org/viewvc/incubator/qpid/branches/qpid.0-9/cpp/tests/topic_listener.cpp?view=diff&rev=494483&r1=494482&r2=494483
==============================================================================
--- incubator/qpid/branches/qpid.0-9/cpp/tests/topic_listener.cpp (original)
+++ incubator/qpid/branches/qpid.0-9/cpp/tests/topic_listener.cpp Tue Jan  9 
08:55:27 2007
@@ -121,10 +121,12 @@
             channel.consume(control, tag, &listener, args.getAckMode());
             channel.run();
             connection.close();
+            return 0;
         }catch(qpid::QpidError error){
             std::cout << error.what() << std::endl;
         }
     }
+    return 1;
 }
 
 Listener::Listener(Channel* _channel, const std::string& _responseq, bool tx) 
: 

Modified: incubator/qpid/branches/qpid.0-9/cpp/tests/topic_publisher.cpp
URL: 
http://svn.apache.org/viewvc/incubator/qpid/branches/qpid.0-9/cpp/tests/topic_publisher.cpp?view=diff&rev=494483&r1=494482&r2=494483
==============================================================================
--- incubator/qpid/branches/qpid.0-9/cpp/tests/topic_publisher.cpp (original)
+++ incubator/qpid/branches/qpid.0-9/cpp/tests/topic_publisher.cpp Tue Jan  9 
08:55:27 2007
@@ -110,12 +110,12 @@
     inline bool getHelp() const { return help; }
 };
 
-int main(int argc, char** argv){
+int main(int argc, char** argv) {
     Args args;
     args.parse(argc, argv);
     if(args.getHelp()){
         args.usage();
-    }else{
+    } else {
         try{
             Connection connection(args.getTrace());
             connection.open(args.getHost(), args.getPort());
@@ -156,10 +156,12 @@
             }
             channel.close();
             connection.close();
-        }catch(qpid::QpidError error){
+            return 0;
+        }catch(qpid::QpidError error) {
             std::cout << error.what() << std::endl;
         }
     }
+    return 1;
 }
 
 Publisher::Publisher(Channel* _channel, const std::string& _controlTopic, bool 
tx) : 

Modified: incubator/qpid/branches/qpid.0-9/cpp/tests/topictest
URL: 
http://svn.apache.org/viewvc/incubator/qpid/branches/qpid.0-9/cpp/tests/topictest?view=diff&rev=494483&r1=494482&r2=494483
==============================================================================
--- incubator/qpid/branches/qpid.0-9/cpp/tests/topictest (original)
+++ incubator/qpid/branches/qpid.0-9/cpp/tests/topictest Tue Jan  9 08:55:27 
2007
@@ -1,7 +1,10 @@
 #!/bin/bash
 # Run the C++ topic test
 
-# Defaults
+# Clean up old log files
+rm -f subscriber_*.log 
+
+# Defaults values 
 SUBSCRIBERS=10
 MESSAGES=2000
 BATCHES=10
@@ -19,13 +22,8 @@
 done
 
 subscribe() {
-    ID=$1
-    echo "subscriber $ID"
-    ./topic_listener > subscriber.$ID 2>&1 || {
-       echo "SUBSCRIBER %ID FAILED: " ;
-       cat subscriber.$ID
-    }
-    rm subscriber.$ID
+    LOG="subscriber_$1.log"
+    ./topic_listener > $LOG 2>&1 && rm -f $LOG 
 }
 
 publish() {
@@ -35,7 +33,5 @@
 for ((i=$SUBSCRIBERS ; i--; )); do
     subscribe $i &
 done
-sleep 1
-STATS=~/bin/topictest.times
-echo "---- topictest `date`" >> $STATS
-publish | tee -a $STATS
+
+publish 2>&1 || exit 1


Reply via email to