Skip to content

Commit

Permalink
[chore] [receiver/discovery] Adopt plogtest.IgnoreTimestamp
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitryax committed Apr 25, 2024
1 parent 660c89e commit e8dc23c
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions internal/receiver/discoveryreceiver/endpoint_tracker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -659,12 +659,10 @@ func TestEntityEmittingLifecycle(t *testing.T) {

gotLogs := <-ch
require.Equal(t, 1, gotLogs.LogRecordCount())
// TODO: Use plogtest.IgnoreTimestamp once available
expectedEvents, failed, err := entityStateEvents(obsID, []observer.Endpoint{portEndpoint},
gotLogs.ResourceLogs().At(0).ScopeLogs().At(0).LogRecords().At(0).Timestamp().AsTime())
expectedEvents, failed, err := entityStateEvents(obsID, []observer.Endpoint{portEndpoint}, t0)
require.NoError(t, err)
require.Zero(t, failed)
require.NoError(t, plogtest.CompareLogs(expectedEvents.ConvertAndMoveToLogs(), gotLogs))
require.NoError(t, plogtest.CompareLogs(expectedEvents.ConvertAndMoveToLogs(), gotLogs, plogtest.IgnoreTimestamp()))

// Remove the endpoint.
obs.onRemove([]observer.Endpoint{portEndpoint})
Expand All @@ -673,8 +671,7 @@ func TestEntityEmittingLifecycle(t *testing.T) {
expectedLogs := entityDeleteEvents([]observer.Endpoint{portEndpoint}, t0).ConvertAndMoveToLogs()
require.EventuallyWithT(t, func(c *assert.CollectT) {
logs := <-ch
logs.ResourceLogs().At(0).ScopeLogs().At(0).LogRecords().At(0).SetTimestamp(pcommon.NewTimestampFromTime(t0))
assert.NoError(c, plogtest.CompareLogs(expectedLogs, logs))
assert.NoError(c, plogtest.CompareLogs(expectedLogs, logs, plogtest.IgnoreTimestamp()))
}, 1*time.Second, 50*time.Millisecond)

// Ensure that entities are not emitted anymore
Expand Down

0 comments on commit e8dc23c

Please sign in to comment.