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

[Flaky Test]: TestLogIngestionFleetManaged – unable to create policy: Agent Policy '<redacted>' already exists with name 'test-policy-enroll-1710143889' #4393

Closed
rdner opened this issue Mar 11, 2024 · 4 comments · Fixed by #4421
Assignees
Labels
flaky-test Unstable or unreliable test cases. Team:Elastic-Agent Label for the Agent team

Comments

@rdner
Copy link
Member

rdner commented Mar 11, 2024

Failing test case

TestLogIngestionFleetManaged

Error message

unable to create policy: Agent Policy '' already exists with name 'test-policy-enroll-1710143889'

Build

https://buildkite.com/elastic/elastic-agent/builds/7667#018e2c73-6325-4b6d-a6e7-5e4c99314aff

OS

Linux

Stacktrace and notes

=== RUN   TestLogIngestionFleetManaged
    logs_ingestion_test.go:58: Enrolling agent in Fleet with a test policy
    logs_ingestion_test.go:89: 
        	Error Trace:	/home/ubuntu/agent/testing/integration/logs_ingestion_test.go:89
        	Error:      	Received unexpected error:
        	            	unable to create policy: Agent Policy 'd9698871-b94d-41ba-9cda-a6cd1d613f02' already exists with name 'test-policy-enroll-1710143889'
        	Test:       	TestLogIngestionFleetManaged
--- FAIL: TestLogIngestionFleetManaged (4.24s)
@rdner rdner added Team:Elastic-Agent Label for the Agent team flaky-test Unstable or unreliable test cases. labels Mar 11, 2024
@elasticmachine
Copy link
Contributor

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

@rdner
Copy link
Member Author

rdner commented Mar 14, 2024

Happens on main too https://buildkite.com/elastic/elastic-agent/builds/7763#018e3960-7db8-47ab-830b-56cd7e6e3e3e

=== RUN   TestDebLogIngestFleetManaged
    logs_ingestion_test.go:126: Enrolling agent in Fleet with a test policy
    logs_ingestion_test.go:157: 
        	Error Trace:	/home/ubuntu/agent/testing/integration/logs_ingestion_test.go:157
        	Error:      	Received unexpected error:
        	            	unable to create policy: Agent Policy '5b612cdc-040d-42c2-b3fe-98222d73bf24' already exists with name 'test-policy-enroll-1710361822'
        	Test:       	TestDebLogIngestFleetManaged
--- FAIL: TestDebLogIngestFleetManaged (4.36s)

@rdner rdner changed the title [Flaky Test]: 8.13. TestLogIngestionFleetManaged – unable to create policy: Agent Policy '<redacted>' already exists with name 'test-policy-enroll-1710143889' [Flaky Test]: TestLogIngestionFleetManaged – unable to create policy: Agent Policy '<redacted>' already exists with name 'test-policy-enroll-1710143889' Mar 14, 2024
@cmacknz
Copy link
Member

cmacknz commented Mar 14, 2024

createPolicyReq := kibana.AgentPolicy{
Name: fmt.Sprintf("test-policy-enroll-%d", time.Now().Unix()),

We are using the time since epoch in seconds as the policy name, which is not unique if there are two concurrent requests in the same second, which is not unlikely in our test framework given we run multiple tests concurrently on different VMs.

This test should probably use a proper UUID for the policy name.

@rdner
Copy link
Member Author

rdner commented Mar 15, 2024

@cmacknz good point, I'll make the change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
flaky-test Unstable or unreliable test cases. Team:Elastic-Agent Label for the Agent team
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants