Ejemplo n.º 1
0
    def test_inter_router_protocol_trace(self):
        qd_manager = QdManager(self, self.address)

        # The router already has trace logging turned on for all connections.
        # Get the connection id of the inter-router connection
        results = qd_manager.query("org.apache.qpid.dispatch.connection")
        conn_id = None
        for result in results:
            if result['role'] == 'inter-router':
                conn_id = result['identity']

        # Turn off trace logging for the inter-router connection. This update command is run async by the router
        # so we need to sleep a bit before the operation is actually completed.
        qd_manager.update("org.apache.qpid.dispatch.connection",
                          {"enableProtocolTrace": "false"},
                          identity=conn_id)
        time.sleep(1)

        num_transfers = self._get_transfer_frame_count(conn_id)

        # Create a receiver. This will send an MAU update to the other router but we should not see any of that
        # in the log since the trace logging for the inter-router connection has been turned off.
        TEST_ADDR_1 = "EnableConnectionLevelProtocolTraceTest1"
        conn_2 = BlockingConnection(self.address)
        conn_2.create_receiver(address=TEST_ADDR_1)
        # Give some time for the MAU to go over the inter-router connection.
        time.sleep(2)
        num_transfers_after_update = self._get_transfer_frame_count(conn_id)

        # Since there will be no transfer frames printed in the log, there should be no more new transfers in the
        # log file.
        self.assertEqual(num_transfers_after_update, num_transfers)

        # Turn on trace logging for the inter-router connection
        qd_manager.update("org.apache.qpid.dispatch.connection",
                          {"enableProtocolTrace": "yes"},
                          identity=conn_id)

        # Create a receiver and make sure the MAU update is NOT seen on the inter-router connection log
        TEST_ADDR_2 = "EnableConnectionLevelProtocolTraceTest2"
        conn_1 = BlockingConnection(self.address)
        conn_1.create_receiver(address=TEST_ADDR_2)

        # Give time for the MAU to be generated.
        time.sleep(2)

        num_transfers_after_update = self._get_transfer_frame_count(conn_id)

        # Since we have now turned on trace logging for the inter-router connection, we should see
        # additional transfer frames in the log and we check that here.
        self.assertGreater(num_transfers_after_update, num_transfers)
        conn_1.close()
        conn_2.close()
Ejemplo n.º 2
0
    def test_inter_router_protocol_trace(self):
        qd_manager = QdManager(self, self.address)
        # Turn off trace logging on all connections for Router B.
        qd_manager.update("org.apache.qpid.dispatch.log", {"enable": "info+"},
                          name="log/DEFAULT")

        # Get the connection id of the inter-router connection
        results = qd_manager.query("org.apache.qpid.dispatch.connection")
        conn_id = None
        for result in results:
            if result[u'role'] == u'inter-router':
                conn_id = result[u'identity']

        # Turn on trace logging for the inter-router connection
        qd_manager.update("org.apache.qpid.dispatch.connection",
                          {"enableProtocolTrace": "true"},
                          identity=conn_id)

        # Create a receiver and make sure the MAU update is seen on the inter-router connection log
        TEST_ADDR_1 = "EnableConnectionLevelProtocolTraceTest1"
        conn_2 = BlockingConnection(self.address)
        blocking_receiver_1 = conn_2.create_receiver(address=TEST_ADDR_1)

        # Give some time for the MAU to go over the inter-router link
        time.sleep(2)
        logs = qd_manager.get_log()
        mau_found = False
        for log in logs:
            if u'PROTOCOL' in log[0]:
                if "@transfer" in log[2] and TEST_ADDR_1 in log[
                        2] and "MAU" in log[2]:
                    mau_found = True
                    break

        self.assertTrue(mau_found)

        # Turn off trace logging for the inter-router connection
        qd_manager.update("org.apache.qpid.dispatch.connection",
                          {"enableProtocolTrace": "no"},
                          identity=conn_id)

        # Create a receiver and make sure the MAU update is NOT seen on the inter-router connection log
        TEST_ADDR_2 = "EnableConnectionLevelProtocolTraceTest2"
        conn_1 = BlockingConnection(self.address)
        blocking_receiver_2 = conn_1.create_receiver(address=TEST_ADDR_2)

        time.sleep(1)

        logs = qd_manager.get_log()
        mau_found = False
        for log in logs:
            if u'PROTOCOL' in log[0]:
                if "@transfer" in log[2] and TEST_ADDR_2 in log[
                        2] and "MAU" in log[2]:
                    mau_found = True
                    break

        self.assertFalse(mau_found)
        conn_1.close()
        conn_2.close()
