Skip to content

Commit

Permalink
Remove flaky integration test assertion
Browse files Browse the repository at this point in the history
Asserting there are no errors in the logs from Elastic-Agent and all
Beats is flaky and does not ensure the Elastic-Agent is working
correctly. The test already assert the healthy of all components, so
there is no need to look in the logs.

The number of exceptions this assertion for no log errors is already
an example of how fragile this is. The Elastic-Agent life cycle is
complex and some transient errors are expected, as the code evolves
those errors or messages will change, making assertion on them flaky.
  • Loading branch information
belimawr committed Dec 14, 2023
1 parent 55bbc7f commit 665cbe9
Showing 1 changed file with 2 additions and 27 deletions.
29 changes: 2 additions & 27 deletions testing/integration/logs_ingestion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,40 +126,15 @@ func testMonitoringLogsAreShipped(
c.Name, client.Healthy, client.State(c.State))
}

// Stage 3: Make sure there are no errors in logs
t.Log("Making sure there are no error logs")
docs = queryESDocs(t, func() (estools.Documents, error) {
return estools.CheckForErrorsInLogs(info.ESClient, info.Namespace, []string{
// acceptable error messages (include reason)
"Error dialing dial tcp 127.0.0.1:9200: connect: connection refused", // beat is running default config before its config gets updated
"Global configuration artifact is not available", // Endpoint: failed to load user artifact due to connectivity issues
"Failed to download artifact",
"Failed to initialize artifact",
"Failed to apply initial policy from on disk configuration",
"elastic-agent-client error: rpc error: code = Canceled desc = context canceled", // can happen on restart
"add_cloud_metadata: received error failed requesting openstack metadata: Get \\\"https://169.254.169.254/2009-04-04/meta-data/instance-id\\\": dial tcp 169.254.169.254:443: connect: connection refused", // okay for the openstack metadata to not work
"add_cloud_metadata: received error failed requesting openstack metadata: Get \\\"https://169.254.169.254/2009-04-04/meta-data/hostname\\\": dial tcp 169.254.169.254:443: connect: connection refused", // okay for the cloud metadata to not work
"add_cloud_metadata: received error failed requesting openstack metadata: Get \\\"https://169.254.169.254/2009-04-04/meta-data/placement/availability-zone\\\": dial tcp 169.254.169.254:443: connect: connection refused", // okay for the cloud metadata to not work
"add_cloud_metadata: received error failed requesting openstack metadata: Get \\\"https://169.254.169.254/2009-04-04/meta-data/instance-type\\\": dial tcp 169.254.169.254:443: connect: connection refused", // okay for the cloud metadata to not work
"add_cloud_metadata: received error failed with http status code 404", // okay for the cloud metadata to not work
"add_cloud_metadata: received error failed fetching EC2 Identity Document: operation error ec2imds: GetInstanceIdentityDocument, http response error StatusCode: 404, request to EC2 IMDS failed", // okay for the cloud metadata to not work
})
})
t.Logf("error logs: Got %d documents", len(docs.Hits.Hits))
for _, doc := range docs.Hits.Hits {
t.Logf("%#v", doc.Source)
}
require.Empty(t, docs.Hits.Hits)

// Stage 4: Make sure we have message confirming central management is running
// Stage 3: Make sure we have message confirming central management is running
t.Log("Making sure we have message confirming central management is running")
docs = findESDocs(t, func() (estools.Documents, error) {
return estools.FindMatchingLogLines(info.ESClient, info.Namespace,
"Parsed configuration and determined agent is managed by Fleet")
})
require.NotZero(t, len(docs.Hits.Hits))

// Stage 5: verify logs from the monitoring components are not sent to the output
// Stage 4: verify logs from the monitoring components are not sent to the output
t.Log("Check monitoring logs")
hostname, err := os.Hostname()
if err != nil {
Expand Down

0 comments on commit 665cbe9

Please sign in to comment.