def on_link_opened(self, event):
        if event.receiver == self.receiver1:
            local_node = Node.connect(self.first_host, timeout=TIMEOUT)
            out = local_node.query(type='org.apache.qpid.dispatch.router.link')
            link_type_index = out.attribute_names.index('linkType')
            link_dir_index = out.attribute_names.index('linkDir')
            owning_addr_index = out.attribute_names.index('owningAddr')
            link_name_index = out.attribute_names.index('linkName')

            for result in out.results:
                if result[link_type_index] == "endpoint" and result[link_dir_index] == "out" and result[link_name_index] == 'AAA' and result[owning_addr_index] == 'M10.0.0.0/queue.ext':
                    self.receiver1_phase = True
        elif event.receiver == self.receiver2:
            local_node = Node.connect(self.second_host, timeout=TIMEOUT)
            out = local_node.query(type='org.apache.qpid.dispatch.router.link')
            link_type_index = out.attribute_names.index('linkType')
            link_dir_index = out.attribute_names.index('linkDir')
            owning_addr_index = out.attribute_names.index('owningAddr')
            link_name_index = out.attribute_names.index('linkName')

            for result in out.results:
                if result[link_type_index] == "endpoint" and result[link_dir_index] == "out" and result[link_name_index] == 'BBB' and result[owning_addr_index] == 'M10.0.0.0/queue.ext':
                    self.receiver2_phase = True

        if self.receiver1_phase and self.receiver2_phase:
            self.first_conn.close()
            self.second_conn.close()
            self.timer.cancel()
    def test_two_router_ingress_egress_counts(self):
        address1 = self.routers[0].addresses[0]
        address2 = self.routers[1].addresses[0]

        # Gather the values for deliveries_ingress and deliveries_egress before running the test.

        local_node = Node.connect(address1, timeout=TIMEOUT)
        outs = local_node.query(type='org.apache.qpid.dispatch.router')
        deliveries_ingress_index = outs.attribute_names.index(
            'deliveriesIngress')
        results = outs.results[0]

        pre_deliveries_ingresss = results[deliveries_ingress_index]

        local_node = Node.connect(address2, timeout=TIMEOUT)
        outs = local_node.query(type='org.apache.qpid.dispatch.router')
        deliveries_egress_index = outs.attribute_names.index(
            'deliveriesEgress')
        deliveries_accepted_index = outs.attribute_names.index(
            'acceptedDeliveries')
        results = outs.results[0]

        pre_deliveries_egress = results[deliveries_egress_index]
        pre_deliveries_accepted = results[deliveries_accepted_index]

        # Now run the test.
        test = IngressEgressTwoRouterTest(address1, address2)
        test.run()

        # Gather the values for deliveries_ingress and deliveries_egress after running the test.
        local_node = Node.connect(address1, timeout=TIMEOUT)
        outs = local_node.query(type='org.apache.qpid.dispatch.router')
        deliveries_ingress_index = outs.attribute_names.index(
            'deliveriesIngress')
        results = outs.results[0]

        post_deliveries_ingresss = results[deliveries_ingress_index]

        local_node = Node.connect(address2, timeout=TIMEOUT)
        outs = local_node.query(type='org.apache.qpid.dispatch.router')
        deliveries_egress_index = outs.attribute_names.index(
            'deliveriesEgress')
        deliveries_accepted_index = outs.attribute_names.index(
            'acceptedDeliveries')
        results = outs.results[0]

        post_deliveries_egress = results[deliveries_egress_index]
        post_deliveries_accepted = results[deliveries_accepted_index]

        accepted_deliveries_diff = post_deliveries_accepted - pre_deliveries_accepted

        self.assertEqual(post_deliveries_ingresss - pre_deliveries_ingresss,
                         11)
        self.assertEqual(post_deliveries_egress - pre_deliveries_egress, 11)

        # The management requests are counted in the acceptedDeliveries, so it is difficult to measure the
        # exact number of accepted deliveries at this point in time. But it must at least be 10 since
        # we know for sure from the test that the 10 dispositions related to the 10 sent messages
        # were definitely received
        self.assertTrue(accepted_deliveries_diff >= 10)
Ejemplo n.º 3
0
    def test_zzz_delete_create_ssl_profile(self):
        """
        Deletes a connector and its corresponding ssl profile and recreates both
        """
        if not SASL.extended():
            self.skipTest("Cyrus library not available. skipping test")

        ssl_profile_name = 'client-ssl-profile'

        # Deleting the connector first and then its SSL profile must work.
        delete_command = 'DELETE --type=connector --name=connectorToX'
        self.run_qdmanage(delete_command, address=self.routers[1].addresses[0])

        # Delete the connector's associated ssl profile
        delete_command = 'DELETE --type=sslProfile --name=' + ssl_profile_name
        self.run_qdmanage(delete_command, address=self.routers[1].addresses[0])

        local_node = Node.connect(self.routers[1].addresses[0],
                                  timeout=TIMEOUT)
        results = local_node.query(
            type='org.apache.qpid.dispatch.connection').results
        search = "QDR.X"
        found = False

        for N in range(0, 3):
            if results[N][0] == search:
                found = True
                break

        self.assertFalse(found)

        # re-create the ssl profile
        long_type = 'org.apache.qpid.dispatch.sslProfile'
        ssl_create_command = 'CREATE --type=' + long_type + ' certFile=' + self.ssl_file('client-certificate.pem') + \
                             ' keyFile=' + self.ssl_file('client-private-key.pem') + ' password=client-password' + \
                             ' name=' + ssl_profile_name + ' certDb=' + self.ssl_file('ca-certificate.pem')

        output = json.loads(
            self.run_qdmanage(ssl_create_command,
                              address=self.routers[1].addresses[0]))
        name = output['name']
        self.assertEqual(name, ssl_profile_name)

        # Re-add connector
        connector_create_command = 'CREATE --type=connector name=connectorToX host=127.0.0.1 port=' + \
                                   str(RouterTestVerifyHostNameNo.x_listener_port) + \
                                   ' saslMechanisms=PLAIN sslProfile=' + ssl_profile_name + \
                                   ' role=inter-router verifyHostName=no [email protected]' \
                                   ' saslPassword=password'

        json.loads(
            self.run_qdmanage(connector_create_command,
                              address=self.routers[1].addresses[0]))
        self.routers[1].wait_connectors()
        local_node = Node.connect(self.routers[1].addresses[0],
                                  timeout=TIMEOUT)
        results = local_node.query(
            type='org.apache.qpid.dispatch.connection').results

        self.common_asserts(results)
 def test_remote_node(self):
     """Test that we can access management info of remote nodes using get_mgmt_nodes addresses"""
     nodes = [self.cleanup(Node.connect(Url(r.addresses[0]))) for r in self.routers]
     remotes = sum([n.get_mgmt_nodes() for n in nodes], [])
     self.assertEqual([u'amqp:/_topo/0/router2/$management', u'amqp:/_topo/0/router1/$management'], remotes)
     # Query router2 indirectly via router1
     remote_url = Url(self.routers[0].addresses[0], path=Url(remotes[0]).path)
     remote = self.cleanup(Node.connect(remote_url))
     self.assertEqual(["router2"], [r.id for r in remote.query(type=ROUTER).get_entities()])
    def test_two_router_ingress_egress_counts(self):
        address1 = self.routers[0].addresses[0]
        address2 = self.routers[1].addresses[0]

        # Gather the values for deliveries_ingress and deliveries_egress before running the test.

        local_node = Node.connect(address1, timeout=TIMEOUT)
        outs = local_node.query(type='org.apache.qpid.dispatch.router')
        deliveries_ingress_index = outs.attribute_names.index('deliveriesIngress')
        results = outs.results[0]

        pre_deliveries_ingresss = results[deliveries_ingress_index]

        local_node = Node.connect(address2, timeout=TIMEOUT)
        outs = local_node.query(type='org.apache.qpid.dispatch.router')
        deliveries_egress_index = outs.attribute_names.index('deliveriesEgress')
        deliveries_accepted_index = outs.attribute_names.index('acceptedDeliveries')
        results = outs.results[0]

        pre_deliveries_egress = results[deliveries_egress_index]
        pre_deliveries_accepted = results[deliveries_accepted_index]

        # Now run the test.
        test = IngressEgressTwoRouterTest(address1, address2)
        test.run()

        # Gather the values for deliveries_ingress and deliveries_egress after running the test.
        local_node = Node.connect(address1, timeout=TIMEOUT)
        outs = local_node.query(type='org.apache.qpid.dispatch.router')
        deliveries_ingress_index = outs.attribute_names.index('deliveriesIngress')
        results = outs.results[0]

        post_deliveries_ingresss = results[deliveries_ingress_index]

        local_node = Node.connect(address2, timeout=TIMEOUT)
        outs = local_node.query(type='org.apache.qpid.dispatch.router')
        deliveries_egress_index = outs.attribute_names.index('deliveriesEgress')
        deliveries_accepted_index = outs.attribute_names.index('acceptedDeliveries')
        results = outs.results[0]

        post_deliveries_egress = results[deliveries_egress_index]
        post_deliveries_accepted = results[deliveries_accepted_index]

        accepted_deliveries_diff = post_deliveries_accepted - pre_deliveries_accepted

        self.assertEqual(post_deliveries_ingresss - pre_deliveries_ingresss, 11)
        self.assertEqual(post_deliveries_egress - pre_deliveries_egress, 11)

        # The management requests are counted in the acceptedDeliveries, so it is difficult to measure the
        # exact number of accepted deliveries at this point in time. But it must at least be 10 since
        # we know for sure from the test that the 10 dispositions related to the 10 sent messages
        # were definitely received
        self.assertTrue(accepted_deliveries_diff >= 10)
