コード例 #1
0
    def check_connector_delete(self, client_addr, server_addr):
        # Run curl 127.0.0.1:port --http2-prior-knowledge
        # We are first making sure that the http request goes thru successfully.
        out = self.run_curl(client_addr)

        # Run a qdmanage query on connections to see how many qdr_connections are
        # there on the egress router
        qd_manager = QdManager(self, address=server_addr)

        connections = qd_manager.query('org.apache.qpid.dispatch.connection')

        self.assertGreaterEqual(len(connections), 2)

        server_conn_found = False
        for conn in connections:
            if os.environ['SERVER_LISTEN_PORT'] in conn['name']:
                server_conn_found = True
                break
        self.assertTrue(server_conn_found)

        # Run a qdmanage DELETE on the httpConnector
        http_connectors  = qd_manager.query('org.apache.qpid.dispatch.httpConnector')
        self.assertEqual(len(http_connectors), 1)

        # Delete the httpConnector
        qd_manager.delete("org.apache.qpid.dispatch.httpConnector", name=self.connector_name)

        # Make sure the connector is gone
        http_connectors  = qd_manager.query('org.apache.qpid.dispatch.httpConnector')
        self.assertEqual(len(http_connectors), 0)

        # Deleting the connector must have taken out the connection to the server.
        connections = qd_manager.query('org.apache.qpid.dispatch.connection')
        http_server_conn_found = False
        for conn in connections:
            if os.environ['SERVER_LISTEN_PORT'] in conn['name']:
                server_conn_found = True
                break
        self.assertFalse(http_server_conn_found)

        sleep(2)

        # Now, run a curl client GET request with a timeout
        request_timed_out = False
        try:
            out = self.run_curl(client_addr, timeout=5)
            print(out)
        except Exception as e:
            request_timed_out = True

        self.assertTrue(request_timed_out)

        # Add back the httpConnector
        # qdmanage CREATE type=httpConnector address=examples.com host=127.0.0.1 port=80 protocolVersion=HTTP2
        create_result = qd_manager.create("org.apache.qpid.dispatch.httpConnector", self.connector_props)
        num_tries = 2
        tries = 0
        conn_present = False
        while tries < num_tries:
            connections = qd_manager.query('org.apache.qpid.dispatch.connection')
            tries += 1
            if (len(connections) < 2):
                sleep(2)
            else:
                conn_present = True
        self.assertTrue(conn_present)

        out = self.run_curl(client_addr)
        ret_string = ""
        i = 0
        while (i < 1000):
            ret_string += str(i) + ","
            i += 1
        self.assertIn(ret_string, out)
コード例 #2
0
    def test_name_collision(self):
        args = {"name": "autoLink", "address": "autoLink1", "connection": "broker", "dir": "in"}
        # Add autoLink with the same name as the one already present.
        al_long_type = 'org.apache.qpid.dispatch.router.config.autoLink'
        addr_long_type = 'org.apache.qpid.dispatch.router.config.address'
        lr_long_type = 'org.apache.qpid.dispatch.router.config.linkRoute'
        mgmt = QdManager(self, address=self.router.addresses[0])
        test_pass = False
        try:
            mgmt.create(al_long_type, args)
        except Exception as e:
            if "BadRequestStatus: Name conflicts with an existing entity" in str(e):
                test_pass = True
        self.assertTrue(test_pass)

        # Try to add duplicate linkRoute and make sure it fails
        args = {"name": "linkRoute", "prefix": "linkRoute",
                "connection": "broker", "dir": "in"}

        mgmt = QdManager(self, address=self.router.addresses[0])
        test_pass = False
        try:
            mgmt.create(lr_long_type, args)
        except Exception as e:
            if "BadRequestStatus: Name conflicts with an existing entity" in str(e):
                test_pass = True
        self.assertTrue(test_pass)

        args = {"name": "address", "prefix": "address.1",
                "waypoint": "yes"}
        mgmt = QdManager(self, address=self.router.addresses[0])
        test_pass = False
        try:
            mgmt.create(addr_long_type, args)
        except Exception as e:
            if "BadRequestStatus: Name conflicts with an existing entity" in str(e):
                test_pass = True
        self.assertTrue(test_pass)

        # The linkRoutes, autoLinks and addrConfigs share the same hashtable
        # but with a prefix.
        # The following tests make sure that same names used on
        # different entities are allowed.

        # insert a linkRoute with the name of an existing autoLink and make
        # sure that is ok
        args = {"name": "autoLink", "prefix": "linkRoute",
                "connection": "broker", "dir": "in"}
        mgmt = QdManager(self, address=self.router.addresses[0])
        mgmt.create(lr_long_type, args)

        # insert a linkRoute with the name of an existing addr config and make
        # sure that is ok
        args = {"name": "address", "prefix": "linkRoute",
                "connection": "broker", "dir": "in"}
        mgmt = QdManager(self, address=self.router.addresses[0])
        mgmt.create(lr_long_type, args)

        # insert an autoLink with the name of an existing linkRoute and make
        # sure that is ok
        args = {"name": "linkRoute", "address": "autoLink1", "connection": "broker", "dir": "in"}
        mgmt = QdManager(self, address=self.router.addresses[0])
        mgmt.create(al_long_type, args)

        # insert an autoLink with the name of an existing address and make
        # sure that is ok
        args = {"name": "address", "address": "autoLink1", "connection": "broker", "dir": "in"}
        al_long_type = 'org.apache.qpid.dispatch.router.config.autoLink'
        mgmt = QdManager(self, address=self.router.addresses[0])
        mgmt.create(al_long_type, args)

        # insert an address with the name of an existing autoLink and make
        # sure that is ok
        args = {"name": "autoLink", "prefix": "address.2",
                "waypoint": "yes"}
        mgmt = QdManager(self, address=self.router.addresses[0])
        mgmt.create(addr_long_type, args)

        # insert an autoLink with the name of an existing linkRoute and make
        # sure that is ok
        args = {"name": "linkRoute", "prefix": "address.3",
                "waypoint": "yes"}
        mgmt = QdManager(self, address=self.router.addresses[0])
        mgmt.create(addr_long_type, args)