Beispiel #1
0
    def setUp(self):
        super().setUp()
        self.tenant_uuid = SUB_TENANT
        self.tenant_name = 'mytenant'
        bus_port = self.service_port(5672, 'rabbitmq')
        bus = BusClient.from_connection_fields(host='localhost', port=bus_port)
        until.true(bus.is_up, timeout=5)

        bus_url = 'amqp://{username}:{password}@{host}:{port}//'.format(
            username='******',
            password='******',
            host='localhost',
            port=bus_port)
        connection = kombu.Connection(bus_url)
        connection.connect()
        marshaler = Marshaler('the-xivo-uuid')
        exchange = kombu.Exchange('xivo', type='topic')
        producer = kombu.Producer(connection,
                                  exchange=exchange,
                                  auto_declare=True)
        self.publisher = Publisher(producer, marshaler)
        self.mock_auth_client = MockAuthClient('localhost',
                                               self.service_port(9497, 'auth'))

        def wait_for_dird_bus_connection():
            response = self.client.status.get()
            assert_that(response, has_entries(bus_consumer={'status': 'ok'}))

        until.assert_(wait_for_dird_bus_connection, timeout=6)
Beispiel #2
0
    def test_that_adding_favorite_produces_bus_event(self):
        bus_port = self.service_port(5672, 'rabbitmq')
        bus = BusClient.from_connection_fields(host='localhost', port=bus_port)
        until.true(bus.is_up, tries=5)
        bus_events = bus.accumulator('directory.*.favorite.*')

        def favorite_bus_event_received(name):
            return name in (message['name']
                            for message in bus_events.accumulate())

        with self.personal({'firstname': 'Alice'}) as alice:
            with self.favorite('personal', alice['id']):
                until.true(favorite_bus_event_received,
                           'favorite_added',
                           tries=2)

        until.true(favorite_bus_event_received, 'favorite_deleted', tries=2)
def test_stasis_amqp_events(ari):
    real_app = 'A'
    parasite_app = 'B'
    ari.amqp.stasisSubscribe(applicationName=real_app)
    ari.amqp.stasisSubscribe(applicationName=parasite_app)

    assert_that(ari.applications.list(), has_item(has_entry('name', real_app)))
    assert_that(ari.applications.list(),
                has_item(has_entry('name', parasite_app)))

    bus_client = BusClient.from_connection_fields(
        port=AssetLauncher.service_port(5672, 'rabbitmq'))

    assert bus_client.is_up()

    events = bus_client.accumulator("stasis.app." + real_app.lower())
    parasite_events = bus_client.accumulator("stasis.app." +
                                             parasite_app.lower())

    ari.channels.originate(endpoint='local/3000@default', app=real_app)
    ari.channels.originate(endpoint='local/3000@default', app=parasite_app)

    def event_received(events, app):
        assert_that(events.accumulate(),
                    only_contains(has_entry('application', app)))

        assert_that(parasite_events.accumulate(),
                    only_contains(has_entry('application', is_not(app))))

    until.assert_(event_received, events, real_app, timeout=5)

    def event_received(events, app):
        assert_that(events.accumulate(),
                    only_contains(has_entry('application', app)))

        assert_that(parasite_events.accumulate(),
                    only_contains(has_entry('application', is_not(app))))

    until.assert_(event_received, events, real_app, timeout=5)
def test_stasis_amqp_events_bad_routing(ari):
    real_app = 'A'
    parasite_app = 'B'
    ari.amqp.stasisSubscribe(applicationName=real_app)
    ari.amqp.stasisSubscribe(applicationName=parasite_app)

    bus_client = BusClient.from_connection_fields(
        port=AssetLauncher.service_port(5672, 'rabbitmq'))

    assert bus_client.is_up()

    events = bus_client.accumulator("stasis.app." + parasite_app.lower())

    ari.channels.originate(endpoint='local/3000@default', app=real_app.lower())

    def event_received(events, app):
        assert_that(events.accumulate(), empty())

    until.assert_(event_received,
                  events,
                  subscribe_args[app_name_key],
                  timeout=5)
Beispiel #5
0
 def new_message_accumulator(self, routing_key):
     port = self.service_port(5672, service_name='rabbitmq')
     bus_client = BusClient.from_connection_fields(port=port,
                                                   **self.bus_config)
     return bus_client.accumulator(routing_key)
Beispiel #6
0
 def make_bus(self):
     return BusClient.from_connection_fields(host='localhost',
                                             port=self.service_port(
                                                 5672, 'rabbitmq'))
Beispiel #7
0
 def create_bus(cls):
     port = cls.service_port(5672, 'rabbitmq')
     client = BusClient.from_connection_fields(host='localhost', port=port)
     return client
 def setUp(self):
     super().setUp()
     bus_port = self.service_port(5672, 'rabbitmq')
     self.bus = BusClient.from_connection_fields(host='127.0.0.1', port=bus_port)