Ejemplo n.º 6
0
    def test_zzz_delete_create_ssl_profile(self):
        """
        Deletes a connector and its corresponding ssl profile and recreates both
        """

        ssl_profile_name = 'client-ssl-profile'

        # Deleting the connector first and then its SSL profile must work.
        delete_command = 'DELETE --type=connector --name=connectorToX'
        self.run_qdmanage(delete_command, address=self.routers[1].addresses[0])

        # Delete the connector's associated ssl profile
        delete_command = 'DELETE --type=sslProfile --name=' + ssl_profile_name
        self.run_qdmanage(delete_command, address=self.routers[1].addresses[0])

        local_node = Node.connect(self.routers[1].addresses[0], timeout=TIMEOUT)
        results = local_node.query(type='org.apache.qpid.dispatch.connection').results
        search = "QDR.X"
        found = False

        for N in range(0, 3):
            if results[N][0] == search:
                found = True
                break

        self.assertFalse(found)

        # re-create the ssl profile
        long_type = 'org.apache.qpid.dispatch.sslProfile'
        ssl_create_command = 'CREATE --type=' + long_type + ' certFile=' + self.ssl_file('client-certificate.pem') + \
                             ' keyFile=' + self.ssl_file('client-private-key.pem') + ' password=client-password' + \
                             ' name=' + ssl_profile_name + ' certDb=' + self.ssl_file('ca-certificate.pem')

        output = json.loads(self.run_qdmanage(ssl_create_command, address=self.routers[1].addresses[0]))
        name = output['name']
        self.assertEqual(name, ssl_profile_name)

        # Re-add connector
        connector_create_command = 'CREATE --type=connector name=connectorToX host=127.0.0.1 port=' + \
                                   str(RouterTestVerifyHostNameNo.x_listener_port) + \
                                   ' saslMechanisms=PLAIN sslProfile=' + ssl_profile_name + \
                                   ' role=inter-router verifyHostName=no [email protected]' \
                                   ' saslPassword=password'

        json.loads(self.run_qdmanage(connector_create_command, address=self.routers[1].addresses[0]))

        sleep(1)

        local_node = Node.connect(self.routers[1].addresses[0], timeout=TIMEOUT)
        results = local_node.query(type='org.apache.qpid.dispatch.connection').results

        self.common_asserts(results)
 def test_remote_node(self):
     """Test that we can access management info of remote nodes using get_mgmt_nodes addresses"""
     nodes = [self.cleanup(Node.connect(Url(r.addresses[0]))) for r in self.routers]
     remotes = sum([n.get_mgmt_nodes() for n in nodes], [])
     self.assertEqual(set([u'amqp:/_topo/0/router%s/$management' % i for i in [0, 1, 2]]),
                      set(remotes))
     self.assertEqual(9, len(remotes))
     # Query router2 indirectly via router1
     remote_url = Url(self.routers[0].addresses[0], path=Url(remotes[0]).path)
     remote = self.cleanup(Node.connect(remote_url))
     router_id = remotes[0].split("/")[3]
     assert router_id in ['router0', 'router1', 'router2']
     self.assertEqual([router_id], [r.id for r in remote.query(type=ROUTER).get_entities()])
Ejemplo n.º 8
0
 def test_remote_node(self):
     """Test that we can access management info of remote nodes using get_mgmt_nodes addresses"""
     nodes = [self.cleanup(Node.connect(Url(r.addresses[0]))) for r in self.routers]
     remotes = sum([n.get_mgmt_nodes() for n in nodes], [])
     self.assertEqual(set([u'amqp:/_topo/0/router%s/$management' % i for i in [0, 1, 2]]),
                      set(remotes))
     self.assertEqual(9, len(remotes))
     # Query router2 indirectly via router1
     remote_url = Url(self.routers[0].addresses[0], path=Url(remotes[0]).path)
     remote = self.cleanup(Node.connect(remote_url))
     router_id = remotes[0].split("/")[3]
     assert router_id in ['router0', 'router1', 'router2']
     self.assertEqual([router_id], [r.id for r in remote.query(type=ROUTER).get_entities()])
Ejemplo n.º 9
0
    def on_link_opened(self, event):
        if event.receiver == self.receiver:
            self.receiver_link_opened = True

            local_node = Node.connect(self.query_address_listening,
                                      timeout=TIMEOUT)
            out = local_node.query(type='org.apache.qpid.dispatch.router.link')

            link_dir_index = out.attribute_names.index("linkDir")
            owning_addr_index = out.attribute_names.index("owningAddr")

            # Make sure that the owningAddr M0pulp.task.terminusTestReceiver shows up on both in and out.
            # The 'out' link is on address M0pulp.task.terminusTestReceiver outgoing from the router B to the receiver
            # The 'in' link is on address M0pulp.task.terminusTestReceiver incoming from router C to router B
            for result in out.results:
                if result[link_dir_index] == 'in' and result[
                        owning_addr_index] == 'M0pulp.task.terminusTestReceiver':
                    self.in_receiver_found = True
                if result[link_dir_index] == 'out' and result[
                        owning_addr_index] == 'M0pulp.task.terminusTestReceiver':
                    self.out_receiver_found = True

        if event.sender == self.sender:
            self.sender_link_opened = True

            local_node = Node.connect(self.query_address_sending,
                                      timeout=TIMEOUT)
            out = local_node.query(type='org.apache.qpid.dispatch.router.link')

            link_dir_index = out.attribute_names.index("linkDir")
            owning_addr_index = out.attribute_names.index("owningAddr")

            # Make sure that the owningAddr M0pulp.task.terminusTestSender shows up on both in and out.
            # The 'in' link is on address M0pulp.task.terminusTestSender incoming from sender to router
            # The 'out' link is on address M0pulp.task.terminusTestSender outgoing from router C to router B
            for result in out.results:
                if result[link_dir_index] == 'in' and result[
                        owning_addr_index] == 'M0pulp.task.terminusTestSender':
                    self.in_sender_found = True
                if result[link_dir_index] == 'out' and result[
                        owning_addr_index] == 'M0pulp.task.terminusTestSender':
                    self.out_sender_found = True

        # Shutdown the connections only if the on_link_opened has been called for sender and receiver links.
        if self.sender_link_opened and self.receiver_link_opened:
            self.sender.close()
            self.receiver.close()
            self.sender_connection.close()
            self.receiver_connection.close()
 def test_000_wait_for_link_route_up(self):
     # wait up to 60 seconds for link route to get set up
     # The name of this test must dictate that it runs first
     wLoops = 600
     wTimeS = 0.1
     waitTimeS = float(wLoops) * wTimeS
     local_node = Node.connect(self.routers[1].addresses[0], timeout=TIMEOUT)
     counted = False
     for i in range(wLoops):
         try:
             results = local_node.query(type='org.apache.qpid.dispatch.router.address',
                                        attribute_names=[u'name', u'containerCount']
                                        ).results
             for res in results:
                 if res[0] == 'Corg.apache':
                     if res[1] == 1:
                         counted = True
                     break
             if counted:
                 break
             sleep(wTimeS)
         except Exception as e:
             self.fail("Exception: " + str(e))
     if not counted:
         self.fail("Interrouter link route failed to connect after %f seconds" % waitTimeS)
