From e8dc23c174f6365817f7e88593b24c8d6e282372 Mon Sep 17 00:00:00 2001 From: Dmitry Anoshin Date: Thu, 25 Apr 2024 13:57:33 -0700 Subject: [PATCH] [chore] [receiver/discovery] Adopt plogtest.IgnoreTimestamp --- .../receiver/discoveryreceiver/endpoint_tracker_test.go | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/internal/receiver/discoveryreceiver/endpoint_tracker_test.go b/internal/receiver/discoveryreceiver/endpoint_tracker_test.go index d13f0f5d9a..f491b9b33a 100644 --- a/internal/receiver/discoveryreceiver/endpoint_tracker_test.go +++ b/internal/receiver/discoveryreceiver/endpoint_tracker_test.go @@ -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}) @@ -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