Skip to content

Commit

Permalink
[Fleet] allow fleet-server agent upgrade to newer than fleet-server (e…
Browse files Browse the repository at this point in the history
…lastic#181575)

## Summary

Closes elastic#181394

Allow upgrade fleet-server even if fleet-server version is older than
the upgrade version.
See testing steps in the linked issue.

### Checklist

- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
  • Loading branch information
juliaElastic authored Apr 24, 2024
1 parent d5999c3 commit d635c6d
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,43 @@ describe('AgentUpgradeAgentModal', () => {
expect(el).not.toBeDisabled();
});
});

it('should enable submit button for a single fleet-server when version is greater than maxFleetServerVersion', async () => {
mockSendGetAgentsAvailableVersions.mockClear();
mockSendGetAgentsAvailableVersions.mockResolvedValue({
data: {
items: ['8.10.4', '8.10.2', '8.9.0', '8.8.0'],
},
});
mockSendAllFleetServerAgents.mockResolvedValue({
allFleetServerAgents: [
{ id: 'fleet-server', local_metadata: { elastic: { agent: { version: '8.9.0' } } } },
] as any,
});

const { utils } = renderAgentUpgradeAgentModal({
agents: [
{
id: 'fleet-server',
local_metadata: {
elastic: {
agent: { version: '8.9.0', upgradeable: true },
},
host: { hostname: 'host00001' },
},
},
] as any,
agentCount: 1,
});

await waitFor(() => {
const container = utils.getByTestId('agentUpgradeModal.VersionCombobox');
const input = within(container).getByRole<HTMLInputElement>('combobox');
expect(input?.value).toEqual('8.10.2');
const el = utils.getByTestId('confirmModalConfirmButton');
expect(el).toBeEnabled();
});
});
});

describe('restart upgrade', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,13 +287,17 @@ export const AgentUpgradeAgentModal: React.FunctionComponent<AgentUpgradeAgentMo
const { startDatetime, onChangeStartDateTime, initialDatetime, minTime, maxTime } =
useScheduleDateTime();

const isSingleAgentFleetServer =
isSingleAgent && fleetServerAgents.map((agent) => agent.id).includes(agents[0].id);

const isSubmitButtonDisabled = useMemo(
() =>
isSubmitting ||
(isUpdating && updatingAgents === 0) ||
!selectedVersion[0].value ||
(isSingleAgent && !isAgentUpgradeableToVersion(agents[0], selectedVersion[0].value)) ||
(isSingleAgent &&
!isSingleAgentFleetServer &&
!isAgentVersionLessThanFleetServer(selectedVersion[0].value, fleetServerAgents)),
[
agents,
Expand All @@ -303,6 +307,7 @@ export const AgentUpgradeAgentModal: React.FunctionComponent<AgentUpgradeAgentMo
isUpdating,
selectedVersion,
updatingAgents,
isSingleAgentFleetServer,
]
);

Expand Down

0 comments on commit d635c6d

Please sign in to comment.