diff --git a/pkg/testing/tools/fleettools/fleet.go b/pkg/testing/tools/fleettools/fleet.go index ce1048a1c7e..e593590b3f2 100644 --- a/pkg/testing/tools/fleettools/fleet.go +++ b/pkg/testing/tools/fleettools/fleet.go @@ -35,6 +35,8 @@ func GetAgentByPolicyIDAndHostnameFromList(ctx context.Context, client *kibana.C agentHostname := item.LocalMetadata.Host.Hostname agentPolicyID := item.PolicyID + agentHostnames = append(agentHostnames, agentHostname) + if strings.EqualFold(agentHostname, hostname) && agentPolicyID == policyID { hostnameAgents = append(hostnameAgents, &listAgentsResp.Items[i]) }