Open kpollich opened 5 months ago
Pinging @elastic/fleet (Team:Fleet)
It should be "as simple" as extracting startAgent
to his own helper module.
It might be interesting to explore abstractions like loading a standalone policy vs enrolling in Fleet by having a separate Fleet Server container or something along those lines too. Imagining something like
describe('/api/agent_policies', () => {
describe('live agent tests', () => {
describe('standalone'), () => {
withStandaloneAgentContainer()
test('can run a standalone system policy', async () => {
const agentPolicyYml = createTestSystemPolicy(...)
loadStandalonePolicy(agentPolicyYml)
await assertStandaloneAgentIngestsData({ dataStreams: ['logs-system-*'] })
})
})
})
})
Maybe with different tests for fleet enrolled agents, etc. It'd be nice to be able to do something like "set up a policy with xyz constraints and assert that data is ingested to the expected data streams, maybe eventually even asserting on the data's format. 🤷
In https://github.com/elastic/kibana/pull/184435 we added the ability to spin up a Docker container running Elastic Agent in FTR tests, e.g.
https://github.com/elastic/kibana/blob/dff275442614bea4429efcaa807175f5a19606e5/x-pack/test/fleet_api_integration/apis/integrations/inputs_with_standalone_docker_agent.ts#L106-L162
We should extract this logic to a reusable utility that allows any test to spin up an agent container on-demand in order to execute tests. The container should be killed when the test suite exits.
As part of this issue, we should also find other opportunities to make use of this agent container in our test suites.