@@ -52,6 +52,8 @@ func TestGetStatsCmd(t *testing.T) {
5252 if err != nil {
5353 t .Fatal (err )
5454 }
55+ assert .Greaterf (t , stats .TopicCreationTimeStamp , int64 (0 ), "TopicCreationTimeStamp should be greater than 0" )
56+ stats .TopicCreationTimeStamp = 0 // reset to zero for comparison
5557
5658 assert .Equal (t , defaultStats , stats )
5759}
@@ -108,6 +110,7 @@ func TestGetPartitionedStatsCmd(t *testing.T) {
108110 assert .Equal (t , "" , stats .DeDuplicationStatus )
109111 assert .Equal (t , 2 , stats .Metadata .Partitions )
110112 assert .Equal (t , 0 , len (stats .Partitions ))
113+ assert .Greater (t , stats .TopicCreationTimeStamp , int64 (0 ))
111114}
112115
113116func TestGetPerPartitionedStatsCmd (t * testing.T ) {
@@ -125,6 +128,15 @@ func TestGetPerPartitionedStatsCmd(t *testing.T) {
125128 t .Fatal (err )
126129 }
127130
131+ assert .Greater (t , stats .TopicCreationTimeStamp , int64 (0 ))
132+ stats .TopicCreationTimeStamp = 0
133+ partitionKey := "persistent://public/default/test-topic-per-partitioned-stats-partition-0"
134+ assert .Contains (t , stats .Partitions , partitionKey )
135+ assert .Greaterf (t , stats .Partitions [partitionKey ].TopicCreationTimeStamp , int64 (0 ), "TopicCreationTimeStamp should be greater than 0" )
136+ v := stats .Partitions [partitionKey ]
137+ v .TopicCreationTimeStamp = 0
138+ stats .Partitions [partitionKey ] = v
139+
128140 defaultStats := utils.PartitionedTopicStats {
129141 MsgRateIn : 0 ,
130142 MsgRateOut : 0 ,
@@ -138,7 +150,7 @@ func TestGetPerPartitionedStatsCmd(t *testing.T) {
138150 DeDuplicationStatus : "" ,
139151 Metadata : utils.PartitionedTopicMetadata {Partitions : 1 },
140152 Partitions : map [string ]utils.TopicStats {
141- "persistent://public/default/test-topic-per-partitioned-stats-partition-0" : {
153+ partitionKey : {
142154 MsgRateIn : 0 ,
143155 MsgRateOut : 0 ,
144156 MsgThroughputIn : 0 ,
@@ -195,6 +207,8 @@ func TestGetStatsWithPreciseBacklog(t *testing.T) {
195207 if err != nil {
196208 t .Fatal (err )
197209 }
210+ assert .Greaterf (t , stats .TopicCreationTimeStamp , int64 (0 ), "TopicCreationTimeStamp should be greater than 0" )
211+ stats .TopicCreationTimeStamp = 0
198212
199213 assert .Equal (t , defaultStats , stats )
200214}
@@ -213,6 +227,8 @@ func TestGetStatsWithoutSubscriptionBacklogSize(t *testing.T) {
213227 if err != nil {
214228 t .Fatal (err )
215229 }
230+ assert .Greaterf (t , stats .TopicCreationTimeStamp , int64 (0 ), "TopicCreationTimeStamp should be greater than 0" )
231+ stats .TopicCreationTimeStamp = 0
216232
217233 assert .Equal (t , defaultStats , stats )
218234}
@@ -231,6 +247,8 @@ func TestGetStatsWithEarliestTimeInBacklog(t *testing.T) {
231247 if err != nil {
232248 t .Fatal (err )
233249 }
250+ assert .Greaterf (t , stats .TopicCreationTimeStamp , int64 (0 ), "TopicCreationTimeStamp should be greater than 0" )
251+ stats .TopicCreationTimeStamp = 0
234252
235253 assert .Equal (t , defaultStats , stats )
236254}
@@ -249,6 +267,8 @@ func TestGetStatsWithMultipleNewFlags(t *testing.T) {
249267 if err != nil {
250268 t .Fatal (err )
251269 }
270+ assert .Greaterf (t , stats .TopicCreationTimeStamp , int64 (0 ), "TopicCreationTimeStamp should be greater than 0" )
271+ stats .TopicCreationTimeStamp = 0
252272
253273 assert .Equal (t , defaultStats , stats )
254274}
@@ -297,6 +317,15 @@ func TestGetPerPartitionStatsWithNewFlags(t *testing.T) {
297317 t .Fatal (err )
298318 }
299319
320+ assert .Greater (t , stats .TopicCreationTimeStamp , int64 (0 ))
321+ stats .TopicCreationTimeStamp = 0
322+ partitionKey := "persistent://public/default/test-per-part-stats-new-flags-partition-0"
323+ assert .Contains (t , stats .Partitions , partitionKey )
324+ assert .Greaterf (t , stats .Partitions [partitionKey ].TopicCreationTimeStamp , int64 (0 ), "TopicCreationTimeStamp should be greater than 0" )
325+ v := stats .Partitions [partitionKey ]
326+ v .TopicCreationTimeStamp = 0
327+ stats .Partitions [partitionKey ] = v
328+
300329 defaultStats := utils.PartitionedTopicStats {
301330 MsgRateIn : 0 ,
302331 MsgRateOut : 0 ,
@@ -310,7 +339,7 @@ func TestGetPerPartitionStatsWithNewFlags(t *testing.T) {
310339 DeDuplicationStatus : "" ,
311340 Metadata : utils.PartitionedTopicMetadata {Partitions : 1 },
312341 Partitions : map [string ]utils.TopicStats {
313- "persistent://public/default/test-per-part-stats-new-flags-partition-0" : {
342+ partitionKey : {
314343 MsgRateIn : 0 ,
315344 MsgRateOut : 0 ,
316345 MsgThroughputIn : 0 ,
0 commit comments