mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
[Fleet] re-enable flaky telemetry test with new agent checks (#166830)
Closes #164998 It seems the final agent is not loading correctly sometimes, we do `wait_for` when we create the agents so it is a bit strange. I have added a check that all agents are created before the test, if the y are not loaded then I log all the agents so this will help us diagnose any further flakiness better. Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
parent
d2feac06d4
commit
07b31f1d49
1 changed files with 33 additions and 4 deletions
|
@ -14,6 +14,8 @@ import { FtrProviderContext } from '../../api_integration/ftr_provider_context';
|
|||
import { skipIfNoDockerRegistry, generateAgent } from '../helpers';
|
||||
import { setupFleetAndAgents } from './agents/services';
|
||||
|
||||
const AGENT_COUNT_WAIT_ATTEMPTS = 3;
|
||||
|
||||
export default function (providerContext: FtrProviderContext) {
|
||||
const { getService } = providerContext;
|
||||
const supertest = getService('supertest');
|
||||
|
@ -22,8 +24,7 @@ export default function (providerContext: FtrProviderContext) {
|
|||
|
||||
let agentCount = 0;
|
||||
let pkgVersion: string;
|
||||
// FLAKY: https://github.com/elastic/kibana/issues/164998
|
||||
describe.skip('fleet_telemetry', () => {
|
||||
describe('fleet_telemetry', () => {
|
||||
skipIfNoDockerRegistry(providerContext);
|
||||
before(async () => {
|
||||
await kibanaServer.savedObjects.cleanStandardList();
|
||||
|
@ -125,7 +126,35 @@ export default function (providerContext: FtrProviderContext) {
|
|||
);
|
||||
});
|
||||
|
||||
async function waitForAgents(expectedAgentCount: number, attempts: number, _attemptsMade = 0) {
|
||||
const { body: apiResponse } = await supertest
|
||||
.get(`/api/fleet/agents?showInactive=true`)
|
||||
.set('kbn-xsrf', 'xxxx')
|
||||
.expect(200);
|
||||
|
||||
if (apiResponse.list.length === expectedAgentCount) {
|
||||
return apiResponse;
|
||||
}
|
||||
|
||||
if (_attemptsMade >= attempts) {
|
||||
throw new Error(
|
||||
`Agents not loaded correctly, failing test. All agents: \n: ${JSON.stringify(
|
||||
apiResponse.list,
|
||||
null,
|
||||
2
|
||||
)}`
|
||||
);
|
||||
}
|
||||
|
||||
await new Promise((resolve) => setTimeout(resolve, 1000));
|
||||
return waitForAgents(expectedAgentCount, attempts, _attemptsMade + 1);
|
||||
}
|
||||
|
||||
it('should return the correct telemetry values for fleet', async () => {
|
||||
// it appears agent 9 is not being loaded sometimes
|
||||
// first check if all the agents have been correctly loaded
|
||||
await waitForAgents(agentCount, AGENT_COUNT_WAIT_ATTEMPTS);
|
||||
|
||||
const {
|
||||
body: [{ stats: apiResponse }],
|
||||
} = await supertest
|
||||
|
@ -140,13 +169,13 @@ export default function (providerContext: FtrProviderContext) {
|
|||
.expect(200);
|
||||
|
||||
expect(apiResponse.stack_stats.kibana.plugins.fleet.agents).eql({
|
||||
total_enrolled: 8,
|
||||
total_enrolled: 8, // does not include inactive
|
||||
healthy: 3,
|
||||
unhealthy: 3,
|
||||
offline: 1,
|
||||
unenrolled: 0,
|
||||
inactive: 1,
|
||||
updating: 1,
|
||||
updating: 1, // includes enrolling + unenrolling + updating
|
||||
total_all_statuses: 8,
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue