def start_client_registry(self, host, port): self.service = ClientRegistry(host, port) self.service_greenlet = Greenlet(self.service.start) gevent.signal(signal.SIGTERM, self.service_greenlet.kill) gevent.signal(signal.SIGINT, self.service_greenlet.kill) self.service_greenlet.start() logger.info('Started client registry, connecting to %s:%s', host, port)
class BaseTestCase(TestCase): def start_server(self, host, port, linked_servers=[]): result = ObjectoPlex((host, port), middlewares=[ PingPongMiddleware(), LegacySubscriptionMiddleware(), StatisticsMiddleware(), ChecksumMiddleware(), RoutingMiddleware(), ], linked_servers=linked_servers) gevent.signal(signal.SIGTERM, result.stop) gevent.signal(signal.SIGINT, result.stop) Greenlet.spawn(result.serve_forever) sleep(0.1) return result def start_client_registry(self, host, port): self.service = ClientRegistry(host, port) self.service_greenlet = Greenlet(self.service.start) gevent.signal(signal.SIGTERM, self.service_greenlet.kill) gevent.signal(signal.SIGINT, self.service_greenlet.kill) self.service_greenlet.start() logger.info('Started client registry, connecting to %s:%s', host, port) def stop_client_registry(self): self.service.cleanup() self.service_greenlet.kill() logger.info('Stopped client registry, connecting to %s:%s', _host, _port) def assertCorrectClientListReply(self, obj, payload): self.assertIn('clients', payload, msg=u"attribute 'clients' not in payload") d = None for dct in payload['clients']: self.assertIn( 'routing-id', dct, msg=u"attribute 'routing-id' not in list item in clients list") if dct['routing-id'] == self.routing_id: d = dct break self.assertIsNotNone( d, msg=u'Client not present in returned client listing') self.assertEquals(obj.metadata['client'], d['client'], msg=u"attribute 'client' not equal") self.assertEquals(obj.metadata['user'], d['user'], msg=u"attribute 'user' not equal")
class BaseTestCase(TestCase): def start_server(self, host, port, linked_servers=[]): result = ObjectoPlex((host, port), middlewares=[ PingPongMiddleware(), LegacySubscriptionMiddleware(), StatisticsMiddleware(), ChecksumMiddleware(), RoutingMiddleware(), ], linked_servers=linked_servers) gevent.signal(signal.SIGTERM, result.stop) gevent.signal(signal.SIGINT, result.stop) Greenlet.spawn(result.serve_forever) sleep(0.1) return result def start_client_registry(self, host, port): self.service = ClientRegistry(host, port) self.service_greenlet = Greenlet(self.service.start) gevent.signal(signal.SIGTERM, self.service_greenlet.kill) gevent.signal(signal.SIGINT, self.service_greenlet.kill) self.service_greenlet.start() logger.info('Started client registry, connecting to %s:%s', host, port) def stop_client_registry(self): self.service.cleanup() self.service_greenlet.kill() logger.info('Stopped client registry, connecting to %s:%s', _host, _port) def assertCorrectClientListReply(self, obj, payload): self.assertIn('clients', payload, msg=u"attribute 'clients' not in payload") d = None for dct in payload['clients']: self.assertIn('routing-id', dct, msg=u"attribute 'routing-id' not in list item in clients list") if dct['routing-id'] == self.routing_id: d = dct break self.assertIsNotNone(d, msg=u'Client not present in returned client listing') self.assertEquals(obj.metadata['client'], d['client'], msg=u"attribute 'client' not equal") self.assertEquals(obj.metadata['user'], d['user'], msg=u"attribute 'user' not equal")