From 1dc9f70711a82dfb7e4e7bc10f6c3ab252d6f27d Mon Sep 17 00:00:00 2001 From: Kyle Pollich Date: Wed, 29 Nov 2023 15:01:56 -0500 Subject: [PATCH] Unskip flaky suites in agent service jest tests Closes https://github.com/elastic/kibana/issues/172114 Closes https://github.com/elastic/kibana/issues/171536 Closes https://github.com/elastic/kibana/issues/171160 Closes https://github.com/elastic/kibana/issues/171052 Closes https://github.com/elastic/kibana/issues/171541 --- .../fleet/server/services/agents/crud.test.ts | 11 +++++++++-- .../fleet/server/services/agents/upgrade.test.ts | 15 ++++++++++----- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/x-pack/plugins/fleet/server/services/agents/crud.test.ts b/x-pack/plugins/fleet/server/services/agents/crud.test.ts index db08161c95190..d8d65a695d3eb 100644 --- a/x-pack/plugins/fleet/server/services/agents/crud.test.ts +++ b/x-pack/plugins/fleet/server/services/agents/crud.test.ts @@ -27,6 +27,14 @@ jest.mock('../audit_logging'); jest.mock('../../../common/services/is_agent_upgradeable', () => ({ isAgentUpgradeable: jest.fn().mockImplementation((agent: Agent) => agent.id.includes('up')), })); +jest.mock('./versions', () => { + return { + getAvailableVersions: jest + .fn() + .mockResolvedValue(['8.4.0', '8.5.0', '8.6.0', '8.7.0', '8.8.0']), + getLatestAvailableVersion: jest.fn().mockResolvedValue('8.8.0'), + }; +}); const mockedAuditLoggingService = auditLoggingService as jest.Mocked; @@ -151,8 +159,7 @@ describe('Agents CRUD test', () => { }); }); - // FLAKY: https://github.com/elastic/kibana/issues/171541 - describe.skip('getAgentsByKuery', () => { + describe('getAgentsByKuery', () => { it('should return upgradeable on first page', async () => { searchMock .mockImplementationOnce(() => Promise.resolve(getEsResponse(['1', '2', '3', '4', '5'], 7))) diff --git a/x-pack/plugins/fleet/server/services/agents/upgrade.test.ts b/x-pack/plugins/fleet/server/services/agents/upgrade.test.ts index d847bf1aceb38..23688ec52462a 100644 --- a/x-pack/plugins/fleet/server/services/agents/upgrade.test.ts +++ b/x-pack/plugins/fleet/server/services/agents/upgrade.test.ts @@ -15,6 +15,15 @@ import { sendUpgradeAgentsActions } from './upgrade'; import { createClientMock } from './action.mock'; import { getRollingUpgradeOptions, upgradeBatch } from './upgrade_action_runner'; +jest.mock('./versions', () => { + return { + getAvailableVersions: jest + .fn() + .mockResolvedValue(['8.4.0', '8.5.0', '8.6.0', '8.7.0', '8.8.0']), + getLatestAvailableVersion: jest.fn().mockResolvedValue('8.8.0'), + }; +}); + jest.mock('./action_status', () => { return { getCancelledActions: jest.fn().mockResolvedValue([ @@ -25,11 +34,7 @@ jest.mock('./action_status', () => { }; }); -// FLAKY: https://github.com/elastic/kibana/issues/171052 -// FLAKY: https://github.com/elastic/kibana/issues/172114 -// FLAKY: https://github.com/elastic/kibana/issues/171536 -// FLAKY: https://github.com/elastic/kibana/issues/171160 -describe.skip('sendUpgradeAgentsActions (plural)', () => { +describe('sendUpgradeAgentsActions (plural)', () => { beforeEach(async () => { appContextService.start(createAppContextStartContractMock()); });