summaryrefslogtreecommitdiff
path: root/cpp/demo/IceStorm/replicated2/expect.py
diff options
context:
space:
mode:
authorMatthew Newhook <matthew@zeroc.com>2008-03-03 15:53:13 +0800
committerMatthew Newhook <matthew@zeroc.com>2008-03-03 15:53:13 +0800
commitd00fed41c6a7b4a363541858a19919ed0234608e (patch)
tree4933dfa8cf9f9abe19ee121c0ba7425939e5e76a /cpp/demo/IceStorm/replicated2/expect.py
parentMerge branch 'master' of ssh://git/home/git/ice (diff)
downloadice-d00fed41c6a7b4a363541858a19919ed0234608e.tar.bz2
ice-d00fed41c6a7b4a363541858a19919ed0234608e.tar.xz
ice-d00fed41c6a7b4a363541858a19919ed0234608e.zip
Fix expect scripts for HA IceStorm. Clean up READMEs.
Diffstat (limited to 'cpp/demo/IceStorm/replicated2/expect.py')
-rwxr-xr-xcpp/demo/IceStorm/replicated2/expect.py82
1 files changed, 77 insertions, 5 deletions
diff --git a/cpp/demo/IceStorm/replicated2/expect.py b/cpp/demo/IceStorm/replicated2/expect.py
index b303c340957..0e3fde75ae6 100755
--- a/cpp/demo/IceStorm/replicated2/expect.py
+++ b/cpp/demo/IceStorm/replicated2/expect.py
@@ -1,14 +1,14 @@
#!/usr/bin/env python
# **********************************************************************
#
-# Copyright (c) 2003-2007 ZeroC, Inc. All rights reserved.
+# Copyright (c) 2003-2008 ZeroC, Inc. All rights reserved.
#
# This copy of Ice is licensed to you under the terms described in the
# ICE_LICENSE file included in this distribution.
#
# **********************************************************************
-import pexpect, sys, os
+import sys, os
try:
import demoscript
@@ -16,13 +16,85 @@ except ImportError:
for toplevel in [".", "..", "../..", "../../..", "../../../.."]:
toplevel = os.path.normpath(toplevel)
if os.path.exists(os.path.join(toplevel, "demoscript")):
- break
+ break
else:
raise "can't find toplevel directory!"
sys.path.append(os.path.join(toplevel))
import demoscript
import demoscript.Util
-import demoscript.IceStorm.clock
+demoscript.Util.defaultLanguage = "C++"
+import time, signal
-demoscript.IceStorm.clock.run('./subscriber', './publisher')
+desc = 'application.xml'
+if demoscript.Util.mode == 'debug':
+ fi = open(desc, "r")
+ desc = 'tmp_application.xml'
+ fo = open(desc, "w")
+ for l in fi:
+ if l.find('exe="icebox"'):
+ l = l.replace('exe="icebox"', 'exe="iceboxd.exe"')
+ fo.write(l)
+ fi.close()
+ fo.close()
+
+print "cleaning databases...",
+sys.stdout.flush()
+demoscript.Util.cleanDbDir("db1");
+demoscript.Util.cleanDbDir("db2")
+demoscript.Util.cleanDbDir("db3")
+print "ok"
+
+if demoscript.Util.defaultHost:
+ args = ' --IceGrid.Node.PropertiesOverride="Ice.Default.Host=127.0.0.1"'
+else:
+ args = ''
+
+directory = os.path.dirname(os.path.abspath(__file__))
+demoscript.Util.addLdPath(directory)
+
+print "starting replicas...",
+sys.stdout.flush()
+ib1 = demoscript.Util.spawn('%s --Ice.Config=config.ib1 --Ice.PrintAdapterReady %s' % (demoscript.Util.getIceBox(), args))
+ib1.expect('.* ready')
+ib2 = demoscript.Util.spawn('%s --Ice.Config=config.ib2 --Ice.PrintAdapterReady %s' % (demoscript.Util.getIceBox(), args))
+ib2.expect('.* ready')
+ib3 = demoscript.Util.spawn('%s --Ice.Config=config.ib3 --Ice.PrintAdapterReady %s' % (demoscript.Util.getIceBox(), args))
+ib3.expect('.* ready')
+print "ok"
+
+ib3.expect('Election: node 2: reporting for duty in group 2:[-0-9A-F]+ as coordinator' , timeout=20)
+ib2.expect('Election: node 1: reporting for duty in group 2:[-0-9A-F]+ with coordinator 2', timeout=20)
+ib1.expect('Election: node 0: reporting for duty in group 2:[-0-9A-F]+ with coordinator 2', timeout=20)
+
+print "testing pub/sub...",
+sys.stdout.flush()
+sub = demoscript.Util.spawn('./subscriber --Ice.PrintAdapterReady')
+
+ib1.expect('Topic: time: add replica observer: [-0-9A-F]+')
+ib2.expect('Topic: time: add replica observer: [-0-9A-F]+' )
+ib3.expect('Topic: time: subscribeAndGetPublisher: [-0-9A-F]+')
+
+sub.expect('.* ready')
+
+pub = demoscript.Util.spawn('./publisher')
+
+time.sleep(3)
+sub.expect('[0-9][0-9]/[0-9][0-9].*\r{1,2}\n[0-9][0-9]/[0-9][0-9]')
+print "ok"
+
+sub.kill(signal.SIGINT)
+sub.waitTestSuccess()
+pub.kill(signal.SIGINT)
+pub.waitTestSuccess()
+
+ib1.expect('Topic: time: remove replica observer: [-0-9A-F]+')
+ib2.expect('Topic: time: remove replica observer: [-0-9A-F]+' )
+ib3.expect('Topic: time: unsubscribe: [-0-9A-F]+')
+
+admin = demoscript.Util.spawn('iceboxadmin --Ice.Config=config.ib1 shutdown')
+admin.waitTestSuccess()
+admin = demoscript.Util.spawn('iceboxadmin --Ice.Config=config.ib2 shutdown')
+admin.waitTestSuccess()
+admin = demoscript.Util.spawn('iceboxadmin --Ice.Config=config.ib3 shutdown')
+admin.waitTestSuccess()