Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[8.13](backport #4421) Make policy names unique in integration tests #4427

Merged
merged 1 commit into from
Mar 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion testing/integration/container_cmd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"testing"
"time"

"github.com/google/uuid"
"github.com/stretchr/testify/require"

"github.com/elastic/elastic-agent-libs/kibana"
Expand Down Expand Up @@ -41,7 +42,7 @@ func TestContainerCMD(t *testing.T) {
require.NoError(t, err)

createPolicyReq := kibana.AgentPolicy{
Name: fmt.Sprintf("test-policy-enroll-%d", time.Now().Unix()),
Name: fmt.Sprintf("test-policy-enroll-%s", uuid.New().String()),
Namespace: info.Namespace,
Description: "test policy for agent enrollment",
MonitoringEnabled: []kibana.MonitoringEnabledOption{
Expand Down
3 changes: 2 additions & 1 deletion testing/integration/delay_enroll_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"testing"
"time"

"github.com/google/uuid"
"github.com/stretchr/testify/require"

"github.com/elastic/elastic-agent-libs/kibana"
Expand Down Expand Up @@ -44,7 +45,7 @@ func TestDelayEnroll(t *testing.T) {
// name. This policy does not contain any integration.
t.Log("Enrolling agent in Fleet with a test policy")
createPolicyReq := kibana.AgentPolicy{
Name: fmt.Sprintf("test-policy-enroll-%d", time.Now().Unix()),
Name: fmt.Sprintf("test-policy-enroll-%s", uuid.New().String()),
Namespace: info.Namespace,
Description: "test policy for agent enrollment",
MonitoringEnabled: []kibana.MonitoringEnabledOption{
Expand Down
9 changes: 5 additions & 4 deletions testing/integration/logs_ingestion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"context"
"encoding/json"
"fmt"
"math/rand"
"net/http"
"net/http/httputil"
"os"
Expand All @@ -22,6 +21,7 @@ import (
"text/template"
"time"

"github.com/google/uuid"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

Expand Down Expand Up @@ -57,7 +57,7 @@ func TestLogIngestionFleetManaged(t *testing.T) {
// name. This policy does not contain any integration.
t.Log("Enrolling agent in Fleet with a test policy")
createPolicyReq := kibana.AgentPolicy{
Name: fmt.Sprintf("test-policy-enroll-%d", time.Now().Unix()),
Name: fmt.Sprintf("test-policy-enroll-%s", uuid.New().String()),
Namespace: info.Namespace,
Description: "test policy for agent enrollment",
MonitoringEnabled: []kibana.MonitoringEnabledOption{
Expand Down Expand Up @@ -253,8 +253,9 @@ func testFlattenedDatastreamFleetPolicy(
policy kibana.PolicyResponse,
) {
dsType := "logs"
dsNamespace := cleanString(fmt.Sprintf("%snamespace%d", t.Name(), rand.Uint64()))
dsDataset := cleanString(fmt.Sprintf("%s-dataset", t.Name()))
id := uuid.New().String()
dsNamespace := cleanString(fmt.Sprintf("namespace-%s", id))
dsDataset := cleanString(fmt.Sprintf("dataset-%s", id))
numEvents := 60

// tempDir is not deleted to help with debugging issues
Expand Down
Loading