Skip to content

Commit

Permalink
DISPATCH-2276: Accomodate hex values in 0.36+ qpid-proton logging (#1525
Browse files Browse the repository at this point in the history
)

* DISPATCH-2276: Accomodate hex values in 0.36+ qpid-proton logging

* Fix code that extracts integer values during AMQP analysis
* Convert ints from hex to decimal for web display of values line
  link and session numbers and credit.

* DISPATCH-2276: Topology disposition test does not need to import proton

Co-authored-by: chug <chug@taj.localdomain>
Co-authored-by: Chuck Rolke <chug@apache.org>
  • Loading branch information
3 people authored Feb 22, 2022
1 parent ec62cb2 commit 6f75d1f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
2 changes: 0 additions & 2 deletions tests/system_tests_topology_disposition.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import unittest
from subprocess import PIPE, STDOUT

import proton
from proton import Message
from proton.handlers import MessagingHandler
from proton.reactor import Container
Expand Down Expand Up @@ -406,7 +405,6 @@ def test_03_connection_id_propagation(self):
self.assertIsNone(error)
self.assertIsNone(error)

@unittest.skipIf(proton.VERSION > (0, 36, 0), "see DISPATCH-2276")
def test_04_scraper_tool(self):
name = 'test_04'
error = str(None)
Expand Down
8 changes: 4 additions & 4 deletions tools/scraper/amqp_detail.py
Original file line number Diff line number Diff line change
Expand Up @@ -681,7 +681,7 @@ def __init__(self, _router, _common):
sdispmap = sess.rx_rcvr_disposition_map if splf.data.is_receiver else sess.rx_sndr_disposition_map
else:
sdispmap = sess.tx_rcvr_disposition_map if splf.data.is_receiver else sess.tx_sndr_disposition_map
for sdid in range(int(splf.data.first), (int(splf.data.last) + 1)):
for sdid in range(int(splf.data.first, 0), (int(splf.data.last, 0) + 1)):
did = str(sdid)
if did in sdispmap:
old_splf = sdispmap[did]
Expand Down Expand Up @@ -829,7 +829,7 @@ def evaluate_credit(self):
tod_of_second_attach = plf.datetime
if look_for_sender_delivery_id:
if plf.data.name == "attach" and not plf.data.is_receiver:
current_delivery = int(plf.data.described_type.dict.get("initial-delivery_count", "0"))
current_delivery = int(plf.data.described_type.dict.get("initial-delivery_count", "0"), 0)
delivery_limit = current_delivery
look_for_sender_delivery_id = False

Expand All @@ -838,7 +838,7 @@ def evaluate_credit(self):
# a flow in the normal direction updates the delivery limit
dc = plf.data.described_type.dict.get("delivery-count", "0")
lc = plf.data.described_type.dict.get("link-credit", "0")
delivery_limit = int(dc) + int(lc) # TODO: wrap at 32-bits
delivery_limit = int(dc, 0) + int(lc, 0) # TODO: wrap at 32-bits
if n_attaches < 2:
# a working flow before sender attach - cancel initial stall
init_stall = False
Expand All @@ -858,7 +858,7 @@ def evaluate_credit(self):
else:
# flow in the opposite direction updates the senders current delivery
# normally used to consume credit in response to a drain from receiver
current_delivery = int(plf.data.described_type.dict.get("initial-delivery_count", "0"))
current_delivery = int(plf.data.described_type.dict.get("initial-delivery_count", "0"), 0)

elif plf.data.transfer:
if plf.data.direction == dir_of_xfer:
Expand Down
3 changes: 3 additions & 0 deletions tools/scraper/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,9 @@ def parse_dtype_line(self, _dtype, _line):
if '=' not in fields[0]:
raise ValueError("Field does not contain equal sign '%s'" % fields[0])
key, val = DescribedType.get_key_and_val(fields[0])
# New proton logging uses hex strings. Convert to decimal strings.
if val.startswith("0x"):
val = str(int(val, 0))
del fields[0]
if DescribedType.is_dtype_name(val):
# recursing to process subtype
Expand Down

0 comments on commit 6f75d1f

Please sign in to comment.