Ejemplo n.º 3
0
    def test_enable_protocol_trace_on_non_existent_connection(self):
        qd_manager = QdManager(self, self.address)

        bad_request = False

        try:
            # Turn on trace logging for connection with invalid or non-existent identity
            outs = qd_manager.update("org.apache.qpid.dispatch.connection", {"enableProtocolTrace": "true"}, identity='G10000')
        except Exception as e:
            if "BadRequestStatus" in str(e):
                bad_request = True

        self.assertTrue(bad_request)
Ejemplo n.º 4
0
    def test_02_toggle_server_trace_logging(self):
        """
        This test is similar to test_01_toggle_default_trace_logging but it tests the
        SERVER log level.
        """
        hello_world_5 = "Hello World_5!"
        hello_world_6 = "Hello World_6!"
        hello_world_7 = "Hello World_7!"
        TEST_ADDR = "apachetest5"

        # Step 1. Turn off trace logging for module DEFAULT and enable trace logging
        #         for the PROTOCOL module and make sure it works.
        qd_manager = QdManager(self, self.address)
        # Set log level to info+ on the DEFAULT module
        qd_manager.update("org.apache.qpid.dispatch.log", {"enable": "info+"}, name="log/DEFAULT")
        # Set log level to trace+ on the PROTOCOL module
        qd_manager.update("org.apache.qpid.dispatch.log", {"enable": "trace+"}, name="log/PROTOCOL")
        blocking_connection = BlockingConnection(self.address)

        self.create_sender_receiver(TEST_ADDR, hello_world_5,
                                    blocking_connection)
        # Count the number of attaches for address TEST_ADDR, there should be 4
        num_attaches = 0
        logs = qd_manager.get_log()
        for log in logs:
            if 'PROTOCOL' in log[0]:
                if "@attach" in log[2] and TEST_ADDR in log[2]:
                    num_attaches += 1
        # There should be 4 attach frames with address TEST_ADDR
        # because we turned on trace logging.
        self.assertTrue(num_attaches == 4)

        TEST_ADDR = "apachetest6"
        qd_manager.update("org.apache.qpid.dispatch.log", {"enable": "info+"}, name="log/PROTOCOL")

        self.create_sender_receiver(TEST_ADDR, hello_world_6, blocking_connection)

        # Count the number of attaches for address TEST_ADDR, there should be 0
        num_attaches = 0
        logs = qd_manager.get_log()
        for log in logs:
            if 'PROTOCOL' in log[0]:
                if "@attach" in log[2] and TEST_ADDR in log[2]:
                    num_attaches += 1
        self.assertTrue(num_attaches == 0)

        # Create a brand new blocking connection  and make sure that connection
        # is logging at info level as well.
        TEST_ADDR = "apachetest7"
        self.create_sender_receiver(TEST_ADDR, hello_world_7)
        num_attaches = 0
        logs = qd_manager.get_log()
        for log in logs:
            if 'PROTOCOL' in log[0]:
                if "@attach" in log[2] and TEST_ADDR in log[2]:
                    num_attaches += 1

        self.assertTrue(num_attaches == 0)
    def test_01_toggle_default_trace_logging(self):
        hello_world_1 = "Hello World_1!"
        hello_world_2 = "Hello World_2!"
        hello_world_3 = "Hello World_3!"
        hello_world_4 = "Hello World_4!"
        qd_manager = QdManager(self, self.address)

        blocking_connection = BlockingConnection(self.address)
        TEST_ADDR = "apachetest1"
        self.create_sender_receiver(TEST_ADDR, hello_world_1,
                                    blocking_connection)

        # STEP 1: Make sure that proton trace logging is turned on already.
        # Search for attach frames in the log for address TEST_ADDR. There should be 4 attaches
        num_attaches = 0
        logs = qd_manager.get_log()
        for log in logs:
            if u'SERVER' in log[0]:
                if "@attach" in log[2] and TEST_ADDR in log[2]:
                    num_attaches += 1
        # num_attaches for address TEST_ADDR must be 4, two attaches to/from sender and receiver
        self.assertTrue(num_attaches == 4)

        # STEP 2: Turn off trace logging using qdmanage
        qd_manager.update("org.apache.qpid.dispatch.log", {"enable": "info+"},
                          name="log/DEFAULT")

        # Step 3: Now, router trace logging is turned off (has been set to info+)
        # Create the sender and receiver again on a different address and make
        # sure that the attaches are NOT showing in the log for that address.

        TEST_ADDR = "apachetest2"
        self.create_sender_receiver(TEST_ADDR, hello_world_2,
                                    blocking_connection)

        # STEP 3: Count the nimber of attaches for address TEST_ADDR, there should be none
        num_attaches = 0
        logs = qd_manager.get_log()
        for log in logs:
            if u'SERVER' in log[0]:
                if "@attach" in log[2] and TEST_ADDR in log[2]:
                    num_attaches += 1
        # There should be no attach frames with address TEST_ADDR
        # because we turned of trace logging.
        self.assertTrue(num_attaches == 0)

        # STEP 4: Tuen trace logging back on again and make sure num_attaches = 4
        TEST_ADDR = "apachetest3"
        qd_manager.update("org.apache.qpid.dispatch.log", {"enable": "trace+"},
                          name="log/DEFAULT")
        self.create_sender_receiver(TEST_ADDR, hello_world_3,
                                    blocking_connection)

        # STEP 3: Count the number of attaches for address TEST_ADDR, there should be 4
        num_attaches = 0
        logs = qd_manager.get_log()
        for log in logs:
            if u'SERVER' in log[0]:
                if "@attach" in log[2] and TEST_ADDR in log[2]:
                    num_attaches += 1
        # There should be 4 attach frames with address TEST_ADDR
        # because we turned on trace logging.
        self.assertTrue(num_attaches == 4)

        # Create a brand new blocking connection  and make sure that connection
        # is logging at trace level as well.
        num_attaches = 0
        TEST_ADDR = "apachetest4"
        self.create_sender_receiver(TEST_ADDR, hello_world_4)
        num_attaches = 0
        logs = qd_manager.get_log()
        for log in logs:
            if u'SERVER' in log[0]:
                if "@attach" in log[2] and TEST_ADDR in log[2]:
                    num_attaches += 1

        self.assertTrue(num_attaches == 4)
