diff --git a/x-pack/plugins/upgrade_assistant/common/types.ts b/x-pack/plugins/upgrade_assistant/common/types.ts index 5fb1cc8e0372f3..9bcbf629a88f64 100644 --- a/x-pack/plugins/upgrade_assistant/common/types.ts +++ b/x-pack/plugins/upgrade_assistant/common/types.ts @@ -240,7 +240,7 @@ export interface SystemIndicesUpgradeFeature { upgrade_status: UPGRADE_STATUS; indices: Array<{ index: string; - index_version: string; + version: string; }>; } export interface SystemIndicesUpgradeStatus { diff --git a/x-pack/plugins/upgrade_assistant/server/lib/es_system_indices_upgrade.test.ts b/x-pack/plugins/upgrade_assistant/server/lib/es_system_indices_upgrade.test.ts new file mode 100644 index 00000000000000..8010d7ff7acfaf --- /dev/null +++ b/x-pack/plugins/upgrade_assistant/server/lib/es_system_indices_upgrade.test.ts @@ -0,0 +1,53 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import { convertFeaturesListToArray } from './es_system_indices_upgrade'; +import { SystemIndicesUpgradeStatus } from '../../common/types'; + +const esUpgradeSystemIndicesStatusMock: SystemIndicesUpgradeStatus = { + features: [ + { + feature_name: 'machine_learning', + minimum_index_version: '7.1.1', + upgrade_status: 'UPGRADE_NEEDED', + indices: [ + { + index: '.ml-config', + version: '7.1.1', + }, + { + index: '.ml-notifications', + version: '7.1.1', + }, + ], + }, + { + feature_name: 'security', + minimum_index_version: '7.1.1', + upgrade_status: 'UPGRADE_NEEDED', + indices: [ + { + index: '.ml-config', + version: '7.1.1', + }, + ], + }, + ], + upgrade_status: 'UPGRADE_NEEDED', +}; + +describe('convertFeaturesListToArray', () => { + it('converts list with features to flat array of uniq indices', async () => { + const result = convertFeaturesListToArray(esUpgradeSystemIndicesStatusMock.features); + expect(result).toEqual(['.ml-config', '.ml-notifications']); + }); + + it('returns empty array if no features are passed to it', async () => { + const result = convertFeaturesListToArray([]); + expect(result).toEqual([]); + }); +});