Ejemplo n.º 11
0
    def on_connection_remote_open(self, event):
        if event.connection == self.receiver_connection:
            continue_loop = True
            # The following loops introduces a wait. It gives time to the
            # router so that the address Dpulp.task can show up on the remoteCount
            i = 0
            while continue_loop:
                if i > 100:  # If we have run the read command for more than hundred times and we still do not have
                    # the remoteCount set to 1, there is a problem, just exit out of the function instead
                    # of looping to infinity.
                    self.receiver_connection.close()
                    return
                local_node = Node.connect(self.query_address_sending,
                                          timeout=TIMEOUT)
                out = local_node.read(
                    type='org.apache.qpid.dispatch.router.address',
                    name='Dpulp.task').remoteCount
                if out == 1:
                    continue_loop = False
                i += 1
                sleep(0.25)

            self.sender_connection = event.container.connect(
                self.sender_address)

            # Notice here that the receiver and sender are listening on different addresses. Receiver on
            # pulp.task.terminusTestReceiver and the sender on pulp.task.terminusTestSender
            self.receiver = event.container.create_receiver(
                self.receiver_connection, "pulp.task.terminusTestReceiver")
            self.sender = event.container.create_sender(
                self.sender_connection,
                "pulp.task.terminusTestSender",
                options=AtMostOnce())
Ejemplo n.º 12
0
    def on_connection_remote_open(self, event):
        if event.connection == self.receiver_connection:
            continue_loop = True
            # Dont open the sender connection unless we can make sure that there is a remote receiver ready to
            # accept the message.
            # If there is no remote receiver, the router will throw a 'No route to destination' error when
            # creating sender connection.
            # The following loops introduces a wait before creating the sender connection. It gives time to the
            # router so that the address Dpulp.task can show up on the remoteCount
            i = 0
            while continue_loop:
                if i > 100:  # If we have run the read command for more than hundred times and we still do not have
                    # the remoteCount set to 1, there is a problem, just exit out of the function instead
                    # of looping to infinity.
                    self.receiver_connection.close()
                    return
                local_node = Node.connect(self.qdstat_address, timeout=TIMEOUT)
                out = local_node.read(
                    type='org.apache.qpid.dispatch.router.address',
                    name='Dpulp.task').remoteCount
                if out == 1:
                    continue_loop = False
                else:
                    i += 1
                    sleep(0.25)

            self.sender_connection = event.container.connect(
                self.sender_address)
            self.sender = event.container.create_sender(self.sender_connection,
                                                        "pulp.task",
                                                        options=AtMostOnce())
 def test_000_wait_for_link_route_up(self):
     # wait up to 60 seconds for link route to get set up
     # The name of this test must dictate that it runs first
     wLoops = 600
     wTimeS = 0.1
     waitTimeS = float(wLoops) * wTimeS
     local_node = Node.connect(self.routers[1].addresses[0],
                               timeout=TIMEOUT)
     counted = False
     for i in range(wLoops):
         try:
             results = local_node.query(
                 type='org.apache.qpid.dispatch.router.address',
                 attribute_names=[u'name', u'containerCount']).results
             for res in results:
                 if res[0] == 'Corg.apache':
                     if res[1] == 1:
                         counted = True
                     break
             if counted:
                 break
             sleep(wTimeS)
         except Exception as e:
             self.fail("Exception: " + str(e))
     if not counted:
         self.fail(
             "Interrouter link route failed to connect after %f seconds" %
             waitTimeS)
    def on_connection_remote_open(self, event):
        if event.connection == self.receiver_connection:
            continue_loop = True
            # Dont open the sender connection unless we can make sure that there is a remote receiver ready to
            # accept the message.
            # If there is no remote receiver, the router will throw a 'No route to destination' error when
            # creating sender connection.
            # The following loops introduces a wait before creating the sender connection. It gives time to the
            # router so that the address Dpulp.task can show up on the remoteCount
            i = 0
            while continue_loop:
                if i > 100: # If we have run the read command for more than hundred times and we still do not have
                    # the remoteCount set to 1, there is a problem, just exit out of the function instead
                    # of looping to infinity.
                    self.receiver_connection.close()
                    return
                local_node = Node.connect(self.qdstat_address, timeout=TIMEOUT)
                out = local_node.read(type='org.apache.qpid.dispatch.router.address', name='Dpulp.task').remoteCount
                if out == 1:
                    continue_loop = False
                else:
                    i += 1
                    sleep(0.25)

            self.sender_connection = event.container.connect(self.sender_address)
            self.sender = event.container.create_sender(self.sender_connection, "pulp.task", options=AtMostOnce())
    def test_create_connectors(self):
        self.local_node = Node.connect(self.routers[0].addresses[0],
                                       timeout=TIMEOUT)

        res = self.local_node.query(type='org.apache.qpid.dispatch.connection')
        results = res.results

        self.assertEqual(1, len(results))

        long_type = 'org.apache.qpid.dispatch.connector' ''

        create_command = 'CREATE --type=' + long_type + ' --name=foo' + ' host=0.0.0.0 port=' + str(TwoRouterConnection.B_normal_port_1)

        self.run_qdmanage(create_command)

        create_command = 'CREATE --type=' + long_type + ' --name=bar' + ' host=0.0.0.0 port=' + str(TwoRouterConnection.B_normal_port_2)

        self.run_qdmanage(create_command)

        self.schedule_num_connections_test()

        while not self.can_terminate():
            pass

        self.assertTrue(self.success)
    def test_create_listener(self):
        """Create a new listener on a running router"""

        port = self.get_port()
        # Note qdrouter schema defines port as string not int, since it can be a service name.
        attributes = {
            'name': 'foo',
            'port': str(port),
            'role': 'normal',
            'saslMechanisms': 'ANONYMOUS',
            'authenticatePeer': False
        }
        entity = self.assert_create_ok(LISTENER, 'foo', attributes)
        self.assertEqual(entity['name'], 'foo')
        self.assertEqual(entity['host'], '')

        # Connect via the new listener
        node3 = self.cleanup(Node.connect(Url(port=port)))
        router = node3.query(type=ROUTER).get_entities()
        self.assertEqual(self.router.name, router[0]['id'])

        # Delete the listener
        entity.delete()
        response = self.node.query(type=LISTENER, attribute_names=['name'])
        for l in response.get_dicts():
            self.assertTrue(l['name'] != 'foo')
