@@ -63,10 +63,7 @@ const (
63
63
agentTestFileBatchNotAllowedName = "testdata/agentbatchnotallowed.yaml"
64
64
agentTestFileNoProcessorsAllowedName = "testdata/agentnoprocessorsallowed.yaml"
65
65
66
- // collectorStartTime is set to the result of a zero'd out creation timestamp
67
- // read more here https://github.com/open-telemetry/opentelemetry-go/issues/4268
68
- // we could attempt to hack the creation timestamp, but this is a constant and far easier.
69
- collectorStartTime = uint64 (11651379494838206464 )
66
+ collectorStartTime = uint64 (0 )
70
67
)
71
68
72
69
var (
78
75
updatedYamlConfigHash = getConfigHash (testCollectorKey , collectorUpdatedFile )
79
76
otherUpdatedYamlConfigHash = getConfigHash (otherCollectorKey , collectorUpdatedFile )
80
77
81
- podTime = metav1 .NewTime (time .UnixMicro (1704748549000000 ))
82
- mockPodList = & v1.PodList {
78
+ podTime = metav1 .NewTime (time .Unix (0 , 0 ))
79
+ podTimeUnsigned , _ = timeToUnixNanoUnsigned (podTime .Time )
80
+ mockPodList = & v1.PodList {
83
81
TypeMeta : metav1.TypeMeta {
84
82
Kind : "PodList" ,
85
83
APIVersion : "v1" ,
95
93
"app.kubernetes.io/part-of" : "opentelemetry" ,
96
94
"app.kubernetes.io/component" : "opentelemetry-collector" ,
97
95
},
96
+ CreationTimestamp : podTime ,
98
97
},
99
98
Spec : v1.PodSpec {},
100
99
Status : v1.PodStatus {
@@ -119,6 +118,7 @@ var (
119
118
"app.kubernetes.io/part-of" : "opentelemetry" ,
120
119
"app.kubernetes.io/component" : "opentelemetry-collector" ,
121
120
},
121
+ CreationTimestamp : podTime ,
122
122
},
123
123
Spec : v1.PodSpec {},
124
124
Status : v1.PodStatus {
@@ -215,6 +215,8 @@ func getFakeApplier(t *testing.T, conf *config.Config, lists ...runtimeClient.Ob
215
215
216
216
func TestAgent_getHealth (t * testing.T ) {
217
217
fakeClock := testingclock .NewFakeClock (time .Now ())
218
+ startTime , err := timeToUnixNanoUnsigned (fakeClock .Now ())
219
+ require .NoError (t , err )
218
220
type fields struct {
219
221
configFile string
220
222
}
@@ -244,10 +246,10 @@ func TestAgent_getHealth(t *testing.T) {
244
246
want : []* protobufs.ComponentHealth {
245
247
{
246
248
Healthy : true ,
247
- StartTimeUnixNano : uint64 ( fakeClock . Now (). UnixNano ()) ,
249
+ StartTimeUnixNano : startTime ,
248
250
LastError : "" ,
249
251
Status : "" ,
250
- StatusTimeUnixNano : uint64 ( fakeClock . Now (). UnixNano ()) ,
252
+ StatusTimeUnixNano : startTime ,
251
253
ComponentHealthMap : map [string ]* protobufs.ComponentHealth {},
252
254
},
253
255
},
@@ -269,15 +271,15 @@ func TestAgent_getHealth(t *testing.T) {
269
271
want : []* protobufs.ComponentHealth {
270
272
{
271
273
Healthy : true ,
272
- StartTimeUnixNano : uint64 ( fakeClock . Now (). UnixNano ()) ,
273
- StatusTimeUnixNano : uint64 ( fakeClock . Now (). UnixNano ()) ,
274
+ StartTimeUnixNano : startTime ,
275
+ StatusTimeUnixNano : startTime ,
274
276
ComponentHealthMap : map [string ]* protobufs.ComponentHealth {
275
277
"testnamespace/collector" : {
276
278
Healthy : true ,
277
279
StartTimeUnixNano : collectorStartTime ,
278
280
LastError : "" ,
279
281
Status : "" ,
280
- StatusTimeUnixNano : uint64 ( fakeClock . Now (). UnixNano ()) ,
282
+ StatusTimeUnixNano : startTime ,
281
283
ComponentHealthMap : map [string ]* protobufs.ComponentHealth {},
282
284
},
283
285
},
@@ -302,23 +304,23 @@ func TestAgent_getHealth(t *testing.T) {
302
304
want : []* protobufs.ComponentHealth {
303
305
{
304
306
Healthy : true ,
305
- StartTimeUnixNano : uint64 ( fakeClock . Now (). UnixNano ()) ,
306
- StatusTimeUnixNano : uint64 ( fakeClock . Now (). UnixNano ()) ,
307
+ StartTimeUnixNano : startTime ,
308
+ StatusTimeUnixNano : startTime ,
307
309
ComponentHealthMap : map [string ]* protobufs.ComponentHealth {
308
310
"testnamespace/collector" : {
309
311
Healthy : true ,
310
312
StartTimeUnixNano : collectorStartTime ,
311
313
LastError : "" ,
312
314
Status : "" ,
313
- StatusTimeUnixNano : uint64 ( fakeClock . Now (). UnixNano ()) ,
315
+ StatusTimeUnixNano : startTime ,
314
316
ComponentHealthMap : map [string ]* protobufs.ComponentHealth {},
315
317
},
316
318
"testnamespace/other" : {
317
319
Healthy : true ,
318
320
StartTimeUnixNano : collectorStartTime ,
319
321
LastError : "" ,
320
322
Status : "" ,
321
- StatusTimeUnixNano : uint64 ( fakeClock . Now (). UnixNano ()) ,
323
+ StatusTimeUnixNano : startTime ,
322
324
ComponentHealthMap : map [string ]* protobufs.ComponentHealth {},
323
325
},
324
326
},
@@ -342,21 +344,21 @@ func TestAgent_getHealth(t *testing.T) {
342
344
want : []* protobufs.ComponentHealth {
343
345
{
344
346
Healthy : true ,
345
- StartTimeUnixNano : uint64 ( fakeClock . Now (). UnixNano ()) ,
346
- StatusTimeUnixNano : uint64 ( fakeClock . Now (). UnixNano ()) ,
347
+ StartTimeUnixNano : startTime ,
348
+ StatusTimeUnixNano : startTime ,
347
349
ComponentHealthMap : map [string ]* protobufs.ComponentHealth {
348
350
"other/third" : {
349
351
Healthy : true ,
350
352
StartTimeUnixNano : collectorStartTime ,
351
353
LastError : "" ,
352
354
Status : "" ,
353
- StatusTimeUnixNano : uint64 ( fakeClock . Now (). UnixNano ()) ,
355
+ StatusTimeUnixNano : startTime ,
354
356
ComponentHealthMap : map [string ]* protobufs.ComponentHealth {
355
357
otherCollectorName + "/" + thirdCollectorName + "-1" : {
356
358
Healthy : true ,
357
359
Status : "Running" ,
358
- StatusTimeUnixNano : uint64 ( fakeClock . Now (). UnixNano ()) ,
359
- StartTimeUnixNano : uint64 ( podTime . UnixNano ()) ,
360
+ StatusTimeUnixNano : startTime ,
361
+ StartTimeUnixNano : podTimeUnsigned ,
360
362
},
361
363
},
362
364
},
@@ -381,20 +383,20 @@ func TestAgent_getHealth(t *testing.T) {
381
383
want : []* protobufs.ComponentHealth {
382
384
{
383
385
Healthy : true ,
384
- StartTimeUnixNano : uint64 ( fakeClock . Now (). UnixNano ()) ,
385
- StatusTimeUnixNano : uint64 ( fakeClock . Now (). UnixNano ()) ,
386
+ StartTimeUnixNano : startTime ,
387
+ StatusTimeUnixNano : startTime ,
386
388
ComponentHealthMap : map [string ]* protobufs.ComponentHealth {
387
389
"other/third" : {
388
390
Healthy : false , // we're working with mocks so the status will never be reconciled.
389
391
StartTimeUnixNano : collectorStartTime ,
390
392
LastError : "" ,
391
393
Status : "" ,
392
- StatusTimeUnixNano : uint64 ( fakeClock . Now (). UnixNano ()) ,
394
+ StatusTimeUnixNano : startTime ,
393
395
ComponentHealthMap : map [string ]* protobufs.ComponentHealth {
394
396
otherCollectorName + "/" + thirdCollectorName + "-1" : {
395
397
Healthy : false ,
396
398
Status : "Running" ,
397
- StatusTimeUnixNano : uint64 ( fakeClock . Now (). UnixNano ()) ,
399
+ StatusTimeUnixNano : startTime ,
398
400
StartTimeUnixNano : uint64 (0 ),
399
401
},
400
402
},
0 commit comments