Skip to content

Commit 72617cb

Browse files
authored
Merge pull request #1649 from SammyVimes/fix-describe-consumer Fix describe consumer not parsing partition consumer stats
2 parents 912e569 + 15663ac commit 72617cb

File tree

5 files changed

+28
-3
lines changed

5 files changed

+28
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
* Fixed DescribeConsumer ignoring PartitionConsumerStats
12
* Added virtualtimestamps field to cdc description
23

34
## v3.99.10

internal/grpcwrapper/rawoptional/rawoptional.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ func (v *Duration) MustFromProto(proto *durationpb.Duration) {
4848
}
4949

5050
func (v *Duration) ToDuration() *time.Duration {
51-
if v.HasValue {
51+
if !v.HasValue {
5252
return nil
5353
}
5454

@@ -96,7 +96,7 @@ func (v *Time) MustFromProto(proto *timestamppb.Timestamp) {
9696
}
9797

9898
func (v *Time) ToTime() *time.Time {
99-
if v.HasValue {
99+
if !v.HasValue {
100100
return nil
101101
}
102102

internal/grpcwrapper/rawtopic/describe_consumer.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,5 +147,9 @@ func (pi *DescribeConsumerResultPartitionInfo) FromProto(proto *Ydb_Topic.Descri
147147
pi.ChildPartitionIDs = clone.Int64Slice(proto.GetChildPartitionIds())
148148
pi.ParentPartitionIDs = clone.Int64Slice(proto.GetParentPartitionIds())
149149

150+
if err := pi.PartitionConsumerStats.FromProto(proto.GetPartitionConsumerStats()); err != nil {
151+
return err
152+
}
153+
150154
return pi.PartitionStats.FromProto(proto.GetPartitionStats())
151155
}

tests/integration/topic_client_test.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,26 @@ func TestDescribeTopicConsumer(t *testing.T) {
247247

248248
requireAndCleanSubset(&consumer.Consumer.Attributes, &expectedConsumerDesc.Consumer.Attributes)
249249

250+
for i := range consumer.Partitions {
251+
// Fields that are checked here are dynamic and they change with time, so we need to set them to expected values
252+
// to make the comparison possible.
253+
p := &consumer.Partitions[i]
254+
255+
require.NotNil(t, p.PartitionStats.LastWriteTime)
256+
257+
p.PartitionStats.LastWriteTime = expectedConsumerDesc.Partitions[i].PartitionStats.LastWriteTime
258+
p.PartitionStats.MaxWriteTimeLag = expectedConsumerDesc.Partitions[i].PartitionStats.MaxWriteTimeLag
259+
260+
require.NotNil(t, p.PartitionConsumerStats.LastReadTime)
261+
require.NotNil(t, p.PartitionConsumerStats.MaxReadTimeLag)
262+
require.NotNil(t, p.PartitionConsumerStats.MaxWriteTimeLag)
263+
264+
p.PartitionConsumerStats.PartitionReadSessionCreateTime = expectedConsumerDesc.Partitions[i].PartitionConsumerStats.PartitionReadSessionCreateTime
265+
p.PartitionConsumerStats.LastReadTime = expectedConsumerDesc.Partitions[i].PartitionConsumerStats.LastReadTime
266+
p.PartitionConsumerStats.MaxReadTimeLag = expectedConsumerDesc.Partitions[i].PartitionConsumerStats.MaxReadTimeLag
267+
p.PartitionConsumerStats.MaxWriteTimeLag = expectedConsumerDesc.Partitions[i].PartitionConsumerStats.MaxWriteTimeLag
268+
}
269+
250270
require.Equal(t, expectedConsumerDesc, consumer)
251271
}
252272

topic/topictypes/topictypes_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ func TestTopicConsumerDescriptionFromRaw(t *testing.T) {
325325
v.testName, func(t *testing.T) {
326326
d := TopicConsumerDescription{}
327327
d.FromRaw(v.rawConsumerDescription)
328-
if !reflect.DeepEqual(d.Consumer, v.expectedDescription.Consumer) {
328+
if !reflect.DeepEqual(d, v.expectedDescription) {
329329
t.Errorf("got\n%+v\nexpected\n%+v", d, v.expectedDescription)
330330
}
331331
},

0 commit comments

Comments
 (0)