Ejemplo n.º 17
0
    def test_inter_router_plain_over_ssl_exists(self):
        """The setUpClass sets up two routers with SASL PLAIN enabled over TLS.

        This test makes executes a query for type='org.apache.qpid.dispatch.connection' over
        an unauthenticated listener to
        QDR.X and makes sure that the output has an "inter-router" connection to
        QDR.Y whose authentication is PLAIN. This ensures that QDR.Y did not
        somehow use SASL ANONYMOUS to connect to QDR.X
        Also makes sure that TLSv1.x was used as sslProto

        """
        local_node = Node.connect(self.routers[0].addresses[1],
                                  timeout=TIMEOUT)
        results = local_node.query(
            type='org.apache.qpid.dispatch.connection').get_entities()

        # sslProto should be TLSv1.x
        self.assertIn('TLSv1', results[0].sslProto)

        # role should be inter-router
        self.assertEqual('inter-router', results[0].role)

        # sasl must be plain
        self.assertEqual('PLAIN', results[0].sasl)

        # user must be [email protected]
        self.assertEqual('*****@*****.**', results[0].user)
Ejemplo n.º 18
0
    def test_inter_router_plain_over_ssl_exists(self):
        """The setUpClass sets up two routers with SASL PLAIN enabled over TLS.

        This test makes executes a query for type='org.apache.qpid.dispatch.connection' over
        an unauthenticated listener to
        QDR.X and makes sure that the output has an "inter-router" connection to
        QDR.Y whose authentication is PLAIN. This ensures that QDR.Y did not
        somehow use SASL ANONYMOUS to connect to QDR.X
        Also makes sure that TLSv1.x was used as sslProto

        """
        if not SASL.extended():
            self.skipTest("Cyrus library not available. skipping test")

        local_node = Node.connect(self.routers[0].addresses[1],
                                  timeout=TIMEOUT)
        results = local_node.query(
            type='org.apache.qpid.dispatch.connection').results

        # sslProto should be TLSv1.x
        self.assertTrue(u'TLSv1' in results[0][10])

        # role should be inter-router
        self.assertEqual(u'inter-router', results[0][3])

        # sasl must be plain
        self.assertEqual(u'PLAIN', results[0][6])

        # user must be [email protected]
        self.assertEqual(u'*****@*****.**', results[0][8])
    def test_router_node(self):
        """Test node entity in a trio of linked routers"""
        nodes = [
            self.cleanup(Node.connect(Url(r.addresses[0])))
            for r in self.routers
        ]
        rnode_lists = [n.query(type=NODE).get_dicts() for n in nodes]

        def check(attrs):
            name = attrs['id']
            self.assertEqual(attrs['identity'], 'router.node/%s' % name)
            self.assertEqual(attrs['name'], 'router.node/%s' % name)
            self.assertEqual(attrs['type'],
                             'org.apache.qpid.dispatch.router.node')
            self.assertEqual(attrs['address'], 'amqp:/_topo/0/%s' % name)
            return name

        self.assertEqual({"router0", "router1", "router2"},
                         {check(n)
                          for n in rnode_lists[0]})
        self.assertEqual({"router0", "router1", "router2"},
                         {check(n)
                          for n in rnode_lists[1]})
        self.assertEqual({"router0", "router1", "router2"},
                         {check(n)
                          for n in rnode_lists[2]})
    def on_connection_remote_open(self, event):
        if event.connection == self.receiver_connection:
            continue_loop = True
            # The following loops introduces a wait. It gives time to the
            # router so that the address Dpulp.task can show up on the remoteCount
            i = 0
            while continue_loop:
                if i > 100: # If we have run the read command for more than hundred times and we still do not have
                    # the remoteCount set to 1, there is a problem, just exit out of the function instead
                    # of looping to infinity.
                    self.receiver_connection.close()
                    return
                local_node = Node.connect(self.query_address_sending, timeout=TIMEOUT)
                out = local_node.read(type='org.apache.qpid.dispatch.router.address', name='Dpulp.task').remoteCount
                if out == 1:
                    continue_loop = False
                i += 1
                sleep(0.25)

            self.sender_connection = event.container.connect(self.sender_address)

            # Notice here that the receiver and sender are listening on different addresses. Receiver on
            # pulp.task.terminusTestReceiver and the sender on pulp.task.terminusTestSender
            self.receiver = event.container.create_receiver(self.receiver_connection, "pulp.task.terminusTestReceiver")
            self.sender = event.container.create_sender(self.sender_connection, "pulp.task.terminusTestSender", options=AtMostOnce())
Ejemplo n.º 21
0
    def test_inter_router_plain_over_ssl_exists(self):
        """
        Tests to make sure that an inter-router connection exists between the routers since verifyHostName is 'no'.
        """
        local_node = Node.connect(self.routers[1].addresses[0], timeout=TIMEOUT)

        results = local_node.query(type='org.apache.qpid.dispatch.connection').results

        self.assertEqual(4, len(results))

        search = "QDR.X"
        found = False

        for N in range(0,3):
            if results[N][0] == search:
                found = True
                break

        self.assertTrue(found, "Connection to %s not found" % search)

        # sslProto should be TLSv1/SSLv3
        self.assertEqual(u'TLSv1/SSLv3', results[N][4])

        # role should be inter-router
        self.assertEqual(u'inter-router', results[N][9])

        # sasl must be plain
        self.assertEqual(u'PLAIN', results[N][12])

        # user must be [email protected]
        self.assertEqual(u'*****@*****.**', results[N][16])
    def test_inter_router_plain_over_ssl_exists(self):
        """The setUpClass sets up two routers with SASL PLAIN enabled over TLS/SSLv3.

        This test makes executes a query for type='org.apache.qpid.dispatch.connection' over
        an unauthenticated listener to
        QDR.X and makes sure that the output has an "inter-router" connection to
        QDR.Y whose authentication is PLAIN. This ensures that QDR.Y did not
        somehow use SASL ANONYMOUS to connect to QDR.X
        Also makes sure that TLSv1/SSLv3 was used as sslProto

        """
        if not SASL.extended():
            self.skipTest("Cyrus library not available. skipping test")

        local_node = Node.connect(self.routers[0].addresses[1], timeout=TIMEOUT)
        results = local_node.query(type='org.apache.qpid.dispatch.connection').results

        # sslProto should be TLSv1/SSLv3
        self.assertEqual(u'TLSv1/SSLv3', results[0][10])

        # role should be inter-router
        self.assertEqual(u'inter-router', results[0][3])

        # sasl must be plain
        self.assertEqual(u'PLAIN', results[0][6])

        # user must be [email protected]
        self.assertEqual(u'*****@*****.**', results[0][8])
    def test_link_route_ingress_egress_transit_counts(self):
        address1 = self.routers[2].addresses[0]
        address2 = self.routers[2].addresses[0]

        local_node = Node.connect(address1, timeout=TIMEOUT)
        outs = local_node.query(type='org.apache.qpid.dispatch.router')

        deliveries_ingress_index = outs.attribute_names.index(
            'deliveriesIngress')
        deliveries_egress_index = outs.attribute_names.index(
            'deliveriesEgress')
        deliveries_transit_index = outs.attribute_names.index(
            'deliveriesTransit')

        results = outs.results[0]

        pre_ingress_count = results[deliveries_ingress_index]
        pre_egress_count = results[deliveries_egress_index]
        pre_transit_count = results[deliveries_transit_index]

        # Send and receive on the same router, router C
        test = IngressEgressTransitLinkRouteTest(address1, address2)
        test.run()
        local_node = Node.connect(address1, timeout=TIMEOUT)
        outs = local_node.query(type='org.apache.qpid.dispatch.router')

        deliveries_ingress_index = outs.attribute_names.index(
            'deliveriesIngress')
        deliveries_egress_index = outs.attribute_names.index(
            'deliveriesEgress')
        deliveries_transit_index = outs.attribute_names.index(
            'deliveriesTransit')

        results = outs.results[0]

        post_ingress_count = results[deliveries_ingress_index]
        post_egress_count = results[deliveries_egress_index]
        post_transit_count = results[deliveries_transit_index]

        # 10 messages entered the router, and 10 messages were echoed by router A and one mgmt request
        self.assertEqual(post_ingress_count - pre_ingress_count, 21)

        # 10 messages + 1 mgmt request
        self.assertEqual(post_egress_count - pre_egress_count, 11)

        # 10 messages went out this router
        self.assertEqual(post_transit_count - pre_transit_count, 10)
