mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
Fix condition and adjust tests (#78898)
(cherry picked from commit 676ce45993
)
This commit is contained in:
parent
a31dd64778
commit
f6be7dc2f9
2 changed files with 24 additions and 5 deletions
|
@ -80,7 +80,15 @@ describe('test agent checkin new action services', () => {
|
|||
expect(
|
||||
await createAgentActionFromPolicyAction(
|
||||
mockSavedObjectsClient,
|
||||
{ ...mockAgent, local_metadata: { elastic: { agent: { version: '7.10.1-SNAPSHOT' } } } },
|
||||
{ ...mockAgent, local_metadata: { elastic: { agent: { version: '7.10.0-SNAPSHOT' } } } },
|
||||
mockPolicyAction
|
||||
)
|
||||
).toEqual(expectedResult);
|
||||
|
||||
expect(
|
||||
await createAgentActionFromPolicyAction(
|
||||
mockSavedObjectsClient,
|
||||
{ ...mockAgent, local_metadata: { elastic: { agent: { version: '7.10.2' } } } },
|
||||
mockPolicyAction
|
||||
)
|
||||
).toEqual(expectedResult);
|
||||
|
@ -131,7 +139,7 @@ describe('test agent checkin new action services', () => {
|
|||
expect(
|
||||
await createAgentActionFromPolicyAction(
|
||||
mockSavedObjectsClient,
|
||||
{ ...mockAgent, local_metadata: { elastic: { agent: { version: '7.9.1-SNAPSHOT' } } } },
|
||||
{ ...mockAgent, local_metadata: { elastic: { agent: { version: '7.9.3' } } } },
|
||||
mockPolicyAction
|
||||
)
|
||||
).toEqual(expectedResult);
|
||||
|
@ -139,7 +147,7 @@ describe('test agent checkin new action services', () => {
|
|||
expect(
|
||||
await createAgentActionFromPolicyAction(
|
||||
mockSavedObjectsClient,
|
||||
{ ...mockAgent, local_metadata: { elastic: { agent: { version: '7.9.3' } } } },
|
||||
{ ...mockAgent, local_metadata: { elastic: { agent: { version: '7.9.1-SNAPSHOT' } } } },
|
||||
mockPolicyAction
|
||||
)
|
||||
).toEqual(expectedResult);
|
||||
|
|
|
@ -116,10 +116,21 @@ export async function createAgentActionFromPolicyAction(
|
|||
agent: Agent,
|
||||
policyAction: AgentPolicyAction
|
||||
) {
|
||||
// Transform the policy action for agent version <= 7.9 for BWC
|
||||
// Transform the policy action for agent version <= 7.9.x for BWC
|
||||
const agentVersion = semver.parse((agent.local_metadata?.elastic as any)?.agent?.version);
|
||||
const agentPolicyAction: AgentPolicyAction | AgentPolicyActionV7_9 =
|
||||
agentVersion && semver.lt(agentVersion, '7.10.0')
|
||||
agentVersion &&
|
||||
semver.lt(
|
||||
agentVersion,
|
||||
// A prerelease tag is added here so that agent versions with prerelease tags can be compared
|
||||
// correctly using `semvar`
|
||||
'7.10.0-SNAPSHOT',
|
||||
// `@types/semvar` is out of date with the version of `semvar` we use and doesn't have a
|
||||
// corresponding release version we can update the typing to :( so, the typing error is
|
||||
// suppressed here even though it is supported by `semvar`
|
||||
// @ts-expect-error
|
||||
{ includePrerelease: true }
|
||||
)
|
||||
? {
|
||||
...policyAction,
|
||||
type: 'CONFIG_CHANGE',
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue