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

Make policy names unique in integration tests #4421

Merged
merged 2 commits into from
Mar 18, 2024

Conversation

rdner
Copy link
Member

@rdner rdner commented Mar 18, 2024

Verified

This commit was signed with the committer’s verified signature.
rdner Denis
Otherwise we have name collisions and errors from the Fleet server.
@rdner rdner added Team:Elastic-Agent Label for the Agent team skip-changelog backport-v8.13.0 Automated backport with mergify labels Mar 18, 2024
@rdner rdner self-assigned this Mar 18, 2024
@rdner rdner requested a review from a team as a code owner March 18, 2024 12:57
@elasticmachine
Copy link
Contributor

Pinging @elastic/elastic-agent (Team:Elastic-Agent)

Verified

This commit was signed with the committer’s verified signature.
rdner Denis
@rdner rdner enabled auto-merge (squash) March 18, 2024 15:38
@rdner rdner requested review from pchila and removed request for AndersonQ March 18, 2024 15:39
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))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should be able to just use info.Namespace for this, but id is unique so it doesn't matter too much.

// Namespace should be used for isolating data and actions per test.
//
// This is unique to each test and instance combination so a test that need to
// read/write data to a data stream in elasticsearch do not collide.
Namespace string

@@ -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()),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be worth creating a helper for this like UniquePolicyName() to help people do this properly.

@rdner rdner merged commit 8e6593f into elastic:main Mar 18, 2024
8 checks passed
Copy link

Quality Gate passed Quality Gate passed

Kudos, no new issues were introduced!

0 New issues
0 Security Hotspots
No Coverage information No data about Coverage
0.0% 0.0% Duplication on New Code

See analysis details on SonarQube

mergify bot pushed a commit that referenced this pull request Mar 18, 2024

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
Otherwise we have name collisions and errors from the Fleet server.

(cherry picked from commit 8e6593f)
rdner added a commit that referenced this pull request Mar 18, 2024

Partially verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
We cannot verify signatures from co-authors, and some of the co-authors attributed to this commit require their commits to be signed.
Otherwise we have name collisions and errors from the Fleet server.

(cherry picked from commit 8e6593f)

Co-authored-by: Denis <denis.rechkunov@elastic.co>
@rdner rdner deleted the unique-policy-name branch November 1, 2024 19:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-v8.13.0 Automated backport with mergify skip-changelog Team:Elastic-Agent Label for the Agent team
Projects
None yet
3 participants