Ejemplo n.º 24
0
    def test_inter_router_plain_over_ssl_exists(self):
        """
        Tests to make sure that an inter-router connection exists between the routers since verifyHostname is 'no'.
        """
        local_node = Node.connect(self.routers[1].addresses[0], timeout=TIMEOUT)

        results = local_node.query(type='org.apache.qpid.dispatch.connection').results

        self.common_asserts(results)
Ejemplo n.º 25
0
    def test_inter_router_plain_over_ssl_exists(self):
        """
        Tests to make sure that an inter-router connection exists between the routers since verifyHostName is 'no'.
        """
        local_node = Node.connect(self.routers[1].addresses[0], timeout=TIMEOUT)

        results = local_node.query(type='org.apache.qpid.dispatch.connection').results

        self.common_asserts(results)
    def test_deprecated(self):
        """
        Tests deprecated attributes like linkRoutePattern, container, fixedAddress etc.
        This test makes executes a query for type='org.apache.qpid.dispatch.connection' over
        an unauthenticated listener to
        QDR.X and makes sure that the output has an "inter-router" connection to
        QDR.Y whose authentication is PLAIN. This ensures that QDR.Y did not
        somehow use SASL ANONYMOUS to connect to QDR.X
        Also makes sure that TLSv1/SSLv3 was used as sslProto

        """
        if not SASL.extended():
            self.skipTest("Cyrus library not available. skipping test")
            
        local_node = Node.connect(self.routers[0].addresses[1], timeout=TIMEOUT)

        # saslConfigName and saslConfigPath were set in the ContainerEntity. This tests makes sure that the
        # saslConfigName and saslConfigPath were loaded properly from the ContainerEntity.
        # ContainerEntity has been deprecated.

        # role should be inter-router
        self.assertEqual(u'inter-router', local_node.query(type='org.apache.qpid.dispatch.connection').results[0][3])

        # sasl must be plain
        self.assertEqual(u'PLAIN', local_node.query(type='org.apache.qpid.dispatch.connection').results[0][6])

        # user must be [email protected]
        self.assertEqual(u'*****@*****.**', local_node.query(type='org.apache.qpid.dispatch.connection').results[0][8])

        # Make sure that the deprecated linkRoutePattern is set up correctly
        query_response = local_node.query(type='org.apache.qpid.dispatch.router.config.linkRoute')

        self.assertEqual(2, len(query_response.results))
        self.assertEqual("in", query_response.results[0][7])
        self.assertEqual("out", query_response.results[1][7])

        results = local_node.query(type='org.apache.qpid.dispatch.router.config.address').results

        multicast_found = False
        spread_found = False
        closest_found = False

        for result in results:
            if result[3] == 'closest':
                closest_found = True
                self.assertEqual(result[4], 'closest')
            if result[3] == 'spread':
                spread_found = True
                self.assertEqual(result[4], 'balanced')
            if result[3] == 'multicast':
                multicast_found = True
                self.assertEqual(result[4], 'multicast')

        self.assertTrue(multicast_found)
        self.assertTrue(spread_found)
        self.assertTrue(closest_found)
 def test_entity_names(self):
     nodes = [self.cleanup(Node.connect(Url(r.addresses[0]))) for r in self.routers]
     # Test that all entities have a consitent identity format: type/name
     entities = list(chain(
         *[n.query(attribute_names=['type', 'identity', 'name']).iter_entities() for n in nodes]))
     for e in entities:
         if e.type == MANAGEMENT:
             self.assertEqual(e.identity, "self")
         else:
             self.assertRegexpMatches(e.identity, "^%s/" % short_name(e.type), e)
    def on_link_opened(self, event):
        if event.receiver == self.receiver:
            self.receiver_link_opened = True

            local_node = Node.connect(self.query_address_listening, timeout=TIMEOUT)
            out = local_node.query(type='org.apache.qpid.dispatch.router.link')

            link_dir_index = out.attribute_names.index("linkDir")
            owning_addr_index = out.attribute_names.index("owningAddr")

            # Make sure that the owningAddr M0pulp.task.terminusTestReceiver shows up on both in and out.
            # The 'out' link is on address M0pulp.task.terminusTestReceiver outgoing from the router B to the receiver
            # The 'in' link is on address M0pulp.task.terminusTestReceiver incoming from router C to router B
            for result in out.results:
                if result[link_dir_index] == 'in' and result[owning_addr_index] == 'M0pulp.task.terminusTestReceiver':
                    self.in_receiver_found = True
                if result[link_dir_index] == 'out' and result[owning_addr_index] == 'M0pulp.task.terminusTestReceiver':
                    self.out_receiver_found = True

        if event.sender == self.sender:
            self.sender_link_opened = True

            local_node = Node.connect(self.query_address_sending, timeout=TIMEOUT)
            out = local_node.query(type='org.apache.qpid.dispatch.router.link')

            link_dir_index = out.attribute_names.index("linkDir")
            owning_addr_index = out.attribute_names.index("owningAddr")

            # Make sure that the owningAddr M0pulp.task.terminusTestSender shows up on both in and out.
            # The 'in' link is on address M0pulp.task.terminusTestSender incoming from sender to router
            # The 'out' link is on address M0pulp.task.terminusTestSender outgoing from router C to router B
            for result in out.results:
                if result[link_dir_index] == 'in' and result[owning_addr_index] == 'M0pulp.task.terminusTestSender':
                    self.in_sender_found = True
                if result[link_dir_index] == 'out' and result[owning_addr_index] == 'M0pulp.task.terminusTestSender':
                    self.out_sender_found = True

        # Shutdown the connections only if the on_link_opened has been called for sender and receiver links.
        if self.sender_link_opened and self.receiver_link_opened:
            self.sender.close()
            self.receiver.close()
            self.sender_connection.close()
            self.receiver_connection.close()
