Ejemplo n.º 1
0
    def test_rpc_with_xn(self):
        # get an xn to use for send/recv
        xn = self.container.ex_manager.create_xn_service('hello')
        self.addCleanup(xn.delete)

        # create an RPCServer for a hello service
        hs = HelloService()
        rpcs = RPCServer(from_name=xn, service=hs)

        # spawn the listener, kill on test exit (success/fail/error should cover?)
        gl_listen = spawn(rpcs.listen)

        def cleanup():
            rpcs.close()
            gl_listen.join(timeout=2)
            gl_listen.kill()

        self.addCleanup(cleanup)

        # wait for listen to be ready
        rpcs.get_ready_event().wait(timeout=5)

        # ok, now create a client using same xn
        hsc = HelloServiceClient(to_name=xn)

        # try to message it!
        ret = hsc.hello('hi there')

        # did we get back what we expected?
        self.assertEquals(ret, 'BACK:hi there')
Ejemplo n.º 2
0
    def test_rpc_with_xn(self):
        # get an xn to use for send/recv
        xn = self.container.ex_manager.create_xn_service('hello')
        self.addCleanup(xn.delete)

        # create an RPCServer for a hello service
        hs = HelloService()
        rpcs = RPCServer(from_name=xn, service=hs)

        # spawn the listener, kill on test exit (success/fail/error should cover?)
        gl_listen = spawn(rpcs.listen)
        def cleanup():
            rpcs.close()
            gl_listen.join(timeout=2)
            gl_listen.kill()
        self.addCleanup(cleanup)

        # wait for listen to be ready
        rpcs.get_ready_event().wait(timeout=5)

        # ok, now create a client using same xn
        hsc = HelloServiceClient(to_name=xn)

        # try to message it!
        ret = hsc.hello('hi there')

        # did we get back what we expected?
        self.assertEquals(ret, 'BACK:hi there')
Ejemplo n.º 3
0
    def test_rpc_speed(self):
        hsc = HelloServiceClient()

        print >> sys.stderr, ""

        self.counter = 0
        self.alive = True

        def sendem():
            while self.alive:
                hsc.noop('data')
                self.counter += 1

        start_time = time.time()

        sendgl = spawn(sendem)
        time.sleep(5)
        end_time = time.time()

        self.alive = False
        sendgl.join(timeout=2)
        sendgl.kill()

        diff = end_time - start_time
        mps = float(self.counter) / diff

        print >> sys.stderr, "Requests per second (RPC):", mps, "(", self.counter, "messages in", diff, "seconds)"
Ejemplo n.º 4
0
class TestHelloService(IonIntegrationTestCase):
    def setUp(self):
        self._start_container()
        self.container.start_rel_from_url('res/deploy/examples/hello.yml')
        self.hsc = HelloServiceClient()

    def test_hello(self):

        ret = self.hsc.hello("emm")
        self.assertEquals(ret, "BACK:emm")
Ejemplo n.º 5
0
class TestHelloService(IonIntegrationTestCase):
    def setUp(self):
        self._start_container()
        self.container.start_rel_from_url('res/deploy/examples/hello.yml')
        self.hsc = HelloServiceClient()

    def test_hello(self):

        ret = self.hsc.hello("emm")
        self.assertEquals(ret, "BACK:emm")
Ejemplo n.º 6
0
 def setUp(self):
     self._start_container()
     self.container.start_rel_from_url('res/deploy/examples/hello.yml')
     self.hsc = HelloServiceClient()
Ejemplo n.º 7
0
                    type=int,
                    help='Number of parallel requests to run')
parser.add_argument('-m',
                    '--msgpack',
                    action='store_true',
                    help='Encode data with msgpack')
parser.add_argument('-s', '--sysname', action='store', help='ION System Name')
parser.set_defaults(datasize=1024, parallel=1, sysname='tt')
opts = parser.parse_args()

bootstrap.sys_name = opts.sysname
bootstrap.bootstrap_pyon()

node, iowat = make_node()
#dsclient = RPCClient(node=node, name="datastore", iface=IDatastoreService)
hsclient = HelloServiceClient(
    node=node)  #RPCClient(node=node, name="hello", iface=IHelloService)

# make data (bytes)
DATA_SIZE = opts.datasize
# base64 encoding wastes a lot of space, truncate it at the exact data size we requested
data = base64.urlsafe_b64encode(os.urandom(DATA_SIZE))[:DATA_SIZE]
if opts.msgpack:
    data = msgpack.dumps(data)

PARALLEL = opts.parallel

print "Datasize:", DATA_SIZE, "Parallel:", PARALLEL

counter = [0] * PARALLEL
st = time.time()
Ejemplo n.º 8
0
 def setUp(self):
     self._start_container()
     self.container.start_rel_from_url('res/deploy/examples/hello.yml')
     self.hsc = HelloServiceClient()