From 5d8aa1cd1be5e29714a8ea03e7e43a07fc145c17 Mon Sep 17 00:00:00 2001 From: Vladimir Varankin Date: Fri, 12 Apr 2024 15:53:24 +0200 Subject: [PATCH] kfake: fix handling ListOffsets with requested timestamp --- pkg/kfake/02_list_offsets.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/kfake/02_list_offsets.go b/pkg/kfake/02_list_offsets.go index 5ab7843d..587c41a6 100644 --- a/pkg/kfake/02_list_offsets.go +++ b/pkg/kfake/02_list_offsets.go @@ -75,10 +75,11 @@ func (c *Cluster) handleListOffsets(b *broker, kreq kmsg.Request) (kmsg.Response sp.Offset = pd.highWatermark } default: + // returns the index of the first batch _after_ the requested timestamp idx, _ := sort.Find(len(pd.batches), func(idx int) int { maxEarlier := pd.batches[idx].maxEarlierTimestamp switch { - case maxEarlier < rp.Timestamp: + case maxEarlier > rp.Timestamp: return -1 case maxEarlier == rp.Timestamp: return 0