Ejemplo n.º 29
0
    def test_deprecated(self):
        """
        Tests deprecated attributes like linkRoutePattern, container, fixedAddress etc.
        This test makes executes a query for type='org.apache.qpid.dispatch.connection' over
        an unauthenticated listener to
        QDR.X and makes sure that the output has an "inter-router" connection to
        QDR.Y whose authentication is PLAIN. This ensures that QDR.Y did not
        somehow use SASL ANONYMOUS to connect to QDR.X
        Also makes sure that TLSv1/SSLv3 was used as sslProto

        """
        local_node = Node.connect(self.routers[0].addresses[1], timeout=TIMEOUT)

        # saslConfigName and saslConfigPath were set in the ContainerEntity. This tests makes sure that the
        # saslConfigName and saslConfigPath were loaded properly from the ContainerEntity.
        # ContainerEntity has been deprecated.

        # role should be inter-router
        self.assertEqual(u"inter-router", local_node.query(type="org.apache.qpid.dispatch.connection").results[0][9])

        # sasl must be plain
        self.assertEqual(u"PLAIN", local_node.query(type="org.apache.qpid.dispatch.connection").results[0][12])

        # user must be [email protected]
        self.assertEqual(
            u"*****@*****.**", local_node.query(type="org.apache.qpid.dispatch.connection").results[0][16]
        )

        # Make sure that the deprecated linkRoutePattern is set up correctly
        query_response = local_node.query(type="org.apache.qpid.dispatch.router.config.linkRoute")

        self.assertEqual(2, len(query_response.results))
        self.assertEqual("in", query_response.results[0][7])
        self.assertEqual("out", query_response.results[1][7])

        results = local_node.query(type="org.apache.qpid.dispatch.router.config.address").results

        multicast_found = False
        spread_found = False
        closest_found = False

        for result in results:
            if result[3] == "closest":
                closest_found = True
                self.assertEqual(result[4], "closest")
            if result[3] == "spread":
                spread_found = True
                self.assertEqual(result[4], "balanced")
            if result[3] == "multicast":
                multicast_found = True
                self.assertEqual(result[4], "multicast")

        self.assertTrue(multicast_found)
        self.assertTrue(spread_found)
        self.assertTrue(closest_found)
    def test_link_route_ingress_egress_transit_counts(self):
        address1 = self.routers[2].addresses[0]
        address2 = self.routers[2].addresses[0]

        local_node = Node.connect(address1, timeout=TIMEOUT)
        outs = local_node.query(type='org.apache.qpid.dispatch.router')

        deliveries_ingress_index = outs.attribute_names.index('deliveriesIngress')
        deliveries_egress_index = outs.attribute_names.index('deliveriesEgress')
        deliveries_transit_index = outs.attribute_names.index('deliveriesTransit')

        results = outs.results[0]

        pre_ingress_count = results[deliveries_ingress_index]
        pre_egress_count = results[deliveries_egress_index]
        pre_transit_count = results[deliveries_transit_index]

        # Send and receive on the same router, router C
        test = IngressEgressTransitLinkRouteTest(address1, address2)
        test.run()
        local_node = Node.connect(address1, timeout=TIMEOUT)
        outs = local_node.query(type='org.apache.qpid.dispatch.router')

        deliveries_ingress_index = outs.attribute_names.index('deliveriesIngress')
        deliveries_egress_index = outs.attribute_names.index('deliveriesEgress')
        deliveries_transit_index = outs.attribute_names.index('deliveriesTransit')

        results = outs.results[0]

        post_ingress_count = results[deliveries_ingress_index]
        post_egress_count = results[deliveries_egress_index]
        post_transit_count = results[deliveries_transit_index]

        # 10 messages entered the router, and 10 messages were echoed by router A and one mgmt request
        self.assertEqual(post_ingress_count - pre_ingress_count, 21)

        # 10 messages + 1 mgmt request
        self.assertEqual(post_egress_count - pre_egress_count, 11)

        # 10 messages went out this router
        self.assertEqual(post_transit_count - pre_transit_count, 10)
    def test_01_pre_settled(self):
        test = DeliveriesInTransit(self.routers[0].addresses[0], self.routers[1].addresses[0])
        test.run()
        self.assertEqual(None, test.error)

        local_node = Node.connect(self.routers[0].addresses[0], timeout=TIMEOUT)
        outs = local_node.query(type='org.apache.qpid.dispatch.router')

        # deliveriesTransit must most surely be greater than num_msgs
        pos = outs.attribute_names.index("deliveriesTransit")
        results = outs.results[0]
        self.assertTrue(results[pos] > 104)
    def test_inter_router_plain_over_ssl_exists(self):
        """
        Tests to make sure that an inter-router connection exists between the routers since verifyHostName is 'no'.
        """
        if not SASL.extended():
            self.skipTest("Cyrus library not available. skipping test")

        local_node = Node.connect(self.routers[1].addresses[0], timeout=TIMEOUT)

        results = local_node.query(type='org.apache.qpid.dispatch.connection').results

        self.common_asserts(results)
    def on_start(self, event):
        self.timer       = event.reactor.schedule(TIMEOUT, Timeout(self))
        self.normal_conn = event.container.connect(self.normal_address)
        self.sender      = event.container.create_sender(self.normal_conn, self.dest)
        self.last_action = "Attached normal sender"

        local_node = Node.connect(self.normal_address, timeout=TIMEOUT)
        res = local_node.query(type='org.apache.qpid.dispatch.router')
        results = res.results[0]
        attribute_names = res.attribute_names
        if 8 == results[attribute_names.index('autoLinkCount')]:
            self.autolink_count_ok = True
Ejemplo n.º 34
0
 def is_router_connected(self, router_id, **retry_kwargs):
     try:
         self.management.read(identity="router.node/%s" % router_id)
         # TODO aconway 2015-01-29: The above check should be enough, we
         # should not advertise a remote router in managment till it is fully
         # connected. However we still get a race where the router is not
         # actually ready for traffic. Investigate.
         # Meantime the following actually tests send-thru to the router.
         node = Node.connect(self.addresses[0], router_id, timeout=1)
         return retry_exception(lambda: node.query('org.apache.qpid.dispatch.router'))
     except:
         return False
Ejemplo n.º 35
0
 def is_router_connected(self, router_id, **retry_kwargs):
     try:
         self.management.read(identity="router.node/%s" % router_id)
         # TODO aconway 2015-01-29: The above check should be enough, we
         # should not advertise a remote router in managment till it is fully
         # connected. However we still get a race where the router is not
         # actually ready for traffic. Investigate.
         # Meantime the following actually tests send-thru to the router.
         node = Node.connect(self.addresses[0], router_id, timeout=1)
         return retry_exception(lambda: node.query('org.apache.qpid.dispatch.router'))
     except:
         return False
    def test_deprecated(self):
        """
        Tests deprecated attributes like linkRoutePattern, container, fixedAddress etc.
        This test makes executes a query for type='org.apache.qpid.dispatch.connection' over
        an unauthenticated listener to
        QDR.X and makes sure that the output has an "inter-router" connection to
        QDR.Y whose authentication is PLAIN. This ensures that QDR.Y did not
        somehow use SASL ANONYMOUS to connect to QDR.X
        Also makes sure that TLSv1/SSLv3 was used as sslProto

        """
        local_node = Node.connect(self.routers[0].addresses[1], timeout=TIMEOUT)

        # saslConfigName and saslConfigPath were set in the ContainerEntity. This tests makes sure that the
        # saslConfigName and saslConfigPath were loaded properly from the ContainerEntity.
        # ContainerEntity has been deprecated.

        # role should be inter-router
        self.assertEqual(u'inter-router', local_node.query(type='org.apache.qpid.dispatch.connection').results[0][9])

        # sasl must be plain
        self.assertEqual(u'PLAIN', local_node.query(type='org.apache.qpid.dispatch.connection').results[0][12])

        # user must be [email protected]
        self.assertEqual(u'*****@*****.**', local_node.query(type='org.apache.qpid.dispatch.connection').results[0][16])

        # Make sure that the deprecated linkRoutePattern is set up correctly
        query_response = local_node.query(type='org.apache.qpid.dispatch.router.config.linkRoute')

        self.assertEqual(2, len(query_response.results))
        self.assertEqual("in", query_response.results[0][7])
        self.assertEqual("out", query_response.results[1][7])

        results = local_node.query(type='org.apache.qpid.dispatch.router.config.address').results

        multicast_found = False
        spread_found = False
        closest_found = False

        for result in results:
            if result[3] == 'closest':
                closest_found = True
                self.assertEqual(result[4], 'closest')
            if result[3] == 'spread':
                spread_found = True
                self.assertEqual(result[4], 'balanced')
            if result[3] == 'multicast':
                multicast_found = True
                self.assertEqual(result[4], 'multicast')

        self.assertTrue(multicast_found)
        self.assertTrue(spread_found)
        self.assertTrue(closest_found)
    def test_aaa_partial_link_route_match(self):
        """
        The linkRoutePattern on Routers C and B is set to org.apache.
        Creates a receiver listening on the address 'org.apache.dev' and a sender that sends to address 'org.apache.dev'.
        Sends a message to org.apache.dev via router QDR.C and makes sure that the message was successfully
        routed (using partial address matching) and received using pre-created links that were created as a
        result of specifying addresses in the linkRoutePattern attribute('org.apache.').
        """
        hello_world_1 = "Hello World_1!"

        # Connects to listener #2 on QDR.C
        addr = self.routers[2].addresses[1]

        blocking_connection = BlockingConnection(addr)

        # Receive on org.apache.dev
        blocking_receiver = blocking_connection.create_receiver(address="org.apache.dev")

        apply_options = AtMostOnce()

        # Sender to  to org.apache.dev
        blocking_sender = blocking_connection.create_sender(address="org.apache.dev", options=apply_options)
        msg = Message(body=hello_world_1)
        # Send a message
        blocking_sender.send(msg)

        received_message = blocking_receiver.receive()

        self.assertEqual(hello_world_1, received_message.body)

        # Connect to the router acting like the broker (QDR.A) and check the deliveriesIngress and deliveriesEgress
        local_node = Node.connect(self.routers[0].addresses[0], timeout=TIMEOUT)
        self.assertEqual(u'QDR.A', local_node.query(type='org.apache.qpid.dispatch.router',
                                                    attribute_names=['routerId']).results[0][0])

        self.assertEqual(1, local_node.read(type='org.apache.qpid.dispatch.router.address',
                                            name='router.address/M0org.apache.dev').deliveriesEgress,
                         "deliveriesEgress is wrong")
        self.assertEqual(1, local_node.read(type='org.apache.qpid.dispatch.router.address',
                                            name='router.address/M0org.apache.dev').deliveriesIngress,
                         "deliveriesIngress is wrong")

        # There should be 4 links -
        # 1. outbound receiver link on org.apache.dev
        # 2. inbound sender link on blocking_sender
        # 3. inbound link to the $management
        # 4. outbound link to $management
        # self.assertEqual(4, len()
        self.assertEquals(4, len(local_node.query(type='org.apache.qpid.dispatch.router.link').results))

        #blocking_receiver.close()
        blocking_connection.close()