Ejemplo n.º 6
0
    def test_turn_on_protocol_trace(self):
        hello_world_0 = "Hello World_0!"
        qd_manager = QdManager(self, self.address)
        blocking_connection = BlockingConnection(self.address)

        TEST_ADDR = "moduletest0"
        self.create_sender_receiver(TEST_ADDR, hello_world_0,
                                    blocking_connection)

        num_attaches = 0
        logs = qd_manager.get_log()
        for log in logs:
            if u'PROTOCOL' in log[0]:
                if "@attach" in log[2] and TEST_ADDR in log[2]:
                    num_attaches += 1

        # num_attaches for address TEST_ADDR must be 4, two attaches to/from sender and receiver
        self.assertTrue(num_attaches == 4)

        # Turn off trace logging using qdmanage
        qd_manager.update("org.apache.qpid.dispatch.log", {"enable": "info+"},
                          name="log/DEFAULT")

        # Turn on trace (not trace+) level logging for the PROTOCOL module. After doing
        # this we will create a sender and a receiver and make sure that the PROTOCOL module
        # is emitting proton frame trace messages.

        # Before DISPATCH-1558, the only way to turn on proton frame trace logging was to set
        # enable to trace on the SERVER or the DEFAULT module. Turning on trace for the SERVER
        # module would also spit out dispatch trace level messages from the SERVER module.
        # DISPATCH-1558 adds the new PROTOCOL module which moves all protocol traces into
        # that module.
        qd_manager.update("org.apache.qpid.dispatch.log", {"enable": "trace+"},
                          name="log/PROTOCOL")

        TEST_ADDR = "moduletest1"
        hello_world_1 = "Hello World_1!"
        self.create_sender_receiver(TEST_ADDR, hello_world_1,
                                    blocking_connection)

        num_attaches = 0
        logs = qd_manager.get_log()
        for log in logs:
            if u'PROTOCOL' in log[0]:
                if "@attach" in log[2] and TEST_ADDR in log[2]:
                    num_attaches += 1

        # num_attaches for address TEST_ADDR must be 4, two attaches to/from sender and receiver
        self.assertTrue(num_attaches == 4)

        # Now turn off trace logging for the PROTOCOL module and make sure
        # that there is no more proton frame trace messages appearing in the log
        qd_manager.update("org.apache.qpid.dispatch.log", {"enable": "info+"},
                          name="log/PROTOCOL")

        TEST_ADDR = "moduletest2"
        hello_world_2 = "Hello World_2!"
        self.create_sender_receiver(TEST_ADDR, hello_world_2,
                                    blocking_connection)

        num_attaches = 0
        logs = qd_manager.get_log()
        for log in logs:
            if u'PROTOCOL' in log[0]:
                if "@attach" in log[2] and TEST_ADDR in log[2]:
                    num_attaches += 1

        # num_attaches for address TEST_ADDR must be 4, two attaches to/from sender and receiver
        self.assertTrue(num_attaches == 0)
