Skip to content

Commit

Permalink
Merge pull request redpanda-data#14584 from graphcareful/usage-cs-byt…
Browse files Browse the repository at this point in the history
…es-fix

Fix for CI failure (failure to assert_usage_consistency) in UsageTest.test_usage_collection_restart
  • Loading branch information
piyushredpanda authored Nov 2, 2023
2 parents ae2152c + f1eaa00 commit d55e754
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions tests/rptest/tests/usage_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,8 @@ def group_windows(ws):
return {(x.begin, x.end): x for x in ws}

def compare(x, y, fn):
return fn(x.bytes_sent, y.bytes_sent) and fn(
x.bytes_received, y.bytes_received) and fn(
x.bytes_in_cloud_storage, y.bytes_in_cloud_storage)
return fn(x.bytes_sent, y.bytes_sent) and fn(x.bytes_received,
y.bytes_received)

# Windows from group 'a' are expected to be from a previous request
grp_a = group_windows(a)
Expand All @@ -97,8 +96,15 @@ def compare(x, y, fn):
a_value = grp_a.get(key, None)
if a_value is not None:
fn = operator.le if a_value.is_open else operator.eq
assert compare(a_value, x,
fn), f"node: {node} a: {str(a_value)} b:{str(x)}"
assert compare(
a_value, x, fn
), f"Failed to compare historical values, node: {node} a: {str(a_value)} b:{str(x)}"

# Can only assert on value of cloud storage if the windows are closed, since across
# the time of an open window, leadership may change and the value of the cs_bytes field
# depends on if the broker is the controller leader or not
if a_value.is_closed and x.is_closed:
assert a_value.bytes_in_cloud_storage == x.bytes_in_cloud_storage, f"Failed bytes_in_cs compare node: {node} a: {str(a_value)} b:{str(x)}"


class UsageTest(RedpandaTest):
Expand Down

0 comments on commit d55e754

Please sign in to comment.