Ejemplo n.º 38
0
 def get_router_nodes(self):
     """
     Retrieves connected router nodes.
     :return:
     """
     url = Url("amqp://0.0.0.0:%d/$management" % self.PORT_NO_SSL)
     node = Node.connect(url)
     response = node.query(type="org.apache.qpid.dispatch.router.node", attribute_names=["id"])
     router_nodes = []
     for resp in response.get_dicts():
         router_nodes.append(resp['id'])
     node.close()
     return router_nodes
Ejemplo n.º 39
0
    def test_route_container_ingress(self):
        regular_addr = self.router.addresses[0]
        route_container_addr = self.router.addresses[1]
        test = RouteContainerIngressTest(route_container_addr, regular_addr)
        test.run()

        local_node = Node.connect(regular_addr, timeout=TIMEOUT)
        outs = local_node.query(type='org.apache.qpid.dispatch.router')

        deliveries_ingress_route_container_index = outs.attribute_names.index('deliveriesIngressRouteContainer')

        results = outs.results[0]
        self.assertEqual(results[deliveries_ingress_route_container_index], 20)
    def test_route_container_ingress(self):
        regular_addr = self.router.addresses[0]
        route_container_addr = self.router.addresses[1]
        test = RouteContainerIngressTest(route_container_addr, regular_addr)
        test.run()

        local_node = Node.connect(regular_addr, timeout=TIMEOUT)
        outs = local_node.query(type='org.apache.qpid.dispatch.router')

        deliveries_ingress_route_container_index = outs.attribute_names.index('deliveriesIngressRouteContainer')

        results = outs.results[0]
        self.assertEqual(results[deliveries_ingress_route_container_index], 20)
Ejemplo n.º 41
0
    def test_create_listener(self):
        """Create a new listener on a running router"""

        port = self.get_port()
        # Note qdrouter schema defines port as string not int, since it can be a service name.
        attributes = {'name':'foo', 'port':str(port), 'role':'normal', 'saslMechanisms': 'ANONYMOUS', 'authenticatePeer': False}
        entity = self.assert_create_ok(LISTENER, 'foo', attributes)
        self.assertEqual(entity['name'], 'foo')
        self.assertEqual(entity['host'], '')

        # Connect via the new listener
        node3 = self.cleanup(Node.connect(Url(port=port)))
        router = node3.query(type=ROUTER).get_entities()
        self.assertEqual(self.router.name, router[0]['id'])
Ejemplo n.º 42
0
    def test_connection_properties(self):
        connection = BlockingConnection(self.router.addresses[0],
                                        timeout=60,
                                        properties=CONNECTION_PROPERTIES)
        client = SyncRequestResponse(connection)

        node = Node.connect(self.router.addresses[0])

        results = [[{u'connection': u'properties', u'int_property': 6451}], [{}]]

        self.assertEqual(node.query(type='org.apache.qpid.dispatch.connection', attribute_names=['properties']).results,
                         results)

        client.connection.close()
    def test_connection_properties(self):
        connection = BlockingConnection(self.router.addresses[0],
                                        timeout=60,
                                        properties=CONNECTION_PROPERTIES)
        client = SyncRequestResponse(connection)

        node = Node.connect(self.router.addresses[0])

        results = node.query(type='org.apache.qpid.dispatch.connection', attribute_names=[u'properties']).results

        self.assertEqual(results[0][0][u'connection'], u'properties')
        self.assertEqual(results[0][0][u'int_property'], 6451)

        client.connection.close()
Ejemplo n.º 44
0
    def test_inter_router_plain_over_ssl_exists(self):
        """
        Tests to make sure that an inter-router connection exists between the routers since verifyHostName is 'no'.
        """
        if not SASL.extended():
            self.skipTest("Cyrus library not available. skipping test")

        local_node = Node.connect(self.routers[1].addresses[0],
                                  timeout=TIMEOUT)

        results = local_node.query(
            type='org.apache.qpid.dispatch.connection').results

        self.common_asserts(results)
Ejemplo n.º 45
0
 def test_entity_names(self):
     nodes = [self.cleanup(Node.connect(Url(r.addresses[0]))) for r in self.routers]
     # Test that all entities have a consitent identity format: type/name
     entities = list(chain(
         *[n.query(attribute_names=['type', 'identity', 'name']).iter_entities() for n in nodes]))
     for e in entities:
         if e.type == MANAGEMENT:
             self.assertEqual(e.identity, "self")
         else:
             if e.type == 'org.apache.qpid.dispatch.connection':
                 # This will make sure that the identity of the connection object is always numeric
                 self.assertRegexpMatches(str(e.identity), "[1-9]+", e)
             else:
                 self.assertRegexpMatches(e.identity, "^%s/" % short_name(e.type), e)
Ejemplo n.º 46
0
    def test_one_router_rejected_counts(self):
        address = self.router.addresses[0]

        test = RejectedDeliveriesTest(address)
        test.run()

        local_node = Node.connect(address, timeout=TIMEOUT)
        outs = local_node.query(type='org.apache.qpid.dispatch.router')

        deliveries_rejected_index = outs.attribute_names.index('rejectedDeliveries')

        results = outs.results[0]

        self.assertEqual(results[deliveries_rejected_index], 10)
 def test_entity_names(self):
     nodes = [self.cleanup(Node.connect(Url(r.addresses[0]))) for r in self.routers]
     # Test that all entities have a consitent identity format: type/name
     entities = list(chain(
         *[n.query(attribute_names=['type', 'identity', 'name']).iter_entities() for n in nodes]))
     for e in entities:
         if e.type == MANAGEMENT:
             self.assertEqual(e.identity, "self")
         else:
             if e.type == 'org.apache.qpid.dispatch.connection':
                 # This will make sure that the identity of the connection object is always numeric
                 self.assertRegexpMatches(str(e.identity), "[1-9]+", e)
             else:
                 self.assertRegexpMatches(e.identity, "^%s/" % short_name(e.type), e)
    def test_one_router_rejected_counts(self):
        address = self.router.addresses[0]

        test = RejectedDeliveriesTest(address)
        test.run()

        local_node = Node.connect(address, timeout=TIMEOUT)
        outs = local_node.query(type='org.apache.qpid.dispatch.router')

        deliveries_rejected_index = outs.attribute_names.index('rejectedDeliveries')

        results = outs.results[0]

        self.assertEqual(results[deliveries_rejected_index], 10)
