summaryrefslogtreecommitdiff
path: root/python/test/Ice/faultTolerance/Server.py
diff options
context:
space:
mode:
Diffstat (limited to 'python/test/Ice/faultTolerance/Server.py')
-rwxr-xr-xpython/test/Ice/faultTolerance/Server.py88
1 files changed, 37 insertions, 51 deletions
diff --git a/python/test/Ice/faultTolerance/Server.py b/python/test/Ice/faultTolerance/Server.py
index 7595f572415..3da4d0fdd4f 100755
--- a/python/test/Ice/faultTolerance/Server.py
+++ b/python/test/Ice/faultTolerance/Server.py
@@ -8,21 +8,20 @@
#
# **********************************************************************
-import os, sys, traceback
-
+import os
import Ice
-Ice.loadSlice('Test.ice')
+from TestHelper import TestHelper
+TestHelper.loadSlice("Test.ice")
import Test
-def usage(n):
- sys.stderr.write("Usage: " + n + " port\n")
class TestI(Test.TestIntf):
+
def shutdown(self, current=None):
current.adapter.getCommunicator().shutdown()
def abort(self, current=None):
- sys.stdout.write("aborting...")
+ print("aborting...")
os._exit(0)
def idempotentAbort(self, current=None):
@@ -31,48 +30,35 @@ class TestI(Test.TestIntf):
def pid(self, current=None):
return os.getpid()
-def run(args, communicator):
- port = 0
- for arg in args[1:]:
- if arg[0] == '-':
- sys.stderr.write(args[0] + ": unknown option `" + arg + "'\n")
- usage(args[0])
- return False
- if port > 0:
- sys.stderr.write(args[0] + ": only one port can be specified\n")
- usage(args[0])
- return False
-
- port = 12010 + int(arg)
-
- if port <= 0:
- sys.stderr.write(args[0] + ": no port specified\n")
- usage(args[0])
- return False
-
- endpts = "default -p " + str(port)
- communicator.getProperties().setProperty("TestAdapter.Endpoints", endpts)
- adapter = communicator.createObjectAdapter("TestAdapter")
- object = TestI()
- adapter.add(object, Ice.stringToIdentity("test"))
- adapter.activate()
- communicator.waitForShutdown()
- return True
-
-try:
- #
- # In this test, we need a longer server idle time, otherwise
- # our test servers may time out before they are used in the
- # test.
- #
- initData = Ice.InitializationData()
- initData.properties = Ice.createProperties(sys.argv)
- initData.properties.setProperty("Ice.ServerIdleTime", "120") # Two minutes.
-
- with Ice.initialize(sys.argv, initData) as communicator:
- status = run(sys.argv, communicator)
-except:
- traceback.print_exc()
- status = False
-
-sys.exit(not status)
+
+class Server(TestHelper):
+
+ def run(self, args):
+ properties = self.createTestProperties(args)
+ #
+ # In this test, we need a longer server idle time, otherwise
+ # our test servers may time out before they are used in the
+ # test.
+ #
+ properties.setProperty("Ice.ServerIdleTime", "120") # Two minutes.
+
+ port = 0
+ for arg in args:
+
+ if arg[0] == '-':
+ raise RuntimeError("unknown option `" + arg + "'")
+
+ if port > 0:
+ raise RuntimeError("only one port can be specified")
+
+ port = int(arg)
+
+ if port <= 0:
+ raise RuntimeError("no port specified\n")
+
+ with self.initialize(properties=properties) as communicator:
+ communicator.getProperties().setProperty("TestAdapter.Endpoints", self.getTestEndpoint(num=port))
+ adapter = communicator.createObjectAdapter("TestAdapter")
+ adapter.add(TestI(), Ice.stringToIdentity("test"))
+ adapter.activate()
+ communicator.waitForShutdown()