-
Notifications
You must be signed in to change notification settings - Fork 8.6k
[Automatic Migration] Introduce Last execution info for a migration #221635
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
7373a72
incremental commit
logeekal e270fb5
fix: ui changes
logeekal 170c37d
connector ID for last execution
logeekal 4ec44c4
🚧 tests + housekeeping
logeekal 3becfa2
fix: housekeeping + tests
logeekal a670ced
revert unnecessary change
logeekal 13497f3
housekeeping: extract constant
logeekal 9703e8e
fix: types + i18n
logeekal 9a4f618
remove unnecessary comment
logeekal 4e5934a
remove unnecessary yarn.lock
logeekal cfab544
PR Feedback: pRetry
logeekal 85b3b8a
fix: update last execution fields to nullable
logeekal b876124
better status updates
logeekal 185fdde
pr feedback: translations
logeekal 3ad1266
fix: background completion update
logeekal 2567e63
pr feedback: translations
logeekal 70ef273
Merge main --> current branch
logeekal 5b15835
fix: conflict ES error
logeekal de7721c
revert task runner changes
logeekal 6930b3b
fix: better naming + PR Feedback
logeekal 9ef6678
Restart -> Resume
logeekal f27f6ba
fix: remove connector_id as nullable
logeekal 2402a9c
fix: unhandled promises
logeekal 6bf6431
Merge branch 'main' into fix/stop_migration_status
logeekal 8655814
Merge branch 'main' into fix/stop_migration_status
logeekal File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
167 changes: 167 additions & 0 deletions
167
...c/siem_migrations/rules/components/migration_status_panels/migration_ready_panel.test.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,167 @@ | ||
| /* | ||
| * 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 React from 'react'; | ||
| import { render, screen, waitFor } from '@testing-library/react'; | ||
| import { MigrationReadyPanel } from './migration_ready_panel'; | ||
| import { useGetMissingResources } from '../../service/hooks/use_get_missing_resources'; | ||
| import { useStartMigration } from '../../service/hooks/use_start_migration'; | ||
| import { SiemMigrationTaskStatus } from '../../../../../common/siem_migrations/constants'; | ||
| import type { RuleMigrationResourceBase } from '../../../../../common/siem_migrations/model/rule_migration.gen'; | ||
|
|
||
| jest.mock('../data_input_flyout/context', () => ({ | ||
| useRuleMigrationDataInputContext: () => ({ | ||
| openFlyout: jest.fn(), | ||
| }), | ||
| })); | ||
|
|
||
| jest.mock('../../../../common/lib/kibana/kibana_react', () => ({ | ||
| useKibana: jest.fn(() => ({ | ||
| services: { | ||
| siemMigrations: { | ||
| rules: { | ||
| telemetry: jest.fn(), | ||
| }, | ||
| }, | ||
| }, | ||
| })), | ||
| })); | ||
|
|
||
| jest.mock('../../service/hooks/use_start_migration'); | ||
| const useStartMigrationMock = useStartMigration as jest.Mock; | ||
| const mockStartMigration = jest.fn(); | ||
|
|
||
| const mockMigrationStateWithError = { | ||
| status: SiemMigrationTaskStatus.READY, | ||
| last_error: | ||
| 'Failed to populate ELSER indices. Make sure the ELSER model is deployed and running at Machine Learning > Trained Models. Error: Exception when running inference id [.elser-2-elasticsearch] on field [elser_embedding]', | ||
| id: 'c44d2c7d-0de1-4231-8b82-0dcfd67a9fe3', | ||
| rules: { total: 6, pending: 6, processing: 0, completed: 0, failed: 0 }, | ||
| created_at: '2025-05-27T12:12:17.563Z', | ||
| last_updated_at: '2025-05-27T12:12:17.563Z', | ||
| number: 1, | ||
| }; | ||
|
|
||
| const mockMigrationStatsAborted = { | ||
| status: SiemMigrationTaskStatus.ABORTED, | ||
| id: 'c44d2c7d-0de1-4231-8b82-0dcfd67a9fe3', | ||
| rules: { total: 6, pending: 6, processing: 0, completed: 0, failed: 0 }, | ||
| created_at: '2025-05-27T12:12:17.563Z', | ||
| last_updated_at: '2025-05-27T12:12:17.563Z', | ||
| number: 1, | ||
| }; | ||
|
|
||
| const mockMigrationStatsReady = { | ||
| status: SiemMigrationTaskStatus.READY, | ||
| id: 'c44d2c7d-0de1-4231-8b82-0dcfd67a9fe3', | ||
| rules: { total: 6, pending: 6, processing: 0, completed: 0, failed: 0 }, | ||
| created_at: '2025-05-27T12:12:17.563Z', | ||
| last_updated_at: '2025-05-27T12:12:17.563Z', | ||
| number: 1, | ||
| }; | ||
|
|
||
| const missingMacro: RuleMigrationResourceBase = { | ||
| type: 'macro', | ||
| name: 'macro1', | ||
| }; | ||
| const missingLookup: RuleMigrationResourceBase = { | ||
| type: 'lookup', | ||
| name: 'lookup1', | ||
| }; | ||
|
|
||
| jest.mock('../../service/hooks/use_get_missing_resources'); | ||
| const useGetMissingResourcesMock = useGetMissingResources as jest.Mock; | ||
|
|
||
| describe('MigrationReadyPanel', () => { | ||
| beforeEach(() => { | ||
| useGetMissingResourcesMock.mockReturnValue({ | ||
| getMissingResources: jest.fn().mockResolvedValue([]), | ||
| isLoading: false, | ||
| }); | ||
|
|
||
| useStartMigrationMock.mockReturnValue({ | ||
| startMigration: mockStartMigration, | ||
| isLoading: false, | ||
| error: null, | ||
| }); | ||
| }); | ||
|
|
||
| describe('Ready Migration', () => { | ||
| it('should render description text correctly', () => { | ||
| render(<MigrationReadyPanel migrationStats={mockMigrationStatsReady} />); | ||
| expect(screen.getByTestId('ruleMigrationDescription')).toHaveTextContent( | ||
| `Migration of 6 rules is created but the translation has not started yet.` | ||
| ); | ||
| }); | ||
|
|
||
| it('should render start migration button', () => { | ||
| render(<MigrationReadyPanel migrationStats={mockMigrationStatsReady} />); | ||
| expect(screen.getByTestId('startMigrationButton')).toBeVisible(); | ||
| expect(screen.getByTestId('startMigrationButton')).toHaveTextContent('Start translation'); | ||
| }); | ||
| }); | ||
|
|
||
| describe('Migration with Error', () => { | ||
| it('should render error message when migration has an error', () => { | ||
| render(<MigrationReadyPanel migrationStats={mockMigrationStateWithError} />); | ||
| expect(screen.getByTestId('ruleMigrationDescription')).toHaveTextContent( | ||
| 'Migration of 6 rules failed. Please correct the below error and try again.' | ||
| ); | ||
| expect(screen.getByTestId('ruleMigrationLastError')).toHaveTextContent( | ||
| 'Failed to populate ELSER indices. Make sure the ELSER model is deployed and running at Machine Learning > Trained Models. Error: Exception when running inference id [.elser-2-elasticsearch] on field [elser_embedding]' | ||
| ); | ||
| }); | ||
|
|
||
| it('should render start migration button when there is an error', () => { | ||
| render(<MigrationReadyPanel migrationStats={mockMigrationStateWithError} />); | ||
| expect(screen.queryByTestId('startMigrationButton')).toHaveTextContent('Start translation'); | ||
| }); | ||
| }); | ||
|
|
||
| describe('Aborted Migration', () => { | ||
| it('should render aborted migration message', () => { | ||
| render(<MigrationReadyPanel migrationStats={mockMigrationStatsAborted} />); | ||
| expect(screen.getByTestId('ruleMigrationDescription')).toHaveTextContent( | ||
| 'Migration of 6 rules was stopped. You can resume it any time.' | ||
| ); | ||
| }); | ||
|
|
||
| it('should render correct start migration button for aborted migration', () => { | ||
| render(<MigrationReadyPanel migrationStats={mockMigrationStatsAborted} />); | ||
| expect(screen.getByTestId('startMigrationButton')).toHaveTextContent('Resume translation'); | ||
| }); | ||
| }); | ||
|
|
||
| describe('Missing Resources', () => { | ||
| const missingResources = [missingMacro, missingLookup]; | ||
|
|
||
| beforeEach(() => { | ||
| useGetMissingResourcesMock.mockImplementation((setterFn: Function) => { | ||
| return { | ||
| getMissingResources: jest.fn().mockImplementation(() => { | ||
| setterFn(missingResources); | ||
| }), | ||
| isLoading: false, | ||
| }; | ||
| }); | ||
| }); | ||
|
|
||
| it('should render missing resources warning when there are missing resources', async () => { | ||
| render(<MigrationReadyPanel migrationStats={mockMigrationStatsReady} />); | ||
| await waitFor(() => { | ||
| expect(screen.getByTestId('ruleMigrationDescription')).toHaveTextContent( | ||
| 'Migration of 6 rules is created but the translation has not started yet. Upload macros & lookups and start the translation process.' | ||
| ); | ||
| }); | ||
| }); | ||
|
|
||
| it('should render missing resources button', async () => { | ||
| render(<MigrationReadyPanel migrationStats={mockMigrationStatsReady} />); | ||
| expect(screen.getByTestId('ruleMigrationMissingResourcesButton')).toBeVisible(); | ||
| }); | ||
| }); | ||
| }); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.