Ejemplo n.º 49
0
    def test_zzz_delete_create_connector(self):
        """
        Delete an ssl profile before deleting the connector and make sure it fails.
        Delete an ssl profile after deleting the connector and make sure it succeeds.
        Re-add the deleted connector and associate it with an ssl profile and make sure
        that the two routers are able to communicate over the connection.
        """
        if not SASL.extended():
            self.skipTest("Cyrus library not available. skipping test")

        ssl_profile_name = 'client-ssl-profile'

        delete_command = 'DELETE --type=sslProfile --name=' + ssl_profile_name

        cannot_delete = False
        try:
            json.loads(
                self.run_qdmanage(delete_command,
                                  address=self.routers[1].addresses[0]))
        except Exception as e:
            cannot_delete = True
            self.assertTrue(
                'ForbiddenStatus: SSL Profile is referenced by other listeners/connectors'
                in e.message)

        self.assertTrue(cannot_delete)

        # Deleting the connector
        delete_command = 'DELETE --type=connector --name=connectorToX'
        self.run_qdmanage(delete_command, address=self.routers[1].addresses[0])

        #Assert here that the connection to QDR.X is gone

        # Re-add connector
        connector_create_command = 'CREATE --type=connector name=connectorToX host=127.0.0.1 port=' + \
                                   str(RouterTestVerifyHostNameNo.x_listener_port) + \
                                   ' saslMechanisms=PLAIN sslProfile=' + ssl_profile_name + \
                                   ' role=inter-router verifyHostName=no [email protected]' \
                                   ' saslPassword=password'

        json.loads(
            self.run_qdmanage(connector_create_command,
                              address=self.routers[1].addresses[0]))
        self.routers[1].wait_connectors()
        local_node = Node.connect(self.routers[1].addresses[0],
                                  timeout=TIMEOUT)
        results = local_node.query(
            type='org.apache.qpid.dispatch.connection').results
        self.common_asserts(results)
Ejemplo n.º 50
0
 def test_no_inter_router_connection(self):
     """
     Tests to make sure that there are no 'inter-router' connections.
     The connection to the other router will not happen because the connection failed
     due to setting 'verifyHostname': 'yes'
     """
     local_node = Node.connect(self.routers[1].addresses[0], timeout=TIMEOUT)
     results = local_node.query(type='org.apache.qpid.dispatch.connection').results
     # There should be only two connections.
     # There will be no inter-router connection
     self.assertEqual(2, len(results))
     self.assertEqual('in', results[0][4])
     self.assertEqual('normal', results[0][3])
     self.assertEqual('anonymous', results[0][8])
     self.assertEqual('normal', results[1][3])
     self.assertEqual('anonymous', results[1][8])
Ejemplo n.º 51
0
    def test_router_node(self):
        """Test node entity in a trio of linked routers"""
        nodes = [self.cleanup(Node.connect(Url(r.addresses[0]))) for r in self.routers]
        rnode_lists = [n.query(type=NODE).get_dicts() for n in nodes]

        def check(attrs):
            name = attrs['id']
            self.assertEqual(attrs['identity'], 'router.node/%s' % name)
            self.assertEqual(attrs['name'], 'router.node/%s' % name)
            self.assertEqual(attrs['type'], 'org.apache.qpid.dispatch.router.node')
            self.assertEqual(attrs['address'], 'amqp:/_topo/0/%s' % name)
            return name

        self.assertEqual(set(["router0", "router1", "router2"]), set([check(n) for n in rnode_lists[0]]))
        self.assertEqual(set(["router0", "router1", "router2"]), set([check(n) for n in rnode_lists[1]]))
        self.assertEqual(set(["router0", "router1", "router2"]), set([check(n) for n in rnode_lists[2]]))
Ejemplo n.º 52
0
    def get_router_nodes(self):
        """
        Retrieves connected router nodes.
        :return:
        """
        if not SASL.extended():
            self.skipTest("Cyrus library not available. skipping test")

        url = Url("amqp://0.0.0.0:%d/$management" % self.PORT_NO_SSL)
        node = Node.connect(url)
        response = node.query(type="org.apache.qpid.dispatch.router.node", attribute_names=["id"])
        router_nodes = []
        for resp in response.get_dicts():
            router_nodes.append(resp['id'])
        node.close()
        return router_nodes
    def test_one_router_ingress_egress_counts(self):
        address = self.router.addresses[0]

        test = IngressEgressOneRouterTest(address)
        test.run()

        local_node = Node.connect(address, timeout=TIMEOUT)
        outs = local_node.query(type='org.apache.qpid.dispatch.router')

        deliveries_ingress_index = outs.attribute_names.index('deliveriesIngress')
        deliveries_egress_index = outs.attribute_names.index('deliveriesEgress')

        results = outs.results[0]

        self.assertEqual(results[deliveries_ingress_index], 11)
        self.assertEqual(results[deliveries_egress_index], 10)
Ejemplo n.º 54
0
 def test_no_inter_router_connection(self):
     """
     Tests to make sure that there are no 'inter-router' connections.
     The connection to the other router will not happen because the connection failed
     due to setting 'verifyHostname': 'yes'
     """
     local_node = Node.connect(self.routers[1].addresses[0], timeout=TIMEOUT)
     results = local_node.query(type='org.apache.qpid.dispatch.connection').results
     # There should be only two connections.
     # There will be no inter-router connection
     self.assertEqual(2, len(results))
     self.assertEqual('in', results[0][4])
     self.assertEqual('normal', results[0][3])
     self.assertEqual('anonymous', results[0][8])
     self.assertEqual('normal', results[1][3])
     self.assertEqual('anonymous', results[1][8])
Ejemplo n.º 55
0
    def get_router_nodes(self):
        """
        Retrieves connected router nodes.
        :return:
        """
        if not SASL.extended():
            self.skipTest("Cyrus library not available. skipping test")

        url = Url("amqp://0.0.0.0:%d/$management" % self.PORT_NO_SSL)
        node = Node.connect(url)
        response = node.query(type="org.apache.qpid.dispatch.router.node", attribute_names=["id"])
        router_nodes = []
        for resp in response.get_dicts():
            router_nodes.append(resp['id'])
        node.close()
        return router_nodes
    def test_full_link_route_match(self):
        """
        The linkRoutePattern on Routers C and B is set to org.apache.
        Creates a receiver listening on the address 'org.apache' and a sender that sends to address 'org.apache'.
        Sends a message to org.apache via router QDR.C and makes sure that the message was successfully
        routed (using full address matching) and received using pre-created links that were created as a
        result of specifying addresses in the linkRoutePattern attribute('org.apache.').
        """
        hello_world_3 = "Hello World_3!"
        # Connects to listener #2 on QDR.C
        addr = self.routers[2].addresses[1]

        blocking_connection = BlockingConnection(addr)

        # Receive on org.apache
        blocking_receiver = blocking_connection.create_receiver(address="org.apache")

        apply_options = AtMostOnce()

        # Sender to  to org.apache
        blocking_sender = blocking_connection.create_sender(address="org.apache", options=apply_options)
        msg = Message(body=hello_world_3)
        # Send a message
        blocking_sender.send(msg)

        received_message = blocking_receiver.receive()

        self.assertEqual(hello_world_3, received_message.body)

        local_node = Node.connect(self.routers[0].addresses[0], timeout=TIMEOUT)

        # Make sure that the router node acting as the broker (QDR.A) had one message routed through it. This confirms
        # that the message was link routed
        self.assertEqual(1, local_node.read(type='org.apache.qpid.dispatch.router.address',
                                            name='router.address/M0org.apache').deliveriesEgress,
                         "deliveriesEgress is wrong")

        self.assertEqual(1, local_node.read(type='org.apache.qpid.dispatch.router.address',
                                            name='router.address/M0org.apache').deliveriesIngress,
                         "deliveriesIngress is wrong")

        #blocking_receiver.close()
        blocking_connection.close()