Ejemplo n.º 7
0
    def test_single_connection_protocol_trace(self):
        qd_manager = QdManager(self, self.address)

        # Turn off trace logging on all connections.
        qd_manager.update("org.apache.qpid.dispatch.log", {"enable": "info+"},
                          name="log/DEFAULT")

        TEST_ADDR_1 = "EnableConnectionLevelProtocolTraceTest1"
        MSG_BODY = "EnableConnectionLevelProtocolTraceTestMessage1"
        CONTAINER_ID_1 = "CONTAINERID_1"
        container_1 = Container()
        container_1.container_id = CONTAINER_ID_1
        conn_1 = BlockingConnection(self.address, container=container_1)

        TEST_ADDR_2 = "EnableConnectionLevelProtocolTraceTest1"
        CONTAINER_ID_2 = "CONTAINERID_2"
        container_2 = Container()
        container_2.container_id = CONTAINER_ID_2
        conn_2 = BlockingConnection(self.address, container=container_2)

        results = qd_manager.query("org.apache.qpid.dispatch.connection")
        conn_id = None
        for result in results:
            if result[u'container'] == CONTAINER_ID_1:
                conn_id = result[u'identity']

        # Turn on trace logging for connection with identity conn_id
        qd_manager.update("org.apache.qpid.dispatch.connection",
                          {"enableProtocolTrace": "true"},
                          identity=conn_id)

        blocking_receiver_1 = conn_1.create_receiver(address=TEST_ADDR_1)
        blocking_sender_1 = conn_1.create_sender(address=TEST_ADDR_1,
                                                 options=apply_options)

        blocking_receiver_2 = conn_2.create_receiver(address=TEST_ADDR_2)
        blocking_sender_2 = conn_2.create_sender(address=TEST_ADDR_2,
                                                 options=apply_options)

        num_attaches_1 = 0
        num_attaches_2 = 0
        logs = qd_manager.get_log()
        for log in logs:
            if u'PROTOCOL' in log[0]:
                if "@attach" in log[2] and TEST_ADDR_1 in log[2]:
                    num_attaches_1 += 1
                elif "@attach" in log[2] and TEST_ADDR_2 in log[2]:
                    num_attaches_2 += 1

        # num_attaches_1 for address TEST_ADDR_1 must be 4, two attaches to/from sender and receiver
        self.assertTrue(num_attaches_1 == 4)

        # num_attaches_2 for address TEST_ADDR_2 must be 0 since trace was not
        # turned on for that connection
        self.assertTrue(num_attaches_2 == 0)

        # Now turn off the connection tracing on that connection
        qd_manager.update("org.apache.qpid.dispatch.connection",
                          {"enableProtocolTrace": "off"},
                          identity=conn_id)
        blocking_receiver_1.close()
        blocking_sender_1.close()

        # Since tracing was turned off, there should be no detaches
        logs = qd_manager.get_log()
        num_detaches = 0
        for log in logs:
            if u'PROTOCOL' in log[0]:
                if "@detach" in log[2]:
                    num_detaches += 1
        self.assertTrue(num_detaches == 0)
        blocking_receiver_2.close()
        blocking_sender_2.close()
        conn_1.close()
        conn_2.close()