Example #1
0
    def test_rpc_speed(self):
        hsc = HelloServiceClient()

        print >>sys.stderr, ""

        self.counter = 0
        self.alive = True
        def sendem():
            while self.alive:
                hsc.hello('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)"
    def test_procs(self):
        # Start procs
        config = {}
        pid1 = self.container.spawn_process("hello1",
                                            __name__,
                                            "CoordinatedProcess",
                                            config=config)
        pid2 = self.container.spawn_process("hello2",
                                            __name__,
                                            "CoordinatedProcess",
                                            config=config)
        pid3 = self.container.spawn_process("hello3",
                                            __name__,
                                            "CoordinatedProcess",
                                            config=config)

        # Wait for them to be ready
        gevent.sleep(0.3)

        # Call service
        evt_pub = EventPublisher(event_type=OT.ResourceCommandEvent)
        hc = HelloServiceClient()
        end_time = get_ion_ts_millis() + 4000
        counter = 0
        while get_ion_ts_millis() < end_time:
            counter += 1
            res = hc.hello("foo")
            evt_pub.publish_event(origin=str(counter))
            gevent.sleep(random.random() * 0.1)

        # Wait for them to be finish
        gevent.sleep(0.3)

        # Wrap up
        self.container.terminate_process(pid1)
        self.container.terminate_process(pid2)
        self.container.terminate_process(pid3)

        evt_count = CoordinatedProcess.evt_count
        log.info("Counters: %s", evt_count)

        self.assertEqual(evt_count["total"], 3 * counter)
        master_evts = evt_count[pid1] + evt_count[pid2] + evt_count[pid3]
        self.assertLessEqual(master_evts, counter)
        if master_evts < counter:
            log.info("Lost %s events - no functioning master",
                     counter - master_evts)
Example #3
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")
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")
    def test_procs(self):
        # Start procs
        config = {}
        pid1 = self.container.spawn_process("hello1", __name__, "CoordinatedProcess", config=config)
        pid2 = self.container.spawn_process("hello2", __name__, "CoordinatedProcess", config=config)
        pid3 = self.container.spawn_process("hello3", __name__, "CoordinatedProcess", config=config)

        # Wait for them to be ready
        gevent.sleep(0.3)

        # Call service
        evt_pub = EventPublisher(event_type=OT.ResourceCommandEvent)
        hc = HelloServiceClient()
        end_time = get_ion_ts_millis() + 4000
        counter = 0
        while get_ion_ts_millis() < end_time:
            counter += 1
            res = hc.hello("foo")
            evt_pub.publish_event(origin=str(counter))
            gevent.sleep(random.random()*0.1)

        # Wait for them to be finish
        gevent.sleep(0.3)

        # Wrap up
        self.container.terminate_process(pid1)
        self.container.terminate_process(pid2)
        self.container.terminate_process(pid3)

        evt_count = CoordinatedProcess.evt_count
        log.info("Counters: %s", evt_count)

        self.assertEqual(evt_count["total"], 3*counter)
        master_evts = evt_count[pid1] + evt_count[pid2] + evt_count[pid3]
        self.assertLessEqual(master_evts, counter)
        if master_evts < counter:
            log.info("Lost %s events - no functioning master", counter - master_evts)
Example #6
0
 def setUp(self):
     self._start_container()
     self.container.start_rel_from_url('res/deploy/examples/hello.yml')
     self.hsc = HelloServiceClient()
 def setUp(self):
     self._start_container()
     self.container.start_rel_from_url('res/deploy/examples/hello.yml')
     self.hsc = HelloServiceClient()