From 65b8dda1576c340b9d4e8ac30b75b9d8adeb341b Mon Sep 17 00:00:00 2001 From: Quynh Nguyen <43350163+qn895@users.noreply.github.com> Date: Tue, 8 Jun 2021 14:50:14 -0500 Subject: [PATCH 01/19] [ML] Move Index Data Visualizer into separate plugin (Part 1) (#100922) * [ML] Add index visualizer * [ML] Readd support for global state * [ML] Add time buckets & fix dependencies * [ML] Working ver * [ML] Add back and boolean support * [ML] Remove old files inside ml * [ML] Rename files * [ML] Move field type icon * [ML] Create new folder structure * [ML] Organize index_data_visualizer * [ML] Move types into index_data_visualizer folder * [ML] Move more files into file_data_visualizer * [ML] Move more files into index_data_visualizer * [ML] Add new data visualizer model * [ML] Remove getVisualizerFieldStats which is not used by dv * [ML] Delete redundant folder * [ML] Copy old data visualizer routes to new plugin * [ML] Remove old routes * [ML] Disable for ml job cards tests for now * [ML] Remove todos * [ML] Move the toast error to the UI component * [ML] Fix map styling * [ML] Add runtime_mappings for internal/file_upload/time_field_range * [ML] Move routes into folder * [ML] Update permissions * [ML] Update texts * [ML] Update schemas import and api get_field_stats * [ML] Reorg folders into common * [ML] Update types & tests * [ML] Update internal/data_visualizer permissions and action panel tests * [ML] Update imports after #100863 * [ML] Fix CI * [ML] Rename folder from file_data_visualizer to data_visualizer * [ML] Rename i18n ids * [ML] Update fileDataVisualizer -> dataVisualizer dependency name in ml plugin * [ML] Remove ml prefix in data test subjs * [ML] Fix settings and docs * [ML] Update plugin description * [ML] Remove mlContext dependency completely * [ML] Set query to optional * Revert "[ML] Update plugin description" This reverts commit 4ab1a25c * [ML] Update plugins list docs * [ML] Fix types and i18n * [ML] Revert ml data test subj/class name changes * [ML] Split up data visualizer model, remove Logger * [ML] Remove empty file and indexPatternFieldEditor * [ML] Move imports of file_upload * [ML] Update plugin dependencies * Re-add missing data_visualizer.json * Remove capabilities in data_visualizer * Fix test subjs * Update ownership for data_visualizer and file_upload code to be ml * Update estypes after 98266 Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> --- .github/CODEOWNERS | 46 +- ...a_visualizer.json => data_visualizer.json} | 88 +-- ...ata_visualizer.mdx => data_visualizer.mdx} | 0 docs/developer/plugin-list.asciidoc | 8 +- packages/kbn-optimizer/limits.yml | 2 +- x-pack/.i18nrc.json | 2 +- x-pack/plugins/data_visualizer/README.md | 1 + .../common/constants.ts | 2 + .../common/index.ts | 0 .../common/types/field_request_config.ts | 60 ++ .../common/types/index.ts} | 15 +- .../common/types/indices.ts} | 8 +- .../common/types/job_field_type.ts} | 5 +- .../common/types/time_field_request.ts} | 7 +- .../common/utils/datafeed_utils.ts | 23 + .../common/utils/object_utils.ts | 36 ++ .../common/utils/query_utils.ts | 76 +++ .../common/utils/runtime_field_utils.ts | 28 + .../common/utils/string_utils.ts | 23 + .../jest.config.js | 2 +- .../kibana.json | 5 +- .../public/api/index.ts | 8 +- .../public/application/_index.scss | 2 + .../application/common/components/_index.scss | 4 + .../combined_fields/combined_field_label.tsx | 0 .../combined_fields/combined_fields_form.tsx | 30 +- .../combined_fields_read_only_form.tsx | 4 +- .../components/combined_fields/geo_point.tsx | 12 +- .../components/combined_fields/index.ts | 0 .../components/combined_fields/types.ts | 0 .../components/combined_fields/utils.test.ts | 0 .../components/combined_fields/utils.ts | 4 +- .../date_picker_wrapper.tsx | 172 ++++++ .../components/date_picker_wrapper/index.ts | 8 + .../document_count_chart.tsx | 12 +- .../document_count_chart/index.ts | 0 .../document_count_content.tsx | 6 +- .../document_count_content}/index.ts | 1 - .../total_count_header.tsx | 8 +- .../embedded_map/_embedded_map.scss | 0 .../components/embedded_map/_index.scss | 0 .../components/embedded_map/embedded_map.tsx | 16 +- .../common}/components/embedded_map/index.ts | 0 .../examples_list/examples_list.tsx | 6 +- .../common}/components/examples_list/index.ts | 0 .../expanded_row/file_based_expanded_row.tsx | 4 +- .../geo_point_content/format_utils.ts | 2 +- .../geo_point_content/geo_point_content.tsx | 4 +- .../expanded_row/geo_point_content/index.ts | 0 .../geo_point_content_with_map.tsx} | 39 +- .../geo_point_content_with_map}/index.ts | 2 +- .../common}/components/expanded_row/index.ts | 0 .../index_based_expanded_row.tsx} | 39 +- .../_experimental_badge.scss | 0 .../components/experimental_badge/_index.scss | 0 .../experimental_badge/experimental_badge.tsx | 2 +- .../components/experimental_badge/index.ts | 0 .../field_count_panel/field_count_panel.tsx | 15 +- .../components/field_count_panel/index.ts | 0 .../field_data_row/action_menu/actions.ts | 26 +- .../field_data_row/action_menu/index.ts | 0 .../field_data_row/action_menu/lens_utils.ts | 47 +- .../components/field_data_row/index.ts | 0 .../field_data_row/number_content_preview.tsx | 12 +- .../field_names_filter/field_names_filter.tsx | 4 +- .../components/field_names_filter/index.ts | 0 .../field_type_icon.test.tsx.snap | 0 .../field_type_icon/field_type_icon.test.tsx | 2 +- .../field_type_icon/field_type_icon.tsx | 6 +- .../components/field_type_icon/index.ts | 0 .../field_types_filter/field_types_filter.tsx | 6 +- .../components/field_types_filter/index.ts | 0 .../fields_stats_grid/create_fields.ts | 4 +- .../fields_stats_grid/fields_stats_grid.tsx | 8 +- .../fields_stats_grid/filter_fields.ts | 2 +- .../fields_stats_grid/get_field_names.ts | 8 +- .../components/fields_stats_grid/index.ts | 0 .../filebeat_config_flyout/filebeat_config.ts | 4 +- .../filebeat_config_flyout.tsx | 20 +- .../filebeat_config_flyout/index.ts | 0 .../common/components/help_menu/help_menu.tsx | 37 ++ .../common/components/help_menu/index.tsx | 8 + .../common/components/link_card}/index.ts | 2 +- .../common/components/link_card/link_card.tsx | 81 +++ .../components}/loading_indicator/index.ts | 0 .../loading_indicator/loading_indicator.tsx | 6 +- .../components/multi_select_picker/index.ts | 0 .../multi_select_picker.tsx | 2 +- .../components/not_in_docs_content}/index.ts | 2 +- .../not_in_docs_context.tsx} | 2 +- .../common}/components/results_links/index.ts | 0 .../results_links/results_links.tsx | 22 +- .../stats_table/_field_data_row.scss | 0 .../components/stats_table/_index.scss | 0 .../expanded_row_field_header.tsx | 0 .../expanded_row_field_header/index.ts | 0 .../components/field_count_stats/_index.scss | 0 .../components/field_count_stats/index.ts | 0 .../field_count_stats/metric_fields_count.tsx | 10 +- .../field_count_stats/total_fields_count.tsx | 10 +- .../field_data_expanded_row/_index.scss | 0 .../_number_content.scss | 0 .../boolean_content.tsx | 10 +- .../choropleth_map.tsx | 12 +- .../field_data_expanded_row/date_content.tsx | 10 +- .../document_stats.tsx | 10 +- .../expanded_row_content.tsx | 0 .../field_data_expanded_row/index.ts | 0 .../field_data_expanded_row/ip_content.tsx | 2 +- .../keyword_content.tsx | 8 +- .../number_content.tsx | 18 +- .../field_data_expanded_row/other_content.tsx | 2 +- .../field_data_expanded_row/text_content.tsx | 8 +- .../components/field_data_row/_index.scss | 0 .../boolean_content_preview.tsx | 10 +- .../field_data_row/column_chart.scss | 0 .../field_data_row/column_chart.tsx | 0 .../field_data_row/distinct_values.tsx | 0 .../field_data_row/document_stats.tsx | 0 .../field_data_row/field_histograms.ts | 0 .../components/field_data_row/index.ts | 0 .../field_data_row/number_content_preview.tsx | 2 +- .../field_data_row/top_values_preview.tsx | 2 +- .../field_data_row/use_column_chart.test.tsx | 2 +- .../field_data_row/use_column_chart.tsx | 10 +- .../metric_distribution_chart/index.ts | 0 .../metric_distribution_chart.tsx | 4 +- ...metric_distribution_chart_data_builder.tsx | 0 ...tric_distribution_chart_tooltip_header.tsx | 4 +- .../data_visualizer_stats_table.tsx | 81 ++- .../stats_table/hooks/color_range_legend.tsx | 0 .../components/stats_table/hooks/index.ts | 0 .../stats_table/hooks/use_color_range.test.ts | 0 .../stats_table/hooks/use_color_range.ts | 41 +- .../hooks/use_data_viz_chart_theme.ts | 0 .../common}/components/stats_table/index.ts | 0 .../stats_table/types/field_data_row.ts | 0 .../stats_table/types/field_vis_config.ts | 42 +- .../components/stats_table/types/index.ts | 1 - .../stats_table/use_table_settings.ts | 2 +- .../common}/components/stats_table/utils.ts | 0 .../components/top_values/_top_values.scss | 0 .../common}/components/top_values/index.ts | 0 .../components/top_values/top_values.tsx | 15 +- .../common}/components/utils/format_value.ts | 0 .../common}/components/utils/index.ts | 0 .../components/utils/kibana_field_format.ts | 0 .../utils/number_as_ordinal.test.ts | 0 .../components/utils/number_as_ordinal.ts | 0 .../utils/round_to_decimal_place.test.ts | 0 .../utils/round_to_decimal_place.ts | 0 .../common}/components/utils/utils.ts | 2 +- .../common}/util/field_types_utils.test.ts | 2 +- .../common/util/field_types_utils.ts | 87 +++ .../application/common}/util/get_max_bytes.ts | 2 +- .../common/util/parse_interval.test.ts | 45 ++ .../application/common/util/parse_interval.ts | 65 +++ .../application/common/util/url_state.tsx | 148 +++++ .../file_data_visualizer}/_index.scss | 0 .../components/_index.scss | 8 +- .../components/about_panel/_about_panel.scss | 0 .../components/about_panel/_index.scss | 0 .../components/about_panel/about_panel.tsx | 8 +- .../components/about_panel/index.ts | 0 .../about_panel/welcome_content.tsx | 24 +- .../analysis_summary/_analysis_summary.scss | 0 .../components/analysis_summary/_index.scss | 0 .../analysis_summary/analysis_summary.tsx | 18 +- .../components/analysis_summary/index.ts | 0 .../components/bottom_bar/bottom_bar.tsx | 14 +- .../components/bottom_bar/index.ts | 0 .../__snapshots__/overrides.test.js.snap | 8 +- .../components/edit_flyout/_edit_flyout.scss | 0 .../components/edit_flyout/_index.scss | 1 + .../components/edit_flyout/edit_flyout.js | 6 +- .../components/edit_flyout/index.js | 0 .../components/edit_flyout/options/index.js | 0 .../edit_flyout/options/option_lists.js | 0 .../components/edit_flyout/options/options.js | 0 .../components/edit_flyout/overrides.js | 39 +- .../components/edit_flyout/overrides.test.js | 2 +- .../edit_flyout/overrides_validation.js | 8 +- .../explanation_flyout/explanation_flyout.tsx | 8 +- .../components/explanation_flyout/index.ts | 0 .../file_contents/_file_contents.scss | 0 .../components/file_contents/_index.scss | 0 .../file_contents/file_contents.tsx | 4 +- .../components/file_contents/index.ts | 0 .../_file_data_visualizer_view.scss} | 0 .../file_data_visualizer_view/_index.scss | 1 + .../file_data_visualizer_view}/constants.ts | 0 .../file_data_visualizer_view.js} | 9 +- .../file_error_callouts.tsx | 22 +- .../file_data_visualizer_view}/index.js | 2 +- .../components/import_errors/errors.tsx | 20 +- .../components/import_errors/index.ts | 0 .../import_progress/import_progress.tsx | 47 +- .../components/import_progress/index.ts | 0 .../components/import_settings/advanced.tsx | 20 +- .../import_settings/import_settings.tsx | 8 +- .../components/import_settings/index.ts | 0 .../components/import_settings/simple.tsx | 17 +- .../import_summary/_import_summary.scss} | 0 .../components/import_summary/_index.scss | 1 + .../components/import_summary/failures.tsx | 2 +- .../import_summary/import_summary.tsx | 18 +- .../components/import_summary/index.ts | 0 .../components/import_view/import_view.js | 38 +- .../components/import_view/index.js | 0 .../components/json_editor/index.ts | 0 .../components/json_editor/json_editor.tsx | 2 +- .../components/results_view/_index.scss | 1 + .../results_view/_results_view.scss | 0 .../components/results_view/index.ts | 0 .../components/results_view/results_view.tsx | 22 +- .../file_data_visualizer.tsx} | 19 +- .../application/file_data_visualizer/index.ts | 8 + .../public/application}/index.ts | 10 +- .../actions_panel/actions_panel.tsx | 122 ++++ .../components/actions_panel/index.ts | 0 .../full_time_range_selector.tsx | 73 +++ .../full_time_range_selector_service.ts | 52 ++ .../full_time_range_selector/index.tsx} | 8 +- .../index_data_visualizer_view/index.ts | 11 + .../index_data_visualizer_view.tsx} | 237 ++++---- .../search_panel/field_name_filter.tsx | 10 +- .../search_panel/field_type_filter.tsx | 31 +- .../components/search_panel/index.ts | 0 .../components/search_panel/search_panel.tsx | 40 +- .../search_panel/shard_size_select.tsx | 14 +- .../constants/index_data_visualizer_viewer.ts | 8 + .../data_loader/data_loader.ts | 143 +++++ .../hooks/use_time_filter.ts | 38 ++ .../index_data_visualizer/index.ts | 9 + .../index_data_visualizer.tsx | 200 +++++++ .../services/time_buckets.d.ts | 45 ++ .../services/time_buckets.js | 515 +++++++++++++++++ .../services/time_field_range.ts | 32 ++ .../services/timefilter_refresh_service.ts | 16 + .../services/visualizer_stats.ts | 98 ++++ .../types/combined_query.ts | 23 + .../types/index_data_visualizer_state.ts | 28 + .../types/overall_stats.ts} | 1 + .../utils/saved_search_utils.ts | 119 ++++ .../public/application/kibana_context.ts | 6 +- .../public/application/shared_imports.ts | 0 .../public/index.ts | 8 +- .../public/kibana_services.ts | 6 +- .../lazy_load_bundle/component_wrapper.tsx | 4 +- .../public/lazy_load_bundle/index.ts | 5 +- .../public/lazy_load_bundle/lazy/index.ts | 13 + .../public/plugin.ts | 34 +- .../public/register_home.ts | 2 +- .../plugins/data_visualizer/server/index.ts | 11 + .../data_visualizer/check_fields_exist.ts | 183 ++++++ .../models/data_visualizer/constants.ts | 13 + .../models/data_visualizer/data_visualizer.ts | 475 +++++++++++++++ .../data_visualizer/get_field_examples.ts | 80 +++ .../data_visualizer/get_fields_stats.ts | 478 ++++++++++++++++ .../get_histogram_for_fields.ts | 188 ++++++ .../server/models/data_visualizer}/index.ts | 2 +- .../process_distribution_data.ts | 108 ++++ .../plugins/data_visualizer/server/plugin.ts | 20 + .../server/routes}/index.ts | 2 +- .../data_visualizer/server/routes/routes.ts | 262 +++++++++ .../server/routes/schemas}/index.ts | 2 +- .../schemas/index_data_visualizer_schemas.ts | 76 +++ .../server/types/chart_data.ts | 168 ++++++ .../data_visualizer/server/types/deps.ts | 16 + .../server/types}/index.ts | 4 +- .../server/utils/error_wrapper.ts | 24 + .../tsconfig.json | 3 +- .../components/edit_flyout/_index.scss | 1 - .../file_datavisualizer_view/_index.scss | 1 - .../components/import_summary/_index.scss | 1 - .../components/results_view/_index.scss | 1 - .../boolean_content_preview.tsx | 43 -- .../application/util/field_types_utils.ts | 49 -- .../server/get_time_field_range.ts | 7 +- x-pack/plugins/file_upload/server/plugin.ts | 7 +- x-pack/plugins/file_upload/server/routes.ts | 13 +- x-pack/plugins/file_upload/server/schemas.ts | 13 + x-pack/plugins/file_upload/server/types.ts | 5 + .../server/utils/runtime_field_utils.ts | 41 ++ .../ml/common/types/ml_url_generator.ts | 24 +- x-pack/plugins/ml/kibana.json | 2 +- .../ml/public/__mocks__/ml_start_deps.ts | 2 +- .../plugins/ml/public/application/_index.scss | 2 - x-pack/plugins/ml/public/application/app.tsx | 4 +- .../field_title_bar/_field_title_bar.scss | 28 - .../components/field_title_bar/_index.scss | 1 - .../field_title_bar/field_title_bar.test.tsx | 113 ---- .../field_title_bar/field_title_bar.tsx | 64 --- .../field_type_icon.test.tsx.snap | 16 - .../field_type_icon/field_type_icon.test.tsx | 52 -- .../field_type_icon/field_type_icon.tsx | 130 ----- .../contexts/kibana/kibana_context.ts | 4 +- .../analytics_list/use_table_settings.ts | 9 +- .../application/datavisualizer/_index.scss | 2 - .../datavisualizer_selector.tsx | 6 +- .../file_based/file_datavisualizer.tsx | 6 +- .../datavisualizer/index_based/_index.scss | 1 - .../index_based/common/index.ts | 9 - .../actions_panel/actions_panel.tsx | 215 ------- .../components/expanded_row/index.ts | 8 - .../components/field_data_row/_index.scss | 1 - .../choropleth_map/choropleth_map.tsx | 126 ---- .../examples_list/examples_list.tsx | 59 -- .../top_values/_top_values.scss | 19 - .../field_data_row/top_values/top_values.tsx | 113 ---- .../components/total_count_header/index.ts | 8 - .../index_based/data_loader/data_loader.ts | 105 +--- .../datavisualizer/index_based/index.ts | 2 +- .../index_based/index_data_visualizer.tsx | 38 ++ .../stats_table/_field_data_row.scss | 86 --- .../datavisualizer/stats_table/_index.scss | 56 -- .../expanded_row_field_header.tsx | 15 - .../expanded_row_field_header/index.ts | 8 - .../components/field_count_stats/_index.scss | 3 - .../field_count_stats/metric_fields_count.tsx | 68 --- .../field_count_stats/total_fields_count.tsx | 67 --- .../field_data_expanded_row/_index.scss | 7 - .../_number_content.scss | 4 - .../boolean_content.tsx | 145 ----- .../field_data_expanded_row/date_content.tsx | 87 --- .../document_stats.tsx | 93 --- .../expanded_row_content.tsx | 25 - .../field_data_expanded_row/index.ts | 14 - .../field_data_expanded_row/ip_content.tsx | 27 - .../keyword_content.tsx | 54 -- .../number_content.tsx | 154 ----- .../field_data_expanded_row/other_content.tsx | 28 - .../field_data_expanded_row/text_content.tsx | 66 --- .../components/field_data_row/_index.scss | 3 - .../field_data_row/distinct_values.tsx | 24 - .../field_data_row/document_stats.tsx | 33 -- .../components/field_data_row/index.ts | 8 - .../field_data_row/number_content_preview.tsx | 81 --- .../field_data_row/top_values_preview.tsx | 44 -- .../metric_distribution_chart/index.ts | 9 - .../metric_distribution_chart.tsx | 101 ---- ...metric_distribution_chart_data_builder.tsx | 156 ----- ...tric_distribution_chart_tooltip_header.tsx | 54 -- .../data_visualizer_stats_table.tsx | 270 --------- .../datavisualizer/stats_table/hooks/index.ts | 8 - .../hooks/use_data_viz_chart_theme.ts | 55 -- .../datavisualizer/stats_table/index.ts | 8 - .../stats_table/types/field_vis_config.ts | 99 ---- .../datavisualizer/stats_table/types/index.ts | 16 - .../datavisualizer/stats_table/utils.ts | 38 -- .../routes/datavisualizer/index_based.tsx | 2 +- .../services/ml_api_service/index.ts | 86 +-- .../application/util/dependency_cache.ts | 14 +- x-pack/plugins/ml/public/plugin.ts | 6 +- .../search_deep_links.ts | 2 +- .../ml/server/routes/data_visualizer.ts | 185 +----- x-pack/plugins/ml/tsconfig.json | 2 +- .../translations/translations/ja-JP.json | 530 ++++++++--------- .../translations/translations/zh-CN.json | 540 ++++++++---------- .../ml/data_visualizer/get_field_stats.ts | 3 +- .../ml/data_visualizer/get_overall_stats.ts | 3 +- .../data_visualizer/index_data_visualizer.ts | 2 +- .../index_data_visualizer_actions_panel.ts | 46 +- .../apps/ml/permissions/full_ml_access.ts | 16 +- .../apps/ml/permissions/read_ml_access.ts | 15 +- .../functional/services/ml/data_visualizer.ts | 2 +- .../services/ml/data_visualizer_file_based.ts | 42 +- .../ml/data_visualizer_index_based.ts | 54 +- .../services/ml/data_visualizer_table.ts | 108 ++-- .../services/ml/job_source_selection.ts | 2 +- .../apps/ml/permissions/full_ml_access.ts | 15 +- .../apps/ml/permissions/read_ml_access.ts | 16 +- 372 files changed, 6256 insertions(+), 5096 deletions(-) rename api_docs/{file_data_visualizer.json => data_visualizer.json} (72%) rename api_docs/{file_data_visualizer.mdx => data_visualizer.mdx} (100%) create mode 100644 x-pack/plugins/data_visualizer/README.md rename x-pack/plugins/{file_data_visualizer => data_visualizer}/common/constants.ts (90%) rename x-pack/plugins/{file_data_visualizer => data_visualizer}/common/index.ts (100%) create mode 100644 x-pack/plugins/data_visualizer/common/types/field_request_config.ts rename x-pack/plugins/{file_data_visualizer/common/types.ts => data_visualizer/common/types/index.ts} (62%) rename x-pack/plugins/{ml/public/application/datavisualizer/stats_table/types/field_data_row.ts => data_visualizer/common/types/indices.ts} (57%) rename x-pack/plugins/{file_data_visualizer/server/index.ts => data_visualizer/common/types/job_field_type.ts} (66%) rename x-pack/plugins/{ml/public/application/datavisualizer/index_based/common/combined_query.ts => data_visualizer/common/types/time_field_request.ts} (62%) create mode 100644 x-pack/plugins/data_visualizer/common/utils/datafeed_utils.ts create mode 100644 x-pack/plugins/data_visualizer/common/utils/object_utils.ts create mode 100644 x-pack/plugins/data_visualizer/common/utils/query_utils.ts create mode 100644 x-pack/plugins/data_visualizer/common/utils/runtime_field_utils.ts create mode 100644 x-pack/plugins/data_visualizer/common/utils/string_utils.ts rename x-pack/plugins/{file_data_visualizer => data_visualizer}/jest.config.js (84%) rename x-pack/plugins/{file_data_visualizer => data_visualizer}/kibana.json (88%) rename x-pack/plugins/{file_data_visualizer => data_visualizer}/public/api/index.ts (61%) create mode 100644 x-pack/plugins/data_visualizer/public/application/_index.scss create mode 100644 x-pack/plugins/data_visualizer/public/application/common/components/_index.scss rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/common}/components/combined_fields/combined_field_label.tsx (100%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/common}/components/combined_fields/combined_fields_form.tsx (86%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/common}/components/combined_fields/combined_fields_read_only_form.tsx (84%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/common}/components/combined_fields/geo_point.tsx (90%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/common}/components/combined_fields/index.ts (100%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/common}/components/combined_fields/types.ts (100%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/common}/components/combined_fields/utils.test.ts (100%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/common}/components/combined_fields/utils.ts (97%) create mode 100644 x-pack/plugins/data_visualizer/public/application/common/components/date_picker_wrapper/date_picker_wrapper.tsx create mode 100644 x-pack/plugins/data_visualizer/public/application/common/components/date_picker_wrapper/index.ts rename x-pack/plugins/{ml/public/application/datavisualizer/index_based/components/field_data_row => data_visualizer/public/application/common/components/document_count_content}/document_count_chart/document_count_chart.tsx (87%) rename x-pack/plugins/{ml/public/application/datavisualizer/index_based/components/field_data_row => data_visualizer/public/application/common/components/document_count_content}/document_count_chart/index.ts (100%) rename x-pack/plugins/{ml/public/application/datavisualizer/index_based/components/field_data_row/content_types => data_visualizer/public/application/common/components/document_count_content}/document_count_content.tsx (85%) rename x-pack/plugins/{ml/public/application/datavisualizer/index_based/components/field_data_row/content_types => data_visualizer/public/application/common/components/document_count_content}/index.ts (84%) rename x-pack/plugins/{ml/public/application/datavisualizer/index_based/components/total_count_header => data_visualizer/public/application/common/components/document_count_content}/total_count_header.tsx (75%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/common}/components/embedded_map/_embedded_map.scss (100%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/common}/components/embedded_map/_index.scss (100%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/common}/components/embedded_map/embedded_map.tsx (90%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/common}/components/embedded_map/index.ts (100%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/common}/components/examples_list/examples_list.tsx (88%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/common}/components/examples_list/index.ts (100%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/common}/components/expanded_row/file_based_expanded_row.tsx (92%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/common}/components/expanded_row/geo_point_content/format_utils.ts (96%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/common}/components/expanded_row/geo_point_content/geo_point_content.tsx (95%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/common}/components/expanded_row/geo_point_content/index.ts (100%) rename x-pack/plugins/{ml/public/application/datavisualizer/index_based/components/expanded_row/geo_point_content.tsx => data_visualizer/public/application/common/components/expanded_row/geo_point_content_with_map/geo_point_content_with_map.tsx} (59%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/common/components/expanded_row/geo_point_content_with_map}/index.ts (78%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/common}/components/expanded_row/index.ts (100%) rename x-pack/plugins/{ml/public/application/datavisualizer/index_based/components/expanded_row/expanded_row.tsx => data_visualizer/public/application/common/components/expanded_row/index_based_expanded_row.tsx} (58%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/common}/components/experimental_badge/_experimental_badge.scss (100%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/common}/components/experimental_badge/_index.scss (100%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/common}/components/experimental_badge/experimental_badge.tsx (90%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/common}/components/experimental_badge/index.ts (100%) rename x-pack/plugins/{ml/public/application/datavisualizer/index_based => data_visualizer/public/application/common}/components/field_count_panel/field_count_panel.tsx (78%) rename x-pack/plugins/{ml/public/application/datavisualizer/index_based => data_visualizer/public/application/common}/components/field_count_panel/index.ts (100%) rename x-pack/plugins/{ml/public/application/datavisualizer/index_based => data_visualizer/public/application/common}/components/field_data_row/action_menu/actions.ts (61%) rename x-pack/plugins/{ml/public/application/datavisualizer/index_based => data_visualizer/public/application/common}/components/field_data_row/action_menu/index.ts (100%) rename x-pack/plugins/{ml/public/application/datavisualizer/index_based => data_visualizer/public/application/common}/components/field_data_row/action_menu/lens_utils.ts (83%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/common}/components/field_data_row/index.ts (100%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/common}/components/field_data_row/number_content_preview.tsx (79%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/common}/components/field_names_filter/field_names_filter.tsx (91%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/common}/components/field_names_filter/index.ts (100%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/common}/components/field_type_icon/__snapshots__/field_type_icon.test.tsx.snap (100%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/common}/components/field_type_icon/field_type_icon.test.tsx (96%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/common}/components/field_type_icon/field_type_icon.tsx (94%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/common}/components/field_type_icon/index.ts (100%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/common}/components/field_types_filter/field_types_filter.tsx (94%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/common}/components/field_types_filter/index.ts (100%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/common}/components/fields_stats_grid/create_fields.ts (96%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/common}/components/fields_stats_grid/fields_stats_grid.tsx (93%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/common}/components/fields_stats_grid/filter_fields.ts (95%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/common}/components/fields_stats_grid/get_field_names.ts (85%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/common}/components/fields_stats_grid/index.ts (100%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/common}/components/filebeat_config_flyout/filebeat_config.ts (92%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/common}/components/filebeat_config_flyout/filebeat_config_flyout.tsx (84%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/common}/components/filebeat_config_flyout/index.ts (100%) create mode 100644 x-pack/plugins/data_visualizer/public/application/common/components/help_menu/help_menu.tsx create mode 100644 x-pack/plugins/data_visualizer/public/application/common/components/help_menu/index.tsx rename x-pack/plugins/{ml/public/application/datavisualizer/index_based/components/field_data_row/top_values => data_visualizer/public/application/common/components/link_card}/index.ts (85%) create mode 100644 x-pack/plugins/data_visualizer/public/application/common/components/link_card/link_card.tsx rename x-pack/plugins/{ml/public/application/datavisualizer/index_based/components/field_data_row => data_visualizer/public/application/common/components}/loading_indicator/index.ts (100%) rename x-pack/plugins/{ml/public/application/datavisualizer/index_based/components/field_data_row => data_visualizer/public/application/common/components}/loading_indicator/loading_indicator.tsx (86%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/common}/components/multi_select_picker/index.ts (100%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/common}/components/multi_select_picker/multi_select_picker.tsx (98%) rename x-pack/plugins/{file_data_visualizer/public/lazy_load_bundle/lazy => data_visualizer/public/application/common/components/not_in_docs_content}/index.ts (81%) rename x-pack/plugins/{ml/public/application/datavisualizer/index_based/components/field_data_row/content_types/not_in_docs_content.tsx => data_visualizer/public/application/common/components/not_in_docs_content/not_in_docs_context.tsx} (92%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/common}/components/results_links/index.ts (100%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/common}/components/results_links/results_links.tsx (90%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/common}/components/stats_table/_field_data_row.scss (100%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/common}/components/stats_table/_index.scss (100%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/common}/components/stats_table/components/expanded_row_field_header/expanded_row_field_header.tsx (100%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/common}/components/stats_table/components/expanded_row_field_header/index.ts (100%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/common}/components/stats_table/components/field_count_stats/_index.scss (100%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/common}/components/stats_table/components/field_count_stats/index.ts (100%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/common}/components/stats_table/components/field_count_stats/metric_fields_count.tsx (83%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/common}/components/stats_table/components/field_count_stats/total_fields_count.tsx (83%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/common}/components/stats_table/components/field_data_expanded_row/_index.scss (100%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/common}/components/stats_table/components/field_data_expanded_row/_number_content.scss (100%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/common}/components/stats_table/components/field_data_expanded_row/boolean_content.tsx (90%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/common}/components/stats_table/components/field_data_expanded_row/choropleth_map.tsx (88%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/common}/components/stats_table/components/field_data_expanded_row/date_content.tsx (87%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/common}/components/stats_table/components/field_data_expanded_row/document_stats.tsx (83%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/common}/components/stats_table/components/field_data_expanded_row/expanded_row_content.tsx (100%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/common}/components/stats_table/components/field_data_expanded_row/index.ts (100%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/common}/components/stats_table/components/field_data_expanded_row/ip_content.tsx (94%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/common}/components/stats_table/components/field_data_expanded_row/keyword_content.tsx (88%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/common}/components/stats_table/components/field_data_expanded_row/number_content.tsx (85%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/common}/components/stats_table/components/field_data_expanded_row/other_content.tsx (93%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/common}/components/stats_table/components/field_data_expanded_row/text_content.tsx (87%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/common}/components/stats_table/components/field_data_row/_index.scss (100%) rename x-pack/plugins/{ml/public/application/datavisualizer => data_visualizer/public/application/common/components}/stats_table/components/field_data_row/boolean_content_preview.tsx (77%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/common}/components/stats_table/components/field_data_row/column_chart.scss (100%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/common}/components/stats_table/components/field_data_row/column_chart.tsx (100%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/common}/components/stats_table/components/field_data_row/distinct_values.tsx (100%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/common}/components/stats_table/components/field_data_row/document_stats.tsx (100%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/common}/components/stats_table/components/field_data_row/field_histograms.ts (100%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/common}/components/stats_table/components/field_data_row/index.ts (100%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/common}/components/stats_table/components/field_data_row/number_content_preview.tsx (97%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/common}/components/stats_table/components/field_data_row/top_values_preview.tsx (94%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/common}/components/stats_table/components/field_data_row/use_column_chart.test.tsx (98%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/common}/components/stats_table/components/field_data_row/use_column_chart.tsx (92%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/common}/components/stats_table/components/metric_distribution_chart/index.ts (100%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/common}/components/stats_table/components/metric_distribution_chart/metric_distribution_chart.tsx (94%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/common}/components/stats_table/components/metric_distribution_chart/metric_distribution_chart_data_builder.tsx (100%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/common}/components/stats_table/components/metric_distribution_chart/metric_distribution_chart_tooltip_header.tsx (88%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/common}/components/stats_table/data_visualizer_stats_table.tsx (76%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/common}/components/stats_table/hooks/color_range_legend.tsx (100%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/common}/components/stats_table/hooks/index.ts (100%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/common}/components/stats_table/hooks/use_color_range.test.ts (100%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/common}/components/stats_table/hooks/use_color_range.ts (82%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/common}/components/stats_table/hooks/use_data_viz_chart_theme.ts (100%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/common}/components/stats_table/index.ts (100%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/common}/components/stats_table/types/field_data_row.ts (100%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/common}/components/stats_table/types/field_vis_config.ts (62%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/common}/components/stats_table/types/index.ts (96%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/common}/components/stats_table/use_table_settings.ts (96%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/common}/components/stats_table/utils.ts (100%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/common}/components/top_values/_top_values.scss (100%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/common}/components/top_values/index.ts (100%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/common}/components/top_values/top_values.tsx (87%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/common}/components/utils/format_value.ts (100%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/common}/components/utils/index.ts (100%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/common}/components/utils/kibana_field_format.ts (100%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/common}/components/utils/number_as_ordinal.test.ts (100%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/common}/components/utils/number_as_ordinal.ts (100%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/common}/components/utils/round_to_decimal_place.test.ts (100%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/common}/components/utils/round_to_decimal_place.ts (100%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/common}/components/utils/utils.ts (99%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/common}/util/field_types_utils.test.ts (95%) create mode 100644 x-pack/plugins/data_visualizer/public/application/common/util/field_types_utils.ts rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/common}/util/get_max_bytes.ts (89%) create mode 100644 x-pack/plugins/data_visualizer/public/application/common/util/parse_interval.test.ts create mode 100644 x-pack/plugins/data_visualizer/public/application/common/util/parse_interval.ts create mode 100644 x-pack/plugins/data_visualizer/public/application/common/util/url_state.tsx rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/file_data_visualizer}/_index.scss (100%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/file_data_visualizer}/components/_index.scss (52%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/file_data_visualizer}/components/about_panel/_about_panel.scss (100%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/file_data_visualizer}/components/about_panel/_index.scss (100%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/file_data_visualizer}/components/about_panel/about_panel.tsx (87%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/file_data_visualizer}/components/about_panel/index.ts (100%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/file_data_visualizer}/components/about_panel/welcome_content.tsx (81%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/file_data_visualizer}/components/analysis_summary/_analysis_summary.scss (100%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/file_data_visualizer}/components/analysis_summary/_index.scss (100%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/file_data_visualizer}/components/analysis_summary/analysis_summary.tsx (80%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/file_data_visualizer}/components/analysis_summary/index.ts (100%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/file_data_visualizer}/components/bottom_bar/bottom_bar.tsx (81%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/file_data_visualizer}/components/bottom_bar/index.ts (100%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/file_data_visualizer}/components/edit_flyout/__snapshots__/overrides.test.js.snap (96%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/file_data_visualizer}/components/edit_flyout/_edit_flyout.scss (100%) create mode 100644 x-pack/plugins/data_visualizer/public/application/file_data_visualizer/components/edit_flyout/_index.scss rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/file_data_visualizer}/components/edit_flyout/edit_flyout.js (91%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/file_data_visualizer}/components/edit_flyout/index.js (100%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/file_data_visualizer}/components/edit_flyout/options/index.js (100%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/file_data_visualizer}/components/edit_flyout/options/option_lists.js (100%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/file_data_visualizer}/components/edit_flyout/options/options.js (100%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/file_data_visualizer}/components/edit_flyout/overrides.js (91%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/file_data_visualizer}/components/edit_flyout/overrides.test.js (95%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/file_data_visualizer}/components/edit_flyout/overrides_validation.js (90%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/file_data_visualizer}/components/explanation_flyout/explanation_flyout.tsx (87%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/file_data_visualizer}/components/explanation_flyout/index.ts (100%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/file_data_visualizer}/components/file_contents/_file_contents.scss (100%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/file_data_visualizer}/components/file_contents/_index.scss (100%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/file_data_visualizer}/components/file_contents/file_contents.tsx (91%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/file_data_visualizer}/components/file_contents/index.ts (100%) rename x-pack/plugins/{file_data_visualizer/public/application/components/file_datavisualizer_view/_file_datavisualizer_view.scss => data_visualizer/public/application/file_data_visualizer/components/file_data_visualizer_view/_file_data_visualizer_view.scss} (100%) create mode 100644 x-pack/plugins/data_visualizer/public/application/file_data_visualizer/components/file_data_visualizer_view/_index.scss rename x-pack/plugins/{file_data_visualizer/public/application/components/file_datavisualizer_view => data_visualizer/public/application/file_data_visualizer/components/file_data_visualizer_view}/constants.ts (100%) rename x-pack/plugins/{file_data_visualizer/public/application/components/file_datavisualizer_view/file_datavisualizer_view.js => data_visualizer/public/application/file_data_visualizer/components/file_data_visualizer_view/file_data_visualizer_view.js} (97%) rename x-pack/plugins/{file_data_visualizer/public/application/components/file_datavisualizer_view => data_visualizer/public/application/file_data_visualizer/components/file_data_visualizer_view}/file_error_callouts.tsx (80%) rename x-pack/plugins/{file_data_visualizer/public/application/components/file_datavisualizer_view => data_visualizer/public/application/file_data_visualizer/components/file_data_visualizer_view}/index.js (78%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/file_data_visualizer}/components/import_errors/errors.tsx (81%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/file_data_visualizer}/components/import_errors/index.ts (100%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/file_data_visualizer}/components/import_progress/import_progress.tsx (81%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/file_data_visualizer}/components/import_progress/index.ts (100%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/file_data_visualizer}/components/import_settings/advanced.tsx (87%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/file_data_visualizer}/components/import_settings/import_settings.tsx (91%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/file_data_visualizer}/components/import_settings/index.ts (100%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/file_data_visualizer}/components/import_settings/simple.tsx (77%) rename x-pack/plugins/{file_data_visualizer/public/application/components/import_summary/_import_sumary.scss => data_visualizer/public/application/file_data_visualizer/components/import_summary/_import_summary.scss} (100%) create mode 100644 x-pack/plugins/data_visualizer/public/application/file_data_visualizer/components/import_summary/_index.scss rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/file_data_visualizer}/components/import_summary/failures.tsx (95%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/file_data_visualizer}/components/import_summary/import_summary.tsx (83%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/file_data_visualizer}/components/import_summary/index.ts (100%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/file_data_visualizer}/components/import_view/import_view.js (93%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/file_data_visualizer}/components/import_view/index.js (100%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/file_data_visualizer}/components/json_editor/index.ts (100%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/file_data_visualizer}/components/json_editor/json_editor.tsx (94%) create mode 100644 x-pack/plugins/data_visualizer/public/application/file_data_visualizer/components/results_view/_index.scss rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/file_data_visualizer}/components/results_view/_results_view.scss (100%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/file_data_visualizer}/components/results_view/index.ts (100%) rename x-pack/plugins/{file_data_visualizer/public/application => data_visualizer/public/application/file_data_visualizer}/components/results_view/results_view.tsx (75%) rename x-pack/plugins/{file_data_visualizer/public/application/file_datavisualizer.tsx => data_visualizer/public/application/file_data_visualizer/file_data_visualizer.tsx} (66%) create mode 100644 x-pack/plugins/data_visualizer/public/application/file_data_visualizer/index.ts rename x-pack/plugins/{ml/public/application/datavisualizer/stats_table/components/field_count_stats => data_visualizer/public/application}/index.ts (56%) create mode 100644 x-pack/plugins/data_visualizer/public/application/index_data_visualizer/components/actions_panel/actions_panel.tsx rename x-pack/plugins/{ml/public/application/datavisualizer/index_based => data_visualizer/public/application/index_data_visualizer}/components/actions_panel/index.ts (100%) create mode 100644 x-pack/plugins/data_visualizer/public/application/index_data_visualizer/components/full_time_range_selector/full_time_range_selector.tsx create mode 100644 x-pack/plugins/data_visualizer/public/application/index_data_visualizer/components/full_time_range_selector/full_time_range_selector_service.ts rename x-pack/plugins/{file_data_visualizer/server/plugin.ts => data_visualizer/public/application/index_data_visualizer/components/full_time_range_selector/index.tsx} (62%) create mode 100644 x-pack/plugins/data_visualizer/public/application/index_data_visualizer/components/index_data_visualizer_view/index.ts rename x-pack/plugins/{ml/public/application/datavisualizer/index_based/page.tsx => data_visualizer/public/application/index_data_visualizer/components/index_data_visualizer_view/index_data_visualizer_view.tsx} (79%) rename x-pack/plugins/{ml/public/application/datavisualizer/index_based => data_visualizer/public/application/index_data_visualizer}/components/search_panel/field_name_filter.tsx (82%) rename x-pack/plugins/{ml/public/application/datavisualizer/index_based => data_visualizer/public/application/index_data_visualizer}/components/search_panel/field_type_filter.tsx (59%) rename x-pack/plugins/{ml/public/application/datavisualizer/index_based => data_visualizer/public/application/index_data_visualizer}/components/search_panel/index.ts (100%) rename x-pack/plugins/{ml/public/application/datavisualizer/index_based => data_visualizer/public/application/index_data_visualizer}/components/search_panel/search_panel.tsx (85%) rename x-pack/plugins/{ml/public/application/datavisualizer/index_based => data_visualizer/public/application/index_data_visualizer}/components/search_panel/shard_size_select.tsx (77%) create mode 100644 x-pack/plugins/data_visualizer/public/application/index_data_visualizer/constants/index_data_visualizer_viewer.ts create mode 100644 x-pack/plugins/data_visualizer/public/application/index_data_visualizer/data_loader/data_loader.ts create mode 100644 x-pack/plugins/data_visualizer/public/application/index_data_visualizer/hooks/use_time_filter.ts create mode 100644 x-pack/plugins/data_visualizer/public/application/index_data_visualizer/index.ts create mode 100644 x-pack/plugins/data_visualizer/public/application/index_data_visualizer/index_data_visualizer.tsx create mode 100644 x-pack/plugins/data_visualizer/public/application/index_data_visualizer/services/time_buckets.d.ts create mode 100644 x-pack/plugins/data_visualizer/public/application/index_data_visualizer/services/time_buckets.js create mode 100644 x-pack/plugins/data_visualizer/public/application/index_data_visualizer/services/time_field_range.ts create mode 100644 x-pack/plugins/data_visualizer/public/application/index_data_visualizer/services/timefilter_refresh_service.ts create mode 100644 x-pack/plugins/data_visualizer/public/application/index_data_visualizer/services/visualizer_stats.ts create mode 100644 x-pack/plugins/data_visualizer/public/application/index_data_visualizer/types/combined_query.ts create mode 100644 x-pack/plugins/data_visualizer/public/application/index_data_visualizer/types/index_data_visualizer_state.ts rename x-pack/plugins/{ml/common/types/datavisualizer.ts => data_visualizer/public/application/index_data_visualizer/types/overall_stats.ts} (99%) create mode 100644 x-pack/plugins/data_visualizer/public/application/index_data_visualizer/utils/saved_search_utils.ts rename x-pack/plugins/{file_data_visualizer => data_visualizer}/public/application/kibana_context.ts (62%) rename x-pack/plugins/{file_data_visualizer => data_visualizer}/public/application/shared_imports.ts (100%) rename x-pack/plugins/{file_data_visualizer => data_visualizer}/public/index.ts (57%) rename x-pack/plugins/{file_data_visualizer => data_visualizer}/public/kibana_services.ts (68%) rename x-pack/plugins/{file_data_visualizer => data_visualizer}/public/lazy_load_bundle/component_wrapper.tsx (78%) rename x-pack/plugins/{file_data_visualizer => data_visualizer}/public/lazy_load_bundle/index.ts (82%) create mode 100644 x-pack/plugins/data_visualizer/public/lazy_load_bundle/lazy/index.ts rename x-pack/plugins/{file_data_visualizer => data_visualizer}/public/plugin.ts (58%) rename x-pack/plugins/{file_data_visualizer => data_visualizer}/public/register_home.ts (90%) create mode 100644 x-pack/plugins/data_visualizer/server/index.ts create mode 100644 x-pack/plugins/data_visualizer/server/models/data_visualizer/check_fields_exist.ts create mode 100644 x-pack/plugins/data_visualizer/server/models/data_visualizer/constants.ts create mode 100644 x-pack/plugins/data_visualizer/server/models/data_visualizer/data_visualizer.ts create mode 100644 x-pack/plugins/data_visualizer/server/models/data_visualizer/get_field_examples.ts create mode 100644 x-pack/plugins/data_visualizer/server/models/data_visualizer/get_fields_stats.ts create mode 100644 x-pack/plugins/data_visualizer/server/models/data_visualizer/get_histogram_for_fields.ts rename x-pack/plugins/{ml/public/application/datavisualizer/index_based/components/field_data_row/examples_list => data_visualizer/server/models/data_visualizer}/index.ts (84%) create mode 100644 x-pack/plugins/data_visualizer/server/models/data_visualizer/process_distribution_data.ts create mode 100644 x-pack/plugins/data_visualizer/server/plugin.ts rename x-pack/plugins/{ml/public/application/datavisualizer/index_based/components/field_data_row/choropleth_map => data_visualizer/server/routes}/index.ts (83%) create mode 100644 x-pack/plugins/data_visualizer/server/routes/routes.ts rename x-pack/plugins/{ml/public/application/components/field_title_bar => data_visualizer/server/routes/schemas}/index.ts (83%) create mode 100644 x-pack/plugins/data_visualizer/server/routes/schemas/index_data_visualizer_schemas.ts create mode 100644 x-pack/plugins/data_visualizer/server/types/chart_data.ts create mode 100644 x-pack/plugins/data_visualizer/server/types/deps.ts rename x-pack/plugins/{ml/public/application/components/field_type_icon => data_visualizer/server/types}/index.ts (82%) create mode 100644 x-pack/plugins/data_visualizer/server/utils/error_wrapper.ts rename x-pack/plugins/{file_data_visualizer => data_visualizer}/tsconfig.json (85%) delete mode 100644 x-pack/plugins/file_data_visualizer/public/application/components/edit_flyout/_index.scss delete mode 100644 x-pack/plugins/file_data_visualizer/public/application/components/file_datavisualizer_view/_index.scss delete mode 100644 x-pack/plugins/file_data_visualizer/public/application/components/import_summary/_index.scss delete mode 100644 x-pack/plugins/file_data_visualizer/public/application/components/results_view/_index.scss delete mode 100644 x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_row/boolean_content_preview.tsx delete mode 100644 x-pack/plugins/file_data_visualizer/public/application/util/field_types_utils.ts create mode 100644 x-pack/plugins/file_upload/server/utils/runtime_field_utils.ts delete mode 100644 x-pack/plugins/ml/public/application/components/field_title_bar/_field_title_bar.scss delete mode 100644 x-pack/plugins/ml/public/application/components/field_title_bar/_index.scss delete mode 100644 x-pack/plugins/ml/public/application/components/field_title_bar/field_title_bar.test.tsx delete mode 100644 x-pack/plugins/ml/public/application/components/field_title_bar/field_title_bar.tsx delete mode 100644 x-pack/plugins/ml/public/application/components/field_type_icon/__snapshots__/field_type_icon.test.tsx.snap delete mode 100644 x-pack/plugins/ml/public/application/components/field_type_icon/field_type_icon.test.tsx delete mode 100644 x-pack/plugins/ml/public/application/components/field_type_icon/field_type_icon.tsx delete mode 100644 x-pack/plugins/ml/public/application/datavisualizer/_index.scss delete mode 100644 x-pack/plugins/ml/public/application/datavisualizer/index_based/_index.scss delete mode 100644 x-pack/plugins/ml/public/application/datavisualizer/index_based/common/index.ts delete mode 100644 x-pack/plugins/ml/public/application/datavisualizer/index_based/components/actions_panel/actions_panel.tsx delete mode 100644 x-pack/plugins/ml/public/application/datavisualizer/index_based/components/expanded_row/index.ts delete mode 100644 x-pack/plugins/ml/public/application/datavisualizer/index_based/components/field_data_row/_index.scss delete mode 100644 x-pack/plugins/ml/public/application/datavisualizer/index_based/components/field_data_row/choropleth_map/choropleth_map.tsx delete mode 100644 x-pack/plugins/ml/public/application/datavisualizer/index_based/components/field_data_row/examples_list/examples_list.tsx delete mode 100644 x-pack/plugins/ml/public/application/datavisualizer/index_based/components/field_data_row/top_values/_top_values.scss delete mode 100644 x-pack/plugins/ml/public/application/datavisualizer/index_based/components/field_data_row/top_values/top_values.tsx delete mode 100644 x-pack/plugins/ml/public/application/datavisualizer/index_based/components/total_count_header/index.ts create mode 100644 x-pack/plugins/ml/public/application/datavisualizer/index_based/index_data_visualizer.tsx delete mode 100644 x-pack/plugins/ml/public/application/datavisualizer/stats_table/_field_data_row.scss delete mode 100644 x-pack/plugins/ml/public/application/datavisualizer/stats_table/_index.scss delete mode 100644 x-pack/plugins/ml/public/application/datavisualizer/stats_table/components/expanded_row_field_header/expanded_row_field_header.tsx delete mode 100644 x-pack/plugins/ml/public/application/datavisualizer/stats_table/components/expanded_row_field_header/index.ts delete mode 100644 x-pack/plugins/ml/public/application/datavisualizer/stats_table/components/field_count_stats/_index.scss delete mode 100644 x-pack/plugins/ml/public/application/datavisualizer/stats_table/components/field_count_stats/metric_fields_count.tsx delete mode 100644 x-pack/plugins/ml/public/application/datavisualizer/stats_table/components/field_count_stats/total_fields_count.tsx delete mode 100644 x-pack/plugins/ml/public/application/datavisualizer/stats_table/components/field_data_expanded_row/_index.scss delete mode 100644 x-pack/plugins/ml/public/application/datavisualizer/stats_table/components/field_data_expanded_row/_number_content.scss delete mode 100644 x-pack/plugins/ml/public/application/datavisualizer/stats_table/components/field_data_expanded_row/boolean_content.tsx delete mode 100644 x-pack/plugins/ml/public/application/datavisualizer/stats_table/components/field_data_expanded_row/date_content.tsx delete mode 100644 x-pack/plugins/ml/public/application/datavisualizer/stats_table/components/field_data_expanded_row/document_stats.tsx delete mode 100644 x-pack/plugins/ml/public/application/datavisualizer/stats_table/components/field_data_expanded_row/expanded_row_content.tsx delete mode 100644 x-pack/plugins/ml/public/application/datavisualizer/stats_table/components/field_data_expanded_row/index.ts delete mode 100644 x-pack/plugins/ml/public/application/datavisualizer/stats_table/components/field_data_expanded_row/ip_content.tsx delete mode 100644 x-pack/plugins/ml/public/application/datavisualizer/stats_table/components/field_data_expanded_row/keyword_content.tsx delete mode 100644 x-pack/plugins/ml/public/application/datavisualizer/stats_table/components/field_data_expanded_row/number_content.tsx delete mode 100644 x-pack/plugins/ml/public/application/datavisualizer/stats_table/components/field_data_expanded_row/other_content.tsx delete mode 100644 x-pack/plugins/ml/public/application/datavisualizer/stats_table/components/field_data_expanded_row/text_content.tsx delete mode 100644 x-pack/plugins/ml/public/application/datavisualizer/stats_table/components/field_data_row/_index.scss delete mode 100644 x-pack/plugins/ml/public/application/datavisualizer/stats_table/components/field_data_row/distinct_values.tsx delete mode 100644 x-pack/plugins/ml/public/application/datavisualizer/stats_table/components/field_data_row/document_stats.tsx delete mode 100644 x-pack/plugins/ml/public/application/datavisualizer/stats_table/components/field_data_row/index.ts delete mode 100644 x-pack/plugins/ml/public/application/datavisualizer/stats_table/components/field_data_row/number_content_preview.tsx delete mode 100644 x-pack/plugins/ml/public/application/datavisualizer/stats_table/components/field_data_row/top_values_preview.tsx delete mode 100644 x-pack/plugins/ml/public/application/datavisualizer/stats_table/components/metric_distribution_chart/index.ts delete mode 100644 x-pack/plugins/ml/public/application/datavisualizer/stats_table/components/metric_distribution_chart/metric_distribution_chart.tsx delete mode 100644 x-pack/plugins/ml/public/application/datavisualizer/stats_table/components/metric_distribution_chart/metric_distribution_chart_data_builder.tsx delete mode 100644 x-pack/plugins/ml/public/application/datavisualizer/stats_table/components/metric_distribution_chart/metric_distribution_chart_tooltip_header.tsx delete mode 100644 x-pack/plugins/ml/public/application/datavisualizer/stats_table/data_visualizer_stats_table.tsx delete mode 100644 x-pack/plugins/ml/public/application/datavisualizer/stats_table/hooks/index.ts delete mode 100644 x-pack/plugins/ml/public/application/datavisualizer/stats_table/hooks/use_data_viz_chart_theme.ts delete mode 100644 x-pack/plugins/ml/public/application/datavisualizer/stats_table/index.ts delete mode 100644 x-pack/plugins/ml/public/application/datavisualizer/stats_table/types/field_vis_config.ts delete mode 100644 x-pack/plugins/ml/public/application/datavisualizer/stats_table/types/index.ts delete mode 100644 x-pack/plugins/ml/public/application/datavisualizer/stats_table/utils.ts diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 0cf5fc4e0dfd0..a017c79309a56 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -130,6 +130,8 @@ # ML team owns and maintains the transform plugin despite it living in the Data management section. /x-pack/plugins/transform/ @elastic/ml-ui +/x-pack/plugins/data_visualizer/ @elastic/ml-ui +/x-pack/plugins/file_upload/ @elastic/ml-ui /x-pack/test/accessibility/apps/transform.ts @elastic/ml-ui /x-pack/test/api_integration/apis/transform/ @elastic/ml-ui /x-pack/test/api_integration_basic/apis/transform/ @elastic/ml-ui @@ -306,28 +308,28 @@ /x-pack/plugins/enterprise_search/server/saved_objects/workplace_search/ @elastic/workplace-search-frontend # Stack Management -/src/plugins/dev_tools/ @elastic/kibana-stack-management -/src/plugins/console/ @elastic/kibana-stack-management -/src/plugins/es_ui_shared/ @elastic/kibana-stack-management -/x-pack/plugins/cross_cluster_replication/ @elastic/kibana-stack-management -/x-pack/plugins/index_lifecycle_management/ @elastic/kibana-stack-management -/x-pack/plugins/console_extensions/ @elastic/kibana-stack-management -/x-pack/plugins/grokdebugger/ @elastic/kibana-stack-management -/x-pack/plugins/index_management/ @elastic/kibana-stack-management -/x-pack/plugins/license_api_guard/ @elastic/kibana-stack-management -/x-pack/plugins/license_management/ @elastic/kibana-stack-management -/x-pack/plugins/painless_lab/ @elastic/kibana-stack-management -/x-pack/plugins/remote_clusters/ @elastic/kibana-stack-management -/x-pack/plugins/rollup/ @elastic/kibana-stack-management -/x-pack/plugins/searchprofiler/ @elastic/kibana-stack-management -/x-pack/plugins/snapshot_restore/ @elastic/kibana-stack-management -/x-pack/plugins/upgrade_assistant/ @elastic/kibana-stack-management -/x-pack/plugins/watcher/ @elastic/kibana-stack-management -/x-pack/plugins/ingest_pipelines/ @elastic/kibana-stack-management -/packages/kbn-ace/ @elastic/kibana-stack-management -/packages/kbn-monaco/ @elastic/kibana-stack-management -#CC# /x-pack/plugins/console_extensions/ @elastic/kibana-stack-management -#CC# /x-pack/plugins/cross_cluster_replication/ @elastic/kibana-stack-management +/src/plugins/dev_tools/ @elastic/kibana-stack-management +/src/plugins/console/ @elastic/kibana-stack-management +/src/plugins/es_ui_shared/ @elastic/kibana-stack-management +/x-pack/plugins/cross_cluster_replication/ @elastic/kibana-stack-management +/x-pack/plugins/index_lifecycle_management/ @elastic/kibana-stack-management +/x-pack/plugins/console_extensions/ @elastic/kibana-stack-management +/x-pack/plugins/grokdebugger/ @elastic/kibana-stack-management +/x-pack/plugins/index_management/ @elastic/kibana-stack-management +/x-pack/plugins/license_api_guard/ @elastic/kibana-stack-management +/x-pack/plugins/license_management/ @elastic/kibana-stack-management +/x-pack/plugins/painless_lab/ @elastic/kibana-stack-management +/x-pack/plugins/remote_clusters/ @elastic/kibana-stack-management +/x-pack/plugins/rollup/ @elastic/kibana-stack-management +/x-pack/plugins/searchprofiler/ @elastic/kibana-stack-management +/x-pack/plugins/snapshot_restore/ @elastic/kibana-stack-management +/x-pack/plugins/upgrade_assistant/ @elastic/kibana-stack-management +/x-pack/plugins/watcher/ @elastic/kibana-stack-management +/x-pack/plugins/ingest_pipelines/ @elastic/kibana-stack-management +/packages/kbn-ace/ @elastic/kibana-stack-management +/packages/kbn-monaco/ @elastic/kibana-stack-management +#CC# /x-pack/plugins/console_extensions/ @elastic/kibana-stack-management +#CC# /x-pack/plugins/cross_cluster_replication/ @elastic/kibana-stack-management # Security Solution /x-pack/test/endpoint_api_integration_no_ingest/ @elastic/security-solution diff --git a/api_docs/file_data_visualizer.json b/api_docs/data_visualizer.json similarity index 72% rename from api_docs/file_data_visualizer.json rename to api_docs/data_visualizer.json index 31b2c6bf5b673..b4544a0381790 100644 --- a/api_docs/file_data_visualizer.json +++ b/api_docs/data_visualizer.json @@ -1,5 +1,5 @@ { - "id": "fileDataVisualizer", + "id": "dataVisualizer", "client": { "classes": [], "functions": [], @@ -8,18 +8,18 @@ "misc": [], "objects": [], "start": { - "parentPluginId": "fileDataVisualizer", - "id": "def-public.FileDataVisualizerPluginStart", + "parentPluginId": "dataVisualizer", + "id": "def-public.DataVisualizerPluginStart", "type": "Type", "tags": [], - "label": "FileDataVisualizerPluginStart", + "label": "DataVisualizerPluginStart", "description": [], "signature": [ "{ getFileDataVisualizerComponent: () => Promise>; getMaxBytesFormatted: () => string; }" ], "source": { - "path": "x-pack/plugins/file_data_visualizer/public/plugin.ts", - "lineNumber": 36 + "path": "x-pack/plugins/data_visualizer/public/plugin.ts", + "lineNumber": 33 }, "deprecated": false, "lifecycle": "start", @@ -39,72 +39,72 @@ "functions": [], "interfaces": [ { - "parentPluginId": "fileDataVisualizer", + "parentPluginId": "dataVisualizer", "id": "def-common.DataVisualizerTableState", "type": "Interface", "tags": [], "label": "DataVisualizerTableState", "description": [], "source": { - "path": "x-pack/plugins/file_data_visualizer/common/types.ts", + "path": "x-pack/plugins/data_visualizer/common/types.ts", "lineNumber": 14 }, "deprecated": false, "children": [ { - "parentPluginId": "fileDataVisualizer", + "parentPluginId": "dataVisualizer", "id": "def-common.DataVisualizerTableState.pageSize", "type": "number", "tags": [], "label": "pageSize", "description": [], "source": { - "path": "x-pack/plugins/file_data_visualizer/common/types.ts", + "path": "x-pack/plugins/data_visualizer/common/types.ts", "lineNumber": 15 }, "deprecated": false }, { - "parentPluginId": "fileDataVisualizer", + "parentPluginId": "dataVisualizer", "id": "def-common.DataVisualizerTableState.pageIndex", "type": "number", "tags": [], "label": "pageIndex", "description": [], "source": { - "path": "x-pack/plugins/file_data_visualizer/common/types.ts", + "path": "x-pack/plugins/data_visualizer/common/types.ts", "lineNumber": 16 }, "deprecated": false }, { - "parentPluginId": "fileDataVisualizer", + "parentPluginId": "dataVisualizer", "id": "def-common.DataVisualizerTableState.sortField", "type": "string", "tags": [], "label": "sortField", "description": [], "source": { - "path": "x-pack/plugins/file_data_visualizer/common/types.ts", + "path": "x-pack/plugins/data_visualizer/common/types.ts", "lineNumber": 17 }, "deprecated": false }, { - "parentPluginId": "fileDataVisualizer", + "parentPluginId": "dataVisualizer", "id": "def-common.DataVisualizerTableState.sortDirection", "type": "string", "tags": [], "label": "sortDirection", "description": [], "source": { - "path": "x-pack/plugins/file_data_visualizer/common/types.ts", + "path": "x-pack/plugins/data_visualizer/common/types.ts", "lineNumber": 18 }, "deprecated": false }, { - "parentPluginId": "fileDataVisualizer", + "parentPluginId": "dataVisualizer", "id": "def-common.DataVisualizerTableState.visibleFieldTypes", "type": "Array", "tags": [], @@ -114,13 +114,13 @@ "string[]" ], "source": { - "path": "x-pack/plugins/file_data_visualizer/common/types.ts", + "path": "x-pack/plugins/data_visualizer/common/types.ts", "lineNumber": 19 }, "deprecated": false }, { - "parentPluginId": "fileDataVisualizer", + "parentPluginId": "dataVisualizer", "id": "def-common.DataVisualizerTableState.visibleFieldNames", "type": "Array", "tags": [], @@ -130,20 +130,20 @@ "string[]" ], "source": { - "path": "x-pack/plugins/file_data_visualizer/common/types.ts", + "path": "x-pack/plugins/data_visualizer/common/types.ts", "lineNumber": 20 }, "deprecated": false }, { - "parentPluginId": "fileDataVisualizer", + "parentPluginId": "dataVisualizer", "id": "def-common.DataVisualizerTableState.showDistributions", "type": "boolean", "tags": [], "label": "showDistributions", "description": [], "source": { - "path": "x-pack/plugins/file_data_visualizer/common/types.ts", + "path": "x-pack/plugins/data_visualizer/common/types.ts", "lineNumber": 21 }, "deprecated": false @@ -155,7 +155,7 @@ "enums": [], "misc": [ { - "parentPluginId": "fileDataVisualizer", + "parentPluginId": "dataVisualizer", "id": "def-common.ABSOLUTE_MAX_FILE_SIZE_BYTES", "type": "number", "tags": [], @@ -165,14 +165,14 @@ "1073741274" ], "source": { - "path": "x-pack/plugins/file_data_visualizer/common/constants.ts", + "path": "x-pack/plugins/data_visualizer/common/constants.ts", "lineNumber": 14 }, "deprecated": false, "initialIsOpen": false }, { - "parentPluginId": "fileDataVisualizer", + "parentPluginId": "dataVisualizer", "id": "def-common.FILE_SIZE_DISPLAY_FORMAT", "type": "string", "tags": [], @@ -182,14 +182,14 @@ "\"0,0.[0] b\"" ], "source": { - "path": "x-pack/plugins/file_data_visualizer/common/constants.ts", + "path": "x-pack/plugins/data_visualizer/common/constants.ts", "lineNumber": 15 }, "deprecated": false, "initialIsOpen": false }, { - "parentPluginId": "fileDataVisualizer", + "parentPluginId": "dataVisualizer", "id": "def-common.INDEX_META_DATA_CREATED_BY", "type": "string", "tags": [], @@ -199,14 +199,14 @@ "\"file-data-visualizer\"" ], "source": { - "path": "x-pack/plugins/file_data_visualizer/common/constants.ts", + "path": "x-pack/plugins/data_visualizer/common/constants.ts", "lineNumber": 19 }, "deprecated": false, "initialIsOpen": false }, { - "parentPluginId": "fileDataVisualizer", + "parentPluginId": "dataVisualizer", "id": "def-common.InputData", "type": "Type", "tags": [], @@ -216,31 +216,31 @@ "any[]" ], "source": { - "path": "x-pack/plugins/file_data_visualizer/common/types.ts", + "path": "x-pack/plugins/data_visualizer/common/types.ts", "lineNumber": 10 }, "deprecated": false, "initialIsOpen": false }, { - "parentPluginId": "fileDataVisualizer", + "parentPluginId": "dataVisualizer", "id": "def-common.JobFieldType", "type": "Type", "tags": [], "label": "JobFieldType", "description": [], "signature": [ - "\"number\" | \"boolean\" | \"date\" | \"keyword\" | \"text\" | \"ip\" | \"geo_point\" | \"geo_shape\" | \"unknown\"" + "\"number\" | \"boolean\" | \"date\" | \"text\" | \"keyword\" | \"ip\" | \"geo_point\" | \"geo_shape\" | \"unknown\"" ], "source": { - "path": "x-pack/plugins/file_data_visualizer/common/types.ts", + "path": "x-pack/plugins/data_visualizer/common/types.ts", "lineNumber": 12 }, "deprecated": false, "initialIsOpen": false }, { - "parentPluginId": "fileDataVisualizer", + "parentPluginId": "dataVisualizer", "id": "def-common.MAX_FILE_SIZE", "type": "string", "tags": [], @@ -250,14 +250,14 @@ "\"100MB\"" ], "source": { - "path": "x-pack/plugins/file_data_visualizer/common/constants.ts", + "path": "x-pack/plugins/data_visualizer/common/constants.ts", "lineNumber": 11 }, "deprecated": false, "initialIsOpen": false }, { - "parentPluginId": "fileDataVisualizer", + "parentPluginId": "dataVisualizer", "id": "def-common.MAX_FILE_SIZE_BYTES", "type": "number", "tags": [], @@ -267,28 +267,28 @@ "104857600" ], "source": { - "path": "x-pack/plugins/file_data_visualizer/common/constants.ts", + "path": "x-pack/plugins/data_visualizer/common/constants.ts", "lineNumber": 12 }, "deprecated": false, "initialIsOpen": false }, { - "parentPluginId": "fileDataVisualizer", + "parentPluginId": "dataVisualizer", "id": "def-common.MB", "type": "number", "tags": [], "label": "MB", "description": [], "source": { - "path": "x-pack/plugins/file_data_visualizer/common/constants.ts", + "path": "x-pack/plugins/data_visualizer/common/constants.ts", "lineNumber": 10 }, "deprecated": false, "initialIsOpen": false }, { - "parentPluginId": "fileDataVisualizer", + "parentPluginId": "dataVisualizer", "id": "def-common.UI_SETTING_MAX_FILE_SIZE", "type": "string", "tags": [], @@ -298,7 +298,7 @@ "\"fileUpload:maxFileSize\"" ], "source": { - "path": "x-pack/plugins/file_data_visualizer/common/constants.ts", + "path": "x-pack/plugins/data_visualizer/common/constants.ts", "lineNumber": 8 }, "deprecated": false, @@ -307,7 +307,7 @@ ], "objects": [ { - "parentPluginId": "fileDataVisualizer", + "parentPluginId": "dataVisualizer", "id": "def-common.JOB_FIELD_TYPES", "type": "Object", "tags": [], @@ -317,7 +317,7 @@ "{ readonly BOOLEAN: \"boolean\"; readonly DATE: \"date\"; readonly GEO_POINT: \"geo_point\"; readonly GEO_SHAPE: \"geo_shape\"; readonly IP: \"ip\"; readonly KEYWORD: \"keyword\"; readonly NUMBER: \"number\"; readonly TEXT: \"text\"; readonly UNKNOWN: \"unknown\"; }" ], "source": { - "path": "x-pack/plugins/file_data_visualizer/common/constants.ts", + "path": "x-pack/plugins/data_visualizer/common/constants.ts", "lineNumber": 21 }, "deprecated": false, @@ -325,4 +325,4 @@ } ] } -} \ No newline at end of file +} diff --git a/api_docs/file_data_visualizer.mdx b/api_docs/data_visualizer.mdx similarity index 100% rename from api_docs/file_data_visualizer.mdx rename to api_docs/data_visualizer.mdx diff --git a/docs/developer/plugin-list.asciidoc b/docs/developer/plugin-list.asciidoc index 7d06562547f70..6675a8dd283c9 100644 --- a/docs/developer/plugin-list.asciidoc +++ b/docs/developer/plugin-list.asciidoc @@ -369,6 +369,10 @@ The client-side plugin configures following values: |The data_enhanced plugin is the x-pack counterpart to the src/plguins/data plugin. +|{kib-repo}blob/{branch}/x-pack/plugins/data_visualizer/README.md[dataVisualizer] +|The data_visualizer plugin enables you to explore the fields in your data. + + |{kib-repo}blob/{branch}/x-pack/plugins/discover_enhanced/README.md[discoverEnhanced] |Contains the enhancements to the OSS discover app. @@ -396,10 +400,6 @@ actitivies. |The features plugin enhance Kibana with a per-feature privilege system. -|{kib-repo}blob/{branch}/x-pack/plugins/file_data_visualizer[fileDataVisualizer] -|WARNING: Missing README. - - |{kib-repo}blob/{branch}/x-pack/plugins/file_upload[fileUpload] |WARNING: Missing README. diff --git a/packages/kbn-optimizer/limits.yml b/packages/kbn-optimizer/limits.yml index 455453464e957..9b4199c812864 100644 --- a/packages/kbn-optimizer/limits.yml +++ b/packages/kbn-optimizer/limits.yml @@ -104,7 +104,7 @@ pageLoadAssetSize: indexPatternFieldEditor: 90489 osquery: 107090 fileUpload: 25664 - fileDataVisualizer: 27530 + dataVisualizer: 27530 banners: 17946 mapsEms: 26072 timelines: 28613 diff --git a/x-pack/.i18nrc.json b/x-pack/.i18nrc.json index b2c3a36ae3414..9b98ca864f496 100644 --- a/x-pack/.i18nrc.json +++ b/x-pack/.i18nrc.json @@ -19,7 +19,7 @@ "xpack.endpoint": "plugins/endpoint", "xpack.enterpriseSearch": "plugins/enterprise_search", "xpack.features": "plugins/features", - "xpack.fileDataVisualizer": "plugins/file_data_visualizer", + "xpack.dataVisualizer": "plugins/data_visualizer", "xpack.fileUpload": "plugins/file_upload", "xpack.globalSearch": ["plugins/global_search"], "xpack.globalSearchBar": ["plugins/global_search_bar"], diff --git a/x-pack/plugins/data_visualizer/README.md b/x-pack/plugins/data_visualizer/README.md new file mode 100644 index 0000000000000..2bd11b369e785 --- /dev/null +++ b/x-pack/plugins/data_visualizer/README.md @@ -0,0 +1 @@ +The data_visualizer plugin enables you to explore the fields in your data. \ No newline at end of file diff --git a/x-pack/plugins/file_data_visualizer/common/constants.ts b/x-pack/plugins/data_visualizer/common/constants.ts similarity index 90% rename from x-pack/plugins/file_data_visualizer/common/constants.ts rename to x-pack/plugins/data_visualizer/common/constants.ts index 819549a7eb4e6..7e0fe65632ae3 100644 --- a/x-pack/plugins/file_data_visualizer/common/constants.ts +++ b/x-pack/plugins/data_visualizer/common/constants.ts @@ -29,3 +29,5 @@ export const JOB_FIELD_TYPES = { TEXT: 'text', UNKNOWN: 'unknown', } as const; + +export const OMIT_FIELDS: string[] = ['_source', '_type', '_index', '_id', '_version', '_score']; diff --git a/x-pack/plugins/file_data_visualizer/common/index.ts b/x-pack/plugins/data_visualizer/common/index.ts similarity index 100% rename from x-pack/plugins/file_data_visualizer/common/index.ts rename to x-pack/plugins/data_visualizer/common/index.ts diff --git a/x-pack/plugins/data_visualizer/common/types/field_request_config.ts b/x-pack/plugins/data_visualizer/common/types/field_request_config.ts new file mode 100644 index 0000000000000..36e8fe14b7002 --- /dev/null +++ b/x-pack/plugins/data_visualizer/common/types/field_request_config.ts @@ -0,0 +1,60 @@ +/* + * 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 type { JobFieldType } from './index'; + +export interface Percentile { + percent: number; + minValue: number; + maxValue: number; +} + +export interface FieldRequestConfig { + fieldName?: string; + type: JobFieldType; + cardinality: number; +} + +export interface DocumentCountBuckets { + [key: string]: number; +} + +export interface DocumentCounts { + buckets?: DocumentCountBuckets; + interval?: number; +} + +export interface FieldVisStats { + cardinality?: number; + count?: number; + sampleCount?: number; + trueCount?: number; + falseCount?: number; + earliest?: number; + latest?: number; + documentCounts?: { + buckets?: DocumentCountBuckets; + interval?: number; + }; + avg?: number; + distribution?: { + percentiles: Percentile[]; + maxPercentile: number; + minPercentile: 0; + }; + fieldName?: string; + isTopValuesSampled?: boolean; + max?: number; + median?: number; + min?: number; + topValues?: Array<{ key: number | string; doc_count: number }>; + topValuesSampleSize?: number; + topValuesSamplerShardSize?: number; + examples?: Array; + timeRangeEarliest?: number; + timeRangeLatest?: number; +} diff --git a/x-pack/plugins/file_data_visualizer/common/types.ts b/x-pack/plugins/data_visualizer/common/types/index.ts similarity index 62% rename from x-pack/plugins/file_data_visualizer/common/types.ts rename to x-pack/plugins/data_visualizer/common/types/index.ts index edfe8b3575c8d..8b51142e19129 100644 --- a/x-pack/plugins/file_data_visualizer/common/types.ts +++ b/x-pack/plugins/data_visualizer/common/types/index.ts @@ -5,12 +5,17 @@ * 2.0. */ -import { JOB_FIELD_TYPES } from './constants'; - +import type { SimpleSavedObject } from 'kibana/public'; +export type { JobFieldType } from './job_field_type'; +export type { + FieldRequestConfig, + DocumentCountBuckets, + DocumentCounts, + FieldVisStats, + Percentile, +} from './field_request_config'; export type InputData = any[]; -export type JobFieldType = typeof JOB_FIELD_TYPES[keyof typeof JOB_FIELD_TYPES]; - export interface DataVisualizerTableState { pageSize: number; pageIndex: number; @@ -20,3 +25,5 @@ export interface DataVisualizerTableState { visibleFieldNames: string[]; showDistributions: boolean; } + +export type SavedSearchSavedObject = SimpleSavedObject; diff --git a/x-pack/plugins/ml/public/application/datavisualizer/stats_table/types/field_data_row.ts b/x-pack/plugins/data_visualizer/common/types/indices.ts similarity index 57% rename from x-pack/plugins/ml/public/application/datavisualizer/stats_table/types/field_data_row.ts rename to x-pack/plugins/data_visualizer/common/types/indices.ts index 24209af23ceb4..c80b89b4e84c7 100644 --- a/x-pack/plugins/ml/public/application/datavisualizer/stats_table/types/field_data_row.ts +++ b/x-pack/plugins/data_visualizer/common/types/indices.ts @@ -5,8 +5,10 @@ * 2.0. */ -import type { FieldVisConfig, FileBasedFieldVisConfig } from './field_vis_config'; +import { estypes } from '@elastic/elasticsearch'; -export interface FieldDataRowProps { - config: FieldVisConfig | FileBasedFieldVisConfig; +export interface IndicesOptions { + allow_no_indices?: boolean; + expand_wildcards?: estypes.ExpandWildcards; + ignore_unavailable?: boolean; } diff --git a/x-pack/plugins/file_data_visualizer/server/index.ts b/x-pack/plugins/data_visualizer/common/types/job_field_type.ts similarity index 66% rename from x-pack/plugins/file_data_visualizer/server/index.ts rename to x-pack/plugins/data_visualizer/common/types/job_field_type.ts index 43067dbe99d0d..ecb6ade035695 100644 --- a/x-pack/plugins/file_data_visualizer/server/index.ts +++ b/x-pack/plugins/data_visualizer/common/types/job_field_type.ts @@ -5,6 +5,5 @@ * 2.0. */ -import { FileDataVisualizerPlugin } from './plugin'; - -export const plugin = () => new FileDataVisualizerPlugin(); +import { JOB_FIELD_TYPES } from '../constants'; +export type JobFieldType = typeof JOB_FIELD_TYPES[keyof typeof JOB_FIELD_TYPES]; diff --git a/x-pack/plugins/ml/public/application/datavisualizer/index_based/common/combined_query.ts b/x-pack/plugins/data_visualizer/common/types/time_field_request.ts similarity index 62% rename from x-pack/plugins/ml/public/application/datavisualizer/index_based/common/combined_query.ts rename to x-pack/plugins/data_visualizer/common/types/time_field_request.ts index 7723277959b1f..efc5a58138ae9 100644 --- a/x-pack/plugins/ml/public/application/datavisualizer/index_based/common/combined_query.ts +++ b/x-pack/plugins/data_visualizer/common/types/time_field_request.ts @@ -5,7 +5,8 @@ * 2.0. */ -export interface CombinedQuery { - searchString: string | { [key: string]: any }; - searchQueryLanguage: string; +export interface GetTimeFieldRangeResponse { + success: boolean; + start: { epoch: number; string: string }; + end: { epoch: number; string: string }; } diff --git a/x-pack/plugins/data_visualizer/common/utils/datafeed_utils.ts b/x-pack/plugins/data_visualizer/common/utils/datafeed_utils.ts new file mode 100644 index 0000000000000..bccd40ed43b0c --- /dev/null +++ b/x-pack/plugins/data_visualizer/common/utils/datafeed_utils.ts @@ -0,0 +1,23 @@ +/* + * 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 { estypes } from '@elastic/elasticsearch'; + +export type Datafeed = estypes.MlDatafeed; +export type Aggregation = Record; + +export function getAggregations(obj: any): T | undefined { + if (obj?.aggregations !== undefined) return obj.aggregations; + if (obj?.aggs !== undefined) return obj.aggs; + return undefined; +} + +export const getDatafeedAggregations = ( + datafeedConfig: Partial | undefined +): Aggregation | undefined => { + return getAggregations(datafeedConfig); +}; diff --git a/x-pack/plugins/data_visualizer/common/utils/object_utils.ts b/x-pack/plugins/data_visualizer/common/utils/object_utils.ts new file mode 100644 index 0000000000000..537ee9202b4de --- /dev/null +++ b/x-pack/plugins/data_visualizer/common/utils/object_utils.ts @@ -0,0 +1,36 @@ +/* + * 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. + */ + +/* + * A type guard to check record like object structures. + * + * Examples: + * - `isPopulatedObject({...})` + * Limits type to Record + * + * - `isPopulatedObject({...}, ['attribute'])` + * Limits type to Record<'attribute', unknown> + * + * - `isPopulatedObject({...})` + * Limits type to a record with keys of the given interface. + * Note that you might want to add keys from the interface to the + * array of requiredAttributes to satisfy runtime requirements. + * Otherwise you'd just satisfy TS requirements but might still + * run into runtime issues. + */ +export const isPopulatedObject = ( + arg: unknown, + requiredAttributes: U[] = [] +): arg is Record => { + return ( + typeof arg === 'object' && + arg !== null && + Object.keys(arg).length > 0 && + (requiredAttributes.length === 0 || + requiredAttributes.every((d) => ({}.hasOwnProperty.call(arg, d)))) + ); +}; diff --git a/x-pack/plugins/data_visualizer/common/utils/query_utils.ts b/x-pack/plugins/data_visualizer/common/utils/query_utils.ts new file mode 100644 index 0000000000000..d2785072f419d --- /dev/null +++ b/x-pack/plugins/data_visualizer/common/utils/query_utils.ts @@ -0,0 +1,76 @@ +/* + * 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 { estypes } from '@elastic/elasticsearch'; +/* + * Contains utility functions for building and processing queries. + */ + +// Builds the base filter criteria used in queries, +// adding criteria for the time range and an optional query. +export function buildBaseFilterCriteria( + timeFieldName?: string, + earliestMs?: number, + latestMs?: number, + query?: object +) { + const filterCriteria = []; + if (timeFieldName && earliestMs && latestMs) { + filterCriteria.push({ + range: { + [timeFieldName]: { + gte: earliestMs, + lte: latestMs, + format: 'epoch_millis', + }, + }, + }); + } + + if (query) { + filterCriteria.push(query); + } + + return filterCriteria; +} + +// Wraps the supplied aggregations in a sampler aggregation. +// A supplied samplerShardSize (the shard_size parameter of the sampler aggregation) +// of less than 1 indicates no sampling, and the aggs are returned as-is. +export function buildSamplerAggregation( + aggs: any, + samplerShardSize: number +): Record { + if (samplerShardSize < 1) { + return aggs; + } + + return { + sample: { + sampler: { + shard_size: samplerShardSize, + }, + aggs, + }, + }; +} + +// Returns the path of aggregations in the elasticsearch response, as an array, +// depending on whether sampling is being used. +// A supplied samplerShardSize (the shard_size parameter of the sampler aggregation) +// of less than 1 indicates no sampling, and an empty array is returned. +export function getSamplerAggregationsResponsePath(samplerShardSize: number): string[] { + return samplerShardSize > 0 ? ['sample'] : []; +} + +// Returns a name which is safe to use in elasticsearch aggregations for the supplied +// field name. Aggregation names must be alpha-numeric and can only contain '_' and '-' characters, +// so if the supplied field names contains disallowed characters, the provided index +// identifier is used to return a safe 'dummy' name in the format 'field_index' e.g. field_0, field_1 +export function getSafeAggregationName(fieldName: string, index: number): string { + return fieldName.match(/^[a-zA-Z0-9-_.]+$/) ? fieldName : `field_${index}`; +} diff --git a/x-pack/plugins/data_visualizer/common/utils/runtime_field_utils.ts b/x-pack/plugins/data_visualizer/common/utils/runtime_field_utils.ts new file mode 100644 index 0000000000000..fbe4ae5c6faf1 --- /dev/null +++ b/x-pack/plugins/data_visualizer/common/utils/runtime_field_utils.ts @@ -0,0 +1,28 @@ +/* + * 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 { estypes } from '@elastic/elasticsearch'; +import { isPopulatedObject } from './object_utils'; +import { RUNTIME_FIELD_TYPES } from '../../../../../src/plugins/data/common'; + +type RuntimeType = typeof RUNTIME_FIELD_TYPES[number]; + +export function isRuntimeField(arg: unknown): arg is estypes.MappingRuntimeField { + return ( + ((isPopulatedObject(arg, ['type']) && Object.keys(arg).length === 1) || + (isPopulatedObject(arg, ['type', 'script']) && + Object.keys(arg).length === 2 && + (typeof arg.script === 'string' || + (isPopulatedObject(arg.script, ['source']) && + Object.keys(arg.script).length === 1 && + typeof arg.script.source === 'string')))) && + RUNTIME_FIELD_TYPES.includes(arg.type as RuntimeType) + ); +} + +export function isRuntimeMappings(arg: unknown): arg is estypes.MappingRuntimeFields { + return isPopulatedObject(arg) && Object.values(arg).every((d) => isRuntimeField(d)); +} diff --git a/x-pack/plugins/data_visualizer/common/utils/string_utils.ts b/x-pack/plugins/data_visualizer/common/utils/string_utils.ts new file mode 100644 index 0000000000000..94515e4dd95e9 --- /dev/null +++ b/x-pack/plugins/data_visualizer/common/utils/string_utils.ts @@ -0,0 +1,23 @@ +/* + * 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. + */ + +/** + * Creates a deterministic number based hash out of a string. + */ +export function stringHash(str: string): number { + let hash = 0; + let chr = 0; + if (str.length === 0) { + return hash; + } + for (let i = 0; i < str.length; i++) { + chr = str.charCodeAt(i); + hash = (hash << 5) - hash + chr; // eslint-disable-line no-bitwise + hash |= 0; // eslint-disable-line no-bitwise + } + return hash < 0 ? hash * -2 : hash; +} diff --git a/x-pack/plugins/file_data_visualizer/jest.config.js b/x-pack/plugins/data_visualizer/jest.config.js similarity index 84% rename from x-pack/plugins/file_data_visualizer/jest.config.js rename to x-pack/plugins/data_visualizer/jest.config.js index 90d4cfb81f11f..1c4974471bd79 100644 --- a/x-pack/plugins/file_data_visualizer/jest.config.js +++ b/x-pack/plugins/data_visualizer/jest.config.js @@ -8,5 +8,5 @@ module.exports = { preset: '@kbn/test', rootDir: '../../..', - roots: ['/x-pack/plugins/file_data_visualizer'], + roots: ['/x-pack/plugins/data_visualizer'], }; diff --git a/x-pack/plugins/file_data_visualizer/kibana.json b/x-pack/plugins/data_visualizer/kibana.json similarity index 88% rename from x-pack/plugins/file_data_visualizer/kibana.json rename to x-pack/plugins/data_visualizer/kibana.json index eea52bb6e98b2..3934f0ee3417f 100644 --- a/x-pack/plugins/file_data_visualizer/kibana.json +++ b/x-pack/plugins/data_visualizer/kibana.json @@ -1,5 +1,5 @@ { - "id": "fileDataVisualizer", + "id": "dataVisualizer", "version": "8.0.0", "kibanaVersion": "kibana", "server": true, @@ -15,7 +15,8 @@ "optionalPlugins": [ "security", "maps", - "home" + "home", + "lens" ], "requiredBundles": [ "kibanaReact", diff --git a/x-pack/plugins/file_data_visualizer/public/api/index.ts b/x-pack/plugins/data_visualizer/public/api/index.ts similarity index 61% rename from x-pack/plugins/file_data_visualizer/public/api/index.ts rename to x-pack/plugins/data_visualizer/public/api/index.ts index 13efd80133349..746b43ac86e30 100644 --- a/x-pack/plugins/file_data_visualizer/public/api/index.ts +++ b/x-pack/plugins/data_visualizer/public/api/index.ts @@ -6,9 +6,13 @@ */ import { lazyLoadModules } from '../lazy_load_bundle'; -import { FileDataVisualizer } from '../application'; +import type { FileDataVisualizerSpec, IndexDataVisualizerSpec } from '../application'; -export async function getFileDataVisualizerComponent(): Promise { +export async function getFileDataVisualizerComponent(): Promise { const modules = await lazyLoadModules(); return modules.FileDataVisualizer; } +export async function getIndexDataVisualizerComponent(): Promise { + const modules = await lazyLoadModules(); + return modules.IndexDataVisualizer; +} diff --git a/x-pack/plugins/data_visualizer/public/application/_index.scss b/x-pack/plugins/data_visualizer/public/application/_index.scss new file mode 100644 index 0000000000000..9d38869d6d61c --- /dev/null +++ b/x-pack/plugins/data_visualizer/public/application/_index.scss @@ -0,0 +1,2 @@ +@import 'common/components/index'; +@import 'file_data_visualizer/index'; diff --git a/x-pack/plugins/data_visualizer/public/application/common/components/_index.scss b/x-pack/plugins/data_visualizer/public/application/common/components/_index.scss new file mode 100644 index 0000000000000..f57abbbe6396b --- /dev/null +++ b/x-pack/plugins/data_visualizer/public/application/common/components/_index.scss @@ -0,0 +1,4 @@ +@import 'embedded_map/index'; +@import 'experimental_badge/index'; +@import 'stats_table/index'; +@import 'top_values/top_values'; diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/combined_fields/combined_field_label.tsx b/x-pack/plugins/data_visualizer/public/application/common/components/combined_fields/combined_field_label.tsx similarity index 100% rename from x-pack/plugins/file_data_visualizer/public/application/components/combined_fields/combined_field_label.tsx rename to x-pack/plugins/data_visualizer/public/application/common/components/combined_fields/combined_field_label.tsx diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/combined_fields/combined_fields_form.tsx b/x-pack/plugins/data_visualizer/public/application/common/components/combined_fields/combined_fields_form.tsx similarity index 86% rename from x-pack/plugins/file_data_visualizer/public/application/components/combined_fields/combined_fields_form.tsx rename to x-pack/plugins/data_visualizer/public/application/common/components/combined_fields/combined_fields_form.tsx index fddab3edc3ec0..e77dc853fdc52 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/combined_fields/combined_fields_form.tsx +++ b/x-pack/plugins/data_visualizer/public/application/common/components/combined_fields/combined_fields_form.tsx @@ -29,7 +29,7 @@ import { removeCombinedFieldsFromMappings, removeCombinedFieldsFromPipeline, } from './utils'; -import { FindFileStructureResponse } from '../../../../../file_upload/common'; +import { FindFileStructureResponse } from '../../../../../../file_upload/common'; interface Props { mappingsString: string; @@ -110,7 +110,7 @@ export class CombinedFieldsForm extends Component { return JSON.parse(this.props.mappingsString); } catch (error) { throw new Error( - i18n.translate('xpack.fileDataVisualizer.combinedFieldsForm.mappingsParseError', { + i18n.translate('xpack.dataVisualizer.combinedFieldsForm.mappingsParseError', { defaultMessage: 'Error parsing mappings: {error}', values: { error: error.message }, }) @@ -123,7 +123,7 @@ export class CombinedFieldsForm extends Component { return JSON.parse(this.props.pipelineString); } catch (error) { throw new Error( - i18n.translate('xpack.fileDataVisualizer.combinedFieldsForm.pipelineParseError', { + i18n.translate('xpack.dataVisualizer.combinedFieldsForm.pipelineParseError', { defaultMessage: 'Error parsing pipeline: {error}', values: { error: error.message }, }) @@ -149,9 +149,12 @@ export class CombinedFieldsForm extends Component { }; render() { - const geoPointLabel = i18n.translate('xpack.fileDataVisualizer.geoPointCombinedFieldLabel', { - defaultMessage: 'Add geo point field', - }); + const geoPointLabel = i18n.translate( + 'xpack.dataVisualizer.file.geoPointForm.combinedFieldLabel', + { + defaultMessage: 'Add geo point field', + } + ); const panels = [ { id: 0, @@ -176,7 +179,7 @@ export class CombinedFieldsForm extends Component { ]; return ( @@ -192,15 +195,12 @@ export class CombinedFieldsForm extends Component { iconType="trash" color="danger" onClick={this.removeCombinedField.bind(null, idx)} - title={i18n.translate('xpack.fileDataVisualizer.removeCombinedFieldsLabel', { + title={i18n.translate('xpack.dataVisualizer.removeCombinedFieldsLabel', { + defaultMessage: 'Remove combined field', + })} + aria-label={i18n.translate('xpack.dataVisualizer.removeCombinedFieldsLabel', { defaultMessage: 'Remove combined field', })} - aria-label={i18n.translate( - 'xpack.fileDataVisualizer.removeCombinedFieldsLabel', - { - defaultMessage: 'Remove combined field', - } - )} /> )} @@ -216,7 +216,7 @@ export class CombinedFieldsForm extends Component { isDisabled={this.props.isDisabled} > diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/combined_fields/combined_fields_read_only_form.tsx b/x-pack/plugins/data_visualizer/public/application/common/components/combined_fields/combined_fields_read_only_form.tsx similarity index 84% rename from x-pack/plugins/file_data_visualizer/public/application/components/combined_fields/combined_fields_read_only_form.tsx rename to x-pack/plugins/data_visualizer/public/application/common/components/combined_fields/combined_fields_read_only_form.tsx index 978383f8e5e10..a7296c372afe4 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/combined_fields/combined_fields_read_only_form.tsx +++ b/x-pack/plugins/data_visualizer/public/application/common/components/combined_fields/combined_fields_read_only_form.tsx @@ -20,10 +20,10 @@ export function CombinedFieldsReadOnlyForm({ }) { return combinedFields.length ? ( diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/combined_fields/geo_point.tsx b/x-pack/plugins/data_visualizer/public/application/common/components/combined_fields/geo_point.tsx similarity index 90% rename from x-pack/plugins/file_data_visualizer/public/application/components/combined_fields/geo_point.tsx rename to x-pack/plugins/data_visualizer/public/application/common/components/combined_fields/geo_point.tsx index 578d22384be33..f6cfcc32e733a 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/combined_fields/geo_point.tsx +++ b/x-pack/plugins/data_visualizer/public/application/common/components/combined_fields/geo_point.tsx @@ -29,7 +29,7 @@ import { getFieldNames, getNameCollisionMsg, } from './utils'; -import { FindFileStructureResponse } from '../../../../../file_upload/common'; +import { FindFileStructureResponse } from '../../../../../../file_upload/common'; interface Props { addCombinedField: (combinedField: CombinedField) => void; @@ -119,7 +119,7 @@ export class GeoPointForm extends Component { return ( @@ -131,7 +131,7 @@ export class GeoPointForm extends Component { @@ -143,7 +143,7 @@ export class GeoPointForm extends Component { { onChange={this.onGeoPointFieldChange} isInvalid={this.state.geoPointFieldError !== ''} aria-label={i18n.translate( - 'xpack.fileDataVisualizer.geoPointForm.geoPointFieldAriaLabel', + 'xpack.dataVisualizer.file.geoPointForm.geoPointFieldAriaLabel', { defaultMessage: 'Geo point field, required field', } @@ -179,7 +179,7 @@ export class GeoPointForm extends Component { onClick={this.onSubmit} > diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/combined_fields/index.ts b/x-pack/plugins/data_visualizer/public/application/common/components/combined_fields/index.ts similarity index 100% rename from x-pack/plugins/file_data_visualizer/public/application/components/combined_fields/index.ts rename to x-pack/plugins/data_visualizer/public/application/common/components/combined_fields/index.ts diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/combined_fields/types.ts b/x-pack/plugins/data_visualizer/public/application/common/components/combined_fields/types.ts similarity index 100% rename from x-pack/plugins/file_data_visualizer/public/application/components/combined_fields/types.ts rename to x-pack/plugins/data_visualizer/public/application/common/components/combined_fields/types.ts diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/combined_fields/utils.test.ts b/x-pack/plugins/data_visualizer/public/application/common/components/combined_fields/utils.test.ts similarity index 100% rename from x-pack/plugins/file_data_visualizer/public/application/components/combined_fields/utils.test.ts rename to x-pack/plugins/data_visualizer/public/application/common/components/combined_fields/utils.test.ts diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/combined_fields/utils.ts b/x-pack/plugins/data_visualizer/public/application/common/components/combined_fields/utils.ts similarity index 97% rename from x-pack/plugins/file_data_visualizer/public/application/components/combined_fields/utils.ts rename to x-pack/plugins/data_visualizer/public/application/common/components/combined_fields/utils.ts index efd166d4821c5..e021de5e5beca 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/combined_fields/utils.ts +++ b/x-pack/plugins/data_visualizer/public/application/common/components/combined_fields/utils.ts @@ -13,7 +13,7 @@ import { FindFileStructureResponse, IngestPipeline, Mappings, -} from '../../../../../file_upload/common'; +} from '../../../../../../file_upload/common'; const COMMON_LAT_NAMES = ['latitude', 'lat']; const COMMON_LON_NAMES = ['longitude', 'long', 'lon']; @@ -127,7 +127,7 @@ export function createGeoPointCombinedField( } export function getNameCollisionMsg(name: string) { - return i18n.translate('xpack.fileDataVisualizer.nameCollisionMsg', { + return i18n.translate('xpack.dataVisualizer.nameCollisionMsg', { defaultMessage: '"{name}" already exists, please provide a unique name', values: { name }, }); diff --git a/x-pack/plugins/data_visualizer/public/application/common/components/date_picker_wrapper/date_picker_wrapper.tsx b/x-pack/plugins/data_visualizer/public/application/common/components/date_picker_wrapper/date_picker_wrapper.tsx new file mode 100644 index 0000000000000..f6f53f40d6b9e --- /dev/null +++ b/x-pack/plugins/data_visualizer/public/application/common/components/date_picker_wrapper/date_picker_wrapper.tsx @@ -0,0 +1,172 @@ +/* + * 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, { FC, useCallback, useEffect, useMemo, useState } from 'react'; +import { Subscription } from 'rxjs'; +import { debounce } from 'lodash'; + +import { EuiSuperDatePicker, OnRefreshProps } from '@elastic/eui'; +import { + TimeHistoryContract, + TimeRange, + UI_SETTINGS, +} from '../../../../../../../../src/plugins/data/public'; + +import { useUrlState } from '../../util/url_state'; +import { useDataVisualizerKibana } from '../../../kibana_context'; +import { dataVisualizerTimefilterRefresh$ } from '../../../index_data_visualizer/services/timefilter_refresh_service'; + +interface TimePickerQuickRange { + from: string; + to: string; + display: string; +} + +interface Duration { + start: string; + end: string; +} + +interface RefreshInterval { + pause: boolean; + value: number; +} + +function getRecentlyUsedRangesFactory(timeHistory: TimeHistoryContract) { + return function (): Duration[] { + return ( + timeHistory.get()?.map(({ from, to }: TimeRange) => { + return { + start: from, + end: to, + }; + }) ?? [] + ); + }; +} + +function updateLastRefresh(timeRange: OnRefreshProps) { + dataVisualizerTimefilterRefresh$.next({ lastRefresh: Date.now(), timeRange }); +} + +export const DatePickerWrapper: FC = () => { + const { services } = useDataVisualizerKibana(); + const config = services.uiSettings; + const { timefilter, history } = services.data.query.timefilter; + + const [globalState, setGlobalState] = useUrlState('_g'); + const getRecentlyUsedRanges = getRecentlyUsedRangesFactory(history); + + const refreshInterval: RefreshInterval = + globalState?.refreshInterval ?? timefilter.getRefreshInterval(); + + // eslint-disable-next-line react-hooks/exhaustive-deps + const setRefreshInterval = useCallback( + debounce((refreshIntervalUpdate: RefreshInterval) => { + setGlobalState('refreshInterval', refreshIntervalUpdate, true); + }, 200), + [setGlobalState] + ); + + const [time, setTime] = useState(timefilter.getTime()); + const [recentlyUsedRanges, setRecentlyUsedRanges] = useState(getRecentlyUsedRanges()); + const [isAutoRefreshSelectorEnabled, setIsAutoRefreshSelectorEnabled] = useState( + timefilter.isAutoRefreshSelectorEnabled() + ); + const [isTimeRangeSelectorEnabled, setIsTimeRangeSelectorEnabled] = useState( + timefilter.isTimeRangeSelectorEnabled() + ); + + const dateFormat = config.get('dateFormat'); + const timePickerQuickRanges = config.get( + UI_SETTINGS.TIMEPICKER_QUICK_RANGES + ); + + const commonlyUsedRanges = useMemo( + () => + timePickerQuickRanges.map(({ from, to, display }) => ({ + start: from, + end: to, + label: display, + })), + [timePickerQuickRanges] + ); + + useEffect(() => { + const subscriptions = new Subscription(); + const refreshIntervalUpdate$ = timefilter.getRefreshIntervalUpdate$(); + if (refreshIntervalUpdate$ !== undefined) { + subscriptions.add( + refreshIntervalUpdate$.subscribe((r) => { + setRefreshInterval(timefilter.getRefreshInterval()); + }) + ); + } + const timeUpdate$ = timefilter.getTimeUpdate$(); + if (timeUpdate$ !== undefined) { + subscriptions.add( + timeUpdate$.subscribe((v) => { + setTime(timefilter.getTime()); + }) + ); + } + const enabledUpdated$ = timefilter.getEnabledUpdated$(); + if (enabledUpdated$ !== undefined) { + subscriptions.add( + enabledUpdated$.subscribe((w) => { + setIsAutoRefreshSelectorEnabled(timefilter.isAutoRefreshSelectorEnabled()); + setIsTimeRangeSelectorEnabled(timefilter.isTimeRangeSelectorEnabled()); + }) + ); + } + + return function cleanup() { + subscriptions.unsubscribe(); + }; + }, [setRefreshInterval, timefilter]); + + function updateFilter({ start, end }: Duration) { + const newTime = { from: start, to: end }; + // Update timefilter for controllers listening for changes + timefilter.setTime(newTime); + setTime(newTime); + setRecentlyUsedRanges(getRecentlyUsedRanges()); + } + + function updateInterval({ + isPaused: pause, + refreshInterval: value, + }: { + isPaused: boolean; + refreshInterval: number; + }) { + setRefreshInterval({ pause, value }); + } + + /** + * Enforce pause when it's set to false with 0 refresh interval. + */ + const isPaused = refreshInterval.pause || (!refreshInterval.pause && !refreshInterval.value); + + return isAutoRefreshSelectorEnabled || isTimeRangeSelectorEnabled ? ( +
+ +
+ ) : null; +}; diff --git a/x-pack/plugins/data_visualizer/public/application/common/components/date_picker_wrapper/index.ts b/x-pack/plugins/data_visualizer/public/application/common/components/date_picker_wrapper/index.ts new file mode 100644 index 0000000000000..232f6c65d2b64 --- /dev/null +++ b/x-pack/plugins/data_visualizer/public/application/common/components/date_picker_wrapper/index.ts @@ -0,0 +1,8 @@ +/* + * 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. + */ + +export { DatePickerWrapper } from './date_picker_wrapper'; diff --git a/x-pack/plugins/ml/public/application/datavisualizer/index_based/components/field_data_row/document_count_chart/document_count_chart.tsx b/x-pack/plugins/data_visualizer/public/application/common/components/document_count_content/document_count_chart/document_count_chart.tsx similarity index 87% rename from x-pack/plugins/ml/public/application/datavisualizer/index_based/components/field_data_row/document_count_chart/document_count_chart.tsx rename to x-pack/plugins/data_visualizer/public/application/common/components/document_count_content/document_count_chart/document_count_chart.tsx index 4c8740cc76b6f..34faed01f613e 100644 --- a/x-pack/plugins/ml/public/application/datavisualizer/index_based/components/field_data_row/document_count_chart/document_count_chart.tsx +++ b/x-pack/plugins/data_visualizer/public/application/common/components/document_count_content/document_count_chart/document_count_chart.tsx @@ -41,9 +41,12 @@ export const DocumentCountChart: FC = ({ timeRangeLatest, interval, }) => { - const seriesName = i18n.translate('xpack.ml.fieldDataCard.documentCountChart.seriesLabel', { - defaultMessage: 'document count', - }); + const seriesName = i18n.translate( + 'xpack.dataVisualizer.dataGrid.field.documentCountChart.seriesLabel', + { + defaultMessage: 'document count', + } + ); const xDomain = { min: timeRangeEarliest, @@ -65,10 +68,11 @@ export const DocumentCountChart: FC = ({ ]; } return chartPoints; + // eslint-disable-next-line react-hooks/exhaustive-deps }, [chartPoints, timeRangeEarliest, timeRangeLatest, interval]); return ( -
+
{ return ( - + + diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/embedded_map/_embedded_map.scss b/x-pack/plugins/data_visualizer/public/application/common/components/embedded_map/_embedded_map.scss similarity index 100% rename from x-pack/plugins/file_data_visualizer/public/application/components/embedded_map/_embedded_map.scss rename to x-pack/plugins/data_visualizer/public/application/common/components/embedded_map/_embedded_map.scss diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/embedded_map/_index.scss b/x-pack/plugins/data_visualizer/public/application/common/components/embedded_map/_index.scss similarity index 100% rename from x-pack/plugins/file_data_visualizer/public/application/components/embedded_map/_index.scss rename to x-pack/plugins/data_visualizer/public/application/common/components/embedded_map/_index.scss diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/embedded_map/embedded_map.tsx b/x-pack/plugins/data_visualizer/public/application/common/components/embedded_map/embedded_map.tsx similarity index 90% rename from x-pack/plugins/file_data_visualizer/public/application/components/embedded_map/embedded_map.tsx rename to x-pack/plugins/data_visualizer/public/application/common/components/embedded_map/embedded_map.tsx index b2487626099a9..29131b4a3372a 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/embedded_map/embedded_map.tsx +++ b/x-pack/plugins/data_visualizer/public/application/common/components/embedded_map/embedded_map.tsx @@ -8,22 +8,22 @@ import React, { useEffect, useRef, useState } from 'react'; import { htmlIdGenerator } from '@elastic/eui'; -import { LayerDescriptor } from '../../../../../maps/common/descriptor_types'; -import { INITIAL_LOCATION } from '../../../../../maps/common/constants'; +import { LayerDescriptor } from '../../../../../../maps/common/descriptor_types'; +import { INITIAL_LOCATION } from '../../../../../../maps/common/constants'; import { MapEmbeddable, MapEmbeddableInput, MapEmbeddableOutput, // eslint-disable-next-line @kbn/eslint/no-restricted-paths -} from '../../../../../maps/public/embeddable'; -import { MAP_SAVED_OBJECT_TYPE, RenderTooltipContentParams } from '../../../../../maps/public'; +} from '../../../../../../maps/public/embeddable'; +import { MAP_SAVED_OBJECT_TYPE, RenderTooltipContentParams } from '../../../../../../maps/public'; import { EmbeddableFactory, ErrorEmbeddable, isErrorEmbeddable, ViewMode, -} from '../../../../../../../src/plugins/embeddable/public'; -import { useFileDataVisualizerKibana } from '../../kibana_context'; +} from '../../../../../../../../src/plugins/embeddable/public'; +import { useDataVisualizerKibana } from '../../../kibana_context'; export function EmbeddedMapComponent({ layerList, @@ -41,7 +41,7 @@ export function EmbeddedMapComponent({ const { services: { embeddable: embeddablePlugin, maps: mapsPlugin }, - } = useFileDataVisualizerKibana(); + } = useDataVisualizerKibana(); const factory: | EmbeddableFactory @@ -143,7 +143,7 @@ export function EmbeddedMapComponent({ return (
diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/embedded_map/index.ts b/x-pack/plugins/data_visualizer/public/application/common/components/embedded_map/index.ts similarity index 100% rename from x-pack/plugins/file_data_visualizer/public/application/components/embedded_map/index.ts rename to x-pack/plugins/data_visualizer/public/application/common/components/embedded_map/index.ts diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/examples_list/examples_list.tsx b/x-pack/plugins/data_visualizer/public/application/common/components/examples_list/examples_list.tsx similarity index 88% rename from x-pack/plugins/file_data_visualizer/public/application/components/examples_list/examples_list.tsx rename to x-pack/plugins/data_visualizer/public/application/common/components/examples_list/examples_list.tsx index 1c533075af27b..296820479437c 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/examples_list/examples_list.tsx +++ b/x-pack/plugins/data_visualizer/public/application/common/components/examples_list/examples_list.tsx @@ -23,7 +23,7 @@ export const ExamplesList: FC = ({ examples }) => { if (examples.length === 0) { examplesContent = ( ); @@ -41,10 +41,10 @@ export const ExamplesList: FC = ({ examples }) => { } return ( -
+
{ @@ -54,7 +54,7 @@ export const FileBasedDataVisualizerExpandedRow = ({ item }: { item: FileBasedFi return (
{getCardContent()}
diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/expanded_row/geo_point_content/format_utils.ts b/x-pack/plugins/data_visualizer/public/application/common/components/expanded_row/geo_point_content/format_utils.ts similarity index 96% rename from x-pack/plugins/file_data_visualizer/public/application/components/expanded_row/geo_point_content/format_utils.ts rename to x-pack/plugins/data_visualizer/public/application/common/components/expanded_row/geo_point_content/format_utils.ts index 69e361aba9bca..ddc9255b4834d 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/expanded_row/geo_point_content/format_utils.ts +++ b/x-pack/plugins/data_visualizer/public/application/common/components/expanded_row/geo_point_content/format_utils.ts @@ -8,7 +8,7 @@ import { Feature, Point } from 'geojson'; import { euiPaletteColorBlind } from '@elastic/eui'; import { DEFAULT_GEO_REGEX } from './geo_point_content'; -import { SOURCE_TYPES } from '../../../../../../maps/common/constants'; +import { SOURCE_TYPES } from '../../../../../../../maps/common/constants'; export const convertWKTGeoToLonLat = ( value: string | number diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/expanded_row/geo_point_content/geo_point_content.tsx b/x-pack/plugins/data_visualizer/public/application/common/components/expanded_row/geo_point_content/geo_point_content.tsx similarity index 95% rename from x-pack/plugins/file_data_visualizer/public/application/components/expanded_row/geo_point_content/geo_point_content.tsx rename to x-pack/plugins/data_visualizer/public/application/common/components/expanded_row/geo_point_content/geo_point_content.tsx index c395b06059e8f..b732e542658b5 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/expanded_row/geo_point_content/geo_point_content.tsx +++ b/x-pack/plugins/data_visualizer/public/application/common/components/expanded_row/geo_point_content/geo_point_content.tsx @@ -60,7 +60,7 @@ export const GeoPointContent: FC = ({ config }) => { } }, [config]); return ( - + {formattedResults && Array.isArray(formattedResults.examples) && ( @@ -70,7 +70,7 @@ export const GeoPointContent: FC = ({ config }) => { {formattedResults && Array.isArray(formattedResults.layerList) && ( diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/expanded_row/geo_point_content/index.ts b/x-pack/plugins/data_visualizer/public/application/common/components/expanded_row/geo_point_content/index.ts similarity index 100% rename from x-pack/plugins/file_data_visualizer/public/application/components/expanded_row/geo_point_content/index.ts rename to x-pack/plugins/data_visualizer/public/application/common/components/expanded_row/geo_point_content/index.ts diff --git a/x-pack/plugins/ml/public/application/datavisualizer/index_based/components/expanded_row/geo_point_content.tsx b/x-pack/plugins/data_visualizer/public/application/common/components/expanded_row/geo_point_content_with_map/geo_point_content_with_map.tsx similarity index 59% rename from x-pack/plugins/ml/public/application/datavisualizer/index_based/components/expanded_row/geo_point_content.tsx rename to x-pack/plugins/data_visualizer/public/application/common/components/expanded_row/geo_point_content_with_map/geo_point_content_with_map.tsx index 646a81b127bcc..b4c8c3c22f5a9 100644 --- a/x-pack/plugins/ml/public/application/datavisualizer/index_based/components/expanded_row/geo_point_content.tsx +++ b/x-pack/plugins/data_visualizer/public/application/common/components/expanded_row/geo_point_content_with_map/geo_point_content_with_map.tsx @@ -6,21 +6,20 @@ */ import React, { FC, useEffect, useState } from 'react'; - import { EuiFlexItem } from '@elastic/eui'; -import { ExamplesList } from '../../../index_based/components/field_data_row/examples_list'; -import { MlEmbeddedMapComponent } from '../../../../components/ml_embedded_map'; -import { ML_JOB_FIELD_TYPES } from '../../../../../../common/constants/field_types'; -import { ES_GEO_FIELD_TYPE } from '../../../../../../../maps/common/constants'; -import { useMlKibana } from '../../../../contexts/kibana'; -import { DocumentStatsTable } from '../../../stats_table/components/field_data_expanded_row/document_stats'; -import { ExpandedRowContent } from '../../../stats_table/components/field_data_expanded_row/expanded_row_content'; -import type { CombinedQuery } from '../../common'; -import type { IndexPattern } from '../../../../../../../../../src/plugins/data/common/index_patterns/index_patterns'; -import type { LayerDescriptor } from '../../../../../../../maps/common/descriptor_types'; -import type { FieldVisConfig } from '../../../stats_table/types'; +import { IndexPattern } from '../../../../../../../../../src/plugins/data/common/index_patterns/index_patterns'; +import { CombinedQuery } from '../../../../index_data_visualizer/types/combined_query'; +import { ExpandedRowContent } from '../../stats_table/components/field_data_expanded_row/expanded_row_content'; +import { DocumentStatsTable } from '../../stats_table/components/field_data_expanded_row/document_stats'; +import { ExamplesList } from '../../examples_list'; +import { FieldVisConfig } from '../../stats_table/types'; +import { LayerDescriptor } from '../../../../../../../maps/common/descriptor_types'; +import { useDataVisualizerKibana } from '../../../../kibana_context'; +import { JOB_FIELD_TYPES } from '../../../../../../common'; +import { ES_GEO_FIELD_TYPE } from '../../../../../../../maps/common'; +import { EmbeddedMapComponent } from '../../embedded_map'; -export const GeoPointContent: FC<{ +export const GeoPointContentWithMap: FC<{ config: FieldVisConfig; indexPattern: IndexPattern | undefined; combinedQuery: CombinedQuery; @@ -29,7 +28,7 @@ export const GeoPointContent: FC<{ const [layerList, setLayerList] = useState([]); const { services: { maps: mapsPlugin }, - } = useMlKibana(); + } = useDataVisualizerKibana(); // Update the layer list with updated geo points upon refresh useEffect(() => { @@ -38,8 +37,7 @@ export const GeoPointContent: FC<{ indexPattern?.id !== undefined && config !== undefined && config.fieldName !== undefined && - (config.type === ML_JOB_FIELD_TYPES.GEO_POINT || - config.type === ML_JOB_FIELD_TYPES.GEO_SHAPE) + (config.type === JOB_FIELD_TYPES.GEO_POINT || config.type === JOB_FIELD_TYPES.GEO_SHAPE) ) { const params = { indexPatternId: indexPattern.id, @@ -59,18 +57,19 @@ export const GeoPointContent: FC<{ } } updateIndexPatternSearchLayer(); - }, [indexPattern, config.fieldName, combinedQuery]); + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [indexPattern, combinedQuery, config, mapsPlugin]); if (stats?.examples === undefined) return null; return ( - + - - + + ); diff --git a/x-pack/plugins/file_data_visualizer/public/application/index.ts b/x-pack/plugins/data_visualizer/public/application/common/components/expanded_row/geo_point_content_with_map/index.ts similarity index 78% rename from x-pack/plugins/file_data_visualizer/public/application/index.ts rename to x-pack/plugins/data_visualizer/public/application/common/components/expanded_row/geo_point_content_with_map/index.ts index dba820519af94..c40fcfa38fb17 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/index.ts +++ b/x-pack/plugins/data_visualizer/public/application/common/components/expanded_row/geo_point_content_with_map/index.ts @@ -5,4 +5,4 @@ * 2.0. */ -export { FileDataVisualizer } from './file_datavisualizer'; +export { GeoPointContentWithMap } from './geo_point_content_with_map'; diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/expanded_row/index.ts b/x-pack/plugins/data_visualizer/public/application/common/components/expanded_row/index.ts similarity index 100% rename from x-pack/plugins/file_data_visualizer/public/application/components/expanded_row/index.ts rename to x-pack/plugins/data_visualizer/public/application/common/components/expanded_row/index.ts diff --git a/x-pack/plugins/ml/public/application/datavisualizer/index_based/components/expanded_row/expanded_row.tsx b/x-pack/plugins/data_visualizer/public/application/common/components/expanded_row/index_based_expanded_row.tsx similarity index 58% rename from x-pack/plugins/ml/public/application/datavisualizer/index_based/components/expanded_row/expanded_row.tsx rename to x-pack/plugins/data_visualizer/public/application/common/components/expanded_row/index_based_expanded_row.tsx index bd8eb09128d1d..6406012a0540b 100644 --- a/x-pack/plugins/ml/public/application/datavisualizer/index_based/components/expanded_row/expanded_row.tsx +++ b/x-pack/plugins/data_visualizer/public/application/common/components/expanded_row/index_based_expanded_row.tsx @@ -6,10 +6,8 @@ */ import React from 'react'; - -import { ML_JOB_FIELD_TYPES } from '../../../../../../common/constants/field_types'; -import { LoadingIndicator } from '../field_data_row/loading_indicator'; -import { NotInDocsContent } from '../field_data_row/content_types'; +import { GeoPointContentWithMap } from './geo_point_content_with_map'; +import { JOB_FIELD_TYPES } from '../../../../../common'; import { BooleanContent, DateContent, @@ -18,11 +16,12 @@ import { NumberContent, OtherContent, TextContent, -} from '../../../stats_table/components/field_data_expanded_row'; -import { GeoPointContent } from './geo_point_content'; -import type { CombinedQuery } from '../../common'; -import type { IndexPattern } from '../../../../../../../../../src/plugins/data/common/index_patterns/index_patterns'; -import type { FieldVisConfig } from '../../../stats_table/types'; +} from '../stats_table/components/field_data_expanded_row'; +import { NotInDocsContent } from '../not_in_docs_content'; +import { FieldVisConfig } from '../stats_table/types'; +import { IndexPattern } from '../../../../../../../../src/plugins/data/common/index_patterns/index_patterns'; +import { CombinedQuery } from '../../../index_data_visualizer/types/combined_query'; +import { LoadingIndicator } from '../loading_indicator'; export const IndexBasedDataVisualizerExpandedRow = ({ item, @@ -42,32 +41,32 @@ export const IndexBasedDataVisualizerExpandedRow = ({ } switch (type) { - case ML_JOB_FIELD_TYPES.NUMBER: + case JOB_FIELD_TYPES.NUMBER: return ; - case ML_JOB_FIELD_TYPES.BOOLEAN: + case JOB_FIELD_TYPES.BOOLEAN: return ; - case ML_JOB_FIELD_TYPES.DATE: + case JOB_FIELD_TYPES.DATE: return ; - case ML_JOB_FIELD_TYPES.GEO_POINT: - case ML_JOB_FIELD_TYPES.GEO_SHAPE: + case JOB_FIELD_TYPES.GEO_POINT: + case JOB_FIELD_TYPES.GEO_SHAPE: return ( - ); - case ML_JOB_FIELD_TYPES.IP: + case JOB_FIELD_TYPES.IP: return ; - case ML_JOB_FIELD_TYPES.KEYWORD: + case JOB_FIELD_TYPES.KEYWORD: return ; - case ML_JOB_FIELD_TYPES.TEXT: + case JOB_FIELD_TYPES.TEXT: return ; default: @@ -77,8 +76,8 @@ export const IndexBasedDataVisualizerExpandedRow = ({ return (
{loading === true ? : getCardContent()}
diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/experimental_badge/_experimental_badge.scss b/x-pack/plugins/data_visualizer/public/application/common/components/experimental_badge/_experimental_badge.scss similarity index 100% rename from x-pack/plugins/file_data_visualizer/public/application/components/experimental_badge/_experimental_badge.scss rename to x-pack/plugins/data_visualizer/public/application/common/components/experimental_badge/_experimental_badge.scss diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/experimental_badge/_index.scss b/x-pack/plugins/data_visualizer/public/application/common/components/experimental_badge/_index.scss similarity index 100% rename from x-pack/plugins/file_data_visualizer/public/application/components/experimental_badge/_index.scss rename to x-pack/plugins/data_visualizer/public/application/common/components/experimental_badge/_index.scss diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/experimental_badge/experimental_badge.tsx b/x-pack/plugins/data_visualizer/public/application/common/components/experimental_badge/experimental_badge.tsx similarity index 90% rename from x-pack/plugins/file_data_visualizer/public/application/components/experimental_badge/experimental_badge.tsx rename to x-pack/plugins/data_visualizer/public/application/common/components/experimental_badge/experimental_badge.tsx index a067cb198914e..9c39ee54a2a86 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/experimental_badge/experimental_badge.tsx +++ b/x-pack/plugins/data_visualizer/public/application/common/components/experimental_badge/experimental_badge.tsx @@ -17,7 +17,7 @@ export const ExperimentalBadge: FC<{ tooltipContent: string }> = ({ tooltipConte className="experimental-badge" label={ } diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/experimental_badge/index.ts b/x-pack/plugins/data_visualizer/public/application/common/components/experimental_badge/index.ts similarity index 100% rename from x-pack/plugins/file_data_visualizer/public/application/components/experimental_badge/index.ts rename to x-pack/plugins/data_visualizer/public/application/common/components/experimental_badge/index.ts diff --git a/x-pack/plugins/ml/public/application/datavisualizer/index_based/components/field_count_panel/field_count_panel.tsx b/x-pack/plugins/data_visualizer/public/application/common/components/field_count_panel/field_count_panel.tsx similarity index 78% rename from x-pack/plugins/ml/public/application/datavisualizer/index_based/components/field_count_panel/field_count_panel.tsx rename to x-pack/plugins/data_visualizer/public/application/common/components/field_count_panel/field_count_panel.tsx index 9ff3d81fc3918..c79ed4ade7092 100644 --- a/x-pack/plugins/ml/public/application/datavisualizer/index_based/components/field_count_panel/field_count_panel.tsx +++ b/x-pack/plugins/data_visualizer/public/application/common/components/field_count_panel/field_count_panel.tsx @@ -8,14 +8,11 @@ import { EuiFlexGroup, EuiFlexItem, EuiSwitch } from '@elastic/eui'; import { FormattedMessage } from '@kbn/i18n/react'; import React, { FC } from 'react'; -import { - MetricFieldsCount, - TotalFieldsCount, -} from '../../../stats_table/components/field_count_stats'; import type { - TotalFieldsCountProps, MetricFieldsCountProps, -} from '../../../stats_table/components/field_count_stats'; + TotalFieldsCountProps, +} from '../stats_table/components/field_count_stats'; +import { MetricFieldsCount, TotalFieldsCount } from '../stats_table/components/field_count_stats'; interface Props extends TotalFieldsCountProps, MetricFieldsCountProps { showEmptyFields: boolean; @@ -32,16 +29,16 @@ export const FieldCountPanel: FC = ({ alignItems="center" gutterSize="xs" style={{ marginLeft: 4 }} - data-test-subj="mlDataVisualizerFieldCountPanel" + data-test-subj="dataVisualizerFieldCountPanel" > } diff --git a/x-pack/plugins/ml/public/application/datavisualizer/index_based/components/field_count_panel/index.ts b/x-pack/plugins/data_visualizer/public/application/common/components/field_count_panel/index.ts similarity index 100% rename from x-pack/plugins/ml/public/application/datavisualizer/index_based/components/field_count_panel/index.ts rename to x-pack/plugins/data_visualizer/public/application/common/components/field_count_panel/index.ts diff --git a/x-pack/plugins/ml/public/application/datavisualizer/index_based/components/field_data_row/action_menu/actions.ts b/x-pack/plugins/data_visualizer/public/application/common/components/field_data_row/action_menu/actions.ts similarity index 61% rename from x-pack/plugins/ml/public/application/datavisualizer/index_based/components/field_data_row/action_menu/actions.ts rename to x-pack/plugins/data_visualizer/public/application/common/components/field_data_row/action_menu/actions.ts index 57675927ce816..414c72c33f057 100644 --- a/x-pack/plugins/ml/public/application/datavisualizer/index_based/components/field_data_row/action_menu/actions.ts +++ b/x-pack/plugins/data_visualizer/public/application/common/components/field_data_row/action_menu/actions.ts @@ -8,28 +8,24 @@ import { i18n } from '@kbn/i18n'; import { Action } from '@elastic/eui/src/components/basic_table/action_types'; import { getCompatibleLensDataType, getLensAttributes } from './lens_utils'; -import type { CombinedQuery } from '../../../common'; -import type { IIndexPattern } from '../../../../../../../../../../src/plugins/data/common/index_patterns'; -import type { LensPublicStart } from '../../../../../../../../lens/public'; -import type { FieldVisConfig } from '../../../../stats_table/types'; - +import { IndexPattern } from '../../../../../../../../../src/plugins/data/common/index_patterns/index_patterns'; +import { CombinedQuery } from '../../../../index_data_visualizer/types/combined_query'; +import { FieldVisConfig } from '../../stats_table/types'; +import { LensPublicStart } from '../../../../../../../lens/public'; export function getActions( - indexPattern: IIndexPattern, + indexPattern: IndexPattern, lensPlugin: LensPublicStart, combinedQuery: CombinedQuery ): Array> { const canUseLensEditor = lensPlugin.canUseEditor(); return [ { - name: i18n.translate('xpack.ml.dataVisualizer.indexBasedDataGrid.exploreInLensTitle', { + name: i18n.translate('xpack.dataVisualizer.index.dataGrid.exploreInLensTitle', { + defaultMessage: 'Explore in Lens', + }), + description: i18n.translate('xpack.dataVisualizer.index.dataGrid.exploreInLensDescription', { defaultMessage: 'Explore in Lens', }), - description: i18n.translate( - 'xpack.ml.dataVisualizer.indexBasedDataGrid.exploreInLensDescription', - { - defaultMessage: 'Explore in Lens', - } - ), type: 'icon', icon: 'lensApp', available: (item: FieldVisConfig) => @@ -38,12 +34,12 @@ export function getActions( const lensAttributes = getLensAttributes(indexPattern, combinedQuery, item); if (lensAttributes) { lensPlugin.navigateToPrefilledEditor({ - id: `ml-dataVisualizer-${item.fieldName}`, + id: `dataVisualizer-${item.fieldName}`, attributes: lensAttributes, }); } }, - 'data-test-subj': 'mlActionButtonViewInLens', + 'data-test-subj': 'dataVisualizerActionViewInLensButton', }, ]; } diff --git a/x-pack/plugins/ml/public/application/datavisualizer/index_based/components/field_data_row/action_menu/index.ts b/x-pack/plugins/data_visualizer/public/application/common/components/field_data_row/action_menu/index.ts similarity index 100% rename from x-pack/plugins/ml/public/application/datavisualizer/index_based/components/field_data_row/action_menu/index.ts rename to x-pack/plugins/data_visualizer/public/application/common/components/field_data_row/action_menu/index.ts diff --git a/x-pack/plugins/ml/public/application/datavisualizer/index_based/components/field_data_row/action_menu/lens_utils.ts b/x-pack/plugins/data_visualizer/public/application/common/components/field_data_row/action_menu/lens_utils.ts similarity index 83% rename from x-pack/plugins/ml/public/application/datavisualizer/index_based/components/field_data_row/action_menu/lens_utils.ts rename to x-pack/plugins/data_visualizer/public/application/common/components/field_data_row/action_menu/lens_utils.ts index 9690fd1b6c473..4d90defc668a4 100644 --- a/x-pack/plugins/ml/public/application/datavisualizer/index_based/components/field_data_row/action_menu/lens_utils.ts +++ b/x-pack/plugins/data_visualizer/public/application/common/components/field_data_row/action_menu/lens_utils.ts @@ -6,25 +6,28 @@ */ import { i18n } from '@kbn/i18n'; -import { ML_JOB_FIELD_TYPES } from '../../../../../../../common/constants/field_types'; -import type { TypedLensByValueInput } from '../../../../../../../../lens/public'; -import type { FieldVisConfig } from '../../../../stats_table/types'; -import type { IndexPatternColumn, XYLayerConfig } from '../../../../../../../../lens/public'; -import type { CombinedQuery } from '../../../common'; -import type { IIndexPattern } from '../../../../../../../../../../src/plugins/data/common/index_patterns'; +import type { IndexPattern } from '../../../../../../../../../src/plugins/data/common/index_patterns/index_patterns'; +import type { CombinedQuery } from '../../../../index_data_visualizer/types/combined_query'; +import type { + IndexPatternColumn, + TypedLensByValueInput, + XYLayerConfig, +} from '../../../../../../../lens/public'; +import { FieldVisConfig } from '../../stats_table/types'; +import { JOB_FIELD_TYPES } from '../../../../../../common'; interface ColumnsAndLayer { columns: Record; layer: XYLayerConfig; } -const TOP_VALUES_LABEL = i18n.translate('xpack.ml.dataVisualizer.lensChart.topValuesLabel', { +const TOP_VALUES_LABEL = i18n.translate('xpack.dataVisualizer.index.lensChart.topValuesLabel', { defaultMessage: 'Top values', }); -const COUNT = i18n.translate('xpack.ml.dataVisualizer.lensChart.countLabel', { +const COUNT = i18n.translate('xpack.dataVisualizer.index.lensChart.countLabel', { defaultMessage: 'Count', }); -export function getNumberSettings(item: FieldVisConfig, defaultIndexPattern: IIndexPattern) { +export function getNumberSettings(item: FieldVisConfig, defaultIndexPattern: IndexPattern) { // if index has no timestamp field if (defaultIndexPattern.timeFieldName === undefined) { const columns: Record = { @@ -62,7 +65,7 @@ export function getNumberSettings(item: FieldVisConfig, defaultIndexPattern: IIn col2: { dataType: 'number', isBucketed: false, - label: i18n.translate('xpack.ml.dataVisualizer.lensChart.averageOfLabel', { + label: i18n.translate('xpack.dataVisualizer.index.lensChart.averageOfLabel', { defaultMessage: 'Average of {fieldName}', values: { fieldName: item.fieldName }, }), @@ -186,19 +189,19 @@ export function getBooleanSettings(item: FieldVisConfig) { export function getCompatibleLensDataType(type: FieldVisConfig['type']): string | undefined { let lensType: string | undefined; switch (type) { - case ML_JOB_FIELD_TYPES.KEYWORD: + case JOB_FIELD_TYPES.KEYWORD: lensType = 'string'; break; - case ML_JOB_FIELD_TYPES.DATE: + case JOB_FIELD_TYPES.DATE: lensType = 'date'; break; - case ML_JOB_FIELD_TYPES.NUMBER: + case JOB_FIELD_TYPES.NUMBER: lensType = 'number'; break; - case ML_JOB_FIELD_TYPES.IP: + case JOB_FIELD_TYPES.IP: lensType = 'ip'; break; - case ML_JOB_FIELD_TYPES.BOOLEAN: + case JOB_FIELD_TYPES.BOOLEAN: lensType = 'string'; break; default: @@ -210,20 +213,20 @@ export function getCompatibleLensDataType(type: FieldVisConfig['type']): string function getColumnsAndLayer( fieldType: FieldVisConfig['type'], item: FieldVisConfig, - defaultIndexPattern: IIndexPattern + defaultIndexPattern: IndexPattern ): ColumnsAndLayer | undefined { if (item.fieldName === undefined) return; - if (fieldType === ML_JOB_FIELD_TYPES.DATE) { + if (fieldType === JOB_FIELD_TYPES.DATE) { return getDateSettings(item); } - if (fieldType === ML_JOB_FIELD_TYPES.NUMBER) { + if (fieldType === JOB_FIELD_TYPES.NUMBER) { return getNumberSettings(item, defaultIndexPattern); } - if (fieldType === ML_JOB_FIELD_TYPES.IP || fieldType === ML_JOB_FIELD_TYPES.KEYWORD) { + if (fieldType === JOB_FIELD_TYPES.IP || fieldType === JOB_FIELD_TYPES.KEYWORD) { return getKeywordSettings(item); } - if (fieldType === ML_JOB_FIELD_TYPES.BOOLEAN) { + if (fieldType === JOB_FIELD_TYPES.BOOLEAN) { return getBooleanSettings(item); } } @@ -231,7 +234,7 @@ function getColumnsAndLayer( // currently only supports the following types: // 'document' | 'string' | 'number' | 'date' | 'boolean' | 'ip' export function getLensAttributes( - defaultIndexPattern: IIndexPattern | undefined, + defaultIndexPattern: IndexPattern | undefined, combinedQuery: CombinedQuery, item: FieldVisConfig ): TypedLensByValueInput['attributes'] | undefined { @@ -244,7 +247,7 @@ export function getLensAttributes( return { visualizationType: 'lnsXY', - title: i18n.translate('xpack.ml.dataVisualizer.lensChart.chartTitle', { + title: i18n.translate('xpack.dataVisualizer.index.lensChart.chartTitle', { defaultMessage: 'Lens for {fieldName}', values: { fieldName: item.fieldName }, }), diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/field_data_row/index.ts b/x-pack/plugins/data_visualizer/public/application/common/components/field_data_row/index.ts similarity index 100% rename from x-pack/plugins/file_data_visualizer/public/application/components/field_data_row/index.ts rename to x-pack/plugins/data_visualizer/public/application/common/components/field_data_row/index.ts diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/field_data_row/number_content_preview.tsx b/x-pack/plugins/data_visualizer/public/application/common/components/field_data_row/number_content_preview.tsx similarity index 79% rename from x-pack/plugins/file_data_visualizer/public/application/components/field_data_row/number_content_preview.tsx rename to x-pack/plugins/data_visualizer/public/application/common/components/field_data_row/number_content_preview.tsx index c02976cdb3853..08d2d42c6c027 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/field_data_row/number_content_preview.tsx +++ b/x-pack/plugins/data_visualizer/public/application/common/components/field_data_row/number_content_preview.tsx @@ -24,26 +24,20 @@ export const FileBasedNumberContentPreview = ({ config }: { config: FileBasedFie - + - + diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/field_names_filter/field_names_filter.tsx b/x-pack/plugins/data_visualizer/public/application/common/components/field_names_filter/field_names_filter.tsx similarity index 91% rename from x-pack/plugins/file_data_visualizer/public/application/components/field_names_filter/field_names_filter.tsx rename to x-pack/plugins/data_visualizer/public/application/common/components/field_names_filter/field_names_filter.tsx index 466722adc7179..88b4cd406b33c 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/field_names_filter/field_names_filter.tsx +++ b/x-pack/plugins/data_visualizer/public/application/common/components/field_names_filter/field_names_filter.tsx @@ -26,7 +26,7 @@ export const DataVisualizerFieldNamesFilter: FC = ({ }) => { const fieldNameTitle = useMemo( () => - i18n.translate('xpack.fileDataVisualizer.fieldNameSelect', { + i18n.translate('xpack.dataVisualizer.fieldNameSelect', { defaultMessage: 'Field name', }), [] @@ -42,7 +42,7 @@ export const DataVisualizerFieldNamesFilter: FC = ({ options={options} onChange={setVisibleFieldNames} checkedOptions={visibleFieldNames} - dataTestSubj={'mlDataVisualizerFieldNameSelect'} + dataTestSubj={'dataVisualizerFieldNameSelect'} /> ); }; diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/field_names_filter/index.ts b/x-pack/plugins/data_visualizer/public/application/common/components/field_names_filter/index.ts similarity index 100% rename from x-pack/plugins/file_data_visualizer/public/application/components/field_names_filter/index.ts rename to x-pack/plugins/data_visualizer/public/application/common/components/field_names_filter/index.ts diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/field_type_icon/__snapshots__/field_type_icon.test.tsx.snap b/x-pack/plugins/data_visualizer/public/application/common/components/field_type_icon/__snapshots__/field_type_icon.test.tsx.snap similarity index 100% rename from x-pack/plugins/file_data_visualizer/public/application/components/field_type_icon/__snapshots__/field_type_icon.test.tsx.snap rename to x-pack/plugins/data_visualizer/public/application/common/components/field_type_icon/__snapshots__/field_type_icon.test.tsx.snap diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/field_type_icon/field_type_icon.test.tsx b/x-pack/plugins/data_visualizer/public/application/common/components/field_type_icon/field_type_icon.test.tsx similarity index 96% rename from x-pack/plugins/file_data_visualizer/public/application/components/field_type_icon/field_type_icon.test.tsx rename to x-pack/plugins/data_visualizer/public/application/common/components/field_type_icon/field_type_icon.test.tsx index d1321ad8f9f4d..6b7c9eafc8c3e 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/field_type_icon/field_type_icon.test.tsx +++ b/x-pack/plugins/data_visualizer/public/application/common/components/field_type_icon/field_type_icon.test.tsx @@ -9,7 +9,7 @@ import React from 'react'; import { mount, shallow } from 'enzyme'; import { FieldTypeIcon } from './field_type_icon'; -import { JOB_FIELD_TYPES } from '../../../../common'; +import { JOB_FIELD_TYPES } from '../../../../../common'; describe('FieldTypeIcon', () => { test(`render component when type matches a field type`, () => { diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/field_type_icon/field_type_icon.tsx b/x-pack/plugins/data_visualizer/public/application/common/components/field_type_icon/field_type_icon.tsx similarity index 94% rename from x-pack/plugins/file_data_visualizer/public/application/components/field_type_icon/field_type_icon.tsx rename to x-pack/plugins/data_visualizer/public/application/common/components/field_type_icon/field_type_icon.tsx index 2dd7ff635bacd..50823006db3b6 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/field_type_icon/field_type_icon.tsx +++ b/x-pack/plugins/data_visualizer/public/application/common/components/field_type_icon/field_type_icon.tsx @@ -12,8 +12,8 @@ import { EuiToken, EuiToolTip } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import { getJobTypeAriaLabel } from '../../util/field_types_utils'; -import { JOB_FIELD_TYPES } from '../../../../common'; -import type { JobFieldType } from '../../../../common'; +import { JOB_FIELD_TYPES } from '../../../../../common'; +import type { JobFieldType } from '../../../../../common'; interface FieldTypeIconProps { tooltipEnabled: boolean; @@ -91,7 +91,7 @@ export const FieldTypeIcon: FC = ({ return ( = ({ }) => { const fieldNameTitle = useMemo( () => - i18n.translate('xpack.fileDataVisualizer.fieldTypeSelect', { + i18n.translate('xpack.dataVisualizer.fieldTypeSelect', { defaultMessage: 'Field type', }), [] @@ -87,7 +87,7 @@ export const DataVisualizerFieldTypesFilter: FC = ({ options={options} onChange={setVisibleFieldTypes} checkedOptions={visibleFieldTypes} - dataTestSubj={'mlDataVisualizerFieldTypeSelect'} + dataTestSubj={'dataVisualizerFieldTypeSelect'} /> ); }; diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/field_types_filter/index.ts b/x-pack/plugins/data_visualizer/public/application/common/components/field_types_filter/index.ts similarity index 100% rename from x-pack/plugins/file_data_visualizer/public/application/components/field_types_filter/index.ts rename to x-pack/plugins/data_visualizer/public/application/common/components/field_types_filter/index.ts diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/fields_stats_grid/create_fields.ts b/x-pack/plugins/data_visualizer/public/application/common/components/fields_stats_grid/create_fields.ts similarity index 96% rename from x-pack/plugins/file_data_visualizer/public/application/components/fields_stats_grid/create_fields.ts rename to x-pack/plugins/data_visualizer/public/application/common/components/fields_stats_grid/create_fields.ts index f45071d6e96b5..f80ccd42919e2 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/fields_stats_grid/create_fields.ts +++ b/x-pack/plugins/data_visualizer/public/application/common/components/fields_stats_grid/create_fields.ts @@ -5,10 +5,10 @@ * 2.0. */ -import { FindFileStructureResponse } from '../../../../../file_upload/common'; +import { FindFileStructureResponse } from '../../../../../../file_upload/common'; import { getFieldNames, getSupportedFieldType } from './get_field_names'; import { FileBasedFieldVisConfig } from '../stats_table/types'; -import { JOB_FIELD_TYPES } from '../../../../common'; +import { JOB_FIELD_TYPES } from '../../../../../common'; import { roundToDecimalPlace } from '../utils'; export function createFields(results: FindFileStructureResponse) { diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/fields_stats_grid/fields_stats_grid.tsx b/x-pack/plugins/data_visualizer/public/application/common/components/fields_stats_grid/fields_stats_grid.tsx similarity index 93% rename from x-pack/plugins/file_data_visualizer/public/application/components/fields_stats_grid/fields_stats_grid.tsx rename to x-pack/plugins/data_visualizer/public/application/common/components/fields_stats_grid/fields_stats_grid.tsx index 3b5b1bbf81dba..f1c164768d6e7 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/fields_stats_grid/fields_stats_grid.tsx +++ b/x-pack/plugins/data_visualizer/public/application/common/components/fields_stats_grid/fields_stats_grid.tsx @@ -7,8 +7,8 @@ import React, { useMemo, FC, useState } from 'react'; import { EuiFlexGroup, EuiSpacer } from '@elastic/eui'; -import type { FindFileStructureResponse } from '../../../../../file_upload/common'; -import type { DataVisualizerTableState } from '../../../../common'; +import type { FindFileStructureResponse } from '../../../../../../file_upload/common'; +import type { DataVisualizerTableState } from '../../../../../common'; import { DataVisualizerTable, ItemIdToExpandedRowMap } from '../stats_table'; import type { FileBasedFieldVisConfig } from '../stats_table/types/field_vis_config'; import { FileBasedDataVisualizerExpandedRow } from '../expanded_row'; @@ -85,14 +85,14 @@ export const FieldsStatsGrid: FC = ({ results }) => { alignItems="center" gutterSize="xs" style={{ marginLeft: 4 }} - data-test-subj="mlDataVisualizerFieldCountPanel" + data-test-subj="dataVisualizerFieldCountPanel" > '`]; diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/filebeat_config_flyout/filebeat_config_flyout.tsx b/x-pack/plugins/data_visualizer/public/application/common/components/filebeat_config_flyout/filebeat_config_flyout.tsx similarity index 84% rename from x-pack/plugins/file_data_visualizer/public/application/components/filebeat_config_flyout/filebeat_config_flyout.tsx rename to x-pack/plugins/data_visualizer/public/application/common/components/filebeat_config_flyout/filebeat_config_flyout.tsx index c2b7e18059769..238cdcc2f8d9e 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/filebeat_config_flyout/filebeat_config_flyout.tsx +++ b/x-pack/plugins/data_visualizer/public/application/common/components/filebeat_config_flyout/filebeat_config_flyout.tsx @@ -22,8 +22,8 @@ import { EuiCopy, } from '@elastic/eui'; import { createFilebeatConfig } from './filebeat_config'; -import { useFileDataVisualizerKibana } from '../../kibana_context'; // copy context? -import { FindFileStructureResponse } from '../../../../../file_upload/common'; +import { useDataVisualizerKibana } from '../../../kibana_context'; // copy context? +import { FindFileStructureResponse } from '../../../../../../file_upload/common'; export enum EDITOR_MODE { HIDDEN, @@ -48,7 +48,7 @@ export const FilebeatConfigFlyout: FC = ({ const [username, setUsername] = useState(null); const { services: { security }, - } = useFileDataVisualizerKibana(); + } = useDataVisualizerKibana(); useEffect(() => { if (security !== undefined) { @@ -75,7 +75,7 @@ export const FilebeatConfigFlyout: FC = ({ @@ -85,7 +85,7 @@ export const FilebeatConfigFlyout: FC = ({ {(copy) => ( @@ -108,7 +108,7 @@ const Contents: FC<{
@@ -116,14 +116,14 @@ const Contents: FC<{

{index} }} />

filebeat.yml }} /> @@ -137,7 +137,7 @@ const Contents: FC<{

{username === null ? ( {''}, @@ -145,7 +145,7 @@ const Contents: FC<{ /> ) : ( {username}, diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/filebeat_config_flyout/index.ts b/x-pack/plugins/data_visualizer/public/application/common/components/filebeat_config_flyout/index.ts similarity index 100% rename from x-pack/plugins/file_data_visualizer/public/application/components/filebeat_config_flyout/index.ts rename to x-pack/plugins/data_visualizer/public/application/common/components/filebeat_config_flyout/index.ts diff --git a/x-pack/plugins/data_visualizer/public/application/common/components/help_menu/help_menu.tsx b/x-pack/plugins/data_visualizer/public/application/common/components/help_menu/help_menu.tsx new file mode 100644 index 0000000000000..9aa19b511b79a --- /dev/null +++ b/x-pack/plugins/data_visualizer/public/application/common/components/help_menu/help_menu.tsx @@ -0,0 +1,37 @@ +/* + * 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, { FC, useEffect } from 'react'; +import { i18n } from '@kbn/i18n'; +import { useDataVisualizerKibana } from '../../../kibana_context'; + +interface HelpMenuProps { + docLink: string; +} + +// Component for adding a documentation link to the help menu +export const HelpMenu: FC = React.memo(({ docLink }) => { + const { chrome } = useDataVisualizerKibana().services; + + useEffect(() => { + chrome.setHelpExtension({ + appName: i18n.translate('xpack.dataVisualizer.chrome.help.appName', { + defaultMessage: 'Data Visualizer', + }), + links: [ + { + href: docLink, + linkType: 'documentation', + }, + ], + }); + }, [chrome, docLink]); + + return null; +}); + +HelpMenu.displayName = 'HelpMenu'; diff --git a/x-pack/plugins/data_visualizer/public/application/common/components/help_menu/index.tsx b/x-pack/plugins/data_visualizer/public/application/common/components/help_menu/index.tsx new file mode 100644 index 0000000000000..dd4339173ffd4 --- /dev/null +++ b/x-pack/plugins/data_visualizer/public/application/common/components/help_menu/index.tsx @@ -0,0 +1,8 @@ +/* + * 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. + */ + +export { HelpMenu } from './help_menu'; diff --git a/x-pack/plugins/ml/public/application/datavisualizer/index_based/components/field_data_row/top_values/index.ts b/x-pack/plugins/data_visualizer/public/application/common/components/link_card/index.ts similarity index 85% rename from x-pack/plugins/ml/public/application/datavisualizer/index_based/components/field_data_row/top_values/index.ts rename to x-pack/plugins/data_visualizer/public/application/common/components/link_card/index.ts index c006b37fe2794..3a046defde582 100644 --- a/x-pack/plugins/ml/public/application/datavisualizer/index_based/components/field_data_row/top_values/index.ts +++ b/x-pack/plugins/data_visualizer/public/application/common/components/link_card/index.ts @@ -5,4 +5,4 @@ * 2.0. */ -export { TopValues } from './top_values'; +export { LinkCard } from './link_card'; diff --git a/x-pack/plugins/data_visualizer/public/application/common/components/link_card/link_card.tsx b/x-pack/plugins/data_visualizer/public/application/common/components/link_card/link_card.tsx new file mode 100644 index 0000000000000..4076169b9e1fe --- /dev/null +++ b/x-pack/plugins/data_visualizer/public/application/common/components/link_card/link_card.tsx @@ -0,0 +1,81 @@ +/* + * 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, { FC, ReactElement } from 'react'; + +import { + EuiIcon, + IconType, + EuiText, + EuiTitle, + EuiFlexItem, + EuiFlexGroup, + EuiPanel, + EuiLink, +} from '@elastic/eui'; + +interface Props { + icon: IconType | ReactElement; + iconAreaLabel?: string; + title: any; + description: any; + href?: string; + onClick?: () => void; + isDisabled?: boolean; + 'data-test-subj'?: string; +} + +// Component for rendering a card which links to the Create Job page, displaying an +// icon, card title, description and link. +export const LinkCard: FC = ({ + icon, + iconAreaLabel, + title, + description, + onClick, + href, + isDisabled, + 'data-test-subj': dateTestSubj, +}) => { + const linkHrefAndOnClickProps = { + ...(href ? { href } : {}), + ...(onClick ? { onClick } : {}), + }; + return ( + + + + + {typeof icon === 'string' ? ( + + ) : ( + icon + )} + + + +

{title}

+
+ +

{description}

+
+
+
+ + + ); +}; diff --git a/x-pack/plugins/ml/public/application/datavisualizer/index_based/components/field_data_row/loading_indicator/index.ts b/x-pack/plugins/data_visualizer/public/application/common/components/loading_indicator/index.ts similarity index 100% rename from x-pack/plugins/ml/public/application/datavisualizer/index_based/components/field_data_row/loading_indicator/index.ts rename to x-pack/plugins/data_visualizer/public/application/common/components/loading_indicator/index.ts diff --git a/x-pack/plugins/ml/public/application/datavisualizer/index_based/components/field_data_row/loading_indicator/loading_indicator.tsx b/x-pack/plugins/data_visualizer/public/application/common/components/loading_indicator/loading_indicator.tsx similarity index 86% rename from x-pack/plugins/ml/public/application/datavisualizer/index_based/components/field_data_row/loading_indicator/loading_indicator.tsx rename to x-pack/plugins/data_visualizer/public/application/common/components/loading_indicator/loading_indicator.tsx index 846bb518b6656..07733aaa54cc8 100644 --- a/x-pack/plugins/ml/public/application/datavisualizer/index_based/components/field_data_row/loading_indicator/loading_indicator.tsx +++ b/x-pack/plugins/data_visualizer/public/application/common/components/loading_indicator/loading_indicator.tsx @@ -10,7 +10,6 @@ import React, { FC, Fragment } from 'react'; import { EuiFlexGroup, EuiFlexItem, EuiLoadingSpinner, EuiSpacer, EuiText } from '@elastic/eui'; import { FormattedMessage } from '@kbn/i18n/react'; - export const LoadingIndicator: FC = () => ( @@ -22,7 +21,10 @@ export const LoadingIndicator: FC = () => ( - + diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/multi_select_picker/index.ts b/x-pack/plugins/data_visualizer/public/application/common/components/multi_select_picker/index.ts similarity index 100% rename from x-pack/plugins/file_data_visualizer/public/application/components/multi_select_picker/index.ts rename to x-pack/plugins/data_visualizer/public/application/common/components/multi_select_picker/index.ts diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/multi_select_picker/multi_select_picker.tsx b/x-pack/plugins/data_visualizer/public/application/common/components/multi_select_picker/multi_select_picker.tsx similarity index 98% rename from x-pack/plugins/file_data_visualizer/public/application/components/multi_select_picker/multi_select_picker.tsx rename to x-pack/plugins/data_visualizer/public/application/common/components/multi_select_picker/multi_select_picker.tsx index 2093b61a7ef4d..caa58009fda5d 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/multi_select_picker/multi_select_picker.tsx +++ b/x-pack/plugins/data_visualizer/public/application/common/components/multi_select_picker/multi_select_picker.tsx @@ -32,7 +32,7 @@ const NoFilterItems = () => {

diff --git a/x-pack/plugins/file_data_visualizer/public/lazy_load_bundle/lazy/index.ts b/x-pack/plugins/data_visualizer/public/application/common/components/not_in_docs_content/index.ts similarity index 81% rename from x-pack/plugins/file_data_visualizer/public/lazy_load_bundle/lazy/index.ts rename to x-pack/plugins/data_visualizer/public/application/common/components/not_in_docs_content/index.ts index 4229b95f3aaad..0c5e54b846bb8 100644 --- a/x-pack/plugins/file_data_visualizer/public/lazy_load_bundle/lazy/index.ts +++ b/x-pack/plugins/data_visualizer/public/application/common/components/not_in_docs_content/index.ts @@ -5,4 +5,4 @@ * 2.0. */ -export { FileDataVisualizer } from '../../application'; +export { NotInDocsContent } from './not_in_docs_context'; diff --git a/x-pack/plugins/ml/public/application/datavisualizer/index_based/components/field_data_row/content_types/not_in_docs_content.tsx b/x-pack/plugins/data_visualizer/public/application/common/components/not_in_docs_content/not_in_docs_context.tsx similarity index 92% rename from x-pack/plugins/ml/public/application/datavisualizer/index_based/components/field_data_row/content_types/not_in_docs_content.tsx rename to x-pack/plugins/data_visualizer/public/application/common/components/not_in_docs_content/not_in_docs_context.tsx index e3bb4323ce6a8..e4fd3b96405df 100644 --- a/x-pack/plugins/ml/public/application/datavisualizer/index_based/components/field_data_row/content_types/not_in_docs_content.tsx +++ b/x-pack/plugins/data_visualizer/public/application/common/components/not_in_docs_content/not_in_docs_context.tsx @@ -20,7 +20,7 @@ export const NotInDocsContent: FC = () => ( diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/results_links/index.ts b/x-pack/plugins/data_visualizer/public/application/common/components/results_links/index.ts similarity index 100% rename from x-pack/plugins/file_data_visualizer/public/application/components/results_links/index.ts rename to x-pack/plugins/data_visualizer/public/application/common/components/results_links/index.ts diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/results_links/results_links.tsx b/x-pack/plugins/data_visualizer/public/application/common/components/results_links/results_links.tsx similarity index 90% rename from x-pack/plugins/file_data_visualizer/public/application/components/results_links/results_links.tsx rename to x-pack/plugins/data_visualizer/public/application/common/components/results_links/results_links.tsx index db9fa8d8d51d9..a674446397db9 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/results_links/results_links.tsx +++ b/x-pack/plugins/data_visualizer/public/application/common/components/results_links/results_links.tsx @@ -12,11 +12,11 @@ import { EuiFlexGroup, EuiFlexItem, EuiCard, EuiIcon } from '@elastic/eui'; import { DISCOVER_APP_URL_GENERATOR, DiscoverUrlGeneratorState, -} from '../../../../../../../src/plugins/discover/public'; -import { TimeRange, RefreshInterval } from '../../../../../../../src/plugins/data/public'; -import { FindFileStructureResponse } from '../../../../../file_upload/common'; -import type { FileUploadPluginStart } from '../../../../../file_upload/public'; -import { useFileDataVisualizerKibana } from '../../kibana_context'; +} from '../../../../../../../../src/plugins/discover/public'; +import { TimeRange, RefreshInterval } from '../../../../../../../../src/plugins/data/public'; +import { FindFileStructureResponse } from '../../../../../../file_upload/common'; +import type { FileUploadPluginStart } from '../../../../../../file_upload/public'; +import { useDataVisualizerKibana } from '../../../kibana_context'; interface Props { fieldStats: FindFileStructureResponse['field_stats']; @@ -44,7 +44,7 @@ export const ResultsLinks: FC = ({ }) => { const { services: { fileUpload }, - } = useFileDataVisualizerKibana(); + } = useDataVisualizerKibana(); const [duration, setDuration] = useState({ from: 'now-30m', @@ -63,7 +63,7 @@ export const ResultsLinks: FC = ({ urlGenerators: { getUrlGenerator }, }, }, - } = useFileDataVisualizerKibana(); + } = useDataVisualizerKibana(); useEffect(() => { let unmounted = false; @@ -176,7 +176,7 @@ export const ResultsLinks: FC = ({ icon={} title={ } @@ -192,7 +192,7 @@ export const ResultsLinks: FC = ({ icon={} title={ } @@ -208,7 +208,7 @@ export const ResultsLinks: FC = ({ icon={} title={ } @@ -223,7 +223,7 @@ export const ResultsLinks: FC = ({ data-test-subj="fileDataVisFilebeatConfigLink" title={ } diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/_field_data_row.scss b/x-pack/plugins/data_visualizer/public/application/common/components/stats_table/_field_data_row.scss similarity index 100% rename from x-pack/plugins/file_data_visualizer/public/application/components/stats_table/_field_data_row.scss rename to x-pack/plugins/data_visualizer/public/application/common/components/stats_table/_field_data_row.scss diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/_index.scss b/x-pack/plugins/data_visualizer/public/application/common/components/stats_table/_index.scss similarity index 100% rename from x-pack/plugins/file_data_visualizer/public/application/components/stats_table/_index.scss rename to x-pack/plugins/data_visualizer/public/application/common/components/stats_table/_index.scss diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/expanded_row_field_header/expanded_row_field_header.tsx b/x-pack/plugins/data_visualizer/public/application/common/components/stats_table/components/expanded_row_field_header/expanded_row_field_header.tsx similarity index 100% rename from x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/expanded_row_field_header/expanded_row_field_header.tsx rename to x-pack/plugins/data_visualizer/public/application/common/components/stats_table/components/expanded_row_field_header/expanded_row_field_header.tsx diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/expanded_row_field_header/index.ts b/x-pack/plugins/data_visualizer/public/application/common/components/stats_table/components/expanded_row_field_header/index.ts similarity index 100% rename from x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/expanded_row_field_header/index.ts rename to x-pack/plugins/data_visualizer/public/application/common/components/stats_table/components/expanded_row_field_header/index.ts diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_count_stats/_index.scss b/x-pack/plugins/data_visualizer/public/application/common/components/stats_table/components/field_count_stats/_index.scss similarity index 100% rename from x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_count_stats/_index.scss rename to x-pack/plugins/data_visualizer/public/application/common/components/stats_table/components/field_count_stats/_index.scss diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_count_stats/index.ts b/x-pack/plugins/data_visualizer/public/application/common/components/stats_table/components/field_count_stats/index.ts similarity index 100% rename from x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_count_stats/index.ts rename to x-pack/plugins/data_visualizer/public/application/common/components/stats_table/components/field_count_stats/index.ts diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_count_stats/metric_fields_count.tsx b/x-pack/plugins/data_visualizer/public/application/common/components/stats_table/components/field_count_stats/metric_fields_count.tsx similarity index 83% rename from x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_count_stats/metric_fields_count.tsx rename to x-pack/plugins/data_visualizer/public/application/common/components/stats_table/components/field_count_stats/metric_fields_count.tsx index 93582a7cef9ed..7996e6366c497 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_count_stats/metric_fields_count.tsx +++ b/x-pack/plugins/data_visualizer/public/application/common/components/stats_table/components/field_count_stats/metric_fields_count.tsx @@ -31,13 +31,13 @@ export const MetricFieldsCount: FC = ({ metricsStats }) gutterSize="s" alignItems="center" className="dataVisualizerFieldCountContainer" - data-test-subj="mlDataVisualizerMetricFieldsSummary" + data-test-subj="dataVisualizerMetricFieldsSummary" >
@@ -47,15 +47,15 @@ export const MetricFieldsCount: FC = ({ metricsStats }) {metricsStats.visibleMetricsCount}
- + diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_count_stats/total_fields_count.tsx b/x-pack/plugins/data_visualizer/public/application/common/components/stats_table/components/field_count_stats/total_fields_count.tsx similarity index 83% rename from x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_count_stats/total_fields_count.tsx rename to x-pack/plugins/data_visualizer/public/application/common/components/stats_table/components/field_count_stats/total_fields_count.tsx index 9d554c7025d80..8e9e3e59f1281 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_count_stats/total_fields_count.tsx +++ b/x-pack/plugins/data_visualizer/public/application/common/components/stats_table/components/field_count_stats/total_fields_count.tsx @@ -31,13 +31,13 @@ export const TotalFieldsCount: FC = ({ fieldsCountStats } gutterSize="s" alignItems="center" className="dataVisualizerFieldCountContainer" - data-test-subj="mlDataVisualizerFieldsSummary" + data-test-subj="dataVisualizerFieldsSummary" >
@@ -48,15 +48,15 @@ export const TotalFieldsCount: FC = ({ fieldsCountStats } {fieldsCountStats.visibleFieldsCount}
- + diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_expanded_row/_index.scss b/x-pack/plugins/data_visualizer/public/application/common/components/stats_table/components/field_data_expanded_row/_index.scss similarity index 100% rename from x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_expanded_row/_index.scss rename to x-pack/plugins/data_visualizer/public/application/common/components/stats_table/components/field_data_expanded_row/_index.scss diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_expanded_row/_number_content.scss b/x-pack/plugins/data_visualizer/public/application/common/components/stats_table/components/field_data_expanded_row/_number_content.scss similarity index 100% rename from x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_expanded_row/_number_content.scss rename to x-pack/plugins/data_visualizer/public/application/common/components/stats_table/components/field_data_expanded_row/_number_content.scss diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_expanded_row/boolean_content.tsx b/x-pack/plugins/data_visualizer/public/application/common/components/stats_table/components/field_data_expanded_row/boolean_content.tsx similarity index 90% rename from x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_expanded_row/boolean_content.tsx rename to x-pack/plugins/data_visualizer/public/application/common/components/stats_table/components/field_data_expanded_row/boolean_content.tsx index 7c9ddcdab29c8..2869b5030f81b 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_expanded_row/boolean_content.tsx +++ b/x-pack/plugins/data_visualizer/public/application/common/components/stats_table/components/field_data_expanded_row/boolean_content.tsx @@ -49,7 +49,7 @@ export const BooleanContent: FC = ({ config }) => { function: 'true', display: ( ), @@ -59,7 +59,7 @@ export const BooleanContent: FC = ({ config }) => { function: 'false', display: ( ), @@ -80,14 +80,14 @@ export const BooleanContent: FC = ({ config }) => { ]; const summaryTableTitle = i18n.translate( - 'xpack.fileDataVisualizer.fieldDataCardExpandedRow.booleanContent.summaryTableTitle', + 'xpack.dataVisualizer.dataGrid.fieldExpandedRow.booleanContent.summaryTableTitle', { defaultMessage: 'Summary', } ); return ( - + @@ -104,7 +104,7 @@ export const BooleanContent: FC = ({ config }) => { diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_expanded_row/choropleth_map.tsx b/x-pack/plugins/data_visualizer/public/application/common/components/stats_table/components/field_data_expanded_row/choropleth_map.tsx similarity index 88% rename from x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_expanded_row/choropleth_map.tsx rename to x-pack/plugins/data_visualizer/public/application/common/components/stats_table/components/field_data_expanded_row/choropleth_map.tsx index acbb77a7e0cac..6bd4de22beca4 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_expanded_row/choropleth_map.tsx +++ b/x-pack/plugins/data_visualizer/public/application/common/components/stats_table/components/field_data_expanded_row/choropleth_map.tsx @@ -14,11 +14,11 @@ import { SOURCE_TYPES, STYLE_TYPE, COLOR_MAP_TYPE, -} from '../../../../../../../maps/common/constants'; -import { EMSTermJoinConfig } from '../../../../../../../maps/public'; -import { FieldVisStats } from '../../types'; -import { VectorLayerDescriptor } from '../../../../../../../maps/common/descriptor_types'; +} from '../../../../../../../../maps/common/constants'; +import { EMSTermJoinConfig } from '../../../../../../../../maps/public'; +import { VectorLayerDescriptor } from '../../../../../../../../maps/common/descriptor_types'; import { EmbeddedMapComponent } from '../../../embedded_map'; +import { FieldVisStats } from '../../../../../../../common/types'; export const getChoroplethTopValuesLayer = ( fieldName: string, @@ -27,7 +27,7 @@ export const getChoroplethTopValuesLayer = ( ): VectorLayerDescriptor => { return { id: htmlIdGenerator()(), - label: i18n.translate('xpack.fileDataVisualizer.choroplethMap.topValuesCount', { + label: i18n.translate('xpack.dataVisualizer.choroplethMap.topValuesCount', { defaultMessage: 'Top values count for {fieldName}', values: { fieldName }, }), @@ -112,7 +112,7 @@ export const ChoroplethMap: FC = ({ stats, suggestion }) => { = ({ config }) => { const { earliest, latest } = stats; const summaryTableTitle = i18n.translate( - 'xpack.fileDataVisualizer.fieldDataCard.cardDate.summaryTableTitle', + 'xpack.dataVisualizer.dataGrid.field.cardDate.summaryTableTitle', { defaultMessage: 'Summary', } @@ -40,7 +40,7 @@ export const DateContent: FC = ({ config }) => { function: 'earliest', display: ( ), @@ -50,7 +50,7 @@ export const DateContent: FC = ({ config }) => { function: 'latest', display: ( ), @@ -71,13 +71,13 @@ export const DateContent: FC = ({ config }) => { ]; return ( - + {summaryTableTitle} className={'dataVisualizerSummaryTable'} - data-test-subj={'mlDateSummaryTable'} + data-test-subj={'dataVisualizerDateSummaryTable'} compressed items={summaryTableItems} columns={summaryTableColumns} diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_expanded_row/document_stats.tsx b/x-pack/plugins/data_visualizer/public/application/common/components/stats_table/components/field_data_expanded_row/document_stats.tsx similarity index 83% rename from x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_expanded_row/document_stats.tsx rename to x-pack/plugins/data_visualizer/public/application/common/components/stats_table/components/field_data_expanded_row/document_stats.tsx index f3ac0d94aa255..f4ed74193d90a 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_expanded_row/document_stats.tsx +++ b/x-pack/plugins/data_visualizer/public/application/common/components/stats_table/components/field_data_expanded_row/document_stats.tsx @@ -27,7 +27,7 @@ const metaTableColumns = [ ]; const metaTableTitle = i18n.translate( - 'xpack.fileDataVisualizer.fieldDataCardExpandedRow.documentStatsTable.metaTableTitle', + 'xpack.dataVisualizer.dataGrid.fieldExpandedRow.documentStatsTable.metaTableTitle', { defaultMessage: 'Documents stats', } @@ -47,7 +47,7 @@ export const DocumentStatsTable: FC = ({ config }) => { function: 'count', display: ( ), @@ -57,7 +57,7 @@ export const DocumentStatsTable: FC = ({ config }) => { function: 'percentage', display: ( ), @@ -67,7 +67,7 @@ export const DocumentStatsTable: FC = ({ config }) => { function: 'distinctValues', display: ( ), @@ -77,7 +77,7 @@ export const DocumentStatsTable: FC = ({ config }) => { return ( {metaTableTitle} diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_expanded_row/expanded_row_content.tsx b/x-pack/plugins/data_visualizer/public/application/common/components/stats_table/components/field_data_expanded_row/expanded_row_content.tsx similarity index 100% rename from x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_expanded_row/expanded_row_content.tsx rename to x-pack/plugins/data_visualizer/public/application/common/components/stats_table/components/field_data_expanded_row/expanded_row_content.tsx diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_expanded_row/index.ts b/x-pack/plugins/data_visualizer/public/application/common/components/stats_table/components/field_data_expanded_row/index.ts similarity index 100% rename from x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_expanded_row/index.ts rename to x-pack/plugins/data_visualizer/public/application/common/components/stats_table/components/field_data_expanded_row/index.ts diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_expanded_row/ip_content.tsx b/x-pack/plugins/data_visualizer/public/application/common/components/stats_table/components/field_data_expanded_row/ip_content.tsx similarity index 94% rename from x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_expanded_row/ip_content.tsx rename to x-pack/plugins/data_visualizer/public/application/common/components/stats_table/components/field_data_expanded_row/ip_content.tsx index 07adf3103b78e..77cf5fad5cca8 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_expanded_row/ip_content.tsx +++ b/x-pack/plugins/data_visualizer/public/application/common/components/stats_table/components/field_data_expanded_row/ip_content.tsx @@ -19,7 +19,7 @@ export const IpContent: FC = ({ config }) => { const fieldFormat = 'fieldFormat' in config ? config.fieldFormat : undefined; return ( - + diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_expanded_row/keyword_content.tsx b/x-pack/plugins/data_visualizer/public/application/common/components/stats_table/components/field_data_expanded_row/keyword_content.tsx similarity index 88% rename from x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_expanded_row/keyword_content.tsx rename to x-pack/plugins/data_visualizer/public/application/common/components/stats_table/components/field_data_expanded_row/keyword_content.tsx index 6448883bfce73..22fe8244ef760 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_expanded_row/keyword_content.tsx +++ b/x-pack/plugins/data_visualizer/public/application/common/components/stats_table/components/field_data_expanded_row/keyword_content.tsx @@ -8,8 +8,8 @@ import React, { FC, useCallback, useEffect, useState } from 'react'; import type { FieldDataRowProps } from '../../types/field_data_row'; import { TopValues } from '../../../top_values'; -import { EMSTermJoinConfig } from '../../../../../../../maps/public'; -import { useFileDataVisualizerKibana } from '../../../../kibana_context'; +import { EMSTermJoinConfig } from '../../../../../../../../maps/public'; +import { useDataVisualizerKibana } from '../../../../../kibana_context'; import { DocumentStatsTable } from './document_stats'; import { ExpandedRowContent } from './expanded_row_content'; import { ChoroplethMap } from './choropleth_map'; @@ -27,7 +27,7 @@ export const KeywordContent: FC = ({ config }) => { const fieldFormat = 'fieldFormat' in config ? config.fieldFormat : undefined; const { services: { maps: mapsPlugin }, - } = useFileDataVisualizerKibana(); + } = useDataVisualizerKibana(); const loadEMSTermSuggestions = useCallback(async () => { if (!mapsPlugin) return; @@ -50,7 +50,7 @@ export const KeywordContent: FC = ({ config }) => { ); return ( - + {EMSSuggestion && stats && } diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_expanded_row/number_content.tsx b/x-pack/plugins/data_visualizer/public/application/common/components/stats_table/components/field_data_expanded_row/number_content.tsx similarity index 85% rename from x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_expanded_row/number_content.tsx rename to x-pack/plugins/data_visualizer/public/application/common/components/stats_table/components/field_data_expanded_row/number_content.tsx index e83eecb64d02e..ef3ac5a267346 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_expanded_row/number_content.tsx +++ b/x-pack/plugins/data_visualizer/public/application/common/components/stats_table/components/field_data_expanded_row/number_content.tsx @@ -52,7 +52,7 @@ export const NumberContent: FC = ({ config }) => { function: 'min', display: ( ), @@ -62,7 +62,7 @@ export const NumberContent: FC = ({ config }) => { function: 'median', display: ( ), @@ -72,7 +72,7 @@ export const NumberContent: FC = ({ config }) => { function: 'max', display: ( ), @@ -93,13 +93,13 @@ export const NumberContent: FC = ({ config }) => { ]; const summaryTableTitle = i18n.translate( - 'xpack.fileDataVisualizer.fieldDataCardExpandedRow.numberContent.summaryTableTitle', + 'xpack.dataVisualizer.dataGrid.fieldExpandedRow.numberContent.summaryTableTitle', { defaultMessage: 'Summary', } ); return ( - + {summaryTableTitle} @@ -109,7 +109,7 @@ export const NumberContent: FC = ({ config }) => { items={summaryTableItems} columns={summaryTableColumns} tableCaption={summaryTableTitle} - data-test-subj={'mlNumberSummaryTable'} + data-test-subj={'dataVisualizerNumberSummaryTable'} /> @@ -117,11 +117,11 @@ export const NumberContent: FC = ({ config }) => { )} {distribution && ( - + @@ -138,7 +138,7 @@ export const NumberContent: FC = ({ config }) => { = ({ config }) => { const { stats } = config; if (stats === undefined) return null; return ( - + {Array.isArray(stats.examples) && ( diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_expanded_row/text_content.tsx b/x-pack/plugins/data_visualizer/public/application/common/components/stats_table/components/field_data_expanded_row/text_content.tsx similarity index 87% rename from x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_expanded_row/text_content.tsx rename to x-pack/plugins/data_visualizer/public/application/common/components/stats_table/components/field_data_expanded_row/text_content.tsx index b399f952b4d9d..700a715a33396 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_expanded_row/text_content.tsx +++ b/x-pack/plugins/data_visualizer/public/application/common/components/stats_table/components/field_data_expanded_row/text_content.tsx @@ -25,7 +25,7 @@ export const TextContent: FC = ({ config }) => { const numExamples = examples.length; return ( - + {numExamples > 0 && } {numExamples === 0 && ( @@ -33,7 +33,7 @@ export const TextContent: FC = ({ config }) => { = ({ config }) => { iconType="alert" > _source, @@ -51,7 +51,7 @@ export const TextContent: FC = ({ config }) => { copy_to, diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_row/_index.scss b/x-pack/plugins/data_visualizer/public/application/common/components/stats_table/components/field_data_row/_index.scss similarity index 100% rename from x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_row/_index.scss rename to x-pack/plugins/data_visualizer/public/application/common/components/stats_table/components/field_data_row/_index.scss diff --git a/x-pack/plugins/ml/public/application/datavisualizer/stats_table/components/field_data_row/boolean_content_preview.tsx b/x-pack/plugins/data_visualizer/public/application/common/components/stats_table/components/field_data_row/boolean_content_preview.tsx similarity index 77% rename from x-pack/plugins/ml/public/application/datavisualizer/stats_table/components/field_data_row/boolean_content_preview.tsx rename to x-pack/plugins/data_visualizer/public/application/common/components/stats_table/components/field_data_row/boolean_content_preview.tsx index 70adbbe85bc58..ceb2e6f241682 100644 --- a/x-pack/plugins/ml/public/application/datavisualizer/stats_table/components/field_data_row/boolean_content_preview.tsx +++ b/x-pack/plugins/data_visualizer/public/application/common/components/stats_table/components/field_data_row/boolean_content_preview.tsx @@ -6,11 +6,11 @@ */ import React, { FC, useMemo } from 'react'; -import { EuiDataGridColumn } from '@elastic/eui'; -import { OrdinalChartData } from '../../../../../../common/types/field_histograms'; -import { ColumnChart } from '../../../../components/data_grid/column_chart'; -import { FieldDataRowProps } from '../../types'; +import type { EuiDataGridColumn } from '@elastic/eui/src/components/datagrid/data_grid_types'; import { getTFPercentage } from '../../utils'; +import { ColumnChart } from './column_chart'; +import type { OrdinalChartData } from './field_histograms'; +import type { FieldDataRowProps } from '../../types'; export const BooleanContentPreview: FC = ({ config }) => { const chartData = useMemo(() => { @@ -29,7 +29,7 @@ export const BooleanContentPreview: FC = ({ config }) => { id: config.fieldName, schema: undefined, }; - const dataTestSubj = `mlDataGridChart-${config.fieldName}`; + const dataTestSubj = `dataVisualizerDataGridChart-${config.fieldName}`; return ( = ({ const defaultChartData: MetricDistributionChartData[] = []; const [distributionChartData, setDistributionChartData] = useState(defaultChartData); const [legendText, setLegendText] = useState<{ min: number; max: number } | undefined>(); - const dataTestSubj = `mlDataGridChart-${fieldName}`; + const dataTestSubj = `dataVisualizerDataGridChart-${fieldName}`; useEffect(() => { const chartData = buildChartDataFromStats(stats, METRIC_DISTRIBUTION_CHART_WIDTH); if ( diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_row/top_values_preview.tsx b/x-pack/plugins/data_visualizer/public/application/common/components/stats_table/components/field_data_row/top_values_preview.tsx similarity index 94% rename from x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_row/top_values_preview.tsx rename to x-pack/plugins/data_visualizer/public/application/common/components/stats_table/components/field_data_row/top_values_preview.tsx index 63b15fdf30b3b..4e5af381906bf 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_row/top_values_preview.tsx +++ b/x-pack/plugins/data_visualizer/public/application/common/components/stats_table/components/field_data_row/top_values_preview.tsx @@ -36,7 +36,7 @@ export const TopValuesPreview: FC = ({ config }) => { diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_row/use_column_chart.test.tsx b/x-pack/plugins/data_visualizer/public/application/common/components/stats_table/components/field_data_row/use_column_chart.test.tsx similarity index 98% rename from x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_row/use_column_chart.test.tsx rename to x-pack/plugins/data_visualizer/public/application/common/components/stats_table/components/field_data_row/use_column_chart.test.tsx index 2c92c366b2d73..aff4d6d62c6c8 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_row/use_column_chart.test.tsx +++ b/x-pack/plugins/data_visualizer/public/application/common/components/stats_table/components/field_data_row/use_column_chart.test.tsx @@ -10,7 +10,7 @@ import { render } from '@testing-library/react'; import { renderHook } from '@testing-library/react-hooks'; import '@testing-library/jest-dom/extend-expect'; -import { KBN_FIELD_TYPES } from '../../../../../../../../../src/plugins/data/public'; +import { KBN_FIELD_TYPES } from '../../../../../../../../../../src/plugins/data/public'; import { isNumericChartData, diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_row/use_column_chart.tsx b/x-pack/plugins/data_visualizer/public/application/common/components/stats_table/components/field_data_row/use_column_chart.tsx similarity index 92% rename from x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_row/use_column_chart.tsx rename to x-pack/plugins/data_visualizer/public/application/common/components/stats_table/components/field_data_row/use_column_chart.tsx index bd1df7f32c375..2bcf1854235d2 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_row/use_column_chart.tsx +++ b/x-pack/plugins/data_visualizer/public/application/common/components/stats_table/components/field_data_row/use_column_chart.tsx @@ -15,7 +15,7 @@ import { euiPaletteColorBlind, EuiDataGridColumn } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; -import { KBN_FIELD_TYPES } from '../../../../../../../../../src/plugins/data/public'; +import { KBN_FIELD_TYPES } from '../../../../../../../../../../src/plugins/data/public'; import { isNumericChartData, @@ -81,13 +81,13 @@ export const getLegendText = ( maxChartColumns = MAX_CHART_COLUMNS ): LegendText => { if (chartData.type === 'unsupported') { - return i18n.translate('xpack.fileDataVisualizer.dataGridChart.histogramNotAvailable', { + return i18n.translate('xpack.dataVisualizer.dataGridChart.histogramNotAvailable', { defaultMessage: 'Chart not supported.', }); } if (chartData.data.length === 0) { - return i18n.translate('xpack.fileDataVisualizer.dataGridChart.notEnoughData', { + return i18n.translate('xpack.dataVisualizer.dataGridChart.notEnoughData', { defaultMessage: `0 documents contain field.`, }); } @@ -106,14 +106,14 @@ export const getLegendText = ( } if (isOrdinalChartData(chartData) && chartData.cardinality <= maxChartColumns) { - return i18n.translate('xpack.fileDataVisualizer.dataGridChart.singleCategoryLegend', { + return i18n.translate('xpack.dataVisualizer.dataGridChart.singleCategoryLegend', { defaultMessage: `{cardinality, plural, one {# category} other {# categories}}`, values: { cardinality: chartData.cardinality }, }); } if (isOrdinalChartData(chartData) && chartData.cardinality > maxChartColumns) { - return i18n.translate('xpack.fileDataVisualizer.dataGridChart.topCategoriesLegend', { + return i18n.translate('xpack.dataVisualizer.dataGridChart.topCategoriesLegend', { defaultMessage: `top {maxChartColumns} of {cardinality} categories`, values: { cardinality: chartData.cardinality, maxChartColumns }, }); diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/metric_distribution_chart/index.ts b/x-pack/plugins/data_visualizer/public/application/common/components/stats_table/components/metric_distribution_chart/index.ts similarity index 100% rename from x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/metric_distribution_chart/index.ts rename to x-pack/plugins/data_visualizer/public/application/common/components/stats_table/components/metric_distribution_chart/index.ts diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/metric_distribution_chart/metric_distribution_chart.tsx b/x-pack/plugins/data_visualizer/public/application/common/components/stats_table/components/metric_distribution_chart/metric_distribution_chart.tsx similarity index 94% rename from x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/metric_distribution_chart/metric_distribution_chart.tsx rename to x-pack/plugins/data_visualizer/public/application/common/components/stats_table/components/metric_distribution_chart/metric_distribution_chart.tsx index caa560488d499..2c4739206d47f 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/metric_distribution_chart/metric_distribution_chart.tsx +++ b/x-pack/plugins/data_visualizer/public/application/common/components/stats_table/components/metric_distribution_chart/metric_distribution_chart.tsx @@ -58,7 +58,7 @@ export const MetricDistributionChart: FC = ({ // Ideally we wouldn't show these values at all in the tooltip, // but this is not yet possible with Elastic charts. const seriesName = i18n.translate( - 'xpack.fileDataVisualizer.fieldDataCard.metricDistributionChart.seriesName', + 'xpack.dataVisualizer.dataGrid.field.metricDistributionChart.seriesName', { defaultMessage: 'distribution', } @@ -82,7 +82,7 @@ export const MetricDistributionChart: FC = ({ }; return ( -
+
= ({
{chartPoint.dataMax > chartPoint.dataMin ? ( = ({ /> ) : ( ({ const expanderColumn: EuiTableComputedColumnType = { name: ( toggleExpandAll(!expandAll)} aria-label={ !expandAll - ? i18n.translate( - 'xpack.fileDataVisualizer.datavisualizer.dataGrid.expandDetailsForAllAriaLabel', - { - defaultMessage: 'Expand details for all fields', - } - ) - : i18n.translate( - 'xpack.fileDataVisualizer.datavisualizer.dataGrid.collapseDetailsForAllAriaLabel', - { - defaultMessage: 'Collapse details for all fields', - } - ) + ? i18n.translate('xpack.dataVisualizer.dataGrid.expandDetailsForAllAriaLabel', { + defaultMessage: 'Expand details for all fields', + }) + : i18n.translate('xpack.dataVisualizer.dataGrid.collapseDetailsForAllAriaLabel', { + defaultMessage: 'Collapse details for all fields', + }) } iconType={expandAll ? 'arrowUp' : 'arrowDown'} /> @@ -119,15 +115,15 @@ export const DataVisualizerTable = ({ const direction = expandedRowItemIds.includes(item.fieldName) ? 'arrowUp' : 'arrowDown'; return ( toggleDetails(item)} aria-label={ expandedRowItemIds.includes(item.fieldName) - ? i18n.translate('xpack.fileDataVisualizer.datavisualizer.dataGrid.rowCollapse', { + ? i18n.translate('xpack.dataVisualizer.dataGrid.rowCollapse', { defaultMessage: 'Hide details for {fieldName}', values: { fieldName: item.fieldName }, }) - : i18n.translate('xpack.fileDataVisualizer.datavisualizer.dataGrid.rowExpand', { + : i18n.translate('xpack.dataVisualizer.dataGrid.rowExpand', { defaultMessage: 'Show details for {fieldName}', values: { fieldName: item.fieldName }, }) @@ -136,14 +132,14 @@ export const DataVisualizerTable = ({ /> ); }, - 'data-test-subj': 'mlDataVisualizerTableColumnDetailsToggle', + 'data-test-subj': 'dataVisualizerTableColumnDetailsToggle', }; const baseColumns = [ expanderColumn, { field: 'type', - name: i18n.translate('xpack.fileDataVisualizer.datavisualizer.dataGrid.typeColumnName', { + name: i18n.translate('xpack.dataVisualizer.dataGrid.typeColumnName', { defaultMessage: 'Type', }), render: (fieldType: JobFieldType) => { @@ -152,11 +148,11 @@ export const DataVisualizerTable = ({ width: '75px', sortable: true, align: CENTER_ALIGNMENT as HorizontalAlignment, - 'data-test-subj': 'mlDataVisualizerTableColumnType', + 'data-test-subj': 'dataVisualizerTableColumnType', }, { field: 'fieldName', - name: i18n.translate('xpack.fileDataVisualizer.datavisualizer.dataGrid.nameColumnName', { + name: i18n.translate('xpack.dataVisualizer.dataGrid.nameColumnName', { defaultMessage: 'Name', }), sortable: true, @@ -167,53 +163,44 @@ export const DataVisualizerTable = ({ ), align: LEFT_ALIGNMENT as HorizontalAlignment, - 'data-test-subj': 'mlDataVisualizerTableColumnName', + 'data-test-subj': 'dataVisualizerTableColumnName', }, { field: 'docCount', - name: i18n.translate( - 'xpack.fileDataVisualizer.datavisualizer.dataGrid.documentsCountColumnName', - { - defaultMessage: 'Documents (%)', - } - ), + name: i18n.translate('xpack.dataVisualizer.dataGrid.documentsCountColumnName', { + defaultMessage: 'Documents (%)', + }), render: (value: number | undefined, item: DataVisualizerTableItem) => ( ), sortable: (item: DataVisualizerTableItem) => item?.stats?.count, align: LEFT_ALIGNMENT as HorizontalAlignment, - 'data-test-subj': 'mlDataVisualizerTableColumnDocumentsCount', + 'data-test-subj': 'dataVisualizerTableColumnDocumentsCount', }, { field: 'stats.cardinality', - name: i18n.translate( - 'xpack.fileDataVisualizer.datavisualizer.dataGrid.distinctValuesColumnName', - { - defaultMessage: 'Distinct values', - } - ), + name: i18n.translate('xpack.dataVisualizer.dataGrid.distinctValuesColumnName', { + defaultMessage: 'Distinct values', + }), render: (cardinality?: number) => , sortable: true, align: LEFT_ALIGNMENT as HorizontalAlignment, - 'data-test-subj': 'mlDataVisualizerTableColumnDistinctValues', + 'data-test-subj': 'dataVisualizerTableColumnDistinctValues', }, { name: (
- {i18n.translate( - 'xpack.fileDataVisualizer.datavisualizer.dataGrid.distributionsColumnName', - { - defaultMessage: 'Distributions', - } - )} + {i18n.translate('xpack.dataVisualizer.dataGrid.distributionsColumnName', { + defaultMessage: 'Distributions', + })} toggleShowDistribution()} aria-label={i18n.translate( - 'xpack.fileDataVisualizer.datavisualizer.dataGrid.showDistributionsAriaLabel', + 'xpack.dataVisualizer.dataGrid.showDistributionsAriaLabel', { defaultMessage: 'Show distributions', } @@ -245,7 +232,7 @@ export const DataVisualizerTable = ({ return null; }, align: LEFT_ALIGNMENT as HorizontalAlignment, - 'data-test-subj': 'mlDataVisualizerTableColumnDistribution', + 'data-test-subj': 'dataVisualizerTableColumnDistribution', }, ]; return extendedColumns ? [...baseColumns, ...extendedColumns] : baseColumns; @@ -262,7 +249,7 @@ export const DataVisualizerTable = ({ }, [expandAll, items, expandedRowItemIds]); return ( - + className={'dataVisualizer'} items={items} @@ -274,9 +261,9 @@ export const DataVisualizerTable = ({ itemIdToExpandedRowMap={itemIdToExpandedRowMap} isSelectable={false} onTableChange={onTableChange} - data-test-subj={'mlDataVisualizerTable'} + data-test-subj={'dataVisualizerTable'} rowProps={(item) => ({ - 'data-test-subj': `mlDataVisualizerRow row-${item.fieldName}`, + 'data-test-subj': `dataVisualizerRow row-${item.fieldName}`, })} /> diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/hooks/color_range_legend.tsx b/x-pack/plugins/data_visualizer/public/application/common/components/stats_table/hooks/color_range_legend.tsx similarity index 100% rename from x-pack/plugins/file_data_visualizer/public/application/components/stats_table/hooks/color_range_legend.tsx rename to x-pack/plugins/data_visualizer/public/application/common/components/stats_table/hooks/color_range_legend.tsx diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/hooks/index.ts b/x-pack/plugins/data_visualizer/public/application/common/components/stats_table/hooks/index.ts similarity index 100% rename from x-pack/plugins/file_data_visualizer/public/application/components/stats_table/hooks/index.ts rename to x-pack/plugins/data_visualizer/public/application/common/components/stats_table/hooks/index.ts diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/hooks/use_color_range.test.ts b/x-pack/plugins/data_visualizer/public/application/common/components/stats_table/hooks/use_color_range.test.ts similarity index 100% rename from x-pack/plugins/file_data_visualizer/public/application/components/stats_table/hooks/use_color_range.test.ts rename to x-pack/plugins/data_visualizer/public/application/common/components/stats_table/hooks/use_color_range.test.ts diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/hooks/use_color_range.ts b/x-pack/plugins/data_visualizer/public/application/common/components/stats_table/hooks/use_color_range.ts similarity index 82% rename from x-pack/plugins/file_data_visualizer/public/application/components/stats_table/hooks/use_color_range.ts rename to x-pack/plugins/data_visualizer/public/application/common/components/stats_table/hooks/use_color_range.ts index e24134507e3a9..b1d26a5437b44 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/hooks/use_color_range.ts +++ b/x-pack/plugins/data_visualizer/public/application/common/components/stats_table/hooks/use_color_range.ts @@ -12,7 +12,7 @@ import euiThemeDark from '@elastic/eui/dist/eui_theme_dark.json'; import { i18n } from '@kbn/i18n'; -import { useFileDataVisualizerKibana } from '../../../kibana_context'; +import { useDataVisualizerKibana } from '../../../../kibana_context'; /** * Custom color scale factory that takes the amount of feature influencers @@ -51,22 +51,19 @@ export enum COLOR_RANGE_SCALE { export const colorRangeScaleOptions = [ { value: COLOR_RANGE_SCALE.LINEAR, - text: i18n.translate('xpack.fileDataVisualizer.components.colorRangeLegend.linearScaleLabel', { + text: i18n.translate('xpack.dataVisualizer.components.colorRangeLegend.linearScaleLabel', { defaultMessage: 'Linear', }), }, { value: COLOR_RANGE_SCALE.INFLUENCER, - text: i18n.translate( - 'xpack.fileDataVisualizer.components.colorRangeLegend.influencerScaleLabel', - { - defaultMessage: 'Influencer custom scale', - } - ), + text: i18n.translate('xpack.dataVisualizer.components.colorRangeLegend.influencerScaleLabel', { + defaultMessage: 'Influencer custom scale', + }), }, { value: COLOR_RANGE_SCALE.SQRT, - text: i18n.translate('xpack.fileDataVisualizer.components.colorRangeLegend.sqrtScaleLabel', { + text: i18n.translate('xpack.dataVisualizer.components.colorRangeLegend.sqrtScaleLabel', { defaultMessage: 'Sqrt', }), }, @@ -86,26 +83,20 @@ export enum COLOR_RANGE { export const colorRangeOptions = [ { value: COLOR_RANGE.BLUE, - text: i18n.translate( - 'xpack.fileDataVisualizer.components.colorRangeLegend.blueColorRangeLabel', - { - defaultMessage: 'Blue', - } - ), + text: i18n.translate('xpack.dataVisualizer.components.colorRangeLegend.blueColorRangeLabel', { + defaultMessage: 'Blue', + }), }, { value: COLOR_RANGE.RED, - text: i18n.translate( - 'xpack.fileDataVisualizer.components.colorRangeLegend.redColorRangeLabel', - { - defaultMessage: 'Red', - } - ), + text: i18n.translate('xpack.dataVisualizer.components.colorRangeLegend.redColorRangeLabel', { + defaultMessage: 'Red', + }), }, { value: COLOR_RANGE.RED_GREEN, text: i18n.translate( - 'xpack.fileDataVisualizer.components.colorRangeLegend.redGreenColorRangeLabel', + 'xpack.dataVisualizer.components.colorRangeLegend.redGreenColorRangeLabel', { defaultMessage: 'Red - Green', } @@ -114,7 +105,7 @@ export const colorRangeOptions = [ { value: COLOR_RANGE.GREEN_RED, text: i18n.translate( - 'xpack.fileDataVisualizer.components.colorRangeLegend.greenRedColorRangeLabel', + 'xpack.dataVisualizer.components.colorRangeLegend.greenRedColorRangeLabel', { defaultMessage: 'Green - Red', } @@ -123,7 +114,7 @@ export const colorRangeOptions = [ { value: COLOR_RANGE.YELLOW_GREEN_BLUE, text: i18n.translate( - 'xpack.fileDataVisualizer.components.colorRangeLegend.yellowGreenBlueColorRangeLabel', + 'xpack.dataVisualizer.components.colorRangeLegend.yellowGreenBlueColorRangeLabel', { defaultMessage: 'Yellow - Green - Blue', } @@ -211,7 +202,7 @@ export type EuiThemeType = typeof euiThemeLight | typeof euiThemeDark; export function useCurrentEuiTheme() { const { services: { uiSettings }, - } = useFileDataVisualizerKibana(); + } = useDataVisualizerKibana(); return useMemo( () => ({ euiTheme: uiSettings.get('theme:darkMode') ? euiThemeDark : euiThemeLight }), [uiSettings] diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/hooks/use_data_viz_chart_theme.ts b/x-pack/plugins/data_visualizer/public/application/common/components/stats_table/hooks/use_data_viz_chart_theme.ts similarity index 100% rename from x-pack/plugins/file_data_visualizer/public/application/components/stats_table/hooks/use_data_viz_chart_theme.ts rename to x-pack/plugins/data_visualizer/public/application/common/components/stats_table/hooks/use_data_viz_chart_theme.ts diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/index.ts b/x-pack/plugins/data_visualizer/public/application/common/components/stats_table/index.ts similarity index 100% rename from x-pack/plugins/file_data_visualizer/public/application/components/stats_table/index.ts rename to x-pack/plugins/data_visualizer/public/application/common/components/stats_table/index.ts diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/types/field_data_row.ts b/x-pack/plugins/data_visualizer/public/application/common/components/stats_table/types/field_data_row.ts similarity index 100% rename from x-pack/plugins/file_data_visualizer/public/application/components/stats_table/types/field_data_row.ts rename to x-pack/plugins/data_visualizer/public/application/common/components/stats_table/types/field_data_row.ts diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/types/field_vis_config.ts b/x-pack/plugins/data_visualizer/public/application/common/components/stats_table/types/field_vis_config.ts similarity index 62% rename from x-pack/plugins/file_data_visualizer/public/application/components/stats_table/types/field_vis_config.ts rename to x-pack/plugins/data_visualizer/public/application/common/components/stats_table/types/field_vis_config.ts index e9ef0cd75e286..d58497f6cd7cc 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/types/field_vis_config.ts +++ b/x-pack/plugins/data_visualizer/public/application/common/components/stats_table/types/field_vis_config.ts @@ -5,13 +5,7 @@ * 2.0. */ -import { JobFieldType } from '../../../../../common'; - -export interface Percentile { - percent: number; - minValue: number; - maxValue: number; -} +import type { Percentile, JobFieldType, FieldVisStats } from '../../../../../../common/types'; export interface MetricFieldVisStats { avg?: number; @@ -25,40 +19,6 @@ export interface MetricFieldVisStats { min?: number; } -interface DocumentCountBuckets { - [key: string]: number; -} - -export interface FieldVisStats { - cardinality?: number; - count?: number; - sampleCount?: number; - trueCount?: number; - falseCount?: number; - earliest?: number; - latest?: number; - documentCounts?: { - buckets?: DocumentCountBuckets; - }; - avg?: number; - distribution?: { - percentiles: Percentile[]; - maxPercentile: number; - minPercentile: 0; - }; - fieldName?: string; - isTopValuesSampled?: boolean; - max?: number; - median?: number; - min?: number; - topValues?: Array<{ key: number | string; doc_count: number }>; - topValuesSampleSize?: number; - topValuesSamplerShardSize?: number; - examples?: Array; - timeRangeEarliest?: number; - timeRangeLatest?: number; -} - // The internal representation of the configuration used to build the visuals // which display the field information. export interface FieldVisConfig { diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/types/index.ts b/x-pack/plugins/data_visualizer/public/application/common/components/stats_table/types/index.ts similarity index 96% rename from x-pack/plugins/file_data_visualizer/public/application/components/stats_table/types/index.ts rename to x-pack/plugins/data_visualizer/public/application/common/components/stats_table/types/index.ts index 161829461aa26..171d029482e27 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/types/index.ts +++ b/x-pack/plugins/data_visualizer/public/application/common/components/stats_table/types/index.ts @@ -9,7 +9,6 @@ export { FieldDataRowProps } from './field_data_row'; export { FieldVisConfig, FileBasedFieldVisConfig, - FieldVisStats, MetricFieldVisStats, isFileBasedFieldVisConfig, isIndexBasedFieldVisConfig, diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/use_table_settings.ts b/x-pack/plugins/data_visualizer/public/application/common/components/stats_table/use_table_settings.ts similarity index 96% rename from x-pack/plugins/file_data_visualizer/public/application/components/stats_table/use_table_settings.ts rename to x-pack/plugins/data_visualizer/public/application/common/components/stats_table/use_table_settings.ts index e2ff18a8001aa..3fbf333bdc876 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/use_table_settings.ts +++ b/x-pack/plugins/data_visualizer/public/application/common/components/stats_table/use_table_settings.ts @@ -8,7 +8,7 @@ import { Direction, EuiBasicTableProps, Pagination, PropertySort } from '@elastic/eui'; import { useCallback, useMemo } from 'react'; -import { DataVisualizerTableState } from '../../../../common'; +import { DataVisualizerTableState } from '../../../../../common'; const PAGE_SIZE_OPTIONS = [10, 25, 50]; diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/utils.ts b/x-pack/plugins/data_visualizer/public/application/common/components/stats_table/utils.ts similarity index 100% rename from x-pack/plugins/file_data_visualizer/public/application/components/stats_table/utils.ts rename to x-pack/plugins/data_visualizer/public/application/common/components/stats_table/utils.ts diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/top_values/_top_values.scss b/x-pack/plugins/data_visualizer/public/application/common/components/top_values/_top_values.scss similarity index 100% rename from x-pack/plugins/file_data_visualizer/public/application/components/top_values/_top_values.scss rename to x-pack/plugins/data_visualizer/public/application/common/components/top_values/_top_values.scss diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/top_values/index.ts b/x-pack/plugins/data_visualizer/public/application/common/components/top_values/index.ts similarity index 100% rename from x-pack/plugins/file_data_visualizer/public/application/components/top_values/index.ts rename to x-pack/plugins/data_visualizer/public/application/common/components/top_values/index.ts diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/top_values/top_values.tsx b/x-pack/plugins/data_visualizer/public/application/common/components/top_values/top_values.tsx similarity index 87% rename from x-pack/plugins/file_data_visualizer/public/application/components/top_values/top_values.tsx rename to x-pack/plugins/data_visualizer/public/application/common/components/top_values/top_values.tsx index c1815fad41de8..7a20b054462a6 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/top_values/top_values.tsx +++ b/x-pack/plugins/data_visualizer/public/application/common/components/top_values/top_values.tsx @@ -20,7 +20,7 @@ import { FormattedMessage } from '@kbn/i18n/react'; import classNames from 'classnames'; import { roundToDecimalPlace, kibanaFieldFormat } from '../utils'; import { ExpandedRowFieldHeader } from '../stats_table/components/expanded_row_field_header'; -import { FieldVisStats } from '../stats_table/types'; +import { FieldVisStats } from '../../../../../common/types'; interface Props { stats: FieldVisStats | undefined; @@ -49,15 +49,18 @@ export const TopValues: FC = ({ stats, fieldFormat, barColor, compressed } = stats; const progressBarMax = isTopValuesSampled === true ? topValuesSampleSize : count; return ( - + -
+
{Array.isArray(topValues) && topValues.map((value) => ( @@ -75,7 +78,7 @@ export const TopValues: FC = ({ stats, fieldFormat, barColor, compressed - + = ({ stats, fieldFormat, barColor, compressed { diff --git a/x-pack/plugins/data_visualizer/public/application/common/util/field_types_utils.ts b/x-pack/plugins/data_visualizer/public/application/common/util/field_types_utils.ts new file mode 100644 index 0000000000000..e0a6c8ebf85c9 --- /dev/null +++ b/x-pack/plugins/data_visualizer/public/application/common/util/field_types_utils.ts @@ -0,0 +1,87 @@ +/* + * 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 { i18n } from '@kbn/i18n'; +import { JOB_FIELD_TYPES } from '../../../../common'; +import type { IndexPatternField } from '../../../../../../../src/plugins/data/common/index_patterns/fields'; +import { KBN_FIELD_TYPES } from '../../../../../../../src/plugins/data/common'; + +export const jobTypeAriaLabels = { + BOOLEAN: i18n.translate('xpack.dataVisualizer.fieldTypeIcon.booleanTypeAriaLabel', { + defaultMessage: 'boolean type', + }), + DATE: i18n.translate('xpack.dataVisualizer.fieldTypeIcon.dateTypeAriaLabel', { + defaultMessage: 'date type', + }), + GEO_POINT: i18n.translate('xpack.dataVisualizer.fieldTypeIcon.geoPointTypeAriaLabel', { + defaultMessage: '{geoPointParam} type', + values: { + geoPointParam: 'geo point', + }, + }), + IP: i18n.translate('xpack.dataVisualizer.fieldTypeIcon.ipTypeAriaLabel', { + defaultMessage: 'ip type', + }), + KEYWORD: i18n.translate('xpack.dataVisualizer.fieldTypeIcon.keywordTypeAriaLabel', { + defaultMessage: 'keyword type', + }), + NUMBER: i18n.translate('xpack.dataVisualizer.fieldTypeIcon.numberTypeAriaLabel', { + defaultMessage: 'number type', + }), + TEXT: i18n.translate('xpack.dataVisualizer.fieldTypeIcon.textTypeAriaLabel', { + defaultMessage: 'text type', + }), + UNKNOWN: i18n.translate('xpack.dataVisualizer.fieldTypeIcon.unknownTypeAriaLabel', { + defaultMessage: 'unknown type', + }), +}; + +export const getJobTypeAriaLabel = (type: string) => { + const requestedFieldType = Object.keys(JOB_FIELD_TYPES).find( + (k) => JOB_FIELD_TYPES[k as keyof typeof JOB_FIELD_TYPES] === type + ); + if (requestedFieldType === undefined) { + return null; + } + return jobTypeAriaLabels[requestedFieldType as keyof typeof jobTypeAriaLabels]; +}; + +// convert kibana types to ML Job types +// this is needed because kibana types only have string and not text and keyword. +// and we can't use ES_FIELD_TYPES because it has no NUMBER type +export function kbnTypeToJobType(field: IndexPatternField) { + // Return undefined if not one of the supported data visualizer field types. + let type; + switch (field.type) { + case KBN_FIELD_TYPES.STRING: + type = field.aggregatable ? JOB_FIELD_TYPES.KEYWORD : JOB_FIELD_TYPES.TEXT; + break; + case KBN_FIELD_TYPES.NUMBER: + type = JOB_FIELD_TYPES.NUMBER; + break; + case KBN_FIELD_TYPES.DATE: + type = JOB_FIELD_TYPES.DATE; + break; + case KBN_FIELD_TYPES.IP: + type = JOB_FIELD_TYPES.IP; + break; + case KBN_FIELD_TYPES.BOOLEAN: + type = JOB_FIELD_TYPES.BOOLEAN; + break; + case KBN_FIELD_TYPES.GEO_POINT: + type = JOB_FIELD_TYPES.GEO_POINT; + break; + case KBN_FIELD_TYPES.GEO_SHAPE: + type = JOB_FIELD_TYPES.GEO_SHAPE; + break; + + default: + break; + } + + return type; +} diff --git a/x-pack/plugins/file_data_visualizer/public/application/util/get_max_bytes.ts b/x-pack/plugins/data_visualizer/public/application/common/util/get_max_bytes.ts similarity index 89% rename from x-pack/plugins/file_data_visualizer/public/application/util/get_max_bytes.ts rename to x-pack/plugins/data_visualizer/public/application/common/util/get_max_bytes.ts index 821a94bf5166d..e4f8e69470c8b 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/util/get_max_bytes.ts +++ b/x-pack/plugins/data_visualizer/public/application/common/util/get_max_bytes.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { getPluginsStart } from '../../kibana_services'; +import { getPluginsStart } from '../../../kibana_services'; // expose the fileUpload plugin's getMaxBytesFormatted for use in ML // so ML doesn't need to depend on the fileUpload plugin for this one function diff --git a/x-pack/plugins/data_visualizer/public/application/common/util/parse_interval.test.ts b/x-pack/plugins/data_visualizer/public/application/common/util/parse_interval.test.ts new file mode 100644 index 0000000000000..a1608960a91bc --- /dev/null +++ b/x-pack/plugins/data_visualizer/public/application/common/util/parse_interval.test.ts @@ -0,0 +1,45 @@ +/* + * 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 { parseInterval } from './parse_interval'; + +describe('ML parse interval util', () => { + test('should correctly parse an interval containing a valid unit and value', () => { + expect(parseInterval('1d')!.as('d')).toBe(1); + expect(parseInterval('2y')!.as('y')).toBe(2); + expect(parseInterval('5M')!.as('M')).toBe(5); + expect(parseInterval('5m')!.as('m')).toBe(5); + expect(parseInterval('250ms')!.as('ms')).toBe(250); + expect(parseInterval('100s')!.as('s')).toBe(100); + expect(parseInterval('23d')!.as('d')).toBe(23); + expect(parseInterval('52w')!.as('w')).toBe(52); + expect(parseInterval('0s')!.as('s')).toBe(0); + expect(parseInterval('0s')!.as('h')).toBe(0); + }); + + test('should correctly handle zero value intervals', () => { + expect(parseInterval('0h')!.as('h')).toBe(0); + expect(parseInterval('0d')).toBe(null); + }); + + test('should return null for an invalid interval', () => { + expect(parseInterval('')).toBe(null); + expect(parseInterval('234asdf')).toBe(null); + expect(parseInterval('m')).toBe(null); + expect(parseInterval('1.5h')).toBe(null); + }); + + test('should correctly check for whether the interval units are valid Elasticsearch time units', () => { + expect(parseInterval('100s', true)!.as('s')).toBe(100); + expect(parseInterval('5m', true)!.as('m')).toBe(5); + expect(parseInterval('24h', true)!.as('h')).toBe(24); + expect(parseInterval('7d', true)!.as('d')).toBe(7); + expect(parseInterval('1w', true)).toBe(null); + expect(parseInterval('1M', true)).toBe(null); + expect(parseInterval('1y', true)).toBe(null); + }); +}); diff --git a/x-pack/plugins/data_visualizer/public/application/common/util/parse_interval.ts b/x-pack/plugins/data_visualizer/public/application/common/util/parse_interval.ts new file mode 100644 index 0000000000000..6ca280dc12ebd --- /dev/null +++ b/x-pack/plugins/data_visualizer/public/application/common/util/parse_interval.ts @@ -0,0 +1,65 @@ +/* + * 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 { duration, Duration, unitOfTime } from 'moment'; +import dateMath from '@elastic/datemath'; + +type SupportedUnits = unitOfTime.Base; + +// Assume interval is in the form (value)(unit), such as "1h" +const INTERVAL_STRING_RE = new RegExp('^([0-9]*)\\s*(' + dateMath.units.join('|') + ')$'); + +// moment.js is only designed to allow fractional values between 0 and 1 +// for units of hour or less. +const SUPPORT_ZERO_DURATION_UNITS: SupportedUnits[] = ['ms', 's', 'm', 'h']; + +// List of time units which are supported for use in Elasticsearch durations +// (such as anomaly detection job bucket spans) +// See https://www.elastic.co/guide/en/elasticsearch/reference/current/common-options.html#time-units +const SUPPORT_ES_DURATION_UNITS: SupportedUnits[] = ['ms', 's', 'm', 'h', 'd']; + +// Parses an interval String, such as 7d, 1h or 30m to a moment duration. +// Optionally carries out an additional check that the interval is supported as a +// time unit by Elasticsearch, as units greater than 'd' for example cannot be used +// for anomaly detection job bucket spans. +// Differs from the Kibana ui/utils/parse_interval in the following ways: +// 1. A value-less interval such as 'm' is not allowed - in line with the ML back-end +// not accepting such interval Strings for the bucket span of a job. +// 2. Zero length durations 0ms, 0s, 0m and 0h are accepted as-is. +// Note that when adding or subtracting fractional durations, moment is only designed +// to work with units less than 'day'. +// 3. Fractional intervals e.g. 1.5h or 4.5d are not allowed, in line with the behaviour +// of the Elasticsearch date histogram aggregation. +export function parseInterval( + interval: string | number, + checkValidEsUnit = false +): Duration | null { + const matches = String(interval).trim().match(INTERVAL_STRING_RE); + if (!Array.isArray(matches) || matches.length < 3) { + return null; + } + + try { + const value = parseInt(matches[1], 10); + const unit = matches[2] as SupportedUnits; + + // In line with moment.js, only allow zero value intervals when the unit is less than 'day'. + // And check for isNaN as e.g. valueless 'm' will pass the regex test, + // plus an optional check that the unit is not w/M/y which are not fully supported by ES. + if ( + isNaN(value) || + (value < 1 && SUPPORT_ZERO_DURATION_UNITS.indexOf(unit) === -1) || + (checkValidEsUnit === true && SUPPORT_ES_DURATION_UNITS.indexOf(unit) === -1) + ) { + return null; + } + + return duration(value, unit); + } catch (e) { + return null; + } +} diff --git a/x-pack/plugins/data_visualizer/public/application/common/util/url_state.tsx b/x-pack/plugins/data_visualizer/public/application/common/util/url_state.tsx new file mode 100644 index 0000000000000..8ee517e60e6d8 --- /dev/null +++ b/x-pack/plugins/data_visualizer/public/application/common/util/url_state.tsx @@ -0,0 +1,148 @@ +/* + * 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 { parse } from 'query-string'; +import { createContext, useCallback, useContext, useMemo } from 'react'; +// @ts-ignore +import { decode } from 'rison-node'; + +export interface Dictionary { + [id: string]: TValue; +} + +// duplicate of ml/object_utils +export const getNestedProperty = ( + obj: Record, + accessor: string, + defaultValue?: any +) => { + const value = accessor.split('.').reduce((o, i) => o?.[i], obj); + + if (value === undefined) return defaultValue; + + return value; +}; + +export type Accessor = '_a' | '_g'; +export type SetUrlState = ( + accessor: Accessor, + attribute: string | Dictionary, + value?: any, + replaceState?: boolean +) => void; +export interface UrlState { + searchString: string; + setUrlState: SetUrlState; +} + +/** + * Set of URL query parameters that require the rison serialization. + */ +const risonSerializedParams = new Set(['_a', '_g']); + +/** + * Checks if the URL query parameter requires rison serialization. + * @param queryParam + */ +export function isRisonSerializationRequired(queryParam: string): boolean { + return risonSerializedParams.has(queryParam); +} + +export function parseUrlState(search: string): Dictionary { + const urlState: Dictionary = {}; + const parsedQueryString = parse(search, { sort: false }); + + try { + Object.keys(parsedQueryString).forEach((a) => { + if (isRisonSerializationRequired(a)) { + urlState[a] = decode(parsedQueryString[a] as string); + } else { + urlState[a] = parsedQueryString[a]; + } + }); + } catch (error) { + // eslint-disable-next-line no-console + console.error('Could not read url state', error); + } + + return urlState; +} + +// Compared to the original appState/globalState, +// this no longer makes use of fetch/save methods. +// - Reading from `location.search` is the successor of `fetch`. +// - `history.push()` is the successor of `save`. +// - The exposed state and set call make use of the above and make sure that +// different urlStates(e.g. `_a` / `_g`) don't overwrite each other. +// This uses a context to be able to maintain only one instance +// of the url state. It gets passed down with `UrlStateProvider` +// and can be used via `useUrlState`. +export const dataVisualizerUrlStateStore = createContext({ + searchString: '', + setUrlState: () => {}, +}); + +export const { Provider } = dataVisualizerUrlStateStore; + +export const useUrlState = (accessor: Accessor) => { + const { searchString, setUrlState: setUrlStateContext } = useContext(dataVisualizerUrlStateStore); + + const urlState = useMemo(() => { + const fullUrlState = parseUrlState(searchString); + if (typeof fullUrlState === 'object') { + return fullUrlState[accessor]; + } + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [searchString]); + + const setUrlState = useCallback( + (attribute: string | Dictionary, value?: any, replaceState?: boolean) => { + setUrlStateContext(accessor, attribute, value, replaceState); + }, + [accessor, setUrlStateContext] + ); + return [urlState, setUrlState]; +}; + +export type AppStateKey = 'DATA_VISUALIZER_INDEX_VIEWER'; + +/** + * Hook for managing the URL state of the page. + */ +export const usePageUrlState = ( + pageKey: AppStateKey, + defaultState?: PageUrlState +): [PageUrlState, (update: Partial, replaceState?: boolean) => void] => { + const [appState, setAppState] = useUrlState('_a'); + const pageState = appState?.[pageKey]; + + const resultPageState: PageUrlState = useMemo(() => { + return { + ...(defaultState ?? {}), + ...(pageState ?? {}), + }; + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [pageState]); + + const onStateUpdate = useCallback( + (update: Partial, replaceState?: boolean) => { + setAppState( + pageKey, + { + ...resultPageState, + ...update, + }, + replaceState + ); + }, + [pageKey, resultPageState, setAppState] + ); + + return useMemo(() => { + return [resultPageState, onStateUpdate]; + }, [resultPageState, onStateUpdate]); +}; diff --git a/x-pack/plugins/file_data_visualizer/public/application/_index.scss b/x-pack/plugins/data_visualizer/public/application/file_data_visualizer/_index.scss similarity index 100% rename from x-pack/plugins/file_data_visualizer/public/application/_index.scss rename to x-pack/plugins/data_visualizer/public/application/file_data_visualizer/_index.scss diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/_index.scss b/x-pack/plugins/data_visualizer/public/application/file_data_visualizer/components/_index.scss similarity index 52% rename from x-pack/plugins/file_data_visualizer/public/application/components/_index.scss rename to x-pack/plugins/data_visualizer/public/application/file_data_visualizer/components/_index.scss index a47f3712cbb64..1973f51e0a59e 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/_index.scss +++ b/x-pack/plugins/data_visualizer/public/application/file_data_visualizer/components/_index.scss @@ -1,11 +1,7 @@ -@import 'about_panel/index'; @import 'analysis_summary/index'; @import 'edit_flyout/index'; -@import 'embedded_map/index'; -@import 'experimental_badge/index'; @import 'file_contents/index'; -@import 'file_datavisualizer_view/index'; @import 'import_summary/index'; +@import 'file_data_visualizer_view/index'; @import 'results_view/index'; -@import 'stats_table/index'; -@import 'top_values/top_values'; +@import 'about_panel/index'; diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/about_panel/_about_panel.scss b/x-pack/plugins/data_visualizer/public/application/file_data_visualizer/components/about_panel/_about_panel.scss similarity index 100% rename from x-pack/plugins/file_data_visualizer/public/application/components/about_panel/_about_panel.scss rename to x-pack/plugins/data_visualizer/public/application/file_data_visualizer/components/about_panel/_about_panel.scss diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/about_panel/_index.scss b/x-pack/plugins/data_visualizer/public/application/file_data_visualizer/components/about_panel/_index.scss similarity index 100% rename from x-pack/plugins/file_data_visualizer/public/application/components/about_panel/_index.scss rename to x-pack/plugins/data_visualizer/public/application/file_data_visualizer/components/about_panel/_index.scss diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/about_panel/about_panel.tsx b/x-pack/plugins/data_visualizer/public/application/file_data_visualizer/components/about_panel/about_panel.tsx similarity index 87% rename from x-pack/plugins/file_data_visualizer/public/application/components/about_panel/about_panel.tsx rename to x-pack/plugins/data_visualizer/public/application/file_data_visualizer/components/about_panel/about_panel.tsx index e4f59c492fa1c..a176450250ba9 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/about_panel/about_panel.tsx +++ b/x-pack/plugins/data_visualizer/public/application/file_data_visualizer/components/about_panel/about_panel.tsx @@ -30,7 +30,7 @@ interface Props { export const AboutPanel: FC = ({ onFilePickerChange }) => { return ( - + @@ -43,7 +43,7 @@ export const AboutPanel: FC = ({ onFilePickerChange }) => { = ({ onFilePickerChange }) => { export const LoadingPanel: FC = () => { return ( - +

diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/about_panel/index.ts b/x-pack/plugins/data_visualizer/public/application/file_data_visualizer/components/about_panel/index.ts similarity index 100% rename from x-pack/plugins/file_data_visualizer/public/application/components/about_panel/index.ts rename to x-pack/plugins/data_visualizer/public/application/file_data_visualizer/components/about_panel/index.ts diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/about_panel/welcome_content.tsx b/x-pack/plugins/data_visualizer/public/application/file_data_visualizer/components/about_panel/welcome_content.tsx similarity index 81% rename from x-pack/plugins/file_data_visualizer/public/application/components/about_panel/welcome_content.tsx rename to x-pack/plugins/data_visualizer/public/application/file_data_visualizer/components/about_panel/welcome_content.tsx index 684b6dadcb290..86b869fe06fa1 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/about_panel/welcome_content.tsx +++ b/x-pack/plugins/data_visualizer/public/application/file_data_visualizer/components/about_panel/welcome_content.tsx @@ -19,13 +19,13 @@ import { EuiTitle, } from '@elastic/eui'; -import { ExperimentalBadge } from '../experimental_badge'; +import { ExperimentalBadge } from '../../../common/components/experimental_badge'; -import { useFileDataVisualizerKibana } from '../../kibana_context'; +import { useDataVisualizerKibana } from '../../../kibana_context'; export const WelcomeContent: FC = () => { const toolTipContent = i18n.translate( - 'xpack.fileDataVisualizer.welcomeContent.experimentalFeatureTooltip', + 'xpack.dataVisualizer.file.welcomeContent.experimentalFeatureTooltip', { defaultMessage: "Experimental feature. We'd love to hear your feedback.", } @@ -35,7 +35,7 @@ export const WelcomeContent: FC = () => { services: { fileUpload: { getMaxBytesFormatted }, }, - } = useFileDataVisualizerKibana(); + } = useDataVisualizerKibana(); const maxFileSize = getMaxBytesFormatted(); return ( @@ -47,7 +47,7 @@ export const WelcomeContent: FC = () => {

, @@ -59,7 +59,7 @@ export const WelcomeContent: FC = () => {

@@ -69,7 +69,7 @@ export const WelcomeContent: FC = () => {

@@ -83,7 +83,7 @@ export const WelcomeContent: FC = () => {

@@ -99,7 +99,7 @@ export const WelcomeContent: FC = () => {

@@ -115,7 +115,7 @@ export const WelcomeContent: FC = () => {

@@ -126,7 +126,7 @@ export const WelcomeContent: FC = () => {

@@ -136,7 +136,7 @@ export const WelcomeContent: FC = () => {

= ({ results }) => { const items = createDisplayItems(results); @@ -19,7 +19,7 @@ export const AnalysisSummary: FC<{ results: FindFileStructureResponse }> = ({ re

@@ -37,7 +37,7 @@ function createDisplayItems(results: FindFileStructureResponse) { { title: ( ), @@ -53,7 +53,7 @@ function createDisplayItems(results: FindFileStructureResponse) { items.push({ title: ( ), @@ -64,7 +64,7 @@ function createDisplayItems(results: FindFileStructureResponse) { items.push({ title: ( ), @@ -74,7 +74,7 @@ function createDisplayItems(results: FindFileStructureResponse) { items.push({ title: ( ), @@ -87,7 +87,7 @@ function createDisplayItems(results: FindFileStructureResponse) { items.push({ title: ( ), @@ -99,7 +99,7 @@ function createDisplayItems(results: FindFileStructureResponse) { items.push({ title: ( ), @@ -111,7 +111,7 @@ function createDisplayItems(results: FindFileStructureResponse) { items.push({ title: ( = ({ mode, onChangeMode, onCancel, di content={ disableImport ? ( ) : null @@ -49,10 +49,10 @@ export const BottomBar: FC = ({ mode, onChangeMode, onCancel, di fill isDisabled={disableImport} onClick={() => onChangeMode(DATAVISUALIZER_MODE.IMPORT)} - data-test-subj="mlFileDataVisOpenImportPageButton" + data-test-subj="dataVisualizerFileOpenImportPageButton" > @@ -61,7 +61,7 @@ export const BottomBar: FC = ({ mode, onChangeMode, onCancel, di onCancel()}> @@ -76,7 +76,7 @@ export const BottomBar: FC = ({ mode, onChangeMode, onCancel, di onChangeMode(DATAVISUALIZER_MODE.READ)}> @@ -84,7 +84,7 @@ export const BottomBar: FC = ({ mode, onChangeMode, onCancel, di onCancel()}> diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/bottom_bar/index.ts b/x-pack/plugins/data_visualizer/public/application/file_data_visualizer/components/bottom_bar/index.ts similarity index 100% rename from x-pack/plugins/file_data_visualizer/public/application/components/bottom_bar/index.ts rename to x-pack/plugins/data_visualizer/public/application/file_data_visualizer/components/bottom_bar/index.ts diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/edit_flyout/__snapshots__/overrides.test.js.snap b/x-pack/plugins/data_visualizer/public/application/file_data_visualizer/components/edit_flyout/__snapshots__/overrides.test.js.snap similarity index 96% rename from x-pack/plugins/file_data_visualizer/public/application/components/edit_flyout/__snapshots__/overrides.test.js.snap rename to x-pack/plugins/data_visualizer/public/application/file_data_visualizer/components/edit_flyout/__snapshots__/overrides.test.js.snap index 00dd652457daf..8b69f7d742489 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/edit_flyout/__snapshots__/overrides.test.js.snap +++ b/x-pack/plugins/data_visualizer/public/application/file_data_visualizer/components/edit_flyout/__snapshots__/overrides.test.js.snap @@ -13,7 +13,7 @@ exports[`Overrides render overrides 1`] = ` label={ } @@ -33,7 +33,7 @@ exports[`Overrides render overrides 1`] = ` label={ } @@ -94,7 +94,7 @@ exports[`Overrides render overrides 1`] = ` label={ } @@ -335,7 +335,7 @@ exports[`Overrides render overrides 1`] = ` label={ } diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/edit_flyout/_edit_flyout.scss b/x-pack/plugins/data_visualizer/public/application/file_data_visualizer/components/edit_flyout/_edit_flyout.scss similarity index 100% rename from x-pack/plugins/file_data_visualizer/public/application/components/edit_flyout/_edit_flyout.scss rename to x-pack/plugins/data_visualizer/public/application/file_data_visualizer/components/edit_flyout/_edit_flyout.scss diff --git a/x-pack/plugins/data_visualizer/public/application/file_data_visualizer/components/edit_flyout/_index.scss b/x-pack/plugins/data_visualizer/public/application/file_data_visualizer/components/edit_flyout/_index.scss new file mode 100644 index 0000000000000..28489c50f19b4 --- /dev/null +++ b/x-pack/plugins/data_visualizer/public/application/file_data_visualizer/components/edit_flyout/_index.scss @@ -0,0 +1 @@ +@import 'edit_flyout'; diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/edit_flyout/edit_flyout.js b/x-pack/plugins/data_visualizer/public/application/file_data_visualizer/components/edit_flyout/edit_flyout.js similarity index 91% rename from x-pack/plugins/file_data_visualizer/public/application/components/edit_flyout/edit_flyout.js rename to x-pack/plugins/data_visualizer/public/application/file_data_visualizer/components/edit_flyout/edit_flyout.js index 7cdee6f823bd6..cc6f5c45b3105 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/edit_flyout/edit_flyout.js +++ b/x-pack/plugins/data_visualizer/public/application/file_data_visualizer/components/edit_flyout/edit_flyout.js @@ -69,7 +69,7 @@ export class EditFlyout extends Component {

@@ -96,7 +96,7 @@ export class EditFlyout extends Component { @@ -108,7 +108,7 @@ export class EditFlyout extends Component { fill > diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/edit_flyout/index.js b/x-pack/plugins/data_visualizer/public/application/file_data_visualizer/components/edit_flyout/index.js similarity index 100% rename from x-pack/plugins/file_data_visualizer/public/application/components/edit_flyout/index.js rename to x-pack/plugins/data_visualizer/public/application/file_data_visualizer/components/edit_flyout/index.js diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/edit_flyout/options/index.js b/x-pack/plugins/data_visualizer/public/application/file_data_visualizer/components/edit_flyout/options/index.js similarity index 100% rename from x-pack/plugins/file_data_visualizer/public/application/components/edit_flyout/options/index.js rename to x-pack/plugins/data_visualizer/public/application/file_data_visualizer/components/edit_flyout/options/index.js diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/edit_flyout/options/option_lists.js b/x-pack/plugins/data_visualizer/public/application/file_data_visualizer/components/edit_flyout/options/option_lists.js similarity index 100% rename from x-pack/plugins/file_data_visualizer/public/application/components/edit_flyout/options/option_lists.js rename to x-pack/plugins/data_visualizer/public/application/file_data_visualizer/components/edit_flyout/options/option_lists.js diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/edit_flyout/options/options.js b/x-pack/plugins/data_visualizer/public/application/file_data_visualizer/components/edit_flyout/options/options.js similarity index 100% rename from x-pack/plugins/file_data_visualizer/public/application/components/edit_flyout/options/options.js rename to x-pack/plugins/data_visualizer/public/application/file_data_visualizer/components/edit_flyout/options/options.js diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/edit_flyout/overrides.js b/x-pack/plugins/data_visualizer/public/application/file_data_visualizer/components/edit_flyout/overrides.js similarity index 91% rename from x-pack/plugins/file_data_visualizer/public/application/components/edit_flyout/overrides.js rename to x-pack/plugins/data_visualizer/public/application/file_data_visualizer/components/edit_flyout/overrides.js index cb0839b335a97..b7eb790d2cf4e 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/edit_flyout/overrides.js +++ b/x-pack/plugins/data_visualizer/public/application/file_data_visualizer/components/edit_flyout/overrides.js @@ -31,7 +31,7 @@ import { // getCharsetOptions, } from './options'; import { isTimestampFormatValid } from './overrides_validation'; -import { withKibana } from '../../../../../../../src/plugins/kibana_react/public'; +import { withKibana } from '../../../../../../../../src/plugins/kibana_react/public'; import { TIMESTAMP_OPTIONS, CUSTOM_DROPDOWN_OPTION } from './options/option_lists'; @@ -52,7 +52,7 @@ class OverridesUI extends Component { } linesToSampleErrors = i18n.translate( - 'xpack.fileDataVisualizer.editFlyout.overrides.linesToSampleErrorMessage', + 'xpack.dataVisualizer.file.editFlyout.overrides.linesToSampleErrorMessage', { defaultMessage: 'Value must be greater than {min} and less than or equal to {max}', values: { @@ -63,7 +63,7 @@ class OverridesUI extends Component { ); customTimestampFormatErrors = i18n.translate( - 'xpack.fileDataVisualizer.editFlyout.overrides.customTimestampFormatErrorMessage', + 'xpack.dataVisualizer.file.editFlyout.overrides.customTimestampFormatErrorMessage', { defaultMessage: `Timestamp format must be a combination of these Java date/time formats: yy, yyyy, M, MM, MMM, MMMM, d, dd, EEE, EEEE, H, HH, h, mm, ss, S through SSSSSSSSS, a, XX, XXX, zzz`, @@ -274,9 +274,12 @@ class OverridesUI extends Component { const timestampFormatHelp = ( - {i18n.translate('xpack.fileDataVisualizer.editFlyout.overrides.timestampFormatHelpText', { - defaultMessage: 'See more on accepted formats', - })} + {i18n.translate( + 'xpack.dataVisualizer.file.editFlyout.overrides.timestampFormatHelpText', + { + defaultMessage: 'See more on accepted formats', + } + )} ); @@ -288,7 +291,7 @@ class OverridesUI extends Component { isInvalid={linesToSampleValid === false} label={ } @@ -303,7 +306,7 @@ class OverridesUI extends Component { } @@ -321,7 +324,7 @@ class OverridesUI extends Component { } @@ -338,7 +341,7 @@ class OverridesUI extends Component { } @@ -350,7 +353,7 @@ class OverridesUI extends Component { } @@ -369,7 +372,7 @@ class OverridesUI extends Component { id={'hasHeaderRow'} label={ } @@ -383,7 +386,7 @@ class OverridesUI extends Component { id={'shouldTrimFields'} label={ } @@ -398,7 +401,7 @@ class OverridesUI extends Component { } @@ -415,7 +418,7 @@ class OverridesUI extends Component { helpText={timestampFormatHelp} label={ } @@ -434,7 +437,7 @@ class OverridesUI extends Component { isInvalid={timestampFormatValid === false} label={ } @@ -450,7 +453,7 @@ class OverridesUI extends Component { } @@ -480,7 +483,7 @@ class OverridesUI extends Component {

diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/edit_flyout/overrides.test.js b/x-pack/plugins/data_visualizer/public/application/file_data_visualizer/components/edit_flyout/overrides.test.js similarity index 95% rename from x-pack/plugins/file_data_visualizer/public/application/components/edit_flyout/overrides.test.js rename to x-pack/plugins/data_visualizer/public/application/file_data_visualizer/components/edit_flyout/overrides.test.js index 8e11d5150359d..03679a2a65e65 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/edit_flyout/overrides.test.js +++ b/x-pack/plugins/data_visualizer/public/application/file_data_visualizer/components/edit_flyout/overrides.test.js @@ -10,7 +10,7 @@ import React from 'react'; import { Overrides } from './overrides'; -jest.mock('../../../../../../../src/plugins/kibana_react/public', () => ({ +jest.mock('../../../../../../../../src/plugins/kibana_react/public', () => ({ withKibana: (comp) => { return comp; }, diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/edit_flyout/overrides_validation.js b/x-pack/plugins/data_visualizer/public/application/file_data_visualizer/components/edit_flyout/overrides_validation.js similarity index 90% rename from x-pack/plugins/file_data_visualizer/public/application/components/edit_flyout/overrides_validation.js rename to x-pack/plugins/data_visualizer/public/application/file_data_visualizer/components/edit_flyout/overrides_validation.js index c833d55351b6d..281131892e1e6 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/edit_flyout/overrides_validation.js +++ b/x-pack/plugins/data_visualizer/public/application/file_data_visualizer/components/edit_flyout/overrides_validation.js @@ -41,7 +41,7 @@ export function isTimestampFormatValid(timestampFormat) { if (timestampFormat.indexOf('?') >= 0) { result.isValid = false; result.errorMessage = i18n.translate( - 'xpack.fileDataVisualizer.editFlyout.overrides.timestampQuestionMarkValidationErrorMessage', + 'xpack.dataVisualizer.file.editFlyout.overrides.timestampQuestionMarkValidationErrorMessage', { defaultMessage: 'Timestamp format {timestampFormat} not supported because it contains a question mark character ({fieldPlaceholder})', @@ -86,7 +86,7 @@ export function isTimestampFormatValid(timestampFormat) { result.isValid = false; result.errorMessage = i18n.translate( - 'xpack.fileDataVisualizer.editFlyout.overrides.timestampLetterValidationErrorMessage', + 'xpack.dataVisualizer.file.editFlyout.overrides.timestampLetterValidationErrorMessage', { defaultMessage: 'Letter { length, plural, one { {lg} } other { group {lg} } } in {format} is not supported', @@ -101,7 +101,7 @@ export function isTimestampFormatValid(timestampFormat) { if (curChar === 'S') { // disable exceeds maximum line length error so i18n check passes result.errorMessage = i18n.translate( - 'xpack.fileDataVisualizer.editFlyout.overrides.timestampLetterSValidationErrorMessage', + 'xpack.dataVisualizer.file.editFlyout.overrides.timestampLetterSValidationErrorMessage', { defaultMessage: 'Letter { length, plural, one { {lg} } other { group {lg} } } in {format} is not supported because it is not preceded by ss and a separator from {sep}', // eslint-disable-line @@ -128,7 +128,7 @@ export function isTimestampFormatValid(timestampFormat) { if (prevLetterGroup == null) { result.isValid = false; result.errorMessage = i18n.translate( - 'xpack.fileDataVisualizer.editFlyout.overrides.timestampEmptyValidationErrorMessage', + 'xpack.dataVisualizer.file.editFlyout.overrides.timestampEmptyValidationErrorMessage', { defaultMessage: 'No time format letter groups in timestamp format {timestampFormat}', values: { diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/explanation_flyout/explanation_flyout.tsx b/x-pack/plugins/data_visualizer/public/application/file_data_visualizer/components/explanation_flyout/explanation_flyout.tsx similarity index 87% rename from x-pack/plugins/file_data_visualizer/public/application/components/explanation_flyout/explanation_flyout.tsx rename to x-pack/plugins/data_visualizer/public/application/file_data_visualizer/components/explanation_flyout/explanation_flyout.tsx index 606bab514ac9f..9898dd53ec66a 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/explanation_flyout/explanation_flyout.tsx +++ b/x-pack/plugins/data_visualizer/public/application/file_data_visualizer/components/explanation_flyout/explanation_flyout.tsx @@ -20,7 +20,7 @@ import { EuiText, EuiSubSteps, } from '@elastic/eui'; -import { FindFileStructureResponse } from '../../../../../file_upload/common'; +import { FindFileStructureResponse } from '../../../../../../file_upload/common'; interface Props { results: FindFileStructureResponse; @@ -34,7 +34,7 @@ export const ExplanationFlyout: FC = ({ results, closeFlyout }) => {

@@ -48,7 +48,7 @@ export const ExplanationFlyout: FC = ({ results, closeFlyout }) => { @@ -63,7 +63,7 @@ const Content: FC<{ explanation: string[] }> = ({ explanation }) => ( <> diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/explanation_flyout/index.ts b/x-pack/plugins/data_visualizer/public/application/file_data_visualizer/components/explanation_flyout/index.ts similarity index 100% rename from x-pack/plugins/file_data_visualizer/public/application/components/explanation_flyout/index.ts rename to x-pack/plugins/data_visualizer/public/application/file_data_visualizer/components/explanation_flyout/index.ts diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/file_contents/_file_contents.scss b/x-pack/plugins/data_visualizer/public/application/file_data_visualizer/components/file_contents/_file_contents.scss similarity index 100% rename from x-pack/plugins/file_data_visualizer/public/application/components/file_contents/_file_contents.scss rename to x-pack/plugins/data_visualizer/public/application/file_data_visualizer/components/file_contents/_file_contents.scss diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/file_contents/_index.scss b/x-pack/plugins/data_visualizer/public/application/file_data_visualizer/components/file_contents/_index.scss similarity index 100% rename from x-pack/plugins/file_data_visualizer/public/application/components/file_contents/_index.scss rename to x-pack/plugins/data_visualizer/public/application/file_data_visualizer/components/file_contents/_index.scss diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/file_contents/file_contents.tsx b/x-pack/plugins/data_visualizer/public/application/file_data_visualizer/components/file_contents/file_contents.tsx similarity index 91% rename from x-pack/plugins/file_data_visualizer/public/application/components/file_contents/file_contents.tsx rename to x-pack/plugins/data_visualizer/public/application/file_data_visualizer/components/file_contents/file_contents.tsx index fa54cf9cbc05c..9588cad9f72f7 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/file_contents/file_contents.tsx +++ b/x-pack/plugins/data_visualizer/public/application/file_data_visualizer/components/file_contents/file_contents.tsx @@ -31,7 +31,7 @@ export const FileContents: FC = ({ data, format, numberOfLines }) => {

@@ -39,7 +39,7 @@ export const FileContents: FC = ({ data, format, numberOfLines }) => {
), diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/file_datavisualizer_view/file_error_callouts.tsx b/x-pack/plugins/data_visualizer/public/application/file_data_visualizer/components/file_data_visualizer_view/file_error_callouts.tsx similarity index 80% rename from x-pack/plugins/file_data_visualizer/public/application/components/file_datavisualizer_view/file_error_callouts.tsx rename to x-pack/plugins/data_visualizer/public/application/file_data_visualizer/components/file_data_visualizer_view/file_error_callouts.tsx index b932dee35ebb8..7b6378e34e78e 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/file_datavisualizer_view/file_error_callouts.tsx +++ b/x-pack/plugins/data_visualizer/public/application/file_data_visualizer/components/file_data_visualizer_view/file_error_callouts.tsx @@ -11,8 +11,8 @@ import React, { FC } from 'react'; import { EuiCallOut, EuiSpacer, EuiButtonEmpty, EuiHorizontalRule } from '@elastic/eui'; import numeral from '@elastic/numeral'; -import { FILE_SIZE_DISPLAY_FORMAT } from '../../../../common'; -import { FindFileStructureErrorResponse } from '../../../../../file_upload/common'; +import { FILE_SIZE_DISPLAY_FORMAT } from '../../../../../common'; +import { FindFileStructureErrorResponse } from '../../../../../../file_upload/common'; interface FileTooLargeProps { fileSize: number; @@ -31,7 +31,7 @@ export const FileTooLarge: FC = ({ fileSize, maxFileSize }) = errorText = (

= ({ fileSize, maxFileSize }) = errorText = (

= ({ fileSize, maxFileSize }) = } color="danger" iconType="cross" - data-test-subj="mlFileUploadErrorCallout fileTooLarge" + data-test-subj="dataVisualizerFileUploadErrorCallout fileTooLarge" > {errorText} @@ -92,24 +92,24 @@ export const FileCouldNotBeRead: FC = ({ } color="danger" iconType="cross" - data-test-subj="mlFileUploadErrorCallout fileCouldNotBeRead" + data-test-subj="dataVisualizerFileUploadErrorCallout fileCouldNotBeRead" > {loaded === false && ( <>
@@ -122,7 +122,7 @@ export const FileCouldNotBeRead: FC = ({ <> diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/file_datavisualizer_view/index.js b/x-pack/plugins/data_visualizer/public/application/file_data_visualizer/components/file_data_visualizer_view/index.js similarity index 78% rename from x-pack/plugins/file_data_visualizer/public/application/components/file_datavisualizer_view/index.js rename to x-pack/plugins/data_visualizer/public/application/file_data_visualizer/components/file_data_visualizer_view/index.js index c3004f8a1ac3f..6a6130460fa40 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/file_datavisualizer_view/index.js +++ b/x-pack/plugins/data_visualizer/public/application/file_data_visualizer/components/file_data_visualizer_view/index.js @@ -5,4 +5,4 @@ * 2.0. */ -export { FileDataVisualizerView } from './file_datavisualizer_view'; +export { FileDataVisualizerView } from './file_data_visualizer_view'; diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/import_errors/errors.tsx b/x-pack/plugins/data_visualizer/public/application/file_data_visualizer/components/import_errors/errors.tsx similarity index 81% rename from x-pack/plugins/file_data_visualizer/public/application/components/import_errors/errors.tsx rename to x-pack/plugins/data_visualizer/public/application/file_data_visualizer/components/import_errors/errors.tsx index 5a6f78a1a3068..1a54b844574c5 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/import_errors/errors.tsx +++ b/x-pack/plugins/data_visualizer/public/application/file_data_visualizer/components/import_errors/errors.tsx @@ -38,56 +38,56 @@ function title(statuses: Statuses) { case statuses.readStatus: return ( ); case statuses.parseJSONStatus: return ( ); case statuses.indexCreatedStatus: return ( ); case statuses.ingestPipelineCreatedStatus: return ( ); case statuses.uploadStatus: return ( ); case statuses.indexPatternCreatedStatus: return ( ); case statuses.permissionCheckStatus: return ( ); default: return ( ); @@ -105,7 +105,7 @@ const ImportError: FC<{ error: any }> = ({ error }) => { id="more" buttonContent={ } @@ -151,7 +151,7 @@ function toString(error: any): ImportError { } return { - msg: i18n.translate('xpack.fileDataVisualizer.importErrors.unknownErrorMessage', { + msg: i18n.translate('xpack.dataVisualizer.file.importErrors.unknownErrorMessage', { defaultMessage: 'Unknown error', }), }; diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/import_errors/index.ts b/x-pack/plugins/data_visualizer/public/application/file_data_visualizer/components/import_errors/index.ts similarity index 100% rename from x-pack/plugins/file_data_visualizer/public/application/components/import_errors/index.ts rename to x-pack/plugins/data_visualizer/public/application/file_data_visualizer/components/import_errors/index.ts diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/import_progress/import_progress.tsx b/x-pack/plugins/data_visualizer/public/application/file_data_visualizer/components/import_progress/import_progress.tsx similarity index 81% rename from x-pack/plugins/file_data_visualizer/public/application/components/import_progress/import_progress.tsx rename to x-pack/plugins/data_visualizer/public/application/file_data_visualizer/components/import_progress/import_progress.tsx index 8296a4885bf2c..a058afca84c76 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/import_progress/import_progress.tsx +++ b/x-pack/plugins/data_visualizer/public/application/file_data_visualizer/components/import_progress/import_progress.tsx @@ -80,31 +80,31 @@ export const ImportProgress: FC<{ statuses: Statuses }> = ({ statuses }) => { } let processFileTitle = i18n.translate( - 'xpack.fileDataVisualizer.importProgress.processFileTitle', + 'xpack.dataVisualizer.file.importProgress.processFileTitle', { defaultMessage: 'Process file', } ); let createIndexTitle = i18n.translate( - 'xpack.fileDataVisualizer.importProgress.createIndexTitle', + 'xpack.dataVisualizer.file.importProgress.createIndexTitle', { defaultMessage: 'Create index', } ); let createIngestPipelineTitle = i18n.translate( - 'xpack.fileDataVisualizer.importProgress.createIngestPipelineTitle', + 'xpack.dataVisualizer.file.importProgress.createIngestPipelineTitle', { defaultMessage: 'Create ingest pipeline', } ); let uploadingDataTitle = i18n.translate( - 'xpack.fileDataVisualizer.importProgress.uploadDataTitle', + 'xpack.dataVisualizer.file.importProgress.uploadDataTitle', { defaultMessage: 'Upload data', } ); let createIndexPatternTitle = i18n.translate( - 'xpack.fileDataVisualizer.importProgress.createIndexPatternTitle', + 'xpack.dataVisualizer.file.importProgress.createIndexPatternTitle', { defaultMessage: 'Create index pattern', } @@ -113,7 +113,7 @@ export const ImportProgress: FC<{ statuses: Statuses }> = ({ statuses }) => { const creatingIndexStatus = (

@@ -122,7 +122,7 @@ export const ImportProgress: FC<{ statuses: Statuses }> = ({ statuses }) => { const creatingIndexAndIngestPipelineStatus = (

@@ -130,7 +130,7 @@ export const ImportProgress: FC<{ statuses: Statuses }> = ({ statuses }) => { if (completedStep >= 0) { processFileTitle = i18n.translate( - 'xpack.fileDataVisualizer.importProgress.processingFileTitle', + 'xpack.dataVisualizer.file.importProgress.processingFileTitle', { defaultMessage: 'Processing file', } @@ -138,7 +138,7 @@ export const ImportProgress: FC<{ statuses: Statuses }> = ({ statuses }) => { statusInfo = (

@@ -146,13 +146,13 @@ export const ImportProgress: FC<{ statuses: Statuses }> = ({ statuses }) => { } if (completedStep >= 1) { processFileTitle = i18n.translate( - 'xpack.fileDataVisualizer.importProgress.fileProcessedTitle', + 'xpack.dataVisualizer.file.importProgress.fileProcessedTitle', { defaultMessage: 'File processed', } ); createIndexTitle = i18n.translate( - 'xpack.fileDataVisualizer.importProgress.creatingIndexTitle', + 'xpack.dataVisualizer.file.importProgress.creatingIndexTitle', { defaultMessage: 'Creating index', } @@ -161,11 +161,14 @@ export const ImportProgress: FC<{ statuses: Statuses }> = ({ statuses }) => { createPipeline === true ? creatingIndexAndIngestPipelineStatus : creatingIndexStatus; } if (completedStep >= 2) { - createIndexTitle = i18n.translate('xpack.fileDataVisualizer.importProgress.indexCreatedTitle', { - defaultMessage: 'Index created', - }); + createIndexTitle = i18n.translate( + 'xpack.dataVisualizer.file.importProgress.indexCreatedTitle', + { + defaultMessage: 'Index created', + } + ); createIngestPipelineTitle = i18n.translate( - 'xpack.fileDataVisualizer.importProgress.creatingIngestPipelineTitle', + 'xpack.dataVisualizer.file.importProgress.creatingIngestPipelineTitle', { defaultMessage: 'Creating ingest pipeline', } @@ -175,13 +178,13 @@ export const ImportProgress: FC<{ statuses: Statuses }> = ({ statuses }) => { } if (completedStep >= 3) { createIngestPipelineTitle = i18n.translate( - 'xpack.fileDataVisualizer.importProgress.ingestPipelineCreatedTitle', + 'xpack.dataVisualizer.file.importProgress.ingestPipelineCreatedTitle', { defaultMessage: 'Ingest pipeline created', } ); uploadingDataTitle = i18n.translate( - 'xpack.fileDataVisualizer.importProgress.uploadingDataTitle', + 'xpack.dataVisualizer.file.importProgress.uploadingDataTitle', { defaultMessage: 'Uploading data', } @@ -190,14 +193,14 @@ export const ImportProgress: FC<{ statuses: Statuses }> = ({ statuses }) => { } if (completedStep >= 4) { uploadingDataTitle = i18n.translate( - 'xpack.fileDataVisualizer.importProgress.dataUploadedTitle', + 'xpack.dataVisualizer.file.importProgress.dataUploadedTitle', { defaultMessage: 'Data uploaded', } ); if (createIndexPattern === true) { createIndexPatternTitle = i18n.translate( - 'xpack.fileDataVisualizer.importProgress.creatingIndexPatternTitle', + 'xpack.dataVisualizer.file.importProgress.creatingIndexPatternTitle', { defaultMessage: 'Creating index pattern', } @@ -205,7 +208,7 @@ export const ImportProgress: FC<{ statuses: Statuses }> = ({ statuses }) => { statusInfo = (

@@ -216,7 +219,7 @@ export const ImportProgress: FC<{ statuses: Statuses }> = ({ statuses }) => { } if (completedStep >= 5) { createIndexPatternTitle = i18n.translate( - 'xpack.fileDataVisualizer.importProgress.indexPatternCreatedTitle', + 'xpack.dataVisualizer.file.importProgress.indexPatternCreatedTitle', { defaultMessage: 'Index pattern created', } @@ -290,7 +293,7 @@ const UploadFunctionProgress: FC<{ progress: number }> = ({ progress }) => {

diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/import_progress/index.ts b/x-pack/plugins/data_visualizer/public/application/file_data_visualizer/components/import_progress/index.ts similarity index 100% rename from x-pack/plugins/file_data_visualizer/public/application/components/import_progress/index.ts rename to x-pack/plugins/data_visualizer/public/application/file_data_visualizer/components/import_progress/index.ts diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/import_settings/advanced.tsx b/x-pack/plugins/data_visualizer/public/application/file_data_visualizer/components/import_settings/advanced.tsx similarity index 87% rename from x-pack/plugins/file_data_visualizer/public/application/components/import_settings/advanced.tsx rename to x-pack/plugins/data_visualizer/public/application/file_data_visualizer/components/import_settings/advanced.tsx index acb6415e93f9b..a60b291d7e723 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/import_settings/advanced.tsx +++ b/x-pack/plugins/data_visualizer/public/application/file_data_visualizer/components/import_settings/advanced.tsx @@ -18,9 +18,9 @@ import { EuiFlexItem, } from '@elastic/eui'; -import { CombinedField, CombinedFieldsForm } from '../combined_fields'; +import { CombinedField, CombinedFieldsForm } from '../../../common/components/combined_fields'; import { JsonEditor, EDITOR_MODE } from '../json_editor'; -import { FindFileStructureResponse } from '../../../../../file_upload/common'; +import { FindFileStructureResponse } from '../../../../../../file_upload/common'; const EDITOR_HEIGHT = '300px'; interface Props { @@ -69,7 +69,7 @@ export const AdvancedSettings: FC = ({ } @@ -78,7 +78,7 @@ export const AdvancedSettings: FC = ({ > = ({ onChange={onIndexChange} isInvalid={indexNameError !== ''} aria-label={i18n.translate( - 'xpack.fileDataVisualizer.advancedImportSettings.indexNameAriaLabel', + 'xpack.dataVisualizer.file.advancedImportSettings.indexNameAriaLabel', { defaultMessage: 'Index name, required field', } @@ -102,7 +102,7 @@ export const AdvancedSettings: FC = ({ id="createIndexPattern" label={ } @@ -116,7 +116,7 @@ export const AdvancedSettings: FC = ({ } @@ -184,7 +184,7 @@ const IndexSettings: FC = ({ initialized, data, onChange }) => } @@ -209,7 +209,7 @@ const Mappings: FC = ({ initialized, data, onChange }) => { } @@ -234,7 +234,7 @@ const IngestPipeline: FC = ({ initialized, data, onChange }) => } diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/import_settings/import_settings.tsx b/x-pack/plugins/data_visualizer/public/application/file_data_visualizer/components/import_settings/import_settings.tsx similarity index 91% rename from x-pack/plugins/file_data_visualizer/public/application/components/import_settings/import_settings.tsx rename to x-pack/plugins/data_visualizer/public/application/file_data_visualizer/components/import_settings/import_settings.tsx index 90383acd7e6c5..4e36dc42b54a5 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/import_settings/import_settings.tsx +++ b/x-pack/plugins/data_visualizer/public/application/file_data_visualizer/components/import_settings/import_settings.tsx @@ -12,8 +12,8 @@ import { EuiTabbedContent, EuiSpacer } from '@elastic/eui'; import { SimpleSettings } from './simple'; import { AdvancedSettings } from './advanced'; -import { CombinedField } from '../combined_fields'; -import { FindFileStructureResponse } from '../../../../../file_upload/common'; +import { CombinedField } from '../../../common/components/combined_fields'; +import { FindFileStructureResponse } from '../../../../../../file_upload/common'; interface Props { index: string; @@ -59,7 +59,7 @@ export const ImportSettings: FC = ({ const tabs = [ { id: 'simple-settings', - name: i18n.translate('xpack.fileDataVisualizer.importSettings.simpleTabName', { + name: i18n.translate('xpack.dataVisualizer.file.importSettings.simpleTabName', { defaultMessage: 'Simple', }), content: ( @@ -80,7 +80,7 @@ export const ImportSettings: FC = ({ }, { id: 'advanced-settings', - name: i18n.translate('xpack.fileDataVisualizer.importSettings.advancedTabName', { + name: i18n.translate('xpack.dataVisualizer.file.importSettings.advancedTabName', { defaultMessage: 'Advanced', }), content: ( diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/import_settings/index.ts b/x-pack/plugins/data_visualizer/public/application/file_data_visualizer/components/import_settings/index.ts similarity index 100% rename from x-pack/plugins/file_data_visualizer/public/application/components/import_settings/index.ts rename to x-pack/plugins/data_visualizer/public/application/file_data_visualizer/components/import_settings/index.ts diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/import_settings/simple.tsx b/x-pack/plugins/data_visualizer/public/application/file_data_visualizer/components/import_settings/simple.tsx similarity index 77% rename from x-pack/plugins/file_data_visualizer/public/application/components/import_settings/simple.tsx rename to x-pack/plugins/data_visualizer/public/application/file_data_visualizer/components/import_settings/simple.tsx index 2751b37cd3256..02f33c49b77c4 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/import_settings/simple.tsx +++ b/x-pack/plugins/data_visualizer/public/application/file_data_visualizer/components/import_settings/simple.tsx @@ -10,7 +10,10 @@ import { FormattedMessage } from '@kbn/i18n/react'; import React, { FC } from 'react'; import { EuiFieldText, EuiFormRow, EuiCheckbox, EuiSpacer } from '@elastic/eui'; -import { CombinedField, CombinedFieldsReadOnlyForm } from '../combined_fields'; +import { + CombinedField, + CombinedFieldsReadOnlyForm, +} from '../../../common/components/combined_fields'; interface Props { index: string; @@ -36,7 +39,7 @@ export const SimpleSettings: FC = ({ } @@ -45,7 +48,7 @@ export const SimpleSettings: FC = ({ > = ({ onChange={onIndexChange} isInvalid={indexNameError !== ''} aria-label={i18n.translate( - 'xpack.fileDataVisualizer.simpleImportSettings.indexNameAriaLabel', + 'xpack.dataVisualizer.file.simpleImportSettings.indexNameAriaLabel', { defaultMessage: 'Index name, required field', } )} - data-test-subj="mlFileDataVisIndexNameInput" + data-test-subj="dataVisualizerFileIndexNameInput" /> @@ -70,14 +73,14 @@ export const SimpleSettings: FC = ({ id="createIndexPattern" label={ } checked={createIndexPattern === true} disabled={initialized === true} onChange={onCreateIndexPatternChange} - data-test-subj="mlFileDataVisCreateIndexPatternCheckbox" + data-test-subj="dataVisualizerFileCreateIndexPatternCheckbox" /> diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/import_summary/_import_sumary.scss b/x-pack/plugins/data_visualizer/public/application/file_data_visualizer/components/import_summary/_import_summary.scss similarity index 100% rename from x-pack/plugins/file_data_visualizer/public/application/components/import_summary/_import_sumary.scss rename to x-pack/plugins/data_visualizer/public/application/file_data_visualizer/components/import_summary/_import_summary.scss diff --git a/x-pack/plugins/data_visualizer/public/application/file_data_visualizer/components/import_summary/_index.scss b/x-pack/plugins/data_visualizer/public/application/file_data_visualizer/components/import_summary/_index.scss new file mode 100644 index 0000000000000..117e04733ed09 --- /dev/null +++ b/x-pack/plugins/data_visualizer/public/application/file_data_visualizer/components/import_summary/_index.scss @@ -0,0 +1 @@ +@import 'import_summary'; diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/import_summary/failures.tsx b/x-pack/plugins/data_visualizer/public/application/file_data_visualizer/components/import_summary/failures.tsx similarity index 95% rename from x-pack/plugins/file_data_visualizer/public/application/components/import_summary/failures.tsx rename to x-pack/plugins/data_visualizer/public/application/file_data_visualizer/components/import_summary/failures.tsx index c8f62021b7bae..184403ce22893 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/import_summary/failures.tsx +++ b/x-pack/plugins/data_visualizer/public/application/file_data_visualizer/components/import_summary/failures.tsx @@ -51,7 +51,7 @@ export class Failures extends Component { id="failureList" buttonContent={ } diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/import_summary/import_summary.tsx b/x-pack/plugins/data_visualizer/public/application/file_data_visualizer/components/import_summary/import_summary.tsx similarity index 83% rename from x-pack/plugins/file_data_visualizer/public/application/components/import_summary/import_summary.tsx rename to x-pack/plugins/data_visualizer/public/application/file_data_visualizer/components/import_summary/import_summary.tsx index f981b1fdf9f23..1d8217d8df223 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/import_summary/import_summary.tsx +++ b/x-pack/plugins/data_visualizer/public/application/file_data_visualizer/components/import_summary/import_summary.tsx @@ -45,13 +45,13 @@ export const ImportSummary: FC = ({ } color="success" iconType="check" - data-test-subj="mlFileImportSuccessCallout" + data-test-subj="dataVisualizerFileImportSuccessCallout" > @@ -62,7 +62,7 @@ export const ImportSummary: FC = ({ } @@ -71,7 +71,7 @@ export const ImportSummary: FC = ({ >

), @@ -111,7 +111,7 @@ function createDisplayItems( { title: ( ), @@ -123,7 +123,7 @@ function createDisplayItems( items.splice(1, 0, { title: ( ), @@ -135,7 +135,7 @@ function createDisplayItems( items.splice(1, 0, { title: ( ), @@ -147,7 +147,7 @@ function createDisplayItems( items.push({ title: ( ), diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/import_summary/index.ts b/x-pack/plugins/data_visualizer/public/application/file_data_visualizer/components/import_summary/index.ts similarity index 100% rename from x-pack/plugins/file_data_visualizer/public/application/components/import_summary/index.ts rename to x-pack/plugins/data_visualizer/public/application/file_data_visualizer/components/import_summary/index.ts diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/import_view/import_view.js b/x-pack/plugins/data_visualizer/public/application/file_data_visualizer/components/import_view/import_view.js similarity index 93% rename from x-pack/plugins/file_data_visualizer/public/application/components/import_view/import_view.js rename to x-pack/plugins/data_visualizer/public/application/file_data_visualizer/components/import_view/import_view.js index 0eaba4c033910..74a3638f555d0 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/import_view/import_view.js +++ b/x-pack/plugins/data_visualizer/public/application/file_data_visualizer/components/import_view/import_view.js @@ -20,8 +20,8 @@ import { import { i18n } from '@kbn/i18n'; import { debounce } from 'lodash'; -import { ResultsLinks } from '../results_links'; -import { FilebeatConfigFlyout } from '../filebeat_config_flyout'; +import { ResultsLinks } from '../../../common/components/results_links'; +import { FilebeatConfigFlyout } from '../../../common/components/filebeat_config_flyout'; import { ImportProgress, IMPORT_STATUS } from '../import_progress'; import { ImportErrors } from '../import_errors'; import { ImportSummary } from '../import_summary'; @@ -30,8 +30,8 @@ import { addCombinedFieldsToPipeline, addCombinedFieldsToMappings, getDefaultCombinedFields, -} from '../combined_fields'; -import { ExperimentalBadge } from '../experimental_badge'; +} from '../../../common/components/combined_fields'; +import { ExperimentalBadge } from '../../../common/components/experimental_badge'; const DEFAULT_TIME_FIELD = '@timestamp'; const DEFAULT_INDEX_SETTINGS = { number_of_shards: 1 }; @@ -129,7 +129,7 @@ export class ImportView extends Component { })) === false ) { errors.push( - i18n.translate('xpack.fileDataVisualizer.importView.importPermissionError', { + i18n.translate('xpack.dataVisualizer.file.importView.importPermissionError', { defaultMessage: 'You do not have permission to create or import data into index {index}.', values: { @@ -169,7 +169,7 @@ export class ImportView extends Component { } catch (error) { success = false; const parseError = i18n.translate( - 'xpack.fileDataVisualizer.importView.parseSettingsError', + 'xpack.dataVisualizer.file.importView.parseSettingsError', { defaultMessage: 'Error parsing settings:', } @@ -182,7 +182,7 @@ export class ImportView extends Component { } catch (error) { success = false; const parseError = i18n.translate( - 'xpack.fileDataVisualizer.importView.parseMappingsError', + 'xpack.dataVisualizer.file.importView.parseMappingsError', { defaultMessage: 'Error parsing mappings:', } @@ -197,7 +197,7 @@ export class ImportView extends Component { } catch (error) { success = false; const parseError = i18n.translate( - 'xpack.fileDataVisualizer.importView.parsePipelineError', + 'xpack.dataVisualizer.file.importView.parsePipelineError', { defaultMessage: 'Error parsing ingest pipeline:', } @@ -354,7 +354,7 @@ export class ImportView extends Component { const exists = await this.props.fileUpload.checkIndexExists(index); const indexNameError = exists ? ( ) : ( @@ -495,7 +495,7 @@ export class ImportView extends Component { checkingValidIndex === true; return ( - + @@ -503,18 +503,18 @@ export class ImportView extends Component { - +

  } @@ -552,10 +552,10 @@ export class ImportView extends Component { isLoading={importing} iconSide="right" fill - data-test-subj="mlFileDataVisImportButton" + data-test-subj="dataVisualizerFileImportButton" > @@ -564,7 +564,7 @@ export class ImportView extends Component { {initialized === true && importing === false && ( @@ -696,7 +696,7 @@ function isIndexNameValid(name) { ) { return ( ); @@ -713,7 +713,7 @@ function isIndexPatternNameValid(name, indexPatternNames, index) { if (indexPatternNames.find((i) => i === name)) { return ( ); @@ -729,7 +729,7 @@ function isIndexPatternNameValid(name, indexPatternNames, index) { // name should match index return ( ); diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/import_view/index.js b/x-pack/plugins/data_visualizer/public/application/file_data_visualizer/components/import_view/index.js similarity index 100% rename from x-pack/plugins/file_data_visualizer/public/application/components/import_view/index.js rename to x-pack/plugins/data_visualizer/public/application/file_data_visualizer/components/import_view/index.js diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/json_editor/index.ts b/x-pack/plugins/data_visualizer/public/application/file_data_visualizer/components/json_editor/index.ts similarity index 100% rename from x-pack/plugins/file_data_visualizer/public/application/components/json_editor/index.ts rename to x-pack/plugins/data_visualizer/public/application/file_data_visualizer/components/json_editor/index.ts diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/json_editor/json_editor.tsx b/x-pack/plugins/data_visualizer/public/application/file_data_visualizer/components/json_editor/json_editor.tsx similarity index 94% rename from x-pack/plugins/file_data_visualizer/public/application/components/json_editor/json_editor.tsx rename to x-pack/plugins/data_visualizer/public/application/file_data_visualizer/components/json_editor/json_editor.tsx index d429f8dada6ec..283e146abd00d 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/json_editor/json_editor.tsx +++ b/x-pack/plugins/data_visualizer/public/application/file_data_visualizer/components/json_editor/json_editor.tsx @@ -8,7 +8,7 @@ import React, { FC } from 'react'; import { EuiCodeEditor, EuiCodeEditorProps } from '@elastic/eui'; -import { expandLiteralStrings, XJsonMode } from '../../shared_imports'; +import { expandLiteralStrings, XJsonMode } from '../../../shared_imports'; export const EDITOR_MODE = { TEXT: 'text', JSON: 'json', XJSON: new XJsonMode() }; diff --git a/x-pack/plugins/data_visualizer/public/application/file_data_visualizer/components/results_view/_index.scss b/x-pack/plugins/data_visualizer/public/application/file_data_visualizer/components/results_view/_index.scss new file mode 100644 index 0000000000000..31f819d4f08bd --- /dev/null +++ b/x-pack/plugins/data_visualizer/public/application/file_data_visualizer/components/results_view/_index.scss @@ -0,0 +1 @@ +@import 'results_view'; diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/results_view/_results_view.scss b/x-pack/plugins/data_visualizer/public/application/file_data_visualizer/components/results_view/_results_view.scss similarity index 100% rename from x-pack/plugins/file_data_visualizer/public/application/components/results_view/_results_view.scss rename to x-pack/plugins/data_visualizer/public/application/file_data_visualizer/components/results_view/_results_view.scss diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/results_view/index.ts b/x-pack/plugins/data_visualizer/public/application/file_data_visualizer/components/results_view/index.ts similarity index 100% rename from x-pack/plugins/file_data_visualizer/public/application/components/results_view/index.ts rename to x-pack/plugins/data_visualizer/public/application/file_data_visualizer/components/results_view/index.ts diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/results_view/results_view.tsx b/x-pack/plugins/data_visualizer/public/application/file_data_visualizer/components/results_view/results_view.tsx similarity index 75% rename from x-pack/plugins/file_data_visualizer/public/application/components/results_view/results_view.tsx rename to x-pack/plugins/data_visualizer/public/application/file_data_visualizer/components/results_view/results_view.tsx index e2d21f242e4ef..ed2743fcc41d6 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/components/results_view/results_view.tsx +++ b/x-pack/plugins/data_visualizer/public/application/file_data_visualizer/components/results_view/results_view.tsx @@ -20,11 +20,11 @@ import { EuiFlexGroup, EuiFlexItem, } from '@elastic/eui'; -import { FindFileStructureResponse } from '../../../../../file_upload/common'; +import { FindFileStructureResponse } from '../../../../../../file_upload/common'; import { FileContents } from '../file_contents'; import { AnalysisSummary } from '../analysis_summary'; -import { FieldsStatsGrid } from '../fields_stats_grid'; +import { FieldsStatsGrid } from '../../../common/components/fields_stats_grid'; interface Props { data: string; @@ -44,16 +44,16 @@ export const ResultsView: FC = ({ disableButtons, }) => { return ( - + -

{fileName}

+

{fileName}

- + = ({ - + @@ -72,7 +72,7 @@ export const ResultsView: FC = ({ showEditFlyout()} disabled={disableButtons}> @@ -80,7 +80,7 @@ export const ResultsView: FC = ({ showExplanationFlyout()} disabled={disableButtons}> @@ -90,11 +90,11 @@ export const ResultsView: FC = ({ - + -

+

diff --git a/x-pack/plugins/file_data_visualizer/public/application/file_datavisualizer.tsx b/x-pack/plugins/data_visualizer/public/application/file_data_visualizer/file_data_visualizer.tsx similarity index 66% rename from x-pack/plugins/file_data_visualizer/public/application/file_datavisualizer.tsx rename to x-pack/plugins/data_visualizer/public/application/file_data_visualizer/file_data_visualizer.tsx index c8f327496842a..b3f7e8531ebf5 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/file_datavisualizer.tsx +++ b/x-pack/plugins/data_visualizer/public/application/file_data_visualizer/file_data_visualizer.tsx @@ -4,18 +4,27 @@ * 2.0; you may not use this file except in compliance with the Elastic License * 2.0. */ -import './_index.scss'; +import '../_index.scss'; import React, { FC } from 'react'; -import { KibanaContextProvider } from '../../../../../src/plugins/kibana_react/public'; -import { getCoreStart, getPluginsStart } from '../kibana_services'; +import { KibanaContextProvider } from '../../../../../../src/plugins/kibana_react/public'; +import { getCoreStart, getPluginsStart } from '../../kibana_services'; // @ts-ignore -import { FileDataVisualizerView } from './components/file_datavisualizer_view/index'; +import { FileDataVisualizerView } from './components/file_data_visualizer_view/index'; +export type FileDataVisualizerSpec = typeof FileDataVisualizer; export const FileDataVisualizer: FC = () => { const coreStart = getCoreStart(); const { data, maps, embeddable, share, security, fileUpload } = getPluginsStart(); - const services = { data, maps, embeddable, share, security, fileUpload, ...coreStart }; + const services = { + data, + maps, + embeddable, + share, + security, + fileUpload, + ...coreStart, + }; return ( diff --git a/x-pack/plugins/data_visualizer/public/application/file_data_visualizer/index.ts b/x-pack/plugins/data_visualizer/public/application/file_data_visualizer/index.ts new file mode 100644 index 0000000000000..ca87d73b6a758 --- /dev/null +++ b/x-pack/plugins/data_visualizer/public/application/file_data_visualizer/index.ts @@ -0,0 +1,8 @@ +/* + * 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. + */ + +export { FileDataVisualizer, FileDataVisualizerSpec } from './file_data_visualizer'; diff --git a/x-pack/plugins/ml/public/application/datavisualizer/stats_table/components/field_count_stats/index.ts b/x-pack/plugins/data_visualizer/public/application/index.ts similarity index 56% rename from x-pack/plugins/ml/public/application/datavisualizer/stats_table/components/field_count_stats/index.ts rename to x-pack/plugins/data_visualizer/public/application/index.ts index d841ee2959f62..6229f61be85e9 100644 --- a/x-pack/plugins/ml/public/application/datavisualizer/stats_table/components/field_count_stats/index.ts +++ b/x-pack/plugins/data_visualizer/public/application/index.ts @@ -5,9 +5,9 @@ * 2.0. */ -export { TotalFieldsCount, TotalFieldsCountProps, TotalFieldsStats } from './total_fields_count'; +export { FileDataVisualizer, FileDataVisualizerSpec } from './file_data_visualizer'; export { - MetricFieldsCount, - MetricFieldsCountProps, - MetricFieldsStats, -} from './metric_fields_count'; + IndexDataVisualizer, + IndexDataVisualizerSpec, + IndexDataVisualizerViewProps, +} from './index_data_visualizer'; diff --git a/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/components/actions_panel/actions_panel.tsx b/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/components/actions_panel/actions_panel.tsx new file mode 100644 index 0000000000000..4b208b0a59ef1 --- /dev/null +++ b/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/components/actions_panel/actions_panel.tsx @@ -0,0 +1,122 @@ +/* + * 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, { FC, useState, useEffect } from 'react'; + +import { FormattedMessage } from '@kbn/i18n/react'; +import { i18n } from '@kbn/i18n'; +import { EuiSpacer, EuiTitle } from '@elastic/eui'; +import { + DISCOVER_APP_URL_GENERATOR, + DiscoverUrlGeneratorState, +} from '../../../../../../../../src/plugins/discover/public'; +import type { IndexPattern } from '../../../../../../../../src/plugins/data/common/index_patterns'; +import { useDataVisualizerKibana } from '../../../kibana_context'; +import { useUrlState } from '../../../common/util/url_state'; +import { LinkCard } from '../../../common/components/link_card'; + +interface Props { + indexPattern: IndexPattern; + searchString?: string | { [key: string]: any }; + searchQueryLanguage?: string; +} + +// @todo: Add back create job card in a follow up PR +export const ActionsPanel: FC = ({ indexPattern, searchString, searchQueryLanguage }) => { + const [globalState] = useUrlState('_g'); + + const [discoverLink, setDiscoverLink] = useState(''); + const { + services: { + application: { capabilities }, + share: { + urlGenerators: { getUrlGenerator }, + }, + }, + } = useDataVisualizerKibana(); + + useEffect(() => { + let unmounted = false; + + const indexPatternId = indexPattern.id; + const getDiscoverUrl = async (): Promise => { + const isDiscoverAvailable = capabilities.discover?.show ?? false; + if (!isDiscoverAvailable) { + return; + } + + const state: DiscoverUrlGeneratorState = { + indexPatternId, + }; + if (searchString && searchQueryLanguage !== undefined) { + state.query = { query: searchString, language: searchQueryLanguage }; + } + if (globalState?.time) { + state.timeRange = globalState.time; + } + if (globalState?.refreshInterval) { + state.refreshInterval = globalState.refreshInterval; + } + + let discoverUrlGenerator; + try { + discoverUrlGenerator = getUrlGenerator(DISCOVER_APP_URL_GENERATOR); + } catch (error) { + // ignore error thrown when url generator is not available + return; + } + + const discoverUrl = await discoverUrlGenerator.createUrl(state); + if (!unmounted) { + setDiscoverLink(discoverUrl); + } + }; + + getDiscoverUrl(); + return () => { + unmounted = true; + }; + }, [indexPattern, searchString, searchQueryLanguage, globalState, capabilities, getUrlGenerator]); + + // Note we use display:none for the DataRecognizer section as it needs to be + // passed the recognizerResults object, and then run the recognizer check which + // controls whether the recognizer section is ultimately displayed. + return ( +
+ {discoverLink && ( + <> + +

+ +

+
+ + + } + data-test-subj="dataVisualizerViewInDiscoverCard" + /> + + )} +
+ ); +}; diff --git a/x-pack/plugins/ml/public/application/datavisualizer/index_based/components/actions_panel/index.ts b/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/components/actions_panel/index.ts similarity index 100% rename from x-pack/plugins/ml/public/application/datavisualizer/index_based/components/actions_panel/index.ts rename to x-pack/plugins/data_visualizer/public/application/index_data_visualizer/components/actions_panel/index.ts diff --git a/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/components/full_time_range_selector/full_time_range_selector.tsx b/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/components/full_time_range_selector/full_time_range_selector.tsx new file mode 100644 index 0000000000000..59f00bf00c270 --- /dev/null +++ b/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/components/full_time_range_selector/full_time_range_selector.tsx @@ -0,0 +1,73 @@ +/* + * 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, { FC } from 'react'; + +import { FormattedMessage } from '@kbn/i18n/react'; +import { Query, IndexPattern, TimefilterContract } from 'src/plugins/data/public'; +import { EuiButton } from '@elastic/eui'; +import { i18n } from '@kbn/i18n'; +import { setFullTimeRange } from './full_time_range_selector_service'; +import { useDataVisualizerKibana } from '../../../kibana_context'; + +interface Props { + timefilter: TimefilterContract; + indexPattern: IndexPattern; + disabled: boolean; + query?: Query; + callback?: (a: any) => void; +} + +// Component for rendering a button which automatically sets the range of the time filter +// to the time range of data in the index(es) mapped to the supplied Kibana index pattern or query. +export const FullTimeRangeSelector: FC = ({ + timefilter, + indexPattern, + query, + disabled, + callback, +}) => { + const { + services: { + notifications: { toasts }, + }, + } = useDataVisualizerKibana(); + + // wrapper around setFullTimeRange to allow for the calling of the optional callBack prop + async function setRange(i: IndexPattern, q?: Query) { + try { + const fullTimeRange = await setFullTimeRange(timefilter, i, q); + if (typeof callback === 'function') { + callback(fullTimeRange); + } + } catch (e) { + toasts.addDanger( + i18n.translate( + 'xpack.dataVisualizer.index.fullTimeRangeSelector.errorSettingTimeRangeNotification', + { + defaultMessage: 'An error occurred setting the time range.', + } + ) + ); + } + } + return ( + setRange(indexPattern, query)} + data-test-subj="dataVisualizerButtonUseFullData" + > + + + ); +}; diff --git a/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/components/full_time_range_selector/full_time_range_selector_service.ts b/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/components/full_time_range_selector/full_time_range_selector_service.ts new file mode 100644 index 0000000000000..198079c6ec9de --- /dev/null +++ b/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/components/full_time_range_selector/full_time_range_selector_service.ts @@ -0,0 +1,52 @@ +/* + * 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 moment from 'moment'; +import { estypes } from '@elastic/elasticsearch'; +import { Query, TimefilterContract } from 'src/plugins/data/public'; +import dateMath from '@elastic/datemath'; +import { IndexPattern } from '../../../../../../../../src/plugins/data/public'; +import { isPopulatedObject } from '../../../../../common/utils/object_utils'; +import { getTimeFieldRange } from '../../services/time_field_range'; +import { GetTimeFieldRangeResponse } from '../../../../../common/types/time_field_request'; + +export interface TimeRange { + from: number; + to: number; +} + +export async function setFullTimeRange( + timefilter: TimefilterContract, + indexPattern: IndexPattern, + query?: Query +): Promise { + const runtimeMappings = indexPattern.getComputedFields() + .runtimeFields as estypes.MappingRuntimeFields; + const resp = await getTimeFieldRange({ + index: indexPattern.title, + timeFieldName: indexPattern.timeFieldName, + query, + ...(isPopulatedObject(runtimeMappings) ? { runtimeMappings } : {}), + }); + timefilter.setTime({ + from: moment(resp.start.epoch).toISOString(), + to: moment(resp.end.epoch).toISOString(), + }); + return resp; +} + +export function getTimeFilterRange(timefilter: TimefilterContract): TimeRange { + const fromMoment = dateMath.parse(timefilter.getTime().from); + const toMoment = dateMath.parse(timefilter.getTime().to); + const from = fromMoment !== undefined ? fromMoment.valueOf() : 0; + const to = toMoment !== undefined ? toMoment.valueOf() : 0; + + return { + to, + from, + }; +} diff --git a/x-pack/plugins/file_data_visualizer/server/plugin.ts b/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/components/full_time_range_selector/index.tsx similarity index 62% rename from x-pack/plugins/file_data_visualizer/server/plugin.ts rename to x-pack/plugins/data_visualizer/public/application/index_data_visualizer/components/full_time_range_selector/index.tsx index f6893b7edaa53..c79df59ee3f69 100644 --- a/x-pack/plugins/file_data_visualizer/server/plugin.ts +++ b/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/components/full_time_range_selector/index.tsx @@ -5,9 +5,5 @@ * 2.0. */ -import { Plugin } from 'src/core/server'; - -export class FileDataVisualizerPlugin implements Plugin { - setup() {} - start() {} -} +export { FullTimeRangeSelector } from './full_time_range_selector'; +export { getTimeFilterRange, TimeRange } from './full_time_range_selector_service'; diff --git a/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/components/index_data_visualizer_view/index.ts b/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/components/index_data_visualizer_view/index.ts new file mode 100644 index 0000000000000..bcdef0966039d --- /dev/null +++ b/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/components/index_data_visualizer_view/index.ts @@ -0,0 +1,11 @@ +/* + * 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. + */ + +export { + IndexDataVisualizerViewProps, + IndexDataVisualizerView, +} from './index_data_visualizer_view'; diff --git a/x-pack/plugins/ml/public/application/datavisualizer/index_based/page.tsx b/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/components/index_data_visualizer_view/index_data_visualizer_view.tsx similarity index 79% rename from x-pack/plugins/ml/public/application/datavisualizer/index_based/page.tsx rename to x-pack/plugins/data_visualizer/public/application/index_data_visualizer/components/index_data_visualizer_view/index_data_visualizer_view.tsx index 19a4cb7b87c0f..12441bcfbbb23 100644 --- a/x-pack/plugins/ml/public/application/datavisualizer/index_based/page.tsx +++ b/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/components/index_data_visualizer_view/index_data_visualizer_view.tsx @@ -21,47 +21,51 @@ import { } from '@elastic/eui'; import { EuiTableActionsColumnType } from '@elastic/eui/src/components/basic_table/table_types'; import { FormattedMessage } from '@kbn/i18n/react'; +import { Required } from 'utility-types'; +import { i18n } from '@kbn/i18n'; import { - IFieldType, + IndexPatternField, KBN_FIELD_TYPES, - esQuery, - esKuery, UI_SETTINGS, Query, -} from '../../../../../../../src/plugins/data/public'; -import { SavedSearchSavedObject } from '../../../../common/types/kibana'; -import { NavigationMenu } from '../../components/navigation_menu'; -import { DatePickerWrapper } from '../../components/navigation_menu/date_picker_wrapper'; -import { ML_JOB_FIELD_TYPES } from '../../../../common/constants/field_types'; -import { SEARCH_QUERY_LANGUAGE, SearchQueryLanguage } from '../../../../common/constants/search'; -import { FullTimeRangeSelector } from '../../components/full_time_range_selector'; -import { mlTimefilterRefresh$ } from '../../services/timefilter_refresh_service'; -import { useMlContext } from '../../contexts/ml'; -import { kbnTypeToMLJobType } from '../../util/field_types_utils'; -import { useNotifications, useTimefilter } from '../../contexts/kibana'; -import { timeBasedIndexCheck, getQueryFromSavedSearch } from '../../util/index_utils'; -import { getTimeBucketsFromCache } from '../../util/time_buckets'; -import { usePageUrlState, useUrlState } from '../../util/url_state'; -import { ActionsPanel } from './components/actions_panel'; -import { SearchPanel } from './components/search_panel'; -import { DocumentCountContent } from './components/field_data_row/content_types/document_count_content'; -import { DataVisualizerTable, ItemIdToExpandedRowMap } from '../stats_table'; -import { FieldCountPanel } from './components/field_count_panel'; -import { ML_PAGES } from '../../../../common/constants/ml_url_generator'; -import { DataLoader } from './data_loader'; -import type { FieldRequestConfig } from './common'; -import type { DataVisualizerIndexBasedAppState } from '../../../../common/types/ml_url_generator'; -import type { OverallStats } from '../../../../common/types/datavisualizer'; -import { MlJobFieldType } from '../../../../common/types/field_types'; -import { HelpMenu } from '../../components/help_menu'; -import { useMlKibana } from '../../contexts/kibana'; -import { IndexBasedDataVisualizerExpandedRow } from './components/expanded_row'; -import { FieldVisConfig } from '../stats_table/types'; + IndexPattern, +} from '../../../../../../../../src/plugins/data/public'; +import { FullTimeRangeSelector } from '../full_time_range_selector'; +import { usePageUrlState, useUrlState } from '../../../common/util/url_state'; +import { + DataVisualizerTable, + ItemIdToExpandedRowMap, +} from '../../../common/components/stats_table'; +import { FieldVisConfig } from '../../../common/components/stats_table/types'; import type { MetricFieldsStats, TotalFieldsStats, -} from '../stats_table/components/field_count_stats'; -import { getActions } from './components/field_data_row/action_menu/actions'; +} from '../../../common/components/stats_table/components/field_count_stats'; +import { OverallStats } from '../../types/overall_stats'; +import { getActions } from '../../../common/components/field_data_row/action_menu'; +import { IndexBasedDataVisualizerExpandedRow } from '../../../common/components/expanded_row/index_based_expanded_row'; +import { DATA_VISUALIZER_INDEX_VIEWER } from '../../constants/index_data_visualizer_viewer'; +import { DataVisualizerIndexBasedAppState } from '../../types/index_data_visualizer_state'; +import { SEARCH_QUERY_LANGUAGE, SearchQueryLanguage } from '../../types/combined_query'; +import { + FieldRequestConfig, + JobFieldType, + SavedSearchSavedObject, +} from '../../../../../common/types'; +import { useDataVisualizerKibana } from '../../../kibana_context'; +import { FieldCountPanel } from '../../../common/components/field_count_panel'; +import { DocumentCountContent } from '../../../common/components/document_count_content'; +import { DataLoader } from '../../data_loader/data_loader'; +import { JOB_FIELD_TYPES } from '../../../../../common'; +import { useTimefilter } from '../../hooks/use_time_filter'; +import { kbnTypeToJobType } from '../../../common/util/field_types_utils'; +import { SearchPanel } from '../search_panel'; +import { ActionsPanel } from '../actions_panel'; +import { DatePickerWrapper } from '../../../common/components/date_picker_wrapper'; +import { dataVisualizerTimefilterRefresh$ } from '../../services/timefilter_refresh_service'; +import { HelpMenu } from '../../../common/components/help_menu'; +import { TimeBuckets } from '../../services/time_buckets'; +import { extractSearchData } from '../../utils/saved_search_utils'; interface DataVisualizerPageState { overallStats: OverallStats; @@ -112,31 +116,55 @@ export const getDefaultDataVisualizerListState = (): Required { - const mlContext = useMlContext(); - const restorableDefaults = getDefaultDataVisualizerListState(); +export interface IndexDataVisualizerViewProps { + currentIndexPattern: IndexPattern; + currentSavedSearch: SavedSearchSavedObject | null; +} +const restorableDefaults = getDefaultDataVisualizerListState(); + +export const IndexDataVisualizerView: FC = (dataVisualizerProps) => { const { - services: { lens: lensPlugin, docLinks }, - } = useMlKibana(); + services: { lens: lensPlugin, docLinks, notifications, uiSettings }, + } = useDataVisualizerKibana(); + const { toasts } = notifications; const [dataVisualizerListState, setDataVisualizerListState] = usePageUrlState( - ML_PAGES.DATA_VISUALIZER_INDEX_VIEWER, + DATA_VISUALIZER_INDEX_VIEWER, restorableDefaults ); - const [currentSavedSearch, setCurrentSavedSearch] = useState(mlContext.currentSavedSearch); + const [globalState, setGlobalState] = useUrlState('_g'); + + const [currentSavedSearch, setCurrentSavedSearch] = useState( + dataVisualizerProps.currentSavedSearch + ); + + const { currentIndexPattern } = dataVisualizerProps; + + useEffect(() => { + if (dataVisualizerProps?.currentSavedSearch !== undefined) { + setCurrentSavedSearch(dataVisualizerProps?.currentSavedSearch); + } + }, [dataVisualizerProps?.currentSavedSearch]); + + const getTimeBuckets = useCallback(() => { + return new TimeBuckets({ + [UI_SETTINGS.HISTOGRAM_MAX_BARS]: uiSettings.get(UI_SETTINGS.HISTOGRAM_MAX_BARS), + [UI_SETTINGS.HISTOGRAM_BAR_TARGET]: uiSettings.get(UI_SETTINGS.HISTOGRAM_BAR_TARGET), + dateFormat: uiSettings.get('dateFormat'), + 'dateFormat:scaled': uiSettings.get('dateFormat:scaled'), + }); + }, [uiSettings]); - const { combinedQuery, currentIndexPattern, kibanaConfig } = mlContext; const timefilter = useTimefilter({ - timeRangeSelector: currentIndexPattern.timeFieldName !== undefined, + timeRangeSelector: currentIndexPattern?.timeFieldName !== undefined, autoRefreshSelector: true, }); - const { toasts } = useNotifications(); const dataLoader = useMemo(() => new DataLoader(currentIndexPattern, toasts), [ currentIndexPattern, + toasts, ]); - const [globalState, setGlobalState] = useUrlState('_g'); useEffect(() => { if (globalState?.time !== undefined) { timefilter.setTime({ @@ -144,25 +172,42 @@ export const Page: FC = () => { to: globalState.time.to, }); } - }, [globalState?.time?.from, globalState?.time?.to]); + }, [globalState, timefilter]); + useEffect(() => { if (globalState?.refreshInterval !== undefined) { timefilter.setRefreshInterval(globalState.refreshInterval); } - }, [globalState?.refreshInterval?.pause, globalState?.refreshInterval?.value]); + }, [globalState, timefilter]); const [lastRefresh, setLastRefresh] = useState(0); useEffect(() => { - timeBasedIndexCheck(currentIndexPattern, true); - }, []); + if (!currentIndexPattern.isTimeBased()) { + toasts.addWarning({ + title: i18n.translate( + 'xpack.dataVisualizer.index.indexPatternNotBasedOnTimeSeriesNotificationTitle', + { + defaultMessage: 'The index pattern {indexPatternTitle} is not based on a time series', + values: { indexPatternTitle: currentIndexPattern.title }, + } + ), + text: i18n.translate( + 'xpack.dataVisualizer.index.indexPatternNotBasedOnTimeSeriesNotificationDescription', + { + defaultMessage: 'Anomaly detection only runs over time-based indices', + } + ), + }); + } + }, [currentIndexPattern, toasts]); // Obtain the list of non metric field types which appear in the index pattern. - let indexedFieldTypes: MlJobFieldType[] = []; - const indexPatternFields: IFieldType[] = currentIndexPattern.fields; + let indexedFieldTypes: JobFieldType[] = []; + const indexPatternFields: IndexPatternField[] = currentIndexPattern.fields; indexPatternFields.forEach((field) => { if (field.scripted !== true) { - const dataVisualizerType: MlJobFieldType | undefined = kbnTypeToMLJobType(field); + const dataVisualizerType: JobFieldType | undefined = kbnTypeToJobType(field); if (dataVisualizerType !== undefined && !indexedFieldTypes.includes(dataVisualizerType)) { indexedFieldTypes.push(dataVisualizerType); } @@ -173,7 +218,12 @@ export const Page: FC = () => { const defaults = getDefaultPageState(); const { searchQueryLanguage, searchString, searchQuery } = useMemo(() => { - const searchData = extractSearchData(currentSavedSearch); + const searchData = extractSearchData( + currentSavedSearch, + currentIndexPattern, + uiSettings.get(UI_SETTINGS.QUERY_STRING_OPTIONS) + ); + if (searchData === undefined || dataVisualizerListState.searchString !== '') { return { searchQuery: dataVisualizerListState.searchQuery, @@ -187,7 +237,8 @@ export const Page: FC = () => { searchQueryLanguage: searchData.queryLanguage, }; } - }, [currentSavedSearch, dataVisualizerListState]); + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [currentSavedSearch, currentIndexPattern, dataVisualizerListState]); const setSearchParams = (searchParams: { searchQuery: Query['query']; @@ -248,7 +299,7 @@ export const Page: FC = () => { useEffect(() => { const timeUpdateSubscription = merge( timefilter.getTimeUpdate$(), - mlTimefilterRefresh$ + dataVisualizerTimefilterRefresh$ ).subscribe(() => { setGlobalState({ time: timefilter.getTime(), @@ -263,56 +314,35 @@ export const Page: FC = () => { useEffect(() => { loadOverallStats(); + // eslint-disable-next-line react-hooks/exhaustive-deps }, [searchQuery, samplerShardSize, lastRefresh]); useEffect(() => { createMetricCards(); createNonMetricCards(); + // eslint-disable-next-line react-hooks/exhaustive-deps }, [overallStats, showEmptyFields]); useEffect(() => { loadMetricFieldStats(); + // eslint-disable-next-line react-hooks/exhaustive-deps }, [metricConfigs]); useEffect(() => { loadNonMetricFieldStats(); + // eslint-disable-next-line react-hooks/exhaustive-deps }, [nonMetricConfigs]); useEffect(() => { createMetricCards(); + // eslint-disable-next-line react-hooks/exhaustive-deps }, [metricsLoaded]); useEffect(() => { createNonMetricCards(); + // eslint-disable-next-line react-hooks/exhaustive-deps }, [nonMetricsLoaded]); - /** - * Extract query data from the saved search object. - */ - function extractSearchData(savedSearch: SavedSearchSavedObject | null) { - if (!savedSearch) { - return undefined; - } - - const { query } = getQueryFromSavedSearch(savedSearch); - const queryLanguage = query.language as SearchQueryLanguage; - const qryString = query.query; - let qry; - if (queryLanguage === SEARCH_QUERY_LANGUAGE.KUERY) { - const ast = esKuery.fromKueryExpression(qryString); - qry = esKuery.toElasticsearchQuery(ast, currentIndexPattern); - } else { - qry = esQuery.luceneStringToDsl(qryString); - esQuery.decorateQuery(qry, kibanaConfig.get(UI_SETTINGS.QUERY_STRING_OPTIONS)); - } - - return { - searchQuery: qry, - searchString: qryString, - queryLanguage, - }; - } - async function loadOverallStats() { const tf = timefilter as any; let earliest; @@ -367,7 +397,7 @@ export const Page: FC = () => { // Obtain the interval to use for date histogram aggregations // (such as the document count chart). Aim for 75 bars. - const buckets = getTimeBucketsFromCache(); + const buckets = getTimeBuckets(); const tf = timefilter as any; let earliest: number | undefined; @@ -490,7 +520,7 @@ export const Page: FC = () => { } } - function createMetricCards() { + const createMetricCards = useCallback(() => { const configs: FieldVisConfig[] = []; const aggregatableExistsFields: any[] = overallStats.aggregatableExistsFields || []; @@ -510,7 +540,7 @@ export const Page: FC = () => { // Add a config for 'document count', identified by no field name if indexpattern is time based. if (currentIndexPattern.timeFieldName !== undefined) { configs.push({ - type: ML_JOB_FIELD_TYPES.NUMBER, + type: JOB_FIELD_TYPES.NUMBER, existsInDocs: true, loading: true, aggregatable: true, @@ -538,7 +568,7 @@ export const Page: FC = () => { const metricConfig: FieldVisConfig = { ...(fieldData ? fieldData : {}), fieldFormat: currentIndexPattern.getFormatterForField(field), - type: ML_JOB_FIELD_TYPES.NUMBER, + type: JOB_FIELD_TYPES.NUMBER, loading: true, aggregatable: true, }; @@ -551,9 +581,16 @@ export const Page: FC = () => { visibleMetricsCount: metricFieldsToShow.length, }); setMetricConfigs(configs); - } + }, [ + currentIndexPattern, + dataLoader, + indexPatternFields, + metricsLoaded, + overallStats, + showEmptyFields, + ]); - function createNonMetricCards() { + const createNonMetricCards = useCallback(() => { const allNonMetricFields = indexPatternFields.filter((f) => { return ( f.type !== KBN_FIELD_TYPES.NUMBER && @@ -618,7 +655,7 @@ export const Page: FC = () => { // Map the field type from the Kibana index pattern to the field type // used in the data visualizer. - const dataVisualizerType = kbnTypeToMLJobType(field); + const dataVisualizerType = kbnTypeToJobType(field); if (dataVisualizerType !== undefined) { nonMetricConfig.type = dataVisualizerType; } else { @@ -632,7 +669,14 @@ export const Page: FC = () => { }); setNonMetricConfigs(configs); - } + }, [ + currentIndexPattern, + dataLoader, + indexPatternFields, + nonMetricsLoaded, + overallStats, + showEmptyFields, + ]); const wizardPanelWidth = '280px'; @@ -688,7 +732,7 @@ export const Page: FC = () => { return m; }, {} as ItemIdToExpandedRowMap); }, - [currentIndexPattern, searchQuery] + [currentIndexPattern, searchQueryLanguage, searchString] ); // Inject custom action column for the index based visualizer @@ -701,7 +745,7 @@ export const Page: FC = () => { const actionColumn: EuiTableActionsColumnType = { name: ( ), @@ -715,8 +759,7 @@ export const Page: FC = () => { const helpLink = docLinks.links.ml.guide; return ( - - + @@ -726,14 +769,15 @@ export const Page: FC = () => {

{currentIndexPattern.title}

- + {currentIndexPattern.timeFieldName !== undefined && ( )} @@ -804,6 +848,7 @@ export const Page: FC = () => { + ); diff --git a/x-pack/plugins/ml/public/application/datavisualizer/index_based/components/search_panel/field_name_filter.tsx b/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/components/search_panel/field_name_filter.tsx similarity index 82% rename from x-pack/plugins/ml/public/application/datavisualizer/index_based/components/search_panel/field_name_filter.tsx rename to x-pack/plugins/data_visualizer/public/application/index_data_visualizer/components/search_panel/field_name_filter.tsx index ab8f36761a116..634bf25dbc8a0 100644 --- a/x-pack/plugins/ml/public/application/datavisualizer/index_based/components/search_panel/field_name_filter.tsx +++ b/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/components/search_panel/field_name_filter.tsx @@ -7,8 +7,8 @@ import React, { FC, useMemo } from 'react'; import { i18n } from '@kbn/i18n'; -import { Option, MultiSelectPicker } from '../../../../components/multi_select_picker'; -import type { OverallStats } from '../../../../../../common/types/datavisualizer'; +import { Option, MultiSelectPicker } from '../../../common/components/multi_select_picker'; +import { OverallStats } from '../../types/overall_stats'; interface Props { overallStats: OverallStats; @@ -41,11 +41,11 @@ export const DataVisualizerFieldNamesFilter: FC = ({ }); } return options; - }, [overallStats]); + }, [overallStats, showEmptyFields]); const fieldNameTitle = useMemo( () => - i18n.translate('xpack.ml.dataVisualizer.indexBased.fieldNameSelect', { + i18n.translate('xpack.dataVisualizer.index.fieldNameSelect', { defaultMessage: 'Field name', }), [] @@ -57,7 +57,7 @@ export const DataVisualizerFieldNamesFilter: FC = ({ options={items} onChange={setVisibleFieldNames} checkedOptions={visibleFieldNames} - dataTestSubj={'mlDataVisualizerFieldNameSelect'} + dataTestSubj={'dataVisualizerFieldNameSelect'} /> ); }; diff --git a/x-pack/plugins/ml/public/application/datavisualizer/index_based/components/search_panel/field_type_filter.tsx b/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/components/search_panel/field_type_filter.tsx similarity index 59% rename from x-pack/plugins/ml/public/application/datavisualizer/index_based/components/search_panel/field_type_filter.tsx rename to x-pack/plugins/data_visualizer/public/application/index_data_visualizer/components/search_panel/field_type_filter.tsx index 15ddf00c4e1d3..4f9de09dc670e 100644 --- a/x-pack/plugins/ml/public/application/datavisualizer/index_based/components/search_panel/field_type_filter.tsx +++ b/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/components/search_panel/field_type_filter.tsx @@ -8,25 +8,24 @@ import React, { FC, useMemo } from 'react'; import { EuiFlexGroup, EuiFlexItem } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; -import { Option, MultiSelectPicker } from '../../../../components/multi_select_picker'; -import { FieldTypeIcon } from '../../../../components/field_type_icon'; -import { ML_JOB_FIELD_TYPES } from '../../../../../../common/constants/field_types'; -import type { MlJobFieldType } from '../../../../../../common/types/field_types'; +import { JOB_FIELD_TYPES, JobFieldType } from '../../../../../common'; +import { FieldTypeIcon } from '../../../common/components/field_type_icon'; +import { MultiSelectPicker, Option } from '../../../common/components/multi_select_picker'; const ML_JOB_FIELD_TYPES_OPTIONS = { - [ML_JOB_FIELD_TYPES.BOOLEAN]: { name: 'Boolean', icon: 'tokenBoolean' }, - [ML_JOB_FIELD_TYPES.DATE]: { name: 'Date', icon: 'tokenDate' }, - [ML_JOB_FIELD_TYPES.GEO_POINT]: { name: 'Geo point', icon: 'tokenGeo' }, - [ML_JOB_FIELD_TYPES.GEO_SHAPE]: { name: 'Geo shape', icon: 'tokenGeo' }, - [ML_JOB_FIELD_TYPES.IP]: { name: 'IP address', icon: 'tokenIP' }, - [ML_JOB_FIELD_TYPES.KEYWORD]: { name: 'Keyword', icon: 'tokenKeyword' }, - [ML_JOB_FIELD_TYPES.NUMBER]: { name: 'Number', icon: 'tokenNumber' }, - [ML_JOB_FIELD_TYPES.TEXT]: { name: 'Text', icon: 'tokenString' }, - [ML_JOB_FIELD_TYPES.UNKNOWN]: { name: 'Unknown' }, + [JOB_FIELD_TYPES.BOOLEAN]: { name: 'Boolean', icon: 'tokenBoolean' }, + [JOB_FIELD_TYPES.DATE]: { name: 'Date', icon: 'tokenDate' }, + [JOB_FIELD_TYPES.GEO_POINT]: { name: 'Geo point', icon: 'tokenGeo' }, + [JOB_FIELD_TYPES.GEO_SHAPE]: { name: 'Geo shape', icon: 'tokenGeo' }, + [JOB_FIELD_TYPES.IP]: { name: 'IP address', icon: 'tokenIP' }, + [JOB_FIELD_TYPES.KEYWORD]: { name: 'Keyword', icon: 'tokenKeyword' }, + [JOB_FIELD_TYPES.NUMBER]: { name: 'Number', icon: 'tokenNumber' }, + [JOB_FIELD_TYPES.TEXT]: { name: 'Text', icon: 'tokenString' }, + [JOB_FIELD_TYPES.UNKNOWN]: { name: 'Unknown' }, }; export const DatavisualizerFieldTypeFilter: FC<{ - indexedFieldTypes: MlJobFieldType[]; + indexedFieldTypes: JobFieldType[]; setVisibleFieldTypes(q: string[]): void; visibleFieldTypes: string[]; }> = ({ indexedFieldTypes, setVisibleFieldTypes, visibleFieldTypes }) => { @@ -56,7 +55,7 @@ export const DatavisualizerFieldTypeFilter: FC<{ }, [indexedFieldTypes]); const fieldTypeTitle = useMemo( () => - i18n.translate('xpack.ml.dataVisualizer.indexBased.fieldTypeSelect', { + i18n.translate('xpack.dataVisualizer.index.fieldTypeSelect', { defaultMessage: 'Field type', }), [] @@ -67,7 +66,7 @@ export const DatavisualizerFieldTypeFilter: FC<{ options={options} onChange={setVisibleFieldTypes} checkedOptions={visibleFieldTypes} - dataTestSubj={'mlDataVisualizerFieldTypeSelect'} + dataTestSubj={'dataVisualizerFieldTypeSelect'} /> ); }; diff --git a/x-pack/plugins/ml/public/application/datavisualizer/index_based/components/search_panel/index.ts b/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/components/search_panel/index.ts similarity index 100% rename from x-pack/plugins/ml/public/application/datavisualizer/index_based/components/search_panel/index.ts rename to x-pack/plugins/data_visualizer/public/application/index_data_visualizer/components/search_panel/index.ts diff --git a/x-pack/plugins/ml/public/application/datavisualizer/index_based/components/search_panel/search_panel.tsx b/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/components/search_panel/search_panel.tsx similarity index 85% rename from x-pack/plugins/ml/public/application/datavisualizer/index_based/components/search_panel/search_panel.tsx rename to x-pack/plugins/data_visualizer/public/application/index_data_visualizer/components/search_panel/search_panel.tsx index 1988ac39d0a90..8694e1c952dcc 100644 --- a/x-pack/plugins/ml/public/application/datavisualizer/index_based/components/search_panel/search_panel.tsx +++ b/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/components/search_panel/search_panel.tsx @@ -5,30 +5,25 @@ * 2.0. */ -import React, { FC, useState } from 'react'; - +import React, { FC, useEffect, useState } from 'react'; import { EuiCode, EuiFlexItem, EuiFlexGroup, EuiInputPopover } from '@elastic/eui'; - import { i18n } from '@kbn/i18n'; - -import { IndexPattern } from '../../../../../../../../../src/plugins/data/public'; - -import { - SEARCH_QUERY_LANGUAGE, - ErrorMessage, - SearchQueryLanguage, -} from '../../../../../../common/constants/search'; - import { esKuery, esQuery, Query, QueryStringInput, -} from '../../../../../../../../../src/plugins/data/public'; +} from '../../../../../../../../src/plugins/data/public'; import { ShardSizeFilter } from './shard_size_select'; import { DataVisualizerFieldNamesFilter } from './field_name_filter'; import { DatavisualizerFieldTypeFilter } from './field_type_filter'; -import { MlJobFieldType } from '../../../../../../common/types/field_types'; +import { IndexPattern } from '../../../../../../../../src/plugins/data/common/index_patterns/index_patterns'; +import { JobFieldType } from '../../../../../common/types'; +import { + ErrorMessage, + SEARCH_QUERY_LANGUAGE, + SearchQueryLanguage, +} from '../../types/combined_query'; interface Props { indexPattern: IndexPattern; @@ -38,7 +33,7 @@ interface Props { samplerShardSize: number; setSamplerShardSize(s: number): void; overallStats: any; - indexedFieldTypes: MlJobFieldType[]; + indexedFieldTypes: JobFieldType[]; setVisibleFieldTypes(q: string[]): void; visibleFieldTypes: string[]; setVisibleFieldNames(q: string[]): void; @@ -77,6 +72,13 @@ export const SearchPanel: FC = ({ }); const [errorMessage, setErrorMessage] = useState(undefined); + useEffect(() => { + setSearchInput({ + query: searchString || '', + language: searchQueryLanguage, + }); + }, [searchQueryLanguage, searchString]); + const searchHandler = (query: Query) => { let filterQuery; try { @@ -103,7 +105,7 @@ export const SearchPanel: FC = ({ const searchChangeHandler = (query: Query) => setSearchInput(query); return ( - + = ({ onChange={searchChangeHandler} onSubmit={searchHandler} placeholder={i18n.translate( - 'xpack.ml.datavisualizer.searchPanel.queryBarPlaceholderText', + 'xpack.dataVisualizer.searchPanel.queryBarPlaceholderText', { defaultMessage: 'Search… (e.g. status:200 AND extension:"PHP")', } )} disableAutoFocus={true} - dataTestSubj="mlDataVisualizerQueryInput" + dataTestSubj="dataVisualizerQueryInput" languageSwitcherPopoverAnchorPosition="rightDown" /> } @@ -130,7 +132,7 @@ export const SearchPanel: FC = ({ > {i18n.translate( - 'xpack.ml.datavisualizer.searchPanel.invalidKuerySyntaxErrorMessageQueryBar', + 'xpack.dataVisualizer.searchPanel.invalidKuerySyntaxErrorMessageQueryBar', { defaultMessage: 'Invalid query', } diff --git a/x-pack/plugins/ml/public/application/datavisualizer/index_based/components/search_panel/shard_size_select.tsx b/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/components/search_panel/shard_size_select.tsx similarity index 77% rename from x-pack/plugins/ml/public/application/datavisualizer/index_based/components/search_panel/shard_size_select.tsx rename to x-pack/plugins/data_visualizer/public/application/index_data_visualizer/components/search_panel/shard_size_select.tsx index 5351d3467020f..85f3d2b596105 100644 --- a/x-pack/plugins/ml/public/application/datavisualizer/index_based/components/search_panel/shard_size_select.tsx +++ b/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/components/search_panel/shard_size_select.tsx @@ -20,17 +20,17 @@ const searchSizeOptions = [1000, 5000, 10000, 100000, -1].map((v) => { value: String(v), inputDisplay: v > 0 ? ( - + {v} }} /> ) : ( - + @@ -46,15 +46,15 @@ export const ShardSizeFilter: FC = ({ samplerShardSize, setSamplerShardSi options={searchSizeOptions} valueOfSelected={String(samplerShardSize)} onChange={(value) => setSamplerShardSize(+value)} - aria-label={i18n.translate('xpack.ml.datavisualizer.searchPanel.sampleSizeAriaLabel', { + aria-label={i18n.translate('xpack.dataVisualizer.searchPanel.sampleSizeAriaLabel', { defaultMessage: 'Select number of documents to sample', })} - data-test-subj="mlDataVisualizerShardSizeSelect" + data-test-subj="dataVisualizerShardSizeSelect" /> | null | undefined; + +const MAX_EXAMPLES_DEFAULT: number = 10; + +export class DataLoader { + private _indexPattern: IndexPattern; + private _runtimeMappings: estypes.MappingRuntimeFields; + private _indexPatternTitle: IndexPatternTitle = ''; + private _maxExamples: number = MAX_EXAMPLES_DEFAULT; + private _toastNotifications: CoreSetup['notifications']['toasts']; + + constructor( + indexPattern: IndexPattern, + toastNotifications: CoreSetup['notifications']['toasts'] + ) { + this._indexPattern = indexPattern; + this._runtimeMappings = this._indexPattern.getComputedFields() + .runtimeFields as estypes.MappingRuntimeFields; + this._indexPatternTitle = indexPattern.title; + this._toastNotifications = toastNotifications; + } + + async loadOverallData( + query: string | SavedSearchQuery, + samplerShardSize: number, + earliest: number | undefined, + latest: number | undefined + ): Promise { + const aggregatableFields: string[] = []; + const nonAggregatableFields: string[] = []; + this._indexPattern.fields.forEach((field) => { + const fieldName = field.displayName !== undefined ? field.displayName : field.name; + if (this.isDisplayField(fieldName) === true) { + if (field.aggregatable === true && field.type !== KBN_FIELD_TYPES.GEO_SHAPE) { + aggregatableFields.push(fieldName); + } else { + nonAggregatableFields.push(fieldName); + } + } + }); + + // Need to find: + // 1. List of aggregatable fields that do exist in docs + // 2. List of aggregatable fields that do not exist in docs + // 3. List of non-aggregatable fields that do exist in docs. + // 4. List of non-aggregatable fields that do not exist in docs. + const stats = await getVisualizerOverallStats({ + indexPatternTitle: this._indexPatternTitle, + query, + timeFieldName: this._indexPattern.timeFieldName, + samplerShardSize, + earliest, + latest, + aggregatableFields, + nonAggregatableFields, + runtimeMappings: this._runtimeMappings, + }); + + return stats; + } + + async loadFieldStats( + query: string | SavedSearchQuery, + samplerShardSize: number, + earliest: number | undefined, + latest: number | undefined, + fields: FieldRequestConfig[], + interval?: number + ): Promise { + const stats = await getVisualizerFieldStats({ + indexPatternTitle: this._indexPatternTitle, + query, + timeFieldName: this._indexPattern.timeFieldName, + earliest, + latest, + samplerShardSize, + interval, + fields, + maxExamples: this._maxExamples, + runtimeMappings: this._runtimeMappings, + }); + + return stats; + } + + displayError(err: any) { + if (err.statusCode === 500) { + this._toastNotifications.addError(err, { + title: i18n.translate('xpack.dataVisualizer.index.dataLoader.internalServerErrorMessage', { + defaultMessage: + 'Error loading data in index {index}. {message}. ' + + 'The request may have timed out. Try using a smaller sample size or narrowing the time range.', + values: { + index: this._indexPattern.title, + message: err.message, + }, + }), + }); + } else { + this._toastNotifications.addError(err, { + title: i18n.translate('xpack.dataVisualizer.index.errorLoadingDataMessage.', { + defaultMessage: 'Error loading data in index {index}. {message}', + values: { + index: this._indexPattern.title, + message: err.message, + }, + }), + }); + } + } + + public set maxExamples(max: number) { + this._maxExamples = max; + } + + public get maxExamples(): number { + return this._maxExamples; + } + + // Returns whether the field with the specified name should be displayed, + // as certain fields such as _id and _source should be omitted from the view. + public isDisplayField(fieldName: string): boolean { + return !OMIT_FIELDS.includes(fieldName); + } +} diff --git a/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/hooks/use_time_filter.ts b/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/hooks/use_time_filter.ts new file mode 100644 index 0000000000000..132d03c81c0e6 --- /dev/null +++ b/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/hooks/use_time_filter.ts @@ -0,0 +1,38 @@ +/* + * 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 { useEffect } from 'react'; +import { useDataVisualizerKibana } from '../../kibana_context'; + +interface UseTimefilterOptions { + timeRangeSelector?: boolean; + autoRefreshSelector?: boolean; +} + +export const useTimefilter = ({ + timeRangeSelector, + autoRefreshSelector, +}: UseTimefilterOptions = {}) => { + const { services } = useDataVisualizerKibana(); + const { timefilter } = services.data.query.timefilter; + + useEffect(() => { + if (timeRangeSelector === true) { + timefilter.enableTimeRangeSelector(); + } else if (timeRangeSelector === false) { + timefilter.disableTimeRangeSelector(); + } + + if (autoRefreshSelector === true) { + timefilter.enableAutoRefreshSelector(); + } else if (autoRefreshSelector === false) { + timefilter.disableAutoRefreshSelector(); + } + }, [timeRangeSelector, autoRefreshSelector, timefilter]); + + return timefilter; +}; diff --git a/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/index.ts b/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/index.ts new file mode 100644 index 0000000000000..77b6f9b5ab18c --- /dev/null +++ b/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/index.ts @@ -0,0 +1,9 @@ +/* + * 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. + */ + +export { IndexDataVisualizer, IndexDataVisualizerSpec } from './index_data_visualizer'; +export type { IndexDataVisualizerViewProps } from './components/index_data_visualizer_view'; diff --git a/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/index_data_visualizer.tsx b/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/index_data_visualizer.tsx new file mode 100644 index 0000000000000..82a9b93b31a71 --- /dev/null +++ b/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/index_data_visualizer.tsx @@ -0,0 +1,200 @@ +/* + * 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 '../_index.scss'; +import React, { FC, useCallback, useEffect, useState } from 'react'; +import { useHistory, useLocation } from 'react-router-dom'; +import { parse, stringify } from 'query-string'; +import { isEqual } from 'lodash'; +// @ts-ignore +import { encode } from 'rison-node'; +import { SimpleSavedObject } from 'kibana/public'; +import { i18n } from '@kbn/i18n'; +import { KibanaContextProvider } from '../../../../../../src/plugins/kibana_react/public'; +import { getCoreStart, getPluginsStart } from '../../kibana_services'; +import { + IndexDataVisualizerViewProps, + IndexDataVisualizerView, +} from './components/index_data_visualizer_view'; +import { + Accessor, + Provider as UrlStateContextProvider, + Dictionary, + parseUrlState, + SetUrlState, + getNestedProperty, + isRisonSerializationRequired, +} from '../common/util/url_state'; +import { useDataVisualizerKibana } from '../kibana_context'; +import { IndexPattern } from '../../../../../../src/plugins/data/common/index_patterns/index_patterns'; + +export type IndexDataVisualizerSpec = typeof IndexDataVisualizer; + +export interface DataVisualizerUrlStateContextProviderProps { + IndexDataVisualizerComponent: FC; +} + +export const DataVisualizerUrlStateContextProvider: FC = ({ + IndexDataVisualizerComponent, +}) => { + const { + services: { + data: { indexPatterns }, + savedObjects: { client: savedObjectsClient }, + notifications: { toasts }, + }, + } = useDataVisualizerKibana(); + const history = useHistory(); + + const [currentIndexPattern, setCurrentIndexPattern] = useState( + undefined + ); + const [currentSavedSearch, setCurrentSavedSearch] = useState | null>( + null + ); + const { search: searchString } = useLocation(); + + useEffect(() => { + const prevSearchString = searchString; + const parsedQueryString = parse(prevSearchString, { sort: false }); + + const getIndexPattern = async () => { + if (typeof parsedQueryString?.index === 'string') { + const indexPattern = await indexPatterns.get(parsedQueryString.index); + setCurrentIndexPattern(indexPattern); + } + + if (typeof parsedQueryString?.savedSearchId === 'string') { + const savedSearchId = parsedQueryString.savedSearchId; + try { + const savedSearch = await savedObjectsClient.get('search', savedSearchId); + const indexPatternId = savedSearch.references.find((ref) => ref.type === 'index-pattern') + ?.id; + if (indexPatternId !== undefined) { + try { + const indexPattern = await indexPatterns.get(indexPatternId); + setCurrentIndexPattern(indexPattern); + } catch (e) { + toasts.addError(e, { + title: i18n.translate('xpack.dataVisualizer.index.indexPatternErrorMessage', { + defaultMessage: 'Error finding index pattern', + }), + }); + } + } + setCurrentSavedSearch(savedSearch); + } catch (e) { + toasts.addError(e, { + title: i18n.translate('xpack.dataVisualizer.index.savedSearchErrorMessage', { + defaultMessage: 'Error retrieving saved search {savedSearchId}', + values: { savedSearchId }, + }), + }); + } + } + }; + getIndexPattern(); + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [savedObjectsClient, toasts, indexPatterns]); + + const setUrlState: SetUrlState = useCallback( + ( + accessor: Accessor, + attribute: string | Dictionary, + value?: any, + replaceState?: boolean + ) => { + const prevSearchString = searchString; + const urlState = parseUrlState(prevSearchString); + const parsedQueryString = parse(prevSearchString, { sort: false }); + + if (!Object.prototype.hasOwnProperty.call(urlState, accessor)) { + urlState[accessor] = {}; + } + + if (typeof attribute === 'string') { + if (isEqual(getNestedProperty(urlState, `${accessor}.${attribute}`), value)) { + return prevSearchString; + } + + urlState[accessor][attribute] = value; + } else { + const attributes = attribute; + Object.keys(attributes).forEach((a) => { + urlState[accessor][a] = attributes[a]; + }); + } + + try { + const oldLocationSearchString = stringify(parsedQueryString, { + sort: false, + encode: false, + }); + + Object.keys(urlState).forEach((a) => { + if (isRisonSerializationRequired(a)) { + parsedQueryString[a] = encode(urlState[a]); + } else { + parsedQueryString[a] = urlState[a]; + } + }); + const newLocationSearchString = stringify(parsedQueryString, { + sort: false, + encode: false, + }); + + if (oldLocationSearchString !== newLocationSearchString) { + const newSearchString = stringify(parsedQueryString, { sort: false }); + if (replaceState) { + history.replace({ search: newSearchString }); + } else { + history.push({ search: newSearchString }); + } + } + } catch (error) { + // eslint-disable-next-line no-console + console.error('Could not save url state', error); + } + }, + [history, searchString] + ); + + return ( + + {currentIndexPattern ? ( + + ) : ( +
+ )} + + ); +}; + +export const IndexDataVisualizer: FC = () => { + const coreStart = getCoreStart(); + const { data, maps, embeddable, share, security, fileUpload, lens } = getPluginsStart(); + const services = { + data, + maps, + embeddable, + share, + security, + fileUpload, + lens, + ...coreStart, + }; + + return ( + + + + ); +}; diff --git a/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/services/time_buckets.d.ts b/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/services/time_buckets.d.ts new file mode 100644 index 0000000000000..9a5410918a099 --- /dev/null +++ b/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/services/time_buckets.d.ts @@ -0,0 +1,45 @@ +/* + * 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 { Moment } from 'moment'; + +export interface TimeRangeBounds { + min?: Moment; + max?: Moment; +} + +export declare interface TimeBucketsInterval { + asMilliseconds: () => number; + asSeconds: () => number; + expression: string; +} + +export interface TimeBucketsConfig { + 'histogram:maxBars': number; + 'histogram:barTarget': number; + dateFormat: string; + 'dateFormat:scaled': string[][]; +} + +export declare class TimeBuckets { + constructor(timeBucketsConfig: TimeBucketsConfig); + public setBarTarget(barTarget: number): void; + public setMaxBars(maxBars: number): void; + public setInterval(interval: string): void; + public setBounds(bounds: TimeRangeBounds): void; + public getBounds(): { min: any; max: any }; + public getInterval(): TimeBucketsInterval; + public getScaledDateFormat(): string; +} + +export declare function getTimeBucketsFromCache(): InstanceType; + +export declare function getBoundsRoundedToInterval( + bounds: TimeRangeBounds, + interval: TimeBucketsInterval, + inclusiveEnd?: boolean +): Required; diff --git a/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/services/time_buckets.js b/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/services/time_buckets.js new file mode 100644 index 0000000000000..6a68ebeef7c30 --- /dev/null +++ b/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/services/time_buckets.js @@ -0,0 +1,515 @@ +/* + * 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 { FIELD_FORMAT_IDS, UI_SETTINGS } from '../../../../../../../src/plugins/data/common'; +import { ary, assign, isPlainObject, isString, sortBy } from 'lodash'; +import moment from 'moment'; +import dateMath from '@elastic/datemath'; +import { parseInterval } from '../../common/util/parse_interval'; + +const { duration: d } = moment; + +export function timeBucketsCalcAutoIntervalProvider() { + // Note there is a current issue with Kibana (Kibana issue #9184) + // which means we can't round to, for example, 2 week or 3 week buckets, + // so there is a large gap between the 1 week and 1 month rule. + const roundingRules = [ + [d(500, 'ms'), d(100, 'ms')], + [d(5, 'second'), d(1, 'second')], + [d(10, 'second'), d(5, 'second')], + [d(15, 'second'), d(10, 'second')], + [d(30, 'second'), d(15, 'second')], + [d(1, 'minute'), d(30, 'second')], + [d(5, 'minute'), d(1, 'minute')], + [d(10, 'minute'), d(5, 'minute')], + [d(15, 'minute'), d(10, 'minute')], + [d(30, 'minute'), d(10, 'minute')], + [d(1, 'hour'), d(30, 'minute')], + [d(2, 'hour'), d(1, 'hour')], + [d(4, 'hour'), d(2, 'hour')], + [d(6, 'hour'), d(4, 'hour')], + [d(8, 'hour'), d(6, 'hour')], + [d(12, 'hour'), d(8, 'hour')], + [d(24, 'hour'), d(12, 'hour')], + [d(2, 'd'), d(1, 'd')], + [d(4, 'd'), d(2, 'd')], + [d(1, 'week'), d(4, 'd')], + //[ d(2, 'week'), d(1, 'week') ], + //[ d(1, 'month'), d(2, 'week') ], + [d(1, 'month'), d(1, 'week')], + [d(1, 'year'), d(1, 'month')], + [Infinity, d(1, 'year')], + ]; + + const revRoundingRules = roundingRules.slice(0).reverse(); + + function find(rules, check, last) { + function pick(buckets, duration) { + const target = duration / buckets; + let lastResp; + + for (let i = 0; i < rules.length; i++) { + const rule = rules[i]; + const resp = check(rule[0], rule[1], target); + + if (resp == null) { + if (!last) { + continue; + } + if (lastResp) { + return lastResp; + } + break; + } + + if (!last) { + return resp; + } + lastResp = resp; + } + + // fallback to just a number of milliseconds, ensure ms is >= 1 + const ms = Math.max(Math.floor(target), 1); + return moment.duration(ms, 'ms'); + } + + return function (buckets, duration) { + const interval = pick(buckets, duration); + if (interval) { + return moment.duration(interval._data); + } + }; + } + + return { + near: find( + revRoundingRules, + function near(upperBound, lowerBound, target) { + // upperBound - first duration in rule + // lowerBound - second duration in rule + // target - target interval in milliseconds. + if (upperBound > target) { + if (upperBound === Infinity) { + return lowerBound; + } + + const boundMs = upperBound.asMilliseconds(); + const intervalMs = lowerBound.asMilliseconds(); + const retInterval = + Math.abs(boundMs - target) <= Math.abs(intervalMs) ? upperBound : lowerBound; + return retInterval; + } + }, + true + ), + + lessThan: find(revRoundingRules, function (upperBound, lowerBound, target) { + // upperBound - first duration in rule + // lowerBound - second duration in rule + // target - target interval in milliseconds. Must not return intervals less than this duration. + if (lowerBound < target) { + return upperBound !== Infinity ? upperBound : lowerBound; + } + }), + + atLeast: find(revRoundingRules, function atLeast(upperBound, lowerBound, target) { + // Unmodified from Kibana ui/time_buckets/calc_auto_interval.js. + if (lowerBound <= target) { + return lowerBound; + } + }), + }; +} + +const unitsDesc = dateMath.unitsDesc; + +// Index of the list of time interval units at which larger units (i.e. weeks, months, years) need +// need to be converted to multiples of the largest unit supported in ES aggregation intervals (i.e. days). +// Note that similarly the largest interval supported for ML bucket spans is 'd'. +const timeUnitsMaxSupportedIndex = unitsDesc.indexOf('w'); + +const calcAuto = timeBucketsCalcAutoIntervalProvider(); + +/** + * Helper object for wrapping the concept of an "Interval", which + * describes a timespan that will separate buckets of time, + * for example the interval between points on a time series chart. + */ +export function TimeBuckets(timeBucketsConfig, fieldFormats) { + this._timeBucketsConfig = timeBucketsConfig; + this._fieldFormats = fieldFormats; + this.barTarget = this._timeBucketsConfig[UI_SETTINGS.HISTOGRAM_BAR_TARGET]; + this.maxBars = this._timeBucketsConfig[UI_SETTINGS.HISTOGRAM_MAX_BARS]; +} + +/** + * Set the target number of bars. + * + * @param {number} bt - target number of bars (buckets). + * + * @returns {undefined} + */ +TimeBuckets.prototype.setBarTarget = function (bt) { + this.barTarget = bt; +}; + +/** + * Set the maximum number of bars. + * + * @param {number} mb - maximum number of bars (buckets). + * + * @returns {undefined} + */ +TimeBuckets.prototype.setMaxBars = function (mb) { + this.maxBars = mb; +}; + +/** + * Set the bounds that these buckets are expected to cover. + * This is required to support interval "auto" as well + * as interval scaling. + * + * @param {object} input - an object with properties min and max, + * representing the edges for the time span + * we should cover + * + * @returns {undefined} + */ +TimeBuckets.prototype.setBounds = function (input) { + if (!input) return this.clearBounds(); + + let bounds; + if (isPlainObject(input)) { + // accept the response from timefilter.getActiveBounds() + bounds = [input.min, input.max]; + } else { + bounds = Array.isArray(input) ? input : []; + } + + const moments = sortBy(bounds.map(ary(moment, 1)), Number); + + const valid = moments.length === 2 && moments.every(isValidMoment); + if (!valid) { + this.clearBounds(); + throw new Error('invalid bounds set: ' + input); + } + + this._lb = moments.shift(); + this._ub = moments.pop(); + if (this.getDuration().asSeconds() < 0) { + throw new TypeError('Intervals must be positive'); + } +}; + +/** + * Clear the stored bounds + * + * @return {undefined} + */ +TimeBuckets.prototype.clearBounds = function () { + this._lb = this._ub = null; +}; + +/** + * Check to see if we have received bounds yet + * + * @return {Boolean} + */ +TimeBuckets.prototype.hasBounds = function () { + return isValidMoment(this._ub) && isValidMoment(this._lb); +}; + +/** + * Return the current bounds, if we have any. + * + * Note that this does not clone the bounds, so editing them may have unexpected side-effects. + * Always call bounds.min.clone() before editing. + * + * @return {object|undefined} - If bounds are not defined, this + * returns undefined, else it returns the bounds + * for these buckets. This object has two props, + * min and max. Each property will be a moment() + * object + */ +TimeBuckets.prototype.getBounds = function () { + if (!this.hasBounds()) return; + return { + min: this._lb, + max: this._ub, + }; +}; + +/** + * Get a moment duration object representing + * the distance between the bounds, if the bounds + * are set. + * + * @return {moment.duration|undefined} + */ +TimeBuckets.prototype.getDuration = function () { + if (!this.hasBounds()) return; + return moment.duration(this._ub - this._lb, 'ms'); +}; + +/** + * Update the interval at which buckets should be + * generated. + * + * Input can be one of the following: + * - "auto" + * - an interval String, such as 7d, 1h or 30m which can be parsed to a moment duration using ml/common/util/parse_interval + * - a moment.duration object. + * + * @param {string|moment.duration} input - see desc + */ +TimeBuckets.prototype.setInterval = function (input) { + // Preserve the original units because they're lost when the interval is converted to a + // moment duration object. + this.originalInterval = input; + + let interval = input; + + if (!interval || interval === 'auto') { + this._i = 'auto'; + return; + } + + if (isString(interval)) { + input = interval; + interval = parseInterval(interval); + if (+interval === 0) { + interval = null; + } + } + + // If the value wasn't converted to a duration, and isn't already a duration, we have a problem + if (!moment.isDuration(interval)) { + throw new TypeError('"' + input + '" is not a valid interval.'); + } + + this._i = interval; +}; + +/** + * Get the interval for the buckets. If the + * number of buckets created by the interval set + * is larger than config:histogram:maxBars then the + * interval will be scaled up. If the number of buckets + * created is less than one, the interval is scaled back. + * + * The interval object returned is a moment.duration + * object that has been decorated with the following + * properties. + * + * interval.description: a text description of the interval. + * designed to be used list "field per {{ desc }}". + * - "minute" + * - "10 days" + * - "3 years" + * + * interval.expr: the elasticsearch expression that creates this + * interval. If the interval does not properly form an elasticsearch + * expression it will be forced into one. + * + * interval.scaled: the interval was adjusted to + * accommodate the maxBars setting. + * + * interval.scale: the number that y-values should be + * multiplied by + * + * interval.scaleDescription: a description that reflects + * the values which will be produced by using the + * interval.scale. + * + * + * @return {[type]} [description] + */ +TimeBuckets.prototype.getInterval = function () { + const self = this; + const duration = self.getDuration(); + return decorateInterval(maybeScaleInterval(readInterval()), duration); + + // either pull the interval from state or calculate the auto-interval + function readInterval() { + const interval = self._i; + if (moment.isDuration(interval)) return interval; + return calcAuto.near(self.barTarget, duration); + } + + // check to see if the interval should be scaled, and scale it if so + function maybeScaleInterval(interval) { + if (!self.hasBounds()) return interval; + + const maxLength = self.maxBars; + const approxLen = duration / interval; + let scaled; + + // If the number of buckets we got back from using the barTarget is less than + // maxBars, than use the lessThan rule to try and get closer to maxBars. + if (approxLen > maxLength) { + scaled = calcAuto.lessThan(maxLength, duration); + } else { + return interval; + } + + if (+scaled === +interval) return interval; + + decorateInterval(interval, duration); + return assign(scaled, { + preScaled: interval, + scale: interval / scaled, + scaled: true, + }); + } +}; + +/** + * Returns an interval which in the last step of calculation is rounded to + * the closest multiple of the supplied divisor (in seconds). + * + * @return {moment.duration|undefined} + */ +TimeBuckets.prototype.getIntervalToNearestMultiple = function (divisorSecs) { + const interval = this.getInterval(); + const intervalSecs = interval.asSeconds(); + + const remainder = intervalSecs % divisorSecs; + if (remainder === 0) { + return interval; + } + + // Create a new interval which is a multiple of the supplied divisor (not zero). + let nearestMultiple = + remainder > divisorSecs / 2 ? intervalSecs + divisorSecs - remainder : intervalSecs - remainder; + nearestMultiple = nearestMultiple === 0 ? divisorSecs : nearestMultiple; + const nearestMultipleInt = moment.duration(nearestMultiple, 'seconds'); + decorateInterval(nearestMultipleInt, this.getDuration()); + + // Check to see if the new interval is scaled compared to the original. + const preScaled = interval.preScaled; + if (preScaled !== undefined && preScaled < nearestMultipleInt) { + nearestMultipleInt.preScaled = preScaled; + nearestMultipleInt.scale = preScaled / nearestMultipleInt; + nearestMultipleInt.scaled = true; + } + + return nearestMultipleInt; +}; + +/** + * Get a date format string that will represent dates that + * progress at our interval. + * + * Since our interval can be as small as 1ms, the default + * date format is usually way too much. with `dateFormat:scaled` + * users can modify how dates are formatted within series + * produced by TimeBuckets + * + * @return {string} + */ +TimeBuckets.prototype.getScaledDateFormat = function () { + const interval = this.getInterval(); + const rules = this._timeBucketsConfig['dateFormat:scaled']; + + for (let i = rules.length - 1; i >= 0; i--) { + const rule = rules[i]; + if (!rule[0] || interval >= moment.duration(rule[0])) { + return rule[1]; + } + } + + return this._timeBucketsConfig.dateFormat; +}; + +TimeBuckets.prototype.getScaledDateFormatter = function () { + const fieldFormats = this._fieldFormats; + const DateFieldFormat = fieldFormats.getType(FIELD_FORMAT_IDS.DATE); + return new DateFieldFormat( + { + pattern: this.getScaledDateFormat(), + }, + // getConfig + this._timeBucketsConfig + ); +}; + +// Appends some TimeBuckets specific properties to the moment.js duration interval. +// Uses the originalDuration from which the time bucket was created to calculate the overflow +// property (i.e. difference between the supplied duration and the calculated bucket interval). +function decorateInterval(interval, originalDuration) { + const esInterval = calcEsInterval(interval); + interval.esValue = esInterval.value; + interval.esUnit = esInterval.unit; + interval.expression = esInterval.expression; + interval.overflow = + originalDuration > interval ? moment.duration(interval - originalDuration) : false; + + const prettyUnits = moment.normalizeUnits(esInterval.unit); + if (esInterval.value === 1) { + interval.description = prettyUnits; + } else { + interval.description = `${esInterval.value} ${prettyUnits}s`; + } + + return interval; +} + +function isValidMoment(m) { + return m && 'isValid' in m && m.isValid(); +} + +export function getBoundsRoundedToInterval(bounds, interval, inclusiveEnd = false) { + // Returns new bounds, created by flooring the min of the provided bounds to the start of + // the specified interval (a moment duration), and rounded upwards (Math.ceil) to 1ms before + // the start of the next interval (Kibana dashboards search >= bounds min, and <= bounds max, + // so we subtract 1ms off the max to avoid querying start of the new Elasticsearch aggregation bucket). + const intervalMs = interval.asMilliseconds(); + const adjustedMinMs = Math.floor(bounds.min.valueOf() / intervalMs) * intervalMs; + let adjustedMaxMs = Math.ceil(bounds.max.valueOf() / intervalMs) * intervalMs; + + // Don't include the start ms of the next bucket unless specified.. + if (inclusiveEnd === false) { + adjustedMaxMs = adjustedMaxMs - 1; + } + return { min: moment(adjustedMinMs), max: moment(adjustedMaxMs) }; +} + +export function calcEsInterval(duration) { + // Converts a moment.duration into an Elasticsearch compatible interval expression, + // and provides associated metadata. + + // Note this was a copy of Kibana's original ui/time_buckets/calc_es_interval, + // but with the definition of a 'large' unit changed from 'M' to 'w', + // bringing it into line with the time units supported by Elasticsearch + for (let i = 0; i < unitsDesc.length; i++) { + const unit = unitsDesc[i]; + const val = duration.as(unit); + // find a unit that rounds neatly + if (val >= 1 && Math.floor(val) === val) { + // Apart from for date histograms, ES only supports time units up to 'd', + // meaning we can't for example use 'w' for job bucket spans. + // See https://www.elastic.co/guide/en/elasticsearch/reference/current/common-options.html#time-units + // So keep going until we get out of the "large" units. + if (i <= timeUnitsMaxSupportedIndex) { + continue; + } + + return { + value: val, + unit: unit, + expression: val + unit, + }; + } + } + + const ms = duration.as('ms'); + return { + value: ms, + unit: 'ms', + expression: ms + 'ms', + }; +} diff --git a/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/services/time_field_range.ts b/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/services/time_field_range.ts new file mode 100644 index 0000000000000..87d4a3b7fb711 --- /dev/null +++ b/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/services/time_field_range.ts @@ -0,0 +1,32 @@ +/* + * 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 { estypes } from '@elastic/elasticsearch'; +import { lazyLoadModules } from '../../../lazy_load_bundle'; +import { GetTimeFieldRangeResponse } from '../../../../common/types/time_field_request'; +import { Query } from '../../../../../../../src/plugins/data/common/query'; + +export async function getTimeFieldRange({ + index, + timeFieldName, + query, + runtimeMappings, +}: { + index: string; + timeFieldName?: string; + query?: Query; + runtimeMappings?: estypes.MappingRuntimeFields; +}) { + const body = JSON.stringify({ index, timeFieldName, query, runtimeMappings }); + const fileUploadModules = await lazyLoadModules(); + + return await fileUploadModules.getHttp().fetch({ + path: `/internal/file_upload/time_field_range`, + method: 'POST', + body, + }); +} diff --git a/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/services/timefilter_refresh_service.ts b/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/services/timefilter_refresh_service.ts new file mode 100644 index 0000000000000..49ef9107c3ece --- /dev/null +++ b/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/services/timefilter_refresh_service.ts @@ -0,0 +1,16 @@ +/* + * 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 { Subject } from 'rxjs'; +import { Required } from 'utility-types'; + +export interface Refresh { + lastRefresh: number; + timeRange?: { start: string; end: string }; +} + +export const dataVisualizerTimefilterRefresh$ = new Subject>(); diff --git a/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/services/visualizer_stats.ts b/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/services/visualizer_stats.ts new file mode 100644 index 0000000000000..8db267a1dc837 --- /dev/null +++ b/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/services/visualizer_stats.ts @@ -0,0 +1,98 @@ +/* + * 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 { estypes } from '@elastic/elasticsearch'; +import { lazyLoadModules } from '../../../lazy_load_bundle'; +import type { DocumentCounts, FieldRequestConfig, FieldVisStats } from '../../../../common/types'; +import { OverallStats } from '../types/overall_stats'; + +export function basePath() { + return '/internal/data_visualizer'; +} + +export async function getVisualizerOverallStats({ + indexPatternTitle, + query, + timeFieldName, + earliest, + latest, + samplerShardSize, + aggregatableFields, + nonAggregatableFields, + runtimeMappings, +}: { + indexPatternTitle: string; + query: any; + timeFieldName?: string; + earliest?: number; + latest?: number; + samplerShardSize?: number; + aggregatableFields: string[]; + nonAggregatableFields: string[]; + runtimeMappings?: estypes.MappingRuntimeFields; +}) { + const body = JSON.stringify({ + query, + timeFieldName, + earliest, + latest, + samplerShardSize, + aggregatableFields, + nonAggregatableFields, + runtimeMappings, + }); + + const fileUploadModules = await lazyLoadModules(); + return await fileUploadModules.getHttp().fetch({ + path: `${basePath()}/get_overall_stats/${indexPatternTitle}`, + method: 'POST', + body, + }); +} + +export async function getVisualizerFieldStats({ + indexPatternTitle, + query, + timeFieldName, + earliest, + latest, + samplerShardSize, + interval, + fields, + maxExamples, + runtimeMappings, +}: { + indexPatternTitle: string; + query: any; + timeFieldName?: string; + earliest?: number; + latest?: number; + samplerShardSize?: number; + interval?: number; + fields?: FieldRequestConfig[]; + maxExamples?: number; + runtimeMappings?: estypes.MappingRuntimeFields; +}) { + const body = JSON.stringify({ + query, + timeFieldName, + earliest, + latest, + samplerShardSize, + interval, + fields, + maxExamples, + runtimeMappings, + }); + + const fileUploadModules = await lazyLoadModules(); + return await fileUploadModules.getHttp().fetch<[DocumentCounts, FieldVisStats]>({ + path: `${basePath()}/get_field_stats/${indexPatternTitle}`, + method: 'POST', + body, + }); +} diff --git a/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/types/combined_query.ts b/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/types/combined_query.ts new file mode 100644 index 0000000000000..734a47d7f01b0 --- /dev/null +++ b/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/types/combined_query.ts @@ -0,0 +1,23 @@ +/* + * 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. + */ + +export const SEARCH_QUERY_LANGUAGE = { + KUERY: 'kuery', + LUCENE: 'lucene', +} as const; + +export type SearchQueryLanguage = typeof SEARCH_QUERY_LANGUAGE[keyof typeof SEARCH_QUERY_LANGUAGE]; + +export interface CombinedQuery { + searchString: string | { [key: string]: any }; + searchQueryLanguage: string; +} + +export interface ErrorMessage { + query: string; + message: string; +} diff --git a/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/types/index_data_visualizer_state.ts b/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/types/index_data_visualizer_state.ts new file mode 100644 index 0000000000000..7cd1c2bb3ce09 --- /dev/null +++ b/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/types/index_data_visualizer_state.ts @@ -0,0 +1,28 @@ +/* + * 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 { Query } from '../../../../../../../src/plugins/data/common/query'; +import { SearchQueryLanguage } from './combined_query'; + +export interface ListingPageUrlState { + pageSize: number; + pageIndex: number; + sortField: string; + sortDirection: string; + queryText?: string; +} +export interface DataVisualizerIndexBasedAppState extends Omit { + searchString?: Query['query']; + searchQuery?: Query['query']; + searchQueryLanguage?: SearchQueryLanguage; + visibleFieldTypes?: string[]; + visibleFieldNames?: string[]; + samplerShardSize?: number; + showDistributions?: boolean; + showAllFields?: boolean; + showEmptyFields?: boolean; +} diff --git a/x-pack/plugins/ml/common/types/datavisualizer.ts b/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/types/overall_stats.ts similarity index 99% rename from x-pack/plugins/ml/common/types/datavisualizer.ts rename to x-pack/plugins/data_visualizer/public/application/index_data_visualizer/types/overall_stats.ts index b2c1409471658..2672dc69ac29a 100644 --- a/x-pack/plugins/ml/common/types/datavisualizer.ts +++ b/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/types/overall_stats.ts @@ -16,6 +16,7 @@ export interface AggregatableField { } export type NonAggregatableField = Omit; + export interface OverallStats { totalCount: number; aggregatableExistsFields: AggregatableField[]; diff --git a/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/utils/saved_search_utils.ts b/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/utils/saved_search_utils.ts new file mode 100644 index 0000000000000..a04795ceb9d7d --- /dev/null +++ b/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/utils/saved_search_utils.ts @@ -0,0 +1,119 @@ +/* + * 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 { cloneDeep } from 'lodash'; +import { IUiSettingsClient } from 'kibana/public'; +import { SavedSearchSavedObject } from '../../../../common/types'; +import { IndexPattern } from '../../../../../../../src/plugins/data/common/index_patterns/index_patterns'; +import { SEARCH_QUERY_LANGUAGE, SearchQueryLanguage } from '../types/combined_query'; +import { esKuery, esQuery, Query } from '../../../../../../../src/plugins/data/public'; + +export function getQueryFromSavedSearch(savedSearch: SavedSearchSavedObject) { + const search = savedSearch.attributes.kibanaSavedObjectMeta as { searchSourceJSON: string }; + return JSON.parse(search.searchSourceJSON) as { + query: Query; + filter: any[]; + }; +} + +/** + * Extract query data from the saved search object. + */ +export function extractSearchData( + savedSearch: SavedSearchSavedObject | null, + currentIndexPattern: IndexPattern, + queryStringOptions: Record | string +) { + if (!savedSearch) { + return undefined; + } + + const { query: extractedQuery } = getQueryFromSavedSearch(savedSearch); + const queryLanguage = extractedQuery.language as SearchQueryLanguage; + const qryString = extractedQuery.query; + let qry; + if (queryLanguage === SEARCH_QUERY_LANGUAGE.KUERY) { + const ast = esKuery.fromKueryExpression(qryString); + qry = esKuery.toElasticsearchQuery(ast, currentIndexPattern); + } else { + qry = esQuery.luceneStringToDsl(qryString); + esQuery.decorateQuery(qry, queryStringOptions); + } + return { + searchQuery: qry, + searchString: qryString, + queryLanguage, + }; +} + +const DEFAULT_QUERY = { + bool: { + must: [ + { + match_all: {}, + }, + ], + }, +}; + +export function getDefaultDatafeedQuery() { + return cloneDeep(DEFAULT_QUERY); +} + +export function createSearchItems( + kibanaConfig: IUiSettingsClient, + indexPattern: IndexPattern | undefined, + savedSearch: SavedSearchSavedObject | null +) { + // query is only used by the data visualizer as it needs + // a lucene query_string. + // Using a blank query will cause match_all:{} to be used + // when passed through luceneStringToDsl + let query: Query = { + query: '', + language: 'lucene', + }; + + let combinedQuery: any = getDefaultDatafeedQuery(); + if (savedSearch !== null) { + const data = getQueryFromSavedSearch(savedSearch); + + query = data.query; + const filter = data.filter; + + const filters = Array.isArray(filter) ? filter : []; + + if (query.language === SEARCH_QUERY_LANGUAGE.KUERY) { + const ast = esKuery.fromKueryExpression(query.query); + if (query.query !== '') { + combinedQuery = esKuery.toElasticsearchQuery(ast, indexPattern); + } + const filterQuery = esQuery.buildQueryFromFilters(filters, indexPattern); + + if (Array.isArray(combinedQuery.bool.filter) === false) { + combinedQuery.bool.filter = + combinedQuery.bool.filter === undefined ? [] : [combinedQuery.bool.filter]; + } + + if (Array.isArray(combinedQuery.bool.must_not) === false) { + combinedQuery.bool.must_not = + combinedQuery.bool.must_not === undefined ? [] : [combinedQuery.bool.must_not]; + } + + combinedQuery.bool.filter = [...combinedQuery.bool.filter, ...filterQuery.filter]; + combinedQuery.bool.must_not = [...combinedQuery.bool.must_not, ...filterQuery.must_not]; + } else { + const esQueryConfigs = esQuery.getEsQueryConfig(kibanaConfig); + combinedQuery = esQuery.buildEsQuery(indexPattern, [query], filters, esQueryConfigs); + } + } + + return { + query, + combinedQuery, + }; +} diff --git a/x-pack/plugins/file_data_visualizer/public/application/kibana_context.ts b/x-pack/plugins/data_visualizer/public/application/kibana_context.ts similarity index 62% rename from x-pack/plugins/file_data_visualizer/public/application/kibana_context.ts rename to x-pack/plugins/data_visualizer/public/application/kibana_context.ts index 6752c322d42e3..f7ce13d2fd48d 100644 --- a/x-pack/plugins/file_data_visualizer/public/application/kibana_context.ts +++ b/x-pack/plugins/data_visualizer/public/application/kibana_context.ts @@ -7,7 +7,7 @@ import { CoreStart } from 'kibana/public'; import { useKibana } from '../../../../../src/plugins/kibana_react/public'; -import type { FileDataVisualizerStartDependencies } from '../plugin'; +import type { DataVisualizerStartDependencies } from '../plugin'; -export type StartServices = CoreStart & FileDataVisualizerStartDependencies; -export const useFileDataVisualizerKibana = () => useKibana(); +export type StartServices = CoreStart & DataVisualizerStartDependencies; +export const useDataVisualizerKibana = () => useKibana(); diff --git a/x-pack/plugins/file_data_visualizer/public/application/shared_imports.ts b/x-pack/plugins/data_visualizer/public/application/shared_imports.ts similarity index 100% rename from x-pack/plugins/file_data_visualizer/public/application/shared_imports.ts rename to x-pack/plugins/data_visualizer/public/application/shared_imports.ts diff --git a/x-pack/plugins/file_data_visualizer/public/index.ts b/x-pack/plugins/data_visualizer/public/index.ts similarity index 57% rename from x-pack/plugins/file_data_visualizer/public/index.ts rename to x-pack/plugins/data_visualizer/public/index.ts index 64a81936dbbde..b0a622dfe490b 100644 --- a/x-pack/plugins/file_data_visualizer/public/index.ts +++ b/x-pack/plugins/data_visualizer/public/index.ts @@ -5,10 +5,12 @@ * 2.0. */ -import { FileDataVisualizerPlugin } from './plugin'; +import { DataVisualizerPlugin } from './plugin'; export function plugin() { - return new FileDataVisualizerPlugin(); + return new DataVisualizerPlugin(); } -export { FileDataVisualizerPluginStart } from './plugin'; +export { DataVisualizerPluginStart } from './plugin'; + +export type { IndexDataVisualizerViewProps } from './application'; diff --git a/x-pack/plugins/file_data_visualizer/public/kibana_services.ts b/x-pack/plugins/data_visualizer/public/kibana_services.ts similarity index 68% rename from x-pack/plugins/file_data_visualizer/public/kibana_services.ts rename to x-pack/plugins/data_visualizer/public/kibana_services.ts index 6a5fe85c72477..458d3aca9e525 100644 --- a/x-pack/plugins/file_data_visualizer/public/kibana_services.ts +++ b/x-pack/plugins/data_visualizer/public/kibana_services.ts @@ -6,11 +6,11 @@ */ import { CoreStart } from 'kibana/public'; -import { FileDataVisualizerStartDependencies } from './plugin'; +import { DataVisualizerStartDependencies } from './plugin'; let coreStart: CoreStart; -let pluginsStart: FileDataVisualizerStartDependencies; -export function setStartServices(core: CoreStart, plugins: FileDataVisualizerStartDependencies) { +let pluginsStart: DataVisualizerStartDependencies; +export function setStartServices(core: CoreStart, plugins: DataVisualizerStartDependencies) { coreStart = core; pluginsStart = plugins; } diff --git a/x-pack/plugins/file_data_visualizer/public/lazy_load_bundle/component_wrapper.tsx b/x-pack/plugins/data_visualizer/public/lazy_load_bundle/component_wrapper.tsx similarity index 78% rename from x-pack/plugins/file_data_visualizer/public/lazy_load_bundle/component_wrapper.tsx rename to x-pack/plugins/data_visualizer/public/lazy_load_bundle/component_wrapper.tsx index e6835d9e7a668..028c0a402039d 100644 --- a/x-pack/plugins/file_data_visualizer/public/lazy_load_bundle/component_wrapper.tsx +++ b/x-pack/plugins/data_visualizer/public/lazy_load_bundle/component_wrapper.tsx @@ -7,7 +7,9 @@ import React, { FC } from 'react'; -const FileDataVisualizerComponent = React.lazy(() => import('../application/file_datavisualizer')); +const FileDataVisualizerComponent = React.lazy( + () => import('../application/file_data_visualizer/file_data_visualizer') +); export const FileDataVisualizerWrapper: FC = () => { return ( diff --git a/x-pack/plugins/file_data_visualizer/public/lazy_load_bundle/index.ts b/x-pack/plugins/data_visualizer/public/lazy_load_bundle/index.ts similarity index 82% rename from x-pack/plugins/file_data_visualizer/public/lazy_load_bundle/index.ts rename to x-pack/plugins/data_visualizer/public/lazy_load_bundle/index.ts index 99dbb6d3746ce..57f0872d62589 100644 --- a/x-pack/plugins/file_data_visualizer/public/lazy_load_bundle/index.ts +++ b/x-pack/plugins/data_visualizer/public/lazy_load_bundle/index.ts @@ -6,13 +6,14 @@ */ import { HttpSetup } from 'src/core/public'; -import { FileDataVisualizer } from '../application'; +import type { FileDataVisualizerSpec, IndexDataVisualizerSpec } from '../application'; import { getCoreStart } from '../kibana_services'; let loadModulesPromise: Promise; interface LazyLoadedModules { - FileDataVisualizer: typeof FileDataVisualizer; + FileDataVisualizer: FileDataVisualizerSpec; + IndexDataVisualizer: IndexDataVisualizerSpec; getHttp: () => HttpSetup; } diff --git a/x-pack/plugins/data_visualizer/public/lazy_load_bundle/lazy/index.ts b/x-pack/plugins/data_visualizer/public/lazy_load_bundle/lazy/index.ts new file mode 100644 index 0000000000000..a895a0eb98385 --- /dev/null +++ b/x-pack/plugins/data_visualizer/public/lazy_load_bundle/lazy/index.ts @@ -0,0 +1,13 @@ +/* + * 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. + */ + +export { + FileDataVisualizer, + IndexDataVisualizer, + FileDataVisualizerSpec, + IndexDataVisualizerSpec, +} from '../../application'; diff --git a/x-pack/plugins/file_data_visualizer/public/plugin.ts b/x-pack/plugins/data_visualizer/public/plugin.ts similarity index 58% rename from x-pack/plugins/file_data_visualizer/public/plugin.ts rename to x-pack/plugins/data_visualizer/public/plugin.ts index 0064f96195eaf..20d2e93fd6879 100644 --- a/x-pack/plugins/file_data_visualizer/public/plugin.ts +++ b/x-pack/plugins/data_visualizer/public/plugin.ts @@ -16,41 +16,47 @@ import type { HomePublicPluginSetup } from '../../../../src/plugins/home/public' import type { FileUploadPluginStart } from '../../file_upload/public'; import type { MapsStartApi } from '../../maps/public'; import type { SecurityPluginSetup } from '../../security/public'; -import { getFileDataVisualizerComponent } from './api'; -import { getMaxBytesFormatted } from './application/util/get_max_bytes'; +import type { LensPublicStart } from '../../lens/public'; +import { getFileDataVisualizerComponent, getIndexDataVisualizerComponent } from './api'; +import { getMaxBytesFormatted } from './application/common/util/get_max_bytes'; import { registerHomeAddData } from './register_home'; -export interface FileDataVisualizerSetupDependencies { +export interface DataVisualizerSetupDependencies { home?: HomePublicPluginSetup; } -export interface FileDataVisualizerStartDependencies { +export interface DataVisualizerStartDependencies { data: DataPublicPluginStart; fileUpload: FileUploadPluginStart; maps: MapsStartApi; embeddable: EmbeddableStart; security?: SecurityPluginSetup; share: SharePluginStart; + lens?: LensPublicStart; } -export type FileDataVisualizerPluginSetup = ReturnType; -export type FileDataVisualizerPluginStart = ReturnType; +export type DataVisualizerPluginSetup = ReturnType; +export type DataVisualizerPluginStart = ReturnType; -export class FileDataVisualizerPlugin +export class DataVisualizerPlugin implements Plugin< - FileDataVisualizerPluginSetup, - FileDataVisualizerPluginStart, - FileDataVisualizerSetupDependencies, - FileDataVisualizerStartDependencies + DataVisualizerPluginSetup, + DataVisualizerPluginStart, + DataVisualizerSetupDependencies, + DataVisualizerStartDependencies > { - public setup(core: CoreSetup, plugins: FileDataVisualizerSetupDependencies) { + public setup(core: CoreSetup, plugins: DataVisualizerSetupDependencies) { if (plugins.home) { registerHomeAddData(plugins.home); } } - public start(core: CoreStart, plugins: FileDataVisualizerStartDependencies) { + public start(core: CoreStart, plugins: DataVisualizerStartDependencies) { setStartServices(core, plugins); - return { getFileDataVisualizerComponent, getMaxBytesFormatted }; + return { + getFileDataVisualizerComponent, + getIndexDataVisualizerComponent, + getMaxBytesFormatted, + }; } } diff --git a/x-pack/plugins/file_data_visualizer/public/register_home.ts b/x-pack/plugins/data_visualizer/public/register_home.ts similarity index 90% rename from x-pack/plugins/file_data_visualizer/public/register_home.ts rename to x-pack/plugins/data_visualizer/public/register_home.ts index e54c37a8d06bc..0b438dc309c4b 100644 --- a/x-pack/plugins/file_data_visualizer/public/register_home.ts +++ b/x-pack/plugins/data_visualizer/public/register_home.ts @@ -12,7 +12,7 @@ import { FileDataVisualizerWrapper } from './lazy_load_bundle/component_wrapper' export function registerHomeAddData(home: HomePublicPluginSetup) { home.addData.registerAddDataTab({ id: 'fileDataViz', - name: i18n.translate('xpack.fileDataVisualizer.embeddedTabTitle', { + name: i18n.translate('xpack.dataVisualizer.file.embeddedTabTitle', { defaultMessage: 'Upload file', }), component: FileDataVisualizerWrapper, diff --git a/x-pack/plugins/data_visualizer/server/index.ts b/x-pack/plugins/data_visualizer/server/index.ts new file mode 100644 index 0000000000000..f88303829c558 --- /dev/null +++ b/x-pack/plugins/data_visualizer/server/index.ts @@ -0,0 +1,11 @@ +/* + * 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 { PluginInitializerContext } from 'kibana/server'; +import { DataVisualizerPlugin } from './plugin'; + +export const plugin = (initializerContext: PluginInitializerContext) => new DataVisualizerPlugin(); diff --git a/x-pack/plugins/data_visualizer/server/models/data_visualizer/check_fields_exist.ts b/x-pack/plugins/data_visualizer/server/models/data_visualizer/check_fields_exist.ts new file mode 100644 index 0000000000000..ca7287394b8e3 --- /dev/null +++ b/x-pack/plugins/data_visualizer/server/models/data_visualizer/check_fields_exist.ts @@ -0,0 +1,183 @@ +/* + * 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 { estypes } from '@elastic/elasticsearch'; +import { get } from 'lodash'; +import { IScopedClusterClient } from 'kibana/server'; +import { AggCardinality, Aggs, FieldData } from '../../types'; +import { + buildBaseFilterCriteria, + buildSamplerAggregation, + getSafeAggregationName, + getSamplerAggregationsResponsePath, +} from '../../../common/utils/query_utils'; +import { getDatafeedAggregations } from '../../../common/utils/datafeed_utils'; +import { isPopulatedObject } from '../../../common/utils/object_utils'; + +export const checkAggregatableFieldsExist = async ( + client: IScopedClusterClient, + indexPatternTitle: string, + query: any, + aggregatableFields: string[], + samplerShardSize: number, + timeFieldName: string | undefined, + earliestMs?: number, + latestMs?: number, + datafeedConfig?: estypes.MlDatafeed, + runtimeMappings?: estypes.MappingRuntimeFields +) => { + const { asCurrentUser } = client; + + const index = indexPatternTitle; + const size = 0; + const filterCriteria = buildBaseFilterCriteria(timeFieldName, earliestMs, latestMs, query); + const datafeedAggregations = getDatafeedAggregations(datafeedConfig); + + // Value count aggregation faster way of checking if field exists than using + // filter aggregation with exists query. + const aggs: Aggs = datafeedAggregations !== undefined ? { ...datafeedAggregations } : {}; + + // Combine runtime fields from the index pattern as well as the datafeed + const combinedRuntimeMappings: estypes.MappingRuntimeFields = { + ...(isPopulatedObject(runtimeMappings) ? runtimeMappings : {}), + ...(isPopulatedObject(datafeedConfig) && isPopulatedObject(datafeedConfig.runtime_mappings) + ? datafeedConfig.runtime_mappings + : {}), + }; + + aggregatableFields.forEach((field, i) => { + const safeFieldName = getSafeAggregationName(field, i); + aggs[`${safeFieldName}_count`] = { + filter: { exists: { field } }, + }; + + let cardinalityField: AggCardinality; + if (datafeedConfig?.script_fields?.hasOwnProperty(field)) { + cardinalityField = aggs[`${safeFieldName}_cardinality`] = { + cardinality: { script: datafeedConfig?.script_fields[field].script }, + }; + } else { + cardinalityField = { + cardinality: { field }, + }; + } + aggs[`${safeFieldName}_cardinality`] = cardinalityField; + }); + + const searchBody = { + query: { + bool: { + filter: filterCriteria, + }, + }, + ...(isPopulatedObject(aggs) ? { aggs: buildSamplerAggregation(aggs, samplerShardSize) } : {}), + ...(isPopulatedObject(combinedRuntimeMappings) + ? { runtime_mappings: combinedRuntimeMappings } + : {}), + }; + + const { body } = await asCurrentUser.search({ + index, + track_total_hits: true, + size, + body: searchBody, + }); + + const aggregations = body.aggregations; + // @ts-expect-error incorrect search response type + const totalCount = body.hits.total.value; + const stats = { + totalCount, + aggregatableExistsFields: [] as FieldData[], + aggregatableNotExistsFields: [] as FieldData[], + }; + + const aggsPath = getSamplerAggregationsResponsePath(samplerShardSize); + const sampleCount = + samplerShardSize > 0 ? get(aggregations, ['sample', 'doc_count'], 0) : totalCount; + aggregatableFields.forEach((field, i) => { + const safeFieldName = getSafeAggregationName(field, i); + const count = get(aggregations, [...aggsPath, `${safeFieldName}_count`, 'doc_count'], 0); + if (count > 0) { + const cardinality = get( + aggregations, + [...aggsPath, `${safeFieldName}_cardinality`, 'value'], + 0 + ); + stats.aggregatableExistsFields.push({ + fieldName: field, + existsInDocs: true, + stats: { + sampleCount, + count, + cardinality, + }, + }); + } else { + if ( + datafeedConfig?.script_fields?.hasOwnProperty(field) || + datafeedConfig?.runtime_mappings?.hasOwnProperty(field) + ) { + const cardinality = get( + aggregations, + [...aggsPath, `${safeFieldName}_cardinality`, 'value'], + 0 + ); + stats.aggregatableExistsFields.push({ + fieldName: field, + existsInDocs: true, + stats: { + sampleCount, + count, + cardinality, + }, + }); + } else { + stats.aggregatableNotExistsFields.push({ + fieldName: field, + existsInDocs: false, + }); + } + } + }); + + return stats; +}; + +export const checkNonAggregatableFieldExists = async ( + client: IScopedClusterClient, + indexPatternTitle: string, + query: any, + field: string, + timeFieldName: string | undefined, + earliestMs: number | undefined, + latestMs: number | undefined, + runtimeMappings?: estypes.MappingRuntimeFields +) => { + const { asCurrentUser } = client; + const index = indexPatternTitle; + const size = 0; + const filterCriteria = buildBaseFilterCriteria(timeFieldName, earliestMs, latestMs, query); + + const searchBody = { + query: { + bool: { + filter: filterCriteria, + }, + }, + ...(isPopulatedObject(runtimeMappings) ? { runtime_mappings: runtimeMappings } : {}), + }; + filterCriteria.push({ exists: { field } }); + + const { body } = await asCurrentUser.search({ + index, + size, + body: searchBody, + }); + // @ts-expect-error incorrect search response type + return body.hits.total.value > 0; +}; diff --git a/x-pack/plugins/data_visualizer/server/models/data_visualizer/constants.ts b/x-pack/plugins/data_visualizer/server/models/data_visualizer/constants.ts new file mode 100644 index 0000000000000..91bd394aee797 --- /dev/null +++ b/x-pack/plugins/data_visualizer/server/models/data_visualizer/constants.ts @@ -0,0 +1,13 @@ +/* + * 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. + */ + +export const SAMPLER_TOP_TERMS_THRESHOLD = 100000; +export const SAMPLER_TOP_TERMS_SHARD_SIZE = 5000; +export const AGGREGATABLE_EXISTS_REQUEST_BATCH_SIZE = 200; +export const FIELDS_REQUEST_BATCH_SIZE = 10; + +export const MAX_CHART_COLUMNS = 20; diff --git a/x-pack/plugins/data_visualizer/server/models/data_visualizer/data_visualizer.ts b/x-pack/plugins/data_visualizer/server/models/data_visualizer/data_visualizer.ts new file mode 100644 index 0000000000000..27c09c889deb7 --- /dev/null +++ b/x-pack/plugins/data_visualizer/server/models/data_visualizer/data_visualizer.ts @@ -0,0 +1,475 @@ +/* + * 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 { IScopedClusterClient } from 'kibana/server'; +import { each, last } from 'lodash'; +import { estypes } from '@elastic/elasticsearch'; +import { JOB_FIELD_TYPES } from '../../../common'; +import type { + BatchStats, + FieldData, + HistogramField, + Field, + DocumentCountStats, + FieldExamples, +} from '../../types'; +import { getHistogramsForFields } from './get_histogram_for_fields'; +import { + checkAggregatableFieldsExist, + checkNonAggregatableFieldExists, +} from './check_fields_exist'; +import { AGGREGATABLE_EXISTS_REQUEST_BATCH_SIZE, FIELDS_REQUEST_BATCH_SIZE } from './constants'; +import { getFieldExamples } from './get_field_examples'; +import { + getBooleanFieldsStats, + getDateFieldsStats, + getDocumentCountStats, + getNumericFieldsStats, + getStringFieldsStats, +} from './get_fields_stats'; + +export class DataVisualizer { + private _client: IScopedClusterClient; + + constructor(client: IScopedClusterClient) { + this._client = client; + } + + // Obtains overall stats on the fields in the supplied index pattern, returning an object + // containing the total document count, and four arrays showing which of the supplied + // aggregatable and non-aggregatable fields do or do not exist in documents. + // Sampling will be used if supplied samplerShardSize > 0. + async getOverallStats( + indexPatternTitle: string, + query: object, + aggregatableFields: string[], + nonAggregatableFields: string[], + samplerShardSize: number, + timeFieldName: string | undefined, + earliestMs: number | undefined, + latestMs: number | undefined, + runtimeMappings?: estypes.MappingRuntimeFields + ) { + const stats = { + totalCount: 0, + aggregatableExistsFields: [] as FieldData[], + aggregatableNotExistsFields: [] as FieldData[], + nonAggregatableExistsFields: [] as FieldData[], + nonAggregatableNotExistsFields: [] as FieldData[], + }; + + // To avoid checking for the existence of too many aggregatable fields in one request, + // split the check into multiple batches (max 200 fields per request). + const batches: string[][] = [[]]; + each(aggregatableFields, (field) => { + let lastArray: string[] = last(batches) as string[]; + if (lastArray.length === AGGREGATABLE_EXISTS_REQUEST_BATCH_SIZE) { + lastArray = []; + batches.push(lastArray); + } + lastArray.push(field); + }); + + await Promise.all( + batches.map(async (fields) => { + const batchStats = await this.checkAggregatableFieldsExist( + indexPatternTitle, + query, + fields, + samplerShardSize, + timeFieldName, + earliestMs, + latestMs, + undefined, + runtimeMappings + ); + + // Total count will be returned with each batch of fields. Just overwrite. + stats.totalCount = batchStats.totalCount; + + // Add to the lists of fields which do and do not exist. + stats.aggregatableExistsFields.push(...batchStats.aggregatableExistsFields); + stats.aggregatableNotExistsFields.push(...batchStats.aggregatableNotExistsFields); + }) + ); + + await Promise.all( + nonAggregatableFields.map(async (field) => { + const existsInDocs = await this.checkNonAggregatableFieldExists( + indexPatternTitle, + query, + field, + timeFieldName, + earliestMs, + latestMs, + runtimeMappings + ); + + const fieldData: FieldData = { + fieldName: field, + existsInDocs, + stats: {}, + }; + + if (existsInDocs === true) { + stats.nonAggregatableExistsFields.push(fieldData); + } else { + stats.nonAggregatableNotExistsFields.push(fieldData); + } + }) + ); + + return stats; + } + + // Obtains binned histograms for supplied list of fields. The statistics for each field in the + // returned array depend on the type of the field (keyword, number, date etc). + // Sampling will be used if supplied samplerShardSize > 0. + async getHistogramsForFields( + indexPatternTitle: string, + query: any, + fields: HistogramField[], + samplerShardSize: number, + runtimeMappings?: estypes.MappingRuntimeFields + ): Promise { + return await getHistogramsForFields( + this._client, + indexPatternTitle, + query, + fields, + samplerShardSize, + runtimeMappings + ); + } + + // Obtains statistics for supplied list of fields. The statistics for each field in the + // returned array depend on the type of the field (keyword, number, date etc). + // Sampling will be used if supplied samplerShardSize > 0. + async getStatsForFields( + indexPatternTitle: string, + query: any, + fields: Field[], + samplerShardSize: number, + timeFieldName: string | undefined, + earliestMs: number | undefined, + latestMs: number | undefined, + intervalMs: number | undefined, + maxExamples: number, + runtimeMappings: estypes.MappingRuntimeFields + ): Promise { + // Batch up fields by type, getting stats for multiple fields at a time. + const batches: Field[][] = []; + const batchedFields: { [key: string]: Field[][] } = {}; + each(fields, (field) => { + if (field.fieldName === undefined) { + // undefined fieldName is used for a document count request. + // getDocumentCountStats requires timeField - don't add to batched requests if not defined + if (timeFieldName !== undefined) { + batches.push([field]); + } + } else { + const fieldType = field.type; + if (batchedFields[fieldType] === undefined) { + batchedFields[fieldType] = [[]]; + } + let lastArray: Field[] = last(batchedFields[fieldType]) as Field[]; + if (lastArray.length === FIELDS_REQUEST_BATCH_SIZE) { + lastArray = []; + batchedFields[fieldType].push(lastArray); + } + lastArray.push(field); + } + }); + + each(batchedFields, (lists) => { + batches.push(...lists); + }); + + let results: BatchStats[] = []; + await Promise.all( + batches.map(async (batch) => { + let batchStats: BatchStats[] = []; + const first = batch[0]; + switch (first.type) { + case JOB_FIELD_TYPES.NUMBER: + // undefined fieldName is used for a document count request. + if (first.fieldName !== undefined) { + batchStats = await this.getNumericFieldsStats( + indexPatternTitle, + query, + batch, + samplerShardSize, + timeFieldName, + earliestMs, + latestMs, + runtimeMappings + ); + } else { + // Will only ever be one document count card, + // so no value in batching up the single request. + if (intervalMs !== undefined) { + const stats = await this.getDocumentCountStats( + indexPatternTitle, + query, + timeFieldName, + earliestMs, + latestMs, + intervalMs, + runtimeMappings + ); + batchStats.push(stats); + } + } + break; + case JOB_FIELD_TYPES.KEYWORD: + case JOB_FIELD_TYPES.IP: + batchStats = await this.getStringFieldsStats( + indexPatternTitle, + query, + batch, + samplerShardSize, + timeFieldName, + earliestMs, + latestMs, + runtimeMappings + ); + break; + case JOB_FIELD_TYPES.DATE: + batchStats = await this.getDateFieldsStats( + indexPatternTitle, + query, + batch, + samplerShardSize, + timeFieldName, + earliestMs, + latestMs, + runtimeMappings + ); + break; + case JOB_FIELD_TYPES.BOOLEAN: + batchStats = await this.getBooleanFieldsStats( + indexPatternTitle, + query, + batch, + samplerShardSize, + timeFieldName, + earliestMs, + latestMs, + runtimeMappings + ); + break; + case JOB_FIELD_TYPES.TEXT: + default: + // Use an exists filter on the the field name to get + // examples of the field, so cannot batch up. + await Promise.all( + batch.map(async (field) => { + const stats = await this.getFieldExamples( + indexPatternTitle, + query, + field.fieldName, + timeFieldName, + earliestMs, + latestMs, + maxExamples, + runtimeMappings + ); + batchStats.push(stats); + }) + ); + break; + } + + results = [...results, ...batchStats]; + }) + ); + + return results; + } + + async checkAggregatableFieldsExist( + indexPatternTitle: string, + query: any, + aggregatableFields: string[], + samplerShardSize: number, + timeFieldName: string | undefined, + earliestMs?: number, + latestMs?: number, + datafeedConfig?: estypes.MlDatafeed, + runtimeMappings?: estypes.MappingRuntimeFields + ) { + return await checkAggregatableFieldsExist( + this._client, + indexPatternTitle, + query, + aggregatableFields, + samplerShardSize, + timeFieldName, + earliestMs, + latestMs, + datafeedConfig, + runtimeMappings + ); + } + + async checkNonAggregatableFieldExists( + indexPatternTitle: string, + query: any, + field: string, + timeFieldName: string | undefined, + earliestMs: number | undefined, + latestMs: number | undefined, + runtimeMappings?: estypes.MappingRuntimeFields + ) { + return await checkNonAggregatableFieldExists( + this._client, + indexPatternTitle, + query, + field, + timeFieldName, + earliestMs, + latestMs, + runtimeMappings + ); + } + + async getDocumentCountStats( + indexPatternTitle: string, + query: any, + timeFieldName: string | undefined, + earliestMs: number | undefined, + latestMs: number | undefined, + intervalMs: number, + runtimeMappings: estypes.MappingRuntimeFields + ): Promise { + return await getDocumentCountStats( + this._client, + indexPatternTitle, + query, + timeFieldName, + earliestMs, + latestMs, + intervalMs, + runtimeMappings + ); + } + + async getNumericFieldsStats( + indexPatternTitle: string, + query: object, + fields: Field[], + samplerShardSize: number, + timeFieldName: string | undefined, + earliestMs: number | undefined, + latestMs: number | undefined, + runtimeMappings?: estypes.MappingRuntimeFields + ) { + return await getNumericFieldsStats( + this._client, + indexPatternTitle, + query, + fields, + samplerShardSize, + timeFieldName, + earliestMs, + latestMs, + runtimeMappings + ); + } + + async getStringFieldsStats( + indexPatternTitle: string, + query: object, + fields: Field[], + samplerShardSize: number, + timeFieldName: string | undefined, + earliestMs: number | undefined, + latestMs: number | undefined, + runtimeMappings?: estypes.MappingRuntimeFields + ) { + return await getStringFieldsStats( + this._client, + indexPatternTitle, + query, + fields, + samplerShardSize, + timeFieldName, + earliestMs, + latestMs, + runtimeMappings + ); + } + + async getDateFieldsStats( + indexPatternTitle: string, + query: object, + fields: Field[], + samplerShardSize: number, + timeFieldName: string | undefined, + earliestMs: number | undefined, + latestMs: number | undefined, + runtimeMappings?: estypes.MappingRuntimeFields + ) { + return await getDateFieldsStats( + this._client, + indexPatternTitle, + query, + fields, + samplerShardSize, + timeFieldName, + earliestMs, + latestMs, + runtimeMappings + ); + } + + async getBooleanFieldsStats( + indexPatternTitle: string, + query: object, + fields: Field[], + samplerShardSize: number, + timeFieldName: string | undefined, + earliestMs: number | undefined, + latestMs: number | undefined, + runtimeMappings?: estypes.MappingRuntimeFields + ) { + return await getBooleanFieldsStats( + this._client, + indexPatternTitle, + query, + fields, + samplerShardSize, + timeFieldName, + earliestMs, + latestMs, + runtimeMappings + ); + } + + async getFieldExamples( + indexPatternTitle: string, + query: any, + field: string, + timeFieldName: string | undefined, + earliestMs: number | undefined, + latestMs: number | undefined, + maxExamples: number, + runtimeMappings?: estypes.MappingRuntimeFields + ): Promise { + return await getFieldExamples( + this._client, + indexPatternTitle, + query, + field, + timeFieldName, + earliestMs, + latestMs, + maxExamples, + runtimeMappings + ); + } +} diff --git a/x-pack/plugins/data_visualizer/server/models/data_visualizer/get_field_examples.ts b/x-pack/plugins/data_visualizer/server/models/data_visualizer/get_field_examples.ts new file mode 100644 index 0000000000000..69476e254068f --- /dev/null +++ b/x-pack/plugins/data_visualizer/server/models/data_visualizer/get_field_examples.ts @@ -0,0 +1,80 @@ +/* + * 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 { estypes } from '@elastic/elasticsearch'; +import { get } from 'lodash'; +import { IScopedClusterClient } from 'kibana/server'; +import { buildBaseFilterCriteria } from '../../../common/utils/query_utils'; +import { isPopulatedObject } from '../../../common/utils/object_utils'; +import { FieldExamples } from '../../types/chart_data'; + +export const getFieldExamples = async ( + client: IScopedClusterClient, + indexPatternTitle: string, + query: any, + field: string, + timeFieldName: string | undefined, + earliestMs: number | undefined, + latestMs: number | undefined, + maxExamples: number, + runtimeMappings?: estypes.MappingRuntimeFields +): Promise => { + const { asCurrentUser } = client; + + const index = indexPatternTitle; + + // Request at least 100 docs so that we have a chance of obtaining + // 'maxExamples' of the field. + const size = Math.max(100, maxExamples); + const filterCriteria = buildBaseFilterCriteria(timeFieldName, earliestMs, latestMs, query); + + // Use an exists filter to return examples of the field. + filterCriteria.push({ + exists: { field }, + }); + + const searchBody = { + fields: [field], + _source: false, + query: { + bool: { + filter: filterCriteria, + }, + }, + ...(isPopulatedObject(runtimeMappings) ? { runtime_mappings: runtimeMappings } : {}), + }; + + const { body } = await asCurrentUser.search({ + index, + size, + body: searchBody, + }); + const stats = { + fieldName: field, + examples: [] as any[], + }; + // @ts-expect-error incorrect search response type + if (body.hits.total.value > 0) { + const hits = body.hits.hits; + for (let i = 0; i < hits.length; i++) { + // Use lodash get() to support field names containing dots. + const doc: object[] | undefined = get(hits[i].fields, field); + // the results from fields query is always an array + if (Array.isArray(doc) && doc.length > 0) { + const example = doc[0]; + if (example !== undefined && stats.examples.indexOf(example) === -1) { + stats.examples.push(example); + if (stats.examples.length === maxExamples) { + break; + } + } + } + } + } + + return stats; +}; diff --git a/x-pack/plugins/data_visualizer/server/models/data_visualizer/get_fields_stats.ts b/x-pack/plugins/data_visualizer/server/models/data_visualizer/get_fields_stats.ts new file mode 100644 index 0000000000000..6968aa97ab938 --- /dev/null +++ b/x-pack/plugins/data_visualizer/server/models/data_visualizer/get_fields_stats.ts @@ -0,0 +1,478 @@ +/* + * 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 { estypes } from '@elastic/elasticsearch'; +import { each, find, get } from 'lodash'; +import { IScopedClusterClient } from 'kibana/server'; +import { + Aggs, + BooleanFieldStats, + Bucket, + DateFieldStats, + DocumentCountStats, + Field, + NumericFieldStats, + StringFieldStats, +} from '../../types'; +import { + buildBaseFilterCriteria, + buildSamplerAggregation, + getSafeAggregationName, + getSamplerAggregationsResponsePath, +} from '../../../common/utils/query_utils'; +import { isPopulatedObject } from '../../../common/utils/object_utils'; +import { processDistributionData } from './process_distribution_data'; +import { SAMPLER_TOP_TERMS_SHARD_SIZE, SAMPLER_TOP_TERMS_THRESHOLD } from './constants'; + +export const getDocumentCountStats = async ( + client: IScopedClusterClient, + indexPatternTitle: string, + query: any, + timeFieldName: string | undefined, + earliestMs: number | undefined, + latestMs: number | undefined, + intervalMs: number, + runtimeMappings: estypes.MappingRuntimeFields +): Promise => { + const { asCurrentUser } = client; + + const index = indexPatternTitle; + const size = 0; + const filterCriteria = buildBaseFilterCriteria(timeFieldName, earliestMs, latestMs, query); + + // Don't use the sampler aggregation as this can lead to some potentially + // confusing date histogram results depending on the date range of data amongst shards. + + const aggs = { + eventRate: { + date_histogram: { + field: timeFieldName, + fixed_interval: `${intervalMs}ms`, + min_doc_count: 1, + }, + }, + }; + + const searchBody = { + query: { + bool: { + filter: filterCriteria, + }, + }, + aggs, + ...(isPopulatedObject(runtimeMappings) ? { runtime_mappings: runtimeMappings } : {}), + }; + + const { body } = await asCurrentUser.search({ + index, + size, + body: searchBody, + }); + + const buckets: { [key: string]: number } = {}; + const dataByTimeBucket: Array<{ key: string; doc_count: number }> = get( + body, + ['aggregations', 'eventRate', 'buckets'], + [] + ); + each(dataByTimeBucket, (dataForTime) => { + const time = dataForTime.key; + buckets[time] = dataForTime.doc_count; + }); + + return { + documentCounts: { + interval: intervalMs, + buckets, + }, + }; +}; + +export const getNumericFieldsStats = async ( + client: IScopedClusterClient, + indexPatternTitle: string, + query: object, + fields: Field[], + samplerShardSize: number, + timeFieldName: string | undefined, + earliestMs: number | undefined, + latestMs: number | undefined, + runtimeMappings?: estypes.MappingRuntimeFields +) => { + const { asCurrentUser } = client; + const index = indexPatternTitle; + const size = 0; + const filterCriteria = buildBaseFilterCriteria(timeFieldName, earliestMs, latestMs, query); + + // Build the percents parameter which defines the percentiles to query + // for the metric distribution data. + // Use a fixed percentile spacing of 5%. + const MAX_PERCENT = 100; + const PERCENTILE_SPACING = 5; + let count = 0; + const percents = Array.from( + Array(MAX_PERCENT / PERCENTILE_SPACING), + () => (count += PERCENTILE_SPACING) + ); + + const aggs: { [key: string]: any } = {}; + fields.forEach((field, i) => { + const safeFieldName = getSafeAggregationName(field.fieldName, i); + aggs[`${safeFieldName}_field_stats`] = { + filter: { exists: { field: field.fieldName } }, + aggs: { + actual_stats: { + stats: { field: field.fieldName }, + }, + }, + }; + aggs[`${safeFieldName}_percentiles`] = { + percentiles: { + field: field.fieldName, + percents, + keyed: false, + }, + }; + + const top = { + terms: { + field: field.fieldName, + size: 10, + order: { + _count: 'desc', + }, + }, + }; + + // If cardinality >= SAMPLE_TOP_TERMS_THRESHOLD, run the top terms aggregation + // in a sampler aggregation, even if no sampling has been specified (samplerShardSize < 1). + if (samplerShardSize < 1 && field.cardinality >= SAMPLER_TOP_TERMS_THRESHOLD) { + aggs[`${safeFieldName}_top`] = { + sampler: { + shard_size: SAMPLER_TOP_TERMS_SHARD_SIZE, + }, + aggs: { + top, + }, + }; + } else { + aggs[`${safeFieldName}_top`] = top; + } + }); + + const searchBody = { + query: { + bool: { + filter: filterCriteria, + }, + }, + aggs: buildSamplerAggregation(aggs, samplerShardSize), + ...(isPopulatedObject(runtimeMappings) ? { runtime_mappings: runtimeMappings } : {}), + }; + + const { body } = await asCurrentUser.search({ + index, + size, + body: searchBody, + }); + const aggregations = body.aggregations; + const aggsPath = getSamplerAggregationsResponsePath(samplerShardSize); + const batchStats: NumericFieldStats[] = []; + fields.forEach((field, i) => { + const safeFieldName = getSafeAggregationName(field.fieldName, i); + const docCount = get( + aggregations, + [...aggsPath, `${safeFieldName}_field_stats`, 'doc_count'], + 0 + ); + const fieldStatsResp = get( + aggregations, + [...aggsPath, `${safeFieldName}_field_stats`, 'actual_stats'], + {} + ); + + const topAggsPath = [...aggsPath, `${safeFieldName}_top`]; + if (samplerShardSize < 1 && field.cardinality >= SAMPLER_TOP_TERMS_THRESHOLD) { + topAggsPath.push('top'); + } + + const topValues: Bucket[] = get(aggregations, [...topAggsPath, 'buckets'], []); + + const stats: NumericFieldStats = { + fieldName: field.fieldName, + count: docCount, + min: get(fieldStatsResp, 'min', 0), + max: get(fieldStatsResp, 'max', 0), + avg: get(fieldStatsResp, 'avg', 0), + isTopValuesSampled: field.cardinality >= SAMPLER_TOP_TERMS_THRESHOLD || samplerShardSize > 0, + topValues, + topValuesSampleSize: topValues.reduce( + (acc, curr) => acc + curr.doc_count, + get(aggregations, [...topAggsPath, 'sum_other_doc_count'], 0) + ), + topValuesSamplerShardSize: + field.cardinality >= SAMPLER_TOP_TERMS_THRESHOLD + ? SAMPLER_TOP_TERMS_SHARD_SIZE + : samplerShardSize, + }; + + if (stats.count > 0) { + const percentiles = get( + aggregations, + [...aggsPath, `${safeFieldName}_percentiles`, 'values'], + [] + ); + const medianPercentile: { value: number; key: number } | undefined = find(percentiles, { + key: 50, + }); + stats.median = medianPercentile !== undefined ? medianPercentile!.value : 0; + stats.distribution = processDistributionData(percentiles, PERCENTILE_SPACING, stats.min); + } + + batchStats.push(stats); + }); + + return batchStats; +}; + +export const getStringFieldsStats = async ( + client: IScopedClusterClient, + indexPatternTitle: string, + query: object, + fields: Field[], + samplerShardSize: number, + timeFieldName: string | undefined, + earliestMs: number | undefined, + latestMs: number | undefined, + runtimeMappings?: estypes.MappingRuntimeFields +) => { + const { asCurrentUser } = client; + + const index = indexPatternTitle; + const size = 0; + const filterCriteria = buildBaseFilterCriteria(timeFieldName, earliestMs, latestMs, query); + + const aggs: Aggs = {}; + fields.forEach((field, i) => { + const safeFieldName = getSafeAggregationName(field.fieldName, i); + const top = { + terms: { + field: field.fieldName, + size: 10, + order: { + _count: 'desc', + }, + }, + }; + + // If cardinality >= SAMPLE_TOP_TERMS_THRESHOLD, run the top terms aggregation + // in a sampler aggregation, even if no sampling has been specified (samplerShardSize < 1). + if (samplerShardSize < 1 && field.cardinality >= SAMPLER_TOP_TERMS_THRESHOLD) { + aggs[`${safeFieldName}_top`] = { + sampler: { + shard_size: SAMPLER_TOP_TERMS_SHARD_SIZE, + }, + aggs: { + top, + }, + }; + } else { + aggs[`${safeFieldName}_top`] = top; + } + }); + + const searchBody = { + query: { + bool: { + filter: filterCriteria, + }, + }, + aggs: buildSamplerAggregation(aggs, samplerShardSize), + ...(isPopulatedObject(runtimeMappings) ? { runtime_mappings: runtimeMappings } : {}), + }; + + const { body } = await asCurrentUser.search({ + index, + size, + body: searchBody, + }); + const aggregations = body.aggregations; + const aggsPath = getSamplerAggregationsResponsePath(samplerShardSize); + const batchStats: StringFieldStats[] = []; + fields.forEach((field, i) => { + const safeFieldName = getSafeAggregationName(field.fieldName, i); + + const topAggsPath = [...aggsPath, `${safeFieldName}_top`]; + if (samplerShardSize < 1 && field.cardinality >= SAMPLER_TOP_TERMS_THRESHOLD) { + topAggsPath.push('top'); + } + + const topValues: Bucket[] = get(aggregations, [...topAggsPath, 'buckets'], []); + + const stats = { + fieldName: field.fieldName, + isTopValuesSampled: field.cardinality >= SAMPLER_TOP_TERMS_THRESHOLD || samplerShardSize > 0, + topValues, + topValuesSampleSize: topValues.reduce( + (acc, curr) => acc + curr.doc_count, + get(aggregations, [...topAggsPath, 'sum_other_doc_count'], 0) + ), + topValuesSamplerShardSize: + field.cardinality >= SAMPLER_TOP_TERMS_THRESHOLD + ? SAMPLER_TOP_TERMS_SHARD_SIZE + : samplerShardSize, + }; + + batchStats.push(stats); + }); + + return batchStats; +}; + +export const getDateFieldsStats = async ( + client: IScopedClusterClient, + indexPatternTitle: string, + query: object, + fields: Field[], + samplerShardSize: number, + timeFieldName: string | undefined, + earliestMs: number | undefined, + latestMs: number | undefined, + runtimeMappings?: estypes.MappingRuntimeFields +) => { + const { asCurrentUser } = client; + + const index = indexPatternTitle; + const size = 0; + const filterCriteria = buildBaseFilterCriteria(timeFieldName, earliestMs, latestMs, query); + + const aggs: Aggs = {}; + fields.forEach((field, i) => { + const safeFieldName = getSafeAggregationName(field.fieldName, i); + aggs[`${safeFieldName}_field_stats`] = { + filter: { exists: { field: field.fieldName } }, + aggs: { + actual_stats: { + stats: { field: field.fieldName }, + }, + }, + }; + }); + + const searchBody = { + query: { + bool: { + filter: filterCriteria, + }, + }, + aggs: buildSamplerAggregation(aggs, samplerShardSize), + ...(isPopulatedObject(runtimeMappings) ? { runtime_mappings: runtimeMappings } : {}), + }; + + const { body } = await asCurrentUser.search({ + index, + size, + body: searchBody, + }); + const aggregations = body.aggregations; + const aggsPath = getSamplerAggregationsResponsePath(samplerShardSize); + const batchStats: DateFieldStats[] = []; + fields.forEach((field, i) => { + const safeFieldName = getSafeAggregationName(field.fieldName, i); + const docCount = get( + aggregations, + [...aggsPath, `${safeFieldName}_field_stats`, 'doc_count'], + 0 + ); + const fieldStatsResp = get( + aggregations, + [...aggsPath, `${safeFieldName}_field_stats`, 'actual_stats'], + {} + ); + batchStats.push({ + fieldName: field.fieldName, + count: docCount, + earliest: get(fieldStatsResp, 'min', 0), + latest: get(fieldStatsResp, 'max', 0), + }); + }); + + return batchStats; +}; + +export const getBooleanFieldsStats = async ( + client: IScopedClusterClient, + indexPatternTitle: string, + query: object, + fields: Field[], + samplerShardSize: number, + timeFieldName: string | undefined, + earliestMs: number | undefined, + latestMs: number | undefined, + runtimeMappings?: estypes.MappingRuntimeFields +) => { + const { asCurrentUser } = client; + + const index = indexPatternTitle; + const size = 0; + const filterCriteria = buildBaseFilterCriteria(timeFieldName, earliestMs, latestMs, query); + + const aggs: Aggs = {}; + fields.forEach((field, i) => { + const safeFieldName = getSafeAggregationName(field.fieldName, i); + aggs[`${safeFieldName}_value_count`] = { + filter: { exists: { field: field.fieldName } }, + }; + aggs[`${safeFieldName}_values`] = { + terms: { + field: field.fieldName, + size: 2, + }, + }; + }); + + const searchBody = { + query: { + bool: { + filter: filterCriteria, + }, + }, + aggs: buildSamplerAggregation(aggs, samplerShardSize), + ...(isPopulatedObject(runtimeMappings) ? { runtime_mappings: runtimeMappings } : {}), + }; + + const { body } = await asCurrentUser.search({ + index, + size, + body: searchBody, + }); + const aggregations = body.aggregations; + const aggsPath = getSamplerAggregationsResponsePath(samplerShardSize); + const batchStats: BooleanFieldStats[] = []; + fields.forEach((field, i) => { + const safeFieldName = getSafeAggregationName(field.fieldName, i); + const stats: BooleanFieldStats = { + fieldName: field.fieldName, + count: get(aggregations, [...aggsPath, `${safeFieldName}_value_count`, 'doc_count'], 0), + trueCount: 0, + falseCount: 0, + }; + + const valueBuckets: Array<{ [key: string]: number }> = get( + aggregations, + [...aggsPath, `${safeFieldName}_values`, 'buckets'], + [] + ); + valueBuckets.forEach((bucket) => { + stats[`${bucket.key_as_string}Count`] = bucket.doc_count; + }); + + batchStats.push(stats); + }); + + return batchStats; +}; diff --git a/x-pack/plugins/data_visualizer/server/models/data_visualizer/get_histogram_for_fields.ts b/x-pack/plugins/data_visualizer/server/models/data_visualizer/get_histogram_for_fields.ts new file mode 100644 index 0000000000000..b8f6e2f538180 --- /dev/null +++ b/x-pack/plugins/data_visualizer/server/models/data_visualizer/get_histogram_for_fields.ts @@ -0,0 +1,188 @@ +/* + * 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 { IScopedClusterClient } from 'kibana/server'; +import { estypes } from '@elastic/elasticsearch'; +import { get } from 'lodash'; +import { ChartData, ChartRequestAgg, HistogramField, NumericColumnStatsMap } from '../../types'; +import { KBN_FIELD_TYPES } from '../../../../../../src/plugins/data/common'; +import { stringHash } from '../../../common/utils/string_utils'; +import { + buildSamplerAggregation, + getSamplerAggregationsResponsePath, +} from '../../../common/utils/query_utils'; +import { isPopulatedObject } from '../../../common/utils/object_utils'; +import { MAX_CHART_COLUMNS } from './constants'; + +export const getAggIntervals = async ( + { asCurrentUser }: IScopedClusterClient, + indexPatternTitle: string, + query: any, + fields: HistogramField[], + samplerShardSize: number, + runtimeMappings?: estypes.MappingRuntimeFields +): Promise => { + const numericColumns = fields.filter((field) => { + return field.type === KBN_FIELD_TYPES.NUMBER || field.type === KBN_FIELD_TYPES.DATE; + }); + + if (numericColumns.length === 0) { + return {}; + } + + const minMaxAggs = numericColumns.reduce((aggs, c) => { + const id = stringHash(c.fieldName); + aggs[id] = { + stats: { + field: c.fieldName, + }, + }; + return aggs; + }, {} as Record); + + const { body } = await asCurrentUser.search({ + index: indexPatternTitle, + size: 0, + body: { + query, + aggs: buildSamplerAggregation(minMaxAggs, samplerShardSize), + size: 0, + ...(isPopulatedObject(runtimeMappings) ? { runtime_mappings: runtimeMappings } : {}), + }, + }); + + const aggsPath = getSamplerAggregationsResponsePath(samplerShardSize); + const aggregations = aggsPath.length > 0 ? get(body.aggregations, aggsPath) : body.aggregations; + + return Object.keys(aggregations).reduce((p, aggName) => { + const stats = [aggregations[aggName].min, aggregations[aggName].max]; + if (!stats.includes(null)) { + const delta = aggregations[aggName].max - aggregations[aggName].min; + + let aggInterval = 1; + + if (delta > MAX_CHART_COLUMNS || delta <= 1) { + aggInterval = delta / (MAX_CHART_COLUMNS - 1); + } + + p[aggName] = { interval: aggInterval, min: stats[0], max: stats[1] }; + } + + return p; + }, {} as NumericColumnStatsMap); +}; + +export const getHistogramsForFields = async ( + client: IScopedClusterClient, + indexPatternTitle: string, + query: any, + fields: HistogramField[], + samplerShardSize: number, + runtimeMappings?: estypes.MappingRuntimeFields +) => { + const { asCurrentUser } = client; + const aggIntervals = await getAggIntervals( + client, + indexPatternTitle, + query, + fields, + samplerShardSize, + runtimeMappings + ); + + const chartDataAggs = fields.reduce((aggs, field) => { + const fieldName = field.fieldName; + const fieldType = field.type; + const id = stringHash(fieldName); + if (fieldType === KBN_FIELD_TYPES.NUMBER || fieldType === KBN_FIELD_TYPES.DATE) { + if (aggIntervals[id] !== undefined) { + aggs[`${id}_histogram`] = { + histogram: { + field: fieldName, + interval: aggIntervals[id].interval !== 0 ? aggIntervals[id].interval : 1, + }, + }; + } + } else if (fieldType === KBN_FIELD_TYPES.STRING || fieldType === KBN_FIELD_TYPES.BOOLEAN) { + if (fieldType === KBN_FIELD_TYPES.STRING) { + aggs[`${id}_cardinality`] = { + cardinality: { + field: fieldName, + }, + }; + } + aggs[`${id}_terms`] = { + terms: { + field: fieldName, + size: MAX_CHART_COLUMNS, + }, + }; + } + return aggs; + }, {} as Record); + + if (Object.keys(chartDataAggs).length === 0) { + return []; + } + + const { body } = await asCurrentUser.search({ + index: indexPatternTitle, + size: 0, + body: { + query, + aggs: buildSamplerAggregation(chartDataAggs, samplerShardSize), + size: 0, + ...(isPopulatedObject(runtimeMappings) ? { runtime_mappings: runtimeMappings } : {}), + }, + }); + + const aggsPath = getSamplerAggregationsResponsePath(samplerShardSize); + const aggregations = aggsPath.length > 0 ? get(body.aggregations, aggsPath) : body.aggregations; + + const chartsData: ChartData[] = fields.map( + (field): ChartData => { + const fieldName = field.fieldName; + const fieldType = field.type; + const id = stringHash(field.fieldName); + + if (fieldType === KBN_FIELD_TYPES.NUMBER || fieldType === KBN_FIELD_TYPES.DATE) { + if (aggIntervals[id] === undefined) { + return { + type: 'numeric', + data: [], + interval: 0, + stats: [0, 0], + id: fieldName, + }; + } + + return { + data: aggregations[`${id}_histogram`].buckets, + interval: aggIntervals[id].interval, + stats: [aggIntervals[id].min, aggIntervals[id].max], + type: 'numeric', + id: fieldName, + }; + } else if (fieldType === KBN_FIELD_TYPES.STRING || fieldType === KBN_FIELD_TYPES.BOOLEAN) { + return { + type: fieldType === KBN_FIELD_TYPES.STRING ? 'ordinal' : 'boolean', + cardinality: + fieldType === KBN_FIELD_TYPES.STRING ? aggregations[`${id}_cardinality`].value : 2, + data: aggregations[`${id}_terms`].buckets, + id: fieldName, + }; + } + + return { + type: 'unsupported', + id: fieldName, + }; + } + ); + + return chartsData; +}; diff --git a/x-pack/plugins/ml/public/application/datavisualizer/index_based/components/field_data_row/examples_list/index.ts b/x-pack/plugins/data_visualizer/server/models/data_visualizer/index.ts similarity index 84% rename from x-pack/plugins/ml/public/application/datavisualizer/index_based/components/field_data_row/examples_list/index.ts rename to x-pack/plugins/data_visualizer/server/models/data_visualizer/index.ts index 966c844987002..a29957b159b7e 100644 --- a/x-pack/plugins/ml/public/application/datavisualizer/index_based/components/field_data_row/examples_list/index.ts +++ b/x-pack/plugins/data_visualizer/server/models/data_visualizer/index.ts @@ -5,4 +5,4 @@ * 2.0. */ -export { ExamplesList } from './examples_list'; +export * from './data_visualizer'; diff --git a/x-pack/plugins/data_visualizer/server/models/data_visualizer/process_distribution_data.ts b/x-pack/plugins/data_visualizer/server/models/data_visualizer/process_distribution_data.ts new file mode 100644 index 0000000000000..4e40c2baaf701 --- /dev/null +++ b/x-pack/plugins/data_visualizer/server/models/data_visualizer/process_distribution_data.ts @@ -0,0 +1,108 @@ +/* + * 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 { last } from 'lodash'; +import { Distribution } from '../../types'; + +export const processDistributionData = ( + percentiles: Array<{ value: number }>, + percentileSpacing: number, + minValue: number +): Distribution => { + const distribution: Distribution = { percentiles: [], minPercentile: 0, maxPercentile: 100 }; + if (percentiles.length === 0) { + return distribution; + } + + let percentileBuckets: Array<{ value: number }> = []; + let lowerBound = minValue; + if (lowerBound >= 0) { + // By default return results for 0 - 90% percentiles. + distribution.minPercentile = 0; + distribution.maxPercentile = 90; + percentileBuckets = percentiles.slice(0, percentiles.length - 2); + + // Look ahead to the last percentiles and process these too if + // they don't add more than 50% to the value range. + const lastValue = (last(percentileBuckets) as any).value; + const upperBound = lowerBound + 1.5 * (lastValue - lowerBound); + const filteredLength = percentileBuckets.length; + for (let i = filteredLength; i < percentiles.length; i++) { + if (percentiles[i].value < upperBound) { + percentileBuckets.push(percentiles[i]); + distribution.maxPercentile += percentileSpacing; + } else { + break; + } + } + } else { + // By default return results for 5 - 95% percentiles. + const dataMin = lowerBound; + lowerBound = percentiles[0].value; + distribution.minPercentile = 5; + distribution.maxPercentile = 95; + percentileBuckets = percentiles.slice(1, percentiles.length - 1); + + // Add in 0-5 and 95-100% if they don't add more + // than 25% to the value range at either end. + const lastValue: number = (last(percentileBuckets) as any).value; + const maxDiff = 0.25 * (lastValue - lowerBound); + if (lowerBound - dataMin < maxDiff) { + percentileBuckets.splice(0, 0, percentiles[0]); + distribution.minPercentile = 0; + lowerBound = dataMin; + } + + if (percentiles[percentiles.length - 1].value - lastValue < maxDiff) { + percentileBuckets.push(percentiles[percentiles.length - 1]); + distribution.maxPercentile = 100; + } + } + + // Combine buckets with the same value. + const totalBuckets = percentileBuckets.length; + let lastBucketValue = lowerBound; + let numEqualValueBuckets = 0; + for (let i = 0; i < totalBuckets; i++) { + const bucket = percentileBuckets[i]; + + // Results from the percentiles aggregation can have precision rounding + // artifacts e.g returning 200 and 200.000000000123, so check for equality + // around double floating point precision i.e. 15 sig figs. + if (bucket.value.toPrecision(15) !== lastBucketValue.toPrecision(15)) { + // Create a bucket for any 'equal value' buckets which had a value <= last bucket + if (numEqualValueBuckets > 0) { + distribution.percentiles.push({ + percent: numEqualValueBuckets * percentileSpacing, + minValue: lastBucketValue, + maxValue: lastBucketValue, + }); + } + + distribution.percentiles.push({ + percent: percentileSpacing, + minValue: lastBucketValue, + maxValue: bucket.value, + }); + + lastBucketValue = bucket.value; + numEqualValueBuckets = 0; + } else { + numEqualValueBuckets++; + if (i === totalBuckets - 1) { + // If at the last bucket, create a final bucket for the equal value buckets. + distribution.percentiles.push({ + percent: numEqualValueBuckets * percentileSpacing, + minValue: lastBucketValue, + maxValue: lastBucketValue, + }); + } + } + } + + return distribution; +}; diff --git a/x-pack/plugins/data_visualizer/server/plugin.ts b/x-pack/plugins/data_visualizer/server/plugin.ts new file mode 100644 index 0000000000000..4ae695b05b81f --- /dev/null +++ b/x-pack/plugins/data_visualizer/server/plugin.ts @@ -0,0 +1,20 @@ +/* + * 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 { CoreSetup, CoreStart, Plugin } from 'src/core/server'; +import { StartDeps, SetupDeps } from './types'; +import { dataVisualizerRoutes } from './routes'; + +export class DataVisualizerPlugin implements Plugin { + constructor() {} + + async setup(coreSetup: CoreSetup, plugins: SetupDeps) { + dataVisualizerRoutes(coreSetup); + } + + start(core: CoreStart) {} +} diff --git a/x-pack/plugins/ml/public/application/datavisualizer/index_based/components/field_data_row/choropleth_map/index.ts b/x-pack/plugins/data_visualizer/server/routes/index.ts similarity index 83% rename from x-pack/plugins/ml/public/application/datavisualizer/index_based/components/field_data_row/choropleth_map/index.ts rename to x-pack/plugins/data_visualizer/server/routes/index.ts index 6159b5e2ad9bb..892f6cbd77361 100644 --- a/x-pack/plugins/ml/public/application/datavisualizer/index_based/components/field_data_row/choropleth_map/index.ts +++ b/x-pack/plugins/data_visualizer/server/routes/index.ts @@ -5,4 +5,4 @@ * 2.0. */ -export { ChoroplethMap } from './choropleth_map'; +export { dataVisualizerRoutes } from './routes'; diff --git a/x-pack/plugins/data_visualizer/server/routes/routes.ts b/x-pack/plugins/data_visualizer/server/routes/routes.ts new file mode 100644 index 0000000000000..13a0031a25dfd --- /dev/null +++ b/x-pack/plugins/data_visualizer/server/routes/routes.ts @@ -0,0 +1,262 @@ +/* + * 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 type { CoreSetup, IScopedClusterClient } from 'kibana/server'; +import { estypes } from '@elastic/elasticsearch'; +import { + dataVisualizerFieldHistogramsSchema, + dataVisualizerFieldStatsSchema, + dataVisualizerOverallStatsSchema, + indexPatternTitleSchema, +} from './schemas'; +import type { Field, StartDeps, HistogramField } from '../types'; +import { DataVisualizer } from '../models/data_visualizer'; +import { wrapError } from '../utils/error_wrapper'; + +function getOverallStats( + client: IScopedClusterClient, + indexPatternTitle: string, + query: object, + aggregatableFields: string[], + nonAggregatableFields: string[], + samplerShardSize: number, + timeFieldName: string | undefined, + earliestMs: number | undefined, + latestMs: number | undefined, + runtimeMappings: estypes.MappingRuntimeFields +) { + const dv = new DataVisualizer(client); + return dv.getOverallStats( + indexPatternTitle, + query, + aggregatableFields, + nonAggregatableFields, + samplerShardSize, + timeFieldName, + earliestMs, + latestMs, + runtimeMappings + ); +} + +function getStatsForFields( + client: IScopedClusterClient, + indexPatternTitle: string, + query: any, + fields: Field[], + samplerShardSize: number, + timeFieldName: string | undefined, + earliestMs: number | undefined, + latestMs: number | undefined, + interval: number | undefined, + maxExamples: number, + runtimeMappings: estypes.MappingRuntimeFields +) { + const dv = new DataVisualizer(client); + return dv.getStatsForFields( + indexPatternTitle, + query, + fields, + samplerShardSize, + timeFieldName, + earliestMs, + latestMs, + interval, + maxExamples, + runtimeMappings + ); +} + +function getHistogramsForFields( + client: IScopedClusterClient, + indexPatternTitle: string, + query: any, + fields: HistogramField[], + samplerShardSize: number, + runtimeMappings: estypes.MappingRuntimeFields +) { + const dv = new DataVisualizer(client); + return dv.getHistogramsForFields( + indexPatternTitle, + query, + fields, + samplerShardSize, + runtimeMappings + ); +} +/** + * Routes for the index data visualizer. + */ +export function dataVisualizerRoutes(coreSetup: CoreSetup) { + const router = coreSetup.http.createRouter(); + + /** + * @apiGroup DataVisualizer + * + * @api {post} /internal/data_visualizer/get_field_histograms/:indexPatternTitle Get histograms for fields + * @apiName GetHistogramsForFields + * @apiDescription Returns the histograms on a list fields in the specified index pattern. + * + * @apiSchema (params) indexPatternTitleSchema + * @apiSchema (body) dataVisualizerFieldHistogramsSchema + * + * @apiSuccess {Object} fieldName histograms by field, keyed on the name of the field. + */ + router.post( + { + path: '/internal/data_visualizer/get_field_histograms/{indexPatternTitle}', + validate: { + params: indexPatternTitleSchema, + body: dataVisualizerFieldHistogramsSchema, + }, + }, + async (context, request, response) => { + try { + const { + params: { indexPatternTitle }, + body: { query, fields, samplerShardSize, runtimeMappings }, + } = request; + + const results = await getHistogramsForFields( + context.core.elasticsearch.client, + indexPatternTitle, + query, + fields, + samplerShardSize, + runtimeMappings + ); + + return response.ok({ + body: results, + }); + } catch (e) { + return response.customError(wrapError(e)); + } + } + ); + + /** + * @apiGroup DataVisualizer + * + * @api {post} /internal/data_visualizer/get_field_stats/:indexPatternTitle Get stats for fields + * @apiName GetStatsForFields + * @apiDescription Returns the stats on individual fields in the specified index pattern. + * + * @apiSchema (params) indexPatternTitleSchema + * @apiSchema (body) dataVisualizerFieldStatsSchema + * + * @apiSuccess {Object} fieldName stats by field, keyed on the name of the field. + */ + router.post( + { + path: '/internal/data_visualizer/get_field_stats/{indexPatternTitle}', + validate: { + params: indexPatternTitleSchema, + body: dataVisualizerFieldStatsSchema, + }, + }, + async (context, request, response) => { + try { + const { + params: { indexPatternTitle }, + body: { + query, + fields, + samplerShardSize, + timeFieldName, + earliest, + latest, + interval, + maxExamples, + runtimeMappings, + }, + } = request; + const results = await getStatsForFields( + context.core.elasticsearch.client, + indexPatternTitle, + query, + fields, + samplerShardSize, + timeFieldName, + earliest, + latest, + interval, + maxExamples, + runtimeMappings + ); + + return response.ok({ + body: results, + }); + } catch (e) { + return response.customError(wrapError(e)); + } + } + ); + + /** + * @apiGroup DataVisualizer + * + * @api {post} /internal/data_visualizer/get_overall_stats/:indexPatternTitle Get overall stats + * @apiName GetOverallStats + * @apiDescription Returns the top level overall stats for the specified index pattern. + * + * @apiSchema (params) indexPatternTitleSchema + * @apiSchema (body) dataVisualizerOverallStatsSchema + * + * @apiSuccess {number} totalCount total count of documents. + * @apiSuccess {Object} aggregatableExistsFields stats on aggregatable fields that exist in documents. + * @apiSuccess {Object} aggregatableNotExistsFields stats on aggregatable fields that do not exist in documents. + * @apiSuccess {Object} nonAggregatableExistsFields stats on non-aggregatable fields that exist in documents. + * @apiSuccess {Object} nonAggregatableNotExistsFields stats on non-aggregatable fields that do not exist in documents. + */ + router.post( + { + path: '/internal/data_visualizer/get_overall_stats/{indexPatternTitle}', + validate: { + params: indexPatternTitleSchema, + body: dataVisualizerOverallStatsSchema, + }, + }, + async (context, request, response) => { + try { + const { + params: { indexPatternTitle }, + body: { + query, + aggregatableFields, + nonAggregatableFields, + samplerShardSize, + timeFieldName, + earliest, + latest, + runtimeMappings, + }, + } = request; + + const results = await getOverallStats( + context.core.elasticsearch.client, + indexPatternTitle, + query, + aggregatableFields, + nonAggregatableFields, + samplerShardSize, + timeFieldName, + earliest, + latest, + runtimeMappings + ); + + return response.ok({ + body: results, + }); + } catch (e) { + return response.customError(wrapError(e)); + } + } + ); +} diff --git a/x-pack/plugins/ml/public/application/components/field_title_bar/index.ts b/x-pack/plugins/data_visualizer/server/routes/schemas/index.ts similarity index 83% rename from x-pack/plugins/ml/public/application/components/field_title_bar/index.ts rename to x-pack/plugins/data_visualizer/server/routes/schemas/index.ts index 9c2be066c1052..156336feef29e 100644 --- a/x-pack/plugins/ml/public/application/components/field_title_bar/index.ts +++ b/x-pack/plugins/data_visualizer/server/routes/schemas/index.ts @@ -5,4 +5,4 @@ * 2.0. */ -export { FieldTitleBar } from './field_title_bar'; +export * from './index_data_visualizer_schemas'; diff --git a/x-pack/plugins/data_visualizer/server/routes/schemas/index_data_visualizer_schemas.ts b/x-pack/plugins/data_visualizer/server/routes/schemas/index_data_visualizer_schemas.ts new file mode 100644 index 0000000000000..0f145081d8cec --- /dev/null +++ b/x-pack/plugins/data_visualizer/server/routes/schemas/index_data_visualizer_schemas.ts @@ -0,0 +1,76 @@ +/* + * 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 { schema } from '@kbn/config-schema'; +import { isRuntimeField } from '../../../common/utils/runtime_field_utils'; + +export const runtimeMappingsSchema = schema.object( + {}, + { + unknowns: 'allow', + validate: (v: object) => { + if (Object.values(v).some((o) => !isRuntimeField(o))) { + return 'Invalid runtime field'; + } + }, + } +); + +export const indexPatternTitleSchema = schema.object({ + /** Title of the index pattern for which to return stats. */ + indexPatternTitle: schema.string(), +}); + +export const dataVisualizerFieldHistogramsSchema = schema.object({ + /** Query to match documents in the index. */ + query: schema.any(), + /** The fields to return histogram data. */ + fields: schema.arrayOf(schema.any()), + /** Number of documents to be collected in the sample processed on each shard, or -1 for no sampling. */ + samplerShardSize: schema.number(), + /** Optional search time runtime fields */ + runtimeMappings: runtimeMappingsSchema, +}); + +export const dataVisualizerFieldStatsSchema = schema.object({ + /** Query to match documents in the index. */ + query: schema.any(), + fields: schema.arrayOf(schema.any()), + /** Number of documents to be collected in the sample processed on each shard, or -1 for no sampling. */ + samplerShardSize: schema.number(), + /** Name of the time field in the index (optional). */ + timeFieldName: schema.maybe(schema.string()), + /** Earliest timestamp for search, as epoch ms (optional). */ + earliest: schema.maybe(schema.number()), + /** Latest timestamp for search, as epoch ms (optional). */ + latest: schema.maybe(schema.number()), + /** Aggregation interval, in milliseconds, to use for obtaining document counts over time (optional). */ + interval: schema.maybe(schema.number()), + /** Maximum number of examples to return for text type fields. */ + maxExamples: schema.number(), + /** Optional search time runtime fields */ + runtimeMappings: runtimeMappingsSchema, +}); + +export const dataVisualizerOverallStatsSchema = schema.object({ + /** Query to match documents in the index. */ + query: schema.any(), + /** Names of aggregatable fields for which to return stats. */ + aggregatableFields: schema.arrayOf(schema.string()), + /** Names of non-aggregatable fields for which to return stats. */ + nonAggregatableFields: schema.arrayOf(schema.string()), + /** Number of documents to be collected in the sample processed on each shard, or -1 for no sampling. */ + samplerShardSize: schema.number(), + /** Name of the time field in the index (optional). */ + timeFieldName: schema.maybe(schema.string()), + /** Earliest timestamp for search, as epoch ms (optional). */ + earliest: schema.maybe(schema.number()), + /** Latest timestamp for search, as epoch ms (optional). */ + latest: schema.maybe(schema.number()), + /** Optional search time runtime fields */ + runtimeMappings: runtimeMappingsSchema, +}); diff --git a/x-pack/plugins/data_visualizer/server/types/chart_data.ts b/x-pack/plugins/data_visualizer/server/types/chart_data.ts new file mode 100644 index 0000000000000..99c23cf88b5ba --- /dev/null +++ b/x-pack/plugins/data_visualizer/server/types/chart_data.ts @@ -0,0 +1,168 @@ +/* + * 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. + */ + +export interface FieldData { + fieldName: string; + existsInDocs: boolean; + stats?: { + sampleCount?: number; + count?: number; + cardinality?: number; + }; +} + +export interface Field { + fieldName: string; + type: string; + cardinality: number; +} + +export interface HistogramField { + fieldName: string; + type: string; +} + +export interface Distribution { + percentiles: any[]; + minPercentile: number; + maxPercentile: number; +} + +export interface Aggs { + [key: string]: any; +} + +export interface Bucket { + doc_count: number; +} + +export interface NumericFieldStats { + fieldName: string; + count: number; + min: number; + max: number; + avg: number; + isTopValuesSampled: boolean; + topValues: Bucket[]; + topValuesSampleSize: number; + topValuesSamplerShardSize: number; + median?: number; + distribution?: Distribution; +} + +export interface StringFieldStats { + fieldName: string; + isTopValuesSampled: boolean; + topValues: Bucket[]; + topValuesSampleSize: number; + topValuesSamplerShardSize: number; +} + +export interface DateFieldStats { + fieldName: string; + count: number; + earliest: number; + latest: number; +} + +export interface BooleanFieldStats { + fieldName: string; + count: number; + trueCount: number; + falseCount: number; + [key: string]: number | string; +} + +export interface DocumentCountStats { + documentCounts: { + interval: number; + buckets: { [key: string]: number }; + }; +} + +export interface FieldExamples { + fieldName: string; + examples: any[]; +} + +export interface NumericColumnStats { + interval: number; + min: number; + max: number; +} +export type NumericColumnStatsMap = Record; + +export interface AggHistogram { + histogram: { + field: string; + interval: number; + }; +} + +export interface AggTerms { + terms: { + field: string; + size: number; + }; +} + +export interface NumericDataItem { + key: number; + key_as_string?: string; + doc_count: number; +} + +export interface NumericChartData { + data: NumericDataItem[]; + id: string; + interval: number; + stats: [number, number]; + type: 'numeric'; +} + +export interface OrdinalDataItem { + key: string; + key_as_string?: string; + doc_count: number; +} + +export interface OrdinalChartData { + type: 'ordinal' | 'boolean'; + cardinality: number; + data: OrdinalDataItem[]; + id: string; +} + +export interface UnsupportedChartData { + id: string; + type: 'unsupported'; +} + +export interface FieldAggCardinality { + field: string; + percent?: any; +} + +export interface ScriptAggCardinality { + script: any; +} + +export interface AggCardinality { + cardinality: FieldAggCardinality | ScriptAggCardinality; +} + +export type ChartRequestAgg = AggHistogram | AggCardinality | AggTerms; + +export type ChartData = NumericChartData | OrdinalChartData | UnsupportedChartData; + +export type BatchStats = + | NumericFieldStats + | StringFieldStats + | BooleanFieldStats + | DateFieldStats + | DocumentCountStats + | FieldExamples; diff --git a/x-pack/plugins/data_visualizer/server/types/deps.ts b/x-pack/plugins/data_visualizer/server/types/deps.ts new file mode 100644 index 0000000000000..fe982b1fa5e1a --- /dev/null +++ b/x-pack/plugins/data_visualizer/server/types/deps.ts @@ -0,0 +1,16 @@ +/* + * 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 type { SecurityPluginStart } from '../../../security/server'; +import type { UsageCollectionSetup } from '../../../../../src/plugins/usage_collection/server'; + +export interface StartDeps { + security?: SecurityPluginStart; +} +export interface SetupDeps { + usageCollection: UsageCollectionSetup; +} diff --git a/x-pack/plugins/ml/public/application/components/field_type_icon/index.ts b/x-pack/plugins/data_visualizer/server/types/index.ts similarity index 82% rename from x-pack/plugins/ml/public/application/components/field_type_icon/index.ts rename to x-pack/plugins/data_visualizer/server/types/index.ts index fa825e447be30..e0379b514de32 100644 --- a/x-pack/plugins/ml/public/application/components/field_type_icon/index.ts +++ b/x-pack/plugins/data_visualizer/server/types/index.ts @@ -4,5 +4,5 @@ * 2.0; you may not use this file except in compliance with the Elastic License * 2.0. */ - -export { FieldTypeIcon } from './field_type_icon'; +export * from './deps'; +export * from './chart_data'; diff --git a/x-pack/plugins/data_visualizer/server/utils/error_wrapper.ts b/x-pack/plugins/data_visualizer/server/utils/error_wrapper.ts new file mode 100644 index 0000000000000..e0e6e263128e9 --- /dev/null +++ b/x-pack/plugins/data_visualizer/server/utils/error_wrapper.ts @@ -0,0 +1,24 @@ +/* + * 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 { CustomHttpResponseOptions, ResponseError } from 'kibana/server'; +import { boomify, isBoom } from '@hapi/boom'; + +export function wrapError(error: any): CustomHttpResponseOptions { + const boom = isBoom(error) + ? error + : boomify(error, { statusCode: error.status ?? error.statusCode }); + const statusCode = boom.output.statusCode; + return { + body: { + message: boom, + ...(statusCode !== 500 && error.body ? { attributes: { body: error.body } } : {}), + }, + headers: boom.output.headers as { [key: string]: string }, + statusCode, + }; +} diff --git a/x-pack/plugins/file_data_visualizer/tsconfig.json b/x-pack/plugins/data_visualizer/tsconfig.json similarity index 85% rename from x-pack/plugins/file_data_visualizer/tsconfig.json rename to x-pack/plugins/data_visualizer/tsconfig.json index 2d668bcaa2045..7c60002c3c630 100644 --- a/x-pack/plugins/file_data_visualizer/tsconfig.json +++ b/x-pack/plugins/data_visualizer/tsconfig.json @@ -14,7 +14,8 @@ { "path": "../../../src/plugins/usage_collection/tsconfig.json" }, { "path": "../security/tsconfig.json" }, { "path": "../file_upload/tsconfig.json" }, + { "path": "../lens/tsconfig.json" }, { "path": "../maps/tsconfig.json" }, - { "path": "../../../src/plugins/embeddable/tsconfig.json" }, + { "path": "../../../src/plugins/embeddable/tsconfig.json" } ] } diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/edit_flyout/_index.scss b/x-pack/plugins/file_data_visualizer/public/application/components/edit_flyout/_index.scss deleted file mode 100644 index 9558e46aad556..0000000000000 --- a/x-pack/plugins/file_data_visualizer/public/application/components/edit_flyout/_index.scss +++ /dev/null @@ -1 +0,0 @@ -@import 'edit_flyout' diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/file_datavisualizer_view/_index.scss b/x-pack/plugins/file_data_visualizer/public/application/components/file_datavisualizer_view/_index.scss deleted file mode 100644 index c1191ad270e4c..0000000000000 --- a/x-pack/plugins/file_data_visualizer/public/application/components/file_datavisualizer_view/_index.scss +++ /dev/null @@ -1 +0,0 @@ -@import 'file_datavisualizer_view'; diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/import_summary/_index.scss b/x-pack/plugins/file_data_visualizer/public/application/components/import_summary/_index.scss deleted file mode 100644 index 663e2db018921..0000000000000 --- a/x-pack/plugins/file_data_visualizer/public/application/components/import_summary/_index.scss +++ /dev/null @@ -1 +0,0 @@ -@import 'import_sumary' diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/results_view/_index.scss b/x-pack/plugins/file_data_visualizer/public/application/components/results_view/_index.scss deleted file mode 100644 index af3737cf017de..0000000000000 --- a/x-pack/plugins/file_data_visualizer/public/application/components/results_view/_index.scss +++ /dev/null @@ -1 +0,0 @@ -@import 'results_view' diff --git a/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_row/boolean_content_preview.tsx b/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_row/boolean_content_preview.tsx deleted file mode 100644 index c6c28da0baf04..0000000000000 --- a/x-pack/plugins/file_data_visualizer/public/application/components/stats_table/components/field_data_row/boolean_content_preview.tsx +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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, { FC, useMemo } from 'react'; -// import { EuiDataGridColumn } from '@elastic/eui'; -import { OrdinalChartData } from './field_histograms'; -// import { ColumnChart } from '../../../../../../components/data_grid/column_chart'; // TODO copy component -import { FieldDataRowProps } from '../../types'; -import { getTFPercentage } from '../../utils'; - -export const BooleanContentPreview: FC = ({ config }) => { - const chartData = useMemo(() => { - const results = getTFPercentage(config); - if (results) { - const data = [ - { key: 'true', key_as_string: 'true', doc_count: results.trueCount }, - { key: 'false', key_as_string: 'false', doc_count: results.falseCount }, - ]; - return { id: config.fieldName, cardinality: 2, data, type: 'boolean' } as OrdinalChartData; - } - }, [config]); - if (!chartData || config.fieldName === undefined) return null; - - // const columnType: EuiDataGridColumn = { - // id: config.fieldName, - // schema: undefined, - // }; - // const dataTestSubj = `mlDataGridChart-${config.fieldName}`; - - return ( - <> - // - ); -}; diff --git a/x-pack/plugins/file_data_visualizer/public/application/util/field_types_utils.ts b/x-pack/plugins/file_data_visualizer/public/application/util/field_types_utils.ts deleted file mode 100644 index 76a5f6ac20117..0000000000000 --- a/x-pack/plugins/file_data_visualizer/public/application/util/field_types_utils.ts +++ /dev/null @@ -1,49 +0,0 @@ -/* - * 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 { i18n } from '@kbn/i18n'; -import { JOB_FIELD_TYPES } from '../../../common'; - -export const jobTypeAriaLabels = { - BOOLEAN: i18n.translate('xpack.fileDataVisualizer.fieldTypeIcon.booleanTypeAriaLabel', { - defaultMessage: 'boolean type', - }), - DATE: i18n.translate('xpack.fileDataVisualizer.fieldTypeIcon.dateTypeAriaLabel', { - defaultMessage: 'date type', - }), - GEO_POINT: i18n.translate('xpack.fileDataVisualizer.fieldTypeIcon.geoPointTypeAriaLabel', { - defaultMessage: '{geoPointParam} type', - values: { - geoPointParam: 'geo point', - }, - }), - IP: i18n.translate('xpack.fileDataVisualizer.fieldTypeIcon.ipTypeAriaLabel', { - defaultMessage: 'ip type', - }), - KEYWORD: i18n.translate('xpack.fileDataVisualizer.fieldTypeIcon.keywordTypeAriaLabel', { - defaultMessage: 'keyword type', - }), - NUMBER: i18n.translate('xpack.fileDataVisualizer.fieldTypeIcon.numberTypeAriaLabel', { - defaultMessage: 'number type', - }), - TEXT: i18n.translate('xpack.fileDataVisualizer.fieldTypeIcon.textTypeAriaLabel', { - defaultMessage: 'text type', - }), - UNKNOWN: i18n.translate('xpack.fileDataVisualizer.fieldTypeIcon.unknownTypeAriaLabel', { - defaultMessage: 'unknown type', - }), -}; - -export const getJobTypeAriaLabel = (type: string) => { - const requestedFieldType = Object.keys(JOB_FIELD_TYPES).find( - (k) => JOB_FIELD_TYPES[k as keyof typeof JOB_FIELD_TYPES] === type - ); - if (requestedFieldType === undefined) { - return null; - } - return jobTypeAriaLabels[requestedFieldType as keyof typeof jobTypeAriaLabels]; -}; diff --git a/x-pack/plugins/file_upload/server/get_time_field_range.ts b/x-pack/plugins/file_upload/server/get_time_field_range.ts index 66a428128cbe1..0e8358f1671d0 100644 --- a/x-pack/plugins/file_upload/server/get_time_field_range.ts +++ b/x-pack/plugins/file_upload/server/get_time_field_range.ts @@ -5,11 +5,15 @@ * 2.0. */ import { IScopedClusterClient } from 'kibana/server'; +import { estypes } from '@elastic/elasticsearch'; +import { isPopulatedObject } from './utils/runtime_field_utils'; + export async function getTimeFieldRange( client: IScopedClusterClient, index: string[] | string, timeFieldName: string, - query: any + query: any, + runtimeMappings?: estypes.MappingRuntimeFields ): Promise<{ success: boolean; start: { epoch: number; string: string }; @@ -36,6 +40,7 @@ export async function getTimeFieldRange( }, }, }, + ...(isPopulatedObject(runtimeMappings) ? { runtime_mappings: runtimeMappings } : {}), }, }); diff --git a/x-pack/plugins/file_upload/server/plugin.ts b/x-pack/plugins/file_upload/server/plugin.ts index aaf21ed2aa2ec..c729afec92f94 100644 --- a/x-pack/plugins/file_upload/server/plugin.ts +++ b/x-pack/plugins/file_upload/server/plugin.ts @@ -10,14 +10,9 @@ import { CoreSetup, CoreStart, Logger, Plugin, PluginInitializerContext } from ' import { schema } from '@kbn/config-schema'; import { fileUploadRoutes } from './routes'; import { initFileUploadTelemetry } from './telemetry'; -import { UsageCollectionSetup } from '../../../../src/plugins/usage_collection/server'; import { UI_SETTING_MAX_FILE_SIZE, MAX_FILE_SIZE } from '../common'; -import { StartDeps } from './types'; import { setupCapabilities } from './capabilities'; - -interface SetupDeps { - usageCollection: UsageCollectionSetup; -} +import { StartDeps, SetupDeps } from './types'; export class FileUploadPlugin implements Plugin { private readonly _logger: Logger; diff --git a/x-pack/plugins/file_upload/server/routes.ts b/x-pack/plugins/file_upload/server/routes.ts index 3033f8300712c..bd3aa2688c735 100644 --- a/x-pack/plugins/file_upload/server/routes.ts +++ b/x-pack/plugins/file_upload/server/routes.ts @@ -21,7 +21,12 @@ import { getTimeFieldRange } from './get_time_field_range'; import { analyzeFile } from './analyze_file'; import { updateTelemetry } from './telemetry'; -import { importFileBodySchema, importFileQuerySchema, analyzeFileQuerySchema } from './schemas'; +import { + importFileBodySchema, + importFileQuerySchema, + analyzeFileQuerySchema, + runtimeMappingsSchema, +} from './schemas'; import { StartDeps } from './types'; import { checkFileUploadPrivileges } from './check_privileges'; @@ -219,6 +224,7 @@ export function fileUploadRoutes(coreSetup: CoreSetup, logge timeFieldName: schema.string(), /** Query to match documents in the index(es). */ query: schema.maybe(schema.any()), + runtimeMappings: schema.maybe(runtimeMappingsSchema), }), }, options: { @@ -227,12 +233,13 @@ export function fileUploadRoutes(coreSetup: CoreSetup, logge }, async (context, request, response) => { try { - const { index, timeFieldName, query } = request.body; + const { index, timeFieldName, query, runtimeMappings } = request.body; const resp = await getTimeFieldRange( context.core.elasticsearch.client, index, timeFieldName, - query + query, + runtimeMappings ); return response.ok({ diff --git a/x-pack/plugins/file_upload/server/schemas.ts b/x-pack/plugins/file_upload/server/schemas.ts index a0d54cf9ec553..baf7ed864f2e6 100644 --- a/x-pack/plugins/file_upload/server/schemas.ts +++ b/x-pack/plugins/file_upload/server/schemas.ts @@ -6,6 +6,7 @@ */ import { schema } from '@kbn/config-schema'; +import { isRuntimeField } from './utils/runtime_field_utils'; export const analyzeFileQuerySchema = schema.object({ charset: schema.maybe(schema.string()), @@ -40,3 +41,15 @@ export const importFileBodySchema = schema.object({ pipeline: schema.maybe(schema.any()), }), }); + +export const runtimeMappingsSchema = schema.object( + {}, + { + unknowns: 'allow', + validate: (v: object) => { + if (Object.values(v).some((o) => !isRuntimeField(o))) { + return 'Invalid runtime field'; + } + }, + } +); diff --git a/x-pack/plugins/file_upload/server/types.ts b/x-pack/plugins/file_upload/server/types.ts index d23661ebae711..241abadaf750f 100644 --- a/x-pack/plugins/file_upload/server/types.ts +++ b/x-pack/plugins/file_upload/server/types.ts @@ -6,7 +6,12 @@ */ import { SecurityPluginStart } from '../..//security/server'; +import { UsageCollectionSetup } from '../../../../src/plugins/usage_collection/server'; export interface StartDeps { security?: SecurityPluginStart; } + +export interface SetupDeps { + usageCollection: UsageCollectionSetup; +} diff --git a/x-pack/plugins/file_upload/server/utils/runtime_field_utils.ts b/x-pack/plugins/file_upload/server/utils/runtime_field_utils.ts new file mode 100644 index 0000000000000..921741110d2a3 --- /dev/null +++ b/x-pack/plugins/file_upload/server/utils/runtime_field_utils.ts @@ -0,0 +1,41 @@ +/* + * 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 { estypes } from '@elastic/elasticsearch'; +import { RUNTIME_FIELD_TYPES } from '../../../../../src/plugins/data/common/index_patterns'; + +type RuntimeType = typeof RUNTIME_FIELD_TYPES[number]; + +export const isPopulatedObject = ( + arg: unknown, + requiredAttributes: U[] = [] +): arg is Record => { + return ( + typeof arg === 'object' && + arg !== null && + Object.keys(arg).length > 0 && + (requiredAttributes.length === 0 || + requiredAttributes.every((d) => ({}.hasOwnProperty.call(arg, d)))) + ); +}; + +export function isRuntimeField(arg: unknown): arg is estypes.MappingRuntimeField { + return ( + ((isPopulatedObject(arg, ['type']) && Object.keys(arg).length === 1) || + (isPopulatedObject(arg, ['type', 'script']) && + Object.keys(arg).length === 2 && + (typeof arg.script === 'string' || + (isPopulatedObject(arg.script, ['source']) && + Object.keys(arg.script).length === 1 && + typeof arg.script.source === 'string')))) && + RUNTIME_FIELD_TYPES.includes(arg.type as RuntimeType) + ); +} + +export function isRuntimeMappings(arg: unknown): arg is estypes.MappingRuntimeFields { + return isPopulatedObject(arg) && Object.values(arg).every((d) => isRuntimeField(d)); +} diff --git a/x-pack/plugins/ml/common/types/ml_url_generator.ts b/x-pack/plugins/ml/common/types/ml_url_generator.ts index 2b05f231e509f..9c7145c848264 100644 --- a/x-pack/plugins/ml/common/types/ml_url_generator.ts +++ b/x-pack/plugins/ml/common/types/ml_url_generator.ts @@ -5,11 +5,7 @@ * 2.0. */ -import type { - Query, - RefreshInterval, - TimeRange, -} from '../../../../../src/plugins/data/common/query'; +import type { RefreshInterval, TimeRange } from '../../../../../src/plugins/data/common/query'; import type { JobId } from './anomaly_detection_jobs/job'; import { ML_PAGES } from '../constants/ml_url_generator'; import type { DataFrameAnalysisConfigType } from './data_frame_analytics'; @@ -44,24 +40,6 @@ export interface MlGenericUrlPageState extends MlIndexBasedSearchState { [key: string]: any; } -export interface DataVisualizerIndexBasedAppState extends Omit { - searchString?: Query['query']; - searchQuery?: Query['query']; - searchQueryLanguage?: SearchQueryLanguage; - visibleFieldTypes?: string[]; - visibleFieldNames?: string[]; - samplerShardSize?: number; - showDistributions?: boolean; - showAllFields?: boolean; - showEmptyFields?: boolean; -} - -export interface DataVisualizerFileBasedAppState extends Omit { - visibleFieldTypes?: string[]; - visibleFieldNames?: string[]; - showDistributions?: boolean; -} - export type MlGenericUrlState = MLPageState< | typeof ML_PAGES.DATA_VISUALIZER_INDEX_VIEWER | typeof ML_PAGES.ANOMALY_DETECTION_CREATE_JOB diff --git a/x-pack/plugins/ml/kibana.json b/x-pack/plugins/ml/kibana.json index 6804b3f52b52a..92bac61f3fab3 100644 --- a/x-pack/plugins/ml/kibana.json +++ b/x-pack/plugins/ml/kibana.json @@ -10,7 +10,7 @@ "data", "cloud", "features", - "fileDataVisualizer", + "dataVisualizer", "licensing", "share", "embeddable", diff --git a/x-pack/plugins/ml/public/__mocks__/ml_start_deps.ts b/x-pack/plugins/ml/public/__mocks__/ml_start_deps.ts index ad47e84319e4a..0907cce832bf8 100644 --- a/x-pack/plugins/ml/public/__mocks__/ml_start_deps.ts +++ b/x-pack/plugins/ml/public/__mocks__/ml_start_deps.ts @@ -24,5 +24,5 @@ export const createMlStartDepsMock = () => ({ maps: jest.fn(), lens: lensPluginMock.createStartContract(), triggersActionsUi: triggersActionsUiMock.createStart(), - fileDataVisualizer: jest.fn(), + dataVisualizer: jest.fn(), }); diff --git a/x-pack/plugins/ml/public/application/_index.scss b/x-pack/plugins/ml/public/application/_index.scss index da1c226a665f6..fb61a2a16c19d 100644 --- a/x-pack/plugins/ml/public/application/_index.scss +++ b/x-pack/plugins/ml/public/application/_index.scss @@ -9,7 +9,6 @@ // Sub applications @import 'data_frame_analytics/index'; - @import 'datavisualizer/index'; @import 'explorer/index'; // SASSTODO: This file needs to be rewritten @import 'jobs/index'; // SASSTODO: This collection of sass files has multiple problems @import 'overview/index'; @@ -22,7 +21,6 @@ @import 'components/color_range_legend/index'; @import 'components/controls/index'; @import 'components/entity_cell/index'; - @import 'components/field_title_bar/index'; @import 'components/influencers_list/index'; @import 'components/items_grid/index'; @import 'components/job_selector/index'; diff --git a/x-pack/plugins/ml/public/application/app.tsx b/x-pack/plugins/ml/public/application/app.tsx index e2fbcc77f2767..f16a7c561ac5d 100644 --- a/x-pack/plugins/ml/public/application/app.tsx +++ b/x-pack/plugins/ml/public/application/app.tsx @@ -82,7 +82,7 @@ const App: FC = ({ coreStart, deps, appMountParams }) => { embeddable: deps.embeddable, maps: deps.maps, triggersActionsUi: deps.triggersActionsUi, - fileDataVisualizer: deps.fileDataVisualizer, + dataVisualizer: deps.dataVisualizer, ...coreStart, }; @@ -125,7 +125,7 @@ export const renderApp = ( security: deps.security, urlGenerators: deps.share.urlGenerators, maps: deps.maps, - fileDataVisualizer: deps.fileDataVisualizer, + dataVisualizer: deps.dataVisualizer, }); appMountParams.onAppLeave((actions) => actions.default()); diff --git a/x-pack/plugins/ml/public/application/components/field_title_bar/_field_title_bar.scss b/x-pack/plugins/ml/public/application/components/field_title_bar/_field_title_bar.scss deleted file mode 100644 index 77d95653638ac..0000000000000 --- a/x-pack/plugins/ml/public/application/components/field_title_bar/_field_title_bar.scss +++ /dev/null @@ -1,28 +0,0 @@ -.ml-field-title-bar { - @include euiFontSizeM; - font-family: Roboto Mono, serif; - font-style: normal; - font-weight: bold; - font-size: $euiFontSizeS; - border-radius: $euiBorderRadius $euiBorderRadius 0 0; - padding: $euiSizeXS; - margin: (-$euiSize) (-$euiSize) 0 (-$euiSize); - border-top: 3px solid; - text-align: center; - - .field-type-icon { - vertical-align: middle; - margin-bottom: -$euiSizeXS; - display: inline-block; - } - - .field-name { - @include euiTextTruncate; - - vertical-align: middle; - padding-right: $euiSizeS; - max-width: 290px; // SASSTODO: Calculate value - display: inline-block; - margin-left: $euiSizeS; - } -} diff --git a/x-pack/plugins/ml/public/application/components/field_title_bar/_index.scss b/x-pack/plugins/ml/public/application/components/field_title_bar/_index.scss deleted file mode 100644 index d12cf5d008c44..0000000000000 --- a/x-pack/plugins/ml/public/application/components/field_title_bar/_index.scss +++ /dev/null @@ -1 +0,0 @@ -@import 'field_title_bar'; \ No newline at end of file diff --git a/x-pack/plugins/ml/public/application/components/field_title_bar/field_title_bar.test.tsx b/x-pack/plugins/ml/public/application/components/field_title_bar/field_title_bar.test.tsx deleted file mode 100644 index 20fd024fdef86..0000000000000 --- a/x-pack/plugins/ml/public/application/components/field_title_bar/field_title_bar.test.tsx +++ /dev/null @@ -1,113 +0,0 @@ -/* - * 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 { mountWithIntl } from '@kbn/test/jest'; - -import React from 'react'; - -import { FieldTitleBar } from './field_title_bar'; -import { ML_JOB_FIELD_TYPES } from '../../../../common/constants/field_types'; - -describe('FieldTitleBar', () => { - test(`card prop is an empty object`, () => { - const props = { - card: { - type: ML_JOB_FIELD_TYPES.NUMBER, - existsInDocs: true, - loading: false, - aggregatable: true, - }, - }; - - const wrapper = mountWithIntl(); - - const fieldName = wrapper.find({ className: 'field-name' }).text(); - expect(fieldName).toEqual('document count'); - - const hasClassName = wrapper.find('EuiText').hasClass('document_count'); - expect(hasClassName).toBeTruthy(); - }); - - test(`card.isUnsupportedType is true`, () => { - const props = { - card: { - type: ML_JOB_FIELD_TYPES.UNKNOWN, - fieldName: 'foo', - existsInDocs: true, - loading: false, - aggregatable: true, - isUnsupportedType: true, - }, - }; - - const wrapper = mountWithIntl(); - - const fieldName = wrapper.find({ className: 'field-name' }).text(); - expect(fieldName).toEqual(props.card.fieldName); - - const hasClassName = wrapper.find('EuiText').hasClass('type-other'); - expect(hasClassName).toBeTruthy(); - }); - - test(`card.fieldName and card.type is set`, () => { - const props = { - card: { - type: ML_JOB_FIELD_TYPES.KEYWORD, - fieldName: 'bar', - existsInDocs: true, - loading: false, - aggregatable: true, - }, - }; - - const wrapper = mountWithIntl(); - - const fieldName = wrapper.find({ className: 'field-name' }).text(); - expect(fieldName).toEqual(props.card.fieldName); - - const hasClassName = wrapper.find('EuiText').hasClass(props.card.type); - expect(hasClassName).toBeTruthy(); - }); - - test(`tooltip hovering`, () => { - // Use fake timers so we don't have to wait for the EuiToolTip timeout - jest.useFakeTimers(); - - const props = { - card: { - type: ML_JOB_FIELD_TYPES.KEYWORD, - fieldName: 'bar', - existsInDocs: true, - loading: false, - aggregatable: true, - }, - }; - const wrapper = mountWithIntl(); - const container = wrapper.find({ className: 'field-name' }); - - expect(wrapper.find('EuiToolTip').children()).toHaveLength(2); - - container.simulate('mouseover'); - - // Run the timers so the EuiTooltip will be visible - jest.runAllTimers(); - - wrapper.update(); - expect(wrapper.find('EuiToolTip').children()).toHaveLength(3); - - container.simulate('mouseout'); - - // Run the timers so the EuiTooltip will be hidden again - jest.runAllTimers(); - - wrapper.update(); - expect(wrapper.find('EuiToolTip').children()).toHaveLength(2); - - // Clearing all mocks will also reset fake timers. - jest.clearAllMocks(); - }); -}); diff --git a/x-pack/plugins/ml/public/application/components/field_title_bar/field_title_bar.tsx b/x-pack/plugins/ml/public/application/components/field_title_bar/field_title_bar.tsx deleted file mode 100644 index 85971b66a687f..0000000000000 --- a/x-pack/plugins/ml/public/application/components/field_title_bar/field_title_bar.tsx +++ /dev/null @@ -1,64 +0,0 @@ -/* - * 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, { FC } from 'react'; - -import { EuiText, EuiToolTip } from '@elastic/eui'; - -import { i18n } from '@kbn/i18n'; - -import { FieldTypeIcon } from '../field_type_icon'; -import { getMLJobTypeAriaLabel } from '../../util/field_types_utils'; -import { - FieldVisConfig, - FileBasedFieldVisConfig, - isIndexBasedFieldVisConfig, -} from '../../datavisualizer/stats_table/types/field_vis_config'; - -interface Props { - card: FieldVisConfig | FileBasedFieldVisConfig; -} - -export const FieldTitleBar: FC = ({ card }) => { - const fieldName = - card.fieldName || - i18n.translate('xpack.ml.fieldTitleBar.documentCountLabel', { - defaultMessage: 'document count', - }); - const cardTitleAriaLabel = [fieldName]; - - const classNames = ['ml-field-title-bar']; - - if (card.fieldName === undefined) { - classNames.push('document_count'); - } else if (isIndexBasedFieldVisConfig(card) && card.isUnsupportedType === true) { - classNames.push('type-other'); - } else { - classNames.push(card.type); - } - - if (isIndexBasedFieldVisConfig(card) && card.isUnsupportedType !== true) { - // All the supported field types have aria labels. - cardTitleAriaLabel.unshift(getMLJobTypeAriaLabel(card.type)!); - } - - return ( - - - -
- {fieldName} -
-
-
- ); -}; diff --git a/x-pack/plugins/ml/public/application/components/field_type_icon/__snapshots__/field_type_icon.test.tsx.snap b/x-pack/plugins/ml/public/application/components/field_type_icon/__snapshots__/field_type_icon.test.tsx.snap deleted file mode 100644 index 769ebdeba9955..0000000000000 --- a/x-pack/plugins/ml/public/application/components/field_type_icon/__snapshots__/field_type_icon.test.tsx.snap +++ /dev/null @@ -1,16 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`FieldTypeIcon render component when type matches a field type 1`] = ` - - - -`; diff --git a/x-pack/plugins/ml/public/application/components/field_type_icon/field_type_icon.test.tsx b/x-pack/plugins/ml/public/application/components/field_type_icon/field_type_icon.test.tsx deleted file mode 100644 index 4a8b067710c95..0000000000000 --- a/x-pack/plugins/ml/public/application/components/field_type_icon/field_type_icon.test.tsx +++ /dev/null @@ -1,52 +0,0 @@ -/* - * 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 { mount, shallow } from 'enzyme'; - -import { FieldTypeIcon } from './field_type_icon'; -import { ML_JOB_FIELD_TYPES } from '../../../../common/constants/field_types'; - -describe('FieldTypeIcon', () => { - test(`render component when type matches a field type`, () => { - const typeIconComponent = shallow( - - ); - expect(typeIconComponent).toMatchSnapshot(); - }); - - test(`render with tooltip and test hovering`, () => { - // Use fake timers so we don't have to wait for the EuiToolTip timeout - jest.useFakeTimers(); - - const typeIconComponent = mount( - - ); - const container = typeIconComponent.find({ 'data-test-subj': 'mlFieldTypeIcon' }); - - expect(typeIconComponent.find('EuiToolTip').children()).toHaveLength(1); - - container.simulate('mouseover'); - - // Run the timers so the EuiTooltip will be visible - jest.runAllTimers(); - - typeIconComponent.update(); - expect(typeIconComponent.find('EuiToolTip').children()).toHaveLength(2); - - container.simulate('mouseout'); - - // Run the timers so the EuiTooltip will be hidden again - jest.runAllTimers(); - - typeIconComponent.update(); - expect(typeIconComponent.find('EuiToolTip').children()).toHaveLength(1); - - // Clearing all mocks will also reset fake timers. - jest.clearAllMocks(); - }); -}); diff --git a/x-pack/plugins/ml/public/application/components/field_type_icon/field_type_icon.tsx b/x-pack/plugins/ml/public/application/components/field_type_icon/field_type_icon.tsx deleted file mode 100644 index 79ab210ce1dfe..0000000000000 --- a/x-pack/plugins/ml/public/application/components/field_type_icon/field_type_icon.tsx +++ /dev/null @@ -1,130 +0,0 @@ -/* - * 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, { FC } from 'react'; - -import { EuiToken, EuiToolTip } from '@elastic/eui'; - -import { i18n } from '@kbn/i18n'; - -import { getMLJobTypeAriaLabel } from '../../util/field_types_utils'; -import { ML_JOB_FIELD_TYPES } from '../../../../common/constants/field_types'; -import type { MlJobFieldType } from '../../../../common/types/field_types'; - -interface FieldTypeIconProps { - tooltipEnabled: boolean; - type: MlJobFieldType; - fieldName?: string; - needsAria: boolean; -} - -interface FieldTypeIconContainerProps { - ariaLabel: string | null; - iconType: string; - color: string; - needsAria: boolean; - [key: string]: any; -} - -export const FieldTypeIcon: FC = ({ - tooltipEnabled = false, - type, - fieldName, - needsAria = true, -}) => { - const ariaLabel = getMLJobTypeAriaLabel(type); - - let iconType = 'questionInCircle'; - let color = 'euiColorVis6'; - - switch (type) { - // Set icon types and colors - case ML_JOB_FIELD_TYPES.BOOLEAN: - iconType = 'tokenBoolean'; - color = 'euiColorVis5'; - break; - case ML_JOB_FIELD_TYPES.DATE: - iconType = 'tokenDate'; - color = 'euiColorVis7'; - break; - case ML_JOB_FIELD_TYPES.GEO_POINT: - case ML_JOB_FIELD_TYPES.GEO_SHAPE: - iconType = 'tokenGeo'; - color = 'euiColorVis8'; - break; - case ML_JOB_FIELD_TYPES.TEXT: - iconType = 'document'; - color = 'euiColorVis9'; - break; - case ML_JOB_FIELD_TYPES.IP: - iconType = 'tokenIP'; - color = 'euiColorVis3'; - break; - case ML_JOB_FIELD_TYPES.KEYWORD: - iconType = 'tokenText'; - color = 'euiColorVis0'; - break; - case ML_JOB_FIELD_TYPES.NUMBER: - iconType = 'tokenNumber'; - color = fieldName !== undefined ? 'euiColorVis1' : 'euiColorVis2'; - break; - case ML_JOB_FIELD_TYPES.UNKNOWN: - // Use defaults - break; - } - - const containerProps = { - ariaLabel, - iconType, - color, - needsAria, - }; - - if (tooltipEnabled === true) { - // wrap the inner component inside because EuiToolTip doesn't seem - // to support having another component directly inside the tooltip anchor - // see https://github.com/elastic/eui/issues/839 - return ( - - - - ); - } - - return ; -}; - -// If the tooltip is used, it will apply its events to its first inner child. -// To pass on its properties we apply `rest` to the outer `span` element. -const FieldTypeIconContainer: FC = ({ - ariaLabel, - iconType, - color, - needsAria, - ...rest -}) => { - const wrapperProps: { className: string; 'aria-label'?: string } = { - className: 'field-type-icon', - }; - if (needsAria && ariaLabel) { - wrapperProps['aria-label'] = ariaLabel; - } - - return ( - - - - - - ); -}; diff --git a/x-pack/plugins/ml/public/application/contexts/kibana/kibana_context.ts b/x-pack/plugins/ml/public/application/contexts/kibana/kibana_context.ts index b69a8a9b7867a..841f0d03fa21c 100644 --- a/x-pack/plugins/ml/public/application/contexts/kibana/kibana_context.ts +++ b/x-pack/plugins/ml/public/application/contexts/kibana/kibana_context.ts @@ -18,7 +18,7 @@ import { MlServicesContext } from '../../app'; import { IStorageWrapper } from '../../../../../../../src/plugins/kibana_utils/public'; import type { EmbeddableStart } from '../../../../../../../src/plugins/embeddable/public'; import type { MapsStartApi } from '../../../../../maps/public'; -import type { FileDataVisualizerPluginStart } from '../../../../../file_data_visualizer/public'; +import type { DataVisualizerPluginStart } from '../../../../../data_visualizer/public'; import type { LensPublicStart } from '../../../../../lens/public'; import { TriggersAndActionsUIPublicPluginStart } from '../../../../../triggers_actions_ui/public'; @@ -31,7 +31,7 @@ interface StartPlugins { maps?: MapsStartApi; lens?: LensPublicStart; triggersActionsUi?: TriggersAndActionsUIPublicPluginStart; - fileDataVisualizer?: FileDataVisualizerPluginStart; + dataVisualizer?: DataVisualizerPluginStart; } export type StartServices = CoreStart & StartPlugins & { diff --git a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_management/components/analytics_list/use_table_settings.ts b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_management/components/analytics_list/use_table_settings.ts index 5ac7b00e8af67..993aadd3f810f 100644 --- a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_management/components/analytics_list/use_table_settings.ts +++ b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_management/components/analytics_list/use_table_settings.ts @@ -8,10 +8,6 @@ import { Direction, EuiBasicTableProps, Pagination, PropertySort } from '@elastic/eui'; import { useCallback, useMemo } from 'react'; import { ListingPageUrlState } from '../../../../../../../common/types/common'; -import { - DataVisualizerFileBasedAppState, - DataVisualizerIndexBasedAppState, -} from '../../../../../../../common/types/ml_url_generator'; const PAGE_SIZE_OPTIONS = [10, 25, 50]; @@ -42,10 +38,7 @@ interface UseTableSettingsReturnValue { export function useTableSettings( items: TypeOfItem[], - pageState: - | ListingPageUrlState - | DataVisualizerIndexBasedAppState - | DataVisualizerFileBasedAppState, + pageState: ListingPageUrlState, updatePageState: (update: Partial) => void ): UseTableSettingsReturnValue { const { pageIndex, pageSize, sortField, sortDirection } = pageState; diff --git a/x-pack/plugins/ml/public/application/datavisualizer/_index.scss b/x-pack/plugins/ml/public/application/datavisualizer/_index.scss deleted file mode 100644 index c02883c573ead..0000000000000 --- a/x-pack/plugins/ml/public/application/datavisualizer/_index.scss +++ /dev/null @@ -1,2 +0,0 @@ -@import 'index_based/index'; -@import 'stats_table/index'; diff --git a/x-pack/plugins/ml/public/application/datavisualizer/datavisualizer_selector.tsx b/x-pack/plugins/ml/public/application/datavisualizer/datavisualizer_selector.tsx index 5f9127740709f..3b3b1af30610d 100644 --- a/x-pack/plugins/ml/public/application/datavisualizer/datavisualizer_selector.tsx +++ b/x-pack/plugins/ml/public/application/datavisualizer/datavisualizer_selector.tsx @@ -56,7 +56,7 @@ export const DatavisualizerSelector: FC = () => { licenseManagement, http: { basePath }, docLinks, - fileDataVisualizer, + dataVisualizer, }, } = useMlKibana(); @@ -68,12 +68,12 @@ export const DatavisualizerSelector: FC = () => { licenseManagement.enabled === true && isFullLicense() === false; - if (fileDataVisualizer === undefined) { + if (dataVisualizer === undefined) { // eslint-disable-next-line no-console console.error('File data visualizer plugin not available'); return null; } - const maxFileSize = fileDataVisualizer.getMaxBytesFormatted(); + const maxFileSize = dataVisualizer.getMaxBytesFormatted(); return ( diff --git a/x-pack/plugins/ml/public/application/datavisualizer/file_based/file_datavisualizer.tsx b/x-pack/plugins/ml/public/application/datavisualizer/file_based/file_datavisualizer.tsx index 3b4cfbf33fbfc..0e9eeda51f786 100644 --- a/x-pack/plugins/ml/public/application/datavisualizer/file_based/file_datavisualizer.tsx +++ b/x-pack/plugins/ml/public/application/datavisualizer/file_based/file_datavisualizer.tsx @@ -15,13 +15,13 @@ import { useMlKibana } from '../../contexts/kibana'; export const FileDataVisualizerPage: FC = () => { useTimefilter({ timeRangeSelector: false, autoRefreshSelector: false }); const { - services: { docLinks, fileDataVisualizer }, + services: { docLinks, dataVisualizer }, } = useMlKibana(); const [FileDataVisualizer, setFileDataVisualizer] = useState | null>(null); useEffect(() => { - if (fileDataVisualizer !== undefined) { - const { getFileDataVisualizerComponent } = fileDataVisualizer; + if (dataVisualizer !== undefined) { + const { getFileDataVisualizerComponent } = dataVisualizer; getFileDataVisualizerComponent().then(setFileDataVisualizer); } }, []); diff --git a/x-pack/plugins/ml/public/application/datavisualizer/index_based/_index.scss b/x-pack/plugins/ml/public/application/datavisualizer/index_based/_index.scss deleted file mode 100644 index 95a523753dfca..0000000000000 --- a/x-pack/plugins/ml/public/application/datavisualizer/index_based/_index.scss +++ /dev/null @@ -1 +0,0 @@ -@import 'components/field_data_row/index'; diff --git a/x-pack/plugins/ml/public/application/datavisualizer/index_based/common/index.ts b/x-pack/plugins/ml/public/application/datavisualizer/index_based/common/index.ts deleted file mode 100644 index fe99a63432793..0000000000000 --- a/x-pack/plugins/ml/public/application/datavisualizer/index_based/common/index.ts +++ /dev/null @@ -1,9 +0,0 @@ -/* - * 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. - */ - -export { FieldHistogramRequestConfig, FieldRequestConfig } from './request'; -export type { CombinedQuery } from './combined_query'; diff --git a/x-pack/plugins/ml/public/application/datavisualizer/index_based/components/actions_panel/actions_panel.tsx b/x-pack/plugins/ml/public/application/datavisualizer/index_based/components/actions_panel/actions_panel.tsx deleted file mode 100644 index ca393c2d8ce72..0000000000000 --- a/x-pack/plugins/ml/public/application/datavisualizer/index_based/components/actions_panel/actions_panel.tsx +++ /dev/null @@ -1,215 +0,0 @@ -/* - * 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, { FC, useState, useEffect } from 'react'; - -import { FormattedMessage } from '@kbn/i18n/react'; -import { i18n } from '@kbn/i18n'; -import { EuiSpacer, EuiTitle, EuiFlexGroup } from '@elastic/eui'; -import { LinkCard } from '../../../../components/link_card'; -import { DataRecognizer } from '../../../../components/data_recognizer'; -import { ML_PAGES } from '../../../../../../common/constants/ml_url_generator'; -import { - DISCOVER_APP_URL_GENERATOR, - DiscoverUrlGeneratorState, -} from '../../../../../../../../../src/plugins/discover/public'; -import { useMlKibana, useMlLink } from '../../../../contexts/kibana'; -import { isFullLicense } from '../../../../license'; -import { checkPermission } from '../../../../capabilities/check_capabilities'; -import { mlNodesAvailable } from '../../../../ml_nodes_check'; -import { useUrlState } from '../../../../util/url_state'; -import type { IIndexPattern } from '../../../../../../../../../src/plugins/data/common'; - -interface Props { - indexPattern: IIndexPattern; - searchString?: string | { [key: string]: any }; - searchQueryLanguage?: string; -} - -export const ActionsPanel: FC = ({ indexPattern, searchString, searchQueryLanguage }) => { - const [recognizerResultsCount, setRecognizerResultsCount] = useState(0); - const [discoverLink, setDiscoverLink] = useState(''); - const { - services: { - application: { capabilities }, - share: { - urlGenerators: { getUrlGenerator }, - }, - }, - } = useMlKibana(); - const [globalState] = useUrlState('_g'); - - const recognizerResults = { - count: 0, - onChange() { - setRecognizerResultsCount(recognizerResults.count); - }, - }; - const mlAvailable = isFullLicense() && checkPermission('canCreateJob') && mlNodesAvailable(); - const showCreateAnomalyDetectionJob = mlAvailable && indexPattern.timeFieldName !== undefined; - - const createJobLink = useMlLink({ - page: ML_PAGES.ANOMALY_DETECTION_CREATE_JOB_ADVANCED, - pageState: { index: indexPattern.id }, - }); - - const createDataFrameAnalyticsLink = useMlLink({ - page: ML_PAGES.DATA_FRAME_ANALYTICS_CREATE_JOB, - pageState: { index: indexPattern.id }, - }); - - useEffect(() => { - let unmounted = false; - - const indexPatternId = indexPattern.id; - const getDiscoverUrl = async (): Promise => { - const isDiscoverAvailable = capabilities.discover?.show ?? false; - if (!isDiscoverAvailable) { - return; - } - - const state: DiscoverUrlGeneratorState = { - indexPatternId, - }; - if (searchString && searchQueryLanguage !== undefined) { - state.query = { query: searchString, language: searchQueryLanguage }; - } - if (globalState?.time) { - state.timeRange = globalState.time; - } - if (globalState?.refreshInterval) { - state.refreshInterval = globalState.refreshInterval; - } - - let discoverUrlGenerator; - try { - discoverUrlGenerator = getUrlGenerator(DISCOVER_APP_URL_GENERATOR); - } catch (error) { - // ignore error thrown when url generator is not available - return; - } - - const discoverUrl = await discoverUrlGenerator.createUrl(state); - if (!unmounted) { - setDiscoverLink(discoverUrl); - } - }; - - getDiscoverUrl(); - return () => { - unmounted = true; - }; - }, [indexPattern, searchString, searchQueryLanguage, globalState]); - - // Note we use display:none for the DataRecognizer section as it needs to be - // passed the recognizerResults object, and then run the recognizer check which - // controls whether the recognizer section is ultimately displayed. - return ( -
- {mlAvailable && ( - <> - -

- -

-
- - {showCreateAnomalyDetectionJob && ( - <> - - - - - - )} - - )} - {mlAvailable && indexPattern.id !== undefined && createDataFrameAnalyticsLink && ( - <> - - - } - data-test-subj="mlDataVisualizerCreateDataFrameAnalyticsCard" - /> - - - )} - - {discoverLink && ( - <> - -

- -

-
- - - } - data-test-subj="mlDataVisualizerViewInDiscoverCard" - /> - - )} -
- ); -}; diff --git a/x-pack/plugins/ml/public/application/datavisualizer/index_based/components/expanded_row/index.ts b/x-pack/plugins/ml/public/application/datavisualizer/index_based/components/expanded_row/index.ts deleted file mode 100644 index d251dc7b6d333..0000000000000 --- a/x-pack/plugins/ml/public/application/datavisualizer/index_based/components/expanded_row/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -/* - * 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. - */ - -export { IndexBasedDataVisualizerExpandedRow } from './expanded_row'; diff --git a/x-pack/plugins/ml/public/application/datavisualizer/index_based/components/field_data_row/_index.scss b/x-pack/plugins/ml/public/application/datavisualizer/index_based/components/field_data_row/_index.scss deleted file mode 100644 index 38327dc51bd97..0000000000000 --- a/x-pack/plugins/ml/public/application/datavisualizer/index_based/components/field_data_row/_index.scss +++ /dev/null @@ -1 +0,0 @@ -@import 'top_values/top_values'; diff --git a/x-pack/plugins/ml/public/application/datavisualizer/index_based/components/field_data_row/choropleth_map/choropleth_map.tsx b/x-pack/plugins/ml/public/application/datavisualizer/index_based/components/field_data_row/choropleth_map/choropleth_map.tsx deleted file mode 100644 index 8b7cbf83f7996..0000000000000 --- a/x-pack/plugins/ml/public/application/datavisualizer/index_based/components/field_data_row/choropleth_map/choropleth_map.tsx +++ /dev/null @@ -1,126 +0,0 @@ -/* - * 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, { FC, useMemo } from 'react'; -import { EuiFlexItem, EuiSpacer, EuiText, htmlIdGenerator } from '@elastic/eui'; -import { i18n } from '@kbn/i18n'; -import { FormattedMessage } from '@kbn/i18n/react'; -import { - FIELD_ORIGIN, - SOURCE_TYPES, - STYLE_TYPE, - COLOR_MAP_TYPE, -} from '../../../../../../../../maps/common/constants'; -import { EMSTermJoinConfig } from '../../../../../../../../maps/public'; -import { FieldVisStats } from '../../../../stats_table/types'; -import { VectorLayerDescriptor } from '../../../../../../../../maps/common/descriptor_types'; -import { MlEmbeddedMapComponent } from '../../../../../components/ml_embedded_map'; - -export const getChoroplethTopValuesLayer = ( - fieldName: string, - topValues: Array<{ key: any; doc_count: number }>, - { layerId, field }: EMSTermJoinConfig -): VectorLayerDescriptor => { - return { - id: htmlIdGenerator()(), - label: i18n.translate('xpack.ml.dataviz.choroplethMap.topValuesCount', { - defaultMessage: 'Top values count for {fieldName}', - values: { fieldName }, - }), - joins: [ - { - // Left join is the id from the type of field (e.g. world_countries) - leftField: field, - right: { - id: 'anomaly_count', - type: SOURCE_TYPES.TABLE_SOURCE, - __rows: topValues, - __columns: [ - { - name: 'key', - type: 'string', - }, - { - name: 'doc_count', - type: 'number', - }, - ], - // Right join/term is the field in the doc you’re trying to join it to (foreign key - e.g. US) - term: 'key', - }, - }, - ], - sourceDescriptor: { - type: 'EMS_FILE', - id: layerId, - }, - style: { - type: 'VECTOR', - // @ts-ignore missing style properties. Remove once 'VectorLayerDescriptor' type is updated - properties: { - icon: { type: STYLE_TYPE.STATIC, options: { value: 'marker' } }, - fillColor: { - type: STYLE_TYPE.DYNAMIC, - options: { - color: 'Blue to Red', - colorCategory: 'palette_0', - fieldMetaOptions: { isEnabled: true, sigma: 3 }, - type: COLOR_MAP_TYPE.ORDINAL, - field: { - name: 'doc_count', - origin: FIELD_ORIGIN.JOIN, - }, - useCustomColorRamp: false, - }, - }, - lineColor: { - type: STYLE_TYPE.DYNAMIC, - options: { fieldMetaOptions: { isEnabled: true } }, - }, - lineWidth: { type: STYLE_TYPE.STATIC, options: { size: 1 } }, - }, - isTimeAware: true, - }, - type: 'VECTOR', - }; -}; - -interface Props { - stats: FieldVisStats | undefined; - suggestion: EMSTermJoinConfig; -} - -export const ChoroplethMap: FC = ({ stats, suggestion }) => { - const { fieldName, isTopValuesSampled, topValues, topValuesSamplerShardSize } = stats!; - - const layerList: VectorLayerDescriptor[] = useMemo( - () => [getChoroplethTopValuesLayer(fieldName || '', topValues || [], suggestion)], - [suggestion, stats] - ); - - return ( - -
- -
- {isTopValuesSampled === true && ( - <> - - - - - - )} -
- ); -}; diff --git a/x-pack/plugins/ml/public/application/datavisualizer/index_based/components/field_data_row/examples_list/examples_list.tsx b/x-pack/plugins/ml/public/application/datavisualizer/index_based/components/field_data_row/examples_list/examples_list.tsx deleted file mode 100644 index 7804c4bddf266..0000000000000 --- a/x-pack/plugins/ml/public/application/datavisualizer/index_based/components/field_data_row/examples_list/examples_list.tsx +++ /dev/null @@ -1,59 +0,0 @@ -/* - * 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, { FC } from 'react'; - -import { EuiListGroup, EuiListGroupItem } from '@elastic/eui'; - -import { FormattedMessage } from '@kbn/i18n/react'; -import { ExpandedRowFieldHeader } from '../../../../stats_table/components/expanded_row_field_header'; -interface Props { - examples: Array; -} - -export const ExamplesList: FC = ({ examples }) => { - if (examples === undefined || examples === null || !Array.isArray(examples)) { - return null; - } - let examplesContent; - if (examples.length === 0) { - examplesContent = ( - - ); - } else { - examplesContent = examples.map((example, i) => { - return ( - - ); - }); - } - - return ( -
- - - - - {examplesContent} - -
- ); -}; diff --git a/x-pack/plugins/ml/public/application/datavisualizer/index_based/components/field_data_row/top_values/_top_values.scss b/x-pack/plugins/ml/public/application/datavisualizer/index_based/components/field_data_row/top_values/_top_values.scss deleted file mode 100644 index 75ee6aef1b7eb..0000000000000 --- a/x-pack/plugins/ml/public/application/datavisualizer/index_based/components/field_data_row/top_values/_top_values.scss +++ /dev/null @@ -1,19 +0,0 @@ -.mlFieldDataTopValuesContainer { - padding-top: $euiSizeXS; -} - -.mlTopValuesValueLabelContainer { - margin-right: $euiSizeM; - &.mlTopValuesValueLabelContainer--small { - width:70px; - } - - &.mlTopValuesValueLabelContainer--large { - width: 200px; - } -} - -.mlTopValuesPercentLabelContainer { - margin-left: $euiSizeM; - width:70px; -} diff --git a/x-pack/plugins/ml/public/application/datavisualizer/index_based/components/field_data_row/top_values/top_values.tsx b/x-pack/plugins/ml/public/application/datavisualizer/index_based/components/field_data_row/top_values/top_values.tsx deleted file mode 100644 index 2d423b9dbb751..0000000000000 --- a/x-pack/plugins/ml/public/application/datavisualizer/index_based/components/field_data_row/top_values/top_values.tsx +++ /dev/null @@ -1,113 +0,0 @@ -/* - * 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, { FC, Fragment } from 'react'; -import { - EuiFlexGroup, - EuiFlexItem, - EuiProgress, - EuiSpacer, - EuiText, - EuiToolTip, -} from '@elastic/eui'; - -import { FormattedMessage } from '@kbn/i18n/react'; - -import classNames from 'classnames'; -import { kibanaFieldFormat } from '../../../../../formatters/kibana_field_format'; -import { roundToDecimalPlace } from '../../../../../formatters/round_to_decimal_place'; -import { ExpandedRowFieldHeader } from '../../../../stats_table/components/expanded_row_field_header'; -import { FieldVisStats } from '../../../../stats_table/types'; - -interface Props { - stats: FieldVisStats | undefined; - fieldFormat?: any; - barColor?: 'primary' | 'secondary' | 'danger' | 'subdued' | 'accent'; - compressed?: boolean; -} - -function getPercentLabel(docCount: number, topValuesSampleSize: number): string { - const percent = (100 * docCount) / topValuesSampleSize; - if (percent >= 0.1) { - return `${roundToDecimalPlace(percent, 1)}%`; - } else { - return '< 0.1%'; - } -} - -export const TopValues: FC = ({ stats, fieldFormat, barColor, compressed }) => { - if (stats === undefined) return null; - const { - topValues, - topValuesSampleSize, - topValuesSamplerShardSize, - count, - isTopValuesSampled, - } = stats; - const progressBarMax = isTopValuesSampled === true ? topValuesSampleSize : count; - return ( - - - - - -
- {Array.isArray(topValues) && - topValues.map((value) => ( - - - - - {kibanaFieldFormat(value.key, fieldFormat)} - - - - - - - {progressBarMax !== undefined && ( - - - {getPercentLabel(value.doc_count, progressBarMax)} - - - )} - - ))} - {isTopValuesSampled === true && ( - - - - - - - )} -
-
- ); -}; diff --git a/x-pack/plugins/ml/public/application/datavisualizer/index_based/components/total_count_header/index.ts b/x-pack/plugins/ml/public/application/datavisualizer/index_based/components/total_count_header/index.ts deleted file mode 100644 index 167988782ba51..0000000000000 --- a/x-pack/plugins/ml/public/application/datavisualizer/index_based/components/total_count_header/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -/* - * 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. - */ - -export { TotalCountHeader } from './total_count_header'; diff --git a/x-pack/plugins/ml/public/application/datavisualizer/index_based/data_loader/data_loader.ts b/x-pack/plugins/ml/public/application/datavisualizer/index_based/data_loader/data_loader.ts index 0da7d3d6b63d8..a5fabc12c83df 100644 --- a/x-pack/plugins/ml/public/application/datavisualizer/index_based/data_loader/data_loader.ts +++ b/x-pack/plugins/ml/public/application/datavisualizer/index_based/data_loader/data_loader.ts @@ -5,11 +5,9 @@ * 2.0. */ -import { i18n } from '@kbn/i18n'; - import { CoreSetup } from 'src/core/public'; -import { IndexPattern, KBN_FIELD_TYPES } from '../../../../../../../../src/plugins/data/public'; +import { IndexPattern } from '../../../../../../../../src/plugins/data/public'; import { SavedSearchQuery } from '../../../contexts/ml'; import { OMIT_FIELDS } from '../../../../../common/constants/field_types'; @@ -17,12 +15,8 @@ import { IndexPatternTitle } from '../../../../../common/types/kibana'; import { DEFAULT_SAMPLER_SHARD_SIZE } from '../../../../../common/constants/field_histograms'; import { ml } from '../../../services/ml_api_service'; -import { FieldHistogramRequestConfig, FieldRequestConfig } from '../common'; +import { FieldHistogramRequestConfig } from '../common/request'; import { RuntimeMappings } from '../../../../../common/types/fields'; -import { - ToastNotificationService, - toastNotificationServiceProvider, -} from '../../../services/toast_notification_service'; // Maximum number of examples to obtain for text type fields. const MAX_EXAMPLES_DEFAULT: number = 10; @@ -32,79 +26,14 @@ export class DataLoader { private _runtimeMappings: RuntimeMappings; private _indexPatternTitle: IndexPatternTitle = ''; private _maxExamples: number = MAX_EXAMPLES_DEFAULT; - private _toastNotificationsService: ToastNotificationService; constructor( indexPattern: IndexPattern, - toastNotifications: CoreSetup['notifications']['toasts'] + toastNotifications?: CoreSetup['notifications']['toasts'] ) { this._indexPattern = indexPattern; this._runtimeMappings = this._indexPattern.getComputedFields().runtimeFields as RuntimeMappings; this._indexPatternTitle = indexPattern.title; - this._toastNotificationsService = toastNotificationServiceProvider(toastNotifications); - } - - async loadOverallData( - query: string | SavedSearchQuery, - samplerShardSize: number, - earliest: number | undefined, - latest: number | undefined - ): Promise { - const aggregatableFields: string[] = []; - const nonAggregatableFields: string[] = []; - this._indexPattern.fields.forEach((field) => { - const fieldName = field.displayName !== undefined ? field.displayName : field.name; - if (this.isDisplayField(fieldName) === true) { - if (field.aggregatable === true && field.type !== KBN_FIELD_TYPES.GEO_SHAPE) { - aggregatableFields.push(fieldName); - } else { - nonAggregatableFields.push(fieldName); - } - } - }); - - // Need to find: - // 1. List of aggregatable fields that do exist in docs - // 2. List of aggregatable fields that do not exist in docs - // 3. List of non-aggregatable fields that do exist in docs. - // 4. List of non-aggregatable fields that do not exist in docs. - const stats = await ml.getVisualizerOverallStats({ - indexPatternTitle: this._indexPatternTitle, - query, - timeFieldName: this._indexPattern.timeFieldName, - samplerShardSize, - earliest, - latest, - aggregatableFields, - nonAggregatableFields, - runtimeMappings: this._runtimeMappings, - }); - - return stats; - } - - async loadFieldStats( - query: string | SavedSearchQuery, - samplerShardSize: number, - earliest: number | undefined, - latest: number | undefined, - fields: FieldRequestConfig[], - interval?: number - ): Promise { - const stats = await ml.getVisualizerFieldStats({ - indexPatternTitle: this._indexPatternTitle, - query, - timeFieldName: this._indexPattern.timeFieldName, - earliest, - latest, - samplerShardSize, - interval, - fields, - maxExamples: this._maxExamples, - runtimeMappings: this._runtimeMappings, - }); - - return stats; } async loadFieldHistograms( @@ -124,34 +53,6 @@ export class DataLoader { return stats; } - displayError(err: any) { - if (err.statusCode === 500) { - this._toastNotificationsService.displayErrorToast( - err, - i18n.translate('xpack.ml.datavisualizer.dataLoader.internalServerErrorMessage', { - defaultMessage: - 'Error loading data in index {index}. {message}. ' + - 'The request may have timed out. Try using a smaller sample size or narrowing the time range.', - values: { - index: this._indexPattern.title, - message: err.message, - }, - }) - ); - } else { - this._toastNotificationsService.displayErrorToast( - err, - i18n.translate('xpack.ml.datavisualizer.page.errorLoadingDataMessage', { - defaultMessage: 'Error loading data in index {index}. {message}', - values: { - index: this._indexPattern.title, - message: err.message, - }, - }) - ); - } - } - public set maxExamples(max: number) { this._maxExamples = max; } diff --git a/x-pack/plugins/ml/public/application/datavisualizer/index_based/index.ts b/x-pack/plugins/ml/public/application/datavisualizer/index_based/index.ts index 99a826236c34f..1216e3f7f4c17 100644 --- a/x-pack/plugins/ml/public/application/datavisualizer/index_based/index.ts +++ b/x-pack/plugins/ml/public/application/datavisualizer/index_based/index.ts @@ -5,4 +5,4 @@ * 2.0. */ -export { Page } from './page'; +export { IndexDataVisualizerPage } from './index_data_visualizer'; diff --git a/x-pack/plugins/ml/public/application/datavisualizer/index_based/index_data_visualizer.tsx b/x-pack/plugins/ml/public/application/datavisualizer/index_based/index_data_visualizer.tsx new file mode 100644 index 0000000000000..af803d32e5139 --- /dev/null +++ b/x-pack/plugins/ml/public/application/datavisualizer/index_based/index_data_visualizer.tsx @@ -0,0 +1,38 @@ +/* + * 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, { FC, Fragment, useEffect, useState } from 'react'; +import { useMlKibana, useTimefilter } from '../../contexts/kibana'; +import { NavigationMenu } from '../../components/navigation_menu'; +import { HelpMenu } from '../../components/help_menu'; +import type { IndexDataVisualizerViewProps } from '../../../../../data_visualizer/public'; +export const IndexDataVisualizerPage: FC = () => { + useTimefilter({ timeRangeSelector: false, autoRefreshSelector: false }); + const { + services: { docLinks, dataVisualizer }, + } = useMlKibana(); + const [ + IndexDataVisualizer, + setIndexDataVisualizer, + ] = useState | null>(null); + + useEffect(() => { + if (dataVisualizer !== undefined) { + const { getIndexDataVisualizerComponent } = dataVisualizer; + getIndexDataVisualizerComponent().then(setIndexDataVisualizer); + } + }, []); + return IndexDataVisualizer ? ( + + + {IndexDataVisualizer} + + + ) : ( + + ); +}; diff --git a/x-pack/plugins/ml/public/application/datavisualizer/stats_table/_field_data_row.scss b/x-pack/plugins/ml/public/application/datavisualizer/stats_table/_field_data_row.scss deleted file mode 100644 index 1832b0f78b895..0000000000000 --- a/x-pack/plugins/ml/public/application/datavisualizer/stats_table/_field_data_row.scss +++ /dev/null @@ -1,86 +0,0 @@ -.mlFieldDataCard { - height: 420px; - box-shadow: none; - border-color: $euiBorderColor; - - // Note the names of these styles need to match the type of the field they are displaying. - .boolean { - color: $euiColorVis5; - border-color: $euiColorVis5; - } - - .date { - color: $euiColorVis7; - border-color: $euiColorVis7; - } - - .document_count { - color: $euiColorVis2; - border-color: $euiColorVis2; - } - - .geo_point { - color: $euiColorVis8; - border-color: $euiColorVis8; - } - - .ip { - color: $euiColorVis3; - border-color: $euiColorVis3; - } - - .keyword { - color: $euiColorVis0; - border-color: $euiColorVis0; - } - - .number { - color: $euiColorVis1; - border-color: $euiColorVis1; - } - - .text { - color: $euiColorVis9; - border-color: $euiColorVis9; - } - - .type-other, - .unknown { - color: $euiColorVis6; - border-color: $euiColorVis6; - } - - .mlFieldDataCard__content { - @include euiFontSizeS; - height: 385px; - overflow: hidden; - } - - .mlFieldDataCard__codeContent { - @include euiCodeFont; - } - - .mlFieldDataCard__geoContent { - z-index: auto; - flex: 1; - display: flex; - flex-direction: column; - height: 100%; - position: relative; - .embPanel__content { - display: flex; - flex: 1 1 100%; - z-index: 1; - min-height: 0; // Absolute must for Firefox to scroll contents - } - } - - .mlFieldDataCard__stats { - padding: $euiSizeS $euiSizeS 0 $euiSizeS; - text-align: center; - } - - .mlFieldDataCard__valuesTitle { - text-transform: uppercase; - } -} diff --git a/x-pack/plugins/ml/public/application/datavisualizer/stats_table/_index.scss b/x-pack/plugins/ml/public/application/datavisualizer/stats_table/_index.scss deleted file mode 100644 index 9e838c180713f..0000000000000 --- a/x-pack/plugins/ml/public/application/datavisualizer/stats_table/_index.scss +++ /dev/null @@ -1,56 +0,0 @@ -@import 'components/field_data_expanded_row/index'; -@import 'components/field_count_stats/index'; -@import 'components/field_data_row/index'; - -.mlDataVisualizerFieldExpandedRow { - padding-left: $euiSize * 4; - width: 100%; - - .mlFieldDataCard__valuesTitle { - text-transform: uppercase; - text-align: left; - color: $euiColorDarkShade; - font-weight: bold; - padding-bottom: $euiSizeS; - } - - .mlFieldDataCard__codeContent { - @include euiCodeFont; - } -} - -.mlDataVisualizer { - .euiTableRow > .euiTableRowCell { - border-bottom: 0; - border-top: $euiBorderThin; - - } - .euiTableRow-isExpandedRow { - - .euiTableRowCell { - background-color: $euiColorEmptyShade !important; - border-top: 0; - border-bottom: $euiBorderThin; - &:hover { - background-color: $euiColorEmptyShade !important; - } - } - } - .mlDataVisualizerSummaryTable { - max-width: 350px; - min-width: 250px; - .euiTableRow > .euiTableRowCell { - border-bottom: 0; - } - .euiTableHeaderCell { - display: none; - } - } - .mlDataVisualizerSummaryTableWrapper { - max-width: 300px; - } - .mlDataVisualizerMapWrapper { - min-height: 300px; - min-width: 600px; - } -} diff --git a/x-pack/plugins/ml/public/application/datavisualizer/stats_table/components/expanded_row_field_header/expanded_row_field_header.tsx b/x-pack/plugins/ml/public/application/datavisualizer/stats_table/components/expanded_row_field_header/expanded_row_field_header.tsx deleted file mode 100644 index 6c82e103a831f..0000000000000 --- a/x-pack/plugins/ml/public/application/datavisualizer/stats_table/components/expanded_row_field_header/expanded_row_field_header.tsx +++ /dev/null @@ -1,15 +0,0 @@ -/* - * 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 { EuiText } from '@elastic/eui'; -import React from 'react'; - -export const ExpandedRowFieldHeader = ({ children }: { children: React.ReactNode }) => ( - - {children} - -); diff --git a/x-pack/plugins/ml/public/application/datavisualizer/stats_table/components/expanded_row_field_header/index.ts b/x-pack/plugins/ml/public/application/datavisualizer/stats_table/components/expanded_row_field_header/index.ts deleted file mode 100644 index a92fa7f1e0659..0000000000000 --- a/x-pack/plugins/ml/public/application/datavisualizer/stats_table/components/expanded_row_field_header/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -/* - * 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. - */ - -export { ExpandedRowFieldHeader } from './expanded_row_field_header'; diff --git a/x-pack/plugins/ml/public/application/datavisualizer/stats_table/components/field_count_stats/_index.scss b/x-pack/plugins/ml/public/application/datavisualizer/stats_table/components/field_count_stats/_index.scss deleted file mode 100644 index 7154d0da2c09c..0000000000000 --- a/x-pack/plugins/ml/public/application/datavisualizer/stats_table/components/field_count_stats/_index.scss +++ /dev/null @@ -1,3 +0,0 @@ -.mlDataVisualizerFieldCountContainer { - max-width: 300px; -} diff --git a/x-pack/plugins/ml/public/application/datavisualizer/stats_table/components/field_count_stats/metric_fields_count.tsx b/x-pack/plugins/ml/public/application/datavisualizer/stats_table/components/field_count_stats/metric_fields_count.tsx deleted file mode 100644 index dae22cf6daab8..0000000000000 --- a/x-pack/plugins/ml/public/application/datavisualizer/stats_table/components/field_count_stats/metric_fields_count.tsx +++ /dev/null @@ -1,68 +0,0 @@ -/* - * 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 { EuiFlexGroup, EuiFlexItem, EuiNotificationBadge, EuiText } from '@elastic/eui'; -import { FormattedMessage } from '@kbn/i18n/react'; -import React, { FC } from 'react'; - -export interface MetricFieldsStats { - visibleMetricsCount: number; - totalMetricFieldsCount: number; -} -export interface MetricFieldsCountProps { - metricsStats?: MetricFieldsStats; -} - -export const MetricFieldsCount: FC = ({ metricsStats }) => { - if ( - !metricsStats || - metricsStats.visibleMetricsCount === undefined || - metricsStats.totalMetricFieldsCount === undefined - ) - return null; - return ( - <> - {metricsStats && ( - - - -
- -
-
-
- - - {metricsStats.visibleMetricsCount} - - - - - - - -
- )} - - ); -}; diff --git a/x-pack/plugins/ml/public/application/datavisualizer/stats_table/components/field_count_stats/total_fields_count.tsx b/x-pack/plugins/ml/public/application/datavisualizer/stats_table/components/field_count_stats/total_fields_count.tsx deleted file mode 100644 index aacd7172903f5..0000000000000 --- a/x-pack/plugins/ml/public/application/datavisualizer/stats_table/components/field_count_stats/total_fields_count.tsx +++ /dev/null @@ -1,67 +0,0 @@ -/* - * 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 { EuiFlexGroup, EuiFlexItem, EuiNotificationBadge, EuiText } from '@elastic/eui'; -import { FormattedMessage } from '@kbn/i18n/react'; -import React, { FC } from 'react'; - -export interface TotalFieldsStats { - visibleFieldsCount: number; - totalFieldsCount: number; -} - -export interface TotalFieldsCountProps { - fieldsCountStats?: TotalFieldsStats; -} - -export const TotalFieldsCount: FC = ({ fieldsCountStats }) => { - if ( - !fieldsCountStats || - fieldsCountStats.visibleFieldsCount === undefined || - fieldsCountStats.totalFieldsCount === undefined - ) - return null; - - return ( - - - -
- -
-
-
- - - - {fieldsCountStats.visibleFieldsCount} - - - - - - - -
- ); -}; diff --git a/x-pack/plugins/ml/public/application/datavisualizer/stats_table/components/field_data_expanded_row/_index.scss b/x-pack/plugins/ml/public/application/datavisualizer/stats_table/components/field_data_expanded_row/_index.scss deleted file mode 100644 index 799beec093cca..0000000000000 --- a/x-pack/plugins/ml/public/application/datavisualizer/stats_table/components/field_data_expanded_row/_index.scss +++ /dev/null @@ -1,7 +0,0 @@ -@import 'number_content'; - -.mlDataVisualizerExpandedRow { - @include euiBreakpoint('xs', 's', 'm') { - flex-direction: column; - } -} diff --git a/x-pack/plugins/ml/public/application/datavisualizer/stats_table/components/field_data_expanded_row/_number_content.scss b/x-pack/plugins/ml/public/application/datavisualizer/stats_table/components/field_data_expanded_row/_number_content.scss deleted file mode 100644 index 066f405b39cd6..0000000000000 --- a/x-pack/plugins/ml/public/application/datavisualizer/stats_table/components/field_data_expanded_row/_number_content.scss +++ /dev/null @@ -1,4 +0,0 @@ -.mlMetricDistributionChartContainer { - padding-top: $euiSizeXS; - width: 100%; -} diff --git a/x-pack/plugins/ml/public/application/datavisualizer/stats_table/components/field_data_expanded_row/boolean_content.tsx b/x-pack/plugins/ml/public/application/datavisualizer/stats_table/components/field_data_expanded_row/boolean_content.tsx deleted file mode 100644 index 6a09e968aa19f..0000000000000 --- a/x-pack/plugins/ml/public/application/datavisualizer/stats_table/components/field_data_expanded_row/boolean_content.tsx +++ /dev/null @@ -1,145 +0,0 @@ -/* - * 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, { FC, ReactNode, useMemo } from 'react'; -import { EuiBasicTable, EuiFlexItem, EuiSpacer } from '@elastic/eui'; -import { Axis, BarSeries, Chart, Settings } from '@elastic/charts'; - -import { FormattedMessage } from '@kbn/i18n/react'; -import { i18n } from '@kbn/i18n'; -import type { FieldDataRowProps } from '../../types/field_data_row'; -import { ExpandedRowFieldHeader } from '../expanded_row_field_header'; -import { getTFPercentage } from '../../utils'; -import { roundToDecimalPlace } from '../../../../formatters/round_to_decimal_place'; -import { useDataVizChartTheme } from '../../hooks'; -import { DocumentStatsTable } from './document_stats'; -import { ExpandedRowContent } from './expanded_row_content'; - -function getPercentLabel(value: number): string { - if (value === 0) { - return '0%'; - } - if (value >= 0.1) { - return `${roundToDecimalPlace(value)}%`; - } else { - return '< 0.1%'; - } -} - -function getFormattedValue(value: number, totalCount: number): string { - const percentage = (value / totalCount) * 100; - return `${value} (${getPercentLabel(percentage)})`; -} - -const BOOLEAN_DISTRIBUTION_CHART_HEIGHT = 100; - -export const BooleanContent: FC = ({ config }) => { - const fieldFormat = 'fieldFormat' in config ? config.fieldFormat : undefined; - const formattedPercentages = useMemo(() => getTFPercentage(config), [config]); - const theme = useDataVizChartTheme(); - if (!formattedPercentages) return null; - - const { trueCount, falseCount, count } = formattedPercentages; - const summaryTableItems = [ - { - function: 'true', - display: ( - - ), - value: getFormattedValue(trueCount, count), - }, - { - function: 'false', - display: ( - - ), - value: getFormattedValue(falseCount, count), - }, - ]; - const summaryTableColumns = [ - { - name: '', - render: (summaryItem: { display: ReactNode }) => summaryItem.display, - width: '75px', - }, - { - field: 'value', - name: '', - render: (v: string) => {v}, - }, - ]; - - const summaryTableTitle = i18n.translate( - 'xpack.ml.fieldDataCardExpandedRow.booleanContent.summaryTableTitle', - { - defaultMessage: 'Summary', - } - ); - - return ( - - - - - {summaryTableTitle} - - - - - - - - - - - getFormattedValue(d, count)} - /> - - - - - - - ); -}; diff --git a/x-pack/plugins/ml/public/application/datavisualizer/stats_table/components/field_data_expanded_row/date_content.tsx b/x-pack/plugins/ml/public/application/datavisualizer/stats_table/components/field_data_expanded_row/date_content.tsx deleted file mode 100644 index ad773ba5a3b16..0000000000000 --- a/x-pack/plugins/ml/public/application/datavisualizer/stats_table/components/field_data_expanded_row/date_content.tsx +++ /dev/null @@ -1,87 +0,0 @@ -/* - * 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, { FC, ReactNode } from 'react'; -import { EuiBasicTable, EuiFlexItem } from '@elastic/eui'; -// @ts-ignore -import { formatDate } from '@elastic/eui/lib/services/format'; -import { FormattedMessage } from '@kbn/i18n/react'; - -import { i18n } from '@kbn/i18n'; -import type { FieldDataRowProps } from '../../types/field_data_row'; -import { ExpandedRowFieldHeader } from '../expanded_row_field_header'; -import { DocumentStatsTable } from './document_stats'; -import { ExpandedRowContent } from './expanded_row_content'; -const TIME_FORMAT = 'MMM D YYYY, HH:mm:ss.SSS'; -interface SummaryTableItem { - function: string; - display: ReactNode; - value: number | string | undefined | null; -} - -export const DateContent: FC = ({ config }) => { - const { stats } = config; - if (stats === undefined) return null; - - const { earliest, latest } = stats; - - const summaryTableTitle = i18n.translate('xpack.ml.fieldDataCard.cardDate.summaryTableTitle', { - defaultMessage: 'Summary', - }); - const summaryTableItems = [ - { - function: 'earliest', - display: ( - - ), - value: typeof earliest === 'string' ? earliest : formatDate(earliest, TIME_FORMAT), - }, - { - function: 'latest', - display: ( - - ), - value: typeof latest === 'string' ? latest : formatDate(latest, TIME_FORMAT), - }, - ]; - const summaryTableColumns = [ - { - name: '', - render: (summaryItem: { display: ReactNode }) => summaryItem.display, - width: '75px', - }, - { - field: 'value', - name: '', - render: (v: string) => {v}, - }, - ]; - - return ( - - - - {summaryTableTitle} - - className={'mlDataVisualizerSummaryTable'} - data-test-subj={'mlDateSummaryTable'} - compressed - items={summaryTableItems} - columns={summaryTableColumns} - tableCaption={summaryTableTitle} - tableLayout="auto" - /> - - - ); -}; diff --git a/x-pack/plugins/ml/public/application/datavisualizer/stats_table/components/field_data_expanded_row/document_stats.tsx b/x-pack/plugins/ml/public/application/datavisualizer/stats_table/components/field_data_expanded_row/document_stats.tsx deleted file mode 100644 index c5b68975d9d31..0000000000000 --- a/x-pack/plugins/ml/public/application/datavisualizer/stats_table/components/field_data_expanded_row/document_stats.tsx +++ /dev/null @@ -1,93 +0,0 @@ -/* - * 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 { FormattedMessage } from '@kbn/i18n/react'; -import React, { FC, ReactNode } from 'react'; -import { i18n } from '@kbn/i18n'; -import { EuiBasicTable, EuiFlexItem } from '@elastic/eui'; -import { ExpandedRowFieldHeader } from '../expanded_row_field_header'; -import { FieldDataRowProps } from '../../types'; -import { roundToDecimalPlace } from '../../../../formatters/round_to_decimal_place'; - -const metaTableColumns = [ - { - name: '', - render: (metaItem: { display: ReactNode }) => metaItem.display, - width: '75px', - }, - { - field: 'value', - name: '', - render: (v: string) => {v}, - }, -]; - -const metaTableTitle = i18n.translate( - 'xpack.ml.fieldDataCardExpandedRow.documentStatsTable.metaTableTitle', - { - defaultMessage: 'Documents stats', - } -); - -export const DocumentStatsTable: FC = ({ config }) => { - if ( - config?.stats === undefined || - config.stats.cardinality === undefined || - config.stats.count === undefined || - config.stats.sampleCount === undefined - ) - return null; - const { cardinality, count, sampleCount } = config.stats; - const metaTableItems = [ - { - function: 'count', - display: ( - - ), - value: count, - }, - { - function: 'percentage', - display: ( - - ), - value: `${roundToDecimalPlace((count / sampleCount) * 100)}%`, - }, - { - function: 'distinctValues', - display: ( - - ), - value: cardinality, - }, - ]; - - return ( - - {metaTableTitle} - - - ); -}; diff --git a/x-pack/plugins/ml/public/application/datavisualizer/stats_table/components/field_data_expanded_row/expanded_row_content.tsx b/x-pack/plugins/ml/public/application/datavisualizer/stats_table/components/field_data_expanded_row/expanded_row_content.tsx deleted file mode 100644 index 8e14945b32a7f..0000000000000 --- a/x-pack/plugins/ml/public/application/datavisualizer/stats_table/components/field_data_expanded_row/expanded_row_content.tsx +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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, { FC, ReactNode } from 'react'; -import { EuiFlexGroup } from '@elastic/eui'; - -interface Props { - children: ReactNode; - dataTestSubj: string; -} -export const ExpandedRowContent: FC = ({ children, dataTestSubj }) => { - return ( - - {children} - - ); -}; diff --git a/x-pack/plugins/ml/public/application/datavisualizer/stats_table/components/field_data_expanded_row/index.ts b/x-pack/plugins/ml/public/application/datavisualizer/stats_table/components/field_data_expanded_row/index.ts deleted file mode 100644 index d35b0ae9688cf..0000000000000 --- a/x-pack/plugins/ml/public/application/datavisualizer/stats_table/components/field_data_expanded_row/index.ts +++ /dev/null @@ -1,14 +0,0 @@ -/* - * 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. - */ - -export { BooleanContent } from './boolean_content'; -export { DateContent } from './date_content'; -export { KeywordContent } from './keyword_content'; -export { IpContent } from './ip_content'; -export { NumberContent } from './number_content'; -export { OtherContent } from './other_content'; -export { TextContent } from './text_content'; diff --git a/x-pack/plugins/ml/public/application/datavisualizer/stats_table/components/field_data_expanded_row/ip_content.tsx b/x-pack/plugins/ml/public/application/datavisualizer/stats_table/components/field_data_expanded_row/ip_content.tsx deleted file mode 100644 index 23c7d721a9ab5..0000000000000 --- a/x-pack/plugins/ml/public/application/datavisualizer/stats_table/components/field_data_expanded_row/ip_content.tsx +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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, { FC } from 'react'; -import type { FieldDataRowProps } from '../../types/field_data_row'; -import { TopValues } from '../../../index_based/components/field_data_row/top_values'; -import { DocumentStatsTable } from './document_stats'; -import { ExpandedRowContent } from './expanded_row_content'; - -export const IpContent: FC = ({ config }) => { - const { stats } = config; - if (stats === undefined) return null; - const { count, sampleCount, cardinality } = stats; - if (count === undefined || sampleCount === undefined || cardinality === undefined) return null; - const fieldFormat = 'fieldFormat' in config ? config.fieldFormat : undefined; - - return ( - - - - - ); -}; diff --git a/x-pack/plugins/ml/public/application/datavisualizer/stats_table/components/field_data_expanded_row/keyword_content.tsx b/x-pack/plugins/ml/public/application/datavisualizer/stats_table/components/field_data_expanded_row/keyword_content.tsx deleted file mode 100644 index 9239632a3f909..0000000000000 --- a/x-pack/plugins/ml/public/application/datavisualizer/stats_table/components/field_data_expanded_row/keyword_content.tsx +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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, { FC, useEffect, useState } from 'react'; -import type { FieldDataRowProps } from '../../types/field_data_row'; -import { TopValues } from '../../../index_based/components/field_data_row/top_values'; -import { ChoroplethMap } from '../../../index_based/components/field_data_row/choropleth_map'; -import { useMlKibana } from '../../../../../application/contexts/kibana'; -import { EMSTermJoinConfig } from '../../../../../../../maps/public'; -import { COMMON_EMS_LAYER_IDS } from '../../../../../../common/constants/embeddable_map'; -import { DocumentStatsTable } from './document_stats'; -import { ExpandedRowContent } from './expanded_row_content'; - -export const KeywordContent: FC = ({ config }) => { - const [EMSSuggestion, setEMSSuggestion] = useState(); - const { stats, fieldName } = config; - const fieldFormat = 'fieldFormat' in config ? config.fieldFormat : undefined; - const { - services: { maps: mapsPlugin }, - } = useMlKibana(); - - const loadEMSTermSuggestions = async () => { - if (!mapsPlugin) return; - const suggestion: EMSTermJoinConfig | null = await mapsPlugin.suggestEMSTermJoinConfig({ - emsLayerIds: COMMON_EMS_LAYER_IDS, - sampleValues: Array.isArray(stats?.topValues) - ? stats?.topValues.map((value) => value.key) - : [], - sampleValuesColumnName: fieldName || '', - }); - setEMSSuggestion(suggestion); - }; - - useEffect( - function getInitialEMSTermSuggestion() { - loadEMSTermSuggestions(); - }, - [config?.fieldName] - ); - - return ( - - - {EMSSuggestion && stats && } - {EMSSuggestion === null && ( - - )} - - ); -}; diff --git a/x-pack/plugins/ml/public/application/datavisualizer/stats_table/components/field_data_expanded_row/number_content.tsx b/x-pack/plugins/ml/public/application/datavisualizer/stats_table/components/field_data_expanded_row/number_content.tsx deleted file mode 100644 index 9d091292f4502..0000000000000 --- a/x-pack/plugins/ml/public/application/datavisualizer/stats_table/components/field_data_expanded_row/number_content.tsx +++ /dev/null @@ -1,154 +0,0 @@ -/* - * 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, { FC, ReactNode, useEffect, useState } from 'react'; -import { EuiBasicTable, EuiFlexItem, EuiText } from '@elastic/eui'; - -import { FormattedMessage } from '@kbn/i18n/react'; -import { i18n } from '@kbn/i18n'; -import type { FieldDataRowProps } from '../../types/field_data_row'; -import { kibanaFieldFormat } from '../../../../formatters/kibana_field_format'; -import { numberAsOrdinal } from '../../../../formatters/number_as_ordinal'; -import { - MetricDistributionChart, - MetricDistributionChartData, - buildChartDataFromStats, -} from '../metric_distribution_chart'; -import { TopValues } from '../../../index_based/components/field_data_row/top_values'; -import { ExpandedRowFieldHeader } from '../expanded_row_field_header'; -import { DocumentStatsTable } from './document_stats'; -import { ExpandedRowContent } from './expanded_row_content'; - -const METRIC_DISTRIBUTION_CHART_WIDTH = 325; -const METRIC_DISTRIBUTION_CHART_HEIGHT = 200; - -interface SummaryTableItem { - function: string; - display: ReactNode; - value: number | string | undefined | null; -} - -export const NumberContent: FC = ({ config }) => { - const { stats } = config; - - useEffect(() => { - const chartData = buildChartDataFromStats(stats, METRIC_DISTRIBUTION_CHART_WIDTH); - setDistributionChartData(chartData); - }, []); - - const defaultChartData: MetricDistributionChartData[] = []; - const [distributionChartData, setDistributionChartData] = useState(defaultChartData); - - if (stats === undefined) return null; - const { min, median, max, distribution } = stats; - const fieldFormat = 'fieldFormat' in config ? config.fieldFormat : undefined; - - const summaryTableItems = [ - { - function: 'min', - display: ( - - ), - value: kibanaFieldFormat(min, fieldFormat), - }, - { - function: 'median', - display: ( - - ), - value: kibanaFieldFormat(median, fieldFormat), - }, - { - function: 'max', - display: ( - - ), - value: kibanaFieldFormat(max, fieldFormat), - }, - ]; - const summaryTableColumns = [ - { - name: '', - render: (summaryItem: { display: ReactNode }) => summaryItem.display, - width: '75px', - }, - { - field: 'value', - name: '', - render: (v: string) => {v}, - }, - ]; - - const summaryTableTitle = i18n.translate( - 'xpack.ml.fieldDataCardExpandedRow.numberContent.summaryTableTitle', - { - defaultMessage: 'Summary', - } - ); - return ( - - - - {summaryTableTitle} - - className={'mlDataVisualizerSummaryTable'} - compressed - items={summaryTableItems} - columns={summaryTableColumns} - tableCaption={summaryTableTitle} - data-test-subj={'mlNumberSummaryTable'} - /> - - - {stats && ( - - )} - {distribution && ( - - - - - - - - - - - - - - - - - )} - - ); -}; diff --git a/x-pack/plugins/ml/public/application/datavisualizer/stats_table/components/field_data_expanded_row/other_content.tsx b/x-pack/plugins/ml/public/application/datavisualizer/stats_table/components/field_data_expanded_row/other_content.tsx deleted file mode 100644 index 0734048e2bc2a..0000000000000 --- a/x-pack/plugins/ml/public/application/datavisualizer/stats_table/components/field_data_expanded_row/other_content.tsx +++ /dev/null @@ -1,28 +0,0 @@ -/* - * 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, { FC } from 'react'; -import { EuiFlexItem } from '@elastic/eui'; -import type { FieldDataRowProps } from '../../types/field_data_row'; -import { ExamplesList } from '../../../index_based/components/field_data_row/examples_list'; -import { DocumentStatsTable } from './document_stats'; -import { ExpandedRowContent } from './expanded_row_content'; - -export const OtherContent: FC = ({ config }) => { - const { stats } = config; - if (stats === undefined) return null; - return ( - - - {Array.isArray(stats.examples) && ( - - - - )} - - ); -}; diff --git a/x-pack/plugins/ml/public/application/datavisualizer/stats_table/components/field_data_expanded_row/text_content.tsx b/x-pack/plugins/ml/public/application/datavisualizer/stats_table/components/field_data_expanded_row/text_content.tsx deleted file mode 100644 index bbef29a9154af..0000000000000 --- a/x-pack/plugins/ml/public/application/datavisualizer/stats_table/components/field_data_expanded_row/text_content.tsx +++ /dev/null @@ -1,66 +0,0 @@ -/* - * 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, { FC, Fragment } from 'react'; -import { EuiCallOut, EuiFlexItem, EuiSpacer } from '@elastic/eui'; - -import { FormattedMessage } from '@kbn/i18n/react'; -import { i18n } from '@kbn/i18n'; - -import type { FieldDataRowProps } from '../../types/field_data_row'; -import { ExamplesList } from '../../../index_based/components/field_data_row/examples_list'; -import { ExpandedRowContent } from './expanded_row_content'; - -export const TextContent: FC = ({ config }) => { - const { stats } = config; - if (stats === undefined) return null; - - const { examples } = stats; - if (examples === undefined) return null; - - const numExamples = examples.length; - - return ( - - - {numExamples > 0 && } - {numExamples === 0 && ( - - - - _source
, - }} - /> - - - - copy_to, - sourceParam: _source, - includesParam: includes, - excludesParam: excludes, - }} - /> - - - )} - - - ); -}; diff --git a/x-pack/plugins/ml/public/application/datavisualizer/stats_table/components/field_data_row/_index.scss b/x-pack/plugins/ml/public/application/datavisualizer/stats_table/components/field_data_row/_index.scss deleted file mode 100644 index 27483feb573b8..0000000000000 --- a/x-pack/plugins/ml/public/application/datavisualizer/stats_table/components/field_data_row/_index.scss +++ /dev/null @@ -1,3 +0,0 @@ -.mlDataVisualizerColumnHeaderIcon { - max-width: $euiSizeM; -} diff --git a/x-pack/plugins/ml/public/application/datavisualizer/stats_table/components/field_data_row/distinct_values.tsx b/x-pack/plugins/ml/public/application/datavisualizer/stats_table/components/field_data_row/distinct_values.tsx deleted file mode 100644 index acbe081599c62..0000000000000 --- a/x-pack/plugins/ml/public/application/datavisualizer/stats_table/components/field_data_row/distinct_values.tsx +++ /dev/null @@ -1,24 +0,0 @@ -/* - * 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 { EuiFlexGroup, EuiFlexItem, EuiIcon, EuiText } from '@elastic/eui'; - -import React from 'react'; - -export const DistinctValues = ({ cardinality }: { cardinality?: number }) => { - if (cardinality === undefined) return null; - return ( - - - - - - {cardinality} - - - ); -}; diff --git a/x-pack/plugins/ml/public/application/datavisualizer/stats_table/components/field_data_row/document_stats.tsx b/x-pack/plugins/ml/public/application/datavisualizer/stats_table/components/field_data_row/document_stats.tsx deleted file mode 100644 index 58afea0848154..0000000000000 --- a/x-pack/plugins/ml/public/application/datavisualizer/stats_table/components/field_data_row/document_stats.tsx +++ /dev/null @@ -1,33 +0,0 @@ -/* - * 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 { EuiFlexGroup, EuiFlexItem, EuiIcon, EuiText } from '@elastic/eui'; - -import React from 'react'; -import type { FieldDataRowProps } from '../../types/field_data_row'; -import { roundToDecimalPlace } from '../../../../formatters/round_to_decimal_place'; - -export const DocumentStat = ({ config }: FieldDataRowProps) => { - const { stats } = config; - if (stats === undefined) return null; - - const { count, sampleCount } = stats; - if (count === undefined || sampleCount === undefined) return null; - - const docsPercent = roundToDecimalPlace((count / sampleCount) * 100); - - return ( - - - - - - {count} ({docsPercent}%) - - - ); -}; diff --git a/x-pack/plugins/ml/public/application/datavisualizer/stats_table/components/field_data_row/index.ts b/x-pack/plugins/ml/public/application/datavisualizer/stats_table/components/field_data_row/index.ts deleted file mode 100644 index e4c0cc80eeb35..0000000000000 --- a/x-pack/plugins/ml/public/application/datavisualizer/stats_table/components/field_data_row/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -/* - * 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. - */ - -export { BooleanContentPreview } from './boolean_content_preview'; diff --git a/x-pack/plugins/ml/public/application/datavisualizer/stats_table/components/field_data_row/number_content_preview.tsx b/x-pack/plugins/ml/public/application/datavisualizer/stats_table/components/field_data_row/number_content_preview.tsx deleted file mode 100644 index e9f04e9e59668..0000000000000 --- a/x-pack/plugins/ml/public/application/datavisualizer/stats_table/components/field_data_row/number_content_preview.tsx +++ /dev/null @@ -1,81 +0,0 @@ -/* - * 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, { FC, useEffect, useState } from 'react'; -import { EuiFlexGroup, EuiFlexItem, EuiSpacer } from '@elastic/eui'; -import classNames from 'classnames'; -import { - MetricDistributionChart, - MetricDistributionChartData, - buildChartDataFromStats, -} from '../metric_distribution_chart'; -import { formatSingleValue } from '../../../../formatters/format_value'; -import { FieldVisConfig } from '../../types'; -import { kibanaFieldFormat } from '../../../../formatters/kibana_field_format'; - -const METRIC_DISTRIBUTION_CHART_WIDTH = 150; -const METRIC_DISTRIBUTION_CHART_HEIGHT = 80; - -export interface NumberContentPreviewProps { - config: FieldVisConfig; -} - -export const IndexBasedNumberContentPreview: FC = ({ config }) => { - const { stats, fieldFormat, fieldName } = config; - const defaultChartData: MetricDistributionChartData[] = []; - const [distributionChartData, setDistributionChartData] = useState(defaultChartData); - const [legendText, setLegendText] = useState<{ min: number; max: number } | undefined>(); - const dataTestSubj = `mlDataGridChart-${fieldName}`; - useEffect(() => { - const chartData = buildChartDataFromStats(stats, METRIC_DISTRIBUTION_CHART_WIDTH); - if ( - Array.isArray(chartData) && - chartData[0].x !== undefined && - chartData[chartData.length - 1].x !== undefined - ) { - setDistributionChartData(chartData); - setLegendText({ - min: formatSingleValue(chartData[0].x), - max: formatSingleValue(chartData[chartData.length - 1].x), - }); - } - }, []); - - return ( -
-
- -
-
- {legendText && ( - <> - - - - {kibanaFieldFormat(legendText.min, fieldFormat)} - - - {kibanaFieldFormat(legendText.max, fieldFormat)} - - - - )} -
-
- ); -}; diff --git a/x-pack/plugins/ml/public/application/datavisualizer/stats_table/components/field_data_row/top_values_preview.tsx b/x-pack/plugins/ml/public/application/datavisualizer/stats_table/components/field_data_row/top_values_preview.tsx deleted file mode 100644 index 07a2eae95c890..0000000000000 --- a/x-pack/plugins/ml/public/application/datavisualizer/stats_table/components/field_data_row/top_values_preview.tsx +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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, { FC } from 'react'; -import { EuiDataGridColumn } from '@elastic/eui'; -import { ChartData, OrdinalDataItem } from '../../../../../../common/types/field_histograms'; -import { ColumnChart } from '../../../../components/data_grid/column_chart'; -import type { FieldDataRowProps } from '../../types/field_data_row'; - -export const TopValuesPreview: FC = ({ config }) => { - const { stats } = config; - if (stats === undefined) return null; - const { topValues, cardinality } = stats; - if (cardinality === undefined || topValues === undefined || config.fieldName === undefined) - return null; - - const data: OrdinalDataItem[] = topValues.map((d) => ({ - ...d, - key: d.key.toString(), - })); - const chartData: ChartData = { - cardinality, - data, - id: config.fieldName, - type: 'ordinal', - }; - const columnType: EuiDataGridColumn = { - id: config.fieldName, - schema: undefined, - }; - return ( - - ); -}; diff --git a/x-pack/plugins/ml/public/application/datavisualizer/stats_table/components/metric_distribution_chart/index.ts b/x-pack/plugins/ml/public/application/datavisualizer/stats_table/components/metric_distribution_chart/index.ts deleted file mode 100644 index 72947f2953cb8..0000000000000 --- a/x-pack/plugins/ml/public/application/datavisualizer/stats_table/components/metric_distribution_chart/index.ts +++ /dev/null @@ -1,9 +0,0 @@ -/* - * 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. - */ - -export { MetricDistributionChart, MetricDistributionChartData } from './metric_distribution_chart'; -export { buildChartDataFromStats } from './metric_distribution_chart_data_builder'; diff --git a/x-pack/plugins/ml/public/application/datavisualizer/stats_table/components/metric_distribution_chart/metric_distribution_chart.tsx b/x-pack/plugins/ml/public/application/datavisualizer/stats_table/components/metric_distribution_chart/metric_distribution_chart.tsx deleted file mode 100644 index 4d9042dc74834..0000000000000 --- a/x-pack/plugins/ml/public/application/datavisualizer/stats_table/components/metric_distribution_chart/metric_distribution_chart.tsx +++ /dev/null @@ -1,101 +0,0 @@ -/* - * 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, { FC } from 'react'; - -import { i18n } from '@kbn/i18n'; - -import { - AreaSeries, - Axis, - Chart, - CurveType, - Position, - ScaleType, - Settings, - TooltipValueFormatter, -} from '@elastic/charts'; - -import { MetricDistributionChartTooltipHeader } from './metric_distribution_chart_tooltip_header'; -import { kibanaFieldFormat } from '../../../../formatters/kibana_field_format'; -import type { ChartTooltipValue } from '../../../../components/chart_tooltip/chart_tooltip_service'; -import { useDataVizChartTheme } from '../../hooks'; - -export interface MetricDistributionChartData { - x: number; - y: number; - dataMin: number; - dataMax: number; - percent: number; -} - -interface Props { - width: number; - height: number; - chartData: MetricDistributionChartData[]; - fieldFormat?: any; // Kibana formatter for field being viewed - hideXAxis?: boolean; -} - -const SPEC_ID = 'metric_distribution'; - -export const MetricDistributionChart: FC = ({ - width, - height, - chartData, - fieldFormat, - hideXAxis, -}) => { - // This value is shown to label the y axis values in the tooltip. - // Ideally we wouldn't show these values at all in the tooltip, - // but this is not yet possible with Elastic charts. - const seriesName = i18n.translate('xpack.ml.fieldDataCard.metricDistributionChart.seriesName', { - defaultMessage: 'distribution', - }); - - const theme = useDataVizChartTheme(); - - const headerFormatter: TooltipValueFormatter = (tooltipData: ChartTooltipValue) => { - const xValue = tooltipData.value; - const chartPoint: MetricDistributionChartData | undefined = chartData.find( - (data) => data.x === xValue - ); - - return ( - - ); - }; - - return ( -
- - - kibanaFieldFormat(d, fieldFormat)} - hide={hideXAxis === true} - /> - d.toFixed(3)} hide={true} /> - 0 ? chartData : [{ x: 0, y: 0 }]} - curve={CurveType.CURVE_STEP_AFTER} - /> - -
- ); -}; diff --git a/x-pack/plugins/ml/public/application/datavisualizer/stats_table/components/metric_distribution_chart/metric_distribution_chart_data_builder.tsx b/x-pack/plugins/ml/public/application/datavisualizer/stats_table/components/metric_distribution_chart/metric_distribution_chart_data_builder.tsx deleted file mode 100644 index a65b6bdc7458f..0000000000000 --- a/x-pack/plugins/ml/public/application/datavisualizer/stats_table/components/metric_distribution_chart/metric_distribution_chart_data_builder.tsx +++ /dev/null @@ -1,156 +0,0 @@ -/* - * 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. - */ - -const METRIC_DISTRIBUTION_CHART_MIN_BAR_WIDTH = 3; // Minimum bar width, in pixels. -const METRIC_DISTRIBUTION_CHART_MAX_BAR_HEIGHT_FACTOR = 20; // Max bar height relative to median bar height. - -import { MetricDistributionChartData } from './metric_distribution_chart'; - -interface DistributionPercentile { - minValue: number; - maxValue: number; - percent: number; -} - -interface DistributionChartBar { - x0: number; - x1: number; - y: number; - dataMin: number; - dataMax: number; - percent: number; - isMinWidth: boolean; -} - -export function buildChartDataFromStats( - stats: any, - chartWidth: number -): MetricDistributionChartData[] { - // Process the raw percentiles data so it is in a suitable format for plotting in the metric distribution chart. - let chartData: MetricDistributionChartData[] = []; - - const distribution = stats.distribution; - if (distribution === undefined) { - return chartData; - } - - const percentiles: DistributionPercentile[] = distribution.percentiles; - if (percentiles.length === 0) { - return chartData; - } - - // Adjust x axis min and max if there is a single bar. - const minX = percentiles[0].minValue; - const maxX = percentiles[percentiles.length - 1].maxValue; - - let xAxisMin: number = minX; - let xAxisMax: number = maxX; - if (maxX === minX) { - if (minX !== 0) { - xAxisMin = 0; - xAxisMax = 2 * minX; - } else { - xAxisMax = 1; - } - } - - // Adjust the right hand x coordinates so that each bar is at least METRIC_DISTRIBUTION_CHART_MIN_BAR_WIDTH. - const minBarWidth = - (METRIC_DISTRIBUTION_CHART_MIN_BAR_WIDTH / chartWidth) * (xAxisMax - xAxisMin); - const processedData: DistributionChartBar[] = []; - let lastBar: DistributionChartBar; - percentiles.forEach((data, index) => { - if (index === 0) { - const bar: DistributionChartBar = { - x0: data.minValue, - x1: Math.max(data.minValue + minBarWidth, data.maxValue), - y: 0, // Set below - dataMin: data.minValue, - dataMax: data.maxValue, - percent: data.percent, - isMinWidth: false, - }; - - // Scale the height of the bar according to the range of data values in the bar. - bar.y = - (data.percent / (bar.x1 - bar.x0)) * - Math.max(1, minBarWidth / Math.max(data.maxValue - data.minValue, 0.5 * minBarWidth)); - bar.isMinWidth = data.maxValue <= data.minValue + minBarWidth; - processedData.push(bar); - lastBar = bar; - } else { - if (lastBar.isMinWidth === false || data.maxValue > lastBar.x1) { - const bar = { - x0: lastBar.x1, - x1: Math.max(lastBar.x1 + minBarWidth, data.maxValue), - y: 0, // Set below - dataMin: data.minValue, - dataMax: data.maxValue, - percent: data.percent, - isMinWidth: false, - }; - - // Scale the height of the bar according to the range of data values in the bar. - bar.y = - (data.percent / (bar.x1 - bar.x0)) * - Math.max(1, minBarWidth / Math.max(data.maxValue - data.minValue, 0.5 * minBarWidth)); - bar.isMinWidth = data.maxValue <= lastBar.x1 + minBarWidth; - processedData.push(bar); - lastBar = bar; - } else { - // Combine bars which are less than minBarWidth apart. - lastBar.percent = lastBar.percent + data.percent; - lastBar.y = lastBar.percent / (lastBar.x1 - lastBar.x0); - lastBar.dataMax = data.maxValue; - } - } - }); - - if (maxX !== minX) { - xAxisMax = processedData[processedData.length - 1].x1; - } - - // Adjust the maximum bar height to be (METRIC_DISTRIBUTION_CHART_MAX_BAR_HEIGHT_FACTOR * median bar height). - let barHeights = processedData.map((data) => data.y); - barHeights = barHeights.sort((a, b) => a - b); - - let maxBarHeight = 0; - const processedDataLength = processedData.length; - if (Math.abs(processedDataLength % 2) === 1) { - maxBarHeight = - METRIC_DISTRIBUTION_CHART_MAX_BAR_HEIGHT_FACTOR * - barHeights[Math.floor(processedDataLength / 2)]; - } else { - maxBarHeight = - (METRIC_DISTRIBUTION_CHART_MAX_BAR_HEIGHT_FACTOR * - (barHeights[Math.floor(processedDataLength / 2) - 1] + - barHeights[Math.floor(processedDataLength / 2)])) / - 2; - } - - processedData.forEach((data) => { - data.y = Math.min(data.y, maxBarHeight); - }); - - // Convert the data to the format used by the chart. - chartData = processedData.map((data) => { - const { x0, y, dataMin, dataMax, percent } = data; - return { x: x0, y, dataMin, dataMax, percent }; - }); - - // Add a final point to drop the curve back to the y axis. - const last = processedData[processedData.length - 1]; - chartData.push({ - x: last.x1, - y: 0, - dataMin: last.dataMin, - dataMax: last.dataMax, - percent: last.percent, - }); - - return chartData; -} diff --git a/x-pack/plugins/ml/public/application/datavisualizer/stats_table/components/metric_distribution_chart/metric_distribution_chart_tooltip_header.tsx b/x-pack/plugins/ml/public/application/datavisualizer/stats_table/components/metric_distribution_chart/metric_distribution_chart_tooltip_header.tsx deleted file mode 100644 index 3144676a46c83..0000000000000 --- a/x-pack/plugins/ml/public/application/datavisualizer/stats_table/components/metric_distribution_chart/metric_distribution_chart_tooltip_header.tsx +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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, { FC } from 'react'; - -import { FormattedMessage } from '@kbn/i18n/react'; - -import { MetricDistributionChartData } from './metric_distribution_chart'; -import { kibanaFieldFormat } from '../../../../formatters/kibana_field_format'; - -interface Props { - chartPoint: MetricDistributionChartData | undefined; - maxWidth: number; - fieldFormat?: any; // Kibana formatter for field being viewed -} - -export const MetricDistributionChartTooltipHeader: FC = ({ - chartPoint, - maxWidth, - fieldFormat, -}) => { - if (chartPoint === undefined) { - return null; - } - - return ( -
- {chartPoint.dataMax > chartPoint.dataMin ? ( - - ) : ( - - )} -
- ); -}; diff --git a/x-pack/plugins/ml/public/application/datavisualizer/stats_table/data_visualizer_stats_table.tsx b/x-pack/plugins/ml/public/application/datavisualizer/stats_table/data_visualizer_stats_table.tsx deleted file mode 100644 index 2003d07efca82..0000000000000 --- a/x-pack/plugins/ml/public/application/datavisualizer/stats_table/data_visualizer_stats_table.tsx +++ /dev/null @@ -1,270 +0,0 @@ -/* - * 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, { useMemo, useState } from 'react'; - -import { - CENTER_ALIGNMENT, - EuiBasicTableColumn, - EuiButtonIcon, - EuiFlexItem, - EuiIcon, - EuiInMemoryTable, - EuiText, - HorizontalAlignment, - LEFT_ALIGNMENT, - RIGHT_ALIGNMENT, -} from '@elastic/eui'; -import { i18n } from '@kbn/i18n'; -import { EuiTableComputedColumnType } from '@elastic/eui/src/components/basic_table/table_types'; -import { ML_JOB_FIELD_TYPES } from '../../../../common/constants/field_types'; -import { FieldTypeIcon } from '../../components/field_type_icon'; -import { DocumentStat } from './components/field_data_row/document_stats'; -import { DistinctValues } from './components/field_data_row/distinct_values'; -import { IndexBasedNumberContentPreview } from './components/field_data_row/number_content_preview'; -import { - DataVisualizerFileBasedAppState, - DataVisualizerIndexBasedAppState, -} from '../../../../common/types/ml_url_generator'; -import { useTableSettings } from '../../data_frame_analytics/pages/analytics_management/components/analytics_list/use_table_settings'; -import { TopValuesPreview } from './components/field_data_row/top_values_preview'; -import type { MlJobFieldType } from '../../../../common/types/field_types'; -import { - FieldVisConfig, - FileBasedFieldVisConfig, - isIndexBasedFieldVisConfig, -} from './types/field_vis_config'; -import { BooleanContentPreview } from './components/field_data_row'; - -const FIELD_NAME = 'fieldName'; - -export type ItemIdToExpandedRowMap = Record; - -type DataVisualizerTableItem = FieldVisConfig | FileBasedFieldVisConfig; -interface DataVisualizerTableProps { - items: T[]; - pageState: DataVisualizerIndexBasedAppState | DataVisualizerFileBasedAppState; - updatePageState: ( - update: Partial - ) => void; - getItemIdToExpandedRowMap: (itemIds: string[], items: T[]) => ItemIdToExpandedRowMap; - extendedColumns?: Array>; -} - -export const DataVisualizerTable = ({ - items, - pageState, - updatePageState, - getItemIdToExpandedRowMap, - extendedColumns, -}: DataVisualizerTableProps) => { - const [expandedRowItemIds, setExpandedRowItemIds] = useState([]); - const [expandAll, toggleExpandAll] = useState(false); - - const { onTableChange, pagination, sorting } = useTableSettings( - items, - pageState, - updatePageState - ); - const showDistributions: boolean = - ('showDistributions' in pageState && pageState.showDistributions) ?? true; - const toggleShowDistribution = () => { - updatePageState({ - ...pageState, - showDistributions: !showDistributions, - }); - }; - - function toggleDetails(item: DataVisualizerTableItem) { - if (item.fieldName === undefined) return; - const index = expandedRowItemIds.indexOf(item.fieldName); - if (index !== -1) { - expandedRowItemIds.splice(index, 1); - } else { - expandedRowItemIds.push(item.fieldName); - } - - // spread to a new array otherwise the component wouldn't re-render - setExpandedRowItemIds([...expandedRowItemIds]); - } - - const columns = useMemo(() => { - const expanderColumn: EuiTableComputedColumnType = { - name: ( - toggleExpandAll(!expandAll)} - aria-label={ - !expandAll - ? i18n.translate('xpack.ml.datavisualizer.dataGrid.expandDetailsForAllAriaLabel', { - defaultMessage: 'Expand details for all fields', - }) - : i18n.translate('xpack.ml.datavisualizer.dataGrid.collapseDetailsForAllAriaLabel', { - defaultMessage: 'Collapse details for all fields', - }) - } - iconType={expandAll ? 'arrowUp' : 'arrowDown'} - /> - ), - align: RIGHT_ALIGNMENT, - width: '40px', - isExpander: true, - render: (item: DataVisualizerTableItem) => { - if (item.fieldName === undefined) return null; - const direction = expandedRowItemIds.includes(item.fieldName) ? 'arrowUp' : 'arrowDown'; - return ( - toggleDetails(item)} - aria-label={ - expandedRowItemIds.includes(item.fieldName) - ? i18n.translate('xpack.ml.datavisualizer.dataGrid.rowCollapse', { - defaultMessage: 'Hide details for {fieldName}', - values: { fieldName: item.fieldName }, - }) - : i18n.translate('xpack.ml.datavisualizer.dataGrid.rowExpand', { - defaultMessage: 'Show details for {fieldName}', - values: { fieldName: item.fieldName }, - }) - } - iconType={direction} - /> - ); - }, - 'data-test-subj': 'mlDataVisualizerTableColumnDetailsToggle', - }; - - const baseColumns = [ - expanderColumn, - { - field: 'type', - name: i18n.translate('xpack.ml.datavisualizer.dataGrid.typeColumnName', { - defaultMessage: 'Type', - }), - render: (fieldType: MlJobFieldType) => { - return ; - }, - width: '75px', - sortable: true, - align: CENTER_ALIGNMENT as HorizontalAlignment, - 'data-test-subj': 'mlDataVisualizerTableColumnType', - }, - { - field: 'fieldName', - name: i18n.translate('xpack.ml.datavisualizer.dataGrid.nameColumnName', { - defaultMessage: 'Name', - }), - sortable: true, - truncateText: true, - render: (fieldName: string) => ( - - {fieldName} - - ), - align: LEFT_ALIGNMENT as HorizontalAlignment, - 'data-test-subj': 'mlDataVisualizerTableColumnName', - }, - { - field: 'docCount', - name: i18n.translate('xpack.ml.datavisualizer.dataGrid.documentsCountColumnName', { - defaultMessage: 'Documents (%)', - }), - render: (value: number | undefined, item: DataVisualizerTableItem) => ( - - ), - sortable: (item: DataVisualizerTableItem) => item?.stats?.count, - align: LEFT_ALIGNMENT as HorizontalAlignment, - 'data-test-subj': 'mlDataVisualizerTableColumnDocumentsCount', - }, - { - field: 'stats.cardinality', - name: i18n.translate('xpack.ml.datavisualizer.dataGrid.distinctValuesColumnName', { - defaultMessage: 'Distinct values', - }), - render: (cardinality?: number) => , - sortable: true, - align: LEFT_ALIGNMENT as HorizontalAlignment, - 'data-test-subj': 'mlDataVisualizerTableColumnDistinctValues', - }, - { - name: ( -
- - {i18n.translate('xpack.ml.datavisualizer.dataGrid.distributionsColumnName', { - defaultMessage: 'Distributions', - })} - toggleShowDistribution()} - aria-label={i18n.translate( - 'xpack.ml.datavisualizer.dataGrid.showDistributionsAriaLabel', - { - defaultMessage: 'Show distributions', - } - )} - /> -
- ), - render: (item: DataVisualizerTableItem) => { - if (item === undefined || showDistributions === false) return null; - if ( - (item.type === ML_JOB_FIELD_TYPES.KEYWORD || item.type === ML_JOB_FIELD_TYPES.IP) && - item.stats?.topValues !== undefined - ) { - return ; - } - - if (item.type === ML_JOB_FIELD_TYPES.NUMBER) { - if (isIndexBasedFieldVisConfig(item) && item.stats?.distribution !== undefined) { - return ; - } - } - - if (item.type === ML_JOB_FIELD_TYPES.BOOLEAN) { - return ; - } - - return null; - }, - align: LEFT_ALIGNMENT as HorizontalAlignment, - 'data-test-subj': 'mlDataVisualizerTableColumnDistribution', - }, - ]; - return extendedColumns ? [...baseColumns, ...extendedColumns] : baseColumns; - }, [expandAll, showDistributions, updatePageState, extendedColumns]); - - const itemIdToExpandedRowMap = useMemo(() => { - let itemIds = expandedRowItemIds; - if (expandAll) { - itemIds = items.map((i) => i[FIELD_NAME]).filter((f) => f !== undefined) as string[]; - } - return getItemIdToExpandedRowMap(itemIds, items); - }, [expandAll, items, expandedRowItemIds]); - - return ( - - - className={'mlDataVisualizer'} - items={items} - itemId={FIELD_NAME} - columns={columns} - pagination={pagination} - sorting={sorting} - isExpandable={true} - itemIdToExpandedRowMap={itemIdToExpandedRowMap} - isSelectable={false} - onTableChange={onTableChange} - data-test-subj={'mlDataVisualizerTable'} - rowProps={(item) => ({ - 'data-test-subj': `mlDataVisualizerRow row-${item.fieldName}`, - })} - /> - - ); -}; diff --git a/x-pack/plugins/ml/public/application/datavisualizer/stats_table/hooks/index.ts b/x-pack/plugins/ml/public/application/datavisualizer/stats_table/hooks/index.ts deleted file mode 100644 index 85d85f51a623f..0000000000000 --- a/x-pack/plugins/ml/public/application/datavisualizer/stats_table/hooks/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -/* - * 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. - */ - -export { useDataVizChartTheme } from './use_data_viz_chart_theme'; diff --git a/x-pack/plugins/ml/public/application/datavisualizer/stats_table/hooks/use_data_viz_chart_theme.ts b/x-pack/plugins/ml/public/application/datavisualizer/stats_table/hooks/use_data_viz_chart_theme.ts deleted file mode 100644 index 0addadf3af0e9..0000000000000 --- a/x-pack/plugins/ml/public/application/datavisualizer/stats_table/hooks/use_data_viz_chart_theme.ts +++ /dev/null @@ -1,55 +0,0 @@ -/* - * 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 type { PartialTheme } from '@elastic/charts'; -import { useMemo } from 'react'; -import { useCurrentEuiTheme } from '../../../components/color_range_legend'; -export const useDataVizChartTheme = (): PartialTheme => { - const { euiTheme } = useCurrentEuiTheme(); - const chartTheme = useMemo(() => { - const AREA_SERIES_COLOR = euiTheme.euiColorVis0; - return { - axes: { - tickLabel: { - fontSize: parseInt(euiTheme.euiFontSizeXS, 10), - fontFamily: euiTheme.euiFontFamily, - fontStyle: 'italic', - }, - }, - background: { color: 'transparent' }, - chartMargins: { - left: 0, - right: 0, - top: 0, - bottom: 0, - }, - chartPaddings: { - left: 0, - right: 0, - top: 4, - bottom: 0, - }, - scales: { barsPadding: 0.1 }, - colors: { - vizColors: [AREA_SERIES_COLOR], - }, - areaSeriesStyle: { - line: { - strokeWidth: 1, - visible: true, - }, - point: { - visible: false, - radius: 0, - opacity: 0, - }, - area: { visible: true, opacity: 1 }, - }, - }; - }, [euiTheme]); - return chartTheme; -}; diff --git a/x-pack/plugins/ml/public/application/datavisualizer/stats_table/index.ts b/x-pack/plugins/ml/public/application/datavisualizer/stats_table/index.ts deleted file mode 100644 index 3009470af4858..0000000000000 --- a/x-pack/plugins/ml/public/application/datavisualizer/stats_table/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -/* - * 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. - */ - -export { DataVisualizerTable, ItemIdToExpandedRowMap } from './data_visualizer_stats_table'; diff --git a/x-pack/plugins/ml/public/application/datavisualizer/stats_table/types/field_vis_config.ts b/x-pack/plugins/ml/public/application/datavisualizer/stats_table/types/field_vis_config.ts deleted file mode 100644 index aa7bd2f5ecf6d..0000000000000 --- a/x-pack/plugins/ml/public/application/datavisualizer/stats_table/types/field_vis_config.ts +++ /dev/null @@ -1,99 +0,0 @@ -/* - * 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 { MlJobFieldType } from '../../../../../common/types/field_types'; - -export interface Percentile { - percent: number; - minValue: number; - maxValue: number; -} - -export interface MetricFieldVisStats { - avg?: number; - distribution?: { - percentiles: Percentile[]; - maxPercentile: number; - minPercentile: 0; - }; - max?: number; - median?: number; - min?: number; -} - -interface DocumentCountBuckets { - [key: string]: number; -} - -export interface FieldVisStats { - cardinality?: number; - count?: number; - sampleCount?: number; - trueCount?: number; - falseCount?: number; - earliest?: number; - latest?: number; - documentCounts?: { - buckets?: DocumentCountBuckets; - interval?: number; - }; - avg?: number; - distribution?: { - percentiles: Percentile[]; - maxPercentile: number; - minPercentile: 0; - }; - fieldName?: string; - isTopValuesSampled?: boolean; - max?: number; - median?: number; - min?: number; - topValues?: Array<{ key: number | string; doc_count: number }>; - topValuesSampleSize?: number; - topValuesSamplerShardSize?: number; - examples?: Array; - timeRangeEarliest?: number; - timeRangeLatest?: number; -} - -// The internal representation of the configuration used to build the visuals -// which display the field information. -export interface FieldVisConfig { - type: MlJobFieldType; - fieldName?: string; - existsInDocs: boolean; - aggregatable: boolean; - loading: boolean; - stats?: FieldVisStats; - fieldFormat?: any; - isUnsupportedType?: boolean; -} - -export interface FileBasedFieldVisConfig { - type: MlJobFieldType; - fieldName?: string; - stats?: FieldVisStats; - format?: string; -} - -export interface FileBasedUnknownFieldVisConfig { - fieldName: string; - type: 'text' | 'unknown'; - stats: { mean: number; count: number; sampleCount: number; cardinality: number }; -} - -export function isFileBasedFieldVisConfig( - field: FieldVisConfig | FileBasedFieldVisConfig -): field is FileBasedFieldVisConfig { - return !field.hasOwnProperty('existsInDocs'); -} - -export function isIndexBasedFieldVisConfig( - field: FieldVisConfig | FileBasedFieldVisConfig -): field is FieldVisConfig { - return field.hasOwnProperty('existsInDocs'); -} diff --git a/x-pack/plugins/ml/public/application/datavisualizer/stats_table/types/index.ts b/x-pack/plugins/ml/public/application/datavisualizer/stats_table/types/index.ts deleted file mode 100644 index 161829461aa26..0000000000000 --- a/x-pack/plugins/ml/public/application/datavisualizer/stats_table/types/index.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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. - */ - -export { FieldDataRowProps } from './field_data_row'; -export { - FieldVisConfig, - FileBasedFieldVisConfig, - FieldVisStats, - MetricFieldVisStats, - isFileBasedFieldVisConfig, - isIndexBasedFieldVisConfig, -} from './field_vis_config'; diff --git a/x-pack/plugins/ml/public/application/datavisualizer/stats_table/utils.ts b/x-pack/plugins/ml/public/application/datavisualizer/stats_table/utils.ts deleted file mode 100644 index 27da91153b3ba..0000000000000 --- a/x-pack/plugins/ml/public/application/datavisualizer/stats_table/utils.ts +++ /dev/null @@ -1,38 +0,0 @@ -/* - * 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 { FileBasedFieldVisConfig } from './types'; - -export const getTFPercentage = (config: FileBasedFieldVisConfig) => { - const { stats } = config; - if (stats === undefined) return null; - const { count } = stats; - // use stats from index based config - let { trueCount, falseCount } = stats; - - // use stats from file based find structure results - if (stats.trueCount === undefined || stats.falseCount === undefined) { - if (config?.stats?.topValues) { - config.stats.topValues.forEach((doc) => { - if (doc.doc_count !== undefined) { - if (doc.key.toString().toLowerCase() === 'false') { - falseCount = doc.doc_count; - } - if (doc.key.toString().toLowerCase() === 'true') { - trueCount = doc.doc_count; - } - } - }); - } - } - if (count === undefined || trueCount === undefined || falseCount === undefined) return null; - return { - count, - trueCount, - falseCount, - }; -}; diff --git a/x-pack/plugins/ml/public/application/routing/routes/datavisualizer/index_based.tsx b/x-pack/plugins/ml/public/application/routing/routes/datavisualizer/index_based.tsx index 7911014291f15..27676820c0472 100644 --- a/x-pack/plugins/ml/public/application/routing/routes/datavisualizer/index_based.tsx +++ b/x-pack/plugins/ml/public/application/routing/routes/datavisualizer/index_based.tsx @@ -14,7 +14,7 @@ import { NavigateToPath } from '../../../contexts/kibana'; import { MlRoute, PageLoader, PageProps } from '../../router'; import { useResolver } from '../../use_resolver'; -import { Page } from '../../../datavisualizer/index_based'; +import { IndexDataVisualizerPage as Page } from '../../../datavisualizer/index_based/index_data_visualizer'; import { checkBasicLicense } from '../../../license'; import { checkGetJobsCapabilitiesResolver } from '../../../capabilities/check_capabilities'; diff --git a/x-pack/plugins/ml/public/application/services/ml_api_service/index.ts b/x-pack/plugins/ml/public/application/services/ml_api_service/index.ts index f8ec4b6488316..d66805b4f737f 100644 --- a/x-pack/plugins/ml/public/application/services/ml_api_service/index.ts +++ b/x-pack/plugins/ml/public/application/services/ml_api_service/index.ts @@ -35,10 +35,7 @@ import { ModelSnapshot, IndicesOptions, } from '../../../../common/types/anomaly_detection_jobs'; -import { - FieldHistogramRequestConfig, - FieldRequestConfig, -} from '../../datavisualizer/index_based/common'; +import { FieldHistogramRequestConfig } from '../../datavisualizer/index_based/common/request'; import { DataRecognizerConfigResponse, Module } from '../../../../common/types/modules'; import { getHttp } from '../../util/dependency_cache'; import type { RuntimeMappings } from '../../../../common/types/fields'; @@ -465,48 +462,6 @@ export function mlApiServicesProvider(httpService: HttpService) { }); }, - getVisualizerFieldStats({ - indexPatternTitle, - query, - timeFieldName, - earliest, - latest, - samplerShardSize, - interval, - fields, - maxExamples, - runtimeMappings, - }: { - indexPatternTitle: string; - query: any; - timeFieldName?: string; - earliest?: number; - latest?: number; - samplerShardSize?: number; - interval?: number; - fields?: FieldRequestConfig[]; - maxExamples?: number; - runtimeMappings?: RuntimeMappings; - }) { - const body = JSON.stringify({ - query, - timeFieldName, - earliest, - latest, - samplerShardSize, - interval, - fields, - maxExamples, - runtimeMappings, - }); - - return httpService.http({ - path: `${basePath()}/data_visualizer/get_field_stats/${indexPatternTitle}`, - method: 'POST', - body, - }); - }, - getVisualizerFieldHistograms({ indexPatternTitle, query, @@ -534,45 +489,6 @@ export function mlApiServicesProvider(httpService: HttpService) { }); }, - getVisualizerOverallStats({ - indexPatternTitle, - query, - timeFieldName, - earliest, - latest, - samplerShardSize, - aggregatableFields, - nonAggregatableFields, - runtimeMappings, - }: { - indexPatternTitle: string; - query: any; - timeFieldName?: string; - earliest?: number; - latest?: number; - samplerShardSize?: number; - aggregatableFields: string[]; - nonAggregatableFields: string[]; - runtimeMappings?: RuntimeMappings; - }) { - const body = JSON.stringify({ - query, - timeFieldName, - earliest, - latest, - samplerShardSize, - aggregatableFields, - nonAggregatableFields, - runtimeMappings, - }); - - return httpService.http({ - path: `${basePath()}/data_visualizer/get_overall_stats/${indexPatternTitle}`, - method: 'POST', - body, - }); - }, - /** * Gets a list of calendars * @param obj diff --git a/x-pack/plugins/ml/public/application/util/dependency_cache.ts b/x-pack/plugins/ml/public/application/util/dependency_cache.ts index 759d0dcc68741..4a3194ed4113f 100644 --- a/x-pack/plugins/ml/public/application/util/dependency_cache.ts +++ b/x-pack/plugins/ml/public/application/util/dependency_cache.ts @@ -23,7 +23,7 @@ import type { IndexPatternsContract, DataPublicPluginStart } from 'src/plugins/d import type { SharePluginStart } from 'src/plugins/share/public'; import type { SecurityPluginSetup } from '../../../../security/public'; import type { MapsStartApi } from '../../../../maps/public'; -import type { FileDataVisualizerPluginStart } from '../../../../file_data_visualizer/public'; +import type { DataVisualizerPluginStart } from '../../../../data_visualizer/public'; export interface DependencyCache { timefilter: DataPublicPluginSetup['query']['timefilter'] | null; @@ -44,7 +44,7 @@ export interface DependencyCache { i18n: I18nStart | null; urlGenerators: SharePluginStart['urlGenerators'] | null; maps: MapsStartApi | null; - fileDataVisualizer: FileDataVisualizerPluginStart | null; + dataVisualizer: DataVisualizerPluginStart | null; } const cache: DependencyCache = { @@ -66,7 +66,7 @@ const cache: DependencyCache = { i18n: null, urlGenerators: null, maps: null, - fileDataVisualizer: null, + dataVisualizer: null, }; export function setDependencyCache(deps: Partial) { @@ -87,7 +87,7 @@ export function setDependencyCache(deps: Partial) { cache.security = deps.security || null; cache.i18n = deps.i18n || null; cache.urlGenerators = deps.urlGenerators || null; - cache.fileDataVisualizer = deps.fileDataVisualizer || null; + cache.dataVisualizer = deps.dataVisualizer || null; } export function getTimefilter() { @@ -215,8 +215,8 @@ export function clearCache() { } export function getFileDataVisualizer() { - if (cache.fileDataVisualizer === null) { - throw new Error("fileDataVisualizer hasn't been initialized"); + if (cache.dataVisualizer === null) { + throw new Error("dataVisualizer hasn't been initialized"); } - return cache.fileDataVisualizer; + return cache.dataVisualizer; } diff --git a/x-pack/plugins/ml/public/plugin.ts b/x-pack/plugins/ml/public/plugin.ts index 1f41f0a1d25c3..42440883408ae 100644 --- a/x-pack/plugins/ml/public/plugin.ts +++ b/x-pack/plugins/ml/public/plugin.ts @@ -51,7 +51,7 @@ import { TriggersAndActionsUIPublicPluginSetup, TriggersAndActionsUIPublicPluginStart, } from '../../triggers_actions_ui/public'; -import { FileDataVisualizerPluginStart } from '../../file_data_visualizer/public'; +import { DataVisualizerPluginStart } from '../../data_visualizer/public'; import { PluginSetupContract as AlertingSetup } from '../../alerting/public'; import { registerManagementSection } from './application/management'; @@ -65,7 +65,7 @@ export interface MlStartDependencies { maps?: MapsStartApi; lens?: LensPublicStart; triggersActionsUi?: TriggersAndActionsUIPublicPluginStart; - fileDataVisualizer: FileDataVisualizerPluginStart; + dataVisualizer: DataVisualizerPluginStart; } export interface MlSetupDependencies { @@ -123,7 +123,7 @@ export class MlPlugin implements Plugin { lens: pluginsStart.lens, kibanaVersion, triggersActionsUi: pluginsStart.triggersActionsUi, - fileDataVisualizer: pluginsStart.fileDataVisualizer, + dataVisualizer: pluginsStart.dataVisualizer, }, params ); diff --git a/x-pack/plugins/ml/public/register_helper/register_search_links/search_deep_links.ts b/x-pack/plugins/ml/public/register_helper/register_search_links/search_deep_links.ts index d682a93fa274c..e6ffa3b530858 100644 --- a/x-pack/plugins/ml/public/register_helper/register_search_links/search_deep_links.ts +++ b/x-pack/plugins/ml/public/register_helper/register_search_links/search_deep_links.ts @@ -44,7 +44,7 @@ const DATA_FRAME_ANALYTICS_DEEP_LINK: AppDeepLink = { }; const DATA_VISUALIZER_DEEP_LINK: AppDeepLink = { - id: 'mlDataVisualizerDeepLink', + id: 'dataVisualizerDeepLink', title: i18n.translate('xpack.ml.deepLink.dataVisualizer', { defaultMessage: 'Data Visualizer', }), diff --git a/x-pack/plugins/ml/server/routes/data_visualizer.ts b/x-pack/plugins/ml/server/routes/data_visualizer.ts index 62a93f16d17fc..39cbb3e9d35f6 100644 --- a/x-pack/plugins/ml/server/routes/data_visualizer.ts +++ b/x-pack/plugins/ml/server/routes/data_visualizer.ts @@ -8,70 +8,14 @@ import { IScopedClusterClient } from 'kibana/server'; import { wrapError } from '../client/error_wrapper'; import { DataVisualizer } from '../models/data_visualizer'; -import { Field, HistogramField } from '../models/data_visualizer/data_visualizer'; +import { HistogramField } from '../models/data_visualizer/data_visualizer'; import { dataVisualizerFieldHistogramsSchema, - dataVisualizerFieldStatsSchema, - dataVisualizerOverallStatsSchema, indexPatternTitleSchema, } from './schemas/data_visualizer_schema'; import { RouteInitialization } from '../types'; import { RuntimeMappings } from '../../common/types/fields'; -function getOverallStats( - client: IScopedClusterClient, - indexPatternTitle: string, - query: object, - aggregatableFields: string[], - nonAggregatableFields: string[], - samplerShardSize: number, - timeFieldName: string | undefined, - earliestMs: number | undefined, - latestMs: number | undefined, - runtimeMappings: RuntimeMappings -) { - const dv = new DataVisualizer(client); - return dv.getOverallStats( - indexPatternTitle, - query, - aggregatableFields, - nonAggregatableFields, - samplerShardSize, - timeFieldName, - earliestMs, - latestMs, - runtimeMappings - ); -} - -function getStatsForFields( - client: IScopedClusterClient, - indexPatternTitle: string, - query: any, - fields: Field[], - samplerShardSize: number, - timeFieldName: string | undefined, - earliestMs: number | undefined, - latestMs: number | undefined, - interval: number | undefined, - maxExamples: number, - runtimeMappings: RuntimeMappings -) { - const dv = new DataVisualizer(client); - return dv.getStatsForFields( - indexPatternTitle, - query, - fields, - samplerShardSize, - timeFieldName, - earliestMs, - latestMs, - interval, - maxExamples, - runtimeMappings - ); -} - function getHistogramsForFields( client: IScopedClusterClient, indexPatternTitle: string, @@ -141,131 +85,4 @@ export function dataVisualizerRoutes({ router, routeGuard }: RouteInitialization } }) ); - - /** - * @apiGroup DataVisualizer - * - * @api {post} /api/ml/data_visualizer/get_field_stats/:indexPatternTitle Get stats for fields - * @apiName GetStatsForFields - * @apiDescription Returns the stats on individual fields in the specified index pattern. - * - * @apiSchema (params) indexPatternTitleSchema - * @apiSchema (body) dataVisualizerFieldStatsSchema - * - * @apiSuccess {Object} fieldName stats by field, keyed on the name of the field. - */ - router.post( - { - path: '/api/ml/data_visualizer/get_field_stats/{indexPatternTitle}', - validate: { - params: indexPatternTitleSchema, - body: dataVisualizerFieldStatsSchema, - }, - options: { - tags: ['access:ml:canAccessML'], - }, - }, - routeGuard.basicLicenseAPIGuard(async ({ client, request, response }) => { - try { - const { - params: { indexPatternTitle }, - body: { - query, - fields, - samplerShardSize, - timeFieldName, - earliest, - latest, - interval, - maxExamples, - runtimeMappings, - }, - } = request; - const results = await getStatsForFields( - client, - indexPatternTitle, - query, - fields, - samplerShardSize, - timeFieldName, - earliest, - latest, - interval, - maxExamples, - runtimeMappings - ); - - return response.ok({ - body: results, - }); - } catch (e) { - return response.customError(wrapError(e)); - } - }) - ); - - /** - * @apiGroup DataVisualizer - * - * @api {post} /api/ml/data_visualizer/get_overall_stats/:indexPatternTitle Get overall stats - * @apiName GetOverallStats - * @apiDescription Returns the top level overall stats for the specified index pattern. - * - * @apiSchema (params) indexPatternTitleSchema - * @apiSchema (body) dataVisualizerOverallStatsSchema - * - * @apiSuccess {number} totalCount total count of documents. - * @apiSuccess {Object} aggregatableExistsFields stats on aggregatable fields that exist in documents. - * @apiSuccess {Object} aggregatableNotExistsFields stats on aggregatable fields that do not exist in documents. - * @apiSuccess {Object} nonAggregatableExistsFields stats on non-aggregatable fields that exist in documents. - * @apiSuccess {Object} nonAggregatableNotExistsFields stats on non-aggregatable fields that do not exist in documents. - */ - router.post( - { - path: '/api/ml/data_visualizer/get_overall_stats/{indexPatternTitle}', - validate: { - params: indexPatternTitleSchema, - body: dataVisualizerOverallStatsSchema, - }, - options: { - tags: ['access:ml:canAccessML'], - }, - }, - routeGuard.basicLicenseAPIGuard(async ({ client, request, response }) => { - try { - const { - params: { indexPatternTitle }, - body: { - query, - aggregatableFields, - nonAggregatableFields, - samplerShardSize, - timeFieldName, - earliest, - latest, - runtimeMappings, - }, - } = request; - - const results = await getOverallStats( - client, - indexPatternTitle, - query, - aggregatableFields, - nonAggregatableFields, - samplerShardSize, - timeFieldName, - earliest, - latest, - runtimeMappings - ); - - return response.ok({ - body: results, - }); - } catch (e) { - return response.customError(wrapError(e)); - } - }) - ); } diff --git a/x-pack/plugins/ml/tsconfig.json b/x-pack/plugins/ml/tsconfig.json index d887cfc885253..221718d423383 100644 --- a/x-pack/plugins/ml/tsconfig.json +++ b/x-pack/plugins/ml/tsconfig.json @@ -24,7 +24,7 @@ { "path": "../../../src/plugins/index_pattern_management/tsconfig.json" }, { "path": "../cloud/tsconfig.json" }, { "path": "../features/tsconfig.json" }, - { "path": "../file_data_visualizer/tsconfig.json" }, + { "path": "../data_visualizer/tsconfig.json"}, { "path": "../license_management/tsconfig.json" }, { "path": "../licensing/tsconfig.json" }, { "path": "../maps/tsconfig.json" }, diff --git a/x-pack/plugins/translations/translations/ja-JP.json b/x-pack/plugins/translations/translations/ja-JP.json index 26521b420ae25..7f82d9f32a868 100644 --- a/x-pack/plugins/translations/translations/ja-JP.json +++ b/x-pack/plugins/translations/translations/ja-JP.json @@ -8510,224 +8510,247 @@ "xpack.features.ossFeatures.visualizeShortUrlSubFeatureName": "短い URL", "xpack.features.savedObjectsManagementFeatureName": "保存されたオブジェクトの管理", "xpack.features.visualizeFeatureName": "Visualizeライブラリ", - "xpack.fileDataVisualizer.aboutPanel.analyzingDataTitle": "データを分析中", - "xpack.fileDataVisualizer.aboutPanel.selectOrDragAndDropFileDescription": "ファイルを選択するかドラッグ &amp; ドロップしてください", - "xpack.fileDataVisualizer.addCombinedFieldsLabel": "結合されたフィールドを追加", - "xpack.fileDataVisualizer.advancedImportSettings.createIndexPatternLabel": "インデックスパターンを作成", - "xpack.fileDataVisualizer.advancedImportSettings.indexNameAriaLabel": "インデックス名、必須フィールド", - "xpack.fileDataVisualizer.advancedImportSettings.indexNameLabel": "インデックス名", - "xpack.fileDataVisualizer.advancedImportSettings.indexNamePlaceholder": "インデックス名", - "xpack.fileDataVisualizer.advancedImportSettings.indexPatternNameLabel": "インデックスパターン名", - "xpack.fileDataVisualizer.advancedImportSettings.indexSettingsLabel": "インデックス設定", - "xpack.fileDataVisualizer.advancedImportSettings.ingestPipelineLabel": "パイプラインを投入", - "xpack.fileDataVisualizer.advancedImportSettings.mappingsLabel": "マッピング", - "xpack.fileDataVisualizer.analysisSummary.analyzedLinesNumberTitle": "分析した行数", - "xpack.fileDataVisualizer.analysisSummary.delimiterTitle": "区切り記号", - "xpack.fileDataVisualizer.analysisSummary.formatTitle": "フォーマット", - "xpack.fileDataVisualizer.analysisSummary.grokPatternTitle": "Grok パターン", - "xpack.fileDataVisualizer.analysisSummary.hasHeaderRowTitle": "ヘッダー行があります", - "xpack.fileDataVisualizer.analysisSummary.summaryTitle": "まとめ", - "xpack.fileDataVisualizer.analysisSummary.timeFieldTitle": "時間フィールド", - "xpack.fileDataVisualizer.bottomBar.backButtonLabel": "戻る", - "xpack.fileDataVisualizer.bottomBar.cancelButtonLabel": "キャンセル", - "xpack.fileDataVisualizer.bottomBar.missingImportPrivilegesMessage": "データインポートを有効にするには、ingest_adminロールが必要です", - "xpack.fileDataVisualizer.bottomBar.readMode.cancelButtonLabel": "キャンセル", - "xpack.fileDataVisualizer.bottomBar.readMode.importButtonLabel": "インポート", - "xpack.fileDataVisualizer.combinedFieldsForm.mappingsParseError": "マッピングのパース中にエラーが発生しました:{error}", - "xpack.fileDataVisualizer.combinedFieldsForm.pipelineParseError": "パイプラインのパース中にエラーが発生しました:{error}", - "xpack.fileDataVisualizer.combinedFieldsLabel": "結合されたフィールド", - "xpack.fileDataVisualizer.combinedFieldsReadOnlyHelpTextLabel": "詳細タグで結合されたフィールドを編集", - "xpack.fileDataVisualizer.combinedFieldsReadOnlyLabel": "結合されたフィールド", - "xpack.fileDataVisualizer.components.colorRangeLegend.blueColorRangeLabel": "青", - "xpack.fileDataVisualizer.components.colorRangeLegend.greenRedColorRangeLabel": "緑 - 赤", - "xpack.fileDataVisualizer.components.colorRangeLegend.influencerScaleLabel": "影響因子カスタムスケール", - "xpack.fileDataVisualizer.components.colorRangeLegend.linearScaleLabel": "線形", - "xpack.fileDataVisualizer.components.colorRangeLegend.redColorRangeLabel": "赤", - "xpack.fileDataVisualizer.components.colorRangeLegend.redGreenColorRangeLabel": "赤 - 緑", - "xpack.fileDataVisualizer.components.colorRangeLegend.sqrtScaleLabel": "Sqrt", - "xpack.fileDataVisualizer.components.colorRangeLegend.yellowGreenBlueColorRangeLabel": "黄 - 緑 - 青", - "xpack.fileDataVisualizer.dataGridChart.histogramNotAvailable": "グラフはサポートされていません。", - "xpack.fileDataVisualizer.dataGridChart.notEnoughData": "0個のドキュメントにフィールドが含まれます。", - "xpack.fileDataVisualizer.dataGridChart.topCategoriesLegend": "上位 {maxChartColumns}/{cardinality} カテゴリ", - "xpack.fileDataVisualizer.datavisualizer.dataGrid.collapseDetailsForAllAriaLabel": "すべてのフィールドの詳細を折りたたむ", - "xpack.fileDataVisualizer.datavisualizer.dataGrid.distinctValuesColumnName": "固有の値", - "xpack.fileDataVisualizer.datavisualizer.dataGrid.distributionsColumnName": "分布", - "xpack.fileDataVisualizer.datavisualizer.dataGrid.documentsCountColumnName": "ドキュメント (%) ", - "xpack.fileDataVisualizer.datavisualizer.dataGrid.expandDetailsForAllAriaLabel": "すべてのフィールドの詳細を展開", - "xpack.fileDataVisualizer.datavisualizer.dataGrid.nameColumnName": "名前", - "xpack.fileDataVisualizer.datavisualizer.dataGrid.rowCollapse": "{fieldName} の詳細を非表示", - "xpack.fileDataVisualizer.datavisualizer.dataGrid.rowExpand": "{fieldName} の詳細を表示", - "xpack.fileDataVisualizer.datavisualizer.dataGrid.showDistributionsAriaLabel": "分布を表示", - "xpack.fileDataVisualizer.datavisualizer.dataGrid.typeColumnName": "型", - "xpack.fileDataVisualizer.editFlyout.applyOverrideSettingsButtonLabel": "適用", - "xpack.fileDataVisualizer.editFlyout.closeOverrideSettingsButtonLabel": "閉じる", - "xpack.fileDataVisualizer.editFlyout.overrides.customDelimiterFormRowLabel": "カスタム区切り記号", - "xpack.fileDataVisualizer.editFlyout.overrides.customTimestampFormatErrorMessage": "タイムスタンプのフォーマットは、これらの Java 日付/時刻フォーマットの組み合わせでなければなりません:\n yy, yyyy, M, MM, MMM, MMMM, d, dd, EEE, EEEE, H, HH, h, mm, ss, S-SSSSSSSSS, a, XX, XXX, zzz", - "xpack.fileDataVisualizer.editFlyout.overrides.customTimestampFormatFormRowLabel": "カスタムタイムスタンプフォーマット", - "xpack.fileDataVisualizer.editFlyout.overrides.dataFormatFormRowLabel": "データフォーマット", - "xpack.fileDataVisualizer.editFlyout.overrides.delimiterFormRowLabel": "区切り記号", - "xpack.fileDataVisualizer.editFlyout.overrides.editFieldNamesTitle": "フィールド名の編集", - "xpack.fileDataVisualizer.editFlyout.overrides.grokPatternFormRowLabel": "Grok パターン", - "xpack.fileDataVisualizer.editFlyout.overrides.hasHeaderRowLabel": "ヘッダー行があります", - "xpack.fileDataVisualizer.editFlyout.overrides.linesToSampleErrorMessage": "値は {min} よりも大きく {max} 以下でなければなりません", - "xpack.fileDataVisualizer.editFlyout.overrides.linesToSampleFormRowLabel": "サンプルする行数", - "xpack.fileDataVisualizer.editFlyout.overrides.quoteCharacterFormRowLabel": "引用符", - "xpack.fileDataVisualizer.editFlyout.overrides.timeFieldFormRowLabel": "時間フィールド", - "xpack.fileDataVisualizer.editFlyout.overrides.timestampEmptyValidationErrorMessage": "タイムスタンプフォーマットにタイムフォーマット文字グループがありません {timestampFormat}", - "xpack.fileDataVisualizer.editFlyout.overrides.timestampFormatFormRowLabel": "タイムスタンプフォーマット", - "xpack.fileDataVisualizer.editFlyout.overrides.timestampFormatHelpText": "対応フォーマットの詳細をご覧ください", - "xpack.fileDataVisualizer.editFlyout.overrides.timestampLetterSValidationErrorMessage": "{format} の文字 { length, plural, one { {lg} } other { グループ {lg} } } は、ss と {sep} からの区切りで始まっていないため、サポートされていません", - "xpack.fileDataVisualizer.editFlyout.overrides.timestampLetterValidationErrorMessage": "{format} の文字 { length, plural, one { {lg} } other { グループ {lg} } } はサポートされていません", - "xpack.fileDataVisualizer.editFlyout.overrides.timestampQuestionMarkValidationErrorMessage": "タイムスタンプフォーマット {timestampFormat} は、疑問符 ({fieldPlaceholder}) が含まれているためサポートされていません", - "xpack.fileDataVisualizer.editFlyout.overrides.trimFieldsLabel": "フィールドを切り抜く", - "xpack.fileDataVisualizer.editFlyout.overrideSettingsTitle": "上書き設定", - "xpack.fileDataVisualizer.experimentalBadge.experimentalLabel": "実験的", - "xpack.fileDataVisualizer.explanationFlyout.closeButton": "閉じる", - "xpack.fileDataVisualizer.explanationFlyout.content": "分析結果を生成した論理ステップ。", - "xpack.fileDataVisualizer.explanationFlyout.title": "分析説明", - "xpack.fileDataVisualizer.fieldDataCard.cardBoolean.valuesLabel": "値", - "xpack.fileDataVisualizer.fieldDataCard.cardDate.earliestLabel": "最も古い", - "xpack.fileDataVisualizer.fieldDataCard.cardDate.latestLabel": "最新", - "xpack.fileDataVisualizer.fieldDataCard.cardDate.summaryTableTitle": "まとめ", - "xpack.fileDataVisualizer.fieldDataCard.cardText.fieldMayBePopulatedDescription": "たとえば、ドキュメントマッピングで {copyToParam} パラメーターを使ったり、{includesParam} と {excludesParam} パラメーターを使用してインデックスした後に {sourceParam} フィールドから切り取ったりして入力される場合があります。", - "xpack.fileDataVisualizer.fieldDataCard.cardText.fieldNotPresentDescription": "このフィールドはクエリが実行されたドキュメントの {sourceParam} フィールドにありませんでした。", - "xpack.fileDataVisualizer.fieldDataCard.cardText.noExamplesForFieldsTitle": "このフィールドの例が取得されませんでした", - "xpack.fileDataVisualizer.fieldDataCard.examplesList.noExamplesMessage": "このフィールドの例が取得されませんでした", - "xpack.fileDataVisualizer.fieldDataCard.examplesList.title": "{numExamples, plural, one {値} other {例}}", - "xpack.fileDataVisualizer.fieldDataCard.metricDistributionChart.seriesName": "分布", - "xpack.fileDataVisualizer.fieldDataCard.metricDistributionChart.tooltipValueBetweenLabel": "{percent}% のドキュメントに {minValFormatted} から {maxValFormatted} の間の値があります", - "xpack.fileDataVisualizer.fieldDataCard.metricDistributionChart.tooltipValueEqualLabel": "{percent}% のドキュメントに {valFormatted} の値があります", - "xpack.fileDataVisualizer.fieldDataCard.topValues.calculatedFromSampleDescription": "1 つのシャードにつき {topValuesSamplerShardSize} のドキュメントのサンプルで計算されています", - "xpack.fileDataVisualizer.fieldDataCard.topValuesLabel": "トップの値", - "xpack.fileDataVisualizer.fieldDataCardExpandedRow.booleanContent.falseCountLabel": "False", - "xpack.fileDataVisualizer.fieldDataCardExpandedRow.booleanContent.summaryTableTitle": "まとめ", - "xpack.fileDataVisualizer.fieldDataCardExpandedRow.booleanContent.trueCountLabel": "True", - "xpack.fileDataVisualizer.fieldDataCardExpandedRow.documentStatsTable.countLabel": "カウント", - "xpack.fileDataVisualizer.fieldDataCardExpandedRow.documentStatsTable.distinctValueLabel": "固有の値", - "xpack.fileDataVisualizer.fieldDataCardExpandedRow.documentStatsTable.metaTableTitle": "ドキュメント統計情報", - "xpack.fileDataVisualizer.fieldDataCardExpandedRow.documentStatsTable.percentageLabel": "割合", - "xpack.fileDataVisualizer.fieldDataCardExpandedRow.numberContent.displayingPercentilesLabel": "{minPercent} - {maxPercent} パーセンタイルを表示中", - "xpack.fileDataVisualizer.fieldDataCardExpandedRow.numberContent.distributionTitle": "分布", - "xpack.fileDataVisualizer.fieldDataCardExpandedRow.numberContent.maxLabel": "最高", - "xpack.fileDataVisualizer.fieldDataCardExpandedRow.numberContent.medianLabel": "中間", - "xpack.fileDataVisualizer.fieldDataCardExpandedRow.numberContent.minLabel": "分", - "xpack.fileDataVisualizer.fieldDataCardExpandedRow.numberContent.summaryTableTitle": "まとめ", - "xpack.fileDataVisualizer.fieldNameSelect": "フィールド名", - "xpack.fileDataVisualizer.fieldStatsCard.maxTitle": "最高", - "xpack.fileDataVisualizer.fieldStatsCard.medianTitle": "中間", - "xpack.fileDataVisualizer.fieldStatsCard.minTitle": "分", - "xpack.fileDataVisualizer.fieldTypeIcon.booleanTypeAriaLabel": "ブールタイプ", - "xpack.fileDataVisualizer.fieldTypeIcon.dateTypeAriaLabel": "日付タイプ", - "xpack.fileDataVisualizer.fieldTypeIcon.fieldTypeTooltip": "{type} タイプ", - "xpack.fileDataVisualizer.fieldTypeIcon.geoPointTypeAriaLabel": "{geoPointParam} タイプ", - "xpack.fileDataVisualizer.fieldTypeIcon.ipTypeAriaLabel": "IP タイプ", - "xpack.fileDataVisualizer.fieldTypeIcon.keywordTypeAriaLabel": "キーワードタイプ", - "xpack.fileDataVisualizer.fieldTypeIcon.numberTypeAriaLabel": "数字タイプ", - "xpack.fileDataVisualizer.fieldTypeIcon.textTypeAriaLabel": "テキストタイプ", - "xpack.fileDataVisualizer.fieldTypeIcon.unknownTypeAriaLabel": "不明なタイプ", - "xpack.fileDataVisualizer.fieldTypeSelect": "フィールド型", - "xpack.fileDataVisualizer.fileBeatConfig.paths": "ファイルのパスをここに追加してください", - "xpack.fileDataVisualizer.fileBeatConfigFlyout.closeButton": "閉じる", - "xpack.fileDataVisualizer.fileBeatConfigFlyout.copyButton": "クリップボードにコピー", - "xpack.fileDataVisualizer.fileContents.fileContentsTitle": "ファイルコンテンツ", - "xpack.fileDataVisualizer.fileDatavisualizerView.xmlNotCurrentlySupportedErrorMessage": "XML は現在サポートされていません", - "xpack.fileDataVisualizer.fileErrorCallouts.applyOverridesDescription": "ファイル形式やタイムスタンプ形式などこのデータに関する何らかの情報がある場合は、初期オーバーライドを追加すると、残りの構造を推論するのに役立つことがあります。", - "xpack.fileDataVisualizer.fileErrorCallouts.fileCouldNotBeReadTitle": "ファイル構造を決定できません", - "xpack.fileDataVisualizer.fileErrorCallouts.fileSizeExceedsAllowedSizeByDiffFormatErrorMessage": "アップロードするよう選択されたファイルのサイズが {diffFormatted} に許可された最大サイズの {maxFileSizeFormatted} を超えています", - "xpack.fileDataVisualizer.fileErrorCallouts.fileSizeExceedsAllowedSizeErrorMessage": "アップロードするよう選択されたファイルのサイズは {fileSizeFormatted} で、許可された最大サイズの {maxFileSizeFormatted} を超えています。", - "xpack.fileDataVisualizer.fileErrorCallouts.fileSizeTooLargeTitle": "ファイルサイズが大きすぎます。", - "xpack.fileDataVisualizer.fileErrorCallouts.overrideButton": "上書き設定を適用", - "xpack.fileDataVisualizer.fileErrorCallouts.revertingToPreviousSettingsDescription": "以前の設定に戻しています。", - "xpack.fileDataVisualizer.geoPointCombinedFieldLabel": "地理ポイントフィールドを追加", - "xpack.fileDataVisualizer.geoPointForm.geoPointFieldAriaLabel": "地理ポイントフィールド、必須フィールド", - "xpack.fileDataVisualizer.geoPointForm.geoPointFieldLabel": "地理ポイントフィールド", - "xpack.fileDataVisualizer.geoPointForm.latFieldLabel": "緯度フィールド", - "xpack.fileDataVisualizer.geoPointForm.lonFieldLabel": "経度フィールド", - "xpack.fileDataVisualizer.geoPointForm.submitButtonLabel": "追加", - "xpack.fileDataVisualizer.importErrors.checkingPermissionErrorMessage": "パーミッションエラーをインポートします", - "xpack.fileDataVisualizer.importErrors.creatingIndexErrorMessage": "インデックスの作成中にエラーが発生しました", - "xpack.fileDataVisualizer.importErrors.creatingIndexPatternErrorMessage": "インデックスパターンの作成中にエラーが発生しました", - "xpack.fileDataVisualizer.importErrors.creatingIngestPipelineErrorMessage": "投入パイプラインの作成中にエラーが発生しました", - "xpack.fileDataVisualizer.importErrors.defaultErrorMessage": "エラー", - "xpack.fileDataVisualizer.importErrors.moreButtonLabel": "詳細", - "xpack.fileDataVisualizer.importErrors.parsingJSONErrorMessage": "JSON のパース中にエラーが発生しました", - "xpack.fileDataVisualizer.importErrors.readingFileErrorMessage": "ファイルの読み込み中にエラーが発生しました", - "xpack.fileDataVisualizer.importErrors.unknownErrorMessage": "不明なエラー", - "xpack.fileDataVisualizer.importErrors.uploadingDataErrorMessage": "データのアップロード中にエラーが発生しました", - "xpack.fileDataVisualizer.importProgress.createIndexPatternTitle": "インデックスパターンを作成", - "xpack.fileDataVisualizer.importProgress.createIndexTitle": "インデックスの作成", - "xpack.fileDataVisualizer.importProgress.createIngestPipelineTitle": "投入パイプラインの作成", - "xpack.fileDataVisualizer.importProgress.creatingIndexPatternDescription": "インデックスパターンを作成中です", - "xpack.fileDataVisualizer.importProgress.creatingIndexPatternTitle": "インデックスパターンを作成中です", - "xpack.fileDataVisualizer.importProgress.creatingIndexTitle": "インデックスを作成中です", - "xpack.fileDataVisualizer.importProgress.creatingIngestPipelineTitle": "投入パイプラインを作成中", - "xpack.fileDataVisualizer.importProgress.dataUploadedTitle": "データがアップロードされました", - "xpack.fileDataVisualizer.importProgress.fileProcessedTitle": "ファイルが処理されました", - "xpack.fileDataVisualizer.importProgress.indexCreatedTitle": "インデックスが作成されました", - "xpack.fileDataVisualizer.importProgress.indexPatternCreatedTitle": "インデックスパターンが作成されました", - "xpack.fileDataVisualizer.importProgress.ingestPipelineCreatedTitle": "投入パイプラインが作成されました", - "xpack.fileDataVisualizer.importProgress.processFileTitle": "ファイルの処理", - "xpack.fileDataVisualizer.importProgress.processingFileTitle": "ファイルを処理中", - "xpack.fileDataVisualizer.importProgress.processingImportedFileDescription": "インポートするファイルを処理中", - "xpack.fileDataVisualizer.importProgress.stepTwoCreatingIndexDescription": "インデックスを作成中です", - "xpack.fileDataVisualizer.importProgress.stepTwoCreatingIndexIngestPipelineDescription": "インデックスと投入パイプラインを作成中です", - "xpack.fileDataVisualizer.importProgress.uploadDataTitle": "データのアップロード", - "xpack.fileDataVisualizer.importProgress.uploadingDataDescription": "データをアップロード中です", - "xpack.fileDataVisualizer.importProgress.uploadingDataTitle": "データをアップロード中です", - "xpack.fileDataVisualizer.importSettings.advancedTabName": "高度な設定", - "xpack.fileDataVisualizer.importSettings.simpleTabName": "シンプル", - "xpack.fileDataVisualizer.importSummary.documentsCouldNotBeImportedDescription": "{importFailuresLength}/{docCount} 個のドキュメントをインポートできませんでした。行が Grok パターンと一致していないことが原因の可能性があります。", - "xpack.fileDataVisualizer.importSummary.documentsCouldNotBeImportedTitle": "ドキュメントの一部をインポートできませんでした。", - "xpack.fileDataVisualizer.importSummary.documentsIngestedTitle": "ドキュメントが投入されました", - "xpack.fileDataVisualizer.importSummary.failedDocumentsButtonLabel": "失敗したドキュメント", - "xpack.fileDataVisualizer.importSummary.failedDocumentsTitle": "失敗したドキュメント", - "xpack.fileDataVisualizer.importSummary.importCompleteTitle": "インポート完了", - "xpack.fileDataVisualizer.importSummary.indexPatternTitle": "インデックスパターン", - "xpack.fileDataVisualizer.importSummary.indexTitle": "インデックス", - "xpack.fileDataVisualizer.importSummary.ingestPipelineTitle": "パイプラインを投入", - "xpack.fileDataVisualizer.importView.experimentalFeatureTooltip": "実験的機能。フィードバックをお待ちしています。", - "xpack.fileDataVisualizer.importView.importButtonLabel": "インポート", - "xpack.fileDataVisualizer.importView.importDataTitle": "データのインポート", - "xpack.fileDataVisualizer.importView.importPermissionError": "インデックス {index} にデータを作成またはインポートするパーミッションがありません。", - "xpack.fileDataVisualizer.importView.indexNameAlreadyExistsErrorMessage": "インデックス名がすでに存在します", - "xpack.fileDataVisualizer.importView.indexNameContainsIllegalCharactersErrorMessage": "インデックス名に許可されていない文字が含まれています。", - "xpack.fileDataVisualizer.importView.indexPatternDoesNotMatchIndexNameErrorMessage": "インデックスパターンがインデックス名と一致しません", - "xpack.fileDataVisualizer.importView.indexPatternNameAlreadyExistsErrorMessage": "インデックスパターン名がすでに存在します", - "xpack.fileDataVisualizer.importView.parseMappingsError": "マッピングのパース中にエラーが発生しました:", - "xpack.fileDataVisualizer.importView.parsePipelineError": "投入パイプラインのパース中にエラーが発生しました:", - "xpack.fileDataVisualizer.importView.parseSettingsError": "設定のパース中にエラーが発生しました:", - "xpack.fileDataVisualizer.importView.resetButtonLabel": "リセット", - "xpack.fileDataVisualizer.multiSelectPicker.NoFiltersFoundMessage": "フィルターが見つかりません", - "xpack.fileDataVisualizer.nameCollisionMsg": "「{name}」はすでに存在します。一意の名前を入力してください。", - "xpack.fileDataVisualizer.removeCombinedFieldsLabel": "結合されたフィールドを削除", - "xpack.fileDataVisualizer.resultsLinks.fileBeatConfig": "Filebeat 構成を作成", - "xpack.fileDataVisualizer.resultsLinks.fileBeatConfigBottomText": "{password} が {user} ユーザーのパスワードである場合、{esUrl} は Elasticsearch の URL です。", - "xpack.fileDataVisualizer.resultsLinks.fileBeatConfigBottomTextNoUsername": "{esUrl} が Elasticsearch の URL である場合", - "xpack.fileDataVisualizer.resultsLinks.fileBeatConfigTitle": "Filebeat 構成", - "xpack.fileDataVisualizer.resultsLinks.fileBeatConfigTopText1": "Filebeat を使用して {index} インデックスに追加データをアップロードできます。", - "xpack.fileDataVisualizer.resultsLinks.fileBeatConfigTopText2": "{filebeatYml} を修正して接続情報を設定します。", - "xpack.fileDataVisualizer.resultsLinks.indexManagementTitle": "インデックス管理", - "xpack.fileDataVisualizer.resultsLinks.indexPatternManagementTitle": "インデックスパターン管理", - "xpack.fileDataVisualizer.resultsLinks.viewIndexInDiscoverTitle": "インデックスを Discover で表示", - "xpack.fileDataVisualizer.resultsView.analysisExplanationButtonLabel": "分析説明", - "xpack.fileDataVisualizer.resultsView.fileStatsName": "ファイル統計", - "xpack.fileDataVisualizer.resultsView.overrideSettingsButtonLabel": "上書き設定", - "xpack.fileDataVisualizer.searchPanel.allFieldsLabel": "すべてのフィールド", - "xpack.fileDataVisualizer.searchPanel.numberFieldsLabel": "数値フィールド", - "xpack.fileDataVisualizer.searchPanel.ofFieldsTotal": "合計 {totalCount}", - "xpack.fileDataVisualizer.simpleImportSettings.createIndexPatternLabel": "インデックスパターンを作成", - "xpack.fileDataVisualizer.simpleImportSettings.indexNameAriaLabel": "インデックス名、必須フィールド", - "xpack.fileDataVisualizer.simpleImportSettings.indexNameFormRowLabel": "インデックス名", - "xpack.fileDataVisualizer.simpleImportSettings.indexNamePlaceholder": "インデックス名", - "xpack.fileDataVisualizer.welcomeContent.delimitedTextFilesDescription": "CSV や TSV などの区切られたテキストファイル", - "xpack.fileDataVisualizer.welcomeContent.experimentalFeatureDescription": "これは実験的な機能です。フィードバックがありますか?{githubLink}で問題を報告してください。", - "xpack.fileDataVisualizer.welcomeContent.experimentalFeatureTooltip": "実験的機能。フィードバックをお待ちしています。", - "xpack.fileDataVisualizer.welcomeContent.logFilesWithCommonFormatDescription": "タイムスタンプの一般的フォーマットのログファイル", - "xpack.fileDataVisualizer.welcomeContent.newlineDelimitedJsonDescription": "改行区切りの JSON", - "xpack.fileDataVisualizer.welcomeContent.supportedFileFormatDescription": "ファイルデータビジュアライザーはこれらのファイル形式をサポートしています:", - "xpack.fileDataVisualizer.welcomeContent.uploadedFilesAllowedSizeDescription": "最大{maxFileSize}のファイルをアップロードできます。", - "xpack.fileDataVisualizer.welcomeContent.visualizeDataFromLogFileDescription": "ファイルデータビジュアライザーは、ログファイルのフィールドとメトリックの理解に役立ちます。ファイルをアップロードして、データを分析し、 Elasticsearch インデックスにインポートするか選択できます。", - "xpack.fileDataVisualizer.welcomeContent.visualizeDataFromLogFileTitle": "ログファイルのデータを可視化 {experimentalBadge}", + "xpack.dataVisualizer.file.aboutPanel.analyzingDataTitle": "データを分析中", + "xpack.dataVisualizer.file.aboutPanel.selectOrDragAndDropFileDescription": "ファイルを選択するかドラッグ &amp; ドロップしてください", + "xpack.dataVisualizer.addCombinedFieldsLabel": "結合されたフィールドを追加", + "xpack.dataVisualizer.file.advancedImportSettings.createIndexPatternLabel": "インデックスパターンを作成", + "xpack.dataVisualizer.file.advancedImportSettings.indexNameAriaLabel": "インデックス名、必須フィールド", + "xpack.dataVisualizer.file.advancedImportSettings.indexNameLabel": "インデックス名", + "xpack.dataVisualizer.file.advancedImportSettings.indexNamePlaceholder": "インデックス名", + "xpack.dataVisualizer.file.advancedImportSettings.indexPatternNameLabel": "インデックスパターン名", + "xpack.dataVisualizer.file.advancedImportSettings.indexSettingsLabel": "インデックス設定", + "xpack.dataVisualizer.file.advancedImportSettings.ingestPipelineLabel": "パイプラインを投入", + "xpack.dataVisualizer.file.advancedImportSettings.mappingsLabel": "マッピング", + "xpack.dataVisualizer.file.analysisSummary.analyzedLinesNumberTitle": "分析した行数", + "xpack.dataVisualizer.file.analysisSummary.delimiterTitle": "区切り記号", + "xpack.dataVisualizer.file.analysisSummary.formatTitle": "フォーマット", + "xpack.dataVisualizer.file.analysisSummary.grokPatternTitle": "Grok パターン", + "xpack.dataVisualizer.file.analysisSummary.hasHeaderRowTitle": "ヘッダー行があります", + "xpack.dataVisualizer.file.analysisSummary.summaryTitle": "まとめ", + "xpack.dataVisualizer.file.analysisSummary.timeFieldTitle": "時間フィールド", + "xpack.dataVisualizer.file.bottomBar.backButtonLabel": "戻る", + "xpack.dataVisualizer.file.bottomBar.cancelButtonLabel": "キャンセル", + "xpack.dataVisualizer.file.bottomBar.missingImportPrivilegesMessage": "データインポートを有効にするには、ingest_adminロールが必要です", + "xpack.dataVisualizer.file.bottomBar.readMode.cancelButtonLabel": "キャンセル", + "xpack.dataVisualizer.file.bottomBar.readMode.importButtonLabel": "インポート", + "xpack.dataVisualizer.combinedFieldsForm.mappingsParseError": "マッピングのパース中にエラーが発生しました:{error}", + "xpack.dataVisualizer.combinedFieldsForm.pipelineParseError": "パイプラインのパース中にエラーが発生しました:{error}", + "xpack.dataVisualizer.combinedFieldsLabel": "結合されたフィールド", + "xpack.dataVisualizer.combinedFieldsReadOnlyHelpTextLabel": "詳細タグで結合されたフィールドを編集", + "xpack.dataVisualizer.combinedFieldsReadOnlyLabel": "結合されたフィールド", + "xpack.dataVisualizer.components.colorRangeLegend.blueColorRangeLabel": "青", + "xpack.dataVisualizer.components.colorRangeLegend.greenRedColorRangeLabel": "緑 - 赤", + "xpack.dataVisualizer.components.colorRangeLegend.influencerScaleLabel": "影響因子カスタムスケール", + "xpack.dataVisualizer.components.colorRangeLegend.linearScaleLabel": "線形", + "xpack.dataVisualizer.components.colorRangeLegend.redColorRangeLabel": "赤", + "xpack.dataVisualizer.components.colorRangeLegend.redGreenColorRangeLabel": "赤 - 緑", + "xpack.dataVisualizer.components.colorRangeLegend.sqrtScaleLabel": "Sqrt", + "xpack.dataVisualizer.components.colorRangeLegend.yellowGreenBlueColorRangeLabel": "黄 - 緑 - 青", + "xpack.dataVisualizer.dataGridChart.histogramNotAvailable": "グラフはサポートされていません。", + "xpack.dataVisualizer.dataGridChart.notEnoughData": "0個のドキュメントにフィールドが含まれます。", + "xpack.dataVisualizer.dataGridChart.topCategoriesLegend": "上位 {maxChartColumns}/{cardinality} カテゴリ", + "xpack.dataVisualizer.dataGrid.collapseDetailsForAllAriaLabel": "すべてのフィールドの詳細を折りたたむ", + "xpack.dataVisualizer.dataGrid.distinctValuesColumnName": "固有の値", + "xpack.dataVisualizer.dataGrid.distributionsColumnName": "分布", + "xpack.dataVisualizer.dataGrid.documentsCountColumnName": "ドキュメント (%) ", + "xpack.dataVisualizer.dataGrid.expandDetailsForAllAriaLabel": "すべてのフィールドの詳細を展開", + "xpack.dataVisualizer.dataGrid.nameColumnName": "名前", + "xpack.dataVisualizer.dataGrid.rowCollapse": "{fieldName} の詳細を非表示", + "xpack.dataVisualizer.dataGrid.rowExpand": "{fieldName} の詳細を表示", + "xpack.dataVisualizer.dataGrid.showDistributionsAriaLabel": "分布を表示", + "xpack.dataVisualizer.dataGrid.typeColumnName": "型", + "xpack.dataVisualizer.file.editFlyout.applyOverrideSettingsButtonLabel": "適用", + "xpack.dataVisualizer.file.editFlyout.closeOverrideSettingsButtonLabel": "閉じる", + "xpack.dataVisualizer.file.editFlyout.overrides.customDelimiterFormRowLabel": "カスタム区切り記号", + "xpack.dataVisualizer.file.editFlyout.overrides.customTimestampFormatErrorMessage": "タイムスタンプのフォーマットは、これらの Java 日付/時刻フォーマットの組み合わせでなければなりません:\n yy, yyyy, M, MM, MMM, MMMM, d, dd, EEE, EEEE, H, HH, h, mm, ss, S-SSSSSSSSS, a, XX, XXX, zzz", + "xpack.dataVisualizer.file.editFlyout.overrides.customTimestampFormatFormRowLabel": "カスタムタイムスタンプフォーマット", + "xpack.dataVisualizer.file.editFlyout.overrides.dataFormatFormRowLabel": "データフォーマット", + "xpack.dataVisualizer.file.editFlyout.overrides.delimiterFormRowLabel": "区切り記号", + "xpack.dataVisualizer.file.editFlyout.overrides.editFieldNamesTitle": "フィールド名の編集", + "xpack.dataVisualizer.file.editFlyout.overrides.grokPatternFormRowLabel": "Grok パターン", + "xpack.dataVisualizer.file.editFlyout.overrides.hasHeaderRowLabel": "ヘッダー行があります", + "xpack.dataVisualizer.file.editFlyout.overrides.linesToSampleErrorMessage": "値は {min} よりも大きく {max} 以下でなければなりません", + "xpack.dataVisualizer.file.editFlyout.overrides.linesToSampleFormRowLabel": "サンプルする行数", + "xpack.dataVisualizer.file.editFlyout.overrides.quoteCharacterFormRowLabel": "引用符", + "xpack.dataVisualizer.file.editFlyout.overrides.timeFieldFormRowLabel": "時間フィールド", + "xpack.dataVisualizer.file.editFlyout.overrides.timestampEmptyValidationErrorMessage": "タイムスタンプフォーマットにタイムフォーマット文字グループがありません {timestampFormat}", + "xpack.dataVisualizer.file.editFlyout.overrides.timestampFormatFormRowLabel": "タイムスタンプフォーマット", + "xpack.dataVisualizer.file.editFlyout.overrides.timestampFormatHelpText": "対応フォーマットの詳細をご覧ください", + "xpack.dataVisualizer.file.editFlyout.overrides.timestampLetterSValidationErrorMessage": "{format} の文字 { length, plural, one { {lg} } other { グループ {lg} } } は、ss と {sep} からの区切りで始まっていないため、サポートされていません", + "xpack.dataVisualizer.file.editFlyout.overrides.timestampLetterValidationErrorMessage": "{format} の文字 { length, plural, one { {lg} } other { グループ {lg} } } はサポートされていません", + "xpack.dataVisualizer.file.editFlyout.overrides.timestampQuestionMarkValidationErrorMessage": "タイムスタンプフォーマット {timestampFormat} は、疑問符 ({fieldPlaceholder}) が含まれているためサポートされていません", + "xpack.dataVisualizer.file.editFlyout.overrides.trimFieldsLabel": "フィールドを切り抜く", + "xpack.dataVisualizer.file.editFlyout.overrideSettingsTitle": "上書き設定", + "xpack.dataVisualizer.experimentalBadge.experimentalLabel": "実験的", + "xpack.dataVisualizer.file.explanationFlyout.closeButton": "閉じる", + "xpack.dataVisualizer.file.explanationFlyout.content": "分析結果を生成した論理ステップ。", + "xpack.dataVisualizer.file.explanationFlyout.title": "分析説明", + "xpack.dataVisualizer.dataGrid.field.cardBoolean.valuesLabel": "値", + "xpack.dataVisualizer.dataGrid.field.cardDate.earliestLabel": "最も古い", + "xpack.dataVisualizer.dataGrid.field.cardDate.latestLabel": "最新", + "xpack.dataVisualizer.dataGrid.field.cardDate.summaryTableTitle": "まとめ", + "xpack.dataVisualizer.dataGrid.fieldText.fieldMayBePopulatedDescription": "たとえば、ドキュメントマッピングで {copyToParam} パラメーターを使ったり、{includesParam} と {excludesParam} パラメーターを使用してインデックスした後に {sourceParam} フィールドから切り取ったりして入力される場合があります。", + "xpack.dataVisualizer.dataGrid.fieldText.fieldNotPresentDescription": "このフィールドはクエリが実行されたドキュメントの {sourceParam} フィールドにありませんでした。", + "xpack.dataVisualizer.dataGrid.fieldText.noExamplesForFieldsTitle": "このフィールドの例が取得されませんでした", + "xpack.dataVisualizer.dataGrid.field.examplesList.noExamplesMessage": "このフィールドの例が取得されませんでした", + "xpack.dataVisualizer.dataGrid.field.examplesList.title": "{numExamples, plural, one {値} other {例}}", + "xpack.dataVisualizer.dataGrid.field.metricDistributionChart.seriesName": "分布", + "xpack.dataVisualizer.dataGrid.field.metricDistributionChart.tooltipValueBetweenLabel": "{percent}% のドキュメントに {minValFormatted} から {maxValFormatted} の間の値があります", + "xpack.dataVisualizer.dataGrid.field.metricDistributionChart.tooltipValueEqualLabel": "{percent}% のドキュメントに {valFormatted} の値があります", + "xpack.dataVisualizer.dataGrid.field.topValues.calculatedFromSampleDescription": "1 つのシャードにつき {topValuesSamplerShardSize} のドキュメントのサンプルで計算されています", + "xpack.dataVisualizer.dataGrid.field.topValuesLabel": "トップの値", + "xpack.dataVisualizer.dataGrid.fieldExpandedRow.booleanContent.falseCountLabel": "False", + "xpack.dataVisualizer.dataGrid.fieldExpandedRow.booleanContent.summaryTableTitle": "まとめ", + "xpack.dataVisualizer.dataGrid.fieldExpandedRow.booleanContent.trueCountLabel": "True", + "xpack.dataVisualizer.dataGrid.fieldExpandedRow.documentStatsTable.countLabel": "カウント", + "xpack.dataVisualizer.dataGrid.fieldExpandedRow.documentStatsTable.distinctValueLabel": "固有の値", + "xpack.dataVisualizer.dataGrid.fieldExpandedRow.documentStatsTable.metaTableTitle": "ドキュメント統計情報", + "xpack.dataVisualizer.dataGrid.fieldExpandedRow.documentStatsTable.percentageLabel": "割合", + "xpack.dataVisualizer.dataGrid.fieldExpandedRow.numberContent.displayingPercentilesLabel": "{minPercent} - {maxPercent} パーセンタイルを表示中", + "xpack.dataVisualizer.dataGrid.fieldExpandedRow.numberContent.distributionTitle": "分布", + "xpack.dataVisualizer.dataGrid.fieldExpandedRow.numberContent.maxLabel": "最高", + "xpack.dataVisualizer.dataGrid.fieldExpandedRow.numberContent.medianLabel": "中間", + "xpack.dataVisualizer.dataGrid.fieldExpandedRow.numberContent.minLabel": "分", + "xpack.dataVisualizer.dataGrid.fieldExpandedRow.numberContent.summaryTableTitle": "まとめ", + "xpack.dataVisualizer.fieldNameSelect": "フィールド名", + "xpack.dataVisualizer.fieldStats.maxTitle": "最高", + "xpack.dataVisualizer.fieldStats.medianTitle": "中間", + "xpack.dataVisualizer.fieldStats.minTitle": "分", + "xpack.dataVisualizer.fieldTypeIcon.booleanTypeAriaLabel": "ブールタイプ", + "xpack.dataVisualizer.fieldTypeIcon.dateTypeAriaLabel": "日付タイプ", + "xpack.dataVisualizer.fieldTypeIcon.fieldTypeTooltip": "{type} タイプ", + "xpack.dataVisualizer.fieldTypeIcon.geoPointTypeAriaLabel": "{geoPointParam} タイプ", + "xpack.dataVisualizer.fieldTypeIcon.ipTypeAriaLabel": "IP タイプ", + "xpack.dataVisualizer.fieldTypeIcon.keywordTypeAriaLabel": "キーワードタイプ", + "xpack.dataVisualizer.fieldTypeIcon.numberTypeAriaLabel": "数字タイプ", + "xpack.dataVisualizer.fieldTypeIcon.textTypeAriaLabel": "テキストタイプ", + "xpack.dataVisualizer.fieldTypeIcon.unknownTypeAriaLabel": "不明なタイプ", + "xpack.dataVisualizer.fieldTypeSelect": "フィールド型", + "xpack.dataVisualizer.fileBeatConfig.paths": "ファイルのパスをここに追加してください", + "xpack.dataVisualizer.fileBeatConfigFlyout.closeButton": "閉じる", + "xpack.dataVisualizer.fileBeatConfigFlyout.copyButton": "クリップボードにコピー", + "xpack.dataVisualizer.file.fileContents.fileContentsTitle": "ファイルコンテンツ", + "xpack.dataVisualizer.file.xmlNotCurrentlySupportedErrorMessage": "XML は現在サポートされていません", + "xpack.dataVisualizer.file.fileErrorCallouts.applyOverridesDescription": "ファイル形式やタイムスタンプ形式などこのデータに関する何らかの情報がある場合は、初期オーバーライドを追加すると、残りの構造を推論するのに役立つことがあります。", + "xpack.dataVisualizer.file.fileErrorCallouts.fileCouldNotBeReadTitle": "ファイル構造を決定できません", + "xpack.dataVisualizer.file.fileErrorCallouts.fileSizeExceedsAllowedSizeByDiffFormatErrorMessage": "アップロードするよう選択されたファイルのサイズが {diffFormatted} に許可された最大サイズの {maxFileSizeFormatted} を超えています", + "xpack.dataVisualizer.file.fileErrorCallouts.fileSizeExceedsAllowedSizeErrorMessage": "アップロードするよう選択されたファイルのサイズは {fileSizeFormatted} で、許可された最大サイズの {maxFileSizeFormatted} を超えています。", + "xpack.dataVisualizer.file.fileErrorCallouts.fileSizeTooLargeTitle": "ファイルサイズが大きすぎます。", + "xpack.dataVisualizer.file.fileErrorCallouts.overrideButton": "上書き設定を適用", + "xpack.dataVisualizer.file.fileErrorCallouts.revertingToPreviousSettingsDescription": "以前の設定に戻しています。", + "xpack.dataVisualizer.file.geoPointForm.combinedFieldLabel": "地理ポイントフィールドを追加", + "xpack.dataVisualizer.file.geoPointForm.geoPointFieldAriaLabel": "地理ポイントフィールド、必須フィールド", + "xpack.dataVisualizer.file.geoPointForm.geoPointFieldLabel": "地理ポイントフィールド", + "xpack.dataVisualizer.file.geoPointForm.latFieldLabel": "緯度フィールド", + "xpack.dataVisualizer.file.geoPointForm.lonFieldLabel": "経度フィールド", + "xpack.dataVisualizer.file.geoPointForm.submitButtonLabel": "追加", + "xpack.dataVisualizer.file.importErrors.checkingPermissionErrorMessage": "パーミッションエラーをインポートします", + "xpack.dataVisualizer.file.importErrors.creatingIndexErrorMessage": "インデックスの作成中にエラーが発生しました", + "xpack.dataVisualizer.file.importErrors.creatingIndexPatternErrorMessage": "インデックスパターンの作成中にエラーが発生しました", + "xpack.dataVisualizer.file.importErrors.creatingIngestPipelineErrorMessage": "投入パイプラインの作成中にエラーが発生しました", + "xpack.dataVisualizer.file.importErrors.defaultErrorMessage": "エラー", + "xpack.dataVisualizer.file.importErrors.moreButtonLabel": "詳細", + "xpack.dataVisualizer.file.importErrors.parsingJSONErrorMessage": "JSON のパース中にエラーが発生しました", + "xpack.dataVisualizer.file.importErrors.readingFileErrorMessage": "ファイルの読み込み中にエラーが発生しました", + "xpack.dataVisualizer.file.importErrors.unknownErrorMessage": "不明なエラー", + "xpack.dataVisualizer.file.importErrors.uploadingDataErrorMessage": "データのアップロード中にエラーが発生しました", + "xpack.dataVisualizer.file.importProgress.createIndexPatternTitle": "インデックスパターンを作成", + "xpack.dataVisualizer.file.importProgress.createIndexTitle": "インデックスの作成", + "xpack.dataVisualizer.file.importProgress.createIngestPipelineTitle": "投入パイプラインの作成", + "xpack.dataVisualizer.file.importProgress.creatingIndexPatternDescription": "インデックスパターンを作成中です", + "xpack.dataVisualizer.file.importProgress.creatingIndexPatternTitle": "インデックスパターンを作成中です", + "xpack.dataVisualizer.file.importProgress.creatingIndexTitle": "インデックスを作成中です", + "xpack.dataVisualizer.file.importProgress.creatingIngestPipelineTitle": "投入パイプラインを作成中", + "xpack.dataVisualizer.file.importProgress.dataUploadedTitle": "データがアップロードされました", + "xpack.dataVisualizer.file.importProgress.fileProcessedTitle": "ファイルが処理されました", + "xpack.dataVisualizer.file.importProgress.indexCreatedTitle": "インデックスが作成されました", + "xpack.dataVisualizer.file.importProgress.indexPatternCreatedTitle": "インデックスパターンが作成されました", + "xpack.dataVisualizer.file.importProgress.ingestPipelineCreatedTitle": "投入パイプラインが作成されました", + "xpack.dataVisualizer.file.importProgress.processFileTitle": "ファイルの処理", + "xpack.dataVisualizer.file.importProgress.processingFileTitle": "ファイルを処理中", + "xpack.dataVisualizer.file.importProgress.processingImportedFileDescription": "インポートするファイルを処理中", + "xpack.dataVisualizer.file.importProgress.stepTwoCreatingIndexDescription": "インデックスを作成中です", + "xpack.dataVisualizer.file.importProgress.stepTwoCreatingIndexIngestPipelineDescription": "インデックスと投入パイプラインを作成中です", + "xpack.dataVisualizer.file.importProgress.uploadDataTitle": "データのアップロード", + "xpack.dataVisualizer.file.importProgress.uploadingDataDescription": "データをアップロード中です", + "xpack.dataVisualizer.file.importProgress.uploadingDataTitle": "データをアップロード中です", + "xpack.dataVisualizer.file.importSettings.advancedTabName": "高度な設定", + "xpack.dataVisualizer.file.importSettings.simpleTabName": "シンプル", + "xpack.dataVisualizer.file.importSummary.documentsCouldNotBeImportedDescription": "{importFailuresLength}/{docCount} 個のドキュメントをインポートできませんでした。行が Grok パターンと一致していないことが原因の可能性があります。", + "xpack.dataVisualizer.file.importSummary.documentsCouldNotBeImportedTitle": "ドキュメントの一部をインポートできませんでした。", + "xpack.dataVisualizer.file.importSummary.documentsIngestedTitle": "ドキュメントが投入されました", + "xpack.dataVisualizer.file.importSummary.failedDocumentsButtonLabel": "失敗したドキュメント", + "xpack.dataVisualizer.file.importSummary.failedDocumentsTitle": "失敗したドキュメント", + "xpack.dataVisualizer.file.importSummary.importCompleteTitle": "インポート完了", + "xpack.dataVisualizer.file.importSummary.indexPatternTitle": "インデックスパターン", + "xpack.dataVisualizer.file.importSummary.indexTitle": "インデックス", + "xpack.dataVisualizer.file.importSummary.ingestPipelineTitle": "パイプラインを投入", + "xpack.dataVisualizer.file.importView.experimentalFeatureTooltip": "実験的機能。フィードバックをお待ちしています。", + "xpack.dataVisualizer.file.importView.importButtonLabel": "インポート", + "xpack.dataVisualizer.file.importView.importDataTitle": "データのインポート", + "xpack.dataVisualizer.file.importView.importPermissionError": "インデックス {index} にデータを作成またはインポートするパーミッションがありません。", + "xpack.dataVisualizer.file.importView.indexNameAlreadyExistsErrorMessage": "インデックス名がすでに存在します", + "xpack.dataVisualizer.file.importView.indexNameContainsIllegalCharactersErrorMessage": "インデックス名に許可されていない文字が含まれています。", + "xpack.dataVisualizer.file.importView.indexPatternDoesNotMatchIndexNameErrorMessage": "インデックスパターンがインデックス名と一致しません", + "xpack.dataVisualizer.file.importView.indexPatternNameAlreadyExistsErrorMessage": "インデックスパターン名がすでに存在します", + "xpack.dataVisualizer.file.importView.parseMappingsError": "マッピングのパース中にエラーが発生しました:", + "xpack.dataVisualizer.file.importView.parsePipelineError": "投入パイプラインのパース中にエラーが発生しました:", + "xpack.dataVisualizer.file.importView.parseSettingsError": "設定のパース中にエラーが発生しました:", + "xpack.dataVisualizer.file.importView.resetButtonLabel": "リセット", + "xpack.dataVisualizer.multiSelectPicker.NoFiltersFoundMessage": "フィルターが見つかりません", + "xpack.dataVisualizer.nameCollisionMsg": "「{name}」はすでに存在します。一意の名前を入力してください。", + "xpack.dataVisualizer.removeCombinedFieldsLabel": "結合されたフィールドを削除", + "xpack.dataVisualizer.file.resultsLinks.fileBeatConfig": "Filebeat 構成を作成", + "xpack.dataVisualizer.file.resultsLinks.fileBeatConfigBottomText": "{password} が {user} ユーザーのパスワードである場合、{esUrl} は Elasticsearch の URL です。", + "xpack.dataVisualizer.file.resultsLinks.fileBeatConfigBottomTextNoUsername": "{esUrl} が Elasticsearch の URL である場合", + "xpack.dataVisualizer.file.resultsLinks.fileBeatConfigTitle": "Filebeat 構成", + "xpack.dataVisualizer.file.resultsLinks.fileBeatConfigTopText1": "Filebeat を使用して {index} インデックスに追加データをアップロードできます。", + "xpack.dataVisualizer.file.resultsLinks.fileBeatConfigTopText2": "{filebeatYml} を修正して接続情報を設定します。", + "xpack.dataVisualizer.file.resultsLinks.indexManagementTitle": "インデックス管理", + "xpack.dataVisualizer.file.resultsLinks.indexPatternManagementTitle": "インデックスパターン管理", + "xpack.dataVisualizer.file.resultsLinks.viewIndexInDiscoverTitle": "インデックスを Discover で表示", + "xpack.dataVisualizer.file.resultsView.analysisExplanationButtonLabel": "分析説明", + "xpack.dataVisualizer.file.resultsView.fileStatsName": "ファイル統計", + "xpack.dataVisualizer.file.resultsView.overrideSettingsButtonLabel": "上書き設定", + "xpack.dataVisualizer.searchPanel.allFieldsLabel": "すべてのフィールド", + "xpack.dataVisualizer.searchPanel.numberFieldsLabel": "数値フィールド", + "xpack.dataVisualizer.searchPanel.ofFieldsTotal": "合計 {totalCount}", + "xpack.dataVisualizer.file.simpleImportSettings.createIndexPatternLabel": "インデックスパターンを作成", + "xpack.dataVisualizer.file.simpleImportSettings.indexNameAriaLabel": "インデックス名、必須フィールド", + "xpack.dataVisualizer.file.simpleImportSettings.indexNameFormRowLabel": "インデックス名", + "xpack.dataVisualizer.file.simpleImportSettings.indexNamePlaceholder": "インデックス名", + "xpack.dataVisualizer.file.welcomeContent.delimitedTextFilesDescription": "CSV や TSV などの区切られたテキストファイル", + "xpack.dataVisualizer.file.welcomeContent.experimentalFeatureDescription": "これは実験的な機能です。フィードバックがありますか?{githubLink}で問題を報告してください。", + "xpack.dataVisualizer.file.welcomeContent.experimentalFeatureTooltip": "実験的機能。フィードバックをお待ちしています。", + "xpack.dataVisualizer.file.welcomeContent.logFilesWithCommonFormatDescription": "タイムスタンプの一般的フォーマットのログファイル", + "xpack.dataVisualizer.file.welcomeContent.newlineDelimitedJsonDescription": "改行区切りの JSON", + "xpack.dataVisualizer.file.welcomeContent.supportedFileFormatDescription": "ファイルデータビジュアライザーはこれらのファイル形式をサポートしています:", + "xpack.dataVisualizer.file.welcomeContent.uploadedFilesAllowedSizeDescription": "最大{maxFileSize}のファイルをアップロードできます。", + "xpack.dataVisualizer.file.welcomeContent.visualizeDataFromLogFileDescription": "ファイルデータビジュアライザーは、ログファイルのフィールドとメトリックの理解に役立ちます。ファイルをアップロードして、データを分析し、 Elasticsearch インデックスにインポートするか選択できます。", + "xpack.dataVisualizer.file.welcomeContent.visualizeDataFromLogFileTitle": "ログファイルのデータを可視化 {experimentalBadge}", + "xpack.dataVisualizer.index.actionsPanel.discoverAppTitle": "Discover", + "xpack.dataVisualizer.index.actionsPanel.exploreTitle": "データの調査", + "xpack.dataVisualizer.index.actionsPanel.viewIndexInDiscoverDescription": "インデックスのドキュメントを調査します。", + "xpack.dataVisualizer.index.fieldNameSelect": "フィールド名", + "xpack.dataVisualizer.index.fieldTypeSelect": "フィールド型", + "xpack.dataVisualizer.index.dataGrid.actionsColumnLabel": "アクション", + "xpack.dataVisualizer.index.dataGrid.exploreInLensDescription": "Lensで検索", + "xpack.dataVisualizer.index.dataGrid.exploreInLensTitle": "Lensで検索", + "xpack.dataVisualizer.index.lensChart.averageOfLabel": "{fieldName}の平均", + "xpack.dataVisualizer.index.lensChart.chartTitle": "{fieldName}のLens", + "xpack.dataVisualizer.index.lensChart.countLabel": "カウント", + "xpack.dataVisualizer.index.lensChart.topValuesLabel": "トップの値", + "xpack.dataVisualizer.searchPanel.allOptionLabel": "すべて検索", + "xpack.dataVisualizer.searchPanel.invalidKuerySyntaxErrorMessageQueryBar": "無効なクエリ", + "xpack.dataVisualizer.searchPanel.queryBarPlaceholder": "小さいサンプルサイズを選択することで、クエリの実行時間を短縮しクラスターへの負荷を軽減できます。", + "xpack.dataVisualizer.searchPanel.sampleSizeAriaLabel": "サンプリングするドキュメント数を選択してください", + "xpack.dataVisualizer.searchPanel.sampleSizeOptionLabel": "サンプルサイズ (シャード単位) :{wrappedValue}", + "xpack.dataVisualizer.searchPanel.showEmptyFields": "空のフィールドを表示", + "xpack.dataVisualizer.searchPanel.totalDocCountLabel": "合計ドキュメント数:{strongTotalCount}", + "xpack.dataVisualizer.dataGrid.field.documentCountChart.seriesLabel": "ドキュメントカウント", + "xpack.dataVisualizer.dataGrid.field.fieldNotInDocsLabel": "このフィールドは選択された時間範囲のドキュメントにありません", + "xpack.dataVisualizer.dataGrid.field.loadingLabel": "読み込み中", + "xpack.dataVisualizer.index.dataLoader.internalServerErrorMessage": "インデックス {index} のデータの読み込み中にエラーが発生。{message}。リクエストがタイムアウトした可能性があります。小さなサンプルサイズを使うか、時間範囲を狭めてみてください。", "xpack.fileUpload.fileSizeError": "ファイルサイズ{fileSize}は最大ファイルサイズの{maxFileSize}を超えています", "xpack.fileUpload.fileTypeError": "ファイルは使用可能なタイプのいずれかではありません。{types}", "xpack.fileUpload.geojsonFilePicker.acceptedCoordinateSystem": "座標は EPSG:4326 座標参照系でなければなりません。", @@ -14512,46 +14535,7 @@ "xpack.ml.dataGridChart.histogramNotAvailable": "グラフはサポートされていません。", "xpack.ml.dataGridChart.notEnoughData": "0個のドキュメントにフィールドが含まれます。", "xpack.ml.dataGridChart.topCategoriesLegend": "上位 {maxChartColumns}/{cardinality} カテゴリ", - "xpack.ml.datavisualizer.actionsPanel.advancedDescription": "より高度なユースケースでは、すべてのオプションを使用してジョブを作成します。", - "xpack.ml.datavisualizer.actionsPanel.advancedTitle": "高度な異常検知", - "xpack.ml.datavisualizer.actionsPanel.createJobTitle": "ジョブを作成", - "xpack.ml.datavisualizer.actionsPanel.dataframeAnalyticsTitle": "データフレーム分析", - "xpack.ml.datavisualizer.actionsPanel.dataframeTypesDescription": "異常値検出、回帰分析、分類分析を作成します。", - "xpack.ml.datavisualizer.actionsPanel.discoverAppTitle": "Discover", - "xpack.ml.datavisualizer.actionsPanel.exploreTitle": "データの調査", - "xpack.ml.datavisualizer.actionsPanel.viewIndexInDiscoverDescription": "インデックスのドキュメントを調査します。", - "xpack.ml.datavisualizer.dataGrid.collapseDetailsForAllAriaLabel": "すべてのフィールドの詳細を折りたたむ", - "xpack.ml.datavisualizer.dataGrid.distinctValuesColumnName": "固有の値", - "xpack.ml.datavisualizer.dataGrid.distributionsColumnName": "分布", - "xpack.ml.datavisualizer.dataGrid.documentsCountColumnName": "ドキュメント (%) ", - "xpack.ml.datavisualizer.dataGrid.expandDetailsForAllAriaLabel": "すべてのフィールドの詳細を展開", - "xpack.ml.datavisualizer.dataGrid.nameColumnName": "名前", - "xpack.ml.datavisualizer.dataGrid.rowCollapse": "{fieldName} の詳細を非表示", - "xpack.ml.datavisualizer.dataGrid.rowExpand": "{fieldName} の詳細を表示", - "xpack.ml.datavisualizer.dataGrid.showDistributionsAriaLabel": "分布を表示", - "xpack.ml.datavisualizer.dataGrid.typeColumnName": "型", - "xpack.ml.datavisualizer.dataLoader.internalServerErrorMessage": "インデックス {index} のデータの読み込み中にエラーが発生。{message}。リクエストがタイムアウトした可能性があります。小さなサンプルサイズを使うか、時間範囲を狭めてみてください。", "xpack.ml.dataVisualizer.fileBasedLabel": "ファイル", - "xpack.ml.dataVisualizer.indexBased.fieldNameSelect": "フィールド名", - "xpack.ml.dataVisualizer.indexBased.fieldTypeSelect": "フィールド型", - "xpack.ml.dataVisualizer.indexBasedDataGrid.actionsColumnLabel": "アクション", - "xpack.ml.dataVisualizer.indexBasedDataGrid.exploreInLensDescription": "Lensで検索", - "xpack.ml.dataVisualizer.indexBasedDataGrid.exploreInLensTitle": "Lensで検索", - "xpack.ml.dataVisualizer.lensChart.averageOfLabel": "{fieldName}の平均", - "xpack.ml.dataVisualizer.lensChart.chartTitle": "{fieldName}のLens", - "xpack.ml.dataVisualizer.lensChart.countLabel": "カウント", - "xpack.ml.dataVisualizer.lensChart.topValuesLabel": "トップの値", - "xpack.ml.datavisualizer.page.errorLoadingDataMessage": "インデックス {index} のデータの読み込み中にエラーが発生。{message}。", - "xpack.ml.dataVisualizer.searchPanel.allFieldsLabel": "すべてのフィールド", - "xpack.ml.datavisualizer.searchPanel.allOptionLabel": "すべて検索", - "xpack.ml.datavisualizer.searchPanel.invalidKuerySyntaxErrorMessageQueryBar": "無効なクエリ", - "xpack.ml.dataVisualizer.searchPanel.numberFieldsLabel": "数値フィールド", - "xpack.ml.dataVisualizer.searchPanel.ofFieldsTotal": "合計 {totalCount}", - "xpack.ml.datavisualizer.searchPanel.queryBarPlaceholder": "小さいサンプルサイズを選択することで、クエリの実行時間を短縮しクラスターへの負荷を軽減できます。", - "xpack.ml.datavisualizer.searchPanel.sampleSizeAriaLabel": "サンプリングするドキュメント数を選択してください", - "xpack.ml.datavisualizer.searchPanel.sampleSizeOptionLabel": "サンプルサイズ (シャード単位) :{wrappedValue}", - "xpack.ml.dataVisualizer.searchPanel.showEmptyFields": "空のフィールドを表示", - "xpack.ml.datavisualizer.searchPanel.totalDocCountLabel": "合計ドキュメント数:{strongTotalCount}", "xpack.ml.datavisualizer.selector.dataVisualizerDescription": "機械学習データビジュアライザーツールは、ログファイルのメトリックとフィールド、または既存の Elasticsearch インデックスを分析し、データの理解を助けます。", "xpack.ml.datavisualizer.selector.dataVisualizerTitle": "データビジュアライザー", "xpack.ml.datavisualizer.selector.experimentalBadgeLabel": "実験的", @@ -14678,40 +14662,8 @@ "xpack.ml.explorerCharts.errorCallOutMessage": "{reason}ため、{jobs} の異常値グラフを表示できません。", "xpack.ml.feature.reserved.description": "ユーザーアクセスを許可するには、machine_learning_user か machine_learning_admin ロールのどちらかを割り当てる必要があります。", "xpack.ml.featureRegistry.mlFeatureName": "機械学習", - "xpack.ml.fieldDataCard.cardBoolean.valuesLabel": "値", - "xpack.ml.fieldDataCard.cardDate.earliestLabel": "最も古い", - "xpack.ml.fieldDataCard.cardDate.latestLabel": "最新", - "xpack.ml.fieldDataCard.cardDate.summaryTableTitle": "まとめ", - "xpack.ml.fieldDataCard.cardText.fieldMayBePopulatedDescription": "たとえば、ドキュメントマッピングで {copyToParam} パラメーターを使ったり、{includesParam} と {excludesParam} パラメーターを使用してインデックスした後に {sourceParam} フィールドから切り取ったりして入力される場合があります。", - "xpack.ml.fieldDataCard.cardText.fieldNotPresentDescription": "このフィールドはクエリが実行されたドキュメントの {sourceParam} フィールドにありませんでした。", - "xpack.ml.fieldDataCard.cardText.noExamplesForFieldsTitle": "このフィールドの例が取得されませんでした", - "xpack.ml.fieldDataCard.documentCountChart.seriesLabel": "ドキュメントカウント", - "xpack.ml.fieldDataCard.examplesList.noExamplesMessage": "このフィールドの例が取得されませんでした", - "xpack.ml.fieldDataCard.examplesList.title": "{numExamples, plural, one {値} other {例}}", - "xpack.ml.fieldDataCard.fieldNotInDocsLabel": "このフィールドは選択された時間範囲のドキュメントにありません", - "xpack.ml.fieldDataCard.loadingLabel": "読み込み中", - "xpack.ml.fieldDataCard.metricDistributionChart.seriesName": "分布", - "xpack.ml.fieldDataCard.metricDistributionChart.tooltipValueBetweenLabel": "{percent}% のドキュメントに {minValFormatted} から {maxValFormatted} の間の値があります", - "xpack.ml.fieldDataCard.metricDistributionChart.tooltipValueEqualLabel": "{percent}% のドキュメントに {valFormatted} の値があります", - "xpack.ml.fieldDataCard.topValues.calculatedFromSampleDescription": "1 つのシャードにつき {topValuesSamplerShardSize} のドキュメントのサンプルで計算されています", - "xpack.ml.fieldDataCard.topValuesLabel": "トップの値", - "xpack.ml.fieldDataCardExpandedRow.booleanContent.falseCountLabel": "False", - "xpack.ml.fieldDataCardExpandedRow.booleanContent.summaryTableTitle": "まとめ", - "xpack.ml.fieldDataCardExpandedRow.booleanContent.trueCountLabel": "True", - "xpack.ml.fieldDataCardExpandedRow.documentStatsTable.countLabel": "カウント", - "xpack.ml.fieldDataCardExpandedRow.documentStatsTable.distinctValueLabel": "固有の値", - "xpack.ml.fieldDataCardExpandedRow.documentStatsTable.metaTableTitle": "ドキュメント統計情報", - "xpack.ml.fieldDataCardExpandedRow.documentStatsTable.percentageLabel": "割合", - "xpack.ml.fieldDataCardExpandedRow.numberContent.displayingPercentilesLabel": "{minPercent} - {maxPercent} パーセンタイルを表示中", - "xpack.ml.fieldDataCardExpandedRow.numberContent.distributionTitle": "分布", - "xpack.ml.fieldDataCardExpandedRow.numberContent.maxLabel": "最高", - "xpack.ml.fieldDataCardExpandedRow.numberContent.medianLabel": "中間", - "xpack.ml.fieldDataCardExpandedRow.numberContent.minLabel": "分", - "xpack.ml.fieldDataCardExpandedRow.numberContent.summaryTableTitle": "まとめ", - "xpack.ml.fieldTitleBar.documentCountLabel": "ドキュメントカウント", "xpack.ml.fieldTypeIcon.booleanTypeAriaLabel": "ブールタイプ", "xpack.ml.fieldTypeIcon.dateTypeAriaLabel": "日付タイプ", - "xpack.ml.fieldTypeIcon.fieldTypeTooltip": "{type} タイプ", "xpack.ml.fieldTypeIcon.geoPointTypeAriaLabel": "{geoPointParam} タイプ", "xpack.ml.fieldTypeIcon.ipTypeAriaLabel": "IP タイプ", "xpack.ml.fieldTypeIcon.keywordTypeAriaLabel": "キーワードタイプ", diff --git a/x-pack/plugins/translations/translations/zh-CN.json b/x-pack/plugins/translations/translations/zh-CN.json index bbc5554bbb6a2..c3c0402ef27ab 100644 --- a/x-pack/plugins/translations/translations/zh-CN.json +++ b/x-pack/plugins/translations/translations/zh-CN.json @@ -8580,227 +8580,252 @@ "xpack.features.ossFeatures.visualizeShortUrlSubFeatureName": "短 URL", "xpack.features.savedObjectsManagementFeatureName": "已保存对象管理", "xpack.features.visualizeFeatureName": "Visualize 库", - "xpack.fileDataVisualizer.aboutPanel.analyzingDataTitle": "正在分析数据", - "xpack.fileDataVisualizer.aboutPanel.selectOrDragAndDropFileDescription": "选择或拖放文件", - "xpack.fileDataVisualizer.addCombinedFieldsLabel": "添加组合字段", - "xpack.fileDataVisualizer.advancedImportSettings.createIndexPatternLabel": "创建索引模式", - "xpack.fileDataVisualizer.advancedImportSettings.indexNameAriaLabel": "索引名称,必填字段", - "xpack.fileDataVisualizer.advancedImportSettings.indexNameLabel": "索引名称", - "xpack.fileDataVisualizer.advancedImportSettings.indexNamePlaceholder": "索引名称", - "xpack.fileDataVisualizer.advancedImportSettings.indexPatternNameLabel": "索引模式名称", - "xpack.fileDataVisualizer.advancedImportSettings.indexSettingsLabel": "索引设置", - "xpack.fileDataVisualizer.advancedImportSettings.ingestPipelineLabel": "采集管道", - "xpack.fileDataVisualizer.advancedImportSettings.mappingsLabel": "映射", - "xpack.fileDataVisualizer.analysisSummary.analyzedLinesNumberTitle": "已分析的行数", - "xpack.fileDataVisualizer.analysisSummary.delimiterTitle": "分隔符", - "xpack.fileDataVisualizer.analysisSummary.formatTitle": "格式", - "xpack.fileDataVisualizer.analysisSummary.grokPatternTitle": "Grok 模式", - "xpack.fileDataVisualizer.analysisSummary.hasHeaderRowTitle": "包含标题行", - "xpack.fileDataVisualizer.analysisSummary.summaryTitle": "摘要", - "xpack.fileDataVisualizer.analysisSummary.timeFieldTitle": "时间字段", - "xpack.fileDataVisualizer.analysisSummary.timeFormatTitle": "时间{timestampFormats, plural, other {格式}}", - "xpack.fileDataVisualizer.bottomBar.backButtonLabel": "返回", - "xpack.fileDataVisualizer.bottomBar.cancelButtonLabel": "取消", - "xpack.fileDataVisualizer.bottomBar.missingImportPrivilegesMessage": "您需要具有 ingest_admin 角色才能启用数据导入", - "xpack.fileDataVisualizer.bottomBar.readMode.cancelButtonLabel": "取消", - "xpack.fileDataVisualizer.bottomBar.readMode.importButtonLabel": "导入", - "xpack.fileDataVisualizer.combinedFieldsForm.mappingsParseError": "解析映射时出错:{error}", - "xpack.fileDataVisualizer.combinedFieldsForm.pipelineParseError": "解析管道时出错:{error}", - "xpack.fileDataVisualizer.combinedFieldsLabel": "组合字段", - "xpack.fileDataVisualizer.combinedFieldsReadOnlyHelpTextLabel": "在高级选项卡中编辑组合字段", - "xpack.fileDataVisualizer.combinedFieldsReadOnlyLabel": "组合字段", - "xpack.fileDataVisualizer.components.colorRangeLegend.blueColorRangeLabel": "蓝", - "xpack.fileDataVisualizer.components.colorRangeLegend.greenRedColorRangeLabel": "绿 - 红", - "xpack.fileDataVisualizer.components.colorRangeLegend.influencerScaleLabel": "影响因素定制比例", - "xpack.fileDataVisualizer.components.colorRangeLegend.linearScaleLabel": "线性", - "xpack.fileDataVisualizer.components.colorRangeLegend.redColorRangeLabel": "红", - "xpack.fileDataVisualizer.components.colorRangeLegend.redGreenColorRangeLabel": "红 - 绿", - "xpack.fileDataVisualizer.components.colorRangeLegend.sqrtScaleLabel": "平方根", - "xpack.fileDataVisualizer.components.colorRangeLegend.yellowGreenBlueColorRangeLabel": "黄 - 绿 - 蓝", - "xpack.fileDataVisualizer.dataGridChart.histogramNotAvailable": "不支持图表。", - "xpack.fileDataVisualizer.dataGridChart.notEnoughData": "0 个文档包含字段。", - "xpack.fileDataVisualizer.dataGridChart.singleCategoryLegend": "{cardinality, plural, other {# 个类别}}", - "xpack.fileDataVisualizer.dataGridChart.topCategoriesLegend": "{cardinality} 个类别中的排名前 {maxChartColumns} 个", - "xpack.fileDataVisualizer.datavisualizer.dataGrid.collapseDetailsForAllAriaLabel": "收起所有字段的详细信息", - "xpack.fileDataVisualizer.datavisualizer.dataGrid.distinctValuesColumnName": "不同值", - "xpack.fileDataVisualizer.datavisualizer.dataGrid.distributionsColumnName": "分布", - "xpack.fileDataVisualizer.datavisualizer.dataGrid.documentsCountColumnName": "文档 (%)", - "xpack.fileDataVisualizer.datavisualizer.dataGrid.expandDetailsForAllAriaLabel": "展开所有字段的详细信息", - "xpack.fileDataVisualizer.datavisualizer.dataGrid.nameColumnName": "名称", - "xpack.fileDataVisualizer.datavisualizer.dataGrid.rowCollapse": "隐藏 {fieldName} 的详细信息", - "xpack.fileDataVisualizer.datavisualizer.dataGrid.rowExpand": "显示 {fieldName} 的详细信息", - "xpack.fileDataVisualizer.datavisualizer.dataGrid.showDistributionsAriaLabel": "显示分布", - "xpack.fileDataVisualizer.datavisualizer.dataGrid.typeColumnName": "类型", - "xpack.fileDataVisualizer.editFlyout.applyOverrideSettingsButtonLabel": "应用", - "xpack.fileDataVisualizer.editFlyout.closeOverrideSettingsButtonLabel": "关闭", - "xpack.fileDataVisualizer.editFlyout.overrides.customDelimiterFormRowLabel": "定制分隔符", - "xpack.fileDataVisualizer.editFlyout.overrides.customTimestampFormatErrorMessage": "时间戳格式必须为以下 Java 日期/时间格式的组合:\n yy、yyyy、M、MM、MMM、MMMM、d、dd、EEE、EEEE、H、HH、h、mm、ss、S 至 SSSSSSSSS、a、XX、XXX、zzz", - "xpack.fileDataVisualizer.editFlyout.overrides.customTimestampFormatFormRowLabel": "定制时间戳格式", - "xpack.fileDataVisualizer.editFlyout.overrides.dataFormatFormRowLabel": "数据格式", - "xpack.fileDataVisualizer.editFlyout.overrides.delimiterFormRowLabel": "分隔符", - "xpack.fileDataVisualizer.editFlyout.overrides.editFieldNamesTitle": "编辑字段名称", - "xpack.fileDataVisualizer.editFlyout.overrides.grokPatternFormRowLabel": "Grok 模式", - "xpack.fileDataVisualizer.editFlyout.overrides.hasHeaderRowLabel": "包含标题行", - "xpack.fileDataVisualizer.editFlyout.overrides.linesToSampleErrorMessage": "值必须大于 {min} 并小于或等于 {max}", - "xpack.fileDataVisualizer.editFlyout.overrides.linesToSampleFormRowLabel": "要采样的行数", - "xpack.fileDataVisualizer.editFlyout.overrides.quoteCharacterFormRowLabel": "引用字符", - "xpack.fileDataVisualizer.editFlyout.overrides.timeFieldFormRowLabel": "时间字段", - "xpack.fileDataVisualizer.editFlyout.overrides.timestampEmptyValidationErrorMessage": "时间戳格式 {timestampFormat} 中没有时间格式字母组", - "xpack.fileDataVisualizer.editFlyout.overrides.timestampFormatFormRowLabel": "时间戳格式", - "xpack.fileDataVisualizer.editFlyout.overrides.timestampFormatHelpText": "请参阅有关接受格式的更多内容。", - "xpack.fileDataVisualizer.editFlyout.overrides.timestampLetterSValidationErrorMessage": "{format}的字母 { length, plural, one { {lg} } other { 组 {lg} } } 不受支持,因为其未前置 ss 和 {sep} 中的分隔符", - "xpack.fileDataVisualizer.editFlyout.overrides.timestampLetterValidationErrorMessage": "{format}的字母 { length, plural, one { {lg} } other { 组 {lg} } } 不受支持", - "xpack.fileDataVisualizer.editFlyout.overrides.timestampQuestionMarkValidationErrorMessage": "时间戳格式 {timestampFormat} 不受支持,因为其包含问号字符 ({fieldPlaceholder})", - "xpack.fileDataVisualizer.editFlyout.overrides.trimFieldsLabel": "应剪裁字段", - "xpack.fileDataVisualizer.editFlyout.overrideSettingsTitle": "替代设置", - "xpack.fileDataVisualizer.experimentalBadge.experimentalLabel": "实验性", - "xpack.fileDataVisualizer.explanationFlyout.closeButton": "关闭", - "xpack.fileDataVisualizer.explanationFlyout.content": "产生分析结果的逻辑步骤。", - "xpack.fileDataVisualizer.explanationFlyout.title": "分析说明", - "xpack.fileDataVisualizer.fieldDataCard.cardBoolean.valuesLabel": "值", - "xpack.fileDataVisualizer.fieldDataCard.cardDate.earliestLabel": "最早", - "xpack.fileDataVisualizer.fieldDataCard.cardDate.latestLabel": "最新", - "xpack.fileDataVisualizer.fieldDataCard.cardDate.summaryTableTitle": "摘要", - "xpack.fileDataVisualizer.fieldDataCard.cardText.fieldMayBePopulatedDescription": "例如,可以使用文档映射中的 {copyToParam} 参数进行填充,也可以在索引后通过使用 {includesParam} 和 {excludesParam} 参数从 {sourceParam} 字段中修剪。", - "xpack.fileDataVisualizer.fieldDataCard.cardText.fieldNotPresentDescription": "查询的文档的 {sourceParam} 字段中不存在此字段。", - "xpack.fileDataVisualizer.fieldDataCard.cardText.noExamplesForFieldsTitle": "没有获取此字段的示例", - "xpack.fileDataVisualizer.fieldDataCard.examplesList.noExamplesMessage": "没有获取此字段的示例", - "xpack.fileDataVisualizer.fieldDataCard.examplesList.title": "{numExamples, plural, one {值} other {示例}}", - "xpack.fileDataVisualizer.fieldDataCard.metricDistributionChart.seriesName": "分布", - "xpack.fileDataVisualizer.fieldDataCard.metricDistributionChart.tooltipValueBetweenLabel": "{percent}% 的文档具有介于 {minValFormatted} 和 {maxValFormatted} 之间的值", - "xpack.fileDataVisualizer.fieldDataCard.metricDistributionChart.tooltipValueEqualLabel": "{percent}% 的文档的值为 {valFormatted}", - "xpack.fileDataVisualizer.fieldDataCard.topValues.calculatedFromSampleDescription": "基于每个分片的 {topValuesSamplerShardSize} 文档样例计算", - "xpack.fileDataVisualizer.fieldDataCard.topValuesLabel": "排名最前值", - "xpack.fileDataVisualizer.fieldDataCardExpandedRow.booleanContent.falseCountLabel": "false", - "xpack.fileDataVisualizer.fieldDataCardExpandedRow.booleanContent.summaryTableTitle": "摘要", - "xpack.fileDataVisualizer.fieldDataCardExpandedRow.booleanContent.trueCountLabel": "true", - "xpack.fileDataVisualizer.fieldDataCardExpandedRow.documentStatsTable.countLabel": "计数", - "xpack.fileDataVisualizer.fieldDataCardExpandedRow.documentStatsTable.distinctValueLabel": "不同值", - "xpack.fileDataVisualizer.fieldDataCardExpandedRow.documentStatsTable.metaTableTitle": "文档统计", - "xpack.fileDataVisualizer.fieldDataCardExpandedRow.documentStatsTable.percentageLabel": "百分比", - "xpack.fileDataVisualizer.fieldDataCardExpandedRow.numberContent.displayingPercentilesLabel": "正在显示 {minPercent} - {maxPercent} 百分位数", - "xpack.fileDataVisualizer.fieldDataCardExpandedRow.numberContent.distributionTitle": "分布", - "xpack.fileDataVisualizer.fieldDataCardExpandedRow.numberContent.maxLabel": "最大值", - "xpack.fileDataVisualizer.fieldDataCardExpandedRow.numberContent.medianLabel": "中值", - "xpack.fileDataVisualizer.fieldDataCardExpandedRow.numberContent.minLabel": "最小值", - "xpack.fileDataVisualizer.fieldDataCardExpandedRow.numberContent.summaryTableTitle": "摘要", - "xpack.fileDataVisualizer.fieldNameSelect": "字段名称", - "xpack.fileDataVisualizer.fieldStatsCard.maxTitle": "最大值", - "xpack.fileDataVisualizer.fieldStatsCard.medianTitle": "中值", - "xpack.fileDataVisualizer.fieldStatsCard.minTitle": "最小值", - "xpack.fileDataVisualizer.fieldTypeIcon.booleanTypeAriaLabel": "布尔类型", - "xpack.fileDataVisualizer.fieldTypeIcon.dateTypeAriaLabel": "日期类型", - "xpack.fileDataVisualizer.fieldTypeIcon.fieldTypeTooltip": "{type} 类型", - "xpack.fileDataVisualizer.fieldTypeIcon.geoPointTypeAriaLabel": "{geoPointParam} 类型", - "xpack.fileDataVisualizer.fieldTypeIcon.ipTypeAriaLabel": "IP 类型", - "xpack.fileDataVisualizer.fieldTypeIcon.keywordTypeAriaLabel": "关键字类型", - "xpack.fileDataVisualizer.fieldTypeIcon.numberTypeAriaLabel": "数字类型", - "xpack.fileDataVisualizer.fieldTypeIcon.textTypeAriaLabel": "文本类型", - "xpack.fileDataVisualizer.fieldTypeIcon.unknownTypeAriaLabel": "未知类型", - "xpack.fileDataVisualizer.fieldTypeSelect": "字段类型", - "xpack.fileDataVisualizer.fileBeatConfig.paths": "在此处将路径添加您的文件中", - "xpack.fileDataVisualizer.fileBeatConfigFlyout.closeButton": "关闭", - "xpack.fileDataVisualizer.fileBeatConfigFlyout.copyButton": "复制到剪贴板", - "xpack.fileDataVisualizer.fileContents.fileContentsTitle": "文件内容", - "xpack.fileDataVisualizer.fileContents.firstLinesDescription": "前 {numberOfLines, plural, other {# 行}}", - "xpack.fileDataVisualizer.fileDatavisualizerView.xmlNotCurrentlySupportedErrorMessage": "当前不支持 XML", - "xpack.fileDataVisualizer.fileErrorCallouts.applyOverridesDescription": "如果您对此数据有所了解,例如文件格式或时间戳格式,则添加初始覆盖可以帮助我们推理结构的其余部分。", - "xpack.fileDataVisualizer.fileErrorCallouts.fileCouldNotBeReadTitle": "无法确定文件结构", - "xpack.fileDataVisualizer.fileErrorCallouts.fileSizeExceedsAllowedSizeByDiffFormatErrorMessage": "您选择用于上传的文件大小超过上限值 {maxFileSizeFormatted} 的 {diffFormatted}", - "xpack.fileDataVisualizer.fileErrorCallouts.fileSizeExceedsAllowedSizeErrorMessage": "您选择用于上传的文件大小为 {fileSizeFormatted},超过上限值 {maxFileSizeFormatted}", - "xpack.fileDataVisualizer.fileErrorCallouts.fileSizeTooLargeTitle": "文件太大", - "xpack.fileDataVisualizer.fileErrorCallouts.overrideButton": "应用覆盖设置", - "xpack.fileDataVisualizer.fileErrorCallouts.revertingToPreviousSettingsDescription": "恢复到以前的设置", - "xpack.fileDataVisualizer.geoPointCombinedFieldLabel": "添加地理点字段", - "xpack.fileDataVisualizer.geoPointForm.geoPointFieldAriaLabel": "地理点字段,必填字段", - "xpack.fileDataVisualizer.geoPointForm.geoPointFieldLabel": "地理点字段", - "xpack.fileDataVisualizer.geoPointForm.latFieldLabel": "纬度字段", - "xpack.fileDataVisualizer.geoPointForm.lonFieldLabel": "经度字段", - "xpack.fileDataVisualizer.geoPointForm.submitButtonLabel": "添加", - "xpack.fileDataVisualizer.importErrors.checkingPermissionErrorMessage": "导入权限错误", - "xpack.fileDataVisualizer.importErrors.creatingIndexErrorMessage": "创建索引时出错", - "xpack.fileDataVisualizer.importErrors.creatingIndexPatternErrorMessage": "创建索引模式时出错", - "xpack.fileDataVisualizer.importErrors.creatingIngestPipelineErrorMessage": "创建采集管道时出错", - "xpack.fileDataVisualizer.importErrors.defaultErrorMessage": "错误", - "xpack.fileDataVisualizer.importErrors.moreButtonLabel": "更多", - "xpack.fileDataVisualizer.importErrors.parsingJSONErrorMessage": "解析 JSON 出错", - "xpack.fileDataVisualizer.importErrors.readingFileErrorMessage": "读取文件时出错", - "xpack.fileDataVisualizer.importErrors.unknownErrorMessage": "未知错误", - "xpack.fileDataVisualizer.importErrors.uploadingDataErrorMessage": "上传数据时出错", - "xpack.fileDataVisualizer.importProgress.createIndexPatternTitle": "创建索引模式", - "xpack.fileDataVisualizer.importProgress.createIndexTitle": "创建索引", - "xpack.fileDataVisualizer.importProgress.createIngestPipelineTitle": "创建采集管道", - "xpack.fileDataVisualizer.importProgress.creatingIndexPatternDescription": "正在创建索引模式", - "xpack.fileDataVisualizer.importProgress.creatingIndexPatternTitle": "正在创建索引模式", - "xpack.fileDataVisualizer.importProgress.creatingIndexTitle": "正在创建索引", - "xpack.fileDataVisualizer.importProgress.creatingIngestPipelineTitle": "正在创建采集管道", - "xpack.fileDataVisualizer.importProgress.dataUploadedTitle": "数据已上传", - "xpack.fileDataVisualizer.importProgress.fileProcessedTitle": "文件已处理", - "xpack.fileDataVisualizer.importProgress.indexCreatedTitle": "索引已创建", - "xpack.fileDataVisualizer.importProgress.indexPatternCreatedTitle": "索引模式已创建", - "xpack.fileDataVisualizer.importProgress.ingestPipelineCreatedTitle": "采集管道已创建", - "xpack.fileDataVisualizer.importProgress.processFileTitle": "处理文件", - "xpack.fileDataVisualizer.importProgress.processingFileTitle": "正在处理文件", - "xpack.fileDataVisualizer.importProgress.processingImportedFileDescription": "正在处理要导入的文件", - "xpack.fileDataVisualizer.importProgress.stepTwoCreatingIndexDescription": "正在创建索引", - "xpack.fileDataVisualizer.importProgress.stepTwoCreatingIndexIngestPipelineDescription": "正在创建索引和采集管道", - "xpack.fileDataVisualizer.importProgress.uploadDataTitle": "上传数据", - "xpack.fileDataVisualizer.importProgress.uploadingDataDescription": "正在上传数据", - "xpack.fileDataVisualizer.importProgress.uploadingDataTitle": "正在上传数据", - "xpack.fileDataVisualizer.importSettings.advancedTabName": "高级", - "xpack.fileDataVisualizer.importSettings.simpleTabName": "简单", - "xpack.fileDataVisualizer.importSummary.documentsCouldNotBeImportedDescription": "无法导入 {importFailuresLength} 个文档,共 {docCount} 个。这可能是由于行与 Grok 模式不匹配。", - "xpack.fileDataVisualizer.importSummary.documentsCouldNotBeImportedTitle": "部分文档无法导入", - "xpack.fileDataVisualizer.importSummary.documentsIngestedTitle": "已采集的文档", - "xpack.fileDataVisualizer.importSummary.failedDocumentsButtonLabel": "失败的文档", - "xpack.fileDataVisualizer.importSummary.failedDocumentsTitle": "失败的文档", - "xpack.fileDataVisualizer.importSummary.importCompleteTitle": "导入完成", - "xpack.fileDataVisualizer.importSummary.indexPatternTitle": "索引模式", - "xpack.fileDataVisualizer.importSummary.indexTitle": "索引", - "xpack.fileDataVisualizer.importSummary.ingestPipelineTitle": "采集管道", - "xpack.fileDataVisualizer.importView.experimentalFeatureTooltip": "实验性功能。我们很乐意听取您的反馈意见。", - "xpack.fileDataVisualizer.importView.importButtonLabel": "导入", - "xpack.fileDataVisualizer.importView.importDataTitle": "导入数据", - "xpack.fileDataVisualizer.importView.importPermissionError": "您无权创建或将数据导入索引 {index}", - "xpack.fileDataVisualizer.importView.indexNameAlreadyExistsErrorMessage": "索引名称已存在", - "xpack.fileDataVisualizer.importView.indexNameContainsIllegalCharactersErrorMessage": "索引名称包含非法字符", - "xpack.fileDataVisualizer.importView.indexPatternDoesNotMatchIndexNameErrorMessage": "索引模式与索引名称不匹配", - "xpack.fileDataVisualizer.importView.indexPatternNameAlreadyExistsErrorMessage": "索引模式名称已存在", - "xpack.fileDataVisualizer.importView.parseMappingsError": "解析映射时出错:", - "xpack.fileDataVisualizer.importView.parsePipelineError": "解析采集管道时出错:", - "xpack.fileDataVisualizer.importView.parseSettingsError": "解析设置时出错:", - "xpack.fileDataVisualizer.importView.resetButtonLabel": "重置", - "xpack.fileDataVisualizer.multiSelectPicker.NoFiltersFoundMessage": "未找到任何筛选", - "xpack.fileDataVisualizer.nameCollisionMsg": "“{name}”已存在,请提供唯一名称", - "xpack.fileDataVisualizer.removeCombinedFieldsLabel": "移除组合字段", - "xpack.fileDataVisualizer.resultsLinks.fileBeatConfig": "创建 Filebeat 配置", - "xpack.fileDataVisualizer.resultsLinks.fileBeatConfigBottomText": "其中 {password} 是 {user} 用户的密码,{esUrl} 是 Elasticsearch 的 URL。", - "xpack.fileDataVisualizer.resultsLinks.fileBeatConfigBottomTextNoUsername": "其中 {esUrl} 是 Elasticsearch 的 URL。", - "xpack.fileDataVisualizer.resultsLinks.fileBeatConfigTitle": "Filebeat 配置", - "xpack.fileDataVisualizer.resultsLinks.fileBeatConfigTopText1": "可以使用 Filebeat 将其他数据上传到 {index} 索引。", - "xpack.fileDataVisualizer.resultsLinks.fileBeatConfigTopText2": "修改 {filebeatYml} 以设置连接信息:", - "xpack.fileDataVisualizer.resultsLinks.indexManagementTitle": "索引管理", - "xpack.fileDataVisualizer.resultsLinks.indexPatternManagementTitle": "索引模式管理", - "xpack.fileDataVisualizer.resultsLinks.viewIndexInDiscoverTitle": "在 Discover 中查看索引", - "xpack.fileDataVisualizer.resultsView.analysisExplanationButtonLabel": "分析说明", - "xpack.fileDataVisualizer.resultsView.fileStatsName": "文件统计", - "xpack.fileDataVisualizer.resultsView.overrideSettingsButtonLabel": "替代设置", - "xpack.fileDataVisualizer.searchPanel.allFieldsLabel": "所有字段", - "xpack.fileDataVisualizer.searchPanel.numberFieldsLabel": "字段数目", - "xpack.fileDataVisualizer.searchPanel.ofFieldsTotal": ",共 {totalCount} 个", - "xpack.fileDataVisualizer.simpleImportSettings.createIndexPatternLabel": "创建索引模式", - "xpack.fileDataVisualizer.simpleImportSettings.indexNameAriaLabel": "索引名称,必填字段", - "xpack.fileDataVisualizer.simpleImportSettings.indexNameFormRowLabel": "索引名称", - "xpack.fileDataVisualizer.simpleImportSettings.indexNamePlaceholder": "索引名称", - "xpack.fileDataVisualizer.welcomeContent.delimitedTextFilesDescription": "分隔的文本文件,例如 CSV 和 TSV", - "xpack.fileDataVisualizer.welcomeContent.experimentalFeatureDescription": "此功能为实验性功能。有反馈?如欲提供反馈,请在 {githubLink} 中创建问题。", - "xpack.fileDataVisualizer.welcomeContent.experimentalFeatureTooltip": "实验性功能。我们很乐意听取您的反馈意见。", - "xpack.fileDataVisualizer.welcomeContent.logFilesWithCommonFormatDescription": "具有时间戳通用格式的日志文件", - "xpack.fileDataVisualizer.welcomeContent.newlineDelimitedJsonDescription": "换行符分隔的 JSON", - "xpack.fileDataVisualizer.welcomeContent.supportedFileFormatDescription": "File Data Visualizer 支持以下文件格式:", - "xpack.fileDataVisualizer.welcomeContent.uploadedFilesAllowedSizeDescription": "您可以上传不超过 {maxFileSize} 的文件。", - "xpack.fileDataVisualizer.welcomeContent.visualizeDataFromLogFileDescription": "File Data Visualizer 可帮助您理解日志文件中的字段和指标。上传文件、分析文件数据,然后选择是否将数据导入 Elasticsearch 索引。", - "xpack.fileDataVisualizer.welcomeContent.visualizeDataFromLogFileTitle": "可视化来自日志文件的数据 {experimentalBadge}", + "xpack.dataVisualizer.file.aboutPanel.analyzingDataTitle": "正在分析数据", + "xpack.dataVisualizer.file.aboutPanel.selectOrDragAndDropFileDescription": "选择或拖放文件", + "xpack.dataVisualizer.addCombinedFieldsLabel": "添加组合字段", + "xpack.dataVisualizer.file.advancedImportSettings.createIndexPatternLabel": "创建索引模式", + "xpack.dataVisualizer.file.advancedImportSettings.indexNameAriaLabel": "索引名称,必填字段", + "xpack.dataVisualizer.file.advancedImportSettings.indexNameLabel": "索引名称", + "xpack.dataVisualizer.file.advancedImportSettings.indexNamePlaceholder": "索引名称", + "xpack.dataVisualizer.file.advancedImportSettings.indexPatternNameLabel": "索引模式名称", + "xpack.dataVisualizer.file.advancedImportSettings.indexSettingsLabel": "索引设置", + "xpack.dataVisualizer.file.advancedImportSettings.ingestPipelineLabel": "采集管道", + "xpack.dataVisualizer.file.advancedImportSettings.mappingsLabel": "映射", + "xpack.dataVisualizer.file.analysisSummary.analyzedLinesNumberTitle": "已分析的行数", + "xpack.dataVisualizer.file.analysisSummary.delimiterTitle": "分隔符", + "xpack.dataVisualizer.file.analysisSummary.formatTitle": "格式", + "xpack.dataVisualizer.file.analysisSummary.grokPatternTitle": "Grok 模式", + "xpack.dataVisualizer.file.analysisSummary.hasHeaderRowTitle": "包含标题行", + "xpack.dataVisualizer.file.analysisSummary.summaryTitle": "摘要", + "xpack.dataVisualizer.file.analysisSummary.timeFieldTitle": "时间字段", + "xpack.dataVisualizer.file.analysisSummary.timeFormatTitle": "时间{timestampFormats, plural, other {格式}}", + "xpack.dataVisualizer.file.bottomBar.backButtonLabel": "返回", + "xpack.dataVisualizer.file.bottomBar.cancelButtonLabel": "取消", + "xpack.dataVisualizer.file.bottomBar.missingImportPrivilegesMessage": "您需要具有 ingest_admin 角色才能启用数据导入", + "xpack.dataVisualizer.file.bottomBar.readMode.cancelButtonLabel": "取消", + "xpack.dataVisualizer.file.bottomBar.readMode.importButtonLabel": "导入", + "xpack.dataVisualizer.combinedFieldsForm.mappingsParseError": "解析映射时出错:{error}", + "xpack.dataVisualizer.combinedFieldsForm.pipelineParseError": "解析管道时出错:{error}", + "xpack.dataVisualizer.combinedFieldsLabel": "组合字段", + "xpack.dataVisualizer.combinedFieldsReadOnlyHelpTextLabel": "在高级选项卡中编辑组合字段", + "xpack.dataVisualizer.combinedFieldsReadOnlyLabel": "组合字段", + "xpack.dataVisualizer.components.colorRangeLegend.blueColorRangeLabel": "蓝", + "xpack.dataVisualizer.components.colorRangeLegend.greenRedColorRangeLabel": "绿 - 红", + "xpack.dataVisualizer.components.colorRangeLegend.influencerScaleLabel": "影响因素定制比例", + "xpack.dataVisualizer.components.colorRangeLegend.linearScaleLabel": "线性", + "xpack.dataVisualizer.components.colorRangeLegend.redColorRangeLabel": "红", + "xpack.dataVisualizer.components.colorRangeLegend.redGreenColorRangeLabel": "红 - 绿", + "xpack.dataVisualizer.components.colorRangeLegend.sqrtScaleLabel": "平方根", + "xpack.dataVisualizer.components.colorRangeLegend.yellowGreenBlueColorRangeLabel": "黄 - 绿 - 蓝", + "xpack.dataVisualizer.dataGridChart.histogramNotAvailable": "不支持图表。", + "xpack.dataVisualizer.dataGridChart.notEnoughData": "0 个文档包含字段。", + "xpack.dataVisualizer.dataGridChart.singleCategoryLegend": "{cardinality, plural, other {# 个类别}}", + "xpack.dataVisualizer.dataGridChart.topCategoriesLegend": "{cardinality} 个类别中的排名前 {maxChartColumns} 个", + "xpack.dataVisualizer.dataGrid.collapseDetailsForAllAriaLabel": "收起所有字段的详细信息", + "xpack.dataVisualizer.dataGrid.distinctValuesColumnName": "不同值", + "xpack.dataVisualizer.dataGrid.distributionsColumnName": "分布", + "xpack.dataVisualizer.dataGrid.documentsCountColumnName": "文档 (%)", + "xpack.dataVisualizer.dataGrid.expandDetailsForAllAriaLabel": "展开所有字段的详细信息", + "xpack.dataVisualizer.dataGrid.nameColumnName": "名称", + "xpack.dataVisualizer.dataGrid.rowCollapse": "隐藏 {fieldName} 的详细信息", + "xpack.dataVisualizer.dataGrid.rowExpand": "显示 {fieldName} 的详细信息", + "xpack.dataVisualizer.dataGrid.showDistributionsAriaLabel": "显示分布", + "xpack.dataVisualizer.dataGrid.typeColumnName": "类型", + "xpack.dataVisualizer.file.editFlyout.applyOverrideSettingsButtonLabel": "应用", + "xpack.dataVisualizer.file.editFlyout.closeOverrideSettingsButtonLabel": "关闭", + "xpack.dataVisualizer.file.editFlyout.overrides.customDelimiterFormRowLabel": "定制分隔符", + "xpack.dataVisualizer.file.editFlyout.overrides.customTimestampFormatErrorMessage": "时间戳格式必须为以下 Java 日期/时间格式的组合:\n yy、yyyy、M、MM、MMM、MMMM、d、dd、EEE、EEEE、H、HH、h、mm、ss、S 至 SSSSSSSSS、a、XX、XXX、zzz", + "xpack.dataVisualizer.file.editFlyout.overrides.customTimestampFormatFormRowLabel": "定制时间戳格式", + "xpack.dataVisualizer.file.editFlyout.overrides.dataFormatFormRowLabel": "数据格式", + "xpack.dataVisualizer.file.editFlyout.overrides.delimiterFormRowLabel": "分隔符", + "xpack.dataVisualizer.file.editFlyout.overrides.editFieldNamesTitle": "编辑字段名称", + "xpack.dataVisualizer.file.editFlyout.overrides.grokPatternFormRowLabel": "Grok 模式", + "xpack.dataVisualizer.file.editFlyout.overrides.hasHeaderRowLabel": "包含标题行", + "xpack.dataVisualizer.file.editFlyout.overrides.linesToSampleErrorMessage": "值必须大于 {min} 并小于或等于 {max}", + "xpack.dataVisualizer.file.editFlyout.overrides.linesToSampleFormRowLabel": "要采样的行数", + "xpack.dataVisualizer.file.editFlyout.overrides.quoteCharacterFormRowLabel": "引用字符", + "xpack.dataVisualizer.file.editFlyout.overrides.timeFieldFormRowLabel": "时间字段", + "xpack.dataVisualizer.file.editFlyout.overrides.timestampEmptyValidationErrorMessage": "时间戳格式 {timestampFormat} 中没有时间格式字母组", + "xpack.dataVisualizer.file.editFlyout.overrides.timestampFormatFormRowLabel": "时间戳格式", + "xpack.dataVisualizer.file.editFlyout.overrides.timestampFormatHelpText": "请参阅有关接受格式的更多内容。", + "xpack.dataVisualizer.file.editFlyout.overrides.timestampLetterSValidationErrorMessage": "{format}的字母 { length, plural, one { {lg} } other { 组 {lg} } } 不受支持,因为其未前置 ss 和 {sep} 中的分隔符", + "xpack.dataVisualizer.file.editFlyout.overrides.timestampLetterValidationErrorMessage": "{format}的字母 { length, plural, one { {lg} } other { 组 {lg} } } 不受支持", + "xpack.dataVisualizer.file.editFlyout.overrides.timestampQuestionMarkValidationErrorMessage": "时间戳格式 {timestampFormat} 不受支持,因为其包含问号字符 ({fieldPlaceholder})", + "xpack.dataVisualizer.file.editFlyout.overrides.trimFieldsLabel": "应剪裁字段", + "xpack.dataVisualizer.file.editFlyout.overrideSettingsTitle": "替代设置", + "xpack.dataVisualizer.experimentalBadge.experimentalLabel": "实验性", + "xpack.dataVisualizer.file.explanationFlyout.closeButton": "关闭", + "xpack.dataVisualizer.file.explanationFlyout.content": "产生分析结果的逻辑步骤。", + "xpack.dataVisualizer.file.explanationFlyout.title": "分析说明", + "xpack.dataVisualizer.dataGrid.field.cardBoolean.valuesLabel": "值", + "xpack.dataVisualizer.dataGrid.field.cardDate.earliestLabel": "最早", + "xpack.dataVisualizer.dataGrid.field.cardDate.latestLabel": "最新", + "xpack.dataVisualizer.dataGrid.field.cardDate.summaryTableTitle": "摘要", + "xpack.dataVisualizer.dataGrid.fieldText.fieldMayBePopulatedDescription": "例如,可以使用文档映射中的 {copyToParam} 参数进行填充,也可以在索引后通过使用 {includesParam} 和 {excludesParam} 参数从 {sourceParam} 字段中修剪。", + "xpack.dataVisualizer.dataGrid.fieldText.fieldNotPresentDescription": "查询的文档的 {sourceParam} 字段中不存在此字段。", + "xpack.dataVisualizer.dataGrid.fieldText.noExamplesForFieldsTitle": "没有获取此字段的示例", + "xpack.dataVisualizer.dataGrid.field.examplesList.noExamplesMessage": "没有获取此字段的示例", + "xpack.dataVisualizer.dataGrid.field.examplesList.title": "{numExamples, plural, one {值} other {示例}}", + "xpack.dataVisualizer.dataGrid.field.metricDistributionChart.seriesName": "分布", + "xpack.dataVisualizer.dataGrid.field.metricDistributionChart.tooltipValueBetweenLabel": "{percent}% 的文档具有介于 {minValFormatted} 和 {maxValFormatted} 之间的值", + "xpack.dataVisualizer.dataGrid.field.metricDistributionChart.tooltipValueEqualLabel": "{percent}% 的文档的值为 {valFormatted}", + "xpack.dataVisualizer.dataGrid.field.topValues.calculatedFromSampleDescription": "基于每个分片的 {topValuesSamplerShardSize} 文档样例计算", + "xpack.dataVisualizer.dataGrid.field.topValuesLabel": "排名最前值", + "xpack.dataVisualizer.dataGrid.fieldExpandedRow.booleanContent.falseCountLabel": "false", + "xpack.dataVisualizer.dataGrid.fieldExpandedRow.booleanContent.summaryTableTitle": "摘要", + "xpack.dataVisualizer.dataGrid.fieldExpandedRow.booleanContent.trueCountLabel": "true", + "xpack.dataVisualizer.dataGrid.fieldExpandedRow.documentStatsTable.countLabel": "计数", + "xpack.dataVisualizer.dataGrid.fieldExpandedRow.documentStatsTable.distinctValueLabel": "不同值", + "xpack.dataVisualizer.dataGrid.fieldExpandedRow.documentStatsTable.metaTableTitle": "文档统计", + "xpack.dataVisualizer.dataGrid.fieldExpandedRow.documentStatsTable.percentageLabel": "百分比", + "xpack.dataVisualizer.dataGrid.fieldExpandedRow.numberContent.displayingPercentilesLabel": "正在显示 {minPercent} - {maxPercent} 百分位数", + "xpack.dataVisualizer.dataGrid.fieldExpandedRow.numberContent.distributionTitle": "分布", + "xpack.dataVisualizer.dataGrid.fieldExpandedRow.numberContent.maxLabel": "最大值", + "xpack.dataVisualizer.dataGrid.fieldExpandedRow.numberContent.medianLabel": "中值", + "xpack.dataVisualizer.dataGrid.fieldExpandedRow.numberContent.minLabel": "最小值", + "xpack.dataVisualizer.dataGrid.fieldExpandedRow.numberContent.summaryTableTitle": "摘要", + "xpack.dataVisualizer.fieldNameSelect": "字段名称", + "xpack.dataVisualizer.fieldStats.maxTitle": "最大值", + "xpack.dataVisualizer.fieldStats.medianTitle": "中值", + "xpack.dataVisualizer.fieldStats.minTitle": "最小值", + "xpack.dataVisualizer.fieldTypeIcon.booleanTypeAriaLabel": "布尔类型", + "xpack.dataVisualizer.fieldTypeIcon.dateTypeAriaLabel": "日期类型", + "xpack.dataVisualizer.fieldTypeIcon.fieldTypeTooltip": "{type} 类型", + "xpack.dataVisualizer.fieldTypeIcon.geoPointTypeAriaLabel": "{geoPointParam} 类型", + "xpack.dataVisualizer.fieldTypeIcon.ipTypeAriaLabel": "IP 类型", + "xpack.dataVisualizer.fieldTypeIcon.keywordTypeAriaLabel": "关键字类型", + "xpack.dataVisualizer.fieldTypeIcon.numberTypeAriaLabel": "数字类型", + "xpack.dataVisualizer.fieldTypeIcon.textTypeAriaLabel": "文本类型", + "xpack.dataVisualizer.fieldTypeIcon.unknownTypeAriaLabel": "未知类型", + "xpack.dataVisualizer.fieldTypeSelect": "字段类型", + "xpack.dataVisualizer.fileBeatConfig.paths": "在此处将路径添加您的文件中", + "xpack.dataVisualizer.fileBeatConfigFlyout.closeButton": "关闭", + "xpack.dataVisualizer.fileBeatConfigFlyout.copyButton": "复制到剪贴板", + "xpack.dataVisualizer.file.fileContents.fileContentsTitle": "文件内容", + "xpack.dataVisualizer.file.fileContents.firstLinesDescription": "前 {numberOfLines, plural, other {# 行}}", + "xpack.dataVisualizer.file.xmlNotCurrentlySupportedErrorMessage": "当前不支持 XML", + "xpack.dataVisualizer.file.fileErrorCallouts.applyOverridesDescription": "如果您对此数据有所了解,例如文件格式或时间戳格式,则添加初始覆盖可以帮助我们推理结构的其余部分。", + "xpack.dataVisualizer.file.fileErrorCallouts.fileCouldNotBeReadTitle": "无法确定文件结构", + "xpack.dataVisualizer.file.fileErrorCallouts.fileSizeExceedsAllowedSizeByDiffFormatErrorMessage": "您选择用于上传的文件大小超过上限值 {maxFileSizeFormatted} 的 {diffFormatted}", + "xpack.dataVisualizer.file.fileErrorCallouts.fileSizeExceedsAllowedSizeErrorMessage": "您选择用于上传的文件大小为 {fileSizeFormatted},超过上限值 {maxFileSizeFormatted}", + "xpack.dataVisualizer.file.fileErrorCallouts.fileSizeTooLargeTitle": "文件太大", + "xpack.dataVisualizer.file.fileErrorCallouts.overrideButton": "应用覆盖设置", + "xpack.dataVisualizer.file.fileErrorCallouts.revertingToPreviousSettingsDescription": "恢复到以前的设置", + "xpack.dataVisualizer.file.geoPointForm.combinedFieldLabel": "添加地理点字段", + "xpack.dataVisualizer.file.geoPointForm.geoPointFieldAriaLabel": "地理点字段,必填字段", + "xpack.dataVisualizer.file.geoPointForm.geoPointFieldLabel": "地理点字段", + "xpack.dataVisualizer.file.geoPointForm.latFieldLabel": "纬度字段", + "xpack.dataVisualizer.file.geoPointForm.lonFieldLabel": "经度字段", + "xpack.dataVisualizer.file.geoPointForm.submitButtonLabel": "添加", + "xpack.dataVisualizer.file.importErrors.checkingPermissionErrorMessage": "导入权限错误", + "xpack.dataVisualizer.file.importErrors.creatingIndexErrorMessage": "创建索引时出错", + "xpack.dataVisualizer.file.importErrors.creatingIndexPatternErrorMessage": "创建索引模式时出错", + "xpack.dataVisualizer.file.importErrors.creatingIngestPipelineErrorMessage": "创建采集管道时出错", + "xpack.dataVisualizer.file.importErrors.defaultErrorMessage": "错误", + "xpack.dataVisualizer.file.importErrors.moreButtonLabel": "更多", + "xpack.dataVisualizer.file.importErrors.parsingJSONErrorMessage": "解析 JSON 出错", + "xpack.dataVisualizer.file.importErrors.readingFileErrorMessage": "读取文件时出错", + "xpack.dataVisualizer.file.importErrors.unknownErrorMessage": "未知错误", + "xpack.dataVisualizer.file.importErrors.uploadingDataErrorMessage": "上传数据时出错", + "xpack.dataVisualizer.file.importProgress.createIndexPatternTitle": "创建索引模式", + "xpack.dataVisualizer.file.importProgress.createIndexTitle": "创建索引", + "xpack.dataVisualizer.file.importProgress.createIngestPipelineTitle": "创建采集管道", + "xpack.dataVisualizer.file.importProgress.creatingIndexPatternDescription": "正在创建索引模式", + "xpack.dataVisualizer.file.importProgress.creatingIndexPatternTitle": "正在创建索引模式", + "xpack.dataVisualizer.file.importProgress.creatingIndexTitle": "正在创建索引", + "xpack.dataVisualizer.file.importProgress.creatingIngestPipelineTitle": "正在创建采集管道", + "xpack.dataVisualizer.file.importProgress.dataUploadedTitle": "数据已上传", + "xpack.dataVisualizer.file.importProgress.fileProcessedTitle": "文件已处理", + "xpack.dataVisualizer.file.importProgress.indexCreatedTitle": "索引已创建", + "xpack.dataVisualizer.file.importProgress.indexPatternCreatedTitle": "索引模式已创建", + "xpack.dataVisualizer.file.importProgress.ingestPipelineCreatedTitle": "采集管道已创建", + "xpack.dataVisualizer.file.importProgress.processFileTitle": "处理文件", + "xpack.dataVisualizer.file.importProgress.processingFileTitle": "正在处理文件", + "xpack.dataVisualizer.file.importProgress.processingImportedFileDescription": "正在处理要导入的文件", + "xpack.dataVisualizer.file.importProgress.stepTwoCreatingIndexDescription": "正在创建索引", + "xpack.dataVisualizer.file.importProgress.stepTwoCreatingIndexIngestPipelineDescription": "正在创建索引和采集管道", + "xpack.dataVisualizer.file.importProgress.uploadDataTitle": "上传数据", + "xpack.dataVisualizer.file.importProgress.uploadingDataDescription": "正在上传数据", + "xpack.dataVisualizer.file.importProgress.uploadingDataTitle": "正在上传数据", + "xpack.dataVisualizer.file.importSettings.advancedTabName": "高级", + "xpack.dataVisualizer.file.importSettings.simpleTabName": "简单", + "xpack.dataVisualizer.file.importSummary.documentsCouldNotBeImportedDescription": "无法导入 {importFailuresLength} 个文档,共 {docCount} 个。这可能是由于行与 Grok 模式不匹配。", + "xpack.dataVisualizer.file.importSummary.documentsCouldNotBeImportedTitle": "部分文档无法导入", + "xpack.dataVisualizer.file.importSummary.documentsIngestedTitle": "已采集的文档", + "xpack.dataVisualizer.file.importSummary.failedDocumentsButtonLabel": "失败的文档", + "xpack.dataVisualizer.file.importSummary.failedDocumentsTitle": "失败的文档", + "xpack.dataVisualizer.file.importSummary.importCompleteTitle": "导入完成", + "xpack.dataVisualizer.file.importSummary.indexPatternTitle": "索引模式", + "xpack.dataVisualizer.file.importSummary.indexTitle": "索引", + "xpack.dataVisualizer.file.importSummary.ingestPipelineTitle": "采集管道", + "xpack.dataVisualizer.file.importView.experimentalFeatureTooltip": "实验性功能。我们很乐意听取您的反馈意见。", + "xpack.dataVisualizer.file.importView.importButtonLabel": "导入", + "xpack.dataVisualizer.file.importView.importDataTitle": "导入数据", + "xpack.dataVisualizer.file.importView.importPermissionError": "您无权创建或将数据导入索引 {index}", + "xpack.dataVisualizer.file.importView.indexNameAlreadyExistsErrorMessage": "索引名称已存在", + "xpack.dataVisualizer.file.importView.indexNameContainsIllegalCharactersErrorMessage": "索引名称包含非法字符", + "xpack.dataVisualizer.file.importView.indexPatternDoesNotMatchIndexNameErrorMessage": "索引模式与索引名称不匹配", + "xpack.dataVisualizer.file.importView.indexPatternNameAlreadyExistsErrorMessage": "索引模式名称已存在", + "xpack.dataVisualizer.file.importView.parseMappingsError": "解析映射时出错:", + "xpack.dataVisualizer.file.importView.parsePipelineError": "解析采集管道时出错:", + "xpack.dataVisualizer.file.importView.parseSettingsError": "解析设置时出错:", + "xpack.dataVisualizer.file.importView.resetButtonLabel": "重置", + "xpack.dataVisualizer.multiSelectPicker.NoFiltersFoundMessage": "未找到任何筛选", + "xpack.dataVisualizer.nameCollisionMsg": "“{name}”已存在,请提供唯一名称", + "xpack.dataVisualizer.removeCombinedFieldsLabel": "移除组合字段", + "xpack.dataVisualizer.file.resultsLinks.fileBeatConfig": "创建 Filebeat 配置", + "xpack.dataVisualizer.file.resultsLinks.fileBeatConfigBottomText": "其中 {password} 是 {user} 用户的密码,{esUrl} 是 Elasticsearch 的 URL。", + "xpack.dataVisualizer.file.resultsLinks.fileBeatConfigBottomTextNoUsername": "其中 {esUrl} 是 Elasticsearch 的 URL。", + "xpack.dataVisualizer.file.resultsLinks.fileBeatConfigTitle": "Filebeat 配置", + "xpack.dataVisualizer.file.resultsLinks.fileBeatConfigTopText1": "可以使用 Filebeat 将其他数据上传到 {index} 索引。", + "xpack.dataVisualizer.file.resultsLinks.fileBeatConfigTopText2": "修改 {filebeatYml} 以设置连接信息:", + "xpack.dataVisualizer.file.resultsLinks.indexManagementTitle": "索引管理", + "xpack.dataVisualizer.file.resultsLinks.indexPatternManagementTitle": "索引模式管理", + "xpack.dataVisualizer.file.resultsLinks.viewIndexInDiscoverTitle": "在 Discover 中查看索引", + "xpack.dataVisualizer.file.resultsView.analysisExplanationButtonLabel": "分析说明", + "xpack.dataVisualizer.file.resultsView.fileStatsName": "文件统计", + "xpack.dataVisualizer.file.resultsView.overrideSettingsButtonLabel": "替代设置", + "xpack.dataVisualizer.searchPanel.allFieldsLabel": "所有字段", + "xpack.dataVisualizer.searchPanel.numberFieldsLabel": "字段数目", + "xpack.dataVisualizer.searchPanel.ofFieldsTotal": ",共 {totalCount} 个", + "xpack.dataVisualizer.file.simpleImportSettings.createIndexPatternLabel": "创建索引模式", + "xpack.dataVisualizer.file.simpleImportSettings.indexNameAriaLabel": "索引名称,必填字段", + "xpack.dataVisualizer.file.simpleImportSettings.indexNameFormRowLabel": "索引名称", + "xpack.dataVisualizer.file.simpleImportSettings.indexNamePlaceholder": "索引名称", + "xpack.dataVisualizer.file.welcomeContent.delimitedTextFilesDescription": "分隔的文本文件,例如 CSV 和 TSV", + "xpack.dataVisualizer.file.welcomeContent.experimentalFeatureDescription": "此功能为实验性功能。有反馈?如欲提供反馈,请在 {githubLink} 中创建问题。", + "xpack.dataVisualizer.file.welcomeContent.experimentalFeatureTooltip": "实验性功能。我们很乐意听取您的反馈意见。", + "xpack.dataVisualizer.file.welcomeContent.logFilesWithCommonFormatDescription": "具有时间戳通用格式的日志文件", + "xpack.dataVisualizer.file.welcomeContent.newlineDelimitedJsonDescription": "换行符分隔的 JSON", + "xpack.dataVisualizer.file.welcomeContent.supportedFileFormatDescription": "File Data Visualizer 支持以下文件格式:", + "xpack.dataVisualizer.file.welcomeContent.uploadedFilesAllowedSizeDescription": "您可以上传不超过 {maxFileSize} 的文件。", + "xpack.dataVisualizer.file.welcomeContent.visualizeDataFromLogFileDescription": "File Data Visualizer 可帮助您理解日志文件中的字段和指标。上传文件、分析文件数据,然后选择是否将数据导入 Elasticsearch 索引。", + "xpack.dataVisualizer.file.welcomeContent.visualizeDataFromLogFileTitle": "可视化来自日志文件的数据 {experimentalBadge}", + "xpack.dataVisualizer.index.actionsPanel.discoverAppTitle": "Discover", + "xpack.dataVisualizer.index.actionsPanel.exploreTitle": "浏览您的数据", + "xpack.dataVisualizer.index.actionsPanel.viewIndexInDiscoverDescription": "浏览您的索引中的文档。", + "xpack.dataVisualizer.index.fieldNameSelect": "字段名称", + "xpack.dataVisualizer.index.fieldTypeSelect": "字段类型", + "xpack.dataVisualizer.index.dataGrid.actionsColumnLabel": "操作", + "xpack.dataVisualizer.index.dataGrid.exploreInLensDescription": "在 Lens 中浏览", + "xpack.dataVisualizer.index.dataGrid.exploreInLensTitle": "在 Lens 中浏览", + "xpack.dataVisualizer.index.lensChart.averageOfLabel": "{fieldName} 的平均值", + "xpack.dataVisualizer.index.lensChart.chartTitle": "{fieldName} 的 Lens", + "xpack.dataVisualizer.index.lensChart.countLabel": "计数", + "xpack.dataVisualizer.index.lensChart.topValuesLabel": "排名最前值", + "xpack.dataVisualizer.searchPanel.allOptionLabel": "搜索全部", + "xpack.dataVisualizer.searchPanel.invalidKuerySyntaxErrorMessageQueryBar": "无效查询", + "xpack.dataVisualizer.searchPanel.queryBarPlaceholder": "选择较小的样例大小将减少查询运行时间和集群上的负载。", + "xpack.dataVisualizer.searchPanel.queryBarPlaceholderText": "搜索…… (例如,status:200 AND extension:\"PHP\") ", + "xpack.dataVisualizer.searchPanel.sampleSizeAriaLabel": "选择要采样的文档数目", + "xpack.dataVisualizer.searchPanel.sampleSizeOptionLabel": "样本大小 (每分片) :{wrappedValue}", + "xpack.dataVisualizer.searchPanel.showEmptyFields": "显示空字段", + "xpack.dataVisualizer.searchPanel.totalDocCountLabel": "文档总数:{strongTotalCount}", + "xpack.dataVisualizer.searchPanel.totalDocCountNumber": "{totalCount, plural, other {#}}", + "xpack.dataVisualizer.dataGrid.field.documentCountChart.seriesLabel": "文档计数", + "xpack.dataVisualizer.dataGrid.field.fieldNotInDocsLabel": "此字段不会出现在所选时间范围的任何文档中", + "xpack.dataVisualizer.dataGrid.field.loadingLabel": "正在加载", + "xpack.dataVisualizer.index.dataLoader.internalServerErrorMessage": "加载索引 {index} 中的数据时出错。{message}。请求可能已超时。请尝试使用较小的样例大小或缩小时间范围。", "xpack.fileUpload.fileSizeError": "文件大小 {fileSize} 超过最大文件大小 {maxFileSize}", "xpack.fileUpload.fileTypeError": "文件不是可接受类型之一:{types}", "xpack.fileUpload.geojsonFilePicker.acceptedCoordinateSystem": "坐标必须在 EPSG:4326 坐标参考系中。", @@ -14699,48 +14724,7 @@ "xpack.ml.dataGridChart.notEnoughData": "0 个文档包含字段。", "xpack.ml.dataGridChart.singleCategoryLegend": "{cardinality, plural, other {# 个类别}}", "xpack.ml.dataGridChart.topCategoriesLegend": "{cardinality} 个类别中的排名前 {maxChartColumns} 个", - "xpack.ml.datavisualizer.actionsPanel.advancedDescription": "为更高级的用例创建具有全部选项的作业。", - "xpack.ml.datavisualizer.actionsPanel.advancedTitle": "高级异常检测", - "xpack.ml.datavisualizer.actionsPanel.createJobTitle": "创建作业", - "xpack.ml.datavisualizer.actionsPanel.dataframeAnalyticsTitle": "数据帧分析", - "xpack.ml.datavisualizer.actionsPanel.dataframeTypesDescription": "创建离群值检测、回归或分类分析。", - "xpack.ml.datavisualizer.actionsPanel.discoverAppTitle": "Discover", - "xpack.ml.datavisualizer.actionsPanel.exploreTitle": "浏览您的数据", - "xpack.ml.datavisualizer.actionsPanel.viewIndexInDiscoverDescription": "浏览您的索引中的文档。", - "xpack.ml.datavisualizer.dataGrid.collapseDetailsForAllAriaLabel": "收起所有字段的详细信息", - "xpack.ml.datavisualizer.dataGrid.distinctValuesColumnName": "不同值", - "xpack.ml.datavisualizer.dataGrid.distributionsColumnName": "分布", - "xpack.ml.datavisualizer.dataGrid.documentsCountColumnName": "文档 (%)", - "xpack.ml.datavisualizer.dataGrid.expandDetailsForAllAriaLabel": "展开所有字段的详细信息", - "xpack.ml.datavisualizer.dataGrid.nameColumnName": "名称", - "xpack.ml.datavisualizer.dataGrid.rowCollapse": "隐藏 {fieldName} 的详细信息", - "xpack.ml.datavisualizer.dataGrid.rowExpand": "显示 {fieldName} 的详细信息", - "xpack.ml.datavisualizer.dataGrid.showDistributionsAriaLabel": "显示分布", - "xpack.ml.datavisualizer.dataGrid.typeColumnName": "类型", - "xpack.ml.datavisualizer.dataLoader.internalServerErrorMessage": "加载索引 {index} 中的数据时出错。{message}。请求可能已超时。请尝试使用较小的样例大小或缩小时间范围。", "xpack.ml.dataVisualizer.fileBasedLabel": "文件", - "xpack.ml.dataVisualizer.indexBased.fieldNameSelect": "字段名称", - "xpack.ml.dataVisualizer.indexBased.fieldTypeSelect": "字段类型", - "xpack.ml.dataVisualizer.indexBasedDataGrid.actionsColumnLabel": "操作", - "xpack.ml.dataVisualizer.indexBasedDataGrid.exploreInLensDescription": "在 Lens 中浏览", - "xpack.ml.dataVisualizer.indexBasedDataGrid.exploreInLensTitle": "在 Lens 中浏览", - "xpack.ml.dataVisualizer.lensChart.averageOfLabel": "{fieldName} 的平均值", - "xpack.ml.dataVisualizer.lensChart.chartTitle": "{fieldName} 的 Lens", - "xpack.ml.dataVisualizer.lensChart.countLabel": "计数", - "xpack.ml.dataVisualizer.lensChart.topValuesLabel": "排名最前值", - "xpack.ml.datavisualizer.page.errorLoadingDataMessage": "加载索引 {index} 中的数据时出错。{message}", - "xpack.ml.dataVisualizer.searchPanel.allFieldsLabel": "所有字段", - "xpack.ml.datavisualizer.searchPanel.allOptionLabel": "搜索全部", - "xpack.ml.datavisualizer.searchPanel.invalidKuerySyntaxErrorMessageQueryBar": "无效查询", - "xpack.ml.dataVisualizer.searchPanel.numberFieldsLabel": "字段数目", - "xpack.ml.dataVisualizer.searchPanel.ofFieldsTotal": ",共 {totalCount} 个", - "xpack.ml.datavisualizer.searchPanel.queryBarPlaceholder": "选择较小的样例大小将减少查询运行时间和集群上的负载。", - "xpack.ml.datavisualizer.searchPanel.queryBarPlaceholderText": "搜索…… (例如,status:200 AND extension:\"PHP\") ", - "xpack.ml.datavisualizer.searchPanel.sampleSizeAriaLabel": "选择要采样的文档数目", - "xpack.ml.datavisualizer.searchPanel.sampleSizeOptionLabel": "样本大小 (每分片) :{wrappedValue}", - "xpack.ml.dataVisualizer.searchPanel.showEmptyFields": "显示空字段", - "xpack.ml.datavisualizer.searchPanel.totalDocCountLabel": "文档总数:{strongTotalCount}", - "xpack.ml.datavisualizer.searchPanel.totalDocCountNumber": "{totalCount, plural, other {#}}", "xpack.ml.datavisualizer.selector.dataVisualizerDescription": "Machine Learning 数据可视化工具通过分析日志文件或现有 Elasticsearch 索引中的指标和字段,帮助您理解数据。", "xpack.ml.datavisualizer.selector.dataVisualizerTitle": "数据可视化工具", "xpack.ml.datavisualizer.selector.experimentalBadgeLabel": "实验性", @@ -14871,40 +14855,8 @@ "xpack.ml.explorerCharts.errorCallOutMessage": "由于{reason},您无法查看 {jobs} 的异常图表。", "xpack.ml.feature.reserved.description": "要向用户授予访问权限,还应分配 machine_learning_user 或 machine_learning_admin 角色。", "xpack.ml.featureRegistry.mlFeatureName": "Machine Learning", - "xpack.ml.fieldDataCard.cardBoolean.valuesLabel": "值", - "xpack.ml.fieldDataCard.cardDate.earliestLabel": "最早", - "xpack.ml.fieldDataCard.cardDate.latestLabel": "最新", - "xpack.ml.fieldDataCard.cardDate.summaryTableTitle": "摘要", - "xpack.ml.fieldDataCard.cardText.fieldMayBePopulatedDescription": "例如,可以使用文档映射中的 {copyToParam} 参数进行填充,也可以在索引后通过使用 {includesParam} 和 {excludesParam} 参数从 {sourceParam} 字段中修剪。", - "xpack.ml.fieldDataCard.cardText.fieldNotPresentDescription": "查询的文档的 {sourceParam} 字段中不存在此字段。", - "xpack.ml.fieldDataCard.cardText.noExamplesForFieldsTitle": "没有获取此字段的示例", - "xpack.ml.fieldDataCard.documentCountChart.seriesLabel": "文档计数", - "xpack.ml.fieldDataCard.examplesList.noExamplesMessage": "没有获取此字段的示例", - "xpack.ml.fieldDataCard.examplesList.title": "{numExamples, plural, one {值} other {示例}}", - "xpack.ml.fieldDataCard.fieldNotInDocsLabel": "此字段不会出现在所选时间范围的任何文档中", - "xpack.ml.fieldDataCard.loadingLabel": "正在加载", - "xpack.ml.fieldDataCard.metricDistributionChart.seriesName": "分布", - "xpack.ml.fieldDataCard.metricDistributionChart.tooltipValueBetweenLabel": "{percent}% 的文档具有介于 {minValFormatted} 和 {maxValFormatted} 之间的值", - "xpack.ml.fieldDataCard.metricDistributionChart.tooltipValueEqualLabel": "{percent}% 的文档的值为 {valFormatted}", - "xpack.ml.fieldDataCard.topValues.calculatedFromSampleDescription": "基于每个分片的 {topValuesSamplerShardSize} 文档样例计算", - "xpack.ml.fieldDataCard.topValuesLabel": "排名最前值", - "xpack.ml.fieldDataCardExpandedRow.booleanContent.falseCountLabel": "false", - "xpack.ml.fieldDataCardExpandedRow.booleanContent.summaryTableTitle": "摘要", - "xpack.ml.fieldDataCardExpandedRow.booleanContent.trueCountLabel": "true", - "xpack.ml.fieldDataCardExpandedRow.documentStatsTable.countLabel": "计数", - "xpack.ml.fieldDataCardExpandedRow.documentStatsTable.distinctValueLabel": "不同值", - "xpack.ml.fieldDataCardExpandedRow.documentStatsTable.metaTableTitle": "文档统计", - "xpack.ml.fieldDataCardExpandedRow.documentStatsTable.percentageLabel": "百分比", - "xpack.ml.fieldDataCardExpandedRow.numberContent.displayingPercentilesLabel": "正在显示 {minPercent} - {maxPercent} 百分位数", - "xpack.ml.fieldDataCardExpandedRow.numberContent.distributionTitle": "分布", - "xpack.ml.fieldDataCardExpandedRow.numberContent.maxLabel": "最大值", - "xpack.ml.fieldDataCardExpandedRow.numberContent.medianLabel": "中值", - "xpack.ml.fieldDataCardExpandedRow.numberContent.minLabel": "最小值", - "xpack.ml.fieldDataCardExpandedRow.numberContent.summaryTableTitle": "摘要", - "xpack.ml.fieldTitleBar.documentCountLabel": "文档计数", "xpack.ml.fieldTypeIcon.booleanTypeAriaLabel": "布尔类型", "xpack.ml.fieldTypeIcon.dateTypeAriaLabel": "日期类型", - "xpack.ml.fieldTypeIcon.fieldTypeTooltip": "{type} 类型", "xpack.ml.fieldTypeIcon.geoPointTypeAriaLabel": "{geoPointParam} 类型", "xpack.ml.fieldTypeIcon.ipTypeAriaLabel": "IP 类型", "xpack.ml.fieldTypeIcon.keywordTypeAriaLabel": "关键字类型", diff --git a/x-pack/test/api_integration/apis/ml/data_visualizer/get_field_stats.ts b/x-pack/test/api_integration/apis/ml/data_visualizer/get_field_stats.ts index 6e7231065c377..84373d14c4e56 100644 --- a/x-pack/test/api_integration/apis/ml/data_visualizer/get_field_stats.ts +++ b/x-pack/test/api_integration/apis/ml/data_visualizer/get_field_stats.ts @@ -167,7 +167,7 @@ export default ({ getService }: FtrProviderContext) => { expectedResponsecode: number ): Promise { const { body } = await supertest - .post(`/api/ml/data_visualizer/get_field_stats/${index}`) + .post(`/internal/data_visualizer/get_field_stats/${index}`) .auth(user, ml.securityCommon.getPasswordForUser(user)) .set(COMMON_REQUEST_HEADERS) .send(requestBody) @@ -176,6 +176,7 @@ export default ({ getService }: FtrProviderContext) => { return body; } + // Move these tests to file_data_visualizer plugin describe('get_field_stats', function () { before(async () => { await esArchiver.loadIfNeeded('ml/farequote'); diff --git a/x-pack/test/api_integration/apis/ml/data_visualizer/get_overall_stats.ts b/x-pack/test/api_integration/apis/ml/data_visualizer/get_overall_stats.ts index 601a4a04eb0c6..f701fd64e32e6 100644 --- a/x-pack/test/api_integration/apis/ml/data_visualizer/get_overall_stats.ts +++ b/x-pack/test/api_integration/apis/ml/data_visualizer/get_overall_stats.ts @@ -123,6 +123,7 @@ export default ({ getService }: FtrProviderContext) => { }, ]; + // Move these tests to file_data_visualizer plugin describe('get_overall_stats', function () { before(async () => { await esArchiver.loadIfNeeded('ml/farequote'); @@ -132,7 +133,7 @@ export default ({ getService }: FtrProviderContext) => { for (const testData of testDataList) { it(`${testData.testTitle}`, async () => { const { body } = await supertest - .post(`/api/ml/data_visualizer/get_overall_stats/${testData.index}`) + .post(`/internal/data_visualizer/get_overall_stats/${testData.index}`) .auth(testData.user, ml.securityCommon.getPasswordForUser(testData.user)) .set(COMMON_REQUEST_HEADERS) .send(testData.requestBody) diff --git a/x-pack/test/functional/apps/ml/data_visualizer/index_data_visualizer.ts b/x-pack/test/functional/apps/ml/data_visualizer/index_data_visualizer.ts index 609cf05dad541..d83d151e7125e 100644 --- a/x-pack/test/functional/apps/ml/data_visualizer/index_data_visualizer.ts +++ b/x-pack/test/functional/apps/ml/data_visualizer/index_data_visualizer.ts @@ -7,7 +7,7 @@ import { FtrProviderContext } from '../../../ftr_provider_context'; import { ML_JOB_FIELD_TYPES } from '../../../../../plugins/ml/common/constants/field_types'; -import { FieldVisConfig } from '../../../../../plugins/ml/public/application/datavisualizer/stats_table/types'; +import { FieldVisConfig } from '../../../../../plugins/data_visualizer/public/application/common/components/stats_table/types'; interface MetricFieldVisConfig extends FieldVisConfig { statsMaxDecimalPlaces: number; diff --git a/x-pack/test/functional/apps/ml/data_visualizer/index_data_visualizer_actions_panel.ts b/x-pack/test/functional/apps/ml/data_visualizer/index_data_visualizer_actions_panel.ts index bc80d8850032b..2c89f34c41a3d 100644 --- a/x-pack/test/functional/apps/ml/data_visualizer/index_data_visualizer_actions_panel.ts +++ b/x-pack/test/functional/apps/ml/data_visualizer/index_data_visualizer_actions_panel.ts @@ -15,15 +15,16 @@ export default function ({ getService }: FtrProviderContext) { this.tags(['mlqa']); const indexPatternName = 'ft_farequote'; - const advancedJobWizardDatafeedQuery = `{ - "bool": { - "must": [ - { - "match_all": {} - } - ] - } -}`; // Note query is not currently passed to the wizard + // @TODO: Re-enable in follow up + // const advancedJobWizardDatafeedQuery = `{ + // "bool": { + // "must": [ + // { + // "match_all": {} + // } + // ] + // } + // }`; // Note query is not currently passed to the wizard before(async () => { await esArchiver.loadIfNeeded('ml/farequote'); @@ -47,19 +48,20 @@ export default function ({ getService }: FtrProviderContext) { await ml.jobSourceSelection.selectSourceForIndexBasedDataVisualizer(indexPatternName); }); - it('opens the advanced job wizard', async () => { - await ml.testExecution.logTestStep('displays the actions panel with advanced job card'); - await ml.dataVisualizerIndexBased.assertActionsPanelExists(); - await ml.dataVisualizerIndexBased.assertCreateAdvancedJobCardExists(); - await ml.dataVisualizerIndexBased.assertCreateDataFrameAnalyticsCardExists(); - - // Note the search is not currently passed to the wizard, just the index. - await ml.testExecution.logTestStep('displays the actions panel with advanced job card'); - await ml.dataVisualizerIndexBased.clickCreateAdvancedJobButton(); - await ml.jobTypeSelection.assertAdvancedJobWizardOpen(); - await ml.jobWizardAdvanced.assertDatafeedQueryEditorExists(); - await ml.jobWizardAdvanced.assertDatafeedQueryEditorValue(advancedJobWizardDatafeedQuery); - }); + // @TODO: Re-enable in follow up + // it('opens the advanced job wizard', async () => { + // await ml.testExecution.logTestStep('displays the actions panel with advanced job card'); + // await ml.dataVisualizerIndexBased.assertActionsPanelExists(); + // await ml.dataVisualizerIndexBased.assertCreateAdvancedJobCardExists(); + // await ml.dataVisualizerIndexBased.assertCreateDataFrameAnalyticsCardExists(); + // + // // Note the search is not currently passed to the wizard, just the index. + // await ml.testExecution.logTestStep('displays the actions panel with advanced job card'); + // await ml.dataVisualizerIndexBased.clickCreateAdvancedJobButton(); + // await ml.jobTypeSelection.assertAdvancedJobWizardOpen(); + // await ml.jobWizardAdvanced.assertDatafeedQueryEditorExists(); + // await ml.jobWizardAdvanced.assertDatafeedQueryEditorValue(advancedJobWizardDatafeedQuery); + // }); }); describe('view in discover page action', function () { diff --git a/x-pack/test/functional/apps/ml/permissions/full_ml_access.ts b/x-pack/test/functional/apps/ml/permissions/full_ml_access.ts index 87f74363413d3..30f5f9aa6be2b 100644 --- a/x-pack/test/functional/apps/ml/permissions/full_ml_access.ts +++ b/x-pack/test/functional/apps/ml/permissions/full_ml_access.ts @@ -101,7 +101,8 @@ export default function ({ getService }: FtrProviderContext) { const ecIndexPattern = 'ft_module_sample_ecommerce'; const ecExpectedTotalCount = '287'; - const ecExpectedModuleId = 'sample_data_ecommerce'; + // @TODO: Re-enable in follow up + // const ecExpectedModuleId = 'sample_data_ecommerce'; const uploadFilePath = path.join( __dirname, @@ -365,13 +366,16 @@ export default function ({ getService }: FtrProviderContext) { testUser.discoverAvailable ? 'with' : 'without' } Discover card` ); - await ml.dataVisualizerIndexBased.assertActionsPanelExists(); + if (testUser.discoverAvailable) { + await ml.dataVisualizerIndexBased.assertActionsPanelExists(); + } await ml.dataVisualizerIndexBased.assertViewInDiscoverCard(testUser.discoverAvailable); - await ml.testExecution.logTestStep('should display job cards'); - await ml.dataVisualizerIndexBased.assertCreateAdvancedJobCardExists(); - await ml.dataVisualizerIndexBased.assertRecognizerCardExists(ecExpectedModuleId); - await ml.dataVisualizerIndexBased.assertCreateDataFrameAnalyticsCardExists(); + // @TODO: Re-enable in follow up + // await ml.testExecution.logTestStep('should display job cards'); + // await ml.dataVisualizerIndexBased.assertCreateAdvancedJobCardExists(); + // await ml.dataVisualizerIndexBased.assertRecognizerCardExists(ecExpectedModuleId); + // await ml.dataVisualizerIndexBased.assertCreateDataFrameAnalyticsCardExists(); }); it('should display elements on File Data Visualizer page correctly', async () => { diff --git a/x-pack/test/functional/apps/ml/permissions/read_ml_access.ts b/x-pack/test/functional/apps/ml/permissions/read_ml_access.ts index 5e6e179a7bdcc..1aa3b54d2a278 100644 --- a/x-pack/test/functional/apps/ml/permissions/read_ml_access.ts +++ b/x-pack/test/functional/apps/ml/permissions/read_ml_access.ts @@ -102,7 +102,7 @@ export default function ({ getService }: FtrProviderContext) { const ecIndexPattern = 'ft_module_sample_ecommerce'; const ecExpectedTotalCount = '287'; - const ecExpectedModuleId = 'sample_data_ecommerce'; + // const ecExpectedModuleId = 'sample_data_ecommerce'; const uploadFilePath = path.join( __dirname, @@ -358,13 +358,16 @@ export default function ({ getService }: FtrProviderContext) { testUser.discoverAvailable ? 'with' : 'without' } Discover card` ); - await ml.dataVisualizerIndexBased.assertActionsPanelExists(); + if (testUser.discoverAvailable) { + await ml.dataVisualizerIndexBased.assertActionsPanelExists(); + } await ml.dataVisualizerIndexBased.assertViewInDiscoverCard(testUser.discoverAvailable); - await ml.testExecution.logTestStep('should not display job cards'); - await ml.dataVisualizerIndexBased.assertCreateAdvancedJobCardNotExists(); - await ml.dataVisualizerIndexBased.assertRecognizerCardNotExists(ecExpectedModuleId); - await ml.dataVisualizerIndexBased.assertCreateDataFrameAnalyticsCardNotExists(); + // @TODO: Re-enable in follow up + // await ml.testExecution.logTestStep('should not display job cards'); + // await ml.dataVisualizerIndexBased.assertCreateAdvancedJobCardNotExists(); + // await ml.dataVisualizerIndexBased.assertRecognizerCardNotExists(ecExpectedModuleId); + // await ml.dataVisualizerIndexBased.assertCreateDataFrameAnalyticsCardNotExists(); }); it('should display elements on File Data Visualizer page correctly', async () => { diff --git a/x-pack/test/functional/services/ml/data_visualizer.ts b/x-pack/test/functional/services/ml/data_visualizer.ts index 2ebc1e1ad3017..3571f9193e6b3 100644 --- a/x-pack/test/functional/services/ml/data_visualizer.ts +++ b/x-pack/test/functional/services/ml/data_visualizer.ts @@ -62,7 +62,7 @@ export function MachineLearningDataVisualizerProvider({ getService }: FtrProvide async navigateToFileUpload() { await testSubjects.click('mlDataVisualizerUploadFileButton'); - await testSubjects.existOrFail('mlPageFileDataVisualizerUpload'); + await testSubjects.existOrFail('dataVisualizerPageFileUpload'); }, }; } diff --git a/x-pack/test/functional/services/ml/data_visualizer_file_based.ts b/x-pack/test/functional/services/ml/data_visualizer_file_based.ts index e32c04f82804c..5eece4057ac0c 100644 --- a/x-pack/test/functional/services/ml/data_visualizer_file_based.ts +++ b/x-pack/test/functional/services/ml/data_visualizer_file_based.ts @@ -25,18 +25,18 @@ export function MachineLearningDataVisualizerFileBasedProvider( log.debug(`Importing file '${path}' ...`); await PageObjects.common.setFileInputPath(path); - await testSubjects.waitForDeleted('mlPageFileDataVisLoading'); + await testSubjects.waitForDeleted('dataVisualizerPageFileLoading'); if (expectError) { - await testSubjects.existOrFail('~mlFileUploadErrorCallout'); + await testSubjects.existOrFail('~dataVisualizerFileUploadErrorCallout'); } else { - await testSubjects.missingOrFail('~mlFileUploadErrorCallout'); - await testSubjects.existOrFail('mlPageFileDataVisResults'); + await testSubjects.missingOrFail('~dataVisualizerFileUploadErrorCallout'); + await testSubjects.existOrFail('dataVisualizerPageFileResults'); } }, async assertFileTitle(expectedTitle: string) { - const actualTitle = await testSubjects.getVisibleText('mlFileDataVisResultsTitle'); + const actualTitle = await testSubjects.getVisibleText('dataVisualizerFileResultsTitle'); expect(actualTitle).to.eql( expectedTitle, `Expected file title to be '${expectedTitle}' (got '${actualTitle}')` @@ -44,15 +44,15 @@ export function MachineLearningDataVisualizerFileBasedProvider( }, async assertFileContentPanelExists() { - await testSubjects.existOrFail('mlFileDataVisFileContentPanel'); + await testSubjects.existOrFail('dataVisualizerFileFileContentPanel'); }, async assertSummaryPanelExists() { - await testSubjects.existOrFail('mlFileDataVisSummaryPanel'); + await testSubjects.existOrFail('dataVisualizerFileSummaryPanel'); }, async assertFileStatsPanelExists() { - await testSubjects.existOrFail('mlFileDataVisFileStatsPanel'); + await testSubjects.existOrFail('dataVisualizerFileFileStatsPanel'); }, async assertNumberOfFieldCards(number: number) { @@ -64,7 +64,7 @@ export function MachineLearningDataVisualizerFileBasedProvider( }, async assertImportButtonEnabled(expectedValue: boolean) { - const isEnabled = await testSubjects.isEnabled('mlFileDataVisOpenImportPageButton'); + const isEnabled = await testSubjects.isEnabled('dataVisualizerFileOpenImportPageButton'); expect(isEnabled).to.eql( expectedValue, `Expected "import" button to be '${expectedValue ? 'enabled' : 'disabled'}' (got '${ @@ -74,17 +74,17 @@ export function MachineLearningDataVisualizerFileBasedProvider( }, async navigateToFileImport() { - await testSubjects.click('mlFileDataVisOpenImportPageButton'); - await testSubjects.existOrFail('mlPageFileDataVisImport'); + await testSubjects.click('dataVisualizerFileOpenImportPageButton'); + await testSubjects.existOrFail('dataVisualizerPageFileImport'); }, async assertImportSettingsPanelExists() { - await testSubjects.existOrFail('mlFileDataVisImportSettingsPanel'); + await testSubjects.existOrFail('dataVisualizerFileImportSettingsPanel'); }, async assertIndexNameValue(expectedValue: string) { const actualIndexName = await testSubjects.getAttribute( - 'mlFileDataVisIndexNameInput', + 'dataVisualizerFileIndexNameInput', 'value' ); expect(actualIndexName).to.eql( @@ -94,14 +94,16 @@ export function MachineLearningDataVisualizerFileBasedProvider( }, async setIndexName(indexName: string) { - await mlCommonUI.setValueWithChecks('mlFileDataVisIndexNameInput', indexName, { + await mlCommonUI.setValueWithChecks('dataVisualizerFileIndexNameInput', indexName, { clearWithKeyboard: true, }); await this.assertIndexNameValue(indexName); }, async assertCreateIndexPatternCheckboxValue(expectedValue: boolean) { - const isChecked = await testSubjects.isChecked('mlFileDataVisCreateIndexPatternCheckbox'); + const isChecked = await testSubjects.isChecked( + 'dataVisualizerFileCreateIndexPatternCheckbox' + ); expect(isChecked).to.eql( expectedValue, `Expected create index pattern checkbox to be ${expectedValue ? 'checked' : 'unchecked'}` @@ -109,10 +111,12 @@ export function MachineLearningDataVisualizerFileBasedProvider( }, async setCreateIndexPatternCheckboxState(newState: boolean) { - const isChecked = await testSubjects.isChecked('mlFileDataVisCreateIndexPatternCheckbox'); + const isChecked = await testSubjects.isChecked( + 'dataVisualizerFileCreateIndexPatternCheckbox' + ); if (isChecked !== newState) { // this checkbox can't be clicked directly, instead click the corresponding label - const panel = await testSubjects.find('mlFileDataVisImportSettingsPanel'); + const panel = await testSubjects.find('dataVisualizerFileImportSettingsPanel'); const label = await panel.findByCssSelector('[for="createIndexPattern"]'); await label.click(); } @@ -120,9 +124,9 @@ export function MachineLearningDataVisualizerFileBasedProvider( }, async startImportAndWaitForProcessing() { - await testSubjects.clickWhenNotDisabled('mlFileDataVisImportButton'); + await testSubjects.clickWhenNotDisabled('dataVisualizerFileImportButton'); await retry.tryForTime(60 * 1000, async () => { - await testSubjects.existOrFail('mlFileImportSuccessCallout'); + await testSubjects.existOrFail('dataVisualizerFileImportSuccessCallout'); }); }, diff --git a/x-pack/test/functional/services/ml/data_visualizer_index_based.ts b/x-pack/test/functional/services/ml/data_visualizer_index_based.ts index 4beaa78d0189b..7f32968ec4326 100644 --- a/x-pack/test/functional/services/ml/data_visualizer_index_based.ts +++ b/x-pack/test/functional/services/ml/data_visualizer_index_based.ts @@ -19,12 +19,12 @@ export function MachineLearningDataVisualizerIndexBasedProvider({ return { async assertTimeRangeSelectorSectionExists() { - await testSubjects.existOrFail('mlDataVisualizerTimeRangeSelectorSection'); + await testSubjects.existOrFail('dataVisualizerTimeRangeSelectorSection'); }, async assertTotalDocumentCount(expectedFormattedTotalDocCount: string) { await retry.tryForTime(5000, async () => { - const docCount = await testSubjects.getVisibleText('mlDataVisualizerTotalDocCount'); + const docCount = await testSubjects.getVisibleText('dataVisualizerTotalDocCount'); expect(docCount).to.eql( expectedFormattedTotalDocCount, `Expected total document count to be '${expectedFormattedTotalDocCount}' (got '${docCount}')` @@ -33,40 +33,40 @@ export function MachineLearningDataVisualizerIndexBasedProvider({ }, async clickUseFullDataButton(expectedFormattedTotalDocCount: string) { - await testSubjects.clickWhenNotDisabled('mlButtonUseFullData'); + await testSubjects.clickWhenNotDisabled('dataVisualizerButtonUseFullData'); await this.assertTotalDocumentCount(expectedFormattedTotalDocCount); }, async assertTotalDocCountHeaderExist() { await retry.tryForTime(5000, async () => { - await testSubjects.existOrFail(`mlDataVisualizerTotalDocCountHeader`); + await testSubjects.existOrFail(`dataVisualizerTotalDocCountHeader`); }); }, async assertTotalDocCountChartExist() { await retry.tryForTime(5000, async () => { - await testSubjects.existOrFail(`mlFieldDataDocumentCountChart`); + await testSubjects.existOrFail(`dataVisualizerDocumentCountChart`); }); }, async assertFieldCountPanelExist() { await retry.tryForTime(5000, async () => { - await testSubjects.existOrFail(`mlDataVisualizerFieldCountPanel`); + await testSubjects.existOrFail(`dataVisualizerFieldCountPanel`); }); }, async assertMetricFieldsSummaryExist() { await retry.tryForTime(5000, async () => { - await testSubjects.existOrFail(`mlDataVisualizerMetricFieldsSummary`); + await testSubjects.existOrFail(`dataVisualizerMetricFieldsSummary`); }); }, async assertVisibleMetricFieldsCount(count: number) { const expectedCount = count.toString(); await retry.tryForTime(5000, async () => { - await testSubjects.existOrFail('mlDataVisualizerVisibleMetricFieldsCount'); + await testSubjects.existOrFail('dataVisualizerVisibleMetricFieldsCount'); const actualCount = await testSubjects.getVisibleText( - 'mlDataVisualizerVisibleMetricFieldsCount' + 'dataVisualizerVisibleMetricFieldsCount' ); expect(expectedCount).to.eql( expectedCount, @@ -78,9 +78,9 @@ export function MachineLearningDataVisualizerIndexBasedProvider({ async assertTotalMetricFieldsCount(count: number) { const expectedCount = count.toString(); await retry.tryForTime(5000, async () => { - await testSubjects.existOrFail('mlDataVisualizerMetricFieldsCount'); + await testSubjects.existOrFail('dataVisualizerMetricFieldsCount'); const actualCount = await testSubjects.getVisibleText( - 'mlDataVisualizerVisibleMetricFieldsCount' + 'dataVisualizerVisibleMetricFieldsCount' ); expect(expectedCount).to.contain( expectedCount, @@ -92,8 +92,8 @@ export function MachineLearningDataVisualizerIndexBasedProvider({ async assertVisibleFieldsCount(count: number) { const expectedCount = count.toString(); await retry.tryForTime(5000, async () => { - await testSubjects.existOrFail('mlDataVisualizerVisibleFieldsCount'); - const actualCount = await testSubjects.getVisibleText('mlDataVisualizerVisibleFieldsCount'); + await testSubjects.existOrFail('dataVisualizerVisibleFieldsCount'); + const actualCount = await testSubjects.getVisibleText('dataVisualizerVisibleFieldsCount'); expect(expectedCount).to.eql( expectedCount, `Expected fields count to be '${expectedCount}' (got '${actualCount}')` @@ -104,8 +104,8 @@ export function MachineLearningDataVisualizerIndexBasedProvider({ async assertTotalFieldsCount(count: number) { const expectedCount = count.toString(); await retry.tryForTime(5000, async () => { - await testSubjects.existOrFail('mlDataVisualizerTotalFieldsCount'); - const actualCount = await testSubjects.getVisibleText('mlDataVisualizerTotalFieldsCount'); + await testSubjects.existOrFail('dataVisualizerTotalFieldsCount'); + const actualCount = await testSubjects.getVisibleText('dataVisualizerTotalFieldsCount'); expect(expectedCount).to.contain( expectedCount, `Expected total fields count to be '${expectedCount}' (got '${actualCount}')` @@ -115,30 +115,30 @@ export function MachineLearningDataVisualizerIndexBasedProvider({ async assertFieldsSummaryExist() { await retry.tryForTime(5000, async () => { - await testSubjects.existOrFail(`mlDataVisualizerFieldsSummary`); + await testSubjects.existOrFail(`dataVisualizerFieldsSummary`); }); }, async assertDataVisualizerTableExist() { await retry.tryForTime(5000, async () => { - await testSubjects.existOrFail(`mlDataVisualizerTable`); + await testSubjects.existOrFail(`dataVisualizerTable`); }); }, async assertActionsPanelExists() { - await testSubjects.existOrFail('mlDataVisualizerActionsPanel'); + await testSubjects.existOrFail('dataVisualizerActionsPanel'); }, async assertActionsPanelNotExists() { - await testSubjects.missingOrFail('mlDataVisualizerActionsPanel'); + await testSubjects.missingOrFail('dataVisualizerActionsPanel'); }, async assertCreateAdvancedJobCardExists() { - await testSubjects.existOrFail('mlDataVisualizerCreateAdvancedJobCard'); + await testSubjects.existOrFail('dataVisualizerCreateAdvancedJobCard'); }, async assertCreateAdvancedJobCardNotExists() { - await testSubjects.missingOrFail('mlDataVisualizerCreateAdvancedJobCard'); + await testSubjects.missingOrFail('dataVisualizerCreateAdvancedJobCard'); }, async assertRecognizerCardExists(moduleId: string) { @@ -150,15 +150,15 @@ export function MachineLearningDataVisualizerIndexBasedProvider({ }, async clickCreateAdvancedJobButton() { - await testSubjects.clickWhenNotDisabled('mlDataVisualizerCreateAdvancedJobCard'); + await testSubjects.clickWhenNotDisabled('dataVisualizerCreateAdvancedJobCard'); }, async assertCreateDataFrameAnalyticsCardExists() { - await testSubjects.existOrFail('mlDataVisualizerCreateDataFrameAnalyticsCard'); + await testSubjects.existOrFail('dataVisualizerCreateDataFrameAnalyticsCard'); }, async assertCreateDataFrameAnalyticsCardNotExists() { - await testSubjects.missingOrFail('mlDataVisualizerCreateDataFrameAnalyticsCard'); + await testSubjects.missingOrFail('dataVisualizerCreateDataFrameAnalyticsCard'); }, async assertViewInDiscoverCard(shouldExist: boolean) { @@ -170,16 +170,16 @@ export function MachineLearningDataVisualizerIndexBasedProvider({ }, async assertViewInDiscoverCardExists() { - await testSubjects.existOrFail('mlDataVisualizerViewInDiscoverCard'); + await testSubjects.existOrFail('dataVisualizerViewInDiscoverCard'); }, async assertViewInDiscoverCardNotExists() { - await testSubjects.missingOrFail('mlDataVisualizerViewInDiscoverCard'); + await testSubjects.missingOrFail('dataVisualizerViewInDiscoverCard'); }, async clickViewInDiscoverButton() { await retry.tryForTime(5000, async () => { - await testSubjects.clickWhenNotDisabled('mlDataVisualizerViewInDiscoverCard'); + await testSubjects.clickWhenNotDisabled('dataVisualizerViewInDiscoverCard'); await PageObjects.discover.waitForDiscoverAppOnScreen(); }); }, diff --git a/x-pack/test/functional/services/ml/data_visualizer_table.ts b/x-pack/test/functional/services/ml/data_visualizer_table.ts index cdd91da8ff9e6..1eb0edbe01c8e 100644 --- a/x-pack/test/functional/services/ml/data_visualizer_table.ts +++ b/x-pack/test/functional/services/ml/data_visualizer_table.ts @@ -21,36 +21,36 @@ export function MachineLearningDataVisualizerTableProvider( return new (class DataVisualizerTable { public async parseDataVisualizerTable() { - const table = await testSubjects.find('~mlDataVisualizerTable'); + const table = await testSubjects.find('~dataVisualizerTable'); const $ = await table.parseDomContent(); const rows = []; - for (const tr of $.findTestSubjects('~mlDataVisualizerRow').toArray()) { + for (const tr of $.findTestSubjects('~dataVisualizerRow').toArray()) { const $tr = $(tr); rows.push({ type: $tr - .findTestSubject('mlDataVisualizerTableColumnType') + .findTestSubject('dataVisualizerTableColumnType') .find('.euiTableCellContent') .text() .trim(), fieldName: $tr - .findTestSubject('mlDataVisualizerTableColumnName') + .findTestSubject('dataVisualizerTableColumnName') .find('.euiTableCellContent') .text() .trim(), documentsCount: $tr - .findTestSubject('mlDataVisualizerTableColumnDocumentsCount') + .findTestSubject('dataVisualizerTableColumnDocumentsCount') .find('.euiTableCellContent') .text() .trim(), distinctValues: $tr - .findTestSubject('mlDataVisualizerTableColumnDistinctValues') + .findTestSubject('dataVisualizerTableColumnDistinctValues') .find('.euiTableCellContent') .text() .trim(), distribution: $tr - .findTestSubject('mlDataVisualizerTableColumnDistribution') + .findTestSubject('dataVisualizerTableColumnDistribution') .find('.euiTableCellContent') .text() .trim(), @@ -71,7 +71,7 @@ export function MachineLearningDataVisualizerTableProvider( } public rowSelector(fieldName: string, subSelector?: string) { - const row = `~mlDataVisualizerTable > ~row-${fieldName}`; + const row = `~dataVisualizerTable > ~row-${fieldName}`; return !subSelector ? row : `${row} > ${subSelector}`; } @@ -80,7 +80,7 @@ export function MachineLearningDataVisualizerTableProvider( } public detailsSelector(fieldName: string, subSelector?: string) { - const row = `~mlDataVisualizerTable > ~mlDataVisualizerFieldExpandedRow-${fieldName}`; + const row = `~dataVisualizerTable > ~dataVisualizerFieldExpandedRow-${fieldName}`; return !subSelector ? row : `${row} > ${subSelector}`; } @@ -89,11 +89,11 @@ export function MachineLearningDataVisualizerTableProvider( if (!(await testSubjects.exists(this.detailsSelector(fieldName)))) { const selector = this.rowSelector( fieldName, - `mlDataVisualizerDetailsToggle-${fieldName}-arrowDown` + `dataVisualizerDetailsToggle-${fieldName}-arrowDown` ); await testSubjects.click(selector); await testSubjects.existOrFail( - this.rowSelector(fieldName, `mlDataVisualizerDetailsToggle-${fieldName}-arrowUp`), + this.rowSelector(fieldName, `dataVisualizerDetailsToggle-${fieldName}-arrowUp`), { timeout: 1000, } @@ -107,10 +107,10 @@ export function MachineLearningDataVisualizerTableProvider( await retry.tryForTime(10000, async () => { if (await testSubjects.exists(this.detailsSelector(fieldName))) { await testSubjects.click( - this.rowSelector(fieldName, `mlDataVisualizerDetailsToggle-${fieldName}-arrowUp`) + this.rowSelector(fieldName, `dataVisualizerDetailsToggle-${fieldName}-arrowUp`) ); await testSubjects.existOrFail( - this.rowSelector(fieldName, `mlDataVisualizerDetailsToggle-${fieldName}-arrowDown`), + this.rowSelector(fieldName, `dataVisualizerDetailsToggle-${fieldName}-arrowDown`), { timeout: 1000, } @@ -123,7 +123,7 @@ export function MachineLearningDataVisualizerTableProvider( public async assertFieldDocCount(fieldName: string, docCountFormatted: string) { const docCountFormattedSelector = this.rowSelector( fieldName, - 'mlDataVisualizerTableColumnDocumentsCount' + 'dataVisualizerTableColumnDocumentsCount' ); await testSubjects.existOrFail(docCountFormattedSelector); const docCount = await testSubjects.getVisibleText(docCountFormattedSelector); @@ -134,40 +134,40 @@ export function MachineLearningDataVisualizerTableProvider( } public async assertViewInLensActionEnabled(fieldName: string) { - const actionButton = this.rowSelector(fieldName, 'mlActionButtonViewInLens'); + const actionButton = this.rowSelector(fieldName, 'dataVisualizerActionViewInLensButton'); await testSubjects.existOrFail(actionButton); await testSubjects.isEnabled(actionButton); } public async assertViewInLensActionNotExists(fieldName: string) { - const actionButton = this.rowSelector(fieldName, 'mlActionButtonViewInLens'); + const actionButton = this.rowSelector(fieldName, 'dataVisualizerActionViewInLensButton'); await testSubjects.missingOrFail(actionButton); } public async assertFieldDistinctValuesExist(fieldName: string) { - const selector = this.rowSelector(fieldName, 'mlDataVisualizerTableColumnDistinctValues'); + const selector = this.rowSelector(fieldName, 'dataVisualizerTableColumnDistinctValues'); await testSubjects.existOrFail(selector); } public async assertFieldDistributionExist(fieldName: string) { - const selector = this.rowSelector(fieldName, 'mlDataVisualizerTableColumnDistribution'); + const selector = this.rowSelector(fieldName, 'dataVisualizerTableColumnDistribution'); await testSubjects.existOrFail(selector); } public async assertSearchPanelExist() { - await testSubjects.existOrFail(`mlDataVisualizerSearchPanel`); + await testSubjects.existOrFail(`dataVisualizerSearchPanel`); } public async assertFieldNameInputExists() { - await testSubjects.existOrFail('mlDataVisualizerFieldNameSelect'); + await testSubjects.existOrFail('dataVisualizerFieldNameSelect'); } public async assertFieldTypeInputExists() { - await testSubjects.existOrFail('mlDataVisualizerFieldTypeSelect'); + await testSubjects.existOrFail('dataVisualizerFieldTypeSelect'); } public async assertSampleSizeInputExists() { - await testSubjects.existOrFail('mlDataVisualizerShardSizeSelect'); + await testSubjects.existOrFail('dataVisualizerShardSizeSelect'); } public async setSampleSizeInputValue( @@ -176,9 +176,9 @@ export function MachineLearningDataVisualizerTableProvider( docCountFormatted: string ) { await this.assertSampleSizeInputExists(); - await testSubjects.clickWhenNotDisabled('mlDataVisualizerShardSizeSelect'); - await testSubjects.existOrFail(`mlDataVisualizerShardSizeOption ${sampleSize}`); - await testSubjects.click(`mlDataVisualizerShardSizeOption ${sampleSize}`); + await testSubjects.clickWhenNotDisabled('dataVisualizerShardSizeSelect'); + await testSubjects.existOrFail(`dataVisualizerShardSizeOption ${sampleSize}`); + await testSubjects.click(`dataVisualizerShardSizeOption ${sampleSize}`); await retry.tryForTime(5000, async () => { await this.assertFieldDocCount(fieldName, docCountFormatted); @@ -187,38 +187,36 @@ export function MachineLearningDataVisualizerTableProvider( public async setFieldTypeFilter(fieldTypes: string[], expectedRowCount = 1) { await this.assertFieldTypeInputExists(); - await mlCommonUI.setMultiSelectFilter('mlDataVisualizerFieldTypeSelect', fieldTypes); + await mlCommonUI.setMultiSelectFilter('dataVisualizerFieldTypeSelect', fieldTypes); await this.assertTableRowCount(expectedRowCount); } async removeFieldTypeFilter(fieldTypes: string[], expectedRowCount = 1) { await this.assertFieldTypeInputExists(); - await mlCommonUI.removeMultiSelectFilter('mlDataVisualizerFieldTypeSelect', fieldTypes); + await mlCommonUI.removeMultiSelectFilter('dataVisualizerFieldTypeSelect', fieldTypes); await this.assertTableRowCount(expectedRowCount); } public async setFieldNameFilter(fieldNames: string[], expectedRowCount = 1) { await this.assertFieldNameInputExists(); - await mlCommonUI.setMultiSelectFilter('mlDataVisualizerFieldNameSelect', fieldNames); + await mlCommonUI.setMultiSelectFilter('dataVisualizerFieldNameSelect', fieldNames); await this.assertTableRowCount(expectedRowCount); } public async removeFieldNameFilter(fieldNames: string[], expectedRowCount: number) { await this.assertFieldNameInputExists(); - await mlCommonUI.removeMultiSelectFilter('mlDataVisualizerFieldNameSelect', fieldNames); + await mlCommonUI.removeMultiSelectFilter('dataVisualizerFieldNameSelect', fieldNames); await this.assertTableRowCount(expectedRowCount); } public async assertShowEmptyFieldsSwitchExists() { - await testSubjects.existOrFail('mlDataVisualizerShowEmptyFieldsSwitch'); + await testSubjects.existOrFail('dataVisualizerShowEmptyFieldsSwitch'); } public async assertShowEmptyFieldsCheckState(expectedCheckState: boolean) { const actualCheckState = - (await testSubjects.getAttribute( - 'mlDataVisualizerShowEmptyFieldsSwitch', - 'aria-checked' - )) === 'true'; + (await testSubjects.getAttribute('dataVisualizerShowEmptyFieldsSwitch', 'aria-checked')) === + 'true'; expect(actualCheckState).to.eql( expectedCheckState, `Show empty fields check state should be '${expectedCheckState}' (got '${actualCheckState}')` @@ -230,7 +228,7 @@ export function MachineLearningDataVisualizerTableProvider( await this.assertShowEmptyFieldsSwitchExists(); await retry.tryForTime(5000, async () => { if (await this.assertShowEmptyFieldsCheckState(!checkState)) { - await testSubjects.click('mlDataVisualizerShowEmptyFieldsSwitch'); + await testSubjects.click('dataVisualizerShowEmptyFieldsSwitch'); } await this.assertShowEmptyFieldsCheckState(checkState); for (const field of expectedEmptyFields) { @@ -240,9 +238,11 @@ export function MachineLearningDataVisualizerTableProvider( } public async assertTopValuesContents(fieldName: string, expectedTopValuesCount: number) { - const selector = this.detailsSelector(fieldName, 'mlFieldDataTopValues'); + const selector = this.detailsSelector(fieldName, 'dataVisualizerFieldDataTopValuesContent'); const topValuesElement = await testSubjects.find(selector); - const topValuesBars = await topValuesElement.findAllByTestSubject('mlFieldDataTopValueBar'); + const topValuesBars = await topValuesElement.findAllByTestSubject( + 'dataVisualizerFieldDataTopValueBar' + ); expect(topValuesBars).to.have.length( expectedTopValuesCount, `Expected top values count for field '${fieldName}' to be '${expectedTopValuesCount}' (got '${topValuesBars.length}')` @@ -250,9 +250,11 @@ export function MachineLearningDataVisualizerTableProvider( } public async assertDistributionPreviewExist(fieldName: string) { - await testSubjects.existOrFail(this.rowSelector(fieldName, `mlDataGridChart-${fieldName}`)); await testSubjects.existOrFail( - this.rowSelector(fieldName, `mlDataGridChart-${fieldName}-histogram`) + this.rowSelector(fieldName, `dataVisualizerDataGridChart-${fieldName}`) + ); + await testSubjects.existOrFail( + this.rowSelector(fieldName, `dataVisualizerDataGridChart-${fieldName}-histogram`) ); } @@ -267,9 +269,13 @@ export function MachineLearningDataVisualizerTableProvider( await this.assertFieldDocCount(fieldName, docCountFormatted); await this.ensureDetailsOpen(fieldName); - await testSubjects.existOrFail(this.detailsSelector(fieldName, 'mlNumberSummaryTable')); + await testSubjects.existOrFail( + this.detailsSelector(fieldName, 'dataVisualizerNumberSummaryTable') + ); - await testSubjects.existOrFail(this.detailsSelector(fieldName, 'mlTopValues')); + await testSubjects.existOrFail( + this.detailsSelector(fieldName, 'dataVisualizerFieldDataTopValues') + ); await this.assertTopValuesContents(fieldName, topValuesCount); if (checkDistributionPreviewExist) { @@ -289,7 +295,9 @@ export function MachineLearningDataVisualizerTableProvider( await this.assertFieldDocCount(fieldName, docCountFormatted); await this.ensureDetailsOpen(fieldName); - await testSubjects.existOrFail(this.detailsSelector(fieldName, 'mlDateSummaryTable')); + await testSubjects.existOrFail( + this.detailsSelector(fieldName, 'dataVisualizerDateSummaryTable') + ); await this.ensureDetailsClosed(fieldName); } @@ -302,14 +310,16 @@ export function MachineLearningDataVisualizerTableProvider( await this.assertFieldDocCount(fieldName, docCountFormatted); await this.ensureDetailsOpen(fieldName); - await testSubjects.existOrFail(this.detailsSelector(fieldName, 'mlFieldDataTopValues')); + await testSubjects.existOrFail( + this.detailsSelector(fieldName, 'dataVisualizerFieldDataTopValuesContent') + ); await this.assertTopValuesContents(fieldName, topValuesCount); await this.ensureDetailsClosed(fieldName); } public async assertExamplesList(fieldName: string, expectedExamplesCount: number) { const examplesList = await testSubjects.find( - this.detailsSelector(fieldName, 'mlFieldDataExamplesList') + this.detailsSelector(fieldName, 'dataVisualizerFieldDataExamplesList') ); const examplesListItems = await examplesList.findAllByTagName('li'); expect(examplesListItems).to.have.length( @@ -343,7 +353,9 @@ export function MachineLearningDataVisualizerTableProvider( await this.assertExamplesList(fieldName, expectedExamplesCount); - await testSubjects.existOrFail(this.detailsSelector(fieldName, 'mlEmbeddedMapContent')); + await testSubjects.existOrFail( + this.detailsSelector(fieldName, 'dataVisualizerEmbeddedMapContent') + ); await this.ensureDetailsClosed(fieldName); } @@ -354,7 +366,9 @@ export function MachineLearningDataVisualizerTableProvider( await this.ensureDetailsOpen(fieldName); - await testSubjects.existOrFail(this.detailsSelector(fieldName, 'mlDVDocumentStatsContent')); + await testSubjects.existOrFail( + this.detailsSelector(fieldName, 'dataVisualizerDocumentStatsContent') + ); await this.ensureDetailsClosed(fieldName); } @@ -387,7 +401,7 @@ export function MachineLearningDataVisualizerTableProvider( } public async ensureNumRowsPerPage(n: 10 | 25 | 50) { - const paginationButton = 'mlDataVisualizerTable > tablePaginationPopoverButton'; + const paginationButton = 'dataVisualizerTable > tablePaginationPopoverButton'; await retry.tryForTime(10000, async () => { await testSubjects.existOrFail(paginationButton); await testSubjects.click(paginationButton); diff --git a/x-pack/test/functional/services/ml/job_source_selection.ts b/x-pack/test/functional/services/ml/job_source_selection.ts index e5e9a68b95f8e..e215f9b857435 100644 --- a/x-pack/test/functional/services/ml/job_source_selection.ts +++ b/x-pack/test/functional/services/ml/job_source_selection.ts @@ -40,7 +40,7 @@ export function MachineLearningJobSourceSelectionProvider({ getService }: FtrPro }, async selectSourceForIndexBasedDataVisualizer(sourceName: string) { - await this.selectSource(sourceName, 'mlPageIndexDataVisualizer'); + await this.selectSource(sourceName, 'dataVisualizerIndexPage'); }, }; } diff --git a/x-pack/test/functional_basic/apps/ml/permissions/full_ml_access.ts b/x-pack/test/functional_basic/apps/ml/permissions/full_ml_access.ts index 6a80fe18404fb..abd494df7a853 100644 --- a/x-pack/test/functional_basic/apps/ml/permissions/full_ml_access.ts +++ b/x-pack/test/functional_basic/apps/ml/permissions/full_ml_access.ts @@ -25,7 +25,7 @@ export default function ({ getService }: FtrProviderContext) { describe(`(${testUser.user})`, function () { const ecIndexPattern = 'ft_module_sample_ecommerce'; const ecExpectedTotalCount = '287'; - const ecExpectedModuleId = 'sample_data_ecommerce'; + // const ecExpectedModuleId = 'sample_data_ecommerce'; const uploadFilePath = path.join( __dirname, @@ -135,13 +135,16 @@ export default function ({ getService }: FtrProviderContext) { testUser.discoverAvailable ? 'with' : 'without' } Discover card` ); - await ml.dataVisualizerIndexBased.assertActionsPanelExists(); + if (testUser.discoverAvailable) { + await ml.dataVisualizerIndexBased.assertActionsPanelExists(); + } await ml.dataVisualizerIndexBased.assertViewInDiscoverCard(testUser.discoverAvailable); - await ml.testExecution.logTestStep('should not display job cards'); - await ml.dataVisualizerIndexBased.assertCreateAdvancedJobCardNotExists(); - await ml.dataVisualizerIndexBased.assertRecognizerCardNotExists(ecExpectedModuleId); - await ml.dataVisualizerIndexBased.assertCreateDataFrameAnalyticsCardNotExists(); + // @TODO: Re-enable in follow up + // await ml.testExecution.logTestStep('should not display job cards'); + // await ml.dataVisualizerIndexBased.assertCreateAdvancedJobCardNotExists(); + // await ml.dataVisualizerIndexBased.assertRecognizerCardNotExists(ecExpectedModuleId); + // await ml.dataVisualizerIndexBased.assertCreateDataFrameAnalyticsCardNotExists(); }); it('should display elements on File Data Visualizer page correctly', async () => { diff --git a/x-pack/test/functional_basic/apps/ml/permissions/read_ml_access.ts b/x-pack/test/functional_basic/apps/ml/permissions/read_ml_access.ts index f207b79582004..ce72a25a2ee37 100644 --- a/x-pack/test/functional_basic/apps/ml/permissions/read_ml_access.ts +++ b/x-pack/test/functional_basic/apps/ml/permissions/read_ml_access.ts @@ -25,7 +25,8 @@ export default function ({ getService }: FtrProviderContext) { describe(`(${testUser.user})`, function () { const ecIndexPattern = 'ft_module_sample_ecommerce'; const ecExpectedTotalCount = '287'; - const ecExpectedModuleId = 'sample_data_ecommerce'; + // @TODO: Re-enable in follow up + // const ecExpectedModuleId = 'sample_data_ecommerce'; const uploadFilePath = path.join( __dirname, @@ -135,13 +136,16 @@ export default function ({ getService }: FtrProviderContext) { testUser.discoverAvailable ? 'with' : 'without' } Discover card` ); - await ml.dataVisualizerIndexBased.assertActionsPanelExists(); + if (testUser.discoverAvailable) { + await ml.dataVisualizerIndexBased.assertActionsPanelExists(); + } await ml.dataVisualizerIndexBased.assertViewInDiscoverCard(testUser.discoverAvailable); - await ml.testExecution.logTestStep('should not display job cards'); - await ml.dataVisualizerIndexBased.assertCreateAdvancedJobCardNotExists(); - await ml.dataVisualizerIndexBased.assertRecognizerCardNotExists(ecExpectedModuleId); - await ml.dataVisualizerIndexBased.assertCreateDataFrameAnalyticsCardNotExists(); + // @TODO: Re-enable in follow up + // await ml.testExecution.logTestStep('should not display job cards'); + // await ml.dataVisualizerIndexBased.assertCreateAdvancedJobCardNotExists(); + // await ml.dataVisualizerIndexBased.assertRecognizerCardNotExists(ecExpectedModuleId); + // await ml.dataVisualizerIndexBased.assertCreateDataFrameAnalyticsCardNotExists(); }); it('should display elements on File Data Visualizer page correctly', async () => { From 87dde4cb2d17df9e9487f4118a07466a3227c7fe Mon Sep 17 00:00:00 2001 From: gchaps <33642766+gchaps@users.noreply.github.com> Date: Tue, 8 Jun 2021 13:17:59 -0700 Subject: [PATCH 02/19] [DOCS] Adds link to video landing page (#101413) --- docs/index-extra-title-page.html | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/index-extra-title-page.html b/docs/index-extra-title-page.html index 06d8c0b2e827b..7bcbc9f075124 100644 --- a/docs/index-extra-title-page.html +++ b/docs/index-extra-title-page.html @@ -1,5 +1,6 @@

From creating beautiful visualizations to managing the Elastic Stack, learn how Kibana helps you get the most of your data.

+

Watch our videos

@@ -11,8 +12,8 @@ From 3c68a0c8108804506e4abec933167f83878d5a28 Mon Sep 17 00:00:00 2001 From: spalger Date: Tue, 8 Jun 2021 13:30:42 -0700 Subject: [PATCH 03/19] [xpack/test] restore incremental: false in ts project --- x-pack/test/tsconfig.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/x-pack/test/tsconfig.json b/x-pack/test/tsconfig.json index 0424891064cd3..be7d9221e7ab2 100644 --- a/x-pack/test/tsconfig.json +++ b/x-pack/test/tsconfig.json @@ -6,7 +6,9 @@ "emitDeclarationOnly": true, "declaration": true, "declarationMap": true, - "types": ["node"] + "types": ["node"], + // overhead is too significant + "incremental": false, }, "include": [ "**/*", From 8699803255dfc765245ce43431e4a3749c4b4632 Mon Sep 17 00:00:00 2001 From: Kevin Logan <56395104+kevinlog@users.noreply.github.com> Date: Tue, 8 Jun 2021 17:17:19 -0400 Subject: [PATCH 04/19] [Security Solution] Remove Host Isolation feature flag (#101655) --- .../common/experimental_features.ts | 1 - .../public/common/mock/global_state.ts | 1 - .../side_panel/event_details/index.tsx | 28 ++++++++----------- .../factory/hosts/details/index.test.tsx | 1 - 4 files changed, 11 insertions(+), 20 deletions(-) diff --git a/x-pack/plugins/security_solution/common/experimental_features.ts b/x-pack/plugins/security_solution/common/experimental_features.ts index 02006fdb29d47..b20b1501eecc5 100644 --- a/x-pack/plugins/security_solution/common/experimental_features.ts +++ b/x-pack/plugins/security_solution/common/experimental_features.ts @@ -14,7 +14,6 @@ export type ExperimentalFeatures = typeof allowedExperimentalValues; const allowedExperimentalValues = Object.freeze({ trustedAppsByPolicyEnabled: false, metricsEntitiesEnabled: false, - hostIsolationEnabled: false, ruleRegistryEnabled: false, }); diff --git a/x-pack/plugins/security_solution/public/common/mock/global_state.ts b/x-pack/plugins/security_solution/public/common/mock/global_state.ts index 71e33c603b65b..557c04e4e8a47 100644 --- a/x-pack/plugins/security_solution/public/common/mock/global_state.ts +++ b/x-pack/plugins/security_solution/public/common/mock/global_state.ts @@ -42,7 +42,6 @@ export const mockGlobalState: State = { enableExperimental: { trustedAppsByPolicyEnabled: false, metricsEntitiesEnabled: false, - hostIsolationEnabled: false, ruleRegistryEnabled: false, }, }, diff --git a/x-pack/plugins/security_solution/public/timelines/components/side_panel/event_details/index.tsx b/x-pack/plugins/security_solution/public/timelines/components/side_panel/event_details/index.tsx index 341397da09e1d..76341055f28ef 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/side_panel/event_details/index.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/side_panel/event_details/index.tsx @@ -31,7 +31,6 @@ import { UNISOLATE_HOST, } from '../../../../detections/components/host_isolation/translations'; import { ALERT_DETAILS } from './translations'; -import { useIsExperimentalFeatureEnabled } from '../../../../common/hooks/use_experimental_features'; import { useIsolationPrivileges } from '../../../../common/hooks/endpoint/use_isolate_privileges'; const StyledEuiFlyoutBody = styled(EuiFlyoutBody)` @@ -74,8 +73,6 @@ const EventDetailsPanelComponent: React.FC = ({ skip: !expandedEvent.eventId, }); - const isHostIsolationEnabled = useIsExperimentalFeatureEnabled('hostIsolationEnabled'); - const [isHostIsolationPanelOpen, setIsHostIsolationPanel] = useState(false); const [isolateAction, setIsolateAction] = useState('isolateHost'); @@ -156,20 +153,17 @@ const EventDetailsPanelComponent: React.FC = ({ /> )} - {isIsolationAllowed && - isHostIsolationEnabled && - isEndpointAlert && - isHostIsolationPanelOpen === false && ( - - - - - - - - - - )} + {isIsolationAllowed && isEndpointAlert && isHostIsolationPanelOpen === false && ( + + + + + + + + + + )} ) : ( <> diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/details/index.test.tsx b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/details/index.test.tsx index f489fd0c16455..b50623bf9090a 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/details/index.test.tsx +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/details/index.test.tsx @@ -32,7 +32,6 @@ const mockDeps = { experimentalFeatures: { trustedAppsByPolicyEnabled: false, metricsEntitiesEnabled: false, - hostIsolationEnabled: false, ruleRegistryEnabled: false, }, service: {} as EndpointAppContextService, From 686ade7808624869855cde49af01fa8ab705d876 Mon Sep 17 00:00:00 2001 From: spalger Date: Tue, 8 Jun 2021 14:26:26 -0700 Subject: [PATCH 05/19] Revert "[xpack/test] restore incremental: false in ts project" This reverts commit 3c68a0c8108804506e4abec933167f83878d5a28. --- x-pack/test/tsconfig.json | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/x-pack/test/tsconfig.json b/x-pack/test/tsconfig.json index be7d9221e7ab2..0424891064cd3 100644 --- a/x-pack/test/tsconfig.json +++ b/x-pack/test/tsconfig.json @@ -6,9 +6,7 @@ "emitDeclarationOnly": true, "declaration": true, "declarationMap": true, - "types": ["node"], - // overhead is too significant - "incremental": false, + "types": ["node"] }, "include": [ "**/*", From f466ebf1a3fc33ea09ea51853811fe3a8f77c1d2 Mon Sep 17 00:00:00 2001 From: Spencer Date: Tue, 8 Jun 2021 14:37:42 -0700 Subject: [PATCH 06/19] [esArchiver] drop support for --dir, use repo-relative paths instead (#101345) Co-authored-by: spalger --- .../development-functional-tests.asciidoc | 12 +- .../external-plugin-functional-tests.asciidoc | 5 - packages/kbn-es-archiver/src/actions/edit.ts | 20 ++- packages/kbn-es-archiver/src/actions/load.ts | 12 +- .../src/actions/rebuild_all.ts | 21 +--- packages/kbn-es-archiver/src/actions/save.ts | 12 +- .../kbn-es-archiver/src/actions/unload.ts | 12 +- packages/kbn-es-archiver/src/cli.ts | 95 +++++++------- packages/kbn-es-archiver/src/es_archiver.ts | 119 ++++++++++-------- .../lib/config/schema.ts | 7 -- src/core/TESTING.md | 4 +- test/accessibility/apps/discover.ts | 6 +- test/accessibility/apps/management.ts | 6 +- test/accessibility/apps/visualize.ts | 2 +- .../apis/index_patterns/es_errors/errors.js | 6 +- .../fields_api/update_fields/main.ts | 6 +- .../fields_for_time_pattern_route/pattern.js | 8 +- .../query_params.js | 8 +- .../fields_for_wildcard_route/conflicts.js | 8 +- .../fields_for_wildcard_route/params.js | 8 +- .../fields_for_wildcard_route/response.js | 8 +- .../create_index_pattern/main.ts | 8 +- .../create_scripted_field/main.ts | 6 +- .../delete_scripted_field/errors.ts | 6 +- .../delete_scripted_field/main.ts | 6 +- .../get_scripted_field/errors.ts | 6 +- .../get_scripted_field/main.ts | 6 +- .../put_scripted_field/main.ts | 6 +- .../update_scripted_field/main.ts | 6 +- .../apis/saved_objects_management/find.ts | 10 +- .../saved_objects_management/scroll_count.ts | 8 +- test/api_integration/apis/search/bsearch.ts | 6 +- test/api_integration/apis/search/search.ts | 4 +- .../apis/suggestions/suggestions.js | 6 +- test/common/services/es_archiver.ts | 7 -- test/examples/config.js | 5 +- test/examples/embeddables/dashboard.ts | 6 +- test/functional/apps/context/_date_nanos.js | 4 +- .../context/_date_nanos_custom_timestamp.js | 4 +- test/functional/apps/context/index.js | 6 +- .../apps/dashboard/copy_panel_to.ts | 2 +- .../dashboard/create_and_add_embeddables.ts | 2 +- .../apps/dashboard/dashboard_back_button.ts | 4 +- .../dashboard/dashboard_error_handling.ts | 4 +- .../apps/dashboard/dashboard_filter_bar.ts | 2 +- .../apps/dashboard/dashboard_filtering.ts | 2 +- .../apps/dashboard/dashboard_grid.ts | 2 +- .../apps/dashboard/dashboard_options.ts | 2 +- .../apps/dashboard/dashboard_query_bar.ts | 4 +- .../apps/dashboard/dashboard_saved_query.ts | 2 +- .../apps/dashboard/dashboard_snapshots.ts | 2 +- .../dashboard/dashboard_unsaved_listing.ts | 2 +- .../apps/dashboard/dashboard_unsaved_state.ts | 2 +- .../apps/dashboard/data_shared_attributes.ts | 2 +- .../dashboard/edit_embeddable_redirects.ts | 2 +- .../apps/dashboard/edit_visualizations.js | 2 +- test/functional/apps/dashboard/embed_mode.ts | 2 +- .../apps/dashboard/embeddable_data_grid.ts | 8 +- .../apps/dashboard/embeddable_library.ts | 2 +- .../apps/dashboard/embeddable_rendering.ts | 2 +- .../apps/dashboard/empty_dashboard.ts | 2 +- .../apps/dashboard/full_screen_mode.ts | 2 +- test/functional/apps/dashboard/index.ts | 10 +- test/functional/apps/dashboard/legacy_urls.ts | 2 +- .../apps/dashboard/panel_expand_toggle.ts | 2 +- .../apps/dashboard/saved_search_embeddable.ts | 8 +- test/functional/apps/dashboard/share.ts | 2 +- test/functional/apps/dashboard/time_zones.ts | 2 +- .../apps/dashboard/url_field_formatter.ts | 2 +- test/functional/apps/dashboard/view_edit.ts | 2 +- test/functional/apps/discover/_data_grid.ts | 2 +- .../apps/discover/_data_grid_context.ts | 2 +- .../discover/_data_grid_doc_navigation.ts | 4 +- .../apps/discover/_data_grid_doc_table.ts | 2 +- .../apps/discover/_data_grid_field_data.ts | 2 +- test/functional/apps/discover/_date_nanos.ts | 4 +- .../apps/discover/_date_nanos_mixed.ts | 4 +- test/functional/apps/discover/_discover.ts | 2 +- .../apps/discover/_discover_fields_api.ts | 2 +- .../apps/discover/_discover_histogram.ts | 14 ++- .../apps/discover/_doc_navigation.ts | 4 +- test/functional/apps/discover/_doc_table.ts | 2 +- test/functional/apps/discover/_errors.ts | 6 +- test/functional/apps/discover/_field_data.ts | 2 +- .../discover/_field_data_with_fields_api.ts | 2 +- .../apps/discover/_filter_editor.ts | 2 +- test/functional/apps/discover/_huge_fields.ts | 4 +- .../_indexpattern_with_unmapped_fields.ts | 4 +- .../_indexpattern_without_timefield.ts | 8 +- test/functional/apps/discover/_inspector.ts | 2 +- .../functional/apps/discover/_large_string.ts | 4 +- .../apps/discover/_runtime_fields_editor.ts | 4 +- .../apps/discover/_saved_queries.ts | 2 +- .../functional/apps/discover/_shared_links.ts | 2 +- test/functional/apps/discover/_sidebar.ts | 4 +- .../apps/discover/_source_filters.ts | 4 +- test/functional/apps/discover/index.ts | 2 +- .../apps/getting_started/_shakespeare.ts | 8 +- test/functional/apps/home/_navigation.ts | 4 +- .../apps/management/_field_formatter.js | 2 +- .../apps/management/_handle_alias.js | 6 +- .../management/_handle_version_conflict.js | 2 +- .../apps/management/_import_objects.ts | 8 +- .../apps/management/_index_patterns_empty.ts | 6 +- .../management/_mgmt_import_saved_objects.js | 4 +- .../apps/management/_runtime_fields.js | 2 +- .../apps/management/_scripted_fields.js | 2 +- .../management/_scripted_fields_filter.js | 4 +- .../apps/management/_test_huge_fields.js | 4 +- test/functional/apps/management/index.ts | 6 +- .../edit_saved_object.ts | 8 +- .../show_relationships.ts | 8 +- test/functional/apps/timelion/index.js | 2 +- .../visualize/_histogram_request_start.ts | 6 +- test/functional/apps/visualize/_tsvb_chart.ts | 6 +- test/functional/apps/visualize/index.ts | 6 +- .../input_control_vis/input_control_range.ts | 8 +- .../functional/apps/visualize/legacy/index.ts | 4 +- .../functional/page_objects/dashboard_page.ts | 5 +- test/functional/page_objects/timelion_page.ts | 2 +- test/interpreter_functional/config.ts | 3 - .../test_suites/run_pipeline/index.ts | 4 +- .../new_visualize_flow/dashboard_embedding.ts | 2 +- test/new_visualize_flow/index.ts | 4 +- test/plugin_functional/config.ts | 3 - .../test_suites/core/deprecations.ts | 4 +- .../custom_visualizations/index.js | 4 +- .../test_suites/data_plugin/index.ts | 2 +- .../test_suites/data_plugin/session.ts | 10 +- .../test_suites/doc_views/index.ts | 2 +- .../test_suites/panel_actions/index.js | 19 +-- .../saved_objects_hidden_type/delete.ts | 4 +- .../saved_objects_hidden_type/export.ts | 4 +- .../saved_objects_hidden_type/find.ts | 4 +- .../saved_objects_hidden_type/import.ts | 4 +- .../resolve_import_errors.ts | 4 +- .../export_transform.ts | 8 +- .../saved_objects_management/find.ts | 4 +- .../saved_objects_management/get.ts | 4 +- .../saved_objects_management/hidden_types.ts | 4 +- .../saved_objects_management/scroll_count.ts | 4 +- test/security_functional/config.ts | 3 - .../insecure_cluster_warning.ts | 10 +- .../tests/discover/chart_visualization.ts | 6 +- .../tests/vega/vega_map_visualization.ts | 10 +- x-pack/plugins/apm/ftr_e2e/config.ts | 4 - .../apm/ftr_e2e/cypress/tasks/es_archiver.ts | 10 +- .../cypress/tasks/es_archiver.ts | 21 ++-- x-pack/test/accessibility/apps/canvas.ts | 2 +- .../apps/dashboard_edit_panel.ts | 6 +- .../accessibility/apps/kibana_overview.ts | 4 +- x-pack/test/accessibility/apps/lens.ts | 8 +- x-pack/test/accessibility/apps/login_page.ts | 4 +- x-pack/test/accessibility/apps/ml.ts | 14 ++- .../apps/ml_embeddables_in_dashboard.ts | 4 +- x-pack/test/accessibility/apps/roles.ts | 4 +- x-pack/test/accessibility/apps/spaces.ts | 2 +- x-pack/test/accessibility/apps/transform.ts | 4 +- x-pack/test/accessibility/apps/uptime.ts | 4 +- x-pack/test/accessibility/apps/users.ts | 2 +- .../alerting_api_integration/common/config.ts | 1 - .../tests/alerting/rbac_legacy.ts | 4 +- .../security_and_spaces/tests/index.ts | 2 +- .../spaces_only/tests/actions/migrations.ts | 4 +- .../tests/actions/type_not_enabled.ts | 4 +- .../spaces_only/tests/alerting/migrations.ts | 4 +- .../spaces_only/tests/index.ts | 2 +- .../spaces_only_legacy/tests/index.ts | 2 +- .../apis/file_upload/index_exists.ts | 4 +- .../apis/lens/existing_fields.ts | 8 +- .../api_integration/apis/lens/field_stats.ts | 14 ++- .../api_integration/apis/lens/telemetry.ts | 4 +- .../apis/lists/create_exception_list_item.ts | 4 +- .../apis/logstash/pipeline/delete.ts | 2 +- .../apis/logstash/pipeline/load.ts | 2 +- .../apis/logstash/pipeline/save.ts | 2 +- .../apis/logstash/pipelines/delete.ts | 2 +- .../apis/logstash/pipelines/list.ts | 2 +- .../test/api_integration/apis/maps/index.js | 4 +- .../api_integration/apis/maps/migrations.js | 4 +- .../apis/metrics_ui/http_source.ts | 8 +- .../apis/metrics_ui/ip_to_hostname.ts | 4 +- .../apis/metrics_ui/log_entry_highlights.ts | 8 +- .../apis/metrics_ui/log_sources.ts | 8 +- .../apis/metrics_ui/log_summary.ts | 4 +- .../apis/metrics_ui/metadata.ts | 11 +- .../apis/metrics_ui/metrics.ts | 4 +- .../apis/metrics_ui/metrics_explorer.ts | 4 +- .../apis/metrics_ui/snapshot.ts | 16 ++- .../apis/metrics_ui/sources.ts | 8 +- .../apis/ml/annotations/create_annotations.ts | 2 +- .../apis/ml/annotations/delete_annotations.ts | 2 +- .../apis/ml/annotations/get_annotations.ts | 2 +- .../apis/ml/annotations/update_annotations.ts | 2 +- .../apis/ml/anomaly_detectors/create.ts | 2 +- .../apis/ml/anomaly_detectors/get.ts | 2 +- .../ml/data_frame_analytics/create_job.ts | 2 +- .../apis/ml/data_frame_analytics/delete.ts | 2 +- .../ml/data_frame_analytics/delete_spaces.ts | 2 +- .../apis/ml/data_frame_analytics/evaluate.ts | 4 +- .../apis/ml/data_frame_analytics/explain.ts | 6 +- .../apis/ml/data_frame_analytics/get.ts | 2 +- .../ml/data_frame_analytics/get_spaces.ts | 2 +- .../apis/ml/data_frame_analytics/start.ts | 2 +- .../ml/data_frame_analytics/start_spaces.ts | 2 +- .../apis/ml/data_frame_analytics/stop.ts | 2 +- .../ml/data_frame_analytics/stop_spaces.ts | 2 +- .../apis/ml/data_frame_analytics/update.ts | 2 +- .../ml/data_frame_analytics/update_spaces.ts | 2 +- .../apis/ml/data_frame_analytics/validate.ts | 2 +- .../data_visualizer/get_field_histograms.ts | 2 +- .../ml/data_visualizer/get_field_stats.ts | 2 +- .../ml/data_visualizer/get_overall_stats.ts | 2 +- .../ml/fields_service/field_cardinality.ts | 2 +- .../ml/fields_service/time_field_range.ts | 2 +- x-pack/test/api_integration/apis/ml/index.ts | 44 +++---- .../job_validation/bucket_span_estimator.ts | 2 +- .../calculate_model_memory_limit.ts | 2 +- .../apis/ml/job_validation/cardinality.ts | 2 +- .../apis/ml/job_validation/validate.ts | 2 +- .../ml/jobs/categorization_field_examples.ts | 2 +- .../apis/ml/jobs/close_jobs.ts | 2 +- .../apis/ml/jobs/datafeed_preview.ts | 2 +- .../apis/ml/jobs/delete_jobs.ts | 2 +- .../apis/ml/jobs/jobs_exist.ts | 2 +- .../apis/ml/jobs/jobs_summary.ts | 2 +- .../apis/ml/modules/recognize_module.ts | 34 ++--- .../apis/ml/modules/setup_module.ts | 48 +++---- .../ml/results/get_anomalies_table_data.ts | 2 +- .../apis/ml/results/get_categorizer_stats.ts | 2 +- .../apis/ml/results/get_stopped_partitions.ts | 2 +- .../apis/ml/saved_objects/initialize.ts | 2 +- .../apis/ml/saved_objects/jobs_spaces.ts | 2 +- .../apis/ml/saved_objects/status.ts | 2 +- .../ml/saved_objects/update_jobs_spaces.ts | 2 +- .../apis/monitoring/apm/instance.js | 2 +- .../apis/monitoring/apm/instance_mb.js | 2 +- .../apis/monitoring/apm/instances.js | 2 +- .../apis/monitoring/apm/instances_mb.js | 2 +- .../apis/monitoring/apm/overview.js | 2 +- .../apis/monitoring/apm/overview_mb.js | 2 +- .../apis/monitoring/beats/detail.js | 2 +- .../apis/monitoring/beats/detail_mb.js | 3 +- .../apis/monitoring/beats/list.js | 2 +- .../apis/monitoring/beats/list_mb.js | 3 +- .../apis/monitoring/beats/overview.js | 2 +- .../apis/monitoring/beats/overview_mb.js | 2 +- .../apis/monitoring/cluster/list.js | 2 +- .../apis/monitoring/cluster/list_mb.js | 2 +- .../apis/monitoring/cluster/overview.js | 2 +- .../apis/monitoring/cluster/overview_mb.js | 2 +- .../apis/monitoring/elasticsearch/ccr.js | 2 +- .../apis/monitoring/elasticsearch/ccr_mb.js | 2 +- .../monitoring/elasticsearch/ccr_shard.js | 2 +- .../monitoring/elasticsearch/ccr_shard_mb.js | 2 +- .../monitoring/elasticsearch/index_detail.js | 3 +- .../elasticsearch/index_detail_mb.js | 3 +- .../apis/monitoring/elasticsearch/indices.js | 5 +- .../monitoring/elasticsearch/indices_mb.js | 5 +- .../monitoring/elasticsearch/node_detail.js | 3 +- .../elasticsearch/node_detail_advanced.js | 3 +- .../elasticsearch/node_detail_advanced_mb.js | 3 +- .../elasticsearch/node_detail_mb.js | 3 +- .../apis/monitoring/elasticsearch/nodes.js | 13 +- .../apis/monitoring/elasticsearch/nodes_mb.js | 14 ++- .../apis/monitoring/elasticsearch/overview.js | 7 +- .../monitoring/elasticsearch/overview_mb.js | 8 +- .../apis/monitoring/kibana/instance.js | 2 +- .../apis/monitoring/kibana/instance_mb.js | 3 +- .../apis/monitoring/kibana/listing.js | 2 +- .../apis/monitoring/kibana/listing_mb.js | 3 +- .../apis/monitoring/kibana/overview.js | 2 +- .../apis/monitoring/kibana/overview_mb.js | 3 +- .../apis/monitoring/logs/cluster.js | 2 +- .../apis/monitoring/logs/index_detail.js | 2 +- .../apis/monitoring/logs/multiple_clusters.js | 2 +- .../apis/monitoring/logs/node_detail.js | 2 +- .../logstash/multicluster_pipelines.js | 2 +- .../logstash/multicluster_pipelines_mb.js | 3 +- .../apis/monitoring/logstash/node_detail.js | 2 +- .../monitoring/logstash/node_detail_mb.js | 2 +- .../apis/monitoring/logstash/nodes.js | 2 +- .../apis/monitoring/logstash/nodes_mb.js | 2 +- .../apis/monitoring/logstash/overview.js | 2 +- .../apis/monitoring/logstash/overview_mb.js | 2 +- .../apis/monitoring/logstash/pipelines.js | 2 +- .../apis/monitoring/logstash/pipelines_mb.js | 2 +- .../apis/monitoring/setup/collection/ccs.js | 2 +- .../monitoring/setup/collection/detect_apm.js | 2 +- .../setup/collection/detect_beats.js | 2 +- .../collection/detect_beats_management.js | 3 +- .../setup/collection/detect_logstash.js | 3 +- .../collection/detect_logstash_management.js | 3 +- .../setup/collection/es_and_kibana.js | 2 +- .../collection/es_and_kibana_exclusive.js | 3 +- .../collection/es_and_kibana_exclusive_mb.js | 3 +- .../setup/collection/es_and_kibana_mb.js | 3 +- .../monitoring/setup/collection/kibana.js | 2 +- .../setup/collection/kibana_exclusive.js | 3 +- .../setup/collection/kibana_exclusive_mb.js | 3 +- .../monitoring/setup/collection/kibana_mb.js | 2 +- .../monitoring/setup/collection/security.js | 3 +- .../monitoring/standalone_cluster/cluster.js | 2 +- .../monitoring/standalone_cluster/clusters.js | 2 +- .../api_integration/apis/search/search.ts | 4 +- .../apis/security/index_fields.ts | 4 +- .../apis/security_solution/authentications.ts | 4 +- .../apis/security_solution/events.ts | 4 +- .../apis/security_solution/host_details.ts | 4 +- .../apis/security_solution/hosts.ts | 4 +- .../apis/security_solution/kpi_hosts.ts | 8 +- .../apis/security_solution/kpi_network.ts | 8 +- .../security_solution/matrix_dns_histogram.ts | 12 +- .../apis/security_solution/network_details.ts | 8 +- .../apis/security_solution/network_dns.ts | 4 +- .../security_solution/network_top_n_flow.ts | 4 +- .../apis/security_solution/overview_host.ts | 4 +- .../security_solution/overview_network.ts | 12 +- .../security_solution/saved_objects/notes.ts | 4 +- .../saved_objects/pinned_events.ts | 4 +- .../saved_objects/timeline.ts | 4 +- .../apis/security_solution/sources.ts | 4 +- .../security_solution/timeline_details.ts | 4 +- .../apis/security_solution/tls.ts | 8 +- .../security_solution/uncommon_processes.ts | 8 +- .../apis/security_solution/users.ts | 4 +- .../apis/telemetry/telemetry.ts | 4 +- .../apis/transform/delete_transforms.ts | 2 +- .../api_integration/apis/transform/index.ts | 2 +- .../apis/transform/start_transforms.ts | 2 +- .../apis/transform/stop_transforms.ts | 2 +- .../apis/transform/transforms.ts | 2 +- .../apis/transform/transforms_create.ts | 2 +- .../apis/transform/transforms_preview.ts | 2 +- .../apis/transform/transforms_stats.ts | 2 +- .../apis/transform/transforms_update.ts | 2 +- .../apis/uptime/get_all_pings.ts | 2 +- .../api_integration/apis/uptime/rest/certs.ts | 2 +- .../api_integration/apis/uptime/rest/index.ts | 22 +++- .../uptime/rest/monitor_states_generated.ts | 14 ++- .../apis/uptime/rest/ping_list.ts | 8 +- .../apis/uptime/rest/telemetry_collectors.ts | 4 +- .../uptime/rest/telemetry_collectors_fleet.ts | 8 +- .../apis/xpack_legacy/settings/settings.js | 2 +- x-pack/test/api_integration/config.ts | 1 - .../api_integration_basic/apis/ml/index.ts | 2 +- .../test/apm_api_integration/common/config.ts | 4 - .../apm_api_integration/common/registry.ts | 15 ++- x-pack/test/banners_functional/config.ts | 5 - .../test/banners_functional/tests/spaces.ts | 4 +- .../case_api_integration/common/config.ts | 1 - .../tests/common/cases/migrations.ts | 8 +- .../tests/common/cases/patch_cases.ts | 12 +- .../common/client/update_alert_status.ts | 4 +- .../tests/common/comments/migrations.ts | 4 +- .../tests/common/comments/post_comment.ts | 4 +- .../tests/common/configure/migrations.ts | 4 +- .../tests/common/connectors/case.ts | 4 +- .../tests/common/sub_cases/patch_sub_cases.ts | 4 +- .../tests/common/user_actions/migrations.ts | 4 +- .../basic/tests/create_rules.ts | 4 +- .../basic/tests/create_rules_bulk.ts | 4 +- .../basic/tests/find_statuses.ts | 4 +- .../basic/tests/open_close_signals.ts | 4 +- .../common/config.ts | 1 - .../security_and_spaces/tests/add_actions.ts | 4 +- .../security_and_spaces/tests/aliases.ts | 4 +- .../tests/create_exceptions.ts | 8 +- .../security_and_spaces/tests/create_ml.ts | 8 +- .../security_and_spaces/tests/create_rules.ts | 12 +- .../tests/create_rules_bulk.ts | 4 +- .../tests/create_signals_migrations.ts | 8 +- .../tests/create_threat_matching.ts | 12 +- .../tests/delete_signals_migrations.ts | 4 +- .../exception_operators_data_types/date.ts | 4 +- .../exception_operators_data_types/double.ts | 10 +- .../exception_operators_data_types/float.ts | 8 +- .../exception_operators_data_types/integer.ts | 10 +- .../exception_operators_data_types/ip.ts | 4 +- .../ip_array.ts | 4 +- .../exception_operators_data_types/keyword.ts | 4 +- .../keyword_array.ts | 6 +- .../exception_operators_data_types/long.ts | 8 +- .../exception_operators_data_types/text.ts | 8 +- .../text_array.ts | 4 +- .../tests/finalize_signals_migrations.ts | 8 +- .../tests/find_statuses.ts | 4 +- .../tests/generating_signals.ts | 22 ++-- .../tests/get_signals_migration_status.ts | 8 +- .../tests/keyword_family/const_keyword.ts | 6 +- .../tests/keyword_family/keyword.ts | 4 +- .../keyword_mixed_with_const.ts | 10 +- .../tests/open_close_signals.ts | 4 +- .../security_and_spaces/tests/timestamps.ts | 52 +++++--- .../tests/update_actions.ts | 4 +- .../config.ts | 3 - .../tests/encrypted_saved_objects_api.ts | 16 ++- .../apis/metadata.ts | 10 +- x-pack/test/examples/search_examples/index.ts | 6 +- .../apis/agent_policy/agent_policy.ts | 16 +-- .../agent_policy_with_agents_setup.ts | 4 +- .../apis/agents/actions.ts | 4 +- .../apis/agents/delete.ts | 4 +- .../fleet_api_integration/apis/agents/list.ts | 4 +- .../apis/agents/reassign.ts | 12 +- .../apis/agents/status.ts | 4 +- .../apis/agents/unenroll.ts | 12 +- .../apis/agents/upgrade.ts | 8 +- .../apis/enrollment_api_keys/crud.ts | 4 +- .../apis/epm/final_pipeline.ts | 4 +- .../apis/epm/install_error_rollback.ts | 4 +- .../fleet_api_integration/apis/epm/list.ts | 4 +- .../fleet_api_integration/apis/fleet_setup.ts | 8 +- .../apis/outputs/crud.ts | 4 +- .../apis/package_policy/create.ts | 12 +- .../apis/package_policy/delete.ts | 12 +- .../apis/package_policy/get.ts | 12 +- .../apis/package_policy/update.ts | 12 +- .../apis/preconfiguration/preconfiguration.ts | 12 +- .../apis/service_tokens.ts | 4 +- .../apis/settings/update.ts | 4 +- x-pack/test/fleet_api_integration/config.ts | 1 - .../advanced_settings_security.ts | 4 +- .../advanced_settings_spaces.ts | 10 +- .../feature_controls/api_keys_security.ts | 4 +- .../apps/apm/feature_controls/apm_security.ts | 2 +- .../functional/apps/canvas/custom_elements.ts | 2 +- .../test/functional/apps/canvas/expression.ts | 2 +- .../feature_controls/canvas_security.ts | 4 +- .../canvas/feature_controls/canvas_spaces.ts | 10 +- x-pack/test/functional/apps/canvas/filters.ts | 2 +- x-pack/test/functional/apps/canvas/index.js | 2 +- x-pack/test/functional/apps/canvas/lens.ts | 2 +- x-pack/test/functional/apps/canvas/reports.ts | 4 +- .../test/functional/apps/canvas/smoke_test.js | 2 +- .../feature_controls/ccr_security.ts | 4 +- .../apps/dashboard/dashboard_lens_by_value.ts | 4 +- .../apps/dashboard/dashboard_maps_by_value.ts | 4 +- .../apps/dashboard/drilldowns/index.ts | 6 +- .../feature_controls/dashboard_security.ts | 10 +- .../feature_controls/dashboard_spaces.ts | 18 ++- .../time_to_visualize_security.ts | 10 +- .../functional/apps/dashboard/preserve_url.ts | 4 +- .../apps/dashboard/reporting/download_csv.ts | 12 +- .../apps/dashboard/reporting/screenshots.ts | 10 +- .../functional/apps/dashboard/sync_colors.ts | 8 +- .../dashboard_mode/dashboard_empty_screen.js | 4 +- .../dashboard_mode/dashboard_view_mode.js | 4 +- .../feature_controls/dev_tools_security.ts | 2 +- .../feature_controls/dev_tools_spaces.ts | 4 +- .../apps/discover/async_scripted_fields.js | 10 +- .../apps/discover/error_handling.ts | 6 +- .../feature_controls/discover_security.ts | 10 +- .../feature_controls/discover_spaces.ts | 22 ++-- .../functional/apps/discover/preserve_url.ts | 4 +- .../functional/apps/discover/reporting.ts | 18 +-- .../apps/discover/saved_searches.ts | 8 +- .../apps/discover/value_suggestions.ts | 6 +- .../apps/discover/visualize_field.ts | 6 +- .../graph/feature_controls/graph_security.ts | 2 +- .../graph/feature_controls/graph_spaces.ts | 2 +- x-pack/test/functional/apps/graph/graph.ts | 4 +- .../apps/grok_debugger/grok_debugger.js | 2 +- .../home/feature_controls/home_security.ts | 10 +- .../feature_controls/ilm_security.ts | 4 +- .../index_management_security.ts | 4 +- .../index_patterns_security.ts | 4 +- .../feature_controls/index_patterns_spaces.ts | 10 +- .../infrastructure_security.ts | 16 +-- .../feature_controls/infrastructure_spaces.ts | 16 +-- .../infra/feature_controls/logs_security.ts | 2 +- .../infra/feature_controls/logs_spaces.ts | 8 +- .../test/functional/apps/infra/home_page.ts | 14 ++- .../apps/infra/logs_source_configuration.ts | 8 +- .../apps/infra/metrics_anomalies.ts | 8 +- .../infra/metrics_source_configuration.ts | 8 +- .../ingest_pipelines_security.ts | 4 +- x-pack/test/functional/apps/lens/index.ts | 8 +- .../functional/apps/lens/lens_reporting.ts | 4 +- .../test/functional/apps/lens/lens_tagging.ts | 4 +- x-pack/test/functional/apps/lens/rollup.ts | 8 +- .../license_management_security.ts | 4 +- .../feature_controls/logstash_security.ts | 4 +- .../apps/logstash/pipeline_create.js | 4 +- .../functional/apps/logstash/pipeline_list.js | 4 +- .../feature_controls/management_security.ts | 4 +- x-pack/test/functional/apps/maps/index.js | 10 +- .../apps/ml/anomaly_detection/advanced_job.ts | 2 +- .../aggregated_scripted_job.ts | 4 +- .../apps/ml/anomaly_detection/annotations.ts | 2 +- .../ml/anomaly_detection/anomaly_explorer.ts | 2 +- .../anomaly_detection/categorization_job.ts | 2 +- .../apps/ml/anomaly_detection/custom_urls.ts | 2 +- .../ml/anomaly_detection/date_nanos_job.ts | 4 +- .../ml/anomaly_detection/multi_metric_job.ts | 2 +- .../ml/anomaly_detection/population_job.ts | 2 +- .../ml/anomaly_detection/saved_search_job.ts | 2 +- .../ml/anomaly_detection/single_metric_job.ts | 2 +- ...ingle_metric_job_without_datafeed_start.ts | 2 +- .../anomaly_detection/single_metric_viewer.ts | 4 +- .../classification_creation.ts | 2 +- .../apps/ml/data_frame_analytics/cloning.ts | 6 +- .../feature_importance.ts | 6 +- .../outlier_detection_creation.ts | 2 +- .../regression_creation.ts | 2 +- .../data_visualizer/index_data_visualizer.ts | 4 +- .../index_data_visualizer_actions_panel.ts | 2 +- .../anomaly_charts_dashboard_embeddables.ts | 2 +- x-pack/test/functional/apps/ml/index.ts | 32 ++--- .../apps/ml/permissions/full_ml_access.ts | 8 +- .../apps/ml/permissions/read_ml_access.ts | 8 +- .../apps/ml/settings/calendar_creation.ts | 2 +- .../apps/ml/settings/calendar_edit.ts | 2 +- .../apps/monitoring/beats/beat_detail.js | 2 +- .../apps/monitoring/beats/cluster.js | 2 +- .../apps/monitoring/beats/listing.js | 2 +- .../apps/monitoring/beats/overview.js | 2 +- .../apps/monitoring/cluster/list.js | 4 +- .../apps/monitoring/cluster/overview.js | 6 +- .../monitoring/elasticsearch/index_detail.js | 11 +- .../elasticsearch/index_detail_mb.js | 11 +- .../apps/monitoring/elasticsearch/indices.js | 2 +- .../monitoring/elasticsearch/indices_mb.js | 2 +- .../monitoring/elasticsearch/node_detail.js | 24 ++-- .../elasticsearch/node_detail_mb.js | 24 ++-- .../apps/monitoring/elasticsearch/nodes.js | 22 ++-- .../apps/monitoring/elasticsearch/nodes_mb.js | 22 ++-- .../apps/monitoring/elasticsearch/overview.js | 11 +- .../monitoring/elasticsearch/overview_mb.js | 11 +- .../apps/monitoring/elasticsearch/shards.js | 11 +- .../feature_controls/monitoring_security.ts | 4 +- .../feature_controls/monitoring_spaces.ts | 4 +- .../apps/monitoring/kibana/instance.js | 2 +- .../apps/monitoring/kibana/instance_mb.js | 11 +- .../apps/monitoring/kibana/instances.js | 2 +- .../apps/monitoring/kibana/instances_mb.js | 11 +- .../apps/monitoring/kibana/overview.js | 2 +- .../apps/monitoring/kibana/overview_mb.js | 11 +- .../apps/monitoring/logstash/pipelines.js | 2 +- .../apps/monitoring/logstash/pipelines_mb.js | 2 +- .../monitoring/setup/metricbeat_migration.js | 13 +- .../setup/metricbeat_migration_mb.js | 13 +- .../functional/apps/monitoring/time_filter.js | 2 +- .../remote_clusters_security.ts | 4 +- .../functional/apps/reporting/reporting.ts | 4 +- .../reporting_management/report_listing.ts | 8 +- .../apps/rollup_job/hybrid_index_pattern.js | 2 +- .../functional/apps/rollup_job/rollup_jobs.js | 2 +- .../test/functional/apps/rollup_job/tsvb.js | 4 +- .../saved_objects_management_security.ts | 8 +- .../import_saved_objects_between_versions.ts | 10 +- .../spaces_integration.ts | 8 +- .../apps/security/doc_level_security_roles.js | 4 +- .../apps/security/field_level_security.js | 4 +- .../apps/security/secure_roles_perm.js | 4 +- .../test/functional/apps/security/security.ts | 4 +- .../functional/apps/security/user_email.js | 2 +- .../apps/spaces/copy_saved_objects.ts | 4 +- .../functional/apps/spaces/enter_space.ts | 6 +- .../feature_controls/spaces_security.ts | 4 +- .../apps/spaces/spaces_selection.ts | 12 +- .../apps/status_page/status_page.ts | 4 +- .../feature_controls/timelion_security.ts | 4 +- .../feature_controls/timelion_spaces.ts | 10 +- .../test/functional/apps/transform/cloning.ts | 2 +- .../apps/transform/creation_index_pattern.ts | 2 +- .../transform/creation_runtime_mappings.ts | 2 +- .../apps/transform/creation_saved_search.ts | 2 +- .../functional/apps/transform/deleting.ts | 2 +- .../test/functional/apps/transform/editing.ts | 2 +- .../feature_controls/transform_security.ts | 4 +- .../test/functional/apps/transform/index.ts | 4 +- .../functional/apps/transform/starting.ts | 2 +- .../upgrade_assistant_security.ts | 4 +- .../upgrade_assistant/upgrade_assistant.ts | 4 +- .../feature_controls/uptime_security.ts | 2 +- x-pack/test/functional/apps/uptime/index.ts | 6 +- .../test/functional/apps/uptime/ml_anomaly.ts | 2 +- x-pack/test/functional/apps/uptime/monitor.ts | 2 +- .../test/functional/apps/uptime/overview.ts | 2 +- .../functional/apps/uptime/ping_redirects.ts | 2 +- .../feature_controls/visualize_security.ts | 6 +- .../feature_controls/visualize_spaces.ts | 10 +- .../apps/visualize/hybrid_visualization.ts | 12 +- .../apps/visualize/precalculated_histogram.ts | 4 +- .../functional/apps/visualize/preserve_url.ts | 4 +- .../functional/apps/visualize/reporting.ts | 10 +- x-pack/test/functional/config.js | 5 - .../test/functional/config_security_basic.ts | 5 - .../functional/page_objects/security_page.ts | 4 +- .../services/dashboard/drilldowns_manage.ts | 4 +- .../index_data_visualizer_actions_panel.ts | 2 +- x-pack/test/functional_basic/apps/ml/index.ts | 4 +- .../apps/ml/permissions/full_ml_access.ts | 4 +- .../apps/ml/permissions/read_ml_access.ts | 4 +- .../app_search/engines.ts | 4 +- .../app_search/setup_guide.ts | 4 +- .../workplace_search/setup_guide.ts | 4 +- .../apps/visualization_wizard.ts | 8 +- .../apps/ml/alert_flyout.ts | 2 +- .../functional_with_es_ssl/apps/ml/index.ts | 2 +- .../apps/uptime/index.ts | 2 +- .../lists_api_integration/common/config.ts | 1 - x-pack/test/load/config.ts | 4 - x-pack/test/plugin_api_integration/config.ts | 3 - .../event_log/public_api_integration.ts | 6 +- .../task_management_removed_types.ts | 4 +- x-pack/test/plugin_api_perf/config.js | 3 - x-pack/test/plugin_functional/config.ts | 5 - .../global_search/global_search_bar.ts | 8 +- .../global_search/global_search_providers.ts | 4 +- .../download_csv_dashboard.ts | 24 ++-- .../generate_csv_discover.ts | 8 +- .../reporting_and_security/network_policy.ts | 2 +- .../reporting_and_security/spaces.ts | 10 +- .../reporting_and_security/usage.ts | 20 +-- .../reporting_without_security/job_apis.ts | 8 +- .../services/scenarios.ts | 8 +- .../security_roles_privileges.ts | 4 +- .../security_roles_privileges.ts | 4 +- .../reporting_without_security/management.ts | 8 +- .../common/config.ts | 4 - .../common/suites/bulk_create.ts | 12 +- .../common/suites/bulk_get.ts | 12 +- .../common/suites/bulk_update.ts | 12 +- .../common/suites/create.ts | 12 +- .../common/suites/delete.ts | 12 +- .../common/suites/export.ts | 12 +- .../common/suites/find.ts | 12 +- .../common/suites/get.ts | 12 +- .../common/suites/import.ts | 12 +- .../common/suites/resolve.ts | 12 +- .../common/suites/resolve_import_errors.ts | 12 +- .../common/suites/update.ts | 12 +- .../security_and_spaces/apis/_bulk_delete.ts | 8 +- .../security_and_spaces/apis/_find.ts | 8 +- .../apis/_get_assignable_types.ts | 8 +- .../security_and_spaces/apis/bulk_assign.ts | 8 +- .../security_and_spaces/apis/create.ts | 8 +- .../security_and_spaces/apis/delete.ts | 8 +- .../security_and_spaces/apis/get.ts | 8 +- .../security_and_spaces/apis/get_all.ts | 8 +- .../security_and_spaces/apis/update.ts | 8 +- .../security_and_spaces/config.ts | 4 - .../tagging_api/apis/bulk_assign.ts | 8 +- .../tagging_api/apis/create.ts | 8 +- .../tagging_api/apis/delete.ts | 8 +- .../tagging_api/apis/update.ts | 8 +- .../tagging_api/apis/usage_collection.ts | 8 +- .../api_integration/tagging_api/config.ts | 4 - .../saved_object_tagging/functional/config.ts | 5 - .../functional/tests/bulk_actions.ts | 8 +- .../functional/tests/bulk_assign.ts | 8 +- .../functional/tests/create.ts | 8 +- .../functional/tests/dashboard_integration.ts | 16 ++- .../functional/tests/edit.ts | 8 +- .../functional/tests/feature_control.ts | 8 +- .../functional/tests/listing.ts | 8 +- .../functional/tests/maps_integration.ts | 4 +- .../functional/tests/som_integration.ts | 8 +- .../functional/tests/visualize_integration.ts | 16 ++- .../apps/dashboard/async_search/index.ts | 6 +- .../async_search/sessions_in_space.ts | 8 +- .../tests/apps/discover/async_search.ts | 4 +- .../tests/apps/discover/index.ts | 2 +- .../tests/apps/discover/sessions_in_space.ts | 8 +- .../tests/apps/lens/index.ts | 2 +- .../tests/apps/lens/search_sessions.ts | 6 +- .../apps/management/search_sessions/index.ts | 4 +- .../search_sessions/sessions_management.ts | 8 +- .../login_selector.config.ts | 1 - .../test/security_functional/oidc.config.ts | 1 - .../test/security_functional/saml.config.ts | 1 - .../login_selector/auth_provider_hint.ts | 4 +- .../login_selector/basic_functionality.ts | 4 +- .../tests/oidc/url_capture.ts | 4 +- .../tests/saml/url_capture.ts | 4 +- .../config.firefox.ts | 6 - .../test/security_solution_cypress/config.ts | 6 - .../test/security_solution_cypress/runner.ts | 8 +- .../apps/endpoint/endpoint_list.ts | 15 ++- .../apps/endpoint/endpoint_telemetry.ts | 36 ++++-- .../apis/metadata.ts | 4 +- .../apis/metadata_v1.ts | 6 +- .../apis/package.ts | 4 +- .../apis/policy.ts | 7 +- .../apis/resolver/entity.ts | 8 +- .../spaces_api_integration/common/config.ts | 4 - .../common/suites/copy_to_space.ts | 24 +++- .../common/suites/create.ts | 12 +- .../common/suites/delete.ts | 10 +- .../common/suites/get.ts | 12 +- .../common/suites/get_all.ts | 12 +- .../common/suites/get_shareable_references.ts | 12 +- .../suites/resolve_copy_to_space_conflicts.ts | 24 +++- .../common/suites/update.ts | 12 +- .../common/suites/update_objects_spaces.ts | 12 +- .../apps/alerts/alerts_encryption_keys.js | 2 +- .../apps/ccs/ccs_discover.js | 5 +- ...onfig.stack_functional_integration_base.js | 6 +- .../services/es_archiver.js | 40 ++++++ .../services/index.js | 14 +++ x-pack/test/ui_capabilities/common/config.ts | 1 - .../upgrade_assistant_integration/config.js | 1 - .../upgrade_assistant/reindexing.js | 4 +- .../visual_regression/tests/canvas/index.js | 6 +- .../tests/infra/saved_views.js | 4 +- .../tests/infra/waffle_map.js | 4 +- .../visual_regression/tests/login_page.ts | 4 +- .../visual_regression/tests/maps/index.js | 10 +- 710 files changed, 2459 insertions(+), 1831 deletions(-) create mode 100644 x-pack/test/stack_functional_integration/services/es_archiver.js create mode 100644 x-pack/test/stack_functional_integration/services/index.js diff --git a/docs/developer/contributing/development-functional-tests.asciidoc b/docs/developer/contributing/development-functional-tests.asciidoc index f0041b85c14eb..6f5c05f526bd6 100644 --- a/docs/developer/contributing/development-functional-tests.asciidoc +++ b/docs/developer/contributing/development-functional-tests.asciidoc @@ -229,9 +229,9 @@ export default function ({ getService, getPageObject }) { before(async () => { await Promise.all([ // start with an empty .kibana index - esArchiver.load('empty_kibana'), + esArchiver.load('test/functional/fixtures/es_archiver/empty_kibana'), // load some basic log data only if the index doesn't exist - esArchiver.loadIfNeeded('makelogs') + esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/makelogs') ]); // go to the page described by `apps.visualize` in the config await PageObjects.common.navigateTo('visualize'); @@ -243,7 +243,7 @@ export default function ({ getService, getPageObject }) { // we unload the empty_kibana archive but not the makelogs // archive because we don't make any changes to it, and subsequent // suites could use it if they call `.loadIfNeeded()`. - await esArchiver.unload('empty_kibana'); + await esArchiver.unload('test/functional/fixtures/es_archiver/empty_kibana'); }); // This series of tests illustrate how tests generally verify @@ -370,9 +370,9 @@ await testSubjects.click(‘containerButton’); * Source: {blob}test/common/services/es_archiver.ts[test/common/services/es_archiver.ts] * Load/unload archives created with the `esArchiver` * Popular methods: -** `esArchiver.load(name)` -** `esArchiver.loadIfNeeded(name)` -** `esArchiver.unload(name)` +** `esArchiver.load(path)` +** `esArchiver.loadIfNeeded(path)` +** `esArchiver.unload(path)` Full list of services that are used in functional tests can be found here: {blob}test/functional/services[test/functional/services] diff --git a/docs/developer/plugin/external-plugin-functional-tests.asciidoc b/docs/developer/plugin/external-plugin-functional-tests.asciidoc index b39d576d85268..55b311794f9dc 100644 --- a/docs/developer/plugin/external-plugin-functional-tests.asciidoc +++ b/docs/developer/plugin/external-plugin-functional-tests.asciidoc @@ -58,11 +58,6 @@ export default async function ({ readConfigFile }) { } }, - // choose where esArchiver should load archives from - esArchiver: { - directory: resolve(__dirname, './es_archives'), - }, - // choose where screenshots should be saved screenshots: { directory: resolve(__dirname, './tmp/screenshots'), diff --git a/packages/kbn-es-archiver/src/actions/edit.ts b/packages/kbn-es-archiver/src/actions/edit.ts index eb28985f71437..7a97bf08f3675 100644 --- a/packages/kbn-es-archiver/src/actions/edit.ts +++ b/packages/kbn-es-archiver/src/actions/edit.ts @@ -6,9 +6,9 @@ * Side Public License, v 1. */ -import { resolve, relative } from 'path'; +import { relative } from 'path'; import Fs from 'fs'; -import { createGunzip, createGzip, Z_BEST_COMPRESSION } from 'zlib'; +import { createGunzip, createGzip, constants } from 'zlib'; import { promisify } from 'util'; import globby from 'globby'; import { ToolingLog } from '@kbn/dev-utils'; @@ -17,24 +17,22 @@ import { createPromiseFromStreams } from '@kbn/utils'; const unlinkAsync = promisify(Fs.unlink); export async function editAction({ - prefix, - dataDir, + path, log, handler, }: { - prefix: string; - dataDir: string; + path: string; log: ToolingLog; handler: () => Promise; }) { const archives = ( await globby('**/*.gz', { - cwd: prefix ? resolve(dataDir, prefix) : dataDir, + cwd: path, absolute: true, }) - ).map((path) => ({ - path, - rawPath: path.slice(0, -3), + ).map((found) => ({ + path: found, + rawPath: found.slice(0, -3), })); await Promise.all( @@ -61,7 +59,7 @@ export async function editAction({ archives.map(async (archive) => { await createPromiseFromStreams([ Fs.createReadStream(archive.rawPath), - createGzip({ level: Z_BEST_COMPRESSION }), + createGzip({ level: constants.Z_BEST_COMPRESSION }), Fs.createWriteStream(archive.path), ]); diff --git a/packages/kbn-es-archiver/src/actions/load.ts b/packages/kbn-es-archiver/src/actions/load.ts index 248c4a65cb20a..673fa7e7d96c8 100644 --- a/packages/kbn-es-archiver/src/actions/load.ts +++ b/packages/kbn-es-archiver/src/actions/load.ts @@ -6,10 +6,10 @@ * Side Public License, v 1. */ -import { resolve } from 'path'; +import { resolve, relative } from 'path'; import { createReadStream } from 'fs'; import { Readable } from 'stream'; -import { ToolingLog } from '@kbn/dev-utils'; +import { ToolingLog, REPO_ROOT } from '@kbn/dev-utils'; import { KbnClient } from '@kbn/test'; import type { KibanaClient } from '@elastic/elasticsearch/api/kibana'; import { createPromiseFromStreams, concatStreamProviders } from '@kbn/utils'; @@ -37,23 +37,21 @@ const pipeline = (...streams: Readable[]) => ); export async function loadAction({ - name, + inputDir, skipExisting, useCreate, client, - dataDir, log, kbnClient, }: { - name: string; + inputDir: string; skipExisting: boolean; useCreate: boolean; client: KibanaClient; - dataDir: string; log: ToolingLog; kbnClient: KbnClient; }) { - const inputDir = resolve(dataDir, name); + const name = relative(REPO_ROOT, inputDir); const stats = createStats(name, log); const files = prioritizeMappings(await readDirectory(inputDir)); const kibanaPluginIds = await kbnClient.plugins.getEnabledIds(); diff --git a/packages/kbn-es-archiver/src/actions/rebuild_all.ts b/packages/kbn-es-archiver/src/actions/rebuild_all.ts index 1581ff41b95fc..f286f9719bdf1 100644 --- a/packages/kbn-es-archiver/src/actions/rebuild_all.ts +++ b/packages/kbn-es-archiver/src/actions/rebuild_all.ts @@ -6,11 +6,11 @@ * Side Public License, v 1. */ -import { resolve, dirname, relative } from 'path'; +import { resolve, relative } from 'path'; import { stat, Stats, rename, createReadStream, createWriteStream } from 'fs'; import { Readable, Writable } from 'stream'; import { fromNode } from 'bluebird'; -import { ToolingLog } from '@kbn/dev-utils'; +import { ToolingLog, REPO_ROOT } from '@kbn/dev-utils'; import { createPromiseFromStreams } from '@kbn/utils'; import { prioritizeMappings, @@ -25,15 +25,7 @@ async function isDirectory(path: string): Promise { return stats.isDirectory(); } -export async function rebuildAllAction({ - dataDir, - log, - rootDir = dataDir, -}: { - dataDir: string; - log: ToolingLog; - rootDir?: string; -}) { +export async function rebuildAllAction({ dataDir, log }: { dataDir: string; log: ToolingLog }) { const childNames = prioritizeMappings(await readDirectory(dataDir)); for (const childName of childNames) { const childPath = resolve(dataDir, childName); @@ -42,13 +34,12 @@ export async function rebuildAllAction({ await rebuildAllAction({ dataDir: childPath, log, - rootDir, }); continue; } - const archiveName = dirname(relative(rootDir, childPath)); - log.info(`${archiveName} Rebuilding ${childName}`); + const archiveName = relative(REPO_ROOT, childPath); + log.info('[%s] Rebuilding %j', archiveName, childName); const gzip = isGzip(childPath); const tempFile = childPath + (gzip ? '.rebuilding.gz' : '.rebuilding'); @@ -60,6 +51,6 @@ export async function rebuildAllAction({ ] as [Readable, ...Writable[]]); await fromNode((cb) => rename(tempFile, childPath, cb)); - log.info(`${archiveName} Rebuilt ${childName}`); + log.info('[%s] Rebuilt %j', archiveName, childName); } } diff --git a/packages/kbn-es-archiver/src/actions/save.ts b/packages/kbn-es-archiver/src/actions/save.ts index c90f241a1c639..da0966920de24 100644 --- a/packages/kbn-es-archiver/src/actions/save.ts +++ b/packages/kbn-es-archiver/src/actions/save.ts @@ -6,11 +6,11 @@ * Side Public License, v 1. */ -import { resolve } from 'path'; +import { resolve, relative } from 'path'; import { createWriteStream, mkdirSync } from 'fs'; import { Readable, Writable } from 'stream'; import type { KibanaClient } from '@elastic/elasticsearch/api/kibana'; -import { ToolingLog } from '@kbn/dev-utils'; +import { ToolingLog, REPO_ROOT } from '@kbn/dev-utils'; import { createListStream, createPromiseFromStreams } from '@kbn/utils'; import { @@ -22,23 +22,21 @@ import { } from '../lib'; export async function saveAction({ - name, + outputDir, indices, client, - dataDir, log, raw, query, }: { - name: string; + outputDir: string; indices: string | string[]; client: KibanaClient; - dataDir: string; log: ToolingLog; raw: boolean; query?: Record; }) { - const outputDir = resolve(dataDir, name); + const name = relative(REPO_ROOT, outputDir); const stats = createStats(name, log); log.info('[%s] Creating archive of %j', name, indices); diff --git a/packages/kbn-es-archiver/src/actions/unload.ts b/packages/kbn-es-archiver/src/actions/unload.ts index f4e37871a5337..d8bc013b40991 100644 --- a/packages/kbn-es-archiver/src/actions/unload.ts +++ b/packages/kbn-es-archiver/src/actions/unload.ts @@ -6,11 +6,11 @@ * Side Public License, v 1. */ -import { resolve } from 'path'; +import { resolve, relative } from 'path'; import { createReadStream } from 'fs'; import { Readable, Writable } from 'stream'; import type { KibanaClient } from '@elastic/elasticsearch/api/kibana'; -import { ToolingLog } from '@kbn/dev-utils'; +import { ToolingLog, REPO_ROOT } from '@kbn/dev-utils'; import { KbnClient } from '@kbn/test'; import { createPromiseFromStreams } from '@kbn/utils'; @@ -25,19 +25,17 @@ import { } from '../lib'; export async function unloadAction({ - name, + inputDir, client, - dataDir, log, kbnClient, }: { - name: string; + inputDir: string; client: KibanaClient; - dataDir: string; log: ToolingLog; kbnClient: KbnClient; }) { - const inputDir = resolve(dataDir, name); + const name = relative(REPO_ROOT, inputDir); const stats = createStats(name, log); const kibanaPluginIds = await kbnClient.plugins.getEnabledIds(); diff --git a/packages/kbn-es-archiver/src/cli.ts b/packages/kbn-es-archiver/src/cli.ts index 9617457d4573e..9268f5fa7bbb5 100644 --- a/packages/kbn-es-archiver/src/cli.ts +++ b/packages/kbn-es-archiver/src/cli.ts @@ -30,13 +30,12 @@ export function runCli() { new RunWithCommands({ description: 'CLI to manage archiving/restoring data in elasticsearch', globalFlags: { - string: ['es-url', 'kibana-url', 'dir', 'config', 'es-ca', 'kibana-ca'], + string: ['es-url', 'kibana-url', 'config', 'es-ca', 'kibana-ca'], help: ` - --config path to an FTR config file that sets --es-url, --kibana-url, and --dir + --config path to an FTR config file that sets --es-url and --kibana-url default: ${defaultConfigPath} --es-url url for Elasticsearch, prefer the --config flag --kibana-url url for Kibana, prefer the --config flag - --dir where arechives are stored, prefer the --config flag --kibana-ca if Kibana url points to https://localhost we default to the CA from @kbn/dev-utils, customize the CA with this flag --es-ca if Elasticsearch url points to https://localhost we default to the CA from @kbn/dev-utils, customize the CA with this flag `, @@ -104,17 +103,6 @@ export function runCli() { } } - let dir = flags.dir; - if (dir && typeof dir !== 'string') { - throw createFlagError('--dir must be a string'); - } - if (!dir && config) { - dir = Path.resolve(config.get('esArchiver.directory')); - } - if (!dir) { - throw createFlagError('--dir or --config must be defined'); - } - const client = new Client({ node: esUrl, ssl: esCa ? { ca: esCa } : undefined, @@ -130,7 +118,7 @@ export function runCli() { const esArchiver = new EsArchiver({ log, client, - dataDir: dir, + baseDir: process.cwd(), kbnClient, }); @@ -141,16 +129,16 @@ export function runCli() { }) .command({ name: 'save', - usage: 'save [name] [...indices]', + usage: 'save [path] [...indices]', description: ` - archive the [indices ...] into the --dir with [name] + archive the [indices ...] into a directory at [path] Example: - Save all [logstash-*] indices from http://localhost:9200 to [snapshots/my_test_data] directory + Save all [logstash-*] indices from http://localhost:9200 to the [test/functional/es_archives/my_test_data] directory - WARNING: If the [my_test_data] snapshot exists it will be deleted! + WARNING: If the [test/functional/es_archives/my_test_data] snapshot exists it will be deleted! - $ node scripts/es_archiver save my_test_data logstash-* --dir snapshots + $ node scripts/es_archiver save test/functional/es_archives/my_test_data logstash-* `, flags: { boolean: ['raw'], @@ -161,9 +149,9 @@ export function runCli() { `, }, async run({ flags, esArchiver }) { - const [name, ...indices] = flags._; - if (!name) { - throw createFlagError('missing [name] argument'); + const [path, ...indices] = flags._; + if (!path) { + throw createFlagError('missing [path] argument'); } if (!indices.length) { throw createFlagError('missing [...indices] arguments'); @@ -184,22 +172,22 @@ export function runCli() { } } - await esArchiver.save(name, indices, { raw, query: parsedQuery }); + await esArchiver.save(path, indices, { raw, query: parsedQuery }); }, }) .command({ name: 'load', - usage: 'load [name]', + usage: 'load [path]', description: ` - load the archive in --dir with [name] + load the archive stored at [path] Example: - Load the [my_test_data] snapshot from the archive directory and elasticsearch instance defined - in the [test/functional/config.js] config file + Load the [my_test_data] snapshot from the local directory and elasticsearch instance defined + in the [../config.js] config file WARNING: If the indices exist already they will be deleted! - $ node scripts/es_archiver load my_test_data --config test/functional/config.js + $ node scripts/es_archiver load my_test_data --config ../config.js `, flags: { boolean: ['use-create'], @@ -208,9 +196,9 @@ export function runCli() { `, }, async run({ flags, esArchiver }) { - const [name] = flags._; - if (!name) { - throw createFlagError('missing [name] argument'); + const [path] = flags._; + if (!path) { + throw createFlagError('missing [path] argument'); } if (flags._.length > 1) { throw createFlagError(`unknown extra arguments: [${flags._.slice(1).join(', ')}]`); @@ -221,40 +209,40 @@ export function runCli() { throw createFlagError('--use-create does not take a value'); } - await esArchiver.load(name, { useCreate }); + await esArchiver.load(path, { useCreate }); }, }) .command({ name: 'unload', - usage: 'unload [name]', - description: 'remove indices created by the archive in --dir with [name]', + usage: 'unload [path]', + description: 'remove indices created by the archive at [path]', async run({ flags, esArchiver }) { - const [name] = flags._; - if (!name) { - throw createFlagError('missing [name] argument'); + const [path] = flags._; + if (!path) { + throw createFlagError('missing [path] argument'); } if (flags._.length > 1) { throw createFlagError(`unknown extra arguments: [${flags._.slice(1).join(', ')}]`); } - await esArchiver.unload(name); + await esArchiver.unload(path); }, }) .command({ name: 'edit', - usage: 'edit [prefix]', + usage: 'edit [path]', description: - 'extract the archives under the prefix, wait for edits to be completed, and then recompress the archives', + 'extract the archives within or at [path], wait for edits to be completed, and then recompress the archives', async run({ flags, esArchiver }) { - const [prefix] = flags._; - if (!prefix) { - throw createFlagError('missing [prefix] argument'); + const [path] = flags._; + if (!path) { + throw createFlagError('missing [path] argument'); } if (flags._.length > 1) { throw createFlagError(`unknown extra arguments: [${flags._.slice(1).join(', ')}]`); } - await esArchiver.edit(prefix, async () => { + await esArchiver.edit(path, async () => { const rl = readline.createInterface({ input: process.stdin, output: process.stdout, @@ -278,10 +266,19 @@ export function runCli() { }, }) .command({ - name: 'rebuild-all', - description: '[internal] read and write all archives in --dir to remove any inconsistencies', - async run({ esArchiver }) { - await esArchiver.rebuildAll(); + name: 'rebuild-all [dir]', + description: + '[internal] read and write all archives within [dir] to remove any inconsistencies', + async run({ flags, esArchiver }) { + const [dir] = flags._; + if (!dir) { + throw createFlagError('missing [dir] argument'); + } + if (flags._.length > 1) { + throw createFlagError(`unknown extra arguments: [${flags._.slice(1).join(', ')}]`); + } + + await esArchiver.rebuildAll(dir); }, }) .execute(); diff --git a/packages/kbn-es-archiver/src/es_archiver.ts b/packages/kbn-es-archiver/src/es_archiver.ts index 93ce97efd4c84..06a56b79e3012 100644 --- a/packages/kbn-es-archiver/src/es_archiver.ts +++ b/packages/kbn-es-archiver/src/es_archiver.ts @@ -6,8 +6,11 @@ * Side Public License, v 1. */ +import Fs from 'fs'; +import Path from 'path'; + import type { KibanaClient } from '@elastic/elasticsearch/api/kibana'; -import { ToolingLog } from '@kbn/dev-utils'; +import { ToolingLog, REPO_ROOT } from '@kbn/dev-utils'; import { KbnClient } from '@kbn/test'; import { @@ -21,139 +24,128 @@ import { interface Options { client: KibanaClient; - dataDir: string; + baseDir?: string; log: ToolingLog; kbnClient: KbnClient; } export class EsArchiver { private readonly client: KibanaClient; - private readonly dataDir: string; + private readonly baseDir: string; private readonly log: ToolingLog; private readonly kbnClient: KbnClient; constructor(options: Options) { this.client = options.client; - this.dataDir = options.dataDir; + this.baseDir = options.baseDir ?? REPO_ROOT; this.log = options.log; this.kbnClient = options.kbnClient; } /** - * Extract data and mappings from an elasticsearch index and store - * it in the dataDir so it can be used later to recreate the index. + * Extract data and mappings from an elasticsearch index and store + * it in the baseDir so it can be used later to recreate the index. * - * @param {String} name - the name of this archive, used to determine filename - * @param {String|Array} indices - the indices to archive - * @param {Object} options - * @property {Boolean} options.raw - should the archive be raw (unzipped) or not - * @return Promise + * @param {String} path - relative path to the archive, resolved relative to this.baseDir which defaults to REPO_ROOT + * @param {String|Array} indices - the indices to archive + * @param {Object} options + * @property {Boolean} options.raw - should the archive be raw (unzipped) or not */ async save( - name: string, + path: string, indices: string | string[], { raw = false, query }: { raw?: boolean; query?: Record } = {} ) { return await saveAction({ - name, + outputDir: Path.resolve(this.baseDir, path), indices, raw, client: this.client, - dataDir: this.dataDir, log: this.log, query, }); } /** - * Load an index from an archive + * Load an index from an archive * - * @param {String} name - the name of the archive to load - * @param {Object} options - * @property {Boolean} options.skipExisting - should existing indices + * @param {String} path - relative path to the archive to load, resolved relative to this.baseDir which defaults to REPO_ROOT + * @param {Object} options + * @property {Boolean} options.skipExisting - should existing indices * be ignored or overwritten - * @property {Boolean} options.useCreate - use a create operation instead of index for documents - * @return Promise + * @property {Boolean} options.useCreate - use a create operation instead of index for documents */ async load( - name: string, + path: string, { skipExisting = false, useCreate = false, }: { skipExisting?: boolean; useCreate?: boolean } = {} ) { return await loadAction({ - name, + inputDir: this.findArchive(path), skipExisting: !!skipExisting, useCreate: !!useCreate, client: this.client, - dataDir: this.dataDir, log: this.log, kbnClient: this.kbnClient, }); } /** - * Remove the indexes in elasticsearch that have data in an archive. + * Remove the indexes in elasticsearch that have data in an archive. * - * @param {String} name - * @return Promise + * @param {String} path - relative path to the archive to unload, resolved relative to this.baseDir which defaults to REPO_ROOT */ - async unload(name: string) { + async unload(path: string) { return await unloadAction({ - name, + inputDir: this.findArchive(path), client: this.client, - dataDir: this.dataDir, log: this.log, kbnClient: this.kbnClient, }); } /** - * Parse and reformat all of the archives. This is primarily helpful - * for working on the esArchiver. + * Parse and reformat all of the archives. This is primarily helpful + * for working on the esArchiver. * - * @return Promise + * @param {String} dir - relative path to a directory which contains archives, resolved relative to this.baseDir which defaults to REPO_ROOT */ - async rebuildAll() { + async rebuildAll(dir: string) { return await rebuildAllAction({ - dataDir: this.dataDir, + dataDir: Path.resolve(this.baseDir, dir), log: this.log, }); } /** - * Extract the gzipped files in an archive, then call the handler. When it - * resolves re-archive the gzipped files. + * Extract the gzipped files in an archive, then call the handler. When it + * resolves re-archive the gzipped files. * - * @param {String} prefix optional prefix to limit archives that are extracted - * @param {() => Promise} handler - * @return Promise + * @param {String} path optional prefix to limit archives that are extracted + * @param {() => Promise} handler */ - async edit(prefix: string, handler: () => Promise) { + async edit(path: string, handler: () => Promise) { return await editAction({ - prefix, + path: Path.resolve(this.baseDir, path), log: this.log, - dataDir: this.dataDir, handler, }); } /** - * Just like load, but skips any existing index + * Just like load, but skips any existing index * - * @param {String} name - * @return Promise + * @param name */ async loadIfNeeded(name: string) { return await this.load(name, { skipExisting: true }); } /** - * Delete any Kibana indices, and initialize the Kibana index as Kibana would do - * on startup. - * - * @return Promise + * Delete any Kibana indices, and initialize the Kibana index as Kibana would do + * on startup. */ async emptyKibanaIndex() { return await emptyKibanaIndexAction({ @@ -162,4 +154,33 @@ export class EsArchiver { kbnClient: this.kbnClient, }); } + + /** + * Resolve a path relative to the baseDir + * + * @param relativePath + */ + private findArchive(relativePath: string) { + const path = Path.resolve(this.baseDir, relativePath); + let stats; + try { + stats = Fs.statSync(path); + } catch (error) { + if (error.code === 'ENOENT') { + throw new Error( + `Attempt to reference an esArchive with relative path [${relativePath}] could not be resolved. This path was resolved relative to [${this.baseDir}].` + ); + } + + throw error; + } + + if (stats.isDirectory()) { + return path; + } + + throw new Error( + `Attempt to reference an esArchive with relative path [${relativePath}] resolved to a file instead of a directory containing data/mapping files. This path was resolved relative to [${this.baseDir}].` + ); + } } diff --git a/packages/kbn-test/src/functional_test_runner/lib/config/schema.ts b/packages/kbn-test/src/functional_test_runner/lib/config/schema.ts index e5d0fdc122a1a..6a8f384208fd8 100644 --- a/packages/kbn-test/src/functional_test_runner/lib/config/schema.ts +++ b/packages/kbn-test/src/functional_test_runner/lib/config/schema.ts @@ -209,13 +209,6 @@ export const schema = Joi.object() // definition of apps that work with `common.navigateToApp()` apps: Joi.object().pattern(ID_PATTERN, appUrlPartsSchema()).default(), - // settings for the esArchiver module - esArchiver: Joi.object() - .keys({ - directory: Joi.string().default(defaultRelativeToConfigPath('fixtures/es_archiver')), - }) - .default(), - // settings for the saved objects svc kbnArchiver: Joi.object() .keys({ diff --git a/src/core/TESTING.md b/src/core/TESTING.md index ef6db57c1a993..10ead1ea8cfe2 100644 --- a/src/core/TESTING.md +++ b/src/core/TESTING.md @@ -792,8 +792,8 @@ To do that we'll write a Jest integration test using `TestUtils` to start Kibana and esArchiver to load fixture data into Elasticsearch. 1. Create the fixtures data you need in Elasticsearch -2. Create a fixtures archive with `node scripts/es_archiver save [index patterns...]` -3. Load the fixtures in your test using esArchiver `esArchiver.load('name')`; +2. Create a fixtures archive with `node scripts/es_archiver save [index patterns...]` +3. Load the fixtures in your test using esArchiver `esArchiver.load('path from root of repo')`; _todo: fully worked out example_ diff --git a/test/accessibility/apps/discover.ts b/test/accessibility/apps/discover.ts index 67abe15ea537a..6705598ef6e74 100644 --- a/test/accessibility/apps/discover.ts +++ b/test/accessibility/apps/discover.ts @@ -19,8 +19,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('Discover a11y tests', () => { before(async () => { - await esArchiver.load('discover'); - await esArchiver.loadIfNeeded('logstash_functional'); + await esArchiver.load('test/functional/fixtures/es_archiver/discover'); + await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/logstash_functional'); await kibanaServer.uiSettings.update({ defaultIndex: 'logstash-*', 'doc_table:legacy': true, @@ -30,7 +30,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); after(async () => { - await esArchiver.unload('logstash_functional'); + await esArchiver.unload('test/functional/fixtures/es_archiver/logstash_functional'); }); it('Discover main page', async () => { diff --git a/test/accessibility/apps/management.ts b/test/accessibility/apps/management.ts index 82b3479362298..692b140ade7ee 100644 --- a/test/accessibility/apps/management.ts +++ b/test/accessibility/apps/management.ts @@ -16,8 +16,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('Management', () => { before(async () => { - await esArchiver.load('discover'); - await esArchiver.loadIfNeeded('logstash_functional'); + await esArchiver.load('test/functional/fixtures/es_archiver/discover'); + await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/logstash_functional'); await kibanaServer.uiSettings.update({ defaultIndex: 'logstash-*', }); @@ -25,7 +25,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); after(async () => { - await esArchiver.unload('logstash_functional'); + await esArchiver.unload('test/functional/fixtures/es_archiver/logstash_functional'); }); it('main view', async () => { diff --git a/test/accessibility/apps/visualize.ts b/test/accessibility/apps/visualize.ts index e493b288eaa89..6478907fcb96a 100644 --- a/test/accessibility/apps/visualize.ts +++ b/test/accessibility/apps/visualize.ts @@ -15,7 +15,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('Visualize', () => { before(async () => { - await esArchiver.loadIfNeeded('discover'); + await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/discover'); await PageObjects.common.navigateToApp('visualize'); }); diff --git a/test/api_integration/apis/index_patterns/es_errors/errors.js b/test/api_integration/apis/index_patterns/es_errors/errors.js index fab59ef256a05..1a48b391ae87d 100644 --- a/test/api_integration/apis/index_patterns/es_errors/errors.js +++ b/test/api_integration/apis/index_patterns/es_errors/errors.js @@ -27,12 +27,14 @@ export default function ({ getService }) { let indexNotFoundError; let docNotFoundError; before(async () => { - await esArchiver.load('index_patterns/basic_index'); + await esArchiver.load('test/api_integration/fixtures/es_archiver/index_patterns/basic_index'); indexNotFoundError = await getIndexNotFoundError(es); docNotFoundError = await getDocNotFoundError(es); }); after(async () => { - await esArchiver.unload('index_patterns/basic_index'); + await esArchiver.unload( + 'test/api_integration/fixtures/es_archiver/index_patterns/basic_index' + ); }); describe('isEsIndexNotFoundError()', () => { diff --git a/test/api_integration/apis/index_patterns/fields_api/update_fields/main.ts b/test/api_integration/apis/index_patterns/fields_api/update_fields/main.ts index c75b6c607f56e..3bec22de48ee6 100644 --- a/test/api_integration/apis/index_patterns/fields_api/update_fields/main.ts +++ b/test/api_integration/apis/index_patterns/fields_api/update_fields/main.ts @@ -18,7 +18,7 @@ export default function ({ getService }: FtrProviderContext) { let indexPattern: any; before(async () => { - await esArchiver.load('index_patterns/basic_index'); + await esArchiver.load('test/api_integration/fixtures/es_archiver/index_patterns/basic_index'); indexPattern = ( await supertest.post('/api/index_patterns/index_pattern').send({ @@ -30,7 +30,9 @@ export default function ({ getService }: FtrProviderContext) { }); after(async () => { - await esArchiver.unload('index_patterns/basic_index'); + await esArchiver.unload( + 'test/api_integration/fixtures/es_archiver/index_patterns/basic_index' + ); if (indexPattern) { await supertest.delete('/api/index_patterns/index_pattern/' + indexPattern.id); diff --git a/test/api_integration/apis/index_patterns/fields_for_time_pattern_route/pattern.js b/test/api_integration/apis/index_patterns/fields_for_time_pattern_route/pattern.js index e14086f9d973a..8d72cbd2fb37f 100644 --- a/test/api_integration/apis/index_patterns/fields_for_time_pattern_route/pattern.js +++ b/test/api_integration/apis/index_patterns/fields_for_time_pattern_route/pattern.js @@ -13,8 +13,12 @@ export default function ({ getService }) { const esArchiver = getService('esArchiver'); describe('pattern', () => { - before(() => esArchiver.load('index_patterns/daily_index')); - after(() => esArchiver.unload('index_patterns/daily_index')); + before(() => + esArchiver.load('test/api_integration/fixtures/es_archiver/index_patterns/daily_index') + ); + after(() => + esArchiver.unload('test/api_integration/fixtures/es_archiver/index_patterns/daily_index') + ); it('matches indices with compatible patterns', () => supertest diff --git a/test/api_integration/apis/index_patterns/fields_for_time_pattern_route/query_params.js b/test/api_integration/apis/index_patterns/fields_for_time_pattern_route/query_params.js index 3ccf6a7791f6c..481f433deeb73 100644 --- a/test/api_integration/apis/index_patterns/fields_for_time_pattern_route/query_params.js +++ b/test/api_integration/apis/index_patterns/fields_for_time_pattern_route/query_params.js @@ -13,8 +13,12 @@ export default function ({ getService }) { const esArchiver = getService('esArchiver'); describe('query params', () => { - before(() => esArchiver.load('index_patterns/daily_index')); - after(() => esArchiver.unload('index_patterns/daily_index')); + before(() => + esArchiver.load('test/api_integration/fixtures/es_archiver/index_patterns/daily_index') + ); + after(() => + esArchiver.unload('test/api_integration/fixtures/es_archiver/index_patterns/daily_index') + ); it('requires `pattern` query param', () => supertest diff --git a/test/api_integration/apis/index_patterns/fields_for_wildcard_route/conflicts.js b/test/api_integration/apis/index_patterns/fields_for_wildcard_route/conflicts.js index a06c37ea84b4c..f050e2a0626d3 100644 --- a/test/api_integration/apis/index_patterns/fields_for_wildcard_route/conflicts.js +++ b/test/api_integration/apis/index_patterns/fields_for_wildcard_route/conflicts.js @@ -13,8 +13,12 @@ export default function ({ getService }) { const esArchiver = getService('esArchiver'); describe('conflicts', () => { - before(() => esArchiver.load('index_patterns/conflicts')); - after(() => esArchiver.unload('index_patterns/conflicts')); + before(() => + esArchiver.load('test/api_integration/fixtures/es_archiver/index_patterns/conflicts') + ); + after(() => + esArchiver.unload('test/api_integration/fixtures/es_archiver/index_patterns/conflicts') + ); it('flags fields with mismatched types as conflicting', () => supertest diff --git a/test/api_integration/apis/index_patterns/fields_for_wildcard_route/params.js b/test/api_integration/apis/index_patterns/fields_for_wildcard_route/params.js index 61b795ed67d33..5b82473721be8 100644 --- a/test/api_integration/apis/index_patterns/fields_for_wildcard_route/params.js +++ b/test/api_integration/apis/index_patterns/fields_for_wildcard_route/params.js @@ -12,8 +12,12 @@ export default function ({ getService }) { const randomness = getService('randomness'); describe('params', () => { - before(() => esArchiver.load('index_patterns/basic_index')); - after(() => esArchiver.unload('index_patterns/basic_index')); + before(() => + esArchiver.load('test/api_integration/fixtures/es_archiver/index_patterns/basic_index') + ); + after(() => + esArchiver.unload('test/api_integration/fixtures/es_archiver/index_patterns/basic_index') + ); it('requires a pattern query param', () => supertest.get('/api/index_patterns/_fields_for_wildcard').query({}).expect(400)); diff --git a/test/api_integration/apis/index_patterns/fields_for_wildcard_route/response.js b/test/api_integration/apis/index_patterns/fields_for_wildcard_route/response.js index 87c5aa535ccd9..913db9aee9c0f 100644 --- a/test/api_integration/apis/index_patterns/fields_for_wildcard_route/response.js +++ b/test/api_integration/apis/index_patterns/fields_for_wildcard_route/response.js @@ -67,8 +67,12 @@ export default function ({ getService }) { ]; describe('fields_for_wildcard_route response', () => { - before(() => esArchiver.load('index_patterns/basic_index')); - after(() => esArchiver.unload('index_patterns/basic_index')); + before(() => + esArchiver.load('test/api_integration/fixtures/es_archiver/index_patterns/basic_index') + ); + after(() => + esArchiver.unload('test/api_integration/fixtures/es_archiver/index_patterns/basic_index') + ); it('returns a flattened version of the fields in es', async () => { await supertest diff --git a/test/api_integration/apis/index_patterns/index_pattern_crud/create_index_pattern/main.ts b/test/api_integration/apis/index_patterns/index_pattern_crud/create_index_pattern/main.ts index 91f165dbdda7c..31c3f13a6e05f 100644 --- a/test/api_integration/apis/index_patterns/index_pattern_crud/create_index_pattern/main.ts +++ b/test/api_integration/apis/index_patterns/index_pattern_crud/create_index_pattern/main.ts @@ -78,11 +78,15 @@ export default function ({ getService }: FtrProviderContext) { describe('creating fields', () => { before(async () => { - await esArchiver.load('index_patterns/basic_index'); + await esArchiver.load( + 'test/api_integration/fixtures/es_archiver/index_patterns/basic_index' + ); }); after(async () => { - await esArchiver.unload('index_patterns/basic_index'); + await esArchiver.unload( + 'test/api_integration/fixtures/es_archiver/index_patterns/basic_index' + ); }); it('can specify optional fields attribute when creating an index pattern', async () => { diff --git a/test/api_integration/apis/index_patterns/scripted_fields_crud/create_scripted_field/main.ts b/test/api_integration/apis/index_patterns/scripted_fields_crud/create_scripted_field/main.ts index a5ed61d8ab9af..1210e7247f72d 100644 --- a/test/api_integration/apis/index_patterns/scripted_fields_crud/create_scripted_field/main.ts +++ b/test/api_integration/apis/index_patterns/scripted_fields_crud/create_scripted_field/main.ts @@ -15,11 +15,13 @@ export default function ({ getService }: FtrProviderContext) { describe('main', () => { before(async () => { - await esArchiver.load('index_patterns/basic_index'); + await esArchiver.load('test/api_integration/fixtures/es_archiver/index_patterns/basic_index'); }); after(async () => { - await esArchiver.unload('index_patterns/basic_index'); + await esArchiver.unload( + 'test/api_integration/fixtures/es_archiver/index_patterns/basic_index' + ); }); it('can create a new scripted field', async () => { diff --git a/test/api_integration/apis/index_patterns/scripted_fields_crud/delete_scripted_field/errors.ts b/test/api_integration/apis/index_patterns/scripted_fields_crud/delete_scripted_field/errors.ts index f0787500d505c..2b35f1ec50e91 100644 --- a/test/api_integration/apis/index_patterns/scripted_fields_crud/delete_scripted_field/errors.ts +++ b/test/api_integration/apis/index_patterns/scripted_fields_crud/delete_scripted_field/errors.ts @@ -18,7 +18,7 @@ export default function ({ getService }: FtrProviderContext) { let indexPattern: any; before(async () => { - await esArchiver.load('index_patterns/basic_index'); + await esArchiver.load('test/api_integration/fixtures/es_archiver/index_patterns/basic_index'); indexPattern = ( await supertest.post('/api/index_patterns/index_pattern').send({ @@ -30,7 +30,9 @@ export default function ({ getService }: FtrProviderContext) { }); after(async () => { - await esArchiver.unload('index_patterns/basic_index'); + await esArchiver.unload( + 'test/api_integration/fixtures/es_archiver/index_patterns/basic_index' + ); if (indexPattern) { await supertest.delete('/api/index_patterns/index_pattern/' + indexPattern.id); diff --git a/test/api_integration/apis/index_patterns/scripted_fields_crud/delete_scripted_field/main.ts b/test/api_integration/apis/index_patterns/scripted_fields_crud/delete_scripted_field/main.ts index 40f57cd914a2f..466af26f6e127 100644 --- a/test/api_integration/apis/index_patterns/scripted_fields_crud/delete_scripted_field/main.ts +++ b/test/api_integration/apis/index_patterns/scripted_fields_crud/delete_scripted_field/main.ts @@ -15,11 +15,13 @@ export default function ({ getService }: FtrProviderContext) { describe('main', () => { before(async () => { - await esArchiver.load('index_patterns/basic_index'); + await esArchiver.load('test/api_integration/fixtures/es_archiver/index_patterns/basic_index'); }); after(async () => { - await esArchiver.unload('index_patterns/basic_index'); + await esArchiver.unload( + 'test/api_integration/fixtures/es_archiver/index_patterns/basic_index' + ); }); it('can remove a scripted field', async () => { diff --git a/test/api_integration/apis/index_patterns/scripted_fields_crud/get_scripted_field/errors.ts b/test/api_integration/apis/index_patterns/scripted_fields_crud/get_scripted_field/errors.ts index ef2fbc5258d66..be9d213a32845 100644 --- a/test/api_integration/apis/index_patterns/scripted_fields_crud/get_scripted_field/errors.ts +++ b/test/api_integration/apis/index_patterns/scripted_fields_crud/get_scripted_field/errors.ts @@ -18,7 +18,7 @@ export default function ({ getService }: FtrProviderContext) { let indexPattern: any; before(async () => { - await esArchiver.load('index_patterns/basic_index'); + await esArchiver.load('test/api_integration/fixtures/es_archiver/index_patterns/basic_index'); indexPattern = ( await supertest.post('/api/index_patterns/index_pattern').send({ @@ -30,7 +30,9 @@ export default function ({ getService }: FtrProviderContext) { }); after(async () => { - await esArchiver.unload('index_patterns/basic_index'); + await esArchiver.unload( + 'test/api_integration/fixtures/es_archiver/index_patterns/basic_index' + ); if (indexPattern) { await supertest.delete('/api/index_patterns/index_pattern/' + indexPattern.id); diff --git a/test/api_integration/apis/index_patterns/scripted_fields_crud/get_scripted_field/main.ts b/test/api_integration/apis/index_patterns/scripted_fields_crud/get_scripted_field/main.ts index 7fff720e5195f..64d909480260e 100644 --- a/test/api_integration/apis/index_patterns/scripted_fields_crud/get_scripted_field/main.ts +++ b/test/api_integration/apis/index_patterns/scripted_fields_crud/get_scripted_field/main.ts @@ -15,11 +15,13 @@ export default function ({ getService }: FtrProviderContext) { describe('main', () => { before(async () => { - await esArchiver.load('index_patterns/basic_index'); + await esArchiver.load('test/api_integration/fixtures/es_archiver/index_patterns/basic_index'); }); after(async () => { - await esArchiver.unload('index_patterns/basic_index'); + await esArchiver.unload( + 'test/api_integration/fixtures/es_archiver/index_patterns/basic_index' + ); }); it('can fetch a scripted field', async () => { diff --git a/test/api_integration/apis/index_patterns/scripted_fields_crud/put_scripted_field/main.ts b/test/api_integration/apis/index_patterns/scripted_fields_crud/put_scripted_field/main.ts index dec20961b0de0..96f5924e7c132 100644 --- a/test/api_integration/apis/index_patterns/scripted_fields_crud/put_scripted_field/main.ts +++ b/test/api_integration/apis/index_patterns/scripted_fields_crud/put_scripted_field/main.ts @@ -15,11 +15,13 @@ export default function ({ getService }: FtrProviderContext) { describe('main', () => { before(async () => { - await esArchiver.load('index_patterns/basic_index'); + await esArchiver.load('test/api_integration/fixtures/es_archiver/index_patterns/basic_index'); }); after(async () => { - await esArchiver.unload('index_patterns/basic_index'); + await esArchiver.unload( + 'test/api_integration/fixtures/es_archiver/index_patterns/basic_index' + ); }); it('can overwrite an existing field', async () => { diff --git a/test/api_integration/apis/index_patterns/scripted_fields_crud/update_scripted_field/main.ts b/test/api_integration/apis/index_patterns/scripted_fields_crud/update_scripted_field/main.ts index ac6b11522124b..055b3fe9abe04 100644 --- a/test/api_integration/apis/index_patterns/scripted_fields_crud/update_scripted_field/main.ts +++ b/test/api_integration/apis/index_patterns/scripted_fields_crud/update_scripted_field/main.ts @@ -15,11 +15,13 @@ export default function ({ getService }: FtrProviderContext) { describe('main', () => { before(async () => { - await esArchiver.load('index_patterns/basic_index'); + await esArchiver.load('test/api_integration/fixtures/es_archiver/index_patterns/basic_index'); }); after(async () => { - await esArchiver.unload('index_patterns/basic_index'); + await esArchiver.unload( + 'test/api_integration/fixtures/es_archiver/index_patterns/basic_index' + ); }); it('can update an existing field', async () => { diff --git a/test/api_integration/apis/saved_objects_management/find.ts b/test/api_integration/apis/saved_objects_management/find.ts index df39e9b5c2a36..6aefd74f0f36b 100644 --- a/test/api_integration/apis/saved_objects_management/find.ts +++ b/test/api_integration/apis/saved_objects_management/find.ts @@ -145,8 +145,14 @@ export default function ({ getService }: FtrProviderContext) { }); describe('meta attributes injected properly', () => { - before(() => esArchiver.load('management/saved_objects/search')); - after(() => esArchiver.unload('management/saved_objects/search')); + before(() => + esArchiver.load('test/api_integration/fixtures/es_archiver/management/saved_objects/search') + ); + after(() => + esArchiver.unload( + 'test/api_integration/fixtures/es_archiver/management/saved_objects/search' + ) + ); it('should inject meta attributes for searches', async () => await supertest diff --git a/test/api_integration/apis/saved_objects_management/scroll_count.ts b/test/api_integration/apis/saved_objects_management/scroll_count.ts index 78fd316eb4ecb..088b26d8205da 100644 --- a/test/api_integration/apis/saved_objects_management/scroll_count.ts +++ b/test/api_integration/apis/saved_objects_management/scroll_count.ts @@ -19,10 +19,14 @@ export default function ({ getService }: FtrProviderContext) { describe('scroll_count', () => { before(async () => { - await esArchiver.load('management/saved_objects/scroll_count'); + await esArchiver.load( + 'test/api_integration/fixtures/es_archiver/management/saved_objects/scroll_count' + ); }); after(async () => { - await esArchiver.unload('management/saved_objects/scroll_count'); + await esArchiver.unload( + 'test/api_integration/fixtures/es_archiver/management/saved_objects/scroll_count' + ); }); it('returns the count for each included types', async () => { diff --git a/test/api_integration/apis/search/bsearch.ts b/test/api_integration/apis/search/bsearch.ts index 11fb74200d7dd..f80bc1d0d9dfa 100644 --- a/test/api_integration/apis/search/bsearch.ts +++ b/test/api_integration/apis/search/bsearch.ts @@ -193,13 +193,11 @@ export default function ({ getService }: FtrProviderContext) { describe('painless', () => { before(async () => { - await esArchiver.loadIfNeeded( - '../../../functional/fixtures/es_archiver/logstash_functional' - ); + await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/logstash_functional'); }); after(async () => { - await esArchiver.unload('../../../functional/fixtures/es_archiver/logstash_functional'); + await esArchiver.unload('test/functional/fixtures/es_archiver/logstash_functional'); }); it('should return 400 "search_phase_execution_exception" for Painless error in "es" strategy', async () => { const resp = await supertest.post(`/internal/bsearch`).send({ diff --git a/test/api_integration/apis/search/search.ts b/test/api_integration/apis/search/search.ts index 7ef82cd5467ab..96e7f6ab7161b 100644 --- a/test/api_integration/apis/search/search.ts +++ b/test/api_integration/apis/search/search.ts @@ -18,11 +18,11 @@ export default function ({ getService }: FtrProviderContext) { describe('search', () => { before(async () => { await esArchiver.emptyKibanaIndex(); - await esArchiver.loadIfNeeded('../../../functional/fixtures/es_archiver/logstash_functional'); + await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/logstash_functional'); }); after(async () => { - await esArchiver.unload('../../../functional/fixtures/es_archiver/logstash_functional'); + await esArchiver.unload('test/functional/fixtures/es_archiver/logstash_functional'); }); describe('post', () => { it('should return 200 when correctly formatted searches are provided', async () => { diff --git a/test/api_integration/apis/suggestions/suggestions.js b/test/api_integration/apis/suggestions/suggestions.js index b3c8ae238450c..526cb9669f278 100644 --- a/test/api_integration/apis/suggestions/suggestions.js +++ b/test/api_integration/apis/suggestions/suggestions.js @@ -13,11 +13,13 @@ export default function ({ getService }) { describe('Suggestions API', function () { before(async () => { - await esArchiver.load('index_patterns/basic_index'); + await esArchiver.load('test/api_integration/fixtures/es_archiver/index_patterns/basic_index'); await kibanaServer.importExport.load('index_patterns/basic_kibana'); }); after(async () => { - await esArchiver.unload('index_patterns/basic_index'); + await esArchiver.unload( + 'test/api_integration/fixtures/es_archiver/index_patterns/basic_index' + ); await kibanaServer.importExport.unload('index_patterns/basic_kibana'); }); diff --git a/test/common/services/es_archiver.ts b/test/common/services/es_archiver.ts index 742ba74c0dcaf..d99a2e8d10236 100644 --- a/test/common/services/es_archiver.ts +++ b/test/common/services/es_archiver.ts @@ -19,15 +19,8 @@ export function EsArchiverProvider({ getService }: FtrProviderContext): EsArchiv const kibanaServer = getService('kibanaServer'); const retry = getService('retry'); - if (!config.get('esArchiver')) { - throw new Error(`esArchiver can't be used unless you specify it's config in your config file`); - } - - const dataDir = config.get('esArchiver.directory'); - const esArchiver = new EsArchiver({ client, - dataDir, log, kbnClient: kibanaServer, }); diff --git a/test/examples/config.js b/test/examples/config.js index 1ee095fbdedeb..cb6c487c564c3 100644 --- a/test/examples/config.js +++ b/test/examples/config.js @@ -6,7 +6,7 @@ * Side Public License, v 1. */ -import path, { resolve } from 'path'; +import { resolve } from 'path'; import { services } from '../plugin_functional/services'; import fs from 'fs'; import { KIBANA_ROOT } from '@kbn/test'; @@ -47,9 +47,6 @@ export default async function ({ readConfigFile }) { serverArgs: ['xpack.security.enabled=false'], }, apps: functionalConfig.get('apps'), - esArchiver: { - directory: path.resolve(__dirname, '../es_archives'), - }, screenshots: functionalConfig.get('screenshots'), junit: { reportName: 'Example plugin functional tests', diff --git a/test/examples/embeddables/dashboard.ts b/test/examples/embeddables/dashboard.ts index 69788ebad2af2..77ad5a5da9eeb 100644 --- a/test/examples/embeddables/dashboard.ts +++ b/test/examples/embeddables/dashboard.ts @@ -102,8 +102,10 @@ export default function ({ getService, getPageObjects }: PluginFunctionalProvide describe('dashboard container', () => { before(async () => { - await esArchiver.loadIfNeeded('../functional/fixtures/es_archiver/dashboard/current/data'); - await esArchiver.loadIfNeeded('../functional/fixtures/es_archiver/dashboard/current/kibana'); + await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/dashboard/current/data'); + await esArchiver.loadIfNeeded( + 'test/functional/fixtures/es_archiver/dashboard/current/kibana' + ); await PageObjects.common.navigateToApp('dashboardEmbeddableExamples'); await testSubjects.click('dashboardEmbeddableByValue'); await updateInput(JSON.stringify(testDashboardInput, null, 4)); diff --git a/test/functional/apps/context/_date_nanos.js b/test/functional/apps/context/_date_nanos.js index f5408661b9c6e..35e38abc6fdb7 100644 --- a/test/functional/apps/context/_date_nanos.js +++ b/test/functional/apps/context/_date_nanos.js @@ -22,7 +22,7 @@ export default function ({ getService, getPageObjects }) { describe('context view for date_nanos', () => { before(async function () { await security.testUser.setRoles(['kibana_admin', 'kibana_date_nanos']); - await esArchiver.loadIfNeeded('date_nanos'); + await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/date_nanos'); await kibanaServer.uiSettings.replace({ defaultIndex: TEST_INDEX_PATTERN }); await kibanaServer.uiSettings.update({ 'context:defaultSize': `${TEST_DEFAULT_CONTEXT_SIZE}`, @@ -32,7 +32,7 @@ export default function ({ getService, getPageObjects }) { after(async function unloadMakelogs() { await security.testUser.restoreDefaults(); - await esArchiver.unload('date_nanos'); + await esArchiver.unload('test/functional/fixtures/es_archiver/date_nanos'); }); it('displays predessors - anchor - successors in right order ', async function () { diff --git a/test/functional/apps/context/_date_nanos_custom_timestamp.js b/test/functional/apps/context/_date_nanos_custom_timestamp.js index b837c55d821ac..a933c2f20b163 100644 --- a/test/functional/apps/context/_date_nanos_custom_timestamp.js +++ b/test/functional/apps/context/_date_nanos_custom_timestamp.js @@ -22,7 +22,7 @@ export default function ({ getService, getPageObjects }) { describe('context view for date_nanos with custom timestamp', () => { before(async function () { await security.testUser.setRoles(['kibana_admin', 'kibana_date_nanos_custom']); - await esArchiver.loadIfNeeded('date_nanos_custom'); + await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/date_nanos_custom'); await kibanaServer.uiSettings.replace({ defaultIndex: TEST_INDEX_PATTERN }); await kibanaServer.uiSettings.update({ 'context:defaultSize': `${TEST_DEFAULT_CONTEXT_SIZE}`, @@ -43,7 +43,7 @@ export default function ({ getService, getPageObjects }) { after(async function () { await security.testUser.restoreDefaults(); - await esArchiver.unload('date_nanos_custom'); + await esArchiver.unload('test/functional/fixtures/es_archiver/date_nanos_custom'); }); }); } diff --git a/test/functional/apps/context/index.js b/test/functional/apps/context/index.js index 245f88a337dce..7612dae338d9f 100644 --- a/test/functional/apps/context/index.js +++ b/test/functional/apps/context/index.js @@ -17,14 +17,14 @@ export default function ({ getService, getPageObjects, loadTestFile }) { before(async function () { await browser.setWindowSize(1200, 800); - await esArchiver.loadIfNeeded('logstash_functional'); - await esArchiver.load('visualize'); + await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/logstash_functional'); + await esArchiver.load('test/functional/fixtures/es_archiver/visualize'); await kibanaServer.uiSettings.replace({ defaultIndex: 'logstash-*' }); await PageObjects.common.navigateToApp('discover'); }); after(function unloadMakelogs() { - return esArchiver.unload('logstash_functional'); + return esArchiver.unload('test/functional/fixtures/es_archiver/logstash_functional'); }); loadTestFile(require.resolve('./_context_navigation')); diff --git a/test/functional/apps/dashboard/copy_panel_to.ts b/test/functional/apps/dashboard/copy_panel_to.ts index 641d520801c4d..8877e5e47bd95 100644 --- a/test/functional/apps/dashboard/copy_panel_to.ts +++ b/test/functional/apps/dashboard/copy_panel_to.ts @@ -40,7 +40,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('dashboard panel copy to', function viewEditModeTests() { before(async function () { - await esArchiver.load('dashboard/current/kibana'); + await esArchiver.load('test/functional/fixtures/es_archiver/dashboard/current/kibana'); await kibanaServer.uiSettings.replace({ defaultIndex: '0bf35f60-3dc9-11e8-8660-4d65aa086b3c', }); diff --git a/test/functional/apps/dashboard/create_and_add_embeddables.ts b/test/functional/apps/dashboard/create_and_add_embeddables.ts index 3de3b2f843f55..62ce68e026f72 100644 --- a/test/functional/apps/dashboard/create_and_add_embeddables.ts +++ b/test/functional/apps/dashboard/create_and_add_embeddables.ts @@ -22,7 +22,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('create and add embeddables', () => { before(async () => { - await esArchiver.load('dashboard/current/kibana'); + await esArchiver.load('test/functional/fixtures/es_archiver/dashboard/current/kibana'); await kibanaServer.uiSettings.replace({ defaultIndex: '0bf35f60-3dc9-11e8-8660-4d65aa086b3c', }); diff --git a/test/functional/apps/dashboard/dashboard_back_button.ts b/test/functional/apps/dashboard/dashboard_back_button.ts index 7e0bf92e3292a..1e901cdbd48be 100644 --- a/test/functional/apps/dashboard/dashboard_back_button.ts +++ b/test/functional/apps/dashboard/dashboard_back_button.ts @@ -17,7 +17,9 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('dashboard back button', () => { before(async () => { - await esArchiver.loadIfNeeded('dashboard/current/kibana'); + await esArchiver.loadIfNeeded( + 'test/functional/fixtures/es_archiver/dashboard/current/kibana' + ); await kibanaServer.uiSettings.replace({ defaultIndex: '0bf35f60-3dc9-11e8-8660-4d65aa086b3c', }); diff --git a/test/functional/apps/dashboard/dashboard_error_handling.ts b/test/functional/apps/dashboard/dashboard_error_handling.ts index 5d3d8bd251d63..89c2d42029935 100644 --- a/test/functional/apps/dashboard/dashboard_error_handling.ts +++ b/test/functional/apps/dashboard/dashboard_error_handling.ts @@ -19,7 +19,9 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { */ describe('dashboard error handling', () => { before(async () => { - await esArchiver.loadIfNeeded('dashboard/current/kibana'); + await esArchiver.loadIfNeeded( + 'test/functional/fixtures/es_archiver/dashboard/current/kibana' + ); await PageObjects.common.navigateToApp('dashboard'); }); diff --git a/test/functional/apps/dashboard/dashboard_filter_bar.ts b/test/functional/apps/dashboard/dashboard_filter_bar.ts index c2d6cc4c38b6b..e1a15009afe51 100644 --- a/test/functional/apps/dashboard/dashboard_filter_bar.ts +++ b/test/functional/apps/dashboard/dashboard_filter_bar.ts @@ -31,7 +31,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('dashboard filter bar', () => { before(async () => { - await esArchiver.load('dashboard/current/kibana'); + await esArchiver.load('test/functional/fixtures/es_archiver/dashboard/current/kibana'); await kibanaServer.uiSettings.replace({ defaultIndex: '0bf35f60-3dc9-11e8-8660-4d65aa086b3c', }); diff --git a/test/functional/apps/dashboard/dashboard_filtering.ts b/test/functional/apps/dashboard/dashboard_filtering.ts index 86c57efec818b..acb04b4946fad 100644 --- a/test/functional/apps/dashboard/dashboard_filtering.ts +++ b/test/functional/apps/dashboard/dashboard_filtering.ts @@ -54,7 +54,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }; before(async () => { - await esArchiver.load('dashboard/current/kibana'); + await esArchiver.load('test/functional/fixtures/es_archiver/dashboard/current/kibana'); await security.testUser.setRoles(['kibana_admin', 'test_logstash_reader', 'animals']); await kibanaServer.uiSettings.replace({ defaultIndex: '0bf35f60-3dc9-11e8-8660-4d65aa086b3c', diff --git a/test/functional/apps/dashboard/dashboard_grid.ts b/test/functional/apps/dashboard/dashboard_grid.ts index 809fb6fc14001..fecec34fd91e3 100644 --- a/test/functional/apps/dashboard/dashboard_grid.ts +++ b/test/functional/apps/dashboard/dashboard_grid.ts @@ -19,7 +19,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('dashboard grid', function () { before(async () => { - await esArchiver.load('dashboard/current/kibana'); + await esArchiver.load('test/functional/fixtures/es_archiver/dashboard/current/kibana'); await kibanaServer.uiSettings.replace({ defaultIndex: '0bf35f60-3dc9-11e8-8660-4d65aa086b3c', }); diff --git a/test/functional/apps/dashboard/dashboard_options.ts b/test/functional/apps/dashboard/dashboard_options.ts index 1f62256a3fdb5..5702286bba6b6 100644 --- a/test/functional/apps/dashboard/dashboard_options.ts +++ b/test/functional/apps/dashboard/dashboard_options.ts @@ -20,7 +20,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { let originalTitles: string[] = []; before(async () => { - await esArchiver.load('dashboard/current/kibana'); + await esArchiver.load('test/functional/fixtures/es_archiver/dashboard/current/kibana'); await kibanaServer.uiSettings.replace({ defaultIndex: '0bf35f60-3dc9-11e8-8660-4d65aa086b3c', }); diff --git a/test/functional/apps/dashboard/dashboard_query_bar.ts b/test/functional/apps/dashboard/dashboard_query_bar.ts index bf8300defc445..07fa3355c6fba 100644 --- a/test/functional/apps/dashboard/dashboard_query_bar.ts +++ b/test/functional/apps/dashboard/dashboard_query_bar.ts @@ -20,7 +20,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('dashboard query bar', () => { before(async () => { - await esArchiver.load('dashboard/current/kibana'); + await esArchiver.load('test/functional/fixtures/es_archiver/dashboard/current/kibana'); await kibanaServer.uiSettings.replace({ defaultIndex: '0bf35f60-3dc9-11e8-8660-4d65aa086b3c', }); @@ -30,7 +30,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('causes panels to reload when refresh is clicked', async () => { - await esArchiver.unload('dashboard/current/data'); + await esArchiver.unload('test/functional/fixtures/es_archiver/dashboard/current/data'); await queryBar.clickQuerySubmitButton(); await retry.tryForTime(5000, async () => { diff --git a/test/functional/apps/dashboard/dashboard_saved_query.ts b/test/functional/apps/dashboard/dashboard_saved_query.ts index bdf97e8ced140..015a00a713bdc 100644 --- a/test/functional/apps/dashboard/dashboard_saved_query.ts +++ b/test/functional/apps/dashboard/dashboard_saved_query.ts @@ -21,7 +21,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('dashboard saved queries', function describeIndexTests() { before(async function () { - await esArchiver.load('dashboard/current/kibana'); + await esArchiver.load('test/functional/fixtures/es_archiver/dashboard/current/kibana'); await kibanaServer.uiSettings.replace({ defaultIndex: '0bf35f60-3dc9-11e8-8660-4d65aa086b3c', }); diff --git a/test/functional/apps/dashboard/dashboard_snapshots.ts b/test/functional/apps/dashboard/dashboard_snapshots.ts index c93636aeb63c6..3aba671c0a4b2 100644 --- a/test/functional/apps/dashboard/dashboard_snapshots.ts +++ b/test/functional/apps/dashboard/dashboard_snapshots.ts @@ -25,7 +25,7 @@ export default function ({ describe('dashboard snapshots', function describeIndexTests() { before(async function () { - await esArchiver.load('dashboard/current/kibana'); + await esArchiver.load('test/functional/fixtures/es_archiver/dashboard/current/kibana'); await kibanaServer.uiSettings.replace({ defaultIndex: '0bf35f60-3dc9-11e8-8660-4d65aa086b3c', }); diff --git a/test/functional/apps/dashboard/dashboard_unsaved_listing.ts b/test/functional/apps/dashboard/dashboard_unsaved_listing.ts index 1cdc4bbff2c53..2b2d96e8d723a 100644 --- a/test/functional/apps/dashboard/dashboard_unsaved_listing.ts +++ b/test/functional/apps/dashboard/dashboard_unsaved_listing.ts @@ -36,7 +36,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }; before(async () => { - await esArchiver.load('dashboard/current/kibana'); + await esArchiver.load('test/functional/fixtures/es_archiver/dashboard/current/kibana'); await kibanaServer.uiSettings.replace({ defaultIndex: '0bf35f60-3dc9-11e8-8660-4d65aa086b3c', }); diff --git a/test/functional/apps/dashboard/dashboard_unsaved_state.ts b/test/functional/apps/dashboard/dashboard_unsaved_state.ts index fd203cd8c1356..6b71dd34b76f8 100644 --- a/test/functional/apps/dashboard/dashboard_unsaved_state.ts +++ b/test/functional/apps/dashboard/dashboard_unsaved_state.ts @@ -23,7 +23,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { // FLAKY: https://github.com/elastic/kibana/issues/91191 describe.skip('dashboard unsaved panels', () => { before(async () => { - await esArchiver.load('dashboard/current/kibana'); + await esArchiver.load('test/functional/fixtures/es_archiver/dashboard/current/kibana'); await kibanaServer.uiSettings.replace({ defaultIndex: '0bf35f60-3dc9-11e8-8660-4d65aa086b3c', }); diff --git a/test/functional/apps/dashboard/data_shared_attributes.ts b/test/functional/apps/dashboard/data_shared_attributes.ts index 2d6396be80f46..34fd4ddb346ed 100644 --- a/test/functional/apps/dashboard/data_shared_attributes.ts +++ b/test/functional/apps/dashboard/data_shared_attributes.ts @@ -21,7 +21,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { let originalPanelTitles: string[]; before(async () => { - await esArchiver.load('dashboard/current/kibana'); + await esArchiver.load('test/functional/fixtures/es_archiver/dashboard/current/kibana'); await kibanaServer.uiSettings.replace({ defaultIndex: '0bf35f60-3dc9-11e8-8660-4d65aa086b3c', }); diff --git a/test/functional/apps/dashboard/edit_embeddable_redirects.ts b/test/functional/apps/dashboard/edit_embeddable_redirects.ts index be540e18a503f..02f178a5153a2 100644 --- a/test/functional/apps/dashboard/edit_embeddable_redirects.ts +++ b/test/functional/apps/dashboard/edit_embeddable_redirects.ts @@ -19,7 +19,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('edit embeddable redirects', () => { before(async () => { - await esArchiver.load('dashboard/current/kibana'); + await esArchiver.load('test/functional/fixtures/es_archiver/dashboard/current/kibana'); await kibanaServer.uiSettings.replace({ defaultIndex: '0bf35f60-3dc9-11e8-8660-4d65aa086b3c', }); diff --git a/test/functional/apps/dashboard/edit_visualizations.js b/test/functional/apps/dashboard/edit_visualizations.js index b2f21aefcf79c..507d4b8308d4c 100644 --- a/test/functional/apps/dashboard/edit_visualizations.js +++ b/test/functional/apps/dashboard/edit_visualizations.js @@ -44,7 +44,7 @@ export default function ({ getService, getPageObjects }) { describe('edit visualizations from dashboard', () => { before(async () => { - await esArchiver.load('dashboard/current/kibana'); + await esArchiver.load('test/functional/fixtures/es_archiver/dashboard/current/kibana'); await kibanaServer.uiSettings.replace({ defaultIndex: '0bf35f60-3dc9-11e8-8660-4d65aa086b3c', }); diff --git a/test/functional/apps/dashboard/embed_mode.ts b/test/functional/apps/dashboard/embed_mode.ts index b96e957262573..943a6b3bdb469 100644 --- a/test/functional/apps/dashboard/embed_mode.ts +++ b/test/functional/apps/dashboard/embed_mode.ts @@ -28,7 +28,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { ]; before(async () => { - await esArchiver.load('dashboard/current/kibana'); + await esArchiver.load('test/functional/fixtures/es_archiver/dashboard/current/kibana'); await kibanaServer.uiSettings.replace({ defaultIndex: '0bf35f60-3dc9-11e8-8660-4d65aa086b3c', }); diff --git a/test/functional/apps/dashboard/embeddable_data_grid.ts b/test/functional/apps/dashboard/embeddable_data_grid.ts index a9e0039de1f79..66aca561383c3 100644 --- a/test/functional/apps/dashboard/embeddable_data_grid.ts +++ b/test/functional/apps/dashboard/embeddable_data_grid.ts @@ -21,9 +21,11 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('dashboard embeddable data grid', () => { before(async () => { - await esArchiver.loadIfNeeded('logstash_functional'); - await esArchiver.loadIfNeeded('dashboard/current/data'); - await esArchiver.loadIfNeeded('dashboard/current/kibana'); + await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/logstash_functional'); + await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/dashboard/current/data'); + await esArchiver.loadIfNeeded( + 'test/functional/fixtures/es_archiver/dashboard/current/kibana' + ); await kibanaServer.uiSettings.replace({ defaultIndex: '0bf35f60-3dc9-11e8-8660-4d65aa086b3c', 'doc_table:legacy': false, diff --git a/test/functional/apps/dashboard/embeddable_library.ts b/test/functional/apps/dashboard/embeddable_library.ts index 20fe9aeb1387a..d66f6e834c367 100644 --- a/test/functional/apps/dashboard/embeddable_library.ts +++ b/test/functional/apps/dashboard/embeddable_library.ts @@ -21,7 +21,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('embeddable library', () => { before(async () => { - await esArchiver.load('dashboard/current/kibana'); + await esArchiver.load('test/functional/fixtures/es_archiver/dashboard/current/kibana'); await kibanaServer.uiSettings.replace({ defaultIndex: '0bf35f60-3dc9-11e8-8660-4d65aa086b3c', }); diff --git a/test/functional/apps/dashboard/embeddable_rendering.ts b/test/functional/apps/dashboard/embeddable_rendering.ts index 11807831dc352..e045b1a1e3f5e 100644 --- a/test/functional/apps/dashboard/embeddable_rendering.ts +++ b/test/functional/apps/dashboard/embeddable_rendering.ts @@ -94,7 +94,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe.skip('dashboard embeddable rendering', function describeIndexTests() { before(async () => { await security.testUser.setRoles(['kibana_admin', 'animals', 'test_logstash_reader']); - await esArchiver.load('dashboard/current/kibana'); + await esArchiver.load('test/functional/fixtures/es_archiver/dashboard/current/kibana'); await kibanaServer.uiSettings.replace({ defaultIndex: '0bf35f60-3dc9-11e8-8660-4d65aa086b3c', }); diff --git a/test/functional/apps/dashboard/empty_dashboard.ts b/test/functional/apps/dashboard/empty_dashboard.ts index 2cfa6d73dcb72..46a8545b79596 100644 --- a/test/functional/apps/dashboard/empty_dashboard.ts +++ b/test/functional/apps/dashboard/empty_dashboard.ts @@ -21,7 +21,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('empty dashboard', () => { before(async () => { - await esArchiver.load('dashboard/current/kibana'); + await esArchiver.load('test/functional/fixtures/es_archiver/dashboard/current/kibana'); await kibanaServer.uiSettings.replace({ defaultIndex: '0bf35f60-3dc9-11e8-8660-4d65aa086b3c', }); diff --git a/test/functional/apps/dashboard/full_screen_mode.ts b/test/functional/apps/dashboard/full_screen_mode.ts index 1f63dcdafdcce..02669759f68ea 100644 --- a/test/functional/apps/dashboard/full_screen_mode.ts +++ b/test/functional/apps/dashboard/full_screen_mode.ts @@ -20,7 +20,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('full screen mode', () => { before(async () => { - await esArchiver.load('dashboard/current/kibana'); + await esArchiver.load('test/functional/fixtures/es_archiver/dashboard/current/kibana'); await kibanaServer.uiSettings.replace({ defaultIndex: '0bf35f60-3dc9-11e8-8660-4d65aa086b3c', }); diff --git a/test/functional/apps/dashboard/index.ts b/test/functional/apps/dashboard/index.ts index 9f9422ddaec64..4b83b2ac92deb 100644 --- a/test/functional/apps/dashboard/index.ts +++ b/test/functional/apps/dashboard/index.ts @@ -15,21 +15,21 @@ export default function ({ getService, loadTestFile }: FtrProviderContext) { async function loadCurrentData() { await browser.setWindowSize(1300, 900); - await esArchiver.unload('logstash_functional'); - await esArchiver.loadIfNeeded('dashboard/current/data'); + await esArchiver.unload('test/functional/fixtures/es_archiver/logstash_functional'); + await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/dashboard/current/data'); } async function unloadCurrentData() { - await esArchiver.unload('dashboard/current/data'); + await esArchiver.unload('test/functional/fixtures/es_archiver/dashboard/current/data'); } async function loadLogstash() { await browser.setWindowSize(1200, 900); - await esArchiver.loadIfNeeded('logstash_functional'); + await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/logstash_functional'); } async function unloadLogstash() { - await esArchiver.unload('logstash_functional'); + await esArchiver.unload('test/functional/fixtures/es_archiver/logstash_functional'); } describe('dashboard app', function () { diff --git a/test/functional/apps/dashboard/legacy_urls.ts b/test/functional/apps/dashboard/legacy_urls.ts index 9c7f472b287a7..96c7a5aac3f4b 100644 --- a/test/functional/apps/dashboard/legacy_urls.ts +++ b/test/functional/apps/dashboard/legacy_urls.ts @@ -33,7 +33,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('legacy urls', function describeIndexTests() { before(async function () { await security.testUser.setRoles(['kibana_admin', 'animals']); - await esArchiver.load('dashboard/current/kibana'); + await esArchiver.load('test/functional/fixtures/es_archiver/dashboard/current/kibana'); await PageObjects.common.navigateToApp('dashboard'); await PageObjects.dashboard.clickNewDashboard(); await dashboardAddPanel.addVisualization('Rendering-Test:-animal-sounds-pie'); diff --git a/test/functional/apps/dashboard/panel_expand_toggle.ts b/test/functional/apps/dashboard/panel_expand_toggle.ts index 256109c669138..00500450595eb 100644 --- a/test/functional/apps/dashboard/panel_expand_toggle.ts +++ b/test/functional/apps/dashboard/panel_expand_toggle.ts @@ -19,7 +19,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('expanding a panel', () => { before(async () => { - await esArchiver.load('dashboard/current/kibana'); + await esArchiver.load('test/functional/fixtures/es_archiver/dashboard/current/kibana'); await kibanaServer.uiSettings.replace({ defaultIndex: '0bf35f60-3dc9-11e8-8660-4d65aa086b3c', }); diff --git a/test/functional/apps/dashboard/saved_search_embeddable.ts b/test/functional/apps/dashboard/saved_search_embeddable.ts index 098f6ccc00d94..5bcec338aad1e 100644 --- a/test/functional/apps/dashboard/saved_search_embeddable.ts +++ b/test/functional/apps/dashboard/saved_search_embeddable.ts @@ -19,9 +19,11 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('dashboard saved search embeddable', () => { before(async () => { - await esArchiver.loadIfNeeded('logstash_functional'); - await esArchiver.loadIfNeeded('dashboard/current/data'); - await esArchiver.loadIfNeeded('dashboard/current/kibana'); + await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/logstash_functional'); + await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/dashboard/current/data'); + await esArchiver.loadIfNeeded( + 'test/functional/fixtures/es_archiver/dashboard/current/kibana' + ); await kibanaServer.uiSettings.replace({ defaultIndex: '0bf35f60-3dc9-11e8-8660-4d65aa086b3c', }); diff --git a/test/functional/apps/dashboard/share.ts b/test/functional/apps/dashboard/share.ts index 8191b5efb51f6..77a858b22ec79 100644 --- a/test/functional/apps/dashboard/share.ts +++ b/test/functional/apps/dashboard/share.ts @@ -16,7 +16,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('share dashboard', () => { before(async () => { - await esArchiver.load('dashboard/current/kibana'); + await esArchiver.load('test/functional/fixtures/es_archiver/dashboard/current/kibana'); await kibanaServer.uiSettings.replace({ defaultIndex: '0bf35f60-3dc9-11e8-8660-4d65aa086b3c', }); diff --git a/test/functional/apps/dashboard/time_zones.ts b/test/functional/apps/dashboard/time_zones.ts index a4a586cb635d5..e5c532537b6f0 100644 --- a/test/functional/apps/dashboard/time_zones.ts +++ b/test/functional/apps/dashboard/time_zones.ts @@ -27,7 +27,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { this.tags('includeFirefox'); before(async () => { - await esArchiver.load('dashboard/current/kibana'); + await esArchiver.load('test/functional/fixtures/es_archiver/dashboard/current/kibana'); await kibanaServer.uiSettings.replace({ defaultIndex: '0bf35f60-3dc9-11e8-8660-4d65aa086b3c', }); diff --git a/test/functional/apps/dashboard/url_field_formatter.ts b/test/functional/apps/dashboard/url_field_formatter.ts index f930987f16d5f..8a4371a0adf77 100644 --- a/test/functional/apps/dashboard/url_field_formatter.ts +++ b/test/functional/apps/dashboard/url_field_formatter.ts @@ -39,7 +39,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { // FLAKY: https://github.com/elastic/kibana/issues/79463 describe.skip('Changing field formatter to Url', () => { before(async function () { - await esArchiver.load('dashboard/current/kibana'); + await esArchiver.load('test/functional/fixtures/es_archiver/dashboard/current/kibana'); await kibanaServer.uiSettings.replace({ defaultIndex: '0bf35f60-3dc9-11e8-8660-4d65aa086b3c', }); diff --git a/test/functional/apps/dashboard/view_edit.ts b/test/functional/apps/dashboard/view_edit.ts index 9a883c5a527ff..b29b07f9df4e4 100644 --- a/test/functional/apps/dashboard/view_edit.ts +++ b/test/functional/apps/dashboard/view_edit.ts @@ -21,7 +21,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('dashboard view edit mode', function viewEditModeTests() { before(async () => { - await esArchiver.load('dashboard/current/kibana'); + await esArchiver.load('test/functional/fixtures/es_archiver/dashboard/current/kibana'); await kibanaServer.uiSettings.replace({ defaultIndex: '0bf35f60-3dc9-11e8-8660-4d65aa086b3c', }); diff --git a/test/functional/apps/discover/_data_grid.ts b/test/functional/apps/discover/_data_grid.ts index 366865b53fb0d..eaefb3ba38f05 100644 --- a/test/functional/apps/discover/_data_grid.ts +++ b/test/functional/apps/discover/_data_grid.ts @@ -25,7 +25,7 @@ export default function ({ before(async function () { await kibanaServer.savedObjects.clean({ types: ['search', 'index-pattern'] }); await kibanaServer.importExport.load('discover'); - await esArchiver.loadIfNeeded('logstash_functional'); + await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/logstash_functional'); await kibanaServer.uiSettings.replace(defaultSettings); await PageObjects.common.navigateToApp('discover'); await PageObjects.timePicker.setDefaultAbsoluteRange(); diff --git a/test/functional/apps/discover/_data_grid_context.ts b/test/functional/apps/discover/_data_grid_context.ts index ee60660ae4a9e..bfce69ca08d55 100644 --- a/test/functional/apps/discover/_data_grid_context.ts +++ b/test/functional/apps/discover/_data_grid_context.ts @@ -37,7 +37,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { before(async () => { await kibanaServer.savedObjects.clean({ types: ['search', 'index-pattern'] }); await kibanaServer.importExport.load('discover'); - await esArchiver.loadIfNeeded('logstash_functional'); + await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/logstash_functional'); await PageObjects.timePicker.setDefaultAbsoluteRangeViaUiSettings(); await kibanaServer.uiSettings.update(defaultSettings); await PageObjects.common.navigateToApp('discover'); diff --git a/test/functional/apps/discover/_data_grid_doc_navigation.ts b/test/functional/apps/discover/_data_grid_doc_navigation.ts index 2225cb5871f34..e3e8a20b693f8 100644 --- a/test/functional/apps/discover/_data_grid_doc_navigation.ts +++ b/test/functional/apps/discover/_data_grid_doc_navigation.ts @@ -21,8 +21,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('discover data grid doc link', function () { beforeEach(async function () { - await esArchiver.loadIfNeeded('logstash_functional'); - await esArchiver.loadIfNeeded('discover'); + await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/logstash_functional'); + await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/discover'); await PageObjects.timePicker.setDefaultAbsoluteRangeViaUiSettings(); await kibanaServer.uiSettings.update(defaultSettings); await PageObjects.common.navigateToApp('discover'); diff --git a/test/functional/apps/discover/_data_grid_doc_table.ts b/test/functional/apps/discover/_data_grid_doc_table.ts index f0d6abb23d30f..bbd633df6fa1e 100644 --- a/test/functional/apps/discover/_data_grid_doc_table.ts +++ b/test/functional/apps/discover/_data_grid_doc_table.ts @@ -29,7 +29,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { log.debug('load kibana index with default index pattern'); await kibanaServer.savedObjects.clean({ types: ['search', 'index-pattern'] }); await kibanaServer.importExport.load('discover'); - await esArchiver.loadIfNeeded('logstash_functional'); + await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/logstash_functional'); await kibanaServer.uiSettings.replace(defaultSettings); await PageObjects.timePicker.setDefaultAbsoluteRangeViaUiSettings(); await PageObjects.common.navigateToApp('discover'); diff --git a/test/functional/apps/discover/_data_grid_field_data.ts b/test/functional/apps/discover/_data_grid_field_data.ts index 5d73192c1608c..8296b518bee32 100644 --- a/test/functional/apps/discover/_data_grid_field_data.ts +++ b/test/functional/apps/discover/_data_grid_field_data.ts @@ -24,7 +24,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { before(async function () { await kibanaServer.savedObjects.clean({ types: ['search', 'index-pattern'] }); await kibanaServer.importExport.load('discover'); - await esArchiver.loadIfNeeded('logstash_functional'); + await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/logstash_functional'); await PageObjects.timePicker.setDefaultAbsoluteRangeViaUiSettings(); await kibanaServer.uiSettings.update(defaultSettings); await PageObjects.common.navigateToApp('discover'); diff --git a/test/functional/apps/discover/_date_nanos.ts b/test/functional/apps/discover/_date_nanos.ts index 09970b3719c4e..81327d0744bfe 100644 --- a/test/functional/apps/discover/_date_nanos.ts +++ b/test/functional/apps/discover/_date_nanos.ts @@ -20,7 +20,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('date_nanos', function () { before(async function () { - await esArchiver.loadIfNeeded('date_nanos'); + await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/date_nanos'); await kibanaServer.uiSettings.replace({ defaultIndex: 'date-nanos' }); await security.testUser.setRoles(['kibana_admin', 'kibana_date_nanos']); await PageObjects.common.navigateToApp('discover'); @@ -29,7 +29,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { after(async function unloadMakelogs() { await security.testUser.restoreDefaults(); - await esArchiver.unload('date_nanos'); + await esArchiver.unload('test/functional/fixtures/es_archiver/date_nanos'); }); it('should show a timestamp with nanoseconds in the first result row', async function () { diff --git a/test/functional/apps/discover/_date_nanos_mixed.ts b/test/functional/apps/discover/_date_nanos_mixed.ts index a3402cc733431..7d4104c3ac344 100644 --- a/test/functional/apps/discover/_date_nanos_mixed.ts +++ b/test/functional/apps/discover/_date_nanos_mixed.ts @@ -20,7 +20,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('date_nanos_mixed', function () { before(async function () { - await esArchiver.loadIfNeeded('date_nanos_mixed'); + await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/date_nanos_mixed'); await kibanaServer.uiSettings.replace({ defaultIndex: 'timestamp-*' }); await security.testUser.setRoles(['kibana_admin', 'kibana_date_nanos_mixed']); await PageObjects.common.navigateToApp('discover'); @@ -29,7 +29,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { after(async () => { await security.testUser.restoreDefaults(); - esArchiver.unload('date_nanos_mixed'); + esArchiver.unload('test/functional/fixtures/es_archiver/date_nanos_mixed'); }); it('shows a list of records of indices with date & date_nanos fields in the right order', async function () { diff --git a/test/functional/apps/discover/_discover.ts b/test/functional/apps/discover/_discover.ts index b5279eaaa1f12..f26d1f4536e55 100644 --- a/test/functional/apps/discover/_discover.ts +++ b/test/functional/apps/discover/_discover.ts @@ -32,7 +32,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await kibanaServer.importExport.load('discover'); // and load a set of makelogs data - await esArchiver.loadIfNeeded('logstash_functional'); + await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/logstash_functional'); await kibanaServer.uiSettings.replace(defaultSettings); await PageObjects.common.navigateToApp('discover'); await PageObjects.timePicker.setDefaultAbsoluteRange(); diff --git a/test/functional/apps/discover/_discover_fields_api.ts b/test/functional/apps/discover/_discover_fields_api.ts index 0a6029a9f10e8..d3df79dc8658b 100644 --- a/test/functional/apps/discover/_discover_fields_api.ts +++ b/test/functional/apps/discover/_discover_fields_api.ts @@ -24,7 +24,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { log.debug('load kibana index with default index pattern'); await kibanaServer.savedObjects.clean({ types: ['search', 'index-pattern'] }); await kibanaServer.importExport.load('discover'); - await esArchiver.loadIfNeeded('logstash_functional'); + await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/logstash_functional'); await kibanaServer.uiSettings.replace(defaultSettings); log.debug('discover'); await PageObjects.common.navigateToApp('discover'); diff --git a/test/functional/apps/discover/_discover_histogram.ts b/test/functional/apps/discover/_discover_histogram.ts index e41422555f81d..d4b3758fd9b8c 100644 --- a/test/functional/apps/discover/_discover_histogram.ts +++ b/test/functional/apps/discover/_discover_histogram.ts @@ -25,16 +25,20 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('discover histogram', function describeIndexTests() { before(async () => { - await esArchiver.loadIfNeeded('logstash_functional'); - await esArchiver.load('long_window_logstash'); - await esArchiver.load('long_window_logstash_index_pattern'); + await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/logstash_functional'); + await esArchiver.load('test/functional/fixtures/es_archiver/long_window_logstash'); + await esArchiver.load( + 'test/functional/fixtures/es_archiver/long_window_logstash_index_pattern' + ); await security.testUser.setRoles(['kibana_admin', 'long_window_logstash']); await kibanaServer.uiSettings.replace(defaultSettings); await PageObjects.common.navigateToApp('discover'); }); after(async () => { - await esArchiver.unload('long_window_logstash'); - await esArchiver.unload('long_window_logstash_index_pattern'); + await esArchiver.unload('test/functional/fixtures/es_archiver/long_window_logstash'); + await esArchiver.unload( + 'test/functional/fixtures/es_archiver/long_window_logstash_index_pattern' + ); await security.testUser.restoreDefaults(); }); diff --git a/test/functional/apps/discover/_doc_navigation.ts b/test/functional/apps/discover/_doc_navigation.ts index 90d3c4eca423a..771dac4d40a64 100644 --- a/test/functional/apps/discover/_doc_navigation.ts +++ b/test/functional/apps/discover/_doc_navigation.ts @@ -21,8 +21,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('doc link in discover', function contextSize() { before(async () => { - await esArchiver.loadIfNeeded('logstash_functional'); - await esArchiver.loadIfNeeded('discover'); + await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/logstash_functional'); + await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/discover'); await PageObjects.timePicker.setDefaultAbsoluteRangeViaUiSettings(); await kibanaServer.uiSettings.update({ 'doc_table:legacy': true, diff --git a/test/functional/apps/discover/_doc_table.ts b/test/functional/apps/discover/_doc_table.ts index 6f298a364abfa..ffe989f8d498c 100644 --- a/test/functional/apps/discover/_doc_table.ts +++ b/test/functional/apps/discover/_doc_table.ts @@ -33,7 +33,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await kibanaServer.importExport.load('discover'); // and load a set of makelogs data - await esArchiver.loadIfNeeded('logstash_functional'); + await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/logstash_functional'); await kibanaServer.uiSettings.replace(defaultSettings); await PageObjects.timePicker.setDefaultAbsoluteRangeViaUiSettings(); log.debug('discover doc table'); diff --git a/test/functional/apps/discover/_errors.ts b/test/functional/apps/discover/_errors.ts index 8b8877016b103..f127c39fd5d9a 100644 --- a/test/functional/apps/discover/_errors.ts +++ b/test/functional/apps/discover/_errors.ts @@ -16,14 +16,14 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('errors', function describeIndexTests() { before(async function () { - await esArchiver.loadIfNeeded('logstash_functional'); - await esArchiver.load('invalid_scripted_field'); + await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/logstash_functional'); + await esArchiver.load('test/functional/fixtures/es_archiver/invalid_scripted_field'); await PageObjects.timePicker.setDefaultAbsoluteRangeViaUiSettings(); await PageObjects.common.navigateToApp('discover'); }); after(async function () { - await esArchiver.load('empty_kibana'); + await esArchiver.load('test/functional/fixtures/es_archiver/empty_kibana'); }); describe('invalid scripted field error', () => { diff --git a/test/functional/apps/discover/_field_data.ts b/test/functional/apps/discover/_field_data.ts index 1831fb9aa73b1..e8698b984f6cc 100644 --- a/test/functional/apps/discover/_field_data.ts +++ b/test/functional/apps/discover/_field_data.ts @@ -25,7 +25,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { before(async function () { await kibanaServer.savedObjects.clean({ types: ['search', 'index-pattern'] }); await kibanaServer.importExport.load('discover'); - await esArchiver.loadIfNeeded('logstash_functional'); + await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/logstash_functional'); await kibanaServer.uiSettings.replace({ defaultIndex: 'logstash-*', 'discover:searchFieldsFromSource': true, diff --git a/test/functional/apps/discover/_field_data_with_fields_api.ts b/test/functional/apps/discover/_field_data_with_fields_api.ts index 319722e0c8842..7de123bb44f2a 100644 --- a/test/functional/apps/discover/_field_data_with_fields_api.ts +++ b/test/functional/apps/discover/_field_data_with_fields_api.ts @@ -25,7 +25,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { before(async function () { await kibanaServer.savedObjects.clean({ types: ['search', 'index-pattern'] }); await kibanaServer.importExport.load('discover'); - await esArchiver.loadIfNeeded('logstash_functional'); + await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/logstash_functional'); await kibanaServer.uiSettings.replace({ defaultIndex: 'logstash-*', 'discover:searchFieldsFromSource': false, diff --git a/test/functional/apps/discover/_filter_editor.ts b/test/functional/apps/discover/_filter_editor.ts index b94ba3cda4044..4e9839d4e799a 100644 --- a/test/functional/apps/discover/_filter_editor.ts +++ b/test/functional/apps/discover/_filter_editor.ts @@ -28,7 +28,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await kibanaServer.importExport.load('discover'); // and load a set of makelogs data - await esArchiver.loadIfNeeded('logstash_functional'); + await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/logstash_functional'); await kibanaServer.uiSettings.replace(defaultSettings); log.debug('discover filter editor'); await PageObjects.common.navigateToApp('discover'); diff --git a/test/functional/apps/discover/_huge_fields.ts b/test/functional/apps/discover/_huge_fields.ts index b3e63e482e734..c7fe0a94b6019 100644 --- a/test/functional/apps/discover/_huge_fields.ts +++ b/test/functional/apps/discover/_huge_fields.ts @@ -19,7 +19,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe.skip('test large number of fields in sidebar', function () { before(async function () { await security.testUser.setRoles(['kibana_admin', 'test_testhuge_reader'], false); - await esArchiver.loadIfNeeded('large_fields'); + await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/large_fields'); await PageObjects.settings.navigateTo(); await kibanaServer.uiSettings.update({ 'timepicker:timeDefaults': `{ "from": "2016-10-05T00:00:00", "to": "2016-10-06T00:00:00"}`, @@ -41,7 +41,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { after(async () => { await security.testUser.restoreDefaults(); - await esArchiver.unload('large_fields'); + await esArchiver.unload('test/functional/fixtures/es_archiver/large_fields'); await kibanaServer.uiSettings.replace({}); }); }); diff --git a/test/functional/apps/discover/_indexpattern_with_unmapped_fields.ts b/test/functional/apps/discover/_indexpattern_with_unmapped_fields.ts index 06933e828db7e..e986429a15d26 100644 --- a/test/functional/apps/discover/_indexpattern_with_unmapped_fields.ts +++ b/test/functional/apps/discover/_indexpattern_with_unmapped_fields.ts @@ -18,7 +18,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('index pattern with unmapped fields', () => { before(async () => { - await esArchiver.loadIfNeeded('unmapped_fields'); + await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/unmapped_fields'); await kibanaServer.uiSettings.replace({ defaultIndex: 'test-index-unmapped-fields', 'discover:searchFieldsFromSource': false, @@ -31,7 +31,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); after(async () => { - await esArchiver.unload('unmapped_fields'); + await esArchiver.unload('test/functional/fixtures/es_archiver/unmapped_fields'); }); it('unmapped fields exist on a new saved search', async () => { diff --git a/test/functional/apps/discover/_indexpattern_without_timefield.ts b/test/functional/apps/discover/_indexpattern_without_timefield.ts index a1050222937ec..ff3ad0daf69db 100644 --- a/test/functional/apps/discover/_indexpattern_without_timefield.ts +++ b/test/functional/apps/discover/_indexpattern_without_timefield.ts @@ -19,7 +19,9 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('indexpattern without timefield', () => { before(async () => { await security.testUser.setRoles(['kibana_admin', 'kibana_timefield']); - await esArchiver.loadIfNeeded('index_pattern_without_timefield'); + await esArchiver.loadIfNeeded( + 'test/functional/fixtures/es_archiver/index_pattern_without_timefield' + ); await kibanaServer.uiSettings.replace({ defaultIndex: 'without-timefield', 'timepicker:timeDefaults': '{ "from": "2019-01-18T19:37:13.000Z", "to": "now"}', @@ -31,7 +33,9 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await security.testUser.restoreDefaults(); await kibanaServer.uiSettings.unset('timepicker:timeDefaults'); await kibanaServer.uiSettings.unset('defaultIndex'); - await esArchiver.unload('index_pattern_without_timefield'); + await esArchiver.unload( + 'test/functional/fixtures/es_archiver/index_pattern_without_timefield' + ); }); it('should not display a timepicker', async () => { diff --git a/test/functional/apps/discover/_inspector.ts b/test/functional/apps/discover/_inspector.ts index 85bd163bdc50c..9d4fd93eb3a9f 100644 --- a/test/functional/apps/discover/_inspector.ts +++ b/test/functional/apps/discover/_inspector.ts @@ -35,7 +35,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await kibanaServer.savedObjects.clean({ types: ['search', 'index-pattern'] }); await kibanaServer.importExport.load('discover'); - await esArchiver.loadIfNeeded('logstash_functional'); + await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/logstash_functional'); // delete .kibana index and update configDoc await kibanaServer.uiSettings.replace({ defaultIndex: 'logstash-*', diff --git a/test/functional/apps/discover/_large_string.ts b/test/functional/apps/discover/_large_string.ts index 0f6be04212a62..3e426c6237d89 100644 --- a/test/functional/apps/discover/_large_string.ts +++ b/test/functional/apps/discover/_large_string.ts @@ -24,7 +24,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await security.testUser.setRoles(['kibana_admin', 'kibana_large_strings']); await kibanaServer.importExport.load('testlargestring'); - await esArchiver.loadIfNeeded('hamlet'); + await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/hamlet'); await kibanaServer.uiSettings.replace({ defaultIndex: 'testlargestring' }); }); @@ -68,7 +68,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { after(async () => { await security.testUser.restoreDefaults(); - await esArchiver.unload('hamlet'); + await esArchiver.unload('test/functional/fixtures/es_archiver/hamlet'); await kibanaServer.savedObjects.clean({ types: ['search', 'index-pattern'] }); }); }); diff --git a/test/functional/apps/discover/_runtime_fields_editor.ts b/test/functional/apps/discover/_runtime_fields_editor.ts index 407b74c4fd018..fd2ca4dd4b5cf 100644 --- a/test/functional/apps/discover/_runtime_fields_editor.ts +++ b/test/functional/apps/discover/_runtime_fields_editor.ts @@ -33,8 +33,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('discover integration with runtime fields editor', function describeIndexTests() { before(async function () { - await esArchiver.load('discover'); - await esArchiver.loadIfNeeded('logstash_functional'); + await esArchiver.load('test/functional/fixtures/es_archiver/discover'); + await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/logstash_functional'); await kibanaServer.uiSettings.replace(defaultSettings); log.debug('discover'); await PageObjects.common.navigateToApp('discover'); diff --git a/test/functional/apps/discover/_saved_queries.ts b/test/functional/apps/discover/_saved_queries.ts index acf78802fa18f..67806c9d16a94 100644 --- a/test/functional/apps/discover/_saved_queries.ts +++ b/test/functional/apps/discover/_saved_queries.ts @@ -33,7 +33,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await kibanaServer.importExport.load('discover'); // and load a set of makelogs data - await esArchiver.loadIfNeeded('logstash_functional'); + await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/logstash_functional'); await kibanaServer.uiSettings.replace(defaultSettings); log.debug('discover'); await PageObjects.common.navigateToApp('discover'); diff --git a/test/functional/apps/discover/_shared_links.ts b/test/functional/apps/discover/_shared_links.ts index 512e05e4b2d79..151e8555eea77 100644 --- a/test/functional/apps/discover/_shared_links.ts +++ b/test/functional/apps/discover/_shared_links.ts @@ -39,7 +39,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { log.debug('load kibana index with default index pattern'); await kibanaServer.savedObjects.clean({ types: ['search', 'index-pattern'] }); await kibanaServer.importExport.load('discover'); - await esArchiver.loadIfNeeded('logstash_functional'); + await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/logstash_functional'); await kibanaServer.uiSettings.replace({ 'state:storeInSessionStorage': storeStateInSessionStorage, diff --git a/test/functional/apps/discover/_sidebar.ts b/test/functional/apps/discover/_sidebar.ts index f4b806976fc5d..d8701261126c4 100644 --- a/test/functional/apps/discover/_sidebar.ts +++ b/test/functional/apps/discover/_sidebar.ts @@ -16,8 +16,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('discover sidebar', function describeIndexTests() { before(async function () { - await esArchiver.loadIfNeeded('logstash_functional'); - await esArchiver.loadIfNeeded('discover'); + await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/logstash_functional'); + await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/discover'); await kibanaServer.uiSettings.replace({ defaultIndex: 'logstash-*', }); diff --git a/test/functional/apps/discover/_source_filters.ts b/test/functional/apps/discover/_source_filters.ts index 4161f7f289dbf..f3793dc3e0288 100644 --- a/test/functional/apps/discover/_source_filters.ts +++ b/test/functional/apps/discover/_source_filters.ts @@ -24,10 +24,10 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); log.debug('load kibana index with default index pattern'); - await esArchiver.load('visualize_source-filters'); + await esArchiver.load('test/functional/fixtures/es_archiver/visualize_source-filters'); // and load a set of makelogs data - await esArchiver.loadIfNeeded('logstash_functional'); + await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/logstash_functional'); await kibanaServer.uiSettings.update({ 'discover:searchFieldsFromSource': false, diff --git a/test/functional/apps/discover/index.ts b/test/functional/apps/discover/index.ts index db76cd1c20c38..869fb625e8796 100644 --- a/test/functional/apps/discover/index.ts +++ b/test/functional/apps/discover/index.ts @@ -20,7 +20,7 @@ export default function ({ getService, loadTestFile }: FtrProviderContext) { }); after(function unloadMakelogs() { - return esArchiver.unload('logstash_functional'); + return esArchiver.unload('test/functional/fixtures/es_archiver/logstash_functional'); }); loadTestFile(require.resolve('./_saved_queries')); diff --git a/test/functional/apps/getting_started/_shakespeare.ts b/test/functional/apps/getting_started/_shakespeare.ts index 4bc1f54852b82..945c1fdcbdcf4 100644 --- a/test/functional/apps/getting_started/_shakespeare.ts +++ b/test/functional/apps/getting_started/_shakespeare.ts @@ -46,9 +46,13 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { ); isNewChartsLibraryEnabled = await PageObjects.visChart.isNewChartsLibraryEnabled(); await security.testUser.setRoles(['kibana_admin', 'test_shakespeare_reader']); - await esArchiver.load('empty_kibana', { skipExisting: true }); + await esArchiver.load('test/functional/fixtures/es_archiver/empty_kibana', { + skipExisting: true, + }); log.debug('Load shakespeare data'); - await esArchiver.loadIfNeeded('getting_started/shakespeare'); + await esArchiver.loadIfNeeded( + 'test/functional/fixtures/es_archiver/getting_started/shakespeare' + ); if (isNewChartsLibraryEnabled) { await kibanaServer.uiSettings.update({ diff --git a/test/functional/apps/home/_navigation.ts b/test/functional/apps/home/_navigation.ts index 401f33b789c85..a57ce0596abac 100644 --- a/test/functional/apps/home/_navigation.ts +++ b/test/functional/apps/home/_navigation.ts @@ -17,8 +17,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('Kibana browser back navigation should work', function describeIndexTests() { before(async () => { - await esArchiver.loadIfNeeded('discover'); - await esArchiver.loadIfNeeded('logstash_functional'); + await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/discover'); + await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/logstash_functional'); }); it('detect navigate back issues', async () => { diff --git a/test/functional/apps/management/_field_formatter.js b/test/functional/apps/management/_field_formatter.js index 49b6c162caa41..383b4faecc40c 100644 --- a/test/functional/apps/management/_field_formatter.js +++ b/test/functional/apps/management/_field_formatter.js @@ -18,7 +18,7 @@ export default function ({ getService, getPageObjects }) { before(async function () { await browser.setWindowSize(1200, 800); - await esArchiver.load('discover'); + await esArchiver.load('test/functional/fixtures/es_archiver/discover'); await kibanaServer.uiSettings.replace({}); await kibanaServer.uiSettings.update({}); }); diff --git a/test/functional/apps/management/_handle_alias.js b/test/functional/apps/management/_handle_alias.js index 6c90556d77cf0..891e59d84a04b 100644 --- a/test/functional/apps/management/_handle_alias.js +++ b/test/functional/apps/management/_handle_alias.js @@ -18,8 +18,8 @@ export default function ({ getService, getPageObjects }) { describe('Index patterns on aliases', function () { before(async function () { await security.testUser.setRoles(['kibana_admin', 'test_alias_reader']); - await esArchiver.loadIfNeeded('alias'); - await esArchiver.load('empty_kibana'); + await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/alias'); + await esArchiver.load('test/functional/fixtures/es_archiver/empty_kibana'); await es.indices.updateAliases({ body: { actions: [ @@ -71,7 +71,7 @@ export default function ({ getService, getPageObjects }) { after(async () => { await security.testUser.restoreDefaults(); - await esArchiver.unload('alias'); + await esArchiver.unload('test/functional/fixtures/es_archiver/alias'); }); }); } diff --git a/test/functional/apps/management/_handle_version_conflict.js b/test/functional/apps/management/_handle_version_conflict.js index 2daad1e457a6b..82723ad7ce967 100644 --- a/test/functional/apps/management/_handle_version_conflict.js +++ b/test/functional/apps/management/_handle_version_conflict.js @@ -30,7 +30,7 @@ export default function ({ getService, getPageObjects }) { describe('index version conflict', function describeIndexTests() { before(async function () { await browser.setWindowSize(1200, 800); - await esArchiver.load('discover'); + await esArchiver.load('test/functional/fixtures/es_archiver/discover'); }); it('Should be able to surface version conflict notification while creating scripted field', async function () { diff --git a/test/functional/apps/management/_import_objects.ts b/test/functional/apps/management/_import_objects.ts index d9eb945be7777..0278955c577a1 100644 --- a/test/functional/apps/management/_import_objects.ts +++ b/test/functional/apps/management/_import_objects.ts @@ -27,14 +27,14 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('import objects', function describeIndexTests() { describe('.ndjson file', () => { beforeEach(async function () { - await esArchiver.load('management'); + await esArchiver.load('test/functional/fixtures/es_archiver/management'); await kibanaServer.uiSettings.replace({}); await PageObjects.settings.navigateTo(); await PageObjects.settings.clickKibanaSavedObjects(); }); afterEach(async function () { - await esArchiver.unload('management'); + await esArchiver.unload('test/functional/fixtures/es_archiver/management'); }); it('should import saved objects', async function () { @@ -213,14 +213,14 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('.json file', () => { beforeEach(async function () { - await esArchiver.load('saved_objects_imports'); + await esArchiver.load('test/functional/fixtures/es_archiver/saved_objects_imports'); await kibanaServer.uiSettings.replace({}); await PageObjects.settings.navigateTo(); await PageObjects.settings.clickKibanaSavedObjects(); }); afterEach(async function () { - await esArchiver.unload('saved_objects_imports'); + await esArchiver.unload('test/functional/fixtures/es_archiver/saved_objects_imports'); }); it('should import saved objects', async function () { diff --git a/test/functional/apps/management/_index_patterns_empty.ts b/test/functional/apps/management/_index_patterns_empty.ts index 3a09340f06ba0..038039275b843 100644 --- a/test/functional/apps/management/_index_patterns_empty.ts +++ b/test/functional/apps/management/_index_patterns_empty.ts @@ -20,14 +20,14 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { describe('index pattern empty view', () => { before(async () => { await esArchiver.emptyKibanaIndex(); - await esArchiver.unload('logstash_functional'); - await esArchiver.unload('makelogs'); + await esArchiver.unload('test/functional/fixtures/es_archiver/logstash_functional'); + await esArchiver.unload('test/functional/fixtures/es_archiver/makelogs'); await kibanaServer.uiSettings.replace({}); await PageObjects.settings.navigateTo(); }); after(async () => { - await esArchiver.loadIfNeeded('makelogs'); + await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/makelogs'); await es.transport.request({ path: '/logstash-a', method: 'DELETE', diff --git a/test/functional/apps/management/_mgmt_import_saved_objects.js b/test/functional/apps/management/_mgmt_import_saved_objects.js index 8697dc49de46a..84e57a798c006 100644 --- a/test/functional/apps/management/_mgmt_import_saved_objects.js +++ b/test/functional/apps/management/_mgmt_import_saved_objects.js @@ -19,12 +19,12 @@ export default function ({ getService, getPageObjects }) { describe('mgmt saved objects', function describeIndexTests() { beforeEach(async function () { await esArchiver.emptyKibanaIndex(); - await esArchiver.load('discover'); + await esArchiver.load('test/functional/fixtures/es_archiver/discover'); await PageObjects.settings.navigateTo(); }); afterEach(async function () { - await esArchiver.unload('discover'); + await esArchiver.unload('test/functional/fixtures/es_archiver/discover'); }); it('should import saved objects mgmt', async function () { diff --git a/test/functional/apps/management/_runtime_fields.js b/test/functional/apps/management/_runtime_fields.js index 44abf07b38ac6..105e1a394fecb 100644 --- a/test/functional/apps/management/_runtime_fields.js +++ b/test/functional/apps/management/_runtime_fields.js @@ -23,7 +23,7 @@ export default function ({ getService, getPageObjects }) { before(async function () { await browser.setWindowSize(1200, 800); - await esArchiver.load('discover'); + await esArchiver.load('test/functional/fixtures/es_archiver/discover'); // delete .kibana index and then wait for Kibana to re-create it await kibanaServer.uiSettings.replace({}); await kibanaServer.uiSettings.update({}); diff --git a/test/functional/apps/management/_scripted_fields.js b/test/functional/apps/management/_scripted_fields.js index c7a4c8c51bf44..2ff9e55c59ebb 100644 --- a/test/functional/apps/management/_scripted_fields.js +++ b/test/functional/apps/management/_scripted_fields.js @@ -46,7 +46,7 @@ export default function ({ getService, getPageObjects }) { before(async function () { await browser.setWindowSize(1200, 800); - await esArchiver.load('discover'); + await esArchiver.load('test/functional/fixtures/es_archiver/discover'); // delete .kibana index and then wait for Kibana to re-create it await kibanaServer.uiSettings.replace({}); await kibanaServer.uiSettings.update({ 'doc_table:legacy': true }); diff --git a/test/functional/apps/management/_scripted_fields_filter.js b/test/functional/apps/management/_scripted_fields_filter.js index 7ed15a6cddbca..6ced089936e5e 100644 --- a/test/functional/apps/management/_scripted_fields_filter.js +++ b/test/functional/apps/management/_scripted_fields_filter.js @@ -20,14 +20,14 @@ export default function ({ getService, getPageObjects }) { before(async function () { // delete .kibana index and then wait for Kibana to re-create it await browser.setWindowSize(1200, 800); - await esArchiver.load('management'); + await esArchiver.load('test/functional/fixtures/es_archiver/management'); await kibanaServer.uiSettings.replace({ defaultIndex: 'f1e4c910-a2e6-11e7-bb30-233be9be6a15', }); }); after(async function () { - await esArchiver.load('empty_kibana'); + await esArchiver.load('test/functional/fixtures/es_archiver/empty_kibana'); }); const scriptedPainlessFieldName = 'ram_pain1'; diff --git a/test/functional/apps/management/_test_huge_fields.js b/test/functional/apps/management/_test_huge_fields.js index dcfb8cf8b4c6b..c8710a79e4fc8 100644 --- a/test/functional/apps/management/_test_huge_fields.js +++ b/test/functional/apps/management/_test_huge_fields.js @@ -21,7 +21,7 @@ export default function ({ getService, getPageObjects }) { before(async function () { await security.testUser.setRoles(['kibana_admin', 'test_testhuge_reader'], false); await esArchiver.emptyKibanaIndex(); - await esArchiver.loadIfNeeded('large_fields'); + await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/large_fields'); await PageObjects.settings.navigateTo(); await PageObjects.settings.createIndexPattern('testhuge', 'date'); }); @@ -33,7 +33,7 @@ export default function ({ getService, getPageObjects }) { after(async () => { await security.testUser.restoreDefaults(); - await esArchiver.unload('large_fields'); + await esArchiver.unload('test/functional/fixtures/es_archiver/large_fields'); }); }); } diff --git a/test/functional/apps/management/index.ts b/test/functional/apps/management/index.ts index ac0df0aa90c4d..c8049d2db4b28 100644 --- a/test/functional/apps/management/index.ts +++ b/test/functional/apps/management/index.ts @@ -13,12 +13,12 @@ export default function ({ getService, loadTestFile }: FtrProviderContext) { describe('management', function () { before(async () => { - await esArchiver.unload('logstash_functional'); - await esArchiver.loadIfNeeded('makelogs'); + await esArchiver.unload('test/functional/fixtures/es_archiver/logstash_functional'); + await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/makelogs'); }); after(async () => { - await esArchiver.unload('makelogs'); + await esArchiver.unload('test/functional/fixtures/es_archiver/makelogs'); }); describe('', function () { diff --git a/test/functional/apps/saved_objects_management/edit_saved_object.ts b/test/functional/apps/saved_objects_management/edit_saved_object.ts index 89889088bd73b..a90e927416685 100644 --- a/test/functional/apps/saved_objects_management/edit_saved_object.ts +++ b/test/functional/apps/saved_objects_management/edit_saved_object.ts @@ -57,11 +57,15 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { describe('saved objects edition page', () => { beforeEach(async () => { - await esArchiver.load('saved_objects_management/edit_saved_object'); + await esArchiver.load( + 'test/functional/fixtures/es_archiver/saved_objects_management/edit_saved_object' + ); }); afterEach(async () => { - await esArchiver.unload('saved_objects_management/edit_saved_object'); + await esArchiver.unload( + 'test/functional/fixtures/es_archiver/saved_objects_management/edit_saved_object' + ); }); it('allows to update the saved object when submitting', async () => { diff --git a/test/functional/apps/saved_objects_management/show_relationships.ts b/test/functional/apps/saved_objects_management/show_relationships.ts index 92c65323333d0..26fd2a00430f1 100644 --- a/test/functional/apps/saved_objects_management/show_relationships.ts +++ b/test/functional/apps/saved_objects_management/show_relationships.ts @@ -15,11 +15,15 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { describe('saved objects relationships flyout', () => { beforeEach(async () => { - await esArchiver.load('saved_objects_management/show_relationships'); + await esArchiver.load( + 'test/functional/fixtures/es_archiver/saved_objects_management/show_relationships' + ); }); afterEach(async () => { - await esArchiver.unload('saved_objects_management/show_relationships'); + await esArchiver.unload( + 'test/functional/fixtures/es_archiver/saved_objects_management/show_relationships' + ); }); it('displays the invalid references', async () => { diff --git a/test/functional/apps/timelion/index.js b/test/functional/apps/timelion/index.js index 8fba1a5ae2e5b..b81a0e70d8a6d 100644 --- a/test/functional/apps/timelion/index.js +++ b/test/functional/apps/timelion/index.js @@ -18,7 +18,7 @@ export default function ({ getService, loadTestFile }) { before(async function () { log.debug('Starting timelion before method'); await browser.setWindowSize(1280, 800); - await esArchiver.loadIfNeeded('logstash_functional'); + await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/logstash_functional'); await kibanaServer.uiSettings.replace({ defaultIndex: 'logstash-*' }); }); diff --git a/test/functional/apps/visualize/_histogram_request_start.ts b/test/functional/apps/visualize/_histogram_request_start.ts index 8b5c31701d025..28ebb25744d3f 100644 --- a/test/functional/apps/visualize/_histogram_request_start.ts +++ b/test/functional/apps/visualize/_histogram_request_start.ts @@ -26,10 +26,10 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('histogram agg onSearchRequestStart', function () { before(async function () { // loading back default data - await esArchiver.load('empty_kibana'); + await esArchiver.load('test/functional/fixtures/es_archiver/empty_kibana'); - await esArchiver.loadIfNeeded('logstash_functional'); - await esArchiver.loadIfNeeded('long_window_logstash'); + await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/logstash_functional'); + await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/long_window_logstash'); await PageObjects.visualize.initTests(); log.debug('navigateToApp visualize'); diff --git a/test/functional/apps/visualize/_tsvb_chart.ts b/test/functional/apps/visualize/_tsvb_chart.ts index 690db676cb368..1d4d4fee0175e 100644 --- a/test/functional/apps/visualize/_tsvb_chart.ts +++ b/test/functional/apps/visualize/_tsvb_chart.ts @@ -127,7 +127,9 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('switch index patterns', () => { before(async () => { - await esArchiver.loadIfNeeded('index_pattern_without_timefield'); + await esArchiver.loadIfNeeded( + 'test/functional/fixtures/es_archiver/index_pattern_without_timefield' + ); }); beforeEach(async () => { @@ -146,7 +148,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { after(async () => { await security.testUser.restoreDefaults(); - await esArchiver.load('empty_kibana'); + await esArchiver.load('test/functional/fixtures/es_archiver/empty_kibana'); await PageObjects.visualize.initTests(); }); diff --git a/test/functional/apps/visualize/index.ts b/test/functional/apps/visualize/index.ts index 1e0e12a7d31bb..cecd206abd1db 100644 --- a/test/functional/apps/visualize/index.ts +++ b/test/functional/apps/visualize/index.ts @@ -18,10 +18,10 @@ export default function ({ getService, loadTestFile }: FtrProviderContext) { before(async () => { log.debug('Starting visualize before method'); await browser.setWindowSize(1280, 800); - await esArchiver.load('empty_kibana'); + await esArchiver.load('test/functional/fixtures/es_archiver/empty_kibana'); - await esArchiver.loadIfNeeded('logstash_functional'); - await esArchiver.loadIfNeeded('long_window_logstash'); + await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/logstash_functional'); + await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/long_window_logstash'); }); // TODO: Remove when vislib is removed diff --git a/test/functional/apps/visualize/input_control_vis/input_control_range.ts b/test/functional/apps/visualize/input_control_vis/input_control_range.ts index 97e746ba4a4c0..566e6f033d2fd 100644 --- a/test/functional/apps/visualize/input_control_vis/input_control_range.ts +++ b/test/functional/apps/visualize/input_control_vis/input_control_range.ts @@ -22,7 +22,9 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { before(async () => { await PageObjects.visualize.initTests(); await security.testUser.setRoles(['kibana_admin', 'kibana_sample_admin']); - await esArchiver.load('kibana_sample_data_flights_index_pattern'); + await esArchiver.load( + 'test/functional/fixtures/es_archiver/kibana_sample_data_flights_index_pattern' + ); await visualize.navigateToNewVisualization(); await visualize.clickInputControlVis(); }); @@ -50,7 +52,9 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); after(async () => { - await esArchiver.unload('kibana_sample_data_flights_index_pattern'); + await esArchiver.unload( + 'test/functional/fixtures/es_archiver/kibana_sample_data_flights_index_pattern' + ); await security.testUser.restoreDefaults(); }); }); diff --git a/test/functional/apps/visualize/legacy/index.ts b/test/functional/apps/visualize/legacy/index.ts index 914559e5cea92..4e43ec90d1699 100644 --- a/test/functional/apps/visualize/legacy/index.ts +++ b/test/functional/apps/visualize/legacy/index.ts @@ -21,8 +21,8 @@ export default function ({ getPageObjects, getService, loadTestFile }: FtrProvid await PageObjects.visualize.initTests(); log.debug('Starting visualize legacy before method'); await browser.setWindowSize(1280, 800); - await esArchiver.loadIfNeeded('logstash_functional'); - await esArchiver.loadIfNeeded('long_window_logstash'); + await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/logstash_functional'); + await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/long_window_logstash'); await kibanaServer.importExport.load('visualize'); await kibanaServer.uiSettings.replace({ defaultIndex: 'logstash-*', diff --git a/test/functional/page_objects/dashboard_page.ts b/test/functional/page_objects/dashboard_page.ts index 37dd4520a48f4..ecba9549cea02 100644 --- a/test/functional/page_objects/dashboard_page.ts +++ b/test/functional/page_objects/dashboard_page.ts @@ -41,7 +41,10 @@ export class DashboardPageObject extends FtrService { private readonly visualize = this.ctx.getPageObject('visualize'); private readonly discover = this.ctx.getPageObject('discover'); - async initTests({ kibanaIndex = 'dashboard/legacy', defaultIndex = 'logstash-*' } = {}) { + async initTests({ + kibanaIndex = 'test/functional/fixtures/es_archiver/dashboard/legacy', + defaultIndex = 'logstash-*', + } = {}) { this.log.debug('load kibana index with visualizations and log data'); await this.esArchiver.load(kibanaIndex); await this.kibanaServer.uiSettings.replace({ defaultIndex }); diff --git a/test/functional/page_objects/timelion_page.ts b/test/functional/page_objects/timelion_page.ts index 57913f8e2413d..65584d98022be 100644 --- a/test/functional/page_objects/timelion_page.ts +++ b/test/functional/page_objects/timelion_page.ts @@ -21,7 +21,7 @@ export class TimelionPageObject extends FtrService { }); this.log.debug('load kibana index'); - await this.esArchiver.load('timelion'); + await this.esArchiver.load('test/functional/fixtures/es_archiver/timelion'); await this.common.navigateToApp('timelion'); } diff --git a/test/interpreter_functional/config.ts b/test/interpreter_functional/config.ts index adcac520125ad..c0ec982fb98b6 100644 --- a/test/interpreter_functional/config.ts +++ b/test/interpreter_functional/config.ts @@ -26,9 +26,6 @@ export default async function ({ readConfigFile }: FtrConfigProviderContext) { servers: functionalConfig.get('servers'), esTestCluster: functionalConfig.get('esTestCluster'), apps: functionalConfig.get('apps'), - esArchiver: { - directory: path.resolve(__dirname, '../es_archives'), - }, snapshots: { directory: path.resolve(__dirname, 'snapshots'), }, diff --git a/test/interpreter_functional/test_suites/run_pipeline/index.ts b/test/interpreter_functional/test_suites/run_pipeline/index.ts index 18d20c97be81e..9cf7e0deba2fa 100644 --- a/test/interpreter_functional/test_suites/run_pipeline/index.ts +++ b/test/interpreter_functional/test_suites/run_pipeline/index.ts @@ -20,8 +20,8 @@ export default function ({ getService, getPageObjects, loadTestFile }: FtrProvid this.tags(['skipFirefox']); before(async () => { - await esArchiver.loadIfNeeded('../functional/fixtures/es_archiver/logstash_functional'); - await esArchiver.load('../functional/fixtures/es_archiver/visualize_embedding'); + await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/logstash_functional'); + await esArchiver.load('test/functional/fixtures/es_archiver/visualize_embedding'); await kibanaServer.uiSettings.replace({ 'dateFormat:tz': 'Australia/North', defaultIndex: 'logstash-*', diff --git a/test/new_visualize_flow/dashboard_embedding.ts b/test/new_visualize_flow/dashboard_embedding.ts index 04b91542223ba..3470973f9c96c 100644 --- a/test/new_visualize_flow/dashboard_embedding.ts +++ b/test/new_visualize_flow/dashboard_embedding.ts @@ -34,7 +34,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('Dashboard Embedding', function describeIndexTests() { before(async () => { - await esArchiver.load('kibana'); + await esArchiver.load('test/new_visualize_flow/fixtures/es_archiver/kibana'); await kibanaServer.uiSettings.replace({ defaultIndex: '0bf35f60-3dc9-11e8-8660-4d65aa086b3c', }); diff --git a/test/new_visualize_flow/index.ts b/test/new_visualize_flow/index.ts index d17501305d0bd..02245002e8336 100644 --- a/test/new_visualize_flow/index.ts +++ b/test/new_visualize_flow/index.ts @@ -14,7 +14,9 @@ export default function ({ loadTestFile, getService }: FtrProviderContext) { this.tags('ciGroup2'); const esArchiver = getService('esArchiver'); before(async () => { - await esArchiver.loadIfNeeded('logstash_functional'); + await esArchiver.loadIfNeeded( + 'test/new_visualize_flow/fixtures/es_archiver/logstash_functional' + ); }); loadTestFile(require.resolve('./dashboard_embedding')); diff --git a/test/plugin_functional/config.ts b/test/plugin_functional/config.ts index 631cbc8146d65..3791e663fb68c 100644 --- a/test/plugin_functional/config.ts +++ b/test/plugin_functional/config.ts @@ -44,9 +44,6 @@ export default async function ({ readConfigFile }: FtrConfigProviderContext) { serverArgs: ['xpack.security.enabled=false'], }, apps: functionalConfig.get('apps'), - esArchiver: { - directory: path.resolve(__dirname, '../es_archives'), - }, screenshots: functionalConfig.get('screenshots'), junit: { reportName: 'Plugin Functional Tests', diff --git a/test/plugin_functional/test_suites/core/deprecations.ts b/test/plugin_functional/test_suites/core/deprecations.ts index 38a8b835b118c..112b29a896a00 100644 --- a/test/plugin_functional/test_suites/core/deprecations.ts +++ b/test/plugin_functional/test_suites/core/deprecations.ts @@ -76,8 +76,8 @@ export default function ({ getService, getPageObjects }: PluginFunctionalProvide ]; describe('deprecations service', () => { - before(() => esArchiver.load('../functional/fixtures/es_archiver/deprecations_service')); - after(() => esArchiver.unload('../functional/fixtures/es_archiver/deprecations_service')); + before(() => esArchiver.load('test/functional/fixtures/es_archiver/deprecations_service')); + after(() => esArchiver.unload('test/functional/fixtures/es_archiver/deprecations_service')); describe('GET /api/deprecations/', async () => { it('returns registered config deprecations and feature deprecations', async () => { diff --git a/test/plugin_functional/test_suites/custom_visualizations/index.js b/test/plugin_functional/test_suites/custom_visualizations/index.js index eaca1ad3f4d3b..0998b97da67ff 100644 --- a/test/plugin_functional/test_suites/custom_visualizations/index.js +++ b/test/plugin_functional/test_suites/custom_visualizations/index.js @@ -13,8 +13,8 @@ export default function ({ getService, loadTestFile }) { describe('custom visualizations', function () { before(async () => { - await esArchiver.loadIfNeeded('../functional/fixtures/es_archiver/logstash_functional'); - await esArchiver.loadIfNeeded('../functional/fixtures/es_archiver/visualize'); + await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/logstash_functional'); + await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/visualize'); await kibanaServer.uiSettings.replace({ 'dateFormat:tz': 'Australia/North', defaultIndex: 'logstash-*', diff --git a/test/plugin_functional/test_suites/data_plugin/index.ts b/test/plugin_functional/test_suites/data_plugin/index.ts index d39eb839d322d..01a88dbd19b15 100644 --- a/test/plugin_functional/test_suites/data_plugin/index.ts +++ b/test/plugin_functional/test_suites/data_plugin/index.ts @@ -19,7 +19,7 @@ export default function ({ describe('data plugin', () => { before(async () => { await esArchiver.loadIfNeeded( - '../functional/fixtures/es_archiver/getting_started/shakespeare' + 'test/functional/fixtures/es_archiver/getting_started/shakespeare' ); await PageObjects.common.navigateToApp('settings'); await PageObjects.settings.createIndexPattern('shakespeare', ''); diff --git a/test/plugin_functional/test_suites/data_plugin/session.ts b/test/plugin_functional/test_suites/data_plugin/session.ts index ae4f8ffdf4072..54b86f0c8060b 100644 --- a/test/plugin_functional/test_suites/data_plugin/session.ts +++ b/test/plugin_functional/test_suites/data_plugin/session.ts @@ -70,9 +70,11 @@ export default function ({ getService, getPageObjects }: PluginFunctionalProvide describe('Dashboard', () => { before(async () => { - await esArchiver.loadIfNeeded('../functional/fixtures/es_archiver/dashboard/current/data'); await esArchiver.loadIfNeeded( - '../functional/fixtures/es_archiver/dashboard/current/kibana' + 'test/functional/fixtures/es_archiver/dashboard/current/data' + ); + await esArchiver.loadIfNeeded( + 'test/functional/fixtures/es_archiver/dashboard/current/kibana' ); await PageObjects.common.navigateToApp('dashboard'); await PageObjects.dashboard.loadSavedDashboard('dashboard with filter'); @@ -85,8 +87,8 @@ export default function ({ getService, getPageObjects }: PluginFunctionalProvide }); after(async () => { - await esArchiver.unload('../functional/fixtures/es_archiver/dashboard/current/data'); - await esArchiver.unload('../functional/fixtures/es_archiver/dashboard/current/kibana'); + await esArchiver.unload('test/functional/fixtures/es_archiver/dashboard/current/data'); + await esArchiver.unload('test/functional/fixtures/es_archiver/dashboard/current/kibana'); }); it('on load there is a single session', async () => { diff --git a/test/plugin_functional/test_suites/doc_views/index.ts b/test/plugin_functional/test_suites/doc_views/index.ts index e02b9ac4646f6..a790f062e32d4 100644 --- a/test/plugin_functional/test_suites/doc_views/index.ts +++ b/test/plugin_functional/test_suites/doc_views/index.ts @@ -14,7 +14,7 @@ export default function ({ getService, loadTestFile }: PluginFunctionalProviderC // SKIPPED: https://github.com/elastic/kibana/issues/100060 describe.skip('doc views', function () { before(async () => { - await esArchiver.loadIfNeeded('../functional/fixtures/es_archiver/discover'); + await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/discover'); }); loadTestFile(require.resolve('./doc_views')); diff --git a/test/plugin_functional/test_suites/panel_actions/index.js b/test/plugin_functional/test_suites/panel_actions/index.js index 4951b810854fe..70e6ed67b218c 100644 --- a/test/plugin_functional/test_suites/panel_actions/index.js +++ b/test/plugin_functional/test_suites/panel_actions/index.js @@ -6,17 +6,6 @@ * Side Public License, v 1. */ -import path from 'path'; - -export const KIBANA_ARCHIVE_PATH = path.resolve( - __dirname, - '../../../functional/fixtures/es_archiver/dashboard/current/kibana' -); -export const DATA_ARCHIVE_PATH = path.resolve( - __dirname, - '../../../functional/fixtures/es_archiver/dashboard/current/data' -); - export default function ({ getService, getPageObjects, loadTestFile }) { const browser = getService('browser'); const esArchiver = getService('esArchiver'); @@ -26,8 +15,8 @@ export default function ({ getService, getPageObjects, loadTestFile }) { describe('pluggable panel actions', function () { before(async () => { await browser.setWindowSize(1300, 900); - await esArchiver.load(KIBANA_ARCHIVE_PATH); - await esArchiver.loadIfNeeded(DATA_ARCHIVE_PATH); + await esArchiver.load('test/functional/fixtures/es_archiver/dashboard/current/kibana'); + await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/dashboard/current/data'); await kibanaServer.uiSettings.replace({ defaultIndex: 'logstash-*', }); @@ -37,8 +26,8 @@ export default function ({ getService, getPageObjects, loadTestFile }) { after(async function () { await PageObjects.dashboard.clearSavedObjectsFromAppLinks(); - await esArchiver.unload(KIBANA_ARCHIVE_PATH); - await esArchiver.unload(DATA_ARCHIVE_PATH); + await esArchiver.unload('test/functional/fixtures/es_archiver/dashboard/current/kibana'); + await esArchiver.unload('test/functional/fixtures/es_archiver/dashboard/current/data'); }); loadTestFile(require.resolve('./panel_actions')); diff --git a/test/plugin_functional/test_suites/saved_objects_hidden_type/delete.ts b/test/plugin_functional/test_suites/saved_objects_hidden_type/delete.ts index 666afe1acedca..04fcc29efe612 100644 --- a/test/plugin_functional/test_suites/saved_objects_hidden_type/delete.ts +++ b/test/plugin_functional/test_suites/saved_objects_hidden_type/delete.ts @@ -16,12 +16,12 @@ export default function ({ getService }: PluginFunctionalProviderContext) { describe('delete', () => { before(() => esArchiver.load( - '../functional/fixtures/es_archiver/saved_objects_management/hidden_saved_objects' + 'test/functional/fixtures/es_archiver/saved_objects_management/hidden_saved_objects' ) ); after(() => esArchiver.unload( - '../functional/fixtures/es_archiver/saved_objects_management/hidden_saved_objects' + 'test/functional/fixtures/es_archiver/saved_objects_management/hidden_saved_objects' ) ); diff --git a/test/plugin_functional/test_suites/saved_objects_hidden_type/export.ts b/test/plugin_functional/test_suites/saved_objects_hidden_type/export.ts index af25835db5a81..9d1f370dc73e7 100644 --- a/test/plugin_functional/test_suites/saved_objects_hidden_type/export.ts +++ b/test/plugin_functional/test_suites/saved_objects_hidden_type/export.ts @@ -20,12 +20,12 @@ export default function ({ getService }: PluginFunctionalProviderContext) { describe('export', () => { before(() => esArchiver.load( - '../functional/fixtures/es_archiver/saved_objects_management/hidden_saved_objects' + 'test/functional/fixtures/es_archiver/saved_objects_management/hidden_saved_objects' ) ); after(() => esArchiver.unload( - '../functional/fixtures/es_archiver/saved_objects_management/hidden_saved_objects' + 'test/functional/fixtures/es_archiver/saved_objects_management/hidden_saved_objects' ) ); diff --git a/test/plugin_functional/test_suites/saved_objects_hidden_type/find.ts b/test/plugin_functional/test_suites/saved_objects_hidden_type/find.ts index 723140f5c6bf5..5a31da2b57a8e 100644 --- a/test/plugin_functional/test_suites/saved_objects_hidden_type/find.ts +++ b/test/plugin_functional/test_suites/saved_objects_hidden_type/find.ts @@ -16,12 +16,12 @@ export default function ({ getService }: PluginFunctionalProviderContext) { describe('find', () => { before(() => esArchiver.load( - '../functional/fixtures/es_archiver/saved_objects_management/hidden_saved_objects' + 'test/functional/fixtures/es_archiver/saved_objects_management/hidden_saved_objects' ) ); after(() => esArchiver.unload( - '../functional/fixtures/es_archiver/saved_objects_management/hidden_saved_objects' + 'test/functional/fixtures/es_archiver/saved_objects_management/hidden_saved_objects' ) ); diff --git a/test/plugin_functional/test_suites/saved_objects_hidden_type/import.ts b/test/plugin_functional/test_suites/saved_objects_hidden_type/import.ts index 5de7d8375dd8c..70241ade50a3d 100644 --- a/test/plugin_functional/test_suites/saved_objects_hidden_type/import.ts +++ b/test/plugin_functional/test_suites/saved_objects_hidden_type/import.ts @@ -16,12 +16,12 @@ export default function ({ getService }: PluginFunctionalProviderContext) { describe('import', () => { before(() => esArchiver.load( - '../functional/fixtures/es_archiver/saved_objects_management/hidden_saved_objects' + 'test/functional/fixtures/es_archiver/saved_objects_management/hidden_saved_objects' ) ); after(() => esArchiver.unload( - '../functional/fixtures/es_archiver/saved_objects_management/hidden_saved_objects' + 'test/functional/fixtures/es_archiver/saved_objects_management/hidden_saved_objects' ) ); diff --git a/test/plugin_functional/test_suites/saved_objects_hidden_type/resolve_import_errors.ts b/test/plugin_functional/test_suites/saved_objects_hidden_type/resolve_import_errors.ts index dddee085ae22b..8af5e07ab69ad 100644 --- a/test/plugin_functional/test_suites/saved_objects_hidden_type/resolve_import_errors.ts +++ b/test/plugin_functional/test_suites/saved_objects_hidden_type/resolve_import_errors.ts @@ -16,12 +16,12 @@ export default function ({ getService }: PluginFunctionalProviderContext) { describe('export', () => { before(() => esArchiver.load( - '../functional/fixtures/es_archiver/saved_objects_management/hidden_saved_objects' + 'test/functional/fixtures/es_archiver/saved_objects_management/hidden_saved_objects' ) ); after(() => esArchiver.unload( - '../functional/fixtures/es_archiver/saved_objects_management/hidden_saved_objects' + 'test/functional/fixtures/es_archiver/saved_objects_management/hidden_saved_objects' ) ); diff --git a/test/plugin_functional/test_suites/saved_objects_management/export_transform.ts b/test/plugin_functional/test_suites/saved_objects_management/export_transform.ts index 2b845cb6327b8..0351c5abdde46 100644 --- a/test/plugin_functional/test_suites/saved_objects_management/export_transform.ts +++ b/test/plugin_functional/test_suites/saved_objects_management/export_transform.ts @@ -22,13 +22,13 @@ export default function ({ getService }: PluginFunctionalProviderContext) { describe('root objects export transforms', () => { before(async () => { await esArchiver.load( - '../functional/fixtures/es_archiver/saved_objects_management/export_transform' + 'test/functional/fixtures/es_archiver/saved_objects_management/export_transform' ); }); after(async () => { await esArchiver.unload( - '../functional/fixtures/es_archiver/saved_objects_management/export_transform' + 'test/functional/fixtures/es_archiver/saved_objects_management/export_transform' ); }); @@ -142,13 +142,13 @@ export default function ({ getService }: PluginFunctionalProviderContext) { describe('FOO nested export transforms', () => { before(async () => { await esArchiver.load( - '../functional/fixtures/es_archiver/saved_objects_management/nested_export_transform' + 'test/functional/fixtures/es_archiver/saved_objects_management/nested_export_transform' ); }); after(async () => { await esArchiver.unload( - '../functional/fixtures/es_archiver/saved_objects_management/nested_export_transform' + 'test/functional/fixtures/es_archiver/saved_objects_management/nested_export_transform' ); }); diff --git a/test/plugin_functional/test_suites/saved_objects_management/find.ts b/test/plugin_functional/test_suites/saved_objects_management/find.ts index e5a5d69c7e4d4..fdeb2c6f8b124 100644 --- a/test/plugin_functional/test_suites/saved_objects_management/find.ts +++ b/test/plugin_functional/test_suites/saved_objects_management/find.ts @@ -17,12 +17,12 @@ export default function ({ getService }: PluginFunctionalProviderContext) { describe('saved objects with hidden type', () => { before(() => esArchiver.load( - '../functional/fixtures/es_archiver/saved_objects_management/hidden_saved_objects' + 'test/functional/fixtures/es_archiver/saved_objects_management/hidden_saved_objects' ) ); after(() => esArchiver.unload( - '../functional/fixtures/es_archiver/saved_objects_management/hidden_saved_objects' + 'test/functional/fixtures/es_archiver/saved_objects_management/hidden_saved_objects' ) ); it('returns saved objects with importableAndExportable types', async () => diff --git a/test/plugin_functional/test_suites/saved_objects_management/get.ts b/test/plugin_functional/test_suites/saved_objects_management/get.ts index fa35983df8301..6a69aa9146f3e 100644 --- a/test/plugin_functional/test_suites/saved_objects_management/get.ts +++ b/test/plugin_functional/test_suites/saved_objects_management/get.ts @@ -17,12 +17,12 @@ export default function ({ getService }: PluginFunctionalProviderContext) { describe('saved objects with hidden type', () => { before(() => esArchiver.load( - '../functional/fixtures/es_archiver/saved_objects_management/hidden_saved_objects' + 'test/functional/fixtures/es_archiver/saved_objects_management/hidden_saved_objects' ) ); after(() => esArchiver.unload( - '../functional/fixtures/es_archiver/saved_objects_management/hidden_saved_objects' + 'test/functional/fixtures/es_archiver/saved_objects_management/hidden_saved_objects' ) ); const hiddenTypeExportableImportable = diff --git a/test/plugin_functional/test_suites/saved_objects_management/hidden_types.ts b/test/plugin_functional/test_suites/saved_objects_management/hidden_types.ts index 464b7c6e7ced7..8e7adb504ebee 100644 --- a/test/plugin_functional/test_suites/saved_objects_management/hidden_types.ts +++ b/test/plugin_functional/test_suites/saved_objects_management/hidden_types.ts @@ -24,13 +24,13 @@ export default function ({ getService, getPageObjects }: PluginFunctionalProvide describe('saved objects management with hidden types', () => { before(async () => { await esArchiver.load( - '../functional/fixtures/es_archiver/saved_objects_management/hidden_types' + 'test/functional/fixtures/es_archiver/saved_objects_management/hidden_types' ); }); after(async () => { await esArchiver.unload( - '../functional/fixtures/es_archiver/saved_objects_management/hidden_types' + 'test/functional/fixtures/es_archiver/saved_objects_management/hidden_types' ); }); diff --git a/test/plugin_functional/test_suites/saved_objects_management/scroll_count.ts b/test/plugin_functional/test_suites/saved_objects_management/scroll_count.ts index f74cd5b938447..0041344733f0d 100644 --- a/test/plugin_functional/test_suites/saved_objects_management/scroll_count.ts +++ b/test/plugin_functional/test_suites/saved_objects_management/scroll_count.ts @@ -18,12 +18,12 @@ export default function ({ getService }: PluginFunctionalProviderContext) { describe('saved objects with hidden type', () => { before(() => esArchiver.load( - '../functional/fixtures/es_archiver/saved_objects_management/hidden_saved_objects' + 'test/functional/fixtures/es_archiver/saved_objects_management/hidden_saved_objects' ) ); after(() => esArchiver.unload( - '../functional/fixtures/es_archiver/saved_objects_management/hidden_saved_objects' + 'test/functional/fixtures/es_archiver/saved_objects_management/hidden_saved_objects' ) ); diff --git a/test/security_functional/config.ts b/test/security_functional/config.ts index f61f3bbf240ec..b01f27b4cb7d6 100644 --- a/test/security_functional/config.ts +++ b/test/security_functional/config.ts @@ -19,9 +19,6 @@ export default async function ({ readConfigFile }: FtrConfigProviderContext) { servers: functionalConfig.get('servers'), esTestCluster: functionalConfig.get('esTestCluster'), apps: {}, - esArchiver: { - directory: path.resolve(__dirname, '../functional/fixtures/es_archiver'), - }, snapshots: { directory: path.resolve(__dirname, 'snapshots'), }, diff --git a/test/security_functional/insecure_cluster_warning.ts b/test/security_functional/insecure_cluster_warning.ts index 44a0e2eb0e121..238643e573540 100644 --- a/test/security_functional/insecure_cluster_warning.ts +++ b/test/security_functional/insecure_cluster_warning.ts @@ -20,17 +20,17 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await pageObjects.common.navigateToApp('home'); await browser.setLocalStorageItem('insecureClusterWarningVisibility', ''); // starting without user data - await esArchiver.unload('hamlet'); + await esArchiver.unload('test/functional/fixtures/es_archiver/hamlet'); }); after(async () => { - await esArchiver.unload('hamlet'); + await esArchiver.unload('test/functional/fixtures/es_archiver/hamlet'); }); describe('without user data', () => { before(async () => { await browser.setLocalStorageItem('insecureClusterWarningVisibility', ''); - await esArchiver.unload('hamlet'); + await esArchiver.unload('test/functional/fixtures/es_archiver/hamlet'); await esArchiver.emptyKibanaIndex(); }); @@ -48,11 +48,11 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { before(async () => { await pageObjects.common.navigateToApp('home'); await browser.setLocalStorageItem('insecureClusterWarningVisibility', ''); - await esArchiver.load('hamlet'); + await esArchiver.load('test/functional/fixtures/es_archiver/hamlet'); }); after(async () => { - await esArchiver.unload('hamlet'); + await esArchiver.unload('test/functional/fixtures/es_archiver/hamlet'); }); it('should warn about an insecure cluster, and hide when dismissed', async () => { diff --git a/test/visual_regression/tests/discover/chart_visualization.ts b/test/visual_regression/tests/discover/chart_visualization.ts index c8e4fdbef53b2..389a0a4b6a314 100644 --- a/test/visual_regression/tests/discover/chart_visualization.ts +++ b/test/visual_regression/tests/discover/chart_visualization.ts @@ -24,17 +24,17 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('discover', function describeIndexTests() { before(async function () { - await esArchiver.load('discover'); + await esArchiver.load('test/functional/fixtures/es_archiver/discover'); // and load a set of makelogs data - await esArchiver.loadIfNeeded('logstash_functional'); + await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/logstash_functional'); await kibanaServer.uiSettings.replace(defaultSettings); await PageObjects.common.navigateToApp('discover'); await PageObjects.timePicker.setDefaultAbsoluteRange(); }); after(function unloadMakelogs() { - return esArchiver.unload('logstash_functional'); + return esArchiver.unload('test/functional/fixtures/es_archiver/logstash_functional'); }); async function refreshDiscover() { diff --git a/test/visual_regression/tests/vega/vega_map_visualization.ts b/test/visual_regression/tests/vega/vega_map_visualization.ts index fa8704687bec9..96b08467e4a8f 100644 --- a/test/visual_regression/tests/vega/vega_map_visualization.ts +++ b/test/visual_regression/tests/vega/vega_map_visualization.ts @@ -15,13 +15,15 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('vega chart in visualize app', () => { before(async () => { - await esArchiver.loadIfNeeded('kibana_sample_data_flights'); - await esArchiver.loadIfNeeded('visualize'); + await esArchiver.loadIfNeeded( + 'test/functional/fixtures/es_archiver/kibana_sample_data_flights' + ); + await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/visualize'); }); after(async () => { - await esArchiver.unload('kibana_sample_data_flights'); - await esArchiver.unload('visualize'); + await esArchiver.unload('test/functional/fixtures/es_archiver/kibana_sample_data_flights'); + await esArchiver.unload('test/functional/fixtures/es_archiver/visualize'); }); it('should show map with vega layer', async function () { diff --git a/x-pack/plugins/apm/ftr_e2e/config.ts b/x-pack/plugins/apm/ftr_e2e/config.ts index cace655ad7c5b..38c196fbe70c2 100644 --- a/x-pack/plugins/apm/ftr_e2e/config.ts +++ b/x-pack/plugins/apm/ftr_e2e/config.ts @@ -21,10 +21,6 @@ async function config({ readConfigFile }: FtrConfigProviderContext) { return { ...kibanaCommonTestsConfig.getAll(), - esArchiver: { - directory: resolve(__dirname, 'cypress/fixtures/es_archiver'), - }, - esTestCluster: { ...xpackFunctionalTestsConfig.get('esTestCluster'), serverArgs: [ diff --git a/x-pack/plugins/apm/ftr_e2e/cypress/tasks/es_archiver.ts b/x-pack/plugins/apm/ftr_e2e/cypress/tasks/es_archiver.ts index 6388af94df16a..25090e14ebf91 100644 --- a/x-pack/plugins/apm/ftr_e2e/cypress/tasks/es_archiver.ts +++ b/x-pack/plugins/apm/ftr_e2e/cypress/tasks/es_archiver.ts @@ -5,15 +5,21 @@ * 2.0. */ +import Path from 'path'; + +const ES_ARCHIVE_DIR = './cypress/fixtures/es_archiver'; + export const esArchiverLoad = (folder: string) => { + const path = Path.join(ES_ARCHIVE_DIR, folder); cy.exec( - `node ../../../../scripts/es_archiver load ${folder} --dir ./cypress/fixtures/es_archiver --config ../../../test/functional/config.js` + `node ../../../../scripts/es_archiver load "${path}" --config ../../../test/functional/config.js` ); }; export const esArchiverUnload = (folder: string) => { + const path = Path.join(ES_ARCHIVE_DIR, folder); cy.exec( - `node ../../../../scripts/es_archiver unload ${folder} --dir ./cypress/fixtures/es_archiver --config ../../../test/functional/config.js` + `node ../../../../scripts/es_archiver unload "${path}" --config ../../../test/functional/config.js` ); }; diff --git a/x-pack/plugins/security_solution/cypress/tasks/es_archiver.ts b/x-pack/plugins/security_solution/cypress/tasks/es_archiver.ts index 2badeb6ffc10e..a0ee5bda82b01 100644 --- a/x-pack/plugins/security_solution/cypress/tasks/es_archiver.ts +++ b/x-pack/plugins/security_solution/cypress/tasks/es_archiver.ts @@ -5,27 +5,30 @@ * 2.0. */ +import Path from 'path'; + +const ES_ARCHIVE_DIR = '../../test/security_solution_cypress/es_archives'; +const CONFIG_PATH = '../../test/functional/config.js'; +const ES_URL = Cypress.env('ELASTICSEARCH_URL'); +const KIBANA_URL = Cypress.config().baseUrl; + export const esArchiverLoad = (folder: string) => { + const path = Path.join(ES_ARCHIVE_DIR, folder); cy.exec( - `node ../../../scripts/es_archiver load ${folder} --dir ../../test/security_solution_cypress/es_archives --config ../../../test/functional/config.js --es-url ${Cypress.env( - 'ELASTICSEARCH_URL' - )} --kibana-url ${Cypress.config().baseUrl}` + `node ../../../scripts/es_archiver load "${path}" --config "${CONFIG_PATH}" --es-url "${ES_URL}" --kibana-url "${KIBANA_URL}"` ); }; export const esArchiverUnload = (folder: string) => { + const path = Path.join(ES_ARCHIVE_DIR, folder); cy.exec( - `node ../../../scripts/es_archiver unload ${folder} --dir ../../test/security_solution_cypress/es_archives --config ../../../test/functional/config.js --es-url ${Cypress.env( - 'ELASTICSEARCH_URL' - )} --kibana-url ${Cypress.config().baseUrl}` + `node ../../../scripts/es_archiver unload "${path}" --config "${CONFIG_PATH}" --es-url "${ES_URL}" --kibana-url "${KIBANA_URL}"` ); }; export const esArchiverResetKibana = () => { cy.exec( - `node ../../../scripts/es_archiver empty-kibana-index --config ../../../test/functional/config.js --es-url ${Cypress.env( - 'ELASTICSEARCH_URL' - )} --kibana-url ${Cypress.config().baseUrl}`, + `node ../../../scripts/es_archiver empty-kibana-index --config "${CONFIG_PATH}" --es-url "${ES_URL}" --kibana-url "${KIBANA_URL}"`, { failOnNonZeroExit: false } ); }; diff --git a/x-pack/test/accessibility/apps/canvas.ts b/x-pack/test/accessibility/apps/canvas.ts index c802d62b05bf9..a79fb7b60e76a 100644 --- a/x-pack/test/accessibility/apps/canvas.ts +++ b/x-pack/test/accessibility/apps/canvas.ts @@ -16,7 +16,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('Canvas', () => { before(async () => { - await esArchiver.load('canvas/default'); + await esArchiver.load('x-pack/test/functional/es_archives/canvas/default'); await common.navigateToApp('canvas'); }); diff --git a/x-pack/test/accessibility/apps/dashboard_edit_panel.ts b/x-pack/test/accessibility/apps/dashboard_edit_panel.ts index c318c2d1c26a0..5624a5f25db2f 100644 --- a/x-pack/test/accessibility/apps/dashboard_edit_panel.ts +++ b/x-pack/test/accessibility/apps/dashboard_edit_panel.ts @@ -22,8 +22,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('Dashboard Edit Panel', () => { before(async () => { - await esArchiver.load('dashboard/drilldowns'); - await esArchiver.loadIfNeeded('logstash_functional'); + await esArchiver.load('x-pack/test/functional/es_archives/dashboard/drilldowns'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/logstash_functional'); await kibanaServer.uiSettings.replace({ defaultIndex: 'logstash-*' }); await PageObjects.common.navigateToApp('dashboard'); await dashboard.loadSavedDashboard(drilldowns.DASHBOARD_WITH_PIE_CHART_NAME); @@ -31,7 +31,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); after(async () => { - await esArchiver.unload('dashboard/drilldowns'); + await esArchiver.unload('x-pack/test/functional/es_archives/dashboard/drilldowns'); }); it('can open menu', async () => { diff --git a/x-pack/test/accessibility/apps/kibana_overview.ts b/x-pack/test/accessibility/apps/kibana_overview.ts index fe255a3413bd0..9d21f08a900cc 100644 --- a/x-pack/test/accessibility/apps/kibana_overview.ts +++ b/x-pack/test/accessibility/apps/kibana_overview.ts @@ -15,12 +15,12 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const esArchiver = getService('esArchiver'); before(async () => { - await esArchiver.load('empty_kibana'); + await esArchiver.load('x-pack/test/functional/es_archives/empty_kibana'); await PageObjects.common.navigateToApp('kibanaOverview'); }); after(async () => { - await esArchiver.unload('empty_kibana'); + await esArchiver.unload('x-pack/test/functional/es_archives/empty_kibana'); }); it('Kibana overview', async () => { diff --git a/x-pack/test/accessibility/apps/lens.ts b/x-pack/test/accessibility/apps/lens.ts index 682aa5a576f9e..4157f31525acf 100644 --- a/x-pack/test/accessibility/apps/lens.ts +++ b/x-pack/test/accessibility/apps/lens.ts @@ -17,8 +17,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('Lens', () => { const lensChartName = 'MyLensChart'; before(async () => { - await esArchiver.loadIfNeeded('logstash_functional'); - await esArchiver.loadIfNeeded('lens/basic'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/logstash_functional'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/lens/basic'); }); after(async () => { @@ -27,8 +27,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await listingTable.checkListingSelectAllCheckbox(); await listingTable.clickDeleteSelected(); await PageObjects.common.clickConfirmOnModal(); - await esArchiver.unload('logstash_functional'); - await esArchiver.unload('lens/basic'); + await esArchiver.unload('x-pack/test/functional/es_archives/logstash_functional'); + await esArchiver.unload('x-pack/test/functional/es_archives/lens/basic'); }); it('lens', async () => { diff --git a/x-pack/test/accessibility/apps/login_page.ts b/x-pack/test/accessibility/apps/login_page.ts index 02d817612671c..580df3e4ccc88 100644 --- a/x-pack/test/accessibility/apps/login_page.ts +++ b/x-pack/test/accessibility/apps/login_page.ts @@ -17,12 +17,12 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('Security', () => { describe('Login Page', () => { before(async () => { - await esArchiver.load('empty_kibana'); + await esArchiver.load('x-pack/test/functional/es_archives/empty_kibana'); await PageObjects.security.forceLogout(); }); after(async () => { - await esArchiver.unload('empty_kibana'); + await esArchiver.unload('x-pack/test/functional/es_archives/empty_kibana'); }); afterEach(async () => { diff --git a/x-pack/test/accessibility/apps/ml.ts b/x-pack/test/accessibility/apps/ml.ts index 5436f74a2b8f9..4babe0bd6ff88 100644 --- a/x-pack/test/accessibility/apps/ml.ts +++ b/x-pack/test/accessibility/apps/ml.ts @@ -91,9 +91,11 @@ export default function ({ getService }: FtrProviderContext) { ); before(async () => { - await esArchiver.loadIfNeeded('ml/farequote'); - await esArchiver.loadIfNeeded('ml/ihp_outlier'); - await esArchiver.loadIfNeeded('ml/module_sample_ecommerce'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/ml/farequote'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/ml/ihp_outlier'); + await esArchiver.loadIfNeeded( + 'x-pack/test/functional/es_archives/ml/module_sample_ecommerce' + ); await ml.testResources.createIndexPatternIfNeeded(fqIndexPattern, '@timestamp'); await ml.testResources.createIndexPatternIfNeeded(ihpIndexPattern, '@timestamp'); await ml.testResources.createIndexPatternIfNeeded(ecIndexPattern, 'order_date'); @@ -136,9 +138,9 @@ export default function ({ getService }: FtrProviderContext) { await ml.testResources.deleteIndexPatternByTitle(fqIndexPattern); await ml.testResources.deleteIndexPatternByTitle(ihpIndexPattern); await ml.testResources.deleteIndexPatternByTitle(ecIndexPattern); - await esArchiver.unload('ml/farequote'); - await esArchiver.unload('ml/ihp_outlier'); - await esArchiver.unload('ml/module_sample_ecommerce'); + await esArchiver.unload('x-pack/test/functional/es_archives/ml/farequote'); + await esArchiver.unload('x-pack/test/functional/es_archives/ml/ihp_outlier'); + await esArchiver.unload('x-pack/test/functional/es_archives/ml/module_sample_ecommerce'); await ml.testResources.resetKibanaTimeZone(); }); diff --git a/x-pack/test/accessibility/apps/ml_embeddables_in_dashboard.ts b/x-pack/test/accessibility/apps/ml_embeddables_in_dashboard.ts index de44984a50c5b..48224ebcf7353 100644 --- a/x-pack/test/accessibility/apps/ml_embeddables_in_dashboard.ts +++ b/x-pack/test/accessibility/apps/ml_embeddables_in_dashboard.ts @@ -65,7 +65,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await ml.securityCommon.createMlRoles(); await ml.securityCommon.createMlUsers(); - await esArchiver.loadIfNeeded('ml/farequote'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/ml/farequote'); await ml.testResources.createIndexPatternIfNeeded('ft_farequote', '@timestamp'); await ml.testResources.setKibanaTimeZoneToUTC(); await ml.securityUI.loginAsMlPowerUser(); @@ -74,7 +74,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { after(async () => { await ml.securityCommon.cleanMlUsers(); await ml.securityCommon.cleanMlRoles(); - await esArchiver.unload('ml/farequote'); + await esArchiver.unload('x-pack/test/functional/es_archives/ml/farequote'); await ml.securityUI.logout(); }); diff --git a/x-pack/test/accessibility/apps/roles.ts b/x-pack/test/accessibility/apps/roles.ts index 4979f572e739a..3c40e664d7da2 100644 --- a/x-pack/test/accessibility/apps/roles.ts +++ b/x-pack/test/accessibility/apps/roles.ts @@ -19,7 +19,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('Kibana roles page a11y tests', () => { before(async () => { - await esArchiver.loadIfNeeded('logstash_functional'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/logstash_functional'); await kibanaServer.uiSettings.update({ defaultIndex: 'logstash-*', }); @@ -27,7 +27,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); after(async () => { - await esArchiver.unload('logstash_functional'); + await esArchiver.unload('x-pack/test/functional/es_archives/logstash_functional'); }); it('a11y test for Roles main page', async () => { diff --git a/x-pack/test/accessibility/apps/spaces.ts b/x-pack/test/accessibility/apps/spaces.ts index 6242896c263ba..f2e79336e02ba 100644 --- a/x-pack/test/accessibility/apps/spaces.ts +++ b/x-pack/test/accessibility/apps/spaces.ts @@ -20,7 +20,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('Kibana spaces page meets a11y validations', () => { before(async () => { - await esArchiver.load('empty_kibana'); + await esArchiver.load('x-pack/test/functional/es_archives/empty_kibana'); await PageObjects.common.navigateToApp('home'); }); diff --git a/x-pack/test/accessibility/apps/transform.ts b/x-pack/test/accessibility/apps/transform.ts index 38cd8d98e8c32..4c58887f003b2 100644 --- a/x-pack/test/accessibility/apps/transform.ts +++ b/x-pack/test/accessibility/apps/transform.ts @@ -83,7 +83,7 @@ export default function ({ getService }: FtrProviderContext) { const latestTransformDestinationIndex = `user-${latestTransformId}`; before(async () => { - await esArchiver.loadIfNeeded('ml/ecommerce'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/ml/ecommerce'); await transform.testResources.createIndexPatternIfNeeded(ecIndexPattern, 'order_date'); await transform.testResources.setKibanaTimeZoneToUTC(); }); @@ -95,7 +95,7 @@ export default function ({ getService }: FtrProviderContext) { await transform.testResources.deleteIndexPatternByTitle(pivotTransformDestinationIndex); await transform.testResources.deleteIndexPatternByTitle(latestTransformDestinationIndex); await transform.testResources.deleteIndexPatternByTitle(ecIndexPattern); - await esArchiver.unload('ml/ecommerce'); + await esArchiver.unload('x-pack/test/functional/es_archives/ml/ecommerce'); await transform.testResources.resetKibanaTimeZone(); }); diff --git a/x-pack/test/accessibility/apps/uptime.ts b/x-pack/test/accessibility/apps/uptime.ts index 9c48e7d82788f..41664c5920b82 100644 --- a/x-pack/test/accessibility/apps/uptime.ts +++ b/x-pack/test/accessibility/apps/uptime.ts @@ -21,7 +21,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('uptime', () => { before(async () => { - await esArchiver.load('uptime/blank'); + await esArchiver.load('x-pack/test/functional/es_archives/uptime/blank'); await makeChecks(es, A11Y_TEST_MONITOR_ID, 150, 1, 1000, { tls: { certificate_not_valid_after: moment().add(30, 'days').toISOString(), @@ -45,7 +45,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); after(async () => { - await esArchiver.unload('uptime/blank'); + await esArchiver.unload('x-pack/test/functional/es_archives/uptime/blank'); }); it('overview page', async () => { diff --git a/x-pack/test/accessibility/apps/users.ts b/x-pack/test/accessibility/apps/users.ts index 8927a6167598e..bafd608aa8dee 100644 --- a/x-pack/test/accessibility/apps/users.ts +++ b/x-pack/test/accessibility/apps/users.ts @@ -19,7 +19,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('Kibana users page a11y tests', () => { before(async () => { - await esArchiver.load('empty_kibana'); + await esArchiver.load('x-pack/test/functional/es_archives/empty_kibana'); await PageObjects.security.clickElasticsearchUsers(); }); diff --git a/x-pack/test/alerting_api_integration/common/config.ts b/x-pack/test/alerting_api_integration/common/config.ts index 548b4d0db1124..7ee6e146b2a50 100644 --- a/x-pack/test/alerting_api_integration/common/config.ts +++ b/x-pack/test/alerting_api_integration/common/config.ts @@ -131,7 +131,6 @@ export function createTestConfig(name: string, options: CreateTestConfigOptions) junit: { reportName: 'X-Pack Alerting API Integration Tests', }, - esArchiver: xPackApiIntegrationTestsConfig.get('esArchiver'), esTestCluster: { ...xPackApiIntegrationTestsConfig.get('esTestCluster'), license, diff --git a/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/rbac_legacy.ts b/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/rbac_legacy.ts index 539e7eb059107..2294cbcc95aa4 100644 --- a/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/rbac_legacy.ts +++ b/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/rbac_legacy.ts @@ -35,7 +35,7 @@ export default function alertTests({ getService }: FtrProviderContext) { before(async () => { await esTestIndexTool.destroy(); - await esArchiver.load('alerts_legacy'); + await esArchiver.load('x-pack/test/functional/es_archives/alerts_legacy'); await esTestIndexTool.setup(); await es.indices.create({ index: authorizationIndex }); await setupSpacesAndUsers(getService); @@ -44,7 +44,7 @@ export default function alertTests({ getService }: FtrProviderContext) { after(async () => { await esTestIndexTool.destroy(); await es.indices.delete({ index: authorizationIndex }); - await esArchiver.unload('alerts_legacy'); + await esArchiver.unload('x-pack/test/functional/es_archives/alerts_legacy'); }); for (const scenario of UserAtSpaceScenarios) { diff --git a/x-pack/test/alerting_api_integration/security_and_spaces/tests/index.ts b/x-pack/test/alerting_api_integration/security_and_spaces/tests/index.ts index 6de8cb97ae211..a1f15c0db75fd 100644 --- a/x-pack/test/alerting_api_integration/security_and_spaces/tests/index.ts +++ b/x-pack/test/alerting_api_integration/security_and_spaces/tests/index.ts @@ -52,7 +52,7 @@ export async function tearDown(getService: FtrProviderContext['getService']) { } } - await esArchiver.unload('empty_kibana'); + await esArchiver.unload('x-pack/test/functional/es_archives/empty_kibana'); } // eslint-disable-next-line import/no-default-export diff --git a/x-pack/test/alerting_api_integration/spaces_only/tests/actions/migrations.ts b/x-pack/test/alerting_api_integration/spaces_only/tests/actions/migrations.ts index 13426d14960f3..811a9470611eb 100644 --- a/x-pack/test/alerting_api_integration/spaces_only/tests/actions/migrations.ts +++ b/x-pack/test/alerting_api_integration/spaces_only/tests/actions/migrations.ts @@ -16,11 +16,11 @@ export default function createGetTests({ getService }: FtrProviderContext) { describe('migrations', () => { before(async () => { - await esArchiver.load('actions'); + await esArchiver.load('x-pack/test/functional/es_archives/actions'); }); after(async () => { - await esArchiver.unload('actions'); + await esArchiver.unload('x-pack/test/functional/es_archives/actions'); }); it('7.10.0 migrates the `casesConfiguration` to be the `incidentConfiguration` in `config`, then 7.11.0 removes `incidentConfiguration`', async () => { diff --git a/x-pack/test/alerting_api_integration/spaces_only/tests/actions/type_not_enabled.ts b/x-pack/test/alerting_api_integration/spaces_only/tests/actions/type_not_enabled.ts index 6969a7fb181e2..eafe4f487773f 100644 --- a/x-pack/test/alerting_api_integration/spaces_only/tests/actions/type_not_enabled.ts +++ b/x-pack/test/alerting_api_integration/spaces_only/tests/actions/type_not_enabled.ts @@ -18,8 +18,8 @@ export default function typeNotEnabledTests({ getService }: FtrProviderContext) describe('actionType not enabled', () => { // loads action PREWRITTEN_ACTION_ID with actionType DISABLED_ACTION_TYPE - before(() => esArchiver.load('actions')); - after(() => esArchiver.unload('actions')); + before(() => esArchiver.load('x-pack/test/functional/es_archives/actions')); + after(() => esArchiver.unload('x-pack/test/functional/es_archives/actions')); it('should handle create action with disabled actionType request appropriately', async () => { const response = await supertest.post(`/api/actions/action`).set('kbn-xsrf', 'foo').send({ diff --git a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/migrations.ts b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/migrations.ts index 30e69d62933e0..0eaeaf9a4b7e7 100644 --- a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/migrations.ts +++ b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/migrations.ts @@ -16,11 +16,11 @@ export default function createGetTests({ getService }: FtrProviderContext) { describe('migrations', () => { before(async () => { - await esArchiver.load('alerts'); + await esArchiver.load('x-pack/test/functional/es_archives/alerts'); }); after(async () => { - await esArchiver.unload('alerts'); + await esArchiver.unload('x-pack/test/functional/es_archives/alerts'); }); it('7.10.0 migrates the `alerting` consumer to be the `alerts`', async () => { diff --git a/x-pack/test/alerting_api_integration/spaces_only/tests/index.ts b/x-pack/test/alerting_api_integration/spaces_only/tests/index.ts index 711910c13023d..8b0addcba26e9 100644 --- a/x-pack/test/alerting_api_integration/spaces_only/tests/index.ts +++ b/x-pack/test/alerting_api_integration/spaces_only/tests/index.ts @@ -30,5 +30,5 @@ export async function buildUp(getService: FtrProviderContext['getService']) { export async function tearDown(getService: FtrProviderContext['getService']) { const esArchiver = getService('esArchiver'); - await esArchiver.unload('empty_kibana'); + await esArchiver.unload('x-pack/test/functional/es_archives/empty_kibana'); } diff --git a/x-pack/test/alerting_api_integration/spaces_only_legacy/tests/index.ts b/x-pack/test/alerting_api_integration/spaces_only_legacy/tests/index.ts index a5a046dcbbe86..bb581a7f61cdb 100644 --- a/x-pack/test/alerting_api_integration/spaces_only_legacy/tests/index.ts +++ b/x-pack/test/alerting_api_integration/spaces_only_legacy/tests/index.ts @@ -29,5 +29,5 @@ export async function buildUp(getService: FtrProviderContext['getService']) { export async function tearDown(getService: FtrProviderContext['getService']) { const esArchiver = getService('esArchiver'); - await esArchiver.unload('empty_kibana'); + await esArchiver.unload('x-pack/test/functional/es_archives/empty_kibana'); } diff --git a/x-pack/test/api_integration/apis/file_upload/index_exists.ts b/x-pack/test/api_integration/apis/file_upload/index_exists.ts index 4e014105ab7a8..a9688a542dc1e 100644 --- a/x-pack/test/api_integration/apis/file_upload/index_exists.ts +++ b/x-pack/test/api_integration/apis/file_upload/index_exists.ts @@ -14,11 +14,11 @@ export default ({ getService }: FtrProviderContext) => { describe('POST /internal/file_upload/index_exists', () => { before(async () => { - await esArchiver.loadIfNeeded('logstash_functional'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/logstash_functional'); }); after(async () => { - await esArchiver.unload('logstash_functional'); + await esArchiver.unload('x-pack/test/functional/es_archives/logstash_functional'); }); it('should return true when index exists', async () => { diff --git a/x-pack/test/api_integration/apis/lens/existing_fields.ts b/x-pack/test/api_integration/apis/lens/existing_fields.ts index 88949401f102a..952659c2960d4 100644 --- a/x-pack/test/api_integration/apis/lens/existing_fields.ts +++ b/x-pack/test/api_integration/apis/lens/existing_fields.ts @@ -162,12 +162,12 @@ export default ({ getService }: FtrProviderContext) => { describe('existing_fields apis', () => { before(async () => { - await esArchiver.loadIfNeeded('logstash_functional'); - await esArchiver.loadIfNeeded('visualize/default'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/logstash_functional'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/visualize/default'); }); after(async () => { - await esArchiver.unload('logstash_functional'); - await esArchiver.unload('visualize/default'); + await esArchiver.unload('x-pack/test/functional/es_archives/logstash_functional'); + await esArchiver.unload('x-pack/test/functional/es_archives/visualize/default'); }); describe('existence', () => { diff --git a/x-pack/test/api_integration/apis/lens/field_stats.ts b/x-pack/test/api_integration/apis/lens/field_stats.ts index 94960b9859121..5dcb749f54b31 100644 --- a/x-pack/test/api_integration/apis/lens/field_stats.ts +++ b/x-pack/test/api_integration/apis/lens/field_stats.ts @@ -21,18 +21,18 @@ export default ({ getService }: FtrProviderContext) => { describe('index stats apis', () => { before(async () => { - await esArchiver.loadIfNeeded('logstash_functional'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/logstash_functional'); }); after(async () => { - await esArchiver.unload('logstash_functional'); + await esArchiver.unload('x-pack/test/functional/es_archives/logstash_functional'); }); describe('field distribution', () => { before(async () => { - await esArchiver.loadIfNeeded('visualize/default'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/visualize/default'); }); after(async () => { - await esArchiver.unload('visualize/default'); + await esArchiver.unload('x-pack/test/functional/es_archives/visualize/default'); }); it('should return a 404 for missing index patterns', async () => { @@ -431,10 +431,12 @@ export default ({ getService }: FtrProviderContext) => { describe('histogram', () => { before(async () => { - await esArchiver.loadIfNeeded('pre_calculated_histogram'); + await esArchiver.loadIfNeeded( + 'x-pack/test/functional/es_archives/pre_calculated_histogram' + ); }); after(async () => { - await esArchiver.unload('pre_calculated_histogram'); + await esArchiver.unload('x-pack/test/functional/es_archives/pre_calculated_histogram'); }); it('should return an auto histogram for precalculated histograms', async () => { diff --git a/x-pack/test/api_integration/apis/lens/telemetry.ts b/x-pack/test/api_integration/apis/lens/telemetry.ts index be1760d129df7..9f691115232ae 100644 --- a/x-pack/test/api_integration/apis/lens/telemetry.ts +++ b/x-pack/test/api_integration/apis/lens/telemetry.ts @@ -175,7 +175,7 @@ export default ({ getService }: FtrProviderContext) => { it('should collect telemetry on saved visualization types with a painless script', async () => { const esArchiver = getService('esArchiver'); - await esArchiver.loadIfNeeded('lens/basic'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/lens/basic'); const results = await getVisualizationCounts(() => Promise.resolve(es), '.kibana'); @@ -195,7 +195,7 @@ export default ({ getService }: FtrProviderContext) => { }); expect(results.saved_overall_total).to.eql(3); - await esArchiver.unload('lens/basic'); + await esArchiver.unload('x-pack/test/functional/es_archives/lens/basic'); }); }); }; diff --git a/x-pack/test/api_integration/apis/lists/create_exception_list_item.ts b/x-pack/test/api_integration/apis/lists/create_exception_list_item.ts index e18f805bf174e..b24cc7d14fef7 100644 --- a/x-pack/test/api_integration/apis/lists/create_exception_list_item.ts +++ b/x-pack/test/api_integration/apis/lists/create_exception_list_item.ts @@ -13,9 +13,9 @@ export default function ({ getService }: FtrProviderContext) { const esArchiver = getService('esArchiver'); const supertest = getService('supertest'); describe('Lists API', () => { - before(async () => await esArchiver.load('lists')); + before(async () => await esArchiver.load('x-pack/test/functional/es_archives/lists')); - after(async () => await esArchiver.unload('lists')); + after(async () => await esArchiver.unload('x-pack/test/functional/es_archives/lists')); it('should return a 400 if an endpoint exception item with a list-based entry is provided', async () => { const badItem = { diff --git a/x-pack/test/api_integration/apis/logstash/pipeline/delete.ts b/x-pack/test/api_integration/apis/logstash/pipeline/delete.ts index dc24f864250b9..dc626beb1ba44 100644 --- a/x-pack/test/api_integration/apis/logstash/pipeline/delete.ts +++ b/x-pack/test/api_integration/apis/logstash/pipeline/delete.ts @@ -11,7 +11,7 @@ export default function ({ getService }: FtrProviderContext) { const supertest = getService('supertest'); const esArchiver = getService('esArchiver'); describe('delete', () => { - const archive = 'logstash/empty'; + const archive = 'x-pack/test/functional/es_archives/logstash/empty'; before('load pipelines archive', async () => { await esArchiver.load(archive); diff --git a/x-pack/test/api_integration/apis/logstash/pipeline/load.ts b/x-pack/test/api_integration/apis/logstash/pipeline/load.ts index 7fbc603054111..c08acb3d9cf21 100644 --- a/x-pack/test/api_integration/apis/logstash/pipeline/load.ts +++ b/x-pack/test/api_integration/apis/logstash/pipeline/load.ts @@ -14,7 +14,7 @@ export default function ({ getService }: FtrProviderContext) { const supertest = getService('supertest'); const esArchiver = getService('esArchiver'); describe('list', () => { - const archive = 'logstash/example_pipelines'; + const archive = 'x-pack/test/functional/es_archives/logstash/example_pipelines'; before('load pipelines archive', () => { return esArchiver.load(archive); diff --git a/x-pack/test/api_integration/apis/logstash/pipeline/save.ts b/x-pack/test/api_integration/apis/logstash/pipeline/save.ts index 445916c76325b..84f6943845b64 100644 --- a/x-pack/test/api_integration/apis/logstash/pipeline/save.ts +++ b/x-pack/test/api_integration/apis/logstash/pipeline/save.ts @@ -12,7 +12,7 @@ export default function ({ getService }: FtrProviderContext) { const supertest = getService('supertest'); const esArchiver = getService('esArchiver'); describe('save', () => { - const archive = 'logstash/empty'; + const archive = 'x-pack/test/functional/es_archives/logstash/empty'; before('load pipelines archive', () => { return esArchiver.load(archive); diff --git a/x-pack/test/api_integration/apis/logstash/pipelines/delete.ts b/x-pack/test/api_integration/apis/logstash/pipelines/delete.ts index 00650ed43486d..9a18f197c13f3 100644 --- a/x-pack/test/api_integration/apis/logstash/pipelines/delete.ts +++ b/x-pack/test/api_integration/apis/logstash/pipelines/delete.ts @@ -11,7 +11,7 @@ export default function ({ getService }: FtrProviderContext) { const supertest = getService('supertest'); const esArchiver = getService('esArchiver'); describe('delete', () => { - const archive = 'logstash/example_pipelines'; + const archive = 'x-pack/test/functional/es_archives/logstash/example_pipelines'; before('load pipelines archive', async () => { await esArchiver.load(archive); diff --git a/x-pack/test/api_integration/apis/logstash/pipelines/list.ts b/x-pack/test/api_integration/apis/logstash/pipelines/list.ts index 41514cfca93d4..6833bd8131cd6 100644 --- a/x-pack/test/api_integration/apis/logstash/pipelines/list.ts +++ b/x-pack/test/api_integration/apis/logstash/pipelines/list.ts @@ -13,7 +13,7 @@ export default function ({ getService }: FtrProviderContext) { const supertest = getService('supertest'); const esArchiver = getService('esArchiver'); describe('list', () => { - const archive = 'logstash/example_pipelines'; + const archive = 'x-pack/test/functional/es_archives/logstash/example_pipelines'; before('load pipelines archive', () => { return esArchiver.load(archive); diff --git a/x-pack/test/api_integration/apis/maps/index.js b/x-pack/test/api_integration/apis/maps/index.js index db954a3dc0396..dc39d7ce36931 100644 --- a/x-pack/test/api_integration/apis/maps/index.js +++ b/x-pack/test/api_integration/apis/maps/index.js @@ -10,8 +10,8 @@ export default function ({ loadTestFile, getService }) { describe('Maps endpoints', () => { before(async () => { - await esArchiver.loadIfNeeded('logstash_functional'); - await esArchiver.load('maps/data'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/logstash_functional'); + await esArchiver.load('x-pack/test/functional/es_archives/maps/data'); }); describe('', () => { diff --git a/x-pack/test/api_integration/apis/maps/migrations.js b/x-pack/test/api_integration/apis/maps/migrations.js index fe6e1c70356b0..728f26636f970 100644 --- a/x-pack/test/api_integration/apis/maps/migrations.js +++ b/x-pack/test/api_integration/apis/maps/migrations.js @@ -51,11 +51,11 @@ export default function ({ getService }) { describe('embeddable migrations', () => { before(async () => { - await esArchiver.loadIfNeeded('maps/kibana'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/maps/kibana'); }); after(async () => { - await esArchiver.unload('maps/kibana'); + await esArchiver.unload('x-pack/test/functional/es_archives/maps/kibana'); }); it('should apply embeddable migrations', async () => { diff --git a/x-pack/test/api_integration/apis/metrics_ui/http_source.ts b/x-pack/test/api_integration/apis/metrics_ui/http_source.ts index 912266bf87e42..65a350c523ee3 100644 --- a/x-pack/test/api_integration/apis/metrics_ui/http_source.ts +++ b/x-pack/test/api_integration/apis/metrics_ui/http_source.ts @@ -30,8 +30,12 @@ export default function ({ getService }: FtrProviderContext) { describe('Source API via HTTP', () => { describe('8.0.0', () => { - before(() => esArchiver.load('infra/8.0.0/logs_and_metrics')); - after(() => esArchiver.unload('infra/8.0.0/logs_and_metrics')); + before(() => + esArchiver.load('x-pack/test/functional/es_archives/infra/8.0.0/logs_and_metrics') + ); + after(() => + esArchiver.unload('x-pack/test/functional/es_archives/infra/8.0.0/logs_and_metrics') + ); describe('/api/metrics/source/default', () => { it('should just work', async () => { const resp = fetchSource(); diff --git a/x-pack/test/api_integration/apis/metrics_ui/ip_to_hostname.ts b/x-pack/test/api_integration/apis/metrics_ui/ip_to_hostname.ts index 4d09ce2814f88..3a3e6172cdfcc 100644 --- a/x-pack/test/api_integration/apis/metrics_ui/ip_to_hostname.ts +++ b/x-pack/test/api_integration/apis/metrics_ui/ip_to_hostname.ts @@ -13,8 +13,8 @@ export default function ipToHostNameTest({ getService }: FtrProviderContext) { const esArchiver = getService('esArchiver'); describe('Ip to Host API', () => { - before(() => esArchiver.load('infra/metrics_and_logs')); - after(() => esArchiver.unload('infra/metrics_and_logs')); + before(() => esArchiver.load('x-pack/test/functional/es_archives/infra/metrics_and_logs')); + after(() => esArchiver.unload('x-pack/test/functional/es_archives/infra/metrics_and_logs')); it('should basically work', async () => { const postBody = { diff --git a/x-pack/test/api_integration/apis/metrics_ui/log_entry_highlights.ts b/x-pack/test/api_integration/apis/metrics_ui/log_entry_highlights.ts index ca04e1c87c2f1..a6292769fc5a4 100644 --- a/x-pack/test/api_integration/apis/metrics_ui/log_entry_highlights.ts +++ b/x-pack/test/api_integration/apis/metrics_ui/log_entry_highlights.ts @@ -39,13 +39,13 @@ export default function ({ getService }: FtrProviderContext) { const supertest = getService('supertest'); describe('log highlight apis', () => { - before(() => esArchiver.load('infra/simple_logs')); - after(() => esArchiver.unload('infra/simple_logs')); + before(() => esArchiver.load('x-pack/test/functional/es_archives/infra/simple_logs')); + after(() => esArchiver.unload('x-pack/test/functional/es_archives/infra/simple_logs')); describe('/log_entries/highlights', () => { describe('with the default source', () => { - before(() => esArchiver.load('empty_kibana')); - after(() => esArchiver.unload('empty_kibana')); + before(() => esArchiver.load('x-pack/test/functional/es_archives/empty_kibana')); + after(() => esArchiver.unload('x-pack/test/functional/es_archives/empty_kibana')); it('Handles empty responses', async () => { const { body } = await supertest diff --git a/x-pack/test/api_integration/apis/metrics_ui/log_sources.ts b/x-pack/test/api_integration/apis/metrics_ui/log_sources.ts index 0cde7263a2454..5b615c4b18916 100644 --- a/x-pack/test/api_integration/apis/metrics_ui/log_sources.ts +++ b/x-pack/test/api_integration/apis/metrics_ui/log_sources.ts @@ -19,10 +19,10 @@ export default function ({ getService }: FtrProviderContext) { const logSourceConfiguration = getService('infraLogSourceConfiguration'); describe('log sources api', () => { - before(() => esArchiver.load('infra/metrics_and_logs')); - after(() => esArchiver.unload('infra/metrics_and_logs')); - beforeEach(() => esArchiver.load('empty_kibana')); - afterEach(() => esArchiver.unload('empty_kibana')); + before(() => esArchiver.load('x-pack/test/functional/es_archives/infra/metrics_and_logs')); + after(() => esArchiver.unload('x-pack/test/functional/es_archives/infra/metrics_and_logs')); + beforeEach(() => esArchiver.load('x-pack/test/functional/es_archives/empty_kibana')); + afterEach(() => esArchiver.unload('x-pack/test/functional/es_archives/empty_kibana')); describe('source configuration get method for non-existant source', () => { it('returns the default source configuration', async () => { diff --git a/x-pack/test/api_integration/apis/metrics_ui/log_summary.ts b/x-pack/test/api_integration/apis/metrics_ui/log_summary.ts index cab7809a83080..3588bedc807be 100644 --- a/x-pack/test/api_integration/apis/metrics_ui/log_summary.ts +++ b/x-pack/test/api_integration/apis/metrics_ui/log_summary.ts @@ -35,8 +35,8 @@ export default function ({ getService }: FtrProviderContext) { const supertest = getService('supertest'); describe('logSummaryBetween', () => { - before(() => esArchiver.load('infra/metrics_and_logs')); - after(() => esArchiver.unload('infra/metrics_and_logs')); + before(() => esArchiver.load('x-pack/test/functional/es_archives/infra/metrics_and_logs')); + after(() => esArchiver.unload('x-pack/test/functional/es_archives/infra/metrics_and_logs')); it('should return empty and non-empty consecutive buckets', async () => { const startTimestamp = EARLIEST_TIME_WITH_DATA; diff --git a/x-pack/test/api_integration/apis/metrics_ui/metadata.ts b/x-pack/test/api_integration/apis/metrics_ui/metadata.ts index 3cc0f9d33f31e..5c57046db030b 100644 --- a/x-pack/test/api_integration/apis/metrics_ui/metadata.ts +++ b/x-pack/test/api_integration/apis/metrics_ui/metadata.ts @@ -43,8 +43,8 @@ export default function ({ getService }: FtrProviderContext) { describe('metadata', () => { describe('7.0.0', () => { - before(() => esArchiver.load('infra/7.0.0/hosts')); - after(() => esArchiver.unload('infra/7.0.0/hosts')); + before(() => esArchiver.load('x-pack/test/functional/es_archives/infra/7.0.0/hosts')); + after(() => esArchiver.unload('x-pack/test/functional/es_archives/infra/7.0.0/hosts')); it('hosts', async () => { const metadata = await fetchMetadata({ @@ -63,8 +63,8 @@ export default function ({ getService }: FtrProviderContext) { }); describe('6.6.0', () => { - before(() => esArchiver.load('infra/6.6.0/docker')); - after(() => esArchiver.unload('infra/6.6.0/docker')); + before(() => esArchiver.load('x-pack/test/functional/es_archives/infra/6.6.0/docker')); + after(() => esArchiver.unload('x-pack/test/functional/es_archives/infra/6.6.0/docker')); it('docker', async () => { const metadata = await fetchMetadata({ @@ -84,7 +84,8 @@ export default function ({ getService }: FtrProviderContext) { describe('8.0.0', () => { describe('cloud and host information', () => { - const archiveName = 'infra/8.0.0/logs_and_metrics_with_aws'; + const archiveName = + 'x-pack/test/functional/es_archives/infra/8.0.0/logs_and_metrics_with_aws'; before(() => esArchiver.load(archiveName)); after(() => esArchiver.unload(archiveName)); diff --git a/x-pack/test/api_integration/apis/metrics_ui/metrics.ts b/x-pack/test/api_integration/apis/metrics_ui/metrics.ts index 5204d7c499aa5..1011a9ee95dba 100644 --- a/x-pack/test/api_integration/apis/metrics_ui/metrics.ts +++ b/x-pack/test/api_integration/apis/metrics_ui/metrics.ts @@ -31,8 +31,8 @@ export default function ({ getService }: FtrProviderContext) { const supertest = getService('supertest'); describe('metrics', () => { - before(() => esArchiver.load('infra/7.0.0/hosts')); - after(() => esArchiver.unload('infra/7.0.0/hosts')); + before(() => esArchiver.load('x-pack/test/functional/es_archives/infra/7.0.0/hosts')); + after(() => esArchiver.unload('x-pack/test/functional/es_archives/infra/7.0.0/hosts')); const fetchNodeDetails = async ( body: NodeDetailsRequest diff --git a/x-pack/test/api_integration/apis/metrics_ui/metrics_explorer.ts b/x-pack/test/api_integration/apis/metrics_ui/metrics_explorer.ts index 6288c1e5a3a3d..8d5c677f56ea2 100644 --- a/x-pack/test/api_integration/apis/metrics_ui/metrics_explorer.ts +++ b/x-pack/test/api_integration/apis/metrics_ui/metrics_explorer.ts @@ -21,8 +21,8 @@ export default function ({ getService }: FtrProviderContext) { describe('Metrics Explorer API', () => { describe('with data', () => { - before(() => esArchiver.load('infra/7.0.0/hosts')); - after(() => esArchiver.unload('infra/7.0.0/hosts')); + before(() => esArchiver.load('x-pack/test/functional/es_archives/infra/7.0.0/hosts')); + after(() => esArchiver.unload('x-pack/test/functional/es_archives/infra/7.0.0/hosts')); it('should work for multiple metrics', async () => { const postBody = { diff --git a/x-pack/test/api_integration/apis/metrics_ui/snapshot.ts b/x-pack/test/api_integration/apis/metrics_ui/snapshot.ts index 8d73537ddff66..8fd8a5a6d3ec8 100644 --- a/x-pack/test/api_integration/apis/metrics_ui/snapshot.ts +++ b/x-pack/test/api_integration/apis/metrics_ui/snapshot.ts @@ -33,8 +33,8 @@ export default function ({ getService }: FtrProviderContext) { describe('waffle nodes', () => { describe('6.6.0', () => { const { min, max } = DATES['6.6.0'].docker; - before(() => esArchiver.load('infra/6.6.0/docker')); - after(() => esArchiver.unload('infra/6.6.0/docker')); + before(() => esArchiver.load('x-pack/test/functional/es_archives/infra/6.6.0/docker')); + after(() => esArchiver.unload('x-pack/test/functional/es_archives/infra/6.6.0/docker')); it('should basically work', async () => { const resp = fetchSnapshot({ @@ -80,8 +80,12 @@ export default function ({ getService }: FtrProviderContext) { describe('8.0.0', () => { const { min, max } = DATES['8.0.0'].logs_and_metrics; - before(() => esArchiver.load('infra/8.0.0/logs_and_metrics')); - after(() => esArchiver.unload('infra/8.0.0/logs_and_metrics')); + before(() => + esArchiver.load('x-pack/test/functional/es_archives/infra/8.0.0/logs_and_metrics') + ); + after(() => + esArchiver.unload('x-pack/test/functional/es_archives/infra/8.0.0/logs_and_metrics') + ); it("should use the id for the label when the name doesn't exist", async () => { const resp = fetchSnapshot({ @@ -151,8 +155,8 @@ export default function ({ getService }: FtrProviderContext) { describe('7.0.0', () => { const { min, max } = DATES['7.0.0'].hosts; - before(() => esArchiver.load('infra/7.0.0/hosts')); - after(() => esArchiver.unload('infra/7.0.0/hosts')); + before(() => esArchiver.load('x-pack/test/functional/es_archives/infra/7.0.0/hosts')); + after(() => esArchiver.unload('x-pack/test/functional/es_archives/infra/7.0.0/hosts')); it('should basically work', async () => { const resp = fetchSnapshot({ diff --git a/x-pack/test/api_integration/apis/metrics_ui/sources.ts b/x-pack/test/api_integration/apis/metrics_ui/sources.ts index d55530a501366..8c43a05f5eeb6 100644 --- a/x-pack/test/api_integration/apis/metrics_ui/sources.ts +++ b/x-pack/test/api_integration/apis/metrics_ui/sources.ts @@ -30,10 +30,10 @@ export default function ({ getService }: FtrProviderContext) { }; describe('sources', () => { - before(() => esArchiver.load('infra/metrics_and_logs')); - after(() => esArchiver.unload('infra/metrics_and_logs')); - beforeEach(() => esArchiver.load('empty_kibana')); - afterEach(() => esArchiver.unload('empty_kibana')); + before(() => esArchiver.load('x-pack/test/functional/es_archives/infra/metrics_and_logs')); + after(() => esArchiver.unload('x-pack/test/functional/es_archives/infra/metrics_and_logs')); + beforeEach(() => esArchiver.load('x-pack/test/functional/es_archives/empty_kibana')); + afterEach(() => esArchiver.unload('x-pack/test/functional/es_archives/empty_kibana')); describe('patch request', () => { it('applies all top-level field updates to an existing source', async () => { diff --git a/x-pack/test/api_integration/apis/ml/annotations/create_annotations.ts b/x-pack/test/api_integration/apis/ml/annotations/create_annotations.ts index 21c1c1efbf9e8..c2a204c1d1881 100644 --- a/x-pack/test/api_integration/apis/ml/annotations/create_annotations.ts +++ b/x-pack/test/api_integration/apis/ml/annotations/create_annotations.ts @@ -23,7 +23,7 @@ export default ({ getService }: FtrProviderContext) => { describe('create_annotations', function () { before(async () => { - await esArchiver.loadIfNeeded('ml/farequote'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/ml/farequote'); await ml.testResources.setKibanaTimeZoneToUTC(); // @ts-expect-error not full interface await ml.api.createAnomalyDetectionJob(testJobConfig); diff --git a/x-pack/test/api_integration/apis/ml/annotations/delete_annotations.ts b/x-pack/test/api_integration/apis/ml/annotations/delete_annotations.ts index f6c4c98e1f7ea..77b6103a6e22a 100644 --- a/x-pack/test/api_integration/apis/ml/annotations/delete_annotations.ts +++ b/x-pack/test/api_integration/apis/ml/annotations/delete_annotations.ts @@ -18,7 +18,7 @@ export default ({ getService }: FtrProviderContext) => { describe('delete_annotations', function () { before(async () => { - await esArchiver.loadIfNeeded('ml/farequote'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/ml/farequote'); await ml.testResources.setKibanaTimeZoneToUTC(); // generate one annotation for each job diff --git a/x-pack/test/api_integration/apis/ml/annotations/get_annotations.ts b/x-pack/test/api_integration/apis/ml/annotations/get_annotations.ts index c0e81955ad595..bff9f3157c69d 100644 --- a/x-pack/test/api_integration/apis/ml/annotations/get_annotations.ts +++ b/x-pack/test/api_integration/apis/ml/annotations/get_annotations.ts @@ -19,7 +19,7 @@ export default ({ getService }: FtrProviderContext) => { describe('get_annotations', function () { before(async () => { - await esArchiver.loadIfNeeded('ml/farequote'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/ml/farequote'); await ml.testResources.setKibanaTimeZoneToUTC(); // generate one annotation for each job diff --git a/x-pack/test/api_integration/apis/ml/annotations/update_annotations.ts b/x-pack/test/api_integration/apis/ml/annotations/update_annotations.ts index 346f4562b77bb..0beb5e7fde6c5 100644 --- a/x-pack/test/api_integration/apis/ml/annotations/update_annotations.ts +++ b/x-pack/test/api_integration/apis/ml/annotations/update_annotations.ts @@ -31,7 +31,7 @@ export default ({ getService }: FtrProviderContext) => { describe('update_annotations', function () { before(async () => { - await esArchiver.loadIfNeeded('ml/farequote'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/ml/farequote'); await ml.testResources.setKibanaTimeZoneToUTC(); // generate one annotation for each job diff --git a/x-pack/test/api_integration/apis/ml/anomaly_detectors/create.ts b/x-pack/test/api_integration/apis/ml/anomaly_detectors/create.ts index 29ba454ba9f66..c04a368a63e9b 100644 --- a/x-pack/test/api_integration/apis/ml/anomaly_detectors/create.ts +++ b/x-pack/test/api_integration/apis/ml/anomaly_detectors/create.ts @@ -100,7 +100,7 @@ export default ({ getService }: FtrProviderContext) => { describe('create', function () { before(async () => { - await esArchiver.loadIfNeeded('ml/farequote'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/ml/farequote'); await ml.testResources.setKibanaTimeZoneToUTC(); }); diff --git a/x-pack/test/api_integration/apis/ml/anomaly_detectors/get.ts b/x-pack/test/api_integration/apis/ml/anomaly_detectors/get.ts index 03ee82eed27d0..3acefac817d48 100644 --- a/x-pack/test/api_integration/apis/ml/anomaly_detectors/get.ts +++ b/x-pack/test/api_integration/apis/ml/anomaly_detectors/get.ts @@ -59,7 +59,7 @@ export default ({ getService }: FtrProviderContext) => { describe('GET anomaly_detectors', () => { before(async () => { - await esArchiver.loadIfNeeded('ml/farequote'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/ml/farequote'); await ml.testResources.setKibanaTimeZoneToUTC(); await createJobs(); diff --git a/x-pack/test/api_integration/apis/ml/data_frame_analytics/create_job.ts b/x-pack/test/api_integration/apis/ml/data_frame_analytics/create_job.ts index 4a4f5c1e555b4..e1e391add4897 100644 --- a/x-pack/test/api_integration/apis/ml/data_frame_analytics/create_job.ts +++ b/x-pack/test/api_integration/apis/ml/data_frame_analytics/create_job.ts @@ -77,7 +77,7 @@ export default ({ getService }: FtrProviderContext) => { describe('PUT data_frame/analytics/{analyticsId}', () => { before(async () => { - await esArchiver.loadIfNeeded('ml/bm_classification'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/ml/bm_classification'); await ml.testResources.setKibanaTimeZoneToUTC(); }); diff --git a/x-pack/test/api_integration/apis/ml/data_frame_analytics/delete.ts b/x-pack/test/api_integration/apis/ml/data_frame_analytics/delete.ts index dd2e7dd57cb6d..055b4b69ab7a6 100644 --- a/x-pack/test/api_integration/apis/ml/data_frame_analytics/delete.ts +++ b/x-pack/test/api_integration/apis/ml/data_frame_analytics/delete.ts @@ -65,7 +65,7 @@ export default ({ getService }: FtrProviderContext) => { describe('DELETE data_frame/analytics', () => { before(async () => { - await esArchiver.loadIfNeeded('ml/bm_classification'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/ml/bm_classification'); await ml.testResources.setKibanaTimeZoneToUTC(); await createJobs(testJobConfigs); }); diff --git a/x-pack/test/api_integration/apis/ml/data_frame_analytics/delete_spaces.ts b/x-pack/test/api_integration/apis/ml/data_frame_analytics/delete_spaces.ts index 21fed47d7faca..9492358d09000 100644 --- a/x-pack/test/api_integration/apis/ml/data_frame_analytics/delete_spaces.ts +++ b/x-pack/test/api_integration/apis/ml/data_frame_analytics/delete_spaces.ts @@ -36,7 +36,7 @@ export default ({ getService }: FtrProviderContext) => { describe('DELETE data_frame/analytics with spaces', function () { before(async () => { - await esArchiver.loadIfNeeded('ml/ihp_outlier'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/ml/ihp_outlier'); await spacesService.create({ id: idSpace1, name: 'space_one', disabledFeatures: [] }); await spacesService.create({ id: idSpace2, name: 'space_two', disabledFeatures: [] }); diff --git a/x-pack/test/api_integration/apis/ml/data_frame_analytics/evaluate.ts b/x-pack/test/api_integration/apis/ml/data_frame_analytics/evaluate.ts index e1fa889d20daf..e2a9d123aafc9 100644 --- a/x-pack/test/api_integration/apis/ml/data_frame_analytics/evaluate.ts +++ b/x-pack/test/api_integration/apis/ml/data_frame_analytics/evaluate.ts @@ -113,8 +113,8 @@ export default ({ getService }: FtrProviderContext) => { describe('POST data_frame/_evaluate', () => { before(async () => { - await esArchiver.loadIfNeeded('ml/bm_classification'); - await esArchiver.loadIfNeeded('ml/egs_regression'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/ml/bm_classification'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/ml/egs_regression'); await ml.testResources.setKibanaTimeZoneToUTC(); await createJobs(testJobConfigs); }); diff --git a/x-pack/test/api_integration/apis/ml/data_frame_analytics/explain.ts b/x-pack/test/api_integration/apis/ml/data_frame_analytics/explain.ts index 3e9ad9afb8004..b3219c60c1aab 100644 --- a/x-pack/test/api_integration/apis/ml/data_frame_analytics/explain.ts +++ b/x-pack/test/api_integration/apis/ml/data_frame_analytics/explain.ts @@ -77,9 +77,9 @@ export default ({ getService }: FtrProviderContext) => { describe('POST data_frame/analytics/_explain', () => { before(async () => { - await esArchiver.loadIfNeeded('ml/bm_classification'); - await esArchiver.loadIfNeeded('ml/egs_regression'); - await esArchiver.loadIfNeeded('ml/ihp_outlier'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/ml/bm_classification'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/ml/egs_regression'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/ml/ihp_outlier'); await ml.testResources.setKibanaTimeZoneToUTC(); }); diff --git a/x-pack/test/api_integration/apis/ml/data_frame_analytics/get.ts b/x-pack/test/api_integration/apis/ml/data_frame_analytics/get.ts index a374567c449f0..f8c7009e39db6 100644 --- a/x-pack/test/api_integration/apis/ml/data_frame_analytics/get.ts +++ b/x-pack/test/api_integration/apis/ml/data_frame_analytics/get.ts @@ -82,7 +82,7 @@ export default ({ getService }: FtrProviderContext) => { describe('GET data_frame/analytics', () => { before(async () => { - await esArchiver.loadIfNeeded('ml/bm_classification'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/ml/bm_classification'); await ml.testResources.setKibanaTimeZoneToUTC(); await createJobs(); diff --git a/x-pack/test/api_integration/apis/ml/data_frame_analytics/get_spaces.ts b/x-pack/test/api_integration/apis/ml/data_frame_analytics/get_spaces.ts index dacf199daf90e..33dcec6264501 100644 --- a/x-pack/test/api_integration/apis/ml/data_frame_analytics/get_spaces.ts +++ b/x-pack/test/api_integration/apis/ml/data_frame_analytics/get_spaces.ts @@ -47,7 +47,7 @@ export default ({ getService }: FtrProviderContext) => { describe('GET data_frame/analytics with spaces', function () { before(async () => { - await esArchiver.loadIfNeeded('ml/ihp_outlier'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/ml/ihp_outlier'); await spacesService.create({ id: idSpace1, name: 'space_one', disabledFeatures: [] }); await spacesService.create({ id: idSpace2, name: 'space_two', disabledFeatures: [] }); diff --git a/x-pack/test/api_integration/apis/ml/data_frame_analytics/start.ts b/x-pack/test/api_integration/apis/ml/data_frame_analytics/start.ts index 6960dc37bf0f8..d19569407dfcd 100644 --- a/x-pack/test/api_integration/apis/ml/data_frame_analytics/start.ts +++ b/x-pack/test/api_integration/apis/ml/data_frame_analytics/start.ts @@ -63,7 +63,7 @@ export default ({ getService }: FtrProviderContext) => { describe('POST data_frame/analytics/{analyticsId}/_start', () => { before(async () => { - await esArchiver.loadIfNeeded('ml/bm_classification'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/ml/bm_classification'); await ml.testResources.setKibanaTimeZoneToUTC(); await createJobs(testJobConfigs); }); diff --git a/x-pack/test/api_integration/apis/ml/data_frame_analytics/start_spaces.ts b/x-pack/test/api_integration/apis/ml/data_frame_analytics/start_spaces.ts index de8cc7ffb1c41..636097a81c4f6 100644 --- a/x-pack/test/api_integration/apis/ml/data_frame_analytics/start_spaces.ts +++ b/x-pack/test/api_integration/apis/ml/data_frame_analytics/start_spaces.ts @@ -43,7 +43,7 @@ export default ({ getService }: FtrProviderContext) => { describe('POST data_frame/analytics/{analyticsId}/_start with spaces', function () { before(async () => { - await esArchiver.loadIfNeeded('ml/ihp_outlier'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/ml/ihp_outlier'); await spacesService.create({ id: idSpace1, name: 'space_one', disabledFeatures: [] }); await spacesService.create({ id: idSpace2, name: 'space_two', disabledFeatures: [] }); diff --git a/x-pack/test/api_integration/apis/ml/data_frame_analytics/stop.ts b/x-pack/test/api_integration/apis/ml/data_frame_analytics/stop.ts index e1f479b0d2fc7..09663947f61c0 100644 --- a/x-pack/test/api_integration/apis/ml/data_frame_analytics/stop.ts +++ b/x-pack/test/api_integration/apis/ml/data_frame_analytics/stop.ts @@ -22,7 +22,7 @@ export default ({ getService }: FtrProviderContext) => { describe('POST data_frame/analytics/{analyticsId}/_stop', () => { before(async () => { - await esArchiver.loadIfNeeded('ml/bm_classification'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/ml/bm_classification'); await ml.testResources.setKibanaTimeZoneToUTC(); // job config with high training percent so it takes longer to run const slowRunningConfig = ml.commonConfig.getDFABmClassificationJobConfig(analyticsId); diff --git a/x-pack/test/api_integration/apis/ml/data_frame_analytics/stop_spaces.ts b/x-pack/test/api_integration/apis/ml/data_frame_analytics/stop_spaces.ts index 19ce61d840d93..71eff1f00aa00 100644 --- a/x-pack/test/api_integration/apis/ml/data_frame_analytics/stop_spaces.ts +++ b/x-pack/test/api_integration/apis/ml/data_frame_analytics/stop_spaces.ts @@ -44,7 +44,7 @@ export default ({ getService }: FtrProviderContext) => { describe('POST data_frame/analytics/{analyticsId}/_stop with spaces', function () { before(async () => { - await esArchiver.loadIfNeeded('ml/bm_classification'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/ml/bm_classification'); await spacesService.create({ id: idSpace3, name: 'space_three', disabledFeatures: [] }); await spacesService.create({ id: idSpace4, name: 'space_four', disabledFeatures: [] }); // job config with high training percent so it takes longer to run diff --git a/x-pack/test/api_integration/apis/ml/data_frame_analytics/update.ts b/x-pack/test/api_integration/apis/ml/data_frame_analytics/update.ts index c8e52c5852a2f..c39cd72ac80e6 100644 --- a/x-pack/test/api_integration/apis/ml/data_frame_analytics/update.ts +++ b/x-pack/test/api_integration/apis/ml/data_frame_analytics/update.ts @@ -79,7 +79,7 @@ export default ({ getService }: FtrProviderContext) => { describe('UPDATE data_frame/analytics', () => { before(async () => { - await esArchiver.loadIfNeeded('ml/bm_classification'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/ml/bm_classification'); await ml.testResources.setKibanaTimeZoneToUTC(); await createJobs(testJobConfigs); }); diff --git a/x-pack/test/api_integration/apis/ml/data_frame_analytics/update_spaces.ts b/x-pack/test/api_integration/apis/ml/data_frame_analytics/update_spaces.ts index 1278e4f703726..22286628beb35 100644 --- a/x-pack/test/api_integration/apis/ml/data_frame_analytics/update_spaces.ts +++ b/x-pack/test/api_integration/apis/ml/data_frame_analytics/update_spaces.ts @@ -46,7 +46,7 @@ export default ({ getService }: FtrProviderContext) => { describe('POST data_frame/analytics _update with spaces', function () { before(async () => { - await esArchiver.loadIfNeeded('ml/ihp_outlier'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/ml/ihp_outlier'); await spacesService.create({ id: idSpace1, name: 'space_one', disabledFeatures: [] }); await spacesService.create({ id: idSpace2, name: 'space_two', disabledFeatures: [] }); diff --git a/x-pack/test/api_integration/apis/ml/data_frame_analytics/validate.ts b/x-pack/test/api_integration/apis/ml/data_frame_analytics/validate.ts index 2dae0d911a994..24cc23c21cff3 100644 --- a/x-pack/test/api_integration/apis/ml/data_frame_analytics/validate.ts +++ b/x-pack/test/api_integration/apis/ml/data_frame_analytics/validate.ts @@ -77,7 +77,7 @@ export default ({ getService }: FtrProviderContext) => { describe('POST data_frame/analytics/validate', () => { before(async () => { - await esArchiver.loadIfNeeded('ml/bm_classification'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/ml/bm_classification'); await ml.testResources.setKibanaTimeZoneToUTC(); }); diff --git a/x-pack/test/api_integration/apis/ml/data_visualizer/get_field_histograms.ts b/x-pack/test/api_integration/apis/ml/data_visualizer/get_field_histograms.ts index 63d4e2c4a874f..488df74b46968 100644 --- a/x-pack/test/api_integration/apis/ml/data_visualizer/get_field_histograms.ts +++ b/x-pack/test/api_integration/apis/ml/data_visualizer/get_field_histograms.ts @@ -84,7 +84,7 @@ export default ({ getService }: FtrProviderContext) => { describe('get_field_histograms', function () { before(async () => { - await esArchiver.loadIfNeeded('ml/farequote'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/ml/farequote'); await ml.testResources.setKibanaTimeZoneToUTC(); }); diff --git a/x-pack/test/api_integration/apis/ml/data_visualizer/get_field_stats.ts b/x-pack/test/api_integration/apis/ml/data_visualizer/get_field_stats.ts index 84373d14c4e56..65fd1c1ff0c85 100644 --- a/x-pack/test/api_integration/apis/ml/data_visualizer/get_field_stats.ts +++ b/x-pack/test/api_integration/apis/ml/data_visualizer/get_field_stats.ts @@ -179,7 +179,7 @@ export default ({ getService }: FtrProviderContext) => { // Move these tests to file_data_visualizer plugin describe('get_field_stats', function () { before(async () => { - await esArchiver.loadIfNeeded('ml/farequote'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/ml/farequote'); await ml.testResources.setKibanaTimeZoneToUTC(); }); diff --git a/x-pack/test/api_integration/apis/ml/data_visualizer/get_overall_stats.ts b/x-pack/test/api_integration/apis/ml/data_visualizer/get_overall_stats.ts index f701fd64e32e6..4ce9d4871246c 100644 --- a/x-pack/test/api_integration/apis/ml/data_visualizer/get_overall_stats.ts +++ b/x-pack/test/api_integration/apis/ml/data_visualizer/get_overall_stats.ts @@ -126,7 +126,7 @@ export default ({ getService }: FtrProviderContext) => { // Move these tests to file_data_visualizer plugin describe('get_overall_stats', function () { before(async () => { - await esArchiver.loadIfNeeded('ml/farequote'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/ml/farequote'); await ml.testResources.setKibanaTimeZoneToUTC(); }); diff --git a/x-pack/test/api_integration/apis/ml/fields_service/field_cardinality.ts b/x-pack/test/api_integration/apis/ml/fields_service/field_cardinality.ts index 13941f0c1e145..9e233b7d0f7a2 100644 --- a/x-pack/test/api_integration/apis/ml/fields_service/field_cardinality.ts +++ b/x-pack/test/api_integration/apis/ml/fields_service/field_cardinality.ts @@ -87,7 +87,7 @@ export default ({ getService }: FtrProviderContext) => { describe('field_cardinality', function () { before(async () => { - await esArchiver.loadIfNeeded('ml/ecommerce'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/ml/ecommerce'); await ml.testResources.setKibanaTimeZoneToUTC(); }); diff --git a/x-pack/test/api_integration/apis/ml/fields_service/time_field_range.ts b/x-pack/test/api_integration/apis/ml/fields_service/time_field_range.ts index c95cf4e4f9ce4..7cc285f0cece5 100644 --- a/x-pack/test/api_integration/apis/ml/fields_service/time_field_range.ts +++ b/x-pack/test/api_integration/apis/ml/fields_service/time_field_range.ts @@ -90,7 +90,7 @@ export default ({ getService }: FtrProviderContext) => { describe('time_field_range', function () { before(async () => { - await esArchiver.loadIfNeeded('ml/ecommerce'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/ml/ecommerce'); await ml.testResources.setKibanaTimeZoneToUTC(); }); diff --git a/x-pack/test/api_integration/apis/ml/index.ts b/x-pack/test/api_integration/apis/ml/index.ts index 2206355003a75..9ed654c5b9f6b 100644 --- a/x-pack/test/api_integration/apis/ml/index.ts +++ b/x-pack/test/api_integration/apis/ml/index.ts @@ -42,28 +42,28 @@ export default function ({ getService, loadTestFile }: FtrProviderContext) { await ml.testResources.deleteIndexPatternByTitle('ft_module_apache_data_stream'); await ml.testResources.deleteIndexPatternByTitle('ft_module_nginx_data_stream'); - await esArchiver.unload('ml/ecommerce'); - await esArchiver.unload('ml/categorization'); - await esArchiver.unload('ml/module_apache'); - await esArchiver.unload('ml/module_auditbeat'); - await esArchiver.unload('ml/module_apm'); - await esArchiver.unload('ml/module_heartbeat'); - await esArchiver.unload('ml/module_logs'); - await esArchiver.unload('ml/module_nginx'); - await esArchiver.unload('ml/module_sample_ecommerce'); - await esArchiver.unload('ml/module_sample_logs'); - await esArchiver.unload('ml/module_security_endpoint'); - await esArchiver.unload('ml/module_siem_auditbeat'); - await esArchiver.unload('ml/module_siem_packetbeat'); - await esArchiver.unload('ml/module_siem_winlogbeat'); - await esArchiver.unload('ml/farequote'); - await esArchiver.unload('ml/bm_classification'); - await esArchiver.unload('ml/ihp_outlier'); - await esArchiver.unload('ml/module_metricbeat'); - await esArchiver.unload('ml/module_siem_cloudtrail'); - await esArchiver.unload('ml/module_metrics_ui'); - await esArchiver.unload('ml/module_apache_data_stream'); - await esArchiver.unload('ml/module_nginx_data_stream'); + await esArchiver.unload('x-pack/test/functional/es_archives/ml/ecommerce'); + await esArchiver.unload('x-pack/test/functional/es_archives/ml/categorization'); + await esArchiver.unload('x-pack/test/functional/es_archives/ml/module_apache'); + await esArchiver.unload('x-pack/test/functional/es_archives/ml/module_auditbeat'); + await esArchiver.unload('x-pack/test/functional/es_archives/ml/module_apm'); + await esArchiver.unload('x-pack/test/functional/es_archives/ml/module_heartbeat'); + await esArchiver.unload('x-pack/test/functional/es_archives/ml/module_logs'); + await esArchiver.unload('x-pack/test/functional/es_archives/ml/module_nginx'); + await esArchiver.unload('x-pack/test/functional/es_archives/ml/module_sample_ecommerce'); + await esArchiver.unload('x-pack/test/functional/es_archives/ml/module_sample_logs'); + await esArchiver.unload('x-pack/test/functional/es_archives/ml/module_security_endpoint'); + await esArchiver.unload('x-pack/test/functional/es_archives/ml/module_siem_auditbeat'); + await esArchiver.unload('x-pack/test/functional/es_archives/ml/module_siem_packetbeat'); + await esArchiver.unload('x-pack/test/functional/es_archives/ml/module_siem_winlogbeat'); + await esArchiver.unload('x-pack/test/functional/es_archives/ml/farequote'); + await esArchiver.unload('x-pack/test/functional/es_archives/ml/bm_classification'); + await esArchiver.unload('x-pack/test/functional/es_archives/ml/ihp_outlier'); + await esArchiver.unload('x-pack/test/functional/es_archives/ml/module_metricbeat'); + await esArchiver.unload('x-pack/test/functional/es_archives/ml/module_siem_cloudtrail'); + await esArchiver.unload('x-pack/test/functional/es_archives/ml/module_metrics_ui'); + await esArchiver.unload('x-pack/test/functional/es_archives/ml/module_apache_data_stream'); + await esArchiver.unload('x-pack/test/functional/es_archives/ml/module_nginx_data_stream'); await ml.testResources.resetKibanaTimeZone(); }); diff --git a/x-pack/test/api_integration/apis/ml/job_validation/bucket_span_estimator.ts b/x-pack/test/api_integration/apis/ml/job_validation/bucket_span_estimator.ts index c3857c5f3d28d..c55e6e2628c18 100644 --- a/x-pack/test/api_integration/apis/ml/job_validation/bucket_span_estimator.ts +++ b/x-pack/test/api_integration/apis/ml/job_validation/bucket_span_estimator.ts @@ -88,7 +88,7 @@ export default ({ getService }: FtrProviderContext) => { describe('bucket span estimator', function () { before(async () => { - await esArchiver.loadIfNeeded('ml/ecommerce'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/ml/ecommerce'); await ml.testResources.setKibanaTimeZoneToUTC(); }); diff --git a/x-pack/test/api_integration/apis/ml/job_validation/calculate_model_memory_limit.ts b/x-pack/test/api_integration/apis/ml/job_validation/calculate_model_memory_limit.ts index a0f0a97d36d92..c2cc9480fee3b 100644 --- a/x-pack/test/api_integration/apis/ml/job_validation/calculate_model_memory_limit.ts +++ b/x-pack/test/api_integration/apis/ml/job_validation/calculate_model_memory_limit.ts @@ -145,7 +145,7 @@ export default ({ getService }: FtrProviderContext) => { describe('calculate model memory limit', function () { before(async () => { - await esArchiver.loadIfNeeded('ml/ecommerce'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/ml/ecommerce'); await ml.testResources.setKibanaTimeZoneToUTC(); }); diff --git a/x-pack/test/api_integration/apis/ml/job_validation/cardinality.ts b/x-pack/test/api_integration/apis/ml/job_validation/cardinality.ts index 9b6b9305f8b95..e287537b0ca34 100644 --- a/x-pack/test/api_integration/apis/ml/job_validation/cardinality.ts +++ b/x-pack/test/api_integration/apis/ml/job_validation/cardinality.ts @@ -19,7 +19,7 @@ export default ({ getService }: FtrProviderContext) => { describe('ValidateCardinality', function () { before(async () => { - await esArchiver.loadIfNeeded('ml/ecommerce'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/ml/ecommerce'); await ml.testResources.setKibanaTimeZoneToUTC(); }); diff --git a/x-pack/test/api_integration/apis/ml/job_validation/validate.ts b/x-pack/test/api_integration/apis/ml/job_validation/validate.ts index 752aae546565a..06d966851abfd 100644 --- a/x-pack/test/api_integration/apis/ml/job_validation/validate.ts +++ b/x-pack/test/api_integration/apis/ml/job_validation/validate.ts @@ -22,7 +22,7 @@ export default ({ getService }: FtrProviderContext) => { describe('Validate job', function () { before(async () => { - await esArchiver.loadIfNeeded('ml/ecommerce'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/ml/ecommerce'); await ml.testResources.setKibanaTimeZoneToUTC(); }); diff --git a/x-pack/test/api_integration/apis/ml/jobs/categorization_field_examples.ts b/x-pack/test/api_integration/apis/ml/jobs/categorization_field_examples.ts index c9adc85b40c1b..4686787ae9b16 100644 --- a/x-pack/test/api_integration/apis/ml/jobs/categorization_field_examples.ts +++ b/x-pack/test/api_integration/apis/ml/jobs/categorization_field_examples.ts @@ -286,7 +286,7 @@ export default ({ getService }: FtrProviderContext) => { describe('Categorization example endpoint - ', function () { before(async () => { - await esArchiver.loadIfNeeded('ml/categorization'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/ml/categorization'); await ml.testResources.setKibanaTimeZoneToUTC(); }); diff --git a/x-pack/test/api_integration/apis/ml/jobs/close_jobs.ts b/x-pack/test/api_integration/apis/ml/jobs/close_jobs.ts index 96db9d20cbabe..0d64008a49688 100644 --- a/x-pack/test/api_integration/apis/ml/jobs/close_jobs.ts +++ b/x-pack/test/api_integration/apis/ml/jobs/close_jobs.ts @@ -99,7 +99,7 @@ export default ({ getService }: FtrProviderContext) => { describe('close_jobs', function () { before(async () => { - await esArchiver.loadIfNeeded('ml/farequote'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/ml/farequote'); await ml.testResources.createIndexPatternIfNeeded('ft_farequote', '@timestamp'); await ml.testResources.setKibanaTimeZoneToUTC(); }); diff --git a/x-pack/test/api_integration/apis/ml/jobs/datafeed_preview.ts b/x-pack/test/api_integration/apis/ml/jobs/datafeed_preview.ts index 2fcf75f99ff17..d299795826c26 100644 --- a/x-pack/test/api_integration/apis/ml/jobs/datafeed_preview.ts +++ b/x-pack/test/api_integration/apis/ml/jobs/datafeed_preview.ts @@ -40,7 +40,7 @@ export default ({ getService }: FtrProviderContext) => { describe('Datafeed preview', function () { before(async () => { - await esArchiver.loadIfNeeded('ml/farequote'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/ml/farequote'); await ml.testResources.setKibanaTimeZoneToUTC(); }); diff --git a/x-pack/test/api_integration/apis/ml/jobs/delete_jobs.ts b/x-pack/test/api_integration/apis/ml/jobs/delete_jobs.ts index c05fe0d71de2e..f785a35feafac 100644 --- a/x-pack/test/api_integration/apis/ml/jobs/delete_jobs.ts +++ b/x-pack/test/api_integration/apis/ml/jobs/delete_jobs.ts @@ -80,7 +80,7 @@ export default ({ getService }: FtrProviderContext) => { describe('delete_jobs', function () { before(async () => { - await esArchiver.loadIfNeeded('ml/farequote'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/ml/farequote'); await ml.testResources.setKibanaTimeZoneToUTC(); }); diff --git a/x-pack/test/api_integration/apis/ml/jobs/jobs_exist.ts b/x-pack/test/api_integration/apis/ml/jobs/jobs_exist.ts index a6c762bceedcb..8c4a79bc0ce5f 100644 --- a/x-pack/test/api_integration/apis/ml/jobs/jobs_exist.ts +++ b/x-pack/test/api_integration/apis/ml/jobs/jobs_exist.ts @@ -82,7 +82,7 @@ export default ({ getService }: FtrProviderContext) => { describe('jobs_exist', function () { before(async () => { - await esArchiver.loadIfNeeded('ml/farequote'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/ml/farequote'); await ml.testResources.createIndexPatternIfNeeded('ft_farequote', '@timestamp'); await ml.testResources.setKibanaTimeZoneToUTC(); }); diff --git a/x-pack/test/api_integration/apis/ml/jobs/jobs_summary.ts b/x-pack/test/api_integration/apis/ml/jobs/jobs_summary.ts index 4e3be92a54b6a..a57167590c1f1 100644 --- a/x-pack/test/api_integration/apis/ml/jobs/jobs_summary.ts +++ b/x-pack/test/api_integration/apis/ml/jobs/jobs_summary.ts @@ -198,7 +198,7 @@ export default ({ getService }: FtrProviderContext) => { describe('jobs_summary', function () { before(async () => { - await esArchiver.loadIfNeeded('ml/farequote'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/ml/farequote'); await ml.testResources.setKibanaTimeZoneToUTC(); }); diff --git a/x-pack/test/api_integration/apis/ml/modules/recognize_module.ts b/x-pack/test/api_integration/apis/ml/modules/recognize_module.ts index 8cdc7168ac62b..2181bea8b4040 100644 --- a/x-pack/test/api_integration/apis/ml/modules/recognize_module.ts +++ b/x-pack/test/api_integration/apis/ml/modules/recognize_module.ts @@ -19,7 +19,7 @@ export default ({ getService }: FtrProviderContext) => { const testDataList = [ { testTitleSuffix: 'for sample logs dataset', - sourceDataArchive: 'ml/module_sample_logs', + sourceDataArchive: 'x-pack/test/functional/es_archives/ml/module_sample_logs', indexPattern: 'ft_module_sample_logs', user: USER.ML_POWERUSER, expected: { @@ -29,7 +29,7 @@ export default ({ getService }: FtrProviderContext) => { }, { testTitleSuffix: 'for apache dataset', - sourceDataArchive: 'ml/module_apache', + sourceDataArchive: 'x-pack/test/functional/es_archives/ml/module_apache', indexPattern: 'ft_module_apache', user: USER.ML_POWERUSER, expected: { @@ -39,7 +39,7 @@ export default ({ getService }: FtrProviderContext) => { }, { testTitleSuffix: 'for apm dataset', - sourceDataArchive: 'ml/module_apm', + sourceDataArchive: 'x-pack/test/functional/es_archives/ml/module_apm', indexPattern: 'ft_module_apm', user: USER.ML_POWERUSER, expected: { @@ -49,7 +49,7 @@ export default ({ getService }: FtrProviderContext) => { }, { testTitleSuffix: 'for logs dataset', - sourceDataArchive: 'ml/module_logs', + sourceDataArchive: 'x-pack/test/functional/es_archives/ml/module_logs', indexPattern: 'ft_module_logs', user: USER.ML_POWERUSER, expected: { @@ -59,7 +59,7 @@ export default ({ getService }: FtrProviderContext) => { }, { testTitleSuffix: 'for nginx dataset', - sourceDataArchive: 'ml/module_nginx', + sourceDataArchive: 'x-pack/test/functional/es_archives/ml/module_nginx', indexPattern: 'ft_module_nginx', user: USER.ML_POWERUSER, expected: { @@ -69,7 +69,7 @@ export default ({ getService }: FtrProviderContext) => { }, { testTitleSuffix: 'for sample ecommerce dataset', - sourceDataArchive: 'ml/module_sample_ecommerce', + sourceDataArchive: 'x-pack/test/functional/es_archives/ml/module_sample_ecommerce', indexPattern: 'ft_module_sample_ecommerce', user: USER.ML_POWERUSER, expected: { @@ -79,7 +79,7 @@ export default ({ getService }: FtrProviderContext) => { }, { testTitleSuffix: 'for siem auditbeat dataset', - sourceDataArchive: 'ml/module_siem_auditbeat', + sourceDataArchive: 'x-pack/test/functional/es_archives/ml/module_siem_auditbeat', indexPattern: 'ft_module_siem_auditbeat', user: USER.ML_POWERUSER, expected: { @@ -89,7 +89,7 @@ export default ({ getService }: FtrProviderContext) => { }, { testTitleSuffix: 'for siem packetbeat dataset', - sourceDataArchive: 'ml/module_siem_packetbeat', + sourceDataArchive: 'x-pack/test/functional/es_archives/ml/module_siem_packetbeat', indexPattern: 'ft_module_siem_packetbeat', user: USER.ML_POWERUSER, expected: { @@ -99,7 +99,7 @@ export default ({ getService }: FtrProviderContext) => { }, { testTitleSuffix: 'for siem winlogbeat dataset', - sourceDataArchive: 'ml/module_siem_winlogbeat', + sourceDataArchive: 'x-pack/test/functional/es_archives/ml/module_siem_winlogbeat', indexPattern: 'ft_module_siem_winlogbeat', user: USER.ML_POWERUSER, expected: { @@ -123,7 +123,7 @@ export default ({ getService }: FtrProviderContext) => { }, { testTitleSuffix: 'for heartbeat dataset', - sourceDataArchive: 'ml/module_heartbeat', + sourceDataArchive: 'x-pack/test/functional/es_archives/ml/module_heartbeat', indexPattern: 'ft_module_heartbeat', user: USER.ML_POWERUSER, expected: { @@ -133,7 +133,7 @@ export default ({ getService }: FtrProviderContext) => { }, { testTitleSuffix: 'for auditbeat dataset', - sourceDataArchive: 'ml/module_auditbeat', + sourceDataArchive: 'x-pack/test/functional/es_archives/ml/module_auditbeat', indexPattern: 'ft_module_auditbeat', user: USER.ML_POWERUSER, expected: { @@ -143,7 +143,7 @@ export default ({ getService }: FtrProviderContext) => { }, { testTitleSuffix: 'for security endpoint dataset', - sourceDataArchive: 'ml/module_security_endpoint', + sourceDataArchive: 'x-pack/test/functional/es_archives/ml/module_security_endpoint', indexPattern: 'ft_logs-endpoint.events.*', user: USER.ML_POWERUSER, expected: { @@ -153,7 +153,7 @@ export default ({ getService }: FtrProviderContext) => { }, { testTitleSuffix: 'for metricbeat dataset', - sourceDataArchive: 'ml/module_metricbeat', + sourceDataArchive: 'x-pack/test/functional/es_archives/ml/module_metricbeat', indexPattern: 'ft_module_metricbeat', user: USER.ML_POWERUSER, expected: { @@ -163,7 +163,7 @@ export default ({ getService }: FtrProviderContext) => { }, { testTitleSuffix: 'for siem clodutrail dataset', - sourceDataArchive: 'ml/module_siem_cloudtrail', + sourceDataArchive: 'x-pack/test/functional/es_archives/ml/module_siem_cloudtrail', indexPattern: 'ft_module_siem_cloudtrail', user: USER.ML_POWERUSER, expected: { @@ -173,7 +173,7 @@ export default ({ getService }: FtrProviderContext) => { }, { testTitleSuffix: 'for metrics ui dataset', - sourceDataArchive: 'ml/module_metrics_ui', + sourceDataArchive: 'x-pack/test/functional/es_archives/ml/module_metrics_ui', indexPattern: 'ft_module_metrics_ui', user: USER.ML_POWERUSER, expected: { @@ -183,7 +183,7 @@ export default ({ getService }: FtrProviderContext) => { }, { testTitleSuffix: 'for apache data stream dataset', - sourceDataArchive: 'ml/module_apache_data_stream', + sourceDataArchive: 'x-pack/test/functional/es_archives/ml/module_apache_data_stream', indexPattern: 'ft_module_apache_data_stream', user: USER.ML_POWERUSER, expected: { @@ -193,7 +193,7 @@ export default ({ getService }: FtrProviderContext) => { }, { testTitleSuffix: 'for nginx data stream dataset', - sourceDataArchive: 'ml/module_nginx_data_stream', + sourceDataArchive: 'x-pack/test/functional/es_archives/ml/module_nginx_data_stream', indexPattern: 'ft_module_nginx_data_stream', user: USER.ML_POWERUSER, expected: { diff --git a/x-pack/test/api_integration/apis/ml/modules/setup_module.ts b/x-pack/test/api_integration/apis/ml/modules/setup_module.ts index 186a87e547382..30dc31ef460c6 100644 --- a/x-pack/test/api_integration/apis/ml/modules/setup_module.ts +++ b/x-pack/test/api_integration/apis/ml/modules/setup_module.ts @@ -24,7 +24,7 @@ export default ({ getService }: FtrProviderContext) => { { testTitleSuffix: 'for sample_data_weblogs with prefix, startDatafeed false and estimateModelMemory false', - sourceDataArchive: 'ml/module_sample_logs', + sourceDataArchive: 'x-pack/test/functional/es_archives/ml/module_sample_logs', indexPattern: { name: 'ft_module_sample_logs', timeField: '@timestamp' }, module: 'sample_data_weblogs', user: USER.ML_POWERUSER, @@ -61,7 +61,7 @@ export default ({ getService }: FtrProviderContext) => { { testTitleSuffix: 'for sample_data_weblogs with prefix, startDatafeed true and estimateModelMemory true', - sourceDataArchive: 'ml/module_sample_logs', + sourceDataArchive: 'x-pack/test/functional/es_archives/ml/module_sample_logs', indexPattern: { name: 'ft_module_sample_logs', timeField: '@timestamp' }, module: 'sample_data_weblogs', user: USER.ML_POWERUSER, @@ -98,7 +98,7 @@ export default ({ getService }: FtrProviderContext) => { { testTitleSuffix: 'for apache_ecs with prefix, startDatafeed true and estimateModelMemory true', - sourceDataArchive: 'ml/module_apache', + sourceDataArchive: 'x-pack/test/functional/es_archives/ml/module_apache', indexPattern: { name: 'ft_module_apache', timeField: '@timestamp' }, module: 'apache_ecs', user: USER.ML_POWERUSER, @@ -153,7 +153,7 @@ export default ({ getService }: FtrProviderContext) => { { testTitleSuffix: 'for apm_nodejs with prefix, startDatafeed true and estimateModelMemory true', - sourceDataArchive: 'ml/module_apm', + sourceDataArchive: 'x-pack/test/functional/es_archives/ml/module_apm', indexPattern: { name: 'ft_module_apm', timeField: '@timestamp' }, module: 'apm_nodejs', user: USER.ML_POWERUSER, @@ -190,7 +190,7 @@ export default ({ getService }: FtrProviderContext) => { { testTitleSuffix: 'for apm_transaction with prefix, startDatafeed true and estimateModelMemory true', - sourceDataArchive: 'ml/module_apm', + sourceDataArchive: 'x-pack/test/functional/es_archives/ml/module_apm', indexPattern: { name: 'ft_module_apm', timeField: '@timestamp' }, module: 'apm_transaction', user: USER.ML_POWERUSER, @@ -217,7 +217,7 @@ export default ({ getService }: FtrProviderContext) => { { testTitleSuffix: 'for logs_ui_analysis with prefix, startDatafeed true and estimateModelMemory true', - sourceDataArchive: 'ml/module_logs', + sourceDataArchive: 'x-pack/test/functional/es_archives/ml/module_logs', indexPattern: { name: 'ft_module_logs', timeField: '@timestamp' }, module: 'logs_ui_analysis', user: USER.ML_POWERUSER, @@ -244,7 +244,7 @@ export default ({ getService }: FtrProviderContext) => { { testTitleSuffix: 'for logs_ui_categories with prefix, startDatafeed true and estimateModelMemory true', - sourceDataArchive: 'ml/module_logs', + sourceDataArchive: 'x-pack/test/functional/es_archives/ml/module_logs', indexPattern: { name: 'ft_module_logs', timeField: '@timestamp' }, module: 'logs_ui_categories', user: USER.ML_POWERUSER, @@ -270,7 +270,7 @@ export default ({ getService }: FtrProviderContext) => { }, { testTitleSuffix: 'for nginx_ecs with prefix, startDatafeed true and estimateModelMemory true', - sourceDataArchive: 'ml/module_nginx', + sourceDataArchive: 'x-pack/test/functional/es_archives/ml/module_nginx', indexPattern: { name: 'ft_module_nginx', timeField: '@timestamp' }, module: 'nginx_ecs', user: USER.ML_POWERUSER, @@ -325,7 +325,7 @@ export default ({ getService }: FtrProviderContext) => { { testTitleSuffix: 'for sample_data_ecommerce with prefix, startDatafeed true and estimateModelMemory true', - sourceDataArchive: 'ml/module_sample_ecommerce', + sourceDataArchive: 'x-pack/test/functional/es_archives/ml/module_sample_ecommerce', indexPattern: { name: 'ft_module_sample_ecommerce', timeField: 'order_date' }, module: 'sample_data_ecommerce', user: USER.ML_POWERUSER, @@ -352,7 +352,7 @@ export default ({ getService }: FtrProviderContext) => { { testTitleSuffix: 'for siem_auditbeat_auth with prefix, startDatafeed true and estimateModelMemory true', - sourceDataArchive: 'ml/module_siem_auditbeat', + sourceDataArchive: 'x-pack/test/functional/es_archives/ml/module_siem_auditbeat', indexPattern: { name: 'ft_module_siem_auditbeat', timeField: '@timestamp' }, module: 'siem_auditbeat_auth', user: USER.ML_POWERUSER, @@ -379,7 +379,7 @@ export default ({ getService }: FtrProviderContext) => { { testTitleSuffix: 'for siem_packetbeat with prefix, startDatafeed true and estimateModelMemory true', - sourceDataArchive: 'ml/module_siem_packetbeat', + sourceDataArchive: 'x-pack/test/functional/es_archives/ml/module_siem_packetbeat', indexPattern: { name: 'ft_module_siem_packetbeat', timeField: '@timestamp' }, module: 'siem_packetbeat', user: USER.ML_POWERUSER, @@ -426,7 +426,7 @@ export default ({ getService }: FtrProviderContext) => { { testTitleSuffix: 'for uptime_heartbeat with prefix, startDatafeed true and estimateModelMemory true', - sourceDataArchive: 'ml/module_heartbeat', + sourceDataArchive: 'x-pack/test/functional/es_archives/ml/module_heartbeat', indexPattern: { name: 'ft_module_heartbeat', timeField: '@timestamp' }, module: 'uptime_heartbeat', user: USER.ML_POWERUSER, @@ -453,7 +453,7 @@ export default ({ getService }: FtrProviderContext) => { { testTitleSuffix: 'for auditbeat_process_hosts_ecs with prefix, startDatafeed true and estimateModelMemory true', - sourceDataArchive: 'ml/module_auditbeat', + sourceDataArchive: 'x-pack/test/functional/es_archives/ml/module_auditbeat', indexPattern: { name: 'ft_module_auditbeat', timeField: '@timestamp' }, module: 'auditbeat_process_hosts_ecs', user: USER.ML_POWERUSER, @@ -492,7 +492,7 @@ export default ({ getService }: FtrProviderContext) => { { testTitleSuffix: 'for security_linux with prefix, startDatafeed true and estimateModelMemory true', - sourceDataArchive: 'ml/module_security_endpoint', + sourceDataArchive: 'x-pack/test/functional/es_archives/ml/module_security_endpoint', indexPattern: { name: 'ft_logs-endpoint.events.*', timeField: '@timestamp' }, module: 'security_linux', user: USER.ML_POWERUSER, @@ -544,7 +544,7 @@ export default ({ getService }: FtrProviderContext) => { { testTitleSuffix: 'for security_windows with prefix, startDatafeed true and estimateModelMemory true', - sourceDataArchive: 'ml/module_security_endpoint', + sourceDataArchive: 'x-pack/test/functional/es_archives/ml/module_security_endpoint', indexPattern: { name: 'ft_logs-endpoint.events.*', timeField: '@timestamp' }, module: 'security_windows', user: USER.ML_POWERUSER, @@ -606,7 +606,7 @@ export default ({ getService }: FtrProviderContext) => { { testTitleSuffix: 'for metricbeat_system_ecs with prefix, startDatafeed true and estimateModelMemory true', - sourceDataArchive: 'ml/module_metricbeat', + sourceDataArchive: 'x-pack/test/functional/es_archives/ml/module_metricbeat', indexPattern: { name: 'ft_module_metricbeat', timeField: '@timestamp' }, module: 'metricbeat_system_ecs', user: USER.ML_POWERUSER, @@ -643,7 +643,7 @@ export default ({ getService }: FtrProviderContext) => { { testTitleSuffix: 'for metrics_ui_hosts with prefix, startDatafeed true and estimateModelMemory true', - sourceDataArchive: 'ml/module_metrics_ui', + sourceDataArchive: 'x-pack/test/functional/es_archives/ml/module_metrics_ui', indexPattern: { name: 'ft_module_metrics_ui', timeField: '@timestamp' }, module: 'metrics_ui_hosts', user: USER.ML_POWERUSER, @@ -680,7 +680,7 @@ export default ({ getService }: FtrProviderContext) => { { testTitleSuffix: 'for metrics_ui_k8s with prefix, startDatafeed true and estimateModelMemory true', - sourceDataArchive: 'ml/module_metrics_ui', + sourceDataArchive: 'x-pack/test/functional/es_archives/ml/module_metrics_ui', indexPattern: { name: 'ft_module_metrics_ui', timeField: '@timestamp' }, module: 'metrics_ui_k8s', user: USER.ML_POWERUSER, @@ -717,7 +717,7 @@ export default ({ getService }: FtrProviderContext) => { { testTitleSuffix: 'for siem_cloudtrail with prefix, startDatafeed true and estimateModelMemory true', - sourceDataArchive: 'ml/module_siem_cloudtrail', + sourceDataArchive: 'x-pack/test/functional/es_archives/ml/module_siem_cloudtrail', indexPattern: { name: 'ft_module_siem_cloudtrail', timeField: '@timestamp' }, module: 'siem_cloudtrail', user: USER.ML_POWERUSER, @@ -764,7 +764,7 @@ export default ({ getService }: FtrProviderContext) => { { testTitleSuffix: 'for siem_winlogbeat with prefix, startDatafeed true and estimateModelMemory true', - sourceDataArchive: 'ml/module_siem_winlogbeat', + sourceDataArchive: 'x-pack/test/functional/es_archives/ml/module_siem_winlogbeat', indexPattern: { name: 'ft_module_siem_winlogbeat', timeField: '@timestamp' }, module: 'siem_winlogbeat', user: USER.ML_POWERUSER, @@ -841,7 +841,7 @@ export default ({ getService }: FtrProviderContext) => { { testTitleSuffix: 'for siem_winlogbeat_auth with prefix, startDatafeed true and estimateModelMemory true', - sourceDataArchive: 'ml/module_siem_winlogbeat', + sourceDataArchive: 'x-pack/test/functional/es_archives/ml/module_siem_winlogbeat', indexPattern: { name: 'ft_module_siem_winlogbeat', timeField: '@timestamp' }, module: 'siem_winlogbeat_auth', user: USER.ML_POWERUSER, @@ -868,7 +868,7 @@ export default ({ getService }: FtrProviderContext) => { { testTitleSuffix: 'for apache_data_stream with prefix, startDatafeed true and estimateModelMemory true', - sourceDataArchive: 'ml/module_apache_data_stream', + sourceDataArchive: 'x-pack/test/functional/es_archives/ml/module_apache_data_stream', indexPattern: { name: 'ft_module_apache_data_stream', timeField: '@timestamp' }, module: 'apache_data_stream', user: USER.ML_POWERUSER, @@ -915,7 +915,7 @@ export default ({ getService }: FtrProviderContext) => { { testTitleSuffix: 'for nginx_data_stream with prefix, startDatafeed true and estimateModelMemory true', - sourceDataArchive: 'ml/module_nginx_data_stream', + sourceDataArchive: 'x-pack/test/functional/es_archives/ml/module_nginx_data_stream', indexPattern: { name: 'ft_module_nginx_data_stream', timeField: '@timestamp' }, module: 'nginx_data_stream', user: USER.ML_POWERUSER, @@ -979,7 +979,7 @@ export default ({ getService }: FtrProviderContext) => { }, { testTitleSuffix: 'for unauthorized user', - sourceDataArchive: 'ml/module_sample_logs', + sourceDataArchive: 'x-pack/test/functional/es_archives/ml/module_sample_logs', indexPattern: { name: 'ft_module_sample_logs', timeField: '@timestamp' }, module: 'sample_data_weblogs', user: USER.ML_UNAUTHORIZED, diff --git a/x-pack/test/api_integration/apis/ml/results/get_anomalies_table_data.ts b/x-pack/test/api_integration/apis/ml/results/get_anomalies_table_data.ts index 2aaee3ad2bf71..9596cf7ab7d9b 100644 --- a/x-pack/test/api_integration/apis/ml/results/get_anomalies_table_data.ts +++ b/x-pack/test/api_integration/apis/ml/results/get_anomalies_table_data.ts @@ -50,7 +50,7 @@ export default ({ getService }: FtrProviderContext) => { describe('GetAnomaliesTableData', () => { before(async () => { - await esArchiver.loadIfNeeded('ml/farequote'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/ml/farequote'); await ml.testResources.setKibanaTimeZoneToUTC(); await createMockJobs(); }); diff --git a/x-pack/test/api_integration/apis/ml/results/get_categorizer_stats.ts b/x-pack/test/api_integration/apis/ml/results/get_categorizer_stats.ts index ef677969d006f..5555d4a91cd1a 100644 --- a/x-pack/test/api_integration/apis/ml/results/get_categorizer_stats.ts +++ b/x-pack/test/api_integration/apis/ml/results/get_categorizer_stats.ts @@ -53,7 +53,7 @@ export default ({ getService }: FtrProviderContext) => { describe('get categorizer_stats', function () { before(async () => { - await esArchiver.loadIfNeeded('ml/module_sample_logs'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/ml/module_sample_logs'); await ml.testResources.setKibanaTimeZoneToUTC(); // @ts-expect-error not full interface await ml.api.createAndRunAnomalyDetectionLookbackJob(testJobConfig, testDatafeedConfig); diff --git a/x-pack/test/api_integration/apis/ml/results/get_stopped_partitions.ts b/x-pack/test/api_integration/apis/ml/results/get_stopped_partitions.ts index d00999b06b588..d33062af07b68 100644 --- a/x-pack/test/api_integration/apis/ml/results/get_stopped_partitions.ts +++ b/x-pack/test/api_integration/apis/ml/results/get_stopped_partitions.ts @@ -87,7 +87,7 @@ export default ({ getService }: FtrProviderContext) => { describe('get stopped_partitions', function () { before(async () => { - await esArchiver.loadIfNeeded('ml/module_sample_logs'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/ml/module_sample_logs'); await ml.testResources.setKibanaTimeZoneToUTC(); for (const testData of testSetUps) { const { jobConfig, datafeedConfig } = testData; diff --git a/x-pack/test/api_integration/apis/ml/saved_objects/initialize.ts b/x-pack/test/api_integration/apis/ml/saved_objects/initialize.ts index 626b685b56d44..8859b7ed2b106 100644 --- a/x-pack/test/api_integration/apis/ml/saved_objects/initialize.ts +++ b/x-pack/test/api_integration/apis/ml/saved_objects/initialize.ts @@ -32,7 +32,7 @@ export default ({ getService }: FtrProviderContext) => { describe('GET saved_objects/initialize', () => { before(async () => { - await esArchiver.loadIfNeeded('ml/ihp_outlier'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/ml/ihp_outlier'); await ml.api.createAnomalyDetectionJobES( ml.commonConfig.getADFqSingleMetricJobConfig(adJobId) diff --git a/x-pack/test/api_integration/apis/ml/saved_objects/jobs_spaces.ts b/x-pack/test/api_integration/apis/ml/saved_objects/jobs_spaces.ts index 9f369a14a6276..9dbf6657cd593 100644 --- a/x-pack/test/api_integration/apis/ml/saved_objects/jobs_spaces.ts +++ b/x-pack/test/api_integration/apis/ml/saved_objects/jobs_spaces.ts @@ -35,7 +35,7 @@ export default ({ getService }: FtrProviderContext) => { describe('GET saved_objects/jobs_spaces', () => { before(async () => { - await esArchiver.loadIfNeeded('ml/ihp_outlier'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/ml/ihp_outlier'); await spacesService.create({ id: idSpace1, name: 'space_one', disabledFeatures: [] }); await spacesService.create({ id: idSpace2, name: 'space_two', disabledFeatures: [] }); diff --git a/x-pack/test/api_integration/apis/ml/saved_objects/status.ts b/x-pack/test/api_integration/apis/ml/saved_objects/status.ts index 93d82dd59a644..41c94e3b46683 100644 --- a/x-pack/test/api_integration/apis/ml/saved_objects/status.ts +++ b/x-pack/test/api_integration/apis/ml/saved_objects/status.ts @@ -40,7 +40,7 @@ export default ({ getService }: FtrProviderContext) => { describe('GET saved_objects/status', () => { before(async () => { - await esArchiver.loadIfNeeded('ml/ihp_outlier'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/ml/ihp_outlier'); await spacesService.create({ id: idSpace1, name: 'space_one', disabledFeatures: [] }); await spacesService.create({ id: idSpace2, name: 'space_two', disabledFeatures: [] }); diff --git a/x-pack/test/api_integration/apis/ml/saved_objects/update_jobs_spaces.ts b/x-pack/test/api_integration/apis/ml/saved_objects/update_jobs_spaces.ts index 89233fe11dbc6..f326a3049e921 100644 --- a/x-pack/test/api_integration/apis/ml/saved_objects/update_jobs_spaces.ts +++ b/x-pack/test/api_integration/apis/ml/saved_objects/update_jobs_spaces.ts @@ -45,7 +45,7 @@ export default ({ getService }: FtrProviderContext) => { describe('POST saved_objects/update_jobs_spaces', () => { before(async () => { - await esArchiver.loadIfNeeded('ml/ihp_outlier'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/ml/ihp_outlier'); await spacesService.create({ id: idSpace1, name: 'space_one', disabledFeatures: [] }); await spacesService.create({ id: idSpace2, name: 'space_two', disabledFeatures: [] }); diff --git a/x-pack/test/api_integration/apis/monitoring/apm/instance.js b/x-pack/test/api_integration/apis/monitoring/apm/instance.js index 5f603d25b7d69..229cc05a58a1b 100644 --- a/x-pack/test/api_integration/apis/monitoring/apm/instance.js +++ b/x-pack/test/api_integration/apis/monitoring/apm/instance.js @@ -15,7 +15,7 @@ export default function ({ getService }) { const esArchiver = getService('esArchiver'); describe('instance detail', () => { - const archive = 'monitoring/apm'; + const archive = 'x-pack/test/functional/es_archives/monitoring/apm'; const timeRange = { min: '2018-08-31T12:59:49.104Z', max: '2018-08-31T13:59:49.104Z', diff --git a/x-pack/test/api_integration/apis/monitoring/apm/instance_mb.js b/x-pack/test/api_integration/apis/monitoring/apm/instance_mb.js index b47b44c395efa..38179368a8764 100644 --- a/x-pack/test/api_integration/apis/monitoring/apm/instance_mb.js +++ b/x-pack/test/api_integration/apis/monitoring/apm/instance_mb.js @@ -13,7 +13,7 @@ export default function ({ getService }) { const esArchiver = getService('esArchiver'); describe('instance detail mb', () => { - const archive = 'monitoring/apm_mb'; + const archive = 'x-pack/test/functional/es_archives/monitoring/apm_mb'; const timeRange = { min: '2018-08-31T12:59:49.104Z', max: '2018-08-31T13:59:49.104Z', diff --git a/x-pack/test/api_integration/apis/monitoring/apm/instances.js b/x-pack/test/api_integration/apis/monitoring/apm/instances.js index 9d0be53cff97f..d915923991353 100644 --- a/x-pack/test/api_integration/apis/monitoring/apm/instances.js +++ b/x-pack/test/api_integration/apis/monitoring/apm/instances.js @@ -12,7 +12,7 @@ export default function ({ getService }) { const esArchiver = getService('esArchiver'); describe('list', () => { - const archive = 'monitoring/apm'; + const archive = 'x-pack/test/functional/es_archives/monitoring/apm'; const timeRange = { min: '2018-08-31T12:59:49.104Z', max: '2018-08-31T13:59:49.104Z', diff --git a/x-pack/test/api_integration/apis/monitoring/apm/instances_mb.js b/x-pack/test/api_integration/apis/monitoring/apm/instances_mb.js index 879549659936b..9248ba32350cb 100644 --- a/x-pack/test/api_integration/apis/monitoring/apm/instances_mb.js +++ b/x-pack/test/api_integration/apis/monitoring/apm/instances_mb.js @@ -12,7 +12,7 @@ export default function ({ getService }) { const esArchiver = getService('esArchiver'); describe('list mb', () => { - const archive = 'monitoring/apm_mb'; + const archive = 'x-pack/test/functional/es_archives/monitoring/apm_mb'; const timeRange = { min: '2018-08-31T12:59:49.104Z', max: '2018-08-31T13:59:49.104Z', diff --git a/x-pack/test/api_integration/apis/monitoring/apm/overview.js b/x-pack/test/api_integration/apis/monitoring/apm/overview.js index 900a87394f106..b58e8f151b795 100644 --- a/x-pack/test/api_integration/apis/monitoring/apm/overview.js +++ b/x-pack/test/api_integration/apis/monitoring/apm/overview.js @@ -13,7 +13,7 @@ export default function ({ getService }) { const esArchiver = getService('esArchiver'); describe('overview', () => { - const archive = 'monitoring/apm'; + const archive = 'x-pack/test/functional/es_archives/monitoring/apm'; const timeRange = { min: '2018-08-31T12:59:49.104Z', max: '2018-08-31T13:59:49.104Z', diff --git a/x-pack/test/api_integration/apis/monitoring/apm/overview_mb.js b/x-pack/test/api_integration/apis/monitoring/apm/overview_mb.js index 58e257430235a..18cf7e17b760e 100644 --- a/x-pack/test/api_integration/apis/monitoring/apm/overview_mb.js +++ b/x-pack/test/api_integration/apis/monitoring/apm/overview_mb.js @@ -13,7 +13,7 @@ export default function ({ getService }) { const esArchiver = getService('esArchiver'); describe('overview mb', () => { - const archive = 'monitoring/apm_mb'; + const archive = 'x-pack/test/functional/es_archives/monitoring/apm_mb'; const timeRange = { min: '2018-08-31T12:59:49.104Z', max: '2018-08-31T13:59:49.104Z', diff --git a/x-pack/test/api_integration/apis/monitoring/beats/detail.js b/x-pack/test/api_integration/apis/monitoring/beats/detail.js index d1b4c277ef039..2a347f448f188 100644 --- a/x-pack/test/api_integration/apis/monitoring/beats/detail.js +++ b/x-pack/test/api_integration/apis/monitoring/beats/detail.js @@ -13,7 +13,7 @@ export default function ({ getService }) { const esArchiver = getService('esArchiver'); describe('instance detail', () => { - const archive = 'monitoring/beats_with_restarted_instance'; + const archive = 'x-pack/test/functional/es_archives/monitoring/beats_with_restarted_instance'; const timeRange = { min: '2018-02-09T20:49:00Z', max: '2018-02-09T21:50:00Z', diff --git a/x-pack/test/api_integration/apis/monitoring/beats/detail_mb.js b/x-pack/test/api_integration/apis/monitoring/beats/detail_mb.js index c43050d054fa7..745b317612b53 100644 --- a/x-pack/test/api_integration/apis/monitoring/beats/detail_mb.js +++ b/x-pack/test/api_integration/apis/monitoring/beats/detail_mb.js @@ -13,7 +13,8 @@ export default function ({ getService }) { const esArchiver = getService('esArchiver'); describe('instance detail mb', () => { - const archive = 'monitoring/beats_with_restarted_instance_mb'; + const archive = + 'x-pack/test/functional/es_archives/monitoring/beats_with_restarted_instance_mb'; const timeRange = { min: '2018-02-09T20:49:00Z', max: '2018-02-09T21:50:00Z', diff --git a/x-pack/test/api_integration/apis/monitoring/beats/list.js b/x-pack/test/api_integration/apis/monitoring/beats/list.js index 6c8fa8368c6a2..af01ae26c17da 100644 --- a/x-pack/test/api_integration/apis/monitoring/beats/list.js +++ b/x-pack/test/api_integration/apis/monitoring/beats/list.js @@ -13,7 +13,7 @@ export default function ({ getService }) { describe('list', () => { describe('with restarted beat instance', () => { - const archive = 'monitoring/beats_with_restarted_instance'; + const archive = 'x-pack/test/functional/es_archives/monitoring/beats_with_restarted_instance'; const timeRange = { min: '2018-02-09T20:49:00Z', max: '2018-02-09T21:50:00Z', diff --git a/x-pack/test/api_integration/apis/monitoring/beats/list_mb.js b/x-pack/test/api_integration/apis/monitoring/beats/list_mb.js index 3896bac794b0f..767ba107d0822 100644 --- a/x-pack/test/api_integration/apis/monitoring/beats/list_mb.js +++ b/x-pack/test/api_integration/apis/monitoring/beats/list_mb.js @@ -13,7 +13,8 @@ export default function ({ getService }) { describe('list mb', () => { describe('with restarted beat instance', () => { - const archive = 'monitoring/beats_with_restarted_instance_mb'; + const archive = + 'x-pack/test/functional/es_archives/monitoring/beats_with_restarted_instance_mb'; const timeRange = { min: '2018-02-09T20:49:00Z', max: '2018-02-09T21:50:00Z', diff --git a/x-pack/test/api_integration/apis/monitoring/beats/overview.js b/x-pack/test/api_integration/apis/monitoring/beats/overview.js index ee5b7545ccb5a..ce8b6cb317768 100644 --- a/x-pack/test/api_integration/apis/monitoring/beats/overview.js +++ b/x-pack/test/api_integration/apis/monitoring/beats/overview.js @@ -13,7 +13,7 @@ export default function ({ getService }) { const esArchiver = getService('esArchiver'); describe('overview', () => { - const archive = 'monitoring/beats'; + const archive = 'x-pack/test/functional/es_archives/monitoring/beats'; const timeRange = { min: '2017-12-19T18:11:32.000Z', max: '2017-12-19T18:14:38.000Z', diff --git a/x-pack/test/api_integration/apis/monitoring/beats/overview_mb.js b/x-pack/test/api_integration/apis/monitoring/beats/overview_mb.js index 1e4c678539e26..6a20309e226a0 100644 --- a/x-pack/test/api_integration/apis/monitoring/beats/overview_mb.js +++ b/x-pack/test/api_integration/apis/monitoring/beats/overview_mb.js @@ -13,7 +13,7 @@ export default function ({ getService }) { const esArchiver = getService('esArchiver'); describe('overview mb', () => { - const archive = 'monitoring/beats_mb'; + const archive = 'x-pack/test/functional/es_archives/monitoring/beats_mb'; const timeRange = { min: '2017-12-19T18:11:32.000Z', max: '2017-12-19T18:14:38.000Z', diff --git a/x-pack/test/api_integration/apis/monitoring/cluster/list.js b/x-pack/test/api_integration/apis/monitoring/cluster/list.js index 69f867b532f2f..686b63b6e7562 100644 --- a/x-pack/test/api_integration/apis/monitoring/cluster/list.js +++ b/x-pack/test/api_integration/apis/monitoring/cluster/list.js @@ -14,7 +14,7 @@ export default function ({ getService }) { describe('list', () => { describe('with trial license clusters', () => { - const archive = 'monitoring/multicluster'; + const archive = 'x-pack/test/functional/es_archives/monitoring/multicluster'; const timeRange = { min: '2017-08-15T21:00:00Z', max: '2017-08-16T00:00:00Z', diff --git a/x-pack/test/api_integration/apis/monitoring/cluster/list_mb.js b/x-pack/test/api_integration/apis/monitoring/cluster/list_mb.js index fadc81f298c1d..380f4c2a07148 100644 --- a/x-pack/test/api_integration/apis/monitoring/cluster/list_mb.js +++ b/x-pack/test/api_integration/apis/monitoring/cluster/list_mb.js @@ -14,7 +14,7 @@ export default function ({ getService }) { describe('list mb', () => { describe('with trial license clusters', () => { - const archive = 'monitoring/multicluster_mb'; + const archive = 'x-pack/test/functional/es_archives/monitoring/multicluster_mb'; const timeRange = { min: '2017-08-15T21:00:00Z', max: '2017-08-16T00:00:00Z', diff --git a/x-pack/test/api_integration/apis/monitoring/cluster/overview.js b/x-pack/test/api_integration/apis/monitoring/cluster/overview.js index 7484bbb644a9d..02bf91357ed4b 100644 --- a/x-pack/test/api_integration/apis/monitoring/cluster/overview.js +++ b/x-pack/test/api_integration/apis/monitoring/cluster/overview.js @@ -17,7 +17,7 @@ export default function ({ getService }) { this.tags(['skipCloud']); describe('with trial license clusters', () => { - const archive = 'monitoring/singlecluster_green_gold'; + const archive = 'x-pack/test/functional/es_archives/monitoring/singlecluster_green_gold'; const timeRange = { min: '2017-08-23T21:29:35Z', max: '2017-08-23T21:47:25Z', diff --git a/x-pack/test/api_integration/apis/monitoring/cluster/overview_mb.js b/x-pack/test/api_integration/apis/monitoring/cluster/overview_mb.js index 3f291e22c1112..d84ad494e8f41 100644 --- a/x-pack/test/api_integration/apis/monitoring/cluster/overview_mb.js +++ b/x-pack/test/api_integration/apis/monitoring/cluster/overview_mb.js @@ -17,7 +17,7 @@ export default function ({ getService }) { this.tags(['skipCloud']); describe('with trial license clusters', () => { - const archive = 'monitoring/singlecluster_green_gold_mb'; + const archive = 'x-pack/test/functional/es_archives/monitoring/singlecluster_green_gold_mb'; const timeRange = { min: '2017-08-23T21:29:35Z', max: '2017-08-23T21:47:25Z', diff --git a/x-pack/test/api_integration/apis/monitoring/elasticsearch/ccr.js b/x-pack/test/api_integration/apis/monitoring/elasticsearch/ccr.js index cd4b0cbd8e0bf..870bfb31a50e5 100644 --- a/x-pack/test/api_integration/apis/monitoring/elasticsearch/ccr.js +++ b/x-pack/test/api_integration/apis/monitoring/elasticsearch/ccr.js @@ -13,7 +13,7 @@ export default function ({ getService }) { const esArchiver = getService('esArchiver'); describe('ccr', () => { - const archive = 'monitoring/ccr'; + const archive = 'x-pack/test/functional/es_archives/monitoring/ccr'; const timeRange = { min: '2018-09-19T00:00:00.000Z', max: '2018-09-19T23:59:59.000Z', diff --git a/x-pack/test/api_integration/apis/monitoring/elasticsearch/ccr_mb.js b/x-pack/test/api_integration/apis/monitoring/elasticsearch/ccr_mb.js index 2af3ae5af78ff..9a8dd2e2197d8 100644 --- a/x-pack/test/api_integration/apis/monitoring/elasticsearch/ccr_mb.js +++ b/x-pack/test/api_integration/apis/monitoring/elasticsearch/ccr_mb.js @@ -13,7 +13,7 @@ export default function ({ getService }) { const esArchiver = getService('esArchiver'); describe('ccr mb', () => { - const archive = 'monitoring/ccr_mb'; + const archive = 'x-pack/test/functional/es_archives/monitoring/ccr_mb'; const timeRange = { min: '2018-09-19T00:00:00.000Z', max: '2018-09-19T23:59:59.000Z', diff --git a/x-pack/test/api_integration/apis/monitoring/elasticsearch/ccr_shard.js b/x-pack/test/api_integration/apis/monitoring/elasticsearch/ccr_shard.js index 5e983cd13d704..a4bca9798b178 100644 --- a/x-pack/test/api_integration/apis/monitoring/elasticsearch/ccr_shard.js +++ b/x-pack/test/api_integration/apis/monitoring/elasticsearch/ccr_shard.js @@ -13,7 +13,7 @@ export default function ({ getService }) { const esArchiver = getService('esArchiver'); describe('ccr shard', () => { - const archive = 'monitoring/ccr'; + const archive = 'x-pack/test/functional/es_archives/monitoring/ccr'; const timeRange = { min: '2018-09-19T00:00:00.000Z', max: '2018-09-19T23:59:59.000Z', diff --git a/x-pack/test/api_integration/apis/monitoring/elasticsearch/ccr_shard_mb.js b/x-pack/test/api_integration/apis/monitoring/elasticsearch/ccr_shard_mb.js index 516f66ba6f19e..769bff80c0df1 100644 --- a/x-pack/test/api_integration/apis/monitoring/elasticsearch/ccr_shard_mb.js +++ b/x-pack/test/api_integration/apis/monitoring/elasticsearch/ccr_shard_mb.js @@ -14,7 +14,7 @@ export default function ({ getService }) { const esArchiver = getService('esArchiver'); describe('ccr shard mb', () => { - const archive = 'monitoring/ccr_mb'; + const archive = 'x-pack/test/functional/es_archives/monitoring/ccr_mb'; const timeRange = { min: '2018-09-19T00:00:00.000Z', max: '2018-09-19T23:59:59.000Z', diff --git a/x-pack/test/api_integration/apis/monitoring/elasticsearch/index_detail.js b/x-pack/test/api_integration/apis/monitoring/elasticsearch/index_detail.js index 87610feb38f13..e243c3a372f7b 100644 --- a/x-pack/test/api_integration/apis/monitoring/elasticsearch/index_detail.js +++ b/x-pack/test/api_integration/apis/monitoring/elasticsearch/index_detail.js @@ -14,7 +14,8 @@ export default function ({ getService }) { const esArchiver = getService('esArchiver'); describe('index detail', () => { - const archive = 'monitoring/singlecluster_three_nodes_shard_relocation'; + const archive = + 'x-pack/test/functional/es_archives/monitoring/singlecluster_three_nodes_shard_relocation'; const timeRange = { min: '2017-10-05T20:31:48.000Z', max: '2017-10-05T20:35:12.000Z', diff --git a/x-pack/test/api_integration/apis/monitoring/elasticsearch/index_detail_mb.js b/x-pack/test/api_integration/apis/monitoring/elasticsearch/index_detail_mb.js index cd7cd02e13ce1..1858bcf21ba93 100644 --- a/x-pack/test/api_integration/apis/monitoring/elasticsearch/index_detail_mb.js +++ b/x-pack/test/api_integration/apis/monitoring/elasticsearch/index_detail_mb.js @@ -14,7 +14,8 @@ export default function ({ getService }) { const esArchiver = getService('esArchiver'); describe('index detail mb', () => { - const archive = 'monitoring/singlecluster_three_nodes_shard_relocation_mb'; + const archive = + 'x-pack/test/functional/es_archives/monitoring/singlecluster_three_nodes_shard_relocation_mb'; const timeRange = { min: '2017-10-05T20:31:48.000Z', max: '2017-10-05T20:35:12.000Z', diff --git a/x-pack/test/api_integration/apis/monitoring/elasticsearch/indices.js b/x-pack/test/api_integration/apis/monitoring/elasticsearch/indices.js index ba84a5b711154..0b94aaa9f27da 100644 --- a/x-pack/test/api_integration/apis/monitoring/elasticsearch/indices.js +++ b/x-pack/test/api_integration/apis/monitoring/elasticsearch/indices.js @@ -17,7 +17,8 @@ export default function ({ getService }) { describe('indices', () => { describe('shard-relocation', () => { - const archive = 'monitoring/singlecluster_three_nodes_shard_relocation'; + const archive = + 'x-pack/test/functional/es_archives/monitoring/singlecluster_three_nodes_shard_relocation'; const timeRange = { min: '2017-10-05T20:31:48.000Z', max: '2017-10-05T20:35:12.000Z', @@ -57,7 +58,7 @@ export default function ({ getService }) { }); describe('health-red', () => { - const archive = 'monitoring/singlecluster_red_platinum'; + const archive = 'x-pack/test/functional/es_archives/monitoring/singlecluster_red_platinum'; const timeRange = { min: '2017-10-06T19:53:06.000Z', max: '2017-10-06T20:15:30.000Z', diff --git a/x-pack/test/api_integration/apis/monitoring/elasticsearch/indices_mb.js b/x-pack/test/api_integration/apis/monitoring/elasticsearch/indices_mb.js index 083e38b73251b..f353f757062de 100644 --- a/x-pack/test/api_integration/apis/monitoring/elasticsearch/indices_mb.js +++ b/x-pack/test/api_integration/apis/monitoring/elasticsearch/indices_mb.js @@ -17,7 +17,8 @@ export default function ({ getService }) { describe('indices mb', () => { describe('shard-relocation', () => { - const archive = 'monitoring/singlecluster_three_nodes_shard_relocation_mb'; + const archive = + 'x-pack/test/functional/es_archives/monitoring/singlecluster_three_nodes_shard_relocation_mb'; const timeRange = { min: '2017-10-05T20:31:48.000Z', max: '2017-10-05T20:35:12.000Z', @@ -56,7 +57,7 @@ export default function ({ getService }) { }); describe('health-red', () => { - const archive = 'monitoring/singlecluster_red_platinum'; + const archive = 'x-pack/test/functional/es_archives/monitoring/singlecluster_red_platinum'; const timeRange = { min: '2017-10-06T19:53:06.000Z', max: '2017-10-06T20:15:30.000Z', diff --git a/x-pack/test/api_integration/apis/monitoring/elasticsearch/node_detail.js b/x-pack/test/api_integration/apis/monitoring/elasticsearch/node_detail.js index 4022f45ba4003..266b805a258e7 100644 --- a/x-pack/test/api_integration/apis/monitoring/elasticsearch/node_detail.js +++ b/x-pack/test/api_integration/apis/monitoring/elasticsearch/node_detail.js @@ -16,7 +16,8 @@ export default function ({ getService }) { // TODO: https://github.com/elastic/stack-monitoring/issues/31 this.tags(['skipCloud']); - const archive = 'monitoring/singlecluster_three_nodes_shard_relocation'; + const archive = + 'x-pack/test/functional/es_archives/monitoring/singlecluster_three_nodes_shard_relocation'; const timeRange = { min: '2017-10-05T20:31:48.000Z', max: '2017-10-05T20:35:12.000Z', diff --git a/x-pack/test/api_integration/apis/monitoring/elasticsearch/node_detail_advanced.js b/x-pack/test/api_integration/apis/monitoring/elasticsearch/node_detail_advanced.js index d19fa00c7e805..90c6b6b25f4b0 100644 --- a/x-pack/test/api_integration/apis/monitoring/elasticsearch/node_detail_advanced.js +++ b/x-pack/test/api_integration/apis/monitoring/elasticsearch/node_detail_advanced.js @@ -13,7 +13,8 @@ export default function ({ getService }) { const esArchiver = getService('esArchiver'); describe('node detail advanced', () => { - const archive = 'monitoring/singlecluster_three_nodes_shard_relocation'; + const archive = + 'x-pack/test/functional/es_archives/monitoring/singlecluster_three_nodes_shard_relocation'; const timeRange = { min: '2017-10-05T20:31:48.000Z', max: '2017-10-05T20:35:12.000Z', diff --git a/x-pack/test/api_integration/apis/monitoring/elasticsearch/node_detail_advanced_mb.js b/x-pack/test/api_integration/apis/monitoring/elasticsearch/node_detail_advanced_mb.js index 127af8e2367c8..40eff260225c3 100644 --- a/x-pack/test/api_integration/apis/monitoring/elasticsearch/node_detail_advanced_mb.js +++ b/x-pack/test/api_integration/apis/monitoring/elasticsearch/node_detail_advanced_mb.js @@ -13,7 +13,8 @@ export default function ({ getService }) { const esArchiver = getService('esArchiver'); describe('node detail advanced mb', () => { - const archive = 'monitoring/singlecluster_three_nodes_shard_relocation_mb'; + const archive = + 'x-pack/test/functional/es_archives/monitoring/singlecluster_three_nodes_shard_relocation_mb'; const timeRange = { min: '2017-10-05T20:31:48.000Z', max: '2017-10-05T20:35:12.000Z', diff --git a/x-pack/test/api_integration/apis/monitoring/elasticsearch/node_detail_mb.js b/x-pack/test/api_integration/apis/monitoring/elasticsearch/node_detail_mb.js index 50df0dc2c972e..b82eb3dcb6ded 100644 --- a/x-pack/test/api_integration/apis/monitoring/elasticsearch/node_detail_mb.js +++ b/x-pack/test/api_integration/apis/monitoring/elasticsearch/node_detail_mb.js @@ -16,7 +16,8 @@ export default function ({ getService }) { // TODO: https://github.com/elastic/stack-monitoring/issues/31 this.tags(['skipCloud']); - const archive = 'monitoring/singlecluster_three_nodes_shard_relocation_mb'; + const archive = + 'x-pack/test/functional/es_archives/monitoring/singlecluster_three_nodes_shard_relocation_mb'; const timeRange = { min: '2017-10-05T20:31:48.000Z', max: '2017-10-05T20:35:12.000Z', diff --git a/x-pack/test/api_integration/apis/monitoring/elasticsearch/nodes.js b/x-pack/test/api_integration/apis/monitoring/elasticsearch/nodes.js index c22c30370b22b..e437fd707e763 100644 --- a/x-pack/test/api_integration/apis/monitoring/elasticsearch/nodes.js +++ b/x-pack/test/api_integration/apis/monitoring/elasticsearch/nodes.js @@ -17,7 +17,7 @@ export default function ({ getService }) { describe('nodes', () => { describe('with green platinum cluster', () => { - const archive = 'monitoring/singlecluster_green_platinum'; + const archive = 'x-pack/test/functional/es_archives/monitoring/singlecluster_green_platinum'; const timeRange = { min: '2018-02-13T17:04:50.000Z', max: '2018-02-13T17:51:55.000Z', @@ -46,7 +46,7 @@ export default function ({ getService }) { }); describe('with red platinum cluster', () => { - const archive = 'monitoring/singlecluster_red_platinum'; + const archive = 'x-pack/test/functional/es_archives/monitoring/singlecluster_red_platinum'; const timeRange = { min: '2017-10-06T19:53:06.000Z', max: '2017-10-06T20:15:30.000Z', @@ -75,7 +75,8 @@ export default function ({ getService }) { }); describe('with green trial cluster and node in cpu group', () => { - const archive = 'monitoring/singlecluster_green_trial_two_nodes_one_cgrouped'; + const archive = + 'x-pack/test/functional/es_archives/monitoring/singlecluster_green_trial_two_nodes_one_cgrouped'; const timeRange = { min: '2018-02-13T19:18:02.000Z', max: '2018-02-13T19:26:14.000Z', @@ -104,7 +105,7 @@ export default function ({ getService }) { }); describe('with pagination', () => { - const archive = 'monitoring/singlecluster_lots_of_nodes'; + const archive = 'x-pack/test/functional/es_archives/monitoring/singlecluster_lots_of_nodes'; const timeRange = { min: '2019-10-03T19:41:01.402Z', max: '2019-10-03T19:41:13.132Z', @@ -164,7 +165,7 @@ export default function ({ getService }) { }); describe('with sorting', () => { - const archive = 'monitoring/singlecluster_lots_of_nodes'; + const archive = 'x-pack/test/functional/es_archives/monitoring/singlecluster_lots_of_nodes'; const timeRange = { min: '2019-10-03T19:41:01.402Z', max: '2019-10-03T19:41:13.132Z', @@ -309,7 +310,7 @@ export default function ({ getService }) { }); describe('with filtering', () => { - const archive = 'monitoring/singlecluster_lots_of_nodes'; + const archive = 'x-pack/test/functional/es_archives/monitoring/singlecluster_lots_of_nodes'; const timeRange = { min: '2019-10-03T19:41:01.402Z', max: '2019-10-03T19:41:13.132Z', diff --git a/x-pack/test/api_integration/apis/monitoring/elasticsearch/nodes_mb.js b/x-pack/test/api_integration/apis/monitoring/elasticsearch/nodes_mb.js index c31a5d225004d..7878470e070a6 100644 --- a/x-pack/test/api_integration/apis/monitoring/elasticsearch/nodes_mb.js +++ b/x-pack/test/api_integration/apis/monitoring/elasticsearch/nodes_mb.js @@ -17,7 +17,8 @@ export default function ({ getService }) { describe('nodes mb', () => { describe('with green platinum cluster', () => { - const archive = 'monitoring/singlecluster_green_platinum_mb'; + const archive = + 'x-pack/test/functional/es_archives/monitoring/singlecluster_green_platinum_mb'; const timeRange = { min: '2018-02-13T17:04:50.000Z', max: '2018-02-13T17:51:55.000Z', @@ -46,7 +47,7 @@ export default function ({ getService }) { }); describe('with red platinum cluster', () => { - const archive = 'monitoring/singlecluster_red_platinum'; + const archive = 'x-pack/test/functional/es_archives/monitoring/singlecluster_red_platinum'; const timeRange = { min: '2017-10-06T19:53:06.000Z', max: '2017-10-06T20:15:30.000Z', @@ -75,7 +76,8 @@ export default function ({ getService }) { }); describe('with green trial cluster and node in cpu group', () => { - const archive = 'monitoring/singlecluster_green_trial_two_nodes_one_cgrouped'; + const archive = + 'x-pack/test/functional/es_archives/monitoring/singlecluster_green_trial_two_nodes_one_cgrouped'; const timeRange = { min: '2018-02-13T19:18:02.000Z', max: '2018-02-13T19:26:14.000Z', @@ -104,7 +106,7 @@ export default function ({ getService }) { }); describe('with pagination', () => { - const archive = 'monitoring/singlecluster_lots_of_nodes'; + const archive = 'x-pack/test/functional/es_archives/monitoring/singlecluster_lots_of_nodes'; const timeRange = { min: '2019-10-03T19:41:01.402Z', max: '2019-10-03T19:41:13.132Z', @@ -164,7 +166,7 @@ export default function ({ getService }) { }); describe('with sorting', () => { - const archive = 'monitoring/singlecluster_lots_of_nodes'; + const archive = 'x-pack/test/functional/es_archives/monitoring/singlecluster_lots_of_nodes'; const timeRange = { min: '2019-10-03T19:41:01.402Z', max: '2019-10-03T19:41:13.132Z', @@ -309,7 +311,7 @@ export default function ({ getService }) { }); describe('with filtering', () => { - const archive = 'monitoring/singlecluster_lots_of_nodes'; + const archive = 'x-pack/test/functional/es_archives/monitoring/singlecluster_lots_of_nodes'; const timeRange = { min: '2019-10-03T19:41:01.402Z', max: '2019-10-03T19:41:13.132Z', diff --git a/x-pack/test/api_integration/apis/monitoring/elasticsearch/overview.js b/x-pack/test/api_integration/apis/monitoring/elasticsearch/overview.js index ea63023fa634b..1f023401fbe2e 100644 --- a/x-pack/test/api_integration/apis/monitoring/elasticsearch/overview.js +++ b/x-pack/test/api_integration/apis/monitoring/elasticsearch/overview.js @@ -17,7 +17,7 @@ export default function ({ getService }) { describe('overview', () => { describe('with green platinum cluster', () => { - const archive = 'monitoring/singlecluster_green_platinum'; + const archive = 'x-pack/test/functional/es_archives/monitoring/singlecluster_green_platinum'; const timeRange = { min: '2018-02-13T17:04:50.000Z', max: '2018-02-13T17:51:55.000Z', @@ -42,7 +42,7 @@ export default function ({ getService }) { }); describe('with red platinum cluster', () => { - const archive = 'monitoring/singlecluster_red_platinum'; + const archive = 'x-pack/test/functional/es_archives/monitoring/singlecluster_red_platinum'; const timeRange = { min: '2017-10-06T19:53:06.000Z', max: '2017-10-06T20:15:30.000Z', @@ -67,7 +67,8 @@ export default function ({ getService }) { }); describe('with shards relocating', () => { - const archive = 'monitoring/singlecluster_three_nodes_shard_relocation'; + const archive = + 'x-pack/test/functional/es_archives/monitoring/singlecluster_three_nodes_shard_relocation'; const timeRange = { min: '2017-10-05T20:31:17.081Z', max: '2017-10-05T20:35:39.428Z', diff --git a/x-pack/test/api_integration/apis/monitoring/elasticsearch/overview_mb.js b/x-pack/test/api_integration/apis/monitoring/elasticsearch/overview_mb.js index a6e26708fbfcb..7cf3d56a04988 100644 --- a/x-pack/test/api_integration/apis/monitoring/elasticsearch/overview_mb.js +++ b/x-pack/test/api_integration/apis/monitoring/elasticsearch/overview_mb.js @@ -17,7 +17,8 @@ export default function ({ getService }) { describe('overview mb', () => { describe('with green platinum cluster', () => { - const archive = 'monitoring/singlecluster_green_platinum_mb'; + const archive = + 'x-pack/test/functional/es_archives/monitoring/singlecluster_green_platinum_mb'; const timeRange = { min: '2018-02-13T17:04:50.000Z', max: '2018-02-13T17:51:55.000Z', @@ -42,7 +43,7 @@ export default function ({ getService }) { }); describe('with red platinum cluster', () => { - const archive = 'monitoring/singlecluster_red_platinum'; + const archive = 'x-pack/test/functional/es_archives/monitoring/singlecluster_red_platinum'; const timeRange = { min: '2017-10-06T19:53:06.000Z', max: '2017-10-06T20:15:30.000Z', @@ -67,7 +68,8 @@ export default function ({ getService }) { }); describe('with shards relocating', () => { - const archive = 'monitoring/singlecluster_three_nodes_shard_relocation'; + const archive = + 'x-pack/test/functional/es_archives/monitoring/singlecluster_three_nodes_shard_relocation'; const timeRange = { min: '2017-10-05T20:31:17.081Z', max: '2017-10-05T20:35:39.428Z', diff --git a/x-pack/test/api_integration/apis/monitoring/kibana/instance.js b/x-pack/test/api_integration/apis/monitoring/kibana/instance.js index 904302975f071..9827c1d888a7e 100644 --- a/x-pack/test/api_integration/apis/monitoring/kibana/instance.js +++ b/x-pack/test/api_integration/apis/monitoring/kibana/instance.js @@ -13,7 +13,7 @@ export default function ({ getService }) { const esArchiver = getService('esArchiver'); describe('instance detail', () => { - const archive = 'monitoring/singlecluster_yellow_platinum'; + const archive = 'x-pack/test/functional/es_archives/monitoring/singlecluster_yellow_platinum'; const timeRange = { min: '2017-08-29T17:24:17.000Z', max: '2017-08-29T17:26:08.000Z', diff --git a/x-pack/test/api_integration/apis/monitoring/kibana/instance_mb.js b/x-pack/test/api_integration/apis/monitoring/kibana/instance_mb.js index b888f34751209..266165410133c 100644 --- a/x-pack/test/api_integration/apis/monitoring/kibana/instance_mb.js +++ b/x-pack/test/api_integration/apis/monitoring/kibana/instance_mb.js @@ -14,7 +14,8 @@ export default function ({ getService }) { const esArchiver = getService('esArchiver'); describe('instance detail mb', () => { - const archive = 'monitoring/singlecluster_yellow_platinum_mb'; + const archive = + 'x-pack/test/functional/es_archives/monitoring/singlecluster_yellow_platinum_mb'; const timeRange = { min: '2017-08-29T17:24:17.000Z', max: '2017-08-29T17:26:08.000Z', diff --git a/x-pack/test/api_integration/apis/monitoring/kibana/listing.js b/x-pack/test/api_integration/apis/monitoring/kibana/listing.js index a86ad9169d5e2..1a5f71150b1d8 100644 --- a/x-pack/test/api_integration/apis/monitoring/kibana/listing.js +++ b/x-pack/test/api_integration/apis/monitoring/kibana/listing.js @@ -13,7 +13,7 @@ export default function ({ getService }) { const esArchiver = getService('esArchiver'); describe('listing', () => { - const archive = 'monitoring/singlecluster_yellow_platinum'; + const archive = 'x-pack/test/functional/es_archives/monitoring/singlecluster_yellow_platinum'; const timeRange = { min: '2017-08-29T17:24:17.000Z', max: '2017-08-29T17:26:08.000Z', diff --git a/x-pack/test/api_integration/apis/monitoring/kibana/listing_mb.js b/x-pack/test/api_integration/apis/monitoring/kibana/listing_mb.js index 5e226f56122ae..655baecc3c1ad 100644 --- a/x-pack/test/api_integration/apis/monitoring/kibana/listing_mb.js +++ b/x-pack/test/api_integration/apis/monitoring/kibana/listing_mb.js @@ -13,7 +13,8 @@ export default function ({ getService }) { const esArchiver = getService('esArchiver'); describe('listing mb', () => { - const archive = 'monitoring/singlecluster_yellow_platinum_mb'; + const archive = + 'x-pack/test/functional/es_archives/monitoring/singlecluster_yellow_platinum_mb'; const timeRange = { min: '2017-08-29T17:24:17.000Z', max: '2017-08-29T17:26:08.000Z', diff --git a/x-pack/test/api_integration/apis/monitoring/kibana/overview.js b/x-pack/test/api_integration/apis/monitoring/kibana/overview.js index 4f2daa90fc54c..23a783d58d2d8 100644 --- a/x-pack/test/api_integration/apis/monitoring/kibana/overview.js +++ b/x-pack/test/api_integration/apis/monitoring/kibana/overview.js @@ -13,7 +13,7 @@ export default function ({ getService }) { const esArchiver = getService('esArchiver'); describe('overview', () => { - const archive = 'monitoring/singlecluster_yellow_platinum'; + const archive = 'x-pack/test/functional/es_archives/monitoring/singlecluster_yellow_platinum'; const timeRange = { min: '2017-08-29T17:24:17.000Z', max: '2017-08-29T17:26:08.000Z', diff --git a/x-pack/test/api_integration/apis/monitoring/kibana/overview_mb.js b/x-pack/test/api_integration/apis/monitoring/kibana/overview_mb.js index afdba071b9439..87f10d367ae65 100644 --- a/x-pack/test/api_integration/apis/monitoring/kibana/overview_mb.js +++ b/x-pack/test/api_integration/apis/monitoring/kibana/overview_mb.js @@ -14,7 +14,8 @@ export default function ({ getService }) { const esArchiver = getService('esArchiver'); describe('overview mb', () => { - const archive = 'monitoring/singlecluster_yellow_platinum_mb'; + const archive = + 'x-pack/test/functional/es_archives/monitoring/singlecluster_yellow_platinum_mb'; const timeRange = { min: '2017-08-29T17:24:17.000Z', max: '2017-08-29T17:26:08.000Z', diff --git a/x-pack/test/api_integration/apis/monitoring/logs/cluster.js b/x-pack/test/api_integration/apis/monitoring/logs/cluster.js index dbe4cbb43e82e..507448a73bdf9 100644 --- a/x-pack/test/api_integration/apis/monitoring/logs/cluster.js +++ b/x-pack/test/api_integration/apis/monitoring/logs/cluster.js @@ -13,7 +13,7 @@ export default function ({ getService }) { const esArchiver = getService('esArchiver'); describe('cluster', () => { - const archive = 'monitoring/logs'; + const archive = 'x-pack/test/functional/es_archives/monitoring/logs'; const timeRange = { min: '2019-03-15T16:19:22.161Z', max: '2019-03-15T17:19:22.161Z', diff --git a/x-pack/test/api_integration/apis/monitoring/logs/index_detail.js b/x-pack/test/api_integration/apis/monitoring/logs/index_detail.js index adba23668250c..cd0dac1cb5f0c 100644 --- a/x-pack/test/api_integration/apis/monitoring/logs/index_detail.js +++ b/x-pack/test/api_integration/apis/monitoring/logs/index_detail.js @@ -13,7 +13,7 @@ export default function ({ getService }) { const esArchiver = getService('esArchiver'); describe('cluster', () => { - const archive = 'monitoring/logs'; + const archive = 'x-pack/test/functional/es_archives/monitoring/logs'; const timeRange = { min: '2019-03-15T16:19:22.161Z', max: '2019-03-15T17:19:22.161Z', diff --git a/x-pack/test/api_integration/apis/monitoring/logs/multiple_clusters.js b/x-pack/test/api_integration/apis/monitoring/logs/multiple_clusters.js index 69ea749fbdd7d..e2d8db4d587ba 100644 --- a/x-pack/test/api_integration/apis/monitoring/logs/multiple_clusters.js +++ b/x-pack/test/api_integration/apis/monitoring/logs/multiple_clusters.js @@ -13,7 +13,7 @@ export default function ({ getService }) { const esArchiver = getService('esArchiver'); describe('multiple cluster', () => { - const archive = 'monitoring/logs_multiple_clusters'; + const archive = 'x-pack/test/functional/es_archives/monitoring/logs_multiple_clusters'; const timeRange = { min: '2019-08-23T14:14:31.686Z', max: '2019-08-23T15:14:31.686Z', diff --git a/x-pack/test/api_integration/apis/monitoring/logs/node_detail.js b/x-pack/test/api_integration/apis/monitoring/logs/node_detail.js index 20ac7b9394ec5..3888f3995df36 100644 --- a/x-pack/test/api_integration/apis/monitoring/logs/node_detail.js +++ b/x-pack/test/api_integration/apis/monitoring/logs/node_detail.js @@ -13,7 +13,7 @@ export default function ({ getService }) { const esArchiver = getService('esArchiver'); describe('cluster', () => { - const archive = 'monitoring/logs'; + const archive = 'x-pack/test/functional/es_archives/monitoring/logs'; const timeRange = { min: '2019-03-15T16:19:22.161Z', max: '2019-03-15T17:19:22.161Z', diff --git a/x-pack/test/api_integration/apis/monitoring/logstash/multicluster_pipelines.js b/x-pack/test/api_integration/apis/monitoring/logstash/multicluster_pipelines.js index 5cfb7d173aeb5..801cc55ffbcad 100644 --- a/x-pack/test/api_integration/apis/monitoring/logstash/multicluster_pipelines.js +++ b/x-pack/test/api_integration/apis/monitoring/logstash/multicluster_pipelines.js @@ -13,7 +13,7 @@ export default function ({ getService }) { const esArchiver = getService('esArchiver'); describe('pipelines listing multicluster', () => { - const archive = 'monitoring/logstash_pipelines_multicluster'; + const archive = 'x-pack/test/functional/es_archives/monitoring/logstash_pipelines_multicluster'; const timeRange = { min: '2019-11-11T15:13:45.266Z', max: '2019-11-11T15:17:05.399Z', diff --git a/x-pack/test/api_integration/apis/monitoring/logstash/multicluster_pipelines_mb.js b/x-pack/test/api_integration/apis/monitoring/logstash/multicluster_pipelines_mb.js index 24b0d9a099e1b..58851ea31e7e5 100644 --- a/x-pack/test/api_integration/apis/monitoring/logstash/multicluster_pipelines_mb.js +++ b/x-pack/test/api_integration/apis/monitoring/logstash/multicluster_pipelines_mb.js @@ -13,7 +13,8 @@ export default function ({ getService }) { const esArchiver = getService('esArchiver'); describe('pipelines listing multicluster mb', () => { - const archive = 'monitoring/logstash_pipelines_multicluster_mb'; + const archive = + 'x-pack/test/functional/es_archives/monitoring/logstash_pipelines_multicluster_mb'; const timeRange = { min: '2019-11-11T15:13:45.266Z', max: '2019-11-11T15:17:05.399Z', diff --git a/x-pack/test/api_integration/apis/monitoring/logstash/node_detail.js b/x-pack/test/api_integration/apis/monitoring/logstash/node_detail.js index f1d837a427396..a9a12d2f2c853 100644 --- a/x-pack/test/api_integration/apis/monitoring/logstash/node_detail.js +++ b/x-pack/test/api_integration/apis/monitoring/logstash/node_detail.js @@ -14,7 +14,7 @@ export default function ({ getService }) { const esArchiver = getService('esArchiver'); describe('node detail', () => { - const archive = 'monitoring/logstash_pipelines'; + const archive = 'x-pack/test/functional/es_archives/monitoring/logstash_pipelines'; const timeRange = { min: '2018-01-22T09:33:13.000Z', max: '2018-01-22T09:41:04.000Z', diff --git a/x-pack/test/api_integration/apis/monitoring/logstash/node_detail_mb.js b/x-pack/test/api_integration/apis/monitoring/logstash/node_detail_mb.js index f7b33c7bf46b9..872e176408d0f 100644 --- a/x-pack/test/api_integration/apis/monitoring/logstash/node_detail_mb.js +++ b/x-pack/test/api_integration/apis/monitoring/logstash/node_detail_mb.js @@ -15,7 +15,7 @@ export default function ({ getService }) { const esArchiver = getService('esArchiver'); describe('node detail mb', () => { - const archive = 'monitoring/logstash_pipelines_mb'; + const archive = 'x-pack/test/functional/es_archives/monitoring/logstash_pipelines_mb'; const timeRange = { min: '2018-01-22T09:33:13.000Z', max: '2018-01-22T09:41:04.000Z', diff --git a/x-pack/test/api_integration/apis/monitoring/logstash/nodes.js b/x-pack/test/api_integration/apis/monitoring/logstash/nodes.js index 0423c4ed98496..8911f5f77c3a8 100644 --- a/x-pack/test/api_integration/apis/monitoring/logstash/nodes.js +++ b/x-pack/test/api_integration/apis/monitoring/logstash/nodes.js @@ -13,7 +13,7 @@ export default function ({ getService }) { const esArchiver = getService('esArchiver'); describe('node listing', () => { - const archive = 'monitoring/logstash_pipelines'; + const archive = 'x-pack/test/functional/es_archives/monitoring/logstash_pipelines'; const timeRange = { min: '2018-01-22T09:33:13.000Z', max: '2018-01-22T09:41:04.000Z', diff --git a/x-pack/test/api_integration/apis/monitoring/logstash/nodes_mb.js b/x-pack/test/api_integration/apis/monitoring/logstash/nodes_mb.js index 217f1c84ddbdb..f04a059495527 100644 --- a/x-pack/test/api_integration/apis/monitoring/logstash/nodes_mb.js +++ b/x-pack/test/api_integration/apis/monitoring/logstash/nodes_mb.js @@ -13,7 +13,7 @@ export default function ({ getService }) { const esArchiver = getService('esArchiver'); describe('node listing mb', () => { - const archive = 'monitoring/logstash_pipelines_mb'; + const archive = 'x-pack/test/functional/es_archives/monitoring/logstash_pipelines_mb'; const timeRange = { min: '2018-01-22T09:33:13.000Z', max: '2018-01-22T09:41:04.000Z', diff --git a/x-pack/test/api_integration/apis/monitoring/logstash/overview.js b/x-pack/test/api_integration/apis/monitoring/logstash/overview.js index 6476b09d372dc..9b83e60d10439 100644 --- a/x-pack/test/api_integration/apis/monitoring/logstash/overview.js +++ b/x-pack/test/api_integration/apis/monitoring/logstash/overview.js @@ -13,7 +13,7 @@ export default function ({ getService }) { const esArchiver = getService('esArchiver'); describe('overview', () => { - const archive = 'monitoring/logstash_pipelines'; + const archive = 'x-pack/test/functional/es_archives/monitoring/logstash_pipelines'; const timeRange = { min: '2018-01-22T09:33:13.000Z', max: '2018-01-22T09:41:04.000Z', diff --git a/x-pack/test/api_integration/apis/monitoring/logstash/overview_mb.js b/x-pack/test/api_integration/apis/monitoring/logstash/overview_mb.js index 5c42ae3f87be6..0cc8deb5efa5d 100644 --- a/x-pack/test/api_integration/apis/monitoring/logstash/overview_mb.js +++ b/x-pack/test/api_integration/apis/monitoring/logstash/overview_mb.js @@ -13,7 +13,7 @@ export default function ({ getService }) { const esArchiver = getService('esArchiver'); describe('overview mb', () => { - const archive = 'monitoring/logstash_pipelines_mb'; + const archive = 'x-pack/test/functional/es_archives/monitoring/logstash_pipelines_mb'; const timeRange = { min: '2018-01-22T09:33:13.000Z', max: '2018-01-22T09:41:04.000Z', diff --git a/x-pack/test/api_integration/apis/monitoring/logstash/pipelines.js b/x-pack/test/api_integration/apis/monitoring/logstash/pipelines.js index a26fd7b091e75..7378c37a97357 100644 --- a/x-pack/test/api_integration/apis/monitoring/logstash/pipelines.js +++ b/x-pack/test/api_integration/apis/monitoring/logstash/pipelines.js @@ -13,7 +13,7 @@ export default function ({ getService }) { const esArchiver = getService('esArchiver'); describe('pipelines', () => { - const archive = 'monitoring/logstash/changing_pipelines'; + const archive = 'x-pack/test/functional/es_archives/monitoring/logstash/changing_pipelines'; const timeRange = { min: '2019-11-04T15:40:44.855Z', max: '2019-11-04T15:50:38.667Z', diff --git a/x-pack/test/api_integration/apis/monitoring/logstash/pipelines_mb.js b/x-pack/test/api_integration/apis/monitoring/logstash/pipelines_mb.js index bd576eaa9e09e..e17d31043a245 100644 --- a/x-pack/test/api_integration/apis/monitoring/logstash/pipelines_mb.js +++ b/x-pack/test/api_integration/apis/monitoring/logstash/pipelines_mb.js @@ -13,7 +13,7 @@ export default function ({ getService }) { const esArchiver = getService('esArchiver'); describe('pipelines mb', () => { - const archive = 'monitoring/logstash/changing_pipelines_mb'; + const archive = 'x-pack/test/functional/es_archives/monitoring/logstash/changing_pipelines_mb'; const timeRange = { min: '2019-11-04T15:40:44.855Z', max: '2019-11-04T15:50:38.667Z', diff --git a/x-pack/test/api_integration/apis/monitoring/setup/collection/ccs.js b/x-pack/test/api_integration/apis/monitoring/setup/collection/ccs.js index 0faa2b599b78a..2bf9d919d82be 100644 --- a/x-pack/test/api_integration/apis/monitoring/setup/collection/ccs.js +++ b/x-pack/test/api_integration/apis/monitoring/setup/collection/ccs.js @@ -10,7 +10,7 @@ export default function ({ getService }) { const esArchiver = getService('esArchiver'); describe('ccs', () => { - const archive = 'monitoring/setup/collection/detect_apm'; + const archive = 'x-pack/test/functional/es_archives/monitoring/setup/collection/detect_apm'; const timeRange = { min: '2019-04-16T00:00:00.741Z', max: '2019-04-16T23:59:59.741Z', diff --git a/x-pack/test/api_integration/apis/monitoring/setup/collection/detect_apm.js b/x-pack/test/api_integration/apis/monitoring/setup/collection/detect_apm.js index 31daa37e2ae63..744934c1b315f 100644 --- a/x-pack/test/api_integration/apis/monitoring/setup/collection/detect_apm.js +++ b/x-pack/test/api_integration/apis/monitoring/setup/collection/detect_apm.js @@ -13,7 +13,7 @@ export default function ({ getService }) { const esArchiver = getService('esArchiver'); describe('detect_apm', () => { - const archive = 'monitoring/setup/collection/detect_apm'; + const archive = 'x-pack/test/functional/es_archives/monitoring/setup/collection/detect_apm'; const timeRange = { min: '2019-04-16T00:00:00.741Z', max: '2019-04-16T23:59:59.741Z', diff --git a/x-pack/test/api_integration/apis/monitoring/setup/collection/detect_beats.js b/x-pack/test/api_integration/apis/monitoring/setup/collection/detect_beats.js index c2d63fc9ec975..542ee98f3d23d 100644 --- a/x-pack/test/api_integration/apis/monitoring/setup/collection/detect_beats.js +++ b/x-pack/test/api_integration/apis/monitoring/setup/collection/detect_beats.js @@ -13,7 +13,7 @@ export default function ({ getService }) { const esArchiver = getService('esArchiver'); describe('detect_beats', () => { - const archive = 'monitoring/setup/collection/detect_beats'; + const archive = 'x-pack/test/functional/es_archives/monitoring/setup/collection/detect_beats'; const timeRange = { min: '2019-04-09T00:00:00.741Z', max: '2019-04-09T23:59:59.741Z', diff --git a/x-pack/test/api_integration/apis/monitoring/setup/collection/detect_beats_management.js b/x-pack/test/api_integration/apis/monitoring/setup/collection/detect_beats_management.js index d8fcc60c32aa9..de805a05af13f 100644 --- a/x-pack/test/api_integration/apis/monitoring/setup/collection/detect_beats_management.js +++ b/x-pack/test/api_integration/apis/monitoring/setup/collection/detect_beats_management.js @@ -13,7 +13,8 @@ export default function ({ getService }) { const esArchiver = getService('esArchiver'); describe('detect_beats_management', () => { - const archive = 'monitoring/setup/collection/detect_beats_management'; + const archive = + 'x-pack/test/functional/es_archives/monitoring/setup/collection/detect_beats_management'; const timeRange = { min: '2019-04-16T00:00:00.741Z', max: '2019-04-16T23:59:59.741Z', diff --git a/x-pack/test/api_integration/apis/monitoring/setup/collection/detect_logstash.js b/x-pack/test/api_integration/apis/monitoring/setup/collection/detect_logstash.js index b00831da5836a..c7f33061c41c1 100644 --- a/x-pack/test/api_integration/apis/monitoring/setup/collection/detect_logstash.js +++ b/x-pack/test/api_integration/apis/monitoring/setup/collection/detect_logstash.js @@ -13,7 +13,8 @@ export default function ({ getService }) { const esArchiver = getService('esArchiver'); describe('detect_logstash', () => { - const archive = 'monitoring/setup/collection/detect_logstash'; + const archive = + 'x-pack/test/functional/es_archives/monitoring/setup/collection/detect_logstash'; const timeRange = { min: '2019-04-16T00:00:00.741Z', max: '2019-04-16T23:59:59.741Z', diff --git a/x-pack/test/api_integration/apis/monitoring/setup/collection/detect_logstash_management.js b/x-pack/test/api_integration/apis/monitoring/setup/collection/detect_logstash_management.js index e56ee7fad5a42..f85636b01dfa3 100644 --- a/x-pack/test/api_integration/apis/monitoring/setup/collection/detect_logstash_management.js +++ b/x-pack/test/api_integration/apis/monitoring/setup/collection/detect_logstash_management.js @@ -13,7 +13,8 @@ export default function ({ getService }) { const esArchiver = getService('esArchiver'); describe('detect_logstash_management', () => { - const archive = 'monitoring/setup/collection/detect_logstash_management'; + const archive = + 'x-pack/test/functional/es_archives/monitoring/setup/collection/detect_logstash_management'; const timeRange = { min: '2019-04-16T00:00:00.741Z', max: '2019-04-16T23:59:59.741Z', diff --git a/x-pack/test/api_integration/apis/monitoring/setup/collection/es_and_kibana.js b/x-pack/test/api_integration/apis/monitoring/setup/collection/es_and_kibana.js index eb13f264028ce..c6b00d77199ea 100644 --- a/x-pack/test/api_integration/apis/monitoring/setup/collection/es_and_kibana.js +++ b/x-pack/test/api_integration/apis/monitoring/setup/collection/es_and_kibana.js @@ -13,7 +13,7 @@ export default function ({ getService }) { const esArchiver = getService('esArchiver'); describe('es_and_kibana', () => { - const archive = 'monitoring/setup/collection/es_and_kibana'; + const archive = 'x-pack/test/functional/es_archives/monitoring/setup/collection/es_and_kibana'; const timeRange = { min: '2019-04-09T00:00:00.741Z', max: '2019-04-09T23:59:59.741Z', diff --git a/x-pack/test/api_integration/apis/monitoring/setup/collection/es_and_kibana_exclusive.js b/x-pack/test/api_integration/apis/monitoring/setup/collection/es_and_kibana_exclusive.js index 6b2ac002c5e57..68f5c4884d587 100644 --- a/x-pack/test/api_integration/apis/monitoring/setup/collection/es_and_kibana_exclusive.js +++ b/x-pack/test/api_integration/apis/monitoring/setup/collection/es_and_kibana_exclusive.js @@ -13,7 +13,8 @@ export default function ({ getService }) { const esArchiver = getService('esArchiver'); describe('es_and_kibana_exclusive', () => { - const archive = 'monitoring/setup/collection/es_and_kibana_exclusive'; + const archive = + 'x-pack/test/functional/es_archives/monitoring/setup/collection/es_and_kibana_exclusive'; const timeRange = { min: '2019-04-09T00:00:00.741Z', max: '2019-04-09T23:59:59.741Z', diff --git a/x-pack/test/api_integration/apis/monitoring/setup/collection/es_and_kibana_exclusive_mb.js b/x-pack/test/api_integration/apis/monitoring/setup/collection/es_and_kibana_exclusive_mb.js index 7080e7ebeb503..1945688c8eadf 100644 --- a/x-pack/test/api_integration/apis/monitoring/setup/collection/es_and_kibana_exclusive_mb.js +++ b/x-pack/test/api_integration/apis/monitoring/setup/collection/es_and_kibana_exclusive_mb.js @@ -13,7 +13,8 @@ export default function ({ getService }) { const esArchiver = getService('esArchiver'); describe('es_and_kibana_exclusive mb', () => { - const archive = 'monitoring/setup/collection/es_and_kibana_exclusive_mb'; + const archive = + 'x-pack/test/functional/es_archives/monitoring/setup/collection/es_and_kibana_exclusive_mb'; const timeRange = { min: '2019-04-09T00:00:00.741Z', max: '2019-04-09T23:59:59.741Z', diff --git a/x-pack/test/api_integration/apis/monitoring/setup/collection/es_and_kibana_mb.js b/x-pack/test/api_integration/apis/monitoring/setup/collection/es_and_kibana_mb.js index 532ef3c9de173..4f8f2148da84f 100644 --- a/x-pack/test/api_integration/apis/monitoring/setup/collection/es_and_kibana_mb.js +++ b/x-pack/test/api_integration/apis/monitoring/setup/collection/es_and_kibana_mb.js @@ -13,7 +13,8 @@ export default function ({ getService }) { const esArchiver = getService('esArchiver'); describe('es_and_kibana mb', () => { - const archive = 'monitoring/setup/collection/es_and_kibana_mb'; + const archive = + 'x-pack/test/functional/es_archives/monitoring/setup/collection/es_and_kibana_mb'; const timeRange = { min: '2019-04-09T00:00:00.741Z', max: '2019-04-09T23:59:59.741Z', diff --git a/x-pack/test/api_integration/apis/monitoring/setup/collection/kibana.js b/x-pack/test/api_integration/apis/monitoring/setup/collection/kibana.js index d48ac98521af8..bb4a66e274886 100644 --- a/x-pack/test/api_integration/apis/monitoring/setup/collection/kibana.js +++ b/x-pack/test/api_integration/apis/monitoring/setup/collection/kibana.js @@ -13,7 +13,7 @@ export default function ({ getService }) { const esArchiver = getService('esArchiver'); describe('kibana', () => { - const archive = 'monitoring/setup/collection/kibana'; + const archive = 'x-pack/test/functional/es_archives/monitoring/setup/collection/kibana'; const timeRange = { min: '2019-04-09T00:00:00.741Z', max: '2019-04-09T23:59:59.741Z', diff --git a/x-pack/test/api_integration/apis/monitoring/setup/collection/kibana_exclusive.js b/x-pack/test/api_integration/apis/monitoring/setup/collection/kibana_exclusive.js index 65cf74490088e..7fa2a76ae5567 100644 --- a/x-pack/test/api_integration/apis/monitoring/setup/collection/kibana_exclusive.js +++ b/x-pack/test/api_integration/apis/monitoring/setup/collection/kibana_exclusive.js @@ -13,7 +13,8 @@ export default function ({ getService }) { const esArchiver = getService('esArchiver'); describe('kibana_exclusive', () => { - const archive = 'monitoring/setup/collection/kibana_exclusive'; + const archive = + 'x-pack/test/functional/es_archives/monitoring/setup/collection/kibana_exclusive'; const timeRange = { min: '2019-04-09T00:00:00.741Z', max: '2019-04-09T23:59:59.741Z', diff --git a/x-pack/test/api_integration/apis/monitoring/setup/collection/kibana_exclusive_mb.js b/x-pack/test/api_integration/apis/monitoring/setup/collection/kibana_exclusive_mb.js index c86a2a4f4e7c8..37d8148a82fed 100644 --- a/x-pack/test/api_integration/apis/monitoring/setup/collection/kibana_exclusive_mb.js +++ b/x-pack/test/api_integration/apis/monitoring/setup/collection/kibana_exclusive_mb.js @@ -13,7 +13,8 @@ export default function ({ getService }) { const esArchiver = getService('esArchiver'); describe('kibana_exclusive mb', () => { - const archive = 'monitoring/setup/collection/kibana_exclusive_mb'; + const archive = + 'x-pack/test/functional/es_archives/monitoring/setup/collection/kibana_exclusive_mb'; const timeRange = { min: '2019-04-09T00:00:00.741Z', max: '2019-04-09T23:59:59.741Z', diff --git a/x-pack/test/api_integration/apis/monitoring/setup/collection/kibana_mb.js b/x-pack/test/api_integration/apis/monitoring/setup/collection/kibana_mb.js index bf4d27366c139..c36d77f9cbb6d 100644 --- a/x-pack/test/api_integration/apis/monitoring/setup/collection/kibana_mb.js +++ b/x-pack/test/api_integration/apis/monitoring/setup/collection/kibana_mb.js @@ -13,7 +13,7 @@ export default function ({ getService }) { const esArchiver = getService('esArchiver'); describe('kibana mb', () => { - const archive = 'monitoring/setup/collection/kibana_mb'; + const archive = 'x-pack/test/functional/es_archives/monitoring/setup/collection/kibana_mb'; const timeRange = { min: '2019-04-09T00:00:00.741Z', max: '2019-04-09T23:59:59.741Z', diff --git a/x-pack/test/api_integration/apis/monitoring/setup/collection/security.js b/x-pack/test/api_integration/apis/monitoring/setup/collection/security.js index 99bbcb421ba23..20f40b3a10cbe 100644 --- a/x-pack/test/api_integration/apis/monitoring/setup/collection/security.js +++ b/x-pack/test/api_integration/apis/monitoring/setup/collection/security.js @@ -14,7 +14,8 @@ export default function ({ getService }) { const supertestWithoutAuth = getService('supertestWithoutAuth'); describe('security', () => { - const archive = 'monitoring/setup/collection/kibana_exclusive'; + const archive = + 'x-pack/test/functional/es_archives/monitoring/setup/collection/kibana_exclusive'; const timeRange = { min: '2019-04-09T00:00:00.741Z', max: '2019-04-09T23:59:59.741Z', diff --git a/x-pack/test/api_integration/apis/monitoring/standalone_cluster/cluster.js b/x-pack/test/api_integration/apis/monitoring/standalone_cluster/cluster.js index 43bdfa6aeb9c7..14497675ddef0 100644 --- a/x-pack/test/api_integration/apis/monitoring/standalone_cluster/cluster.js +++ b/x-pack/test/api_integration/apis/monitoring/standalone_cluster/cluster.js @@ -13,7 +13,7 @@ export default function ({ getService }) { const esArchiver = getService('esArchiver'); describe('cluster', () => { - const archive = 'monitoring/standalone_cluster'; + const archive = 'x-pack/test/functional/es_archives/monitoring/standalone_cluster'; const timeRange = { min: '2019-02-04T16:52:11.741Z', max: '2019-02-04T17:52:11.741Z', diff --git a/x-pack/test/api_integration/apis/monitoring/standalone_cluster/clusters.js b/x-pack/test/api_integration/apis/monitoring/standalone_cluster/clusters.js index 71ebe70a69e50..3b6ccffe63998 100644 --- a/x-pack/test/api_integration/apis/monitoring/standalone_cluster/clusters.js +++ b/x-pack/test/api_integration/apis/monitoring/standalone_cluster/clusters.js @@ -16,7 +16,7 @@ export default function ({ getService }) { // TODO: https://github.com/elastic/stack-monitoring/issues/31 this.tags(['skipCloud']); - const archive = 'monitoring/standalone_cluster'; + const archive = 'x-pack/test/functional/es_archives/monitoring/standalone_cluster'; const timeRange = { min: '2019-02-04T16:52:11.741Z', max: '2019-02-04T17:52:11.741Z', diff --git a/x-pack/test/api_integration/apis/search/search.ts b/x-pack/test/api_integration/apis/search/search.ts index 05743862c9b6e..82b62a61a932d 100644 --- a/x-pack/test/api_integration/apis/search/search.ts +++ b/x-pack/test/api_integration/apis/search/search.ts @@ -185,10 +185,10 @@ export default function ({ getService }: FtrProviderContext) { describe('rollup', () => { before(async () => { - await esArchiver.load('hybrid/rollup'); + await esArchiver.load('x-pack/test/functional/es_archives/hybrid/rollup'); }); after(async () => { - await esArchiver.unload('hybrid/rollup'); + await esArchiver.unload('x-pack/test/functional/es_archives/hybrid/rollup'); }); it('should return 400 if rollup search is called without index', async () => { diff --git a/x-pack/test/api_integration/apis/security/index_fields.ts b/x-pack/test/api_integration/apis/security/index_fields.ts index c4dc288b0e060..c21f65eb488ba 100644 --- a/x-pack/test/api_integration/apis/security/index_fields.ts +++ b/x-pack/test/api_integration/apis/security/index_fields.ts @@ -15,10 +15,10 @@ export default function ({ getService }: FtrProviderContext) { describe('Index Fields', () => { before(async () => { - await esArchiver.load('security/flstest/data'); + await esArchiver.load('x-pack/test/functional/es_archives/security/flstest/data'); }); after(async () => { - await esArchiver.unload('security/flstest/data'); + await esArchiver.unload('x-pack/test/functional/es_archives/security/flstest/data'); }); describe('GET /internal/security/fields/{query}', () => { diff --git a/x-pack/test/api_integration/apis/security_solution/authentications.ts b/x-pack/test/api_integration/apis/security_solution/authentications.ts index a2e4318d93713..4ea8b8ab82e16 100644 --- a/x-pack/test/api_integration/apis/security_solution/authentications.ts +++ b/x-pack/test/api_integration/apis/security_solution/authentications.ts @@ -24,8 +24,8 @@ export default function ({ getService }: FtrProviderContext) { const supertest = getService('supertest'); describe('authentications', () => { - before(() => esArchiver.load('auditbeat/hosts')); - after(() => esArchiver.unload('auditbeat/hosts')); + before(() => esArchiver.load('x-pack/test/functional/es_archives/auditbeat/hosts')); + after(() => esArchiver.unload('x-pack/test/functional/es_archives/auditbeat/hosts')); it('Make sure that we get Authentication data', async () => { const { body: authentications } = await supertest diff --git a/x-pack/test/api_integration/apis/security_solution/events.ts b/x-pack/test/api_integration/apis/security_solution/events.ts index e5363ec57de06..2135bdafd70ec 100644 --- a/x-pack/test/api_integration/apis/security_solution/events.ts +++ b/x-pack/test/api_integration/apis/security_solution/events.ts @@ -409,8 +409,8 @@ export default function ({ getService }: FtrProviderContext) { const supertest = getService('supertest'); describe('Timeline', () => { - before(() => esArchiver.load('auditbeat/hosts')); - after(() => esArchiver.unload('auditbeat/hosts')); + before(() => esArchiver.load('x-pack/test/functional/es_archives/auditbeat/hosts')); + after(() => esArchiver.unload('x-pack/test/functional/es_archives/auditbeat/hosts')); it('Make sure that we get Timeline data', async () => { await retry.try(async () => { diff --git a/x-pack/test/api_integration/apis/security_solution/host_details.ts b/x-pack/test/api_integration/apis/security_solution/host_details.ts index ed542a24752a8..114f60a21c4e3 100644 --- a/x-pack/test/api_integration/apis/security_solution/host_details.ts +++ b/x-pack/test/api_integration/apis/security_solution/host_details.ts @@ -15,8 +15,8 @@ export default function ({ getService }: FtrProviderContext) { describe('Host Details', () => { describe('With filebeat', () => { - before(() => esArchiver.load('filebeat/default')); - after(() => esArchiver.unload('filebeat/default')); + before(() => esArchiver.load('x-pack/test/functional/es_archives/filebeat/default')); + after(() => esArchiver.unload('x-pack/test/functional/es_archives/filebeat/default')); const FROM = '2000-01-01T00:00:00.000Z'; const TO = '3000-01-01T00:00:00.000Z'; diff --git a/x-pack/test/api_integration/apis/security_solution/hosts.ts b/x-pack/test/api_integration/apis/security_solution/hosts.ts index 7ff0e54af7fbf..12b9ce138d175 100644 --- a/x-pack/test/api_integration/apis/security_solution/hosts.ts +++ b/x-pack/test/api_integration/apis/security_solution/hosts.ts @@ -28,8 +28,8 @@ export default function ({ getService }: FtrProviderContext) { const supertest = getService('supertest'); describe('hosts', () => { - before(() => esArchiver.load('auditbeat/hosts')); - after(() => esArchiver.unload('auditbeat/hosts')); + before(() => esArchiver.load('x-pack/test/functional/es_archives/auditbeat/hosts')); + after(() => esArchiver.unload('x-pack/test/functional/es_archives/auditbeat/hosts')); it('Make sure that we get Hosts Table data', async () => { const { body: hosts } = await supertest diff --git a/x-pack/test/api_integration/apis/security_solution/kpi_hosts.ts b/x-pack/test/api_integration/apis/security_solution/kpi_hosts.ts index ff395f056354e..632f738d85f36 100644 --- a/x-pack/test/api_integration/apis/security_solution/kpi_hosts.ts +++ b/x-pack/test/api_integration/apis/security_solution/kpi_hosts.ts @@ -16,8 +16,8 @@ export default function ({ getService }: FtrProviderContext) { describe('Kpi Hosts', () => { describe('With filebeat', () => { - before(() => esArchiver.load('filebeat/kpi_hosts')); - after(() => esArchiver.unload('filebeat/kpi_hosts')); + before(() => esArchiver.load('x-pack/test/functional/es_archives/filebeat/kpi_hosts')); + after(() => esArchiver.unload('x-pack/test/functional/es_archives/filebeat/kpi_hosts')); const FROM = '2000-01-01T00:00:00.000Z'; const TO = '3000-01-01T00:00:00.000Z'; @@ -130,8 +130,8 @@ export default function ({ getService }: FtrProviderContext) { }); describe('With auditbeat', () => { - before(() => esArchiver.load('auditbeat/kpi_hosts')); - after(() => esArchiver.unload('auditbeat/kpi_hosts')); + before(() => esArchiver.load('x-pack/test/functional/es_archives/auditbeat/kpi_hosts')); + after(() => esArchiver.unload('x-pack/test/functional/es_archives/auditbeat/kpi_hosts')); const FROM = '2000-01-01T00:00:00.000Z'; const TO = '3000-01-01T00:00:00.000Z'; diff --git a/x-pack/test/api_integration/apis/security_solution/kpi_network.ts b/x-pack/test/api_integration/apis/security_solution/kpi_network.ts index 69582ecc6e7c8..53b099bbe18d3 100644 --- a/x-pack/test/api_integration/apis/security_solution/kpi_network.ts +++ b/x-pack/test/api_integration/apis/security_solution/kpi_network.ts @@ -15,8 +15,8 @@ export default function ({ getService }: FtrProviderContext) { describe('Kpi Network', () => { describe('With filebeat', () => { - before(() => esArchiver.load('filebeat/default')); - after(() => esArchiver.unload('filebeat/default')); + before(() => esArchiver.load('x-pack/test/functional/es_archives/filebeat/default')); + after(() => esArchiver.unload('x-pack/test/functional/es_archives/filebeat/default')); const FROM = '2000-01-01T00:00:00.000Z'; const TO = '3000-01-01T00:00:00.000Z'; @@ -202,8 +202,8 @@ export default function ({ getService }: FtrProviderContext) { }); describe('With packetbeat', () => { - before(() => esArchiver.load('packetbeat/default')); - after(() => esArchiver.unload('packetbeat/default')); + before(() => esArchiver.load('x-pack/test/functional/es_archives/packetbeat/default')); + after(() => esArchiver.unload('x-pack/test/functional/es_archives/packetbeat/default')); const FROM = '2000-01-01T00:00:00.000Z'; const TO = '3000-01-01T00:00:00.000Z'; diff --git a/x-pack/test/api_integration/apis/security_solution/matrix_dns_histogram.ts b/x-pack/test/api_integration/apis/security_solution/matrix_dns_histogram.ts index 0fc4e5ba55988..6040ecd1001d9 100644 --- a/x-pack/test/api_integration/apis/security_solution/matrix_dns_histogram.ts +++ b/x-pack/test/api_integration/apis/security_solution/matrix_dns_histogram.ts @@ -35,8 +35,16 @@ export default function ({ getService }: FtrProviderContext) { describe('Matrix DNS Histogram', () => { describe('Large data set', () => { - before(() => esArchiver.load('security_solution/matrix_dns_histogram/large_dns_query')); - after(() => esArchiver.unload('security_solution/matrix_dns_histogram/large_dns_query')); + before(() => + esArchiver.load( + 'x-pack/test/functional/es_archives/security_solution/matrix_dns_histogram/large_dns_query' + ) + ); + after(() => + esArchiver.unload( + 'x-pack/test/functional/es_archives/security_solution/matrix_dns_histogram/large_dns_query' + ) + ); const FROM = '2000-01-01T00:00:00.000Z'; const TO = '3000-01-01T00:00:00.000Z'; diff --git a/x-pack/test/api_integration/apis/security_solution/network_details.ts b/x-pack/test/api_integration/apis/security_solution/network_details.ts index 9c53d80862edb..0397e7550c935 100644 --- a/x-pack/test/api_integration/apis/security_solution/network_details.ts +++ b/x-pack/test/api_integration/apis/security_solution/network_details.ts @@ -15,8 +15,8 @@ export default function ({ getService }: FtrProviderContext) { const supertest = getService('supertest'); describe('Network details', () => { describe('With filebeat', () => { - before(() => esArchiver.load('filebeat/default')); - after(() => esArchiver.unload('filebeat/default')); + before(() => esArchiver.load('x-pack/test/functional/es_archives/filebeat/default')); + after(() => esArchiver.unload('x-pack/test/functional/es_archives/filebeat/default')); it('Make sure that we get Network details data', async () => { const { body } = await supertest @@ -39,8 +39,8 @@ export default function ({ getService }: FtrProviderContext) { }); describe('With packetbeat', () => { - before(() => esArchiver.load('packetbeat/default')); - after(() => esArchiver.unload('packetbeat/default')); + before(() => esArchiver.load('x-pack/test/functional/es_archives/packetbeat/default')); + after(() => esArchiver.unload('x-pack/test/functional/es_archives/packetbeat/default')); it('Make sure that we get Network details data', async () => { const { body } = await supertest diff --git a/x-pack/test/api_integration/apis/security_solution/network_dns.ts b/x-pack/test/api_integration/apis/security_solution/network_dns.ts index 7f482d678be12..80660860a164b 100644 --- a/x-pack/test/api_integration/apis/security_solution/network_dns.ts +++ b/x-pack/test/api_integration/apis/security_solution/network_dns.ts @@ -21,8 +21,8 @@ export default function ({ getService }: FtrProviderContext) { describe('Network DNS', () => { describe('With packetbeat', () => { - before(() => esArchiver.load('packetbeat/dns')); - after(() => esArchiver.unload('packetbeat/dns')); + before(() => esArchiver.load('x-pack/test/functional/es_archives/packetbeat/dns')); + after(() => esArchiver.unload('x-pack/test/functional/es_archives/packetbeat/dns')); const FROM = '2000-01-01T00:00:00.000Z'; const TO = '3000-01-01T00:00:00.000Z'; diff --git a/x-pack/test/api_integration/apis/security_solution/network_top_n_flow.ts b/x-pack/test/api_integration/apis/security_solution/network_top_n_flow.ts index 69a5221be52ea..af8e543907492 100644 --- a/x-pack/test/api_integration/apis/security_solution/network_top_n_flow.ts +++ b/x-pack/test/api_integration/apis/security_solution/network_top_n_flow.ts @@ -24,8 +24,8 @@ export default function ({ getService }: FtrProviderContext) { describe('Network Top N Flow', () => { describe('With filebeat', () => { - before(() => esArchiver.load('filebeat/default')); - after(() => esArchiver.unload('filebeat/default')); + before(() => esArchiver.load('x-pack/test/functional/es_archives/filebeat/default')); + after(() => esArchiver.unload('x-pack/test/functional/es_archives/filebeat/default')); const FROM = '2019-02-09T01:57:24.870Z'; const TO = '2019-02-12T01:57:24.870Z'; diff --git a/x-pack/test/api_integration/apis/security_solution/overview_host.ts b/x-pack/test/api_integration/apis/security_solution/overview_host.ts index ddaa2d41588b7..09bd09782d2f2 100644 --- a/x-pack/test/api_integration/apis/security_solution/overview_host.ts +++ b/x-pack/test/api_integration/apis/security_solution/overview_host.ts @@ -16,8 +16,8 @@ export default function ({ getService }: FtrProviderContext) { describe('Overview Host', () => { describe('With auditbeat', () => { - before(() => esArchiver.load('auditbeat/overview')); - after(() => esArchiver.unload('auditbeat/overview')); + before(() => esArchiver.load('x-pack/test/functional/es_archives/auditbeat/overview')); + after(() => esArchiver.unload('x-pack/test/functional/es_archives/auditbeat/overview')); const FROM = '2000-01-01T00:00:00.000Z'; const TO = '3000-01-01T00:00:00.000Z'; diff --git a/x-pack/test/api_integration/apis/security_solution/overview_network.ts b/x-pack/test/api_integration/apis/security_solution/overview_network.ts index e8173eb327da9..00adc903d5733 100644 --- a/x-pack/test/api_integration/apis/security_solution/overview_network.ts +++ b/x-pack/test/api_integration/apis/security_solution/overview_network.ts @@ -15,8 +15,8 @@ export default function ({ getService }: FtrProviderContext) { describe('Overview Network', () => { describe('With filebeat', () => { - before(() => esArchiver.load('filebeat/default')); - after(() => esArchiver.unload('filebeat/default')); + before(() => esArchiver.load('x-pack/test/functional/es_archives/filebeat/default')); + after(() => esArchiver.unload('x-pack/test/functional/es_archives/filebeat/default')); const FROM = '2000-01-01T00:00:00.000Z'; const TO = '3000-01-01T00:00:00.000Z'; @@ -57,8 +57,8 @@ export default function ({ getService }: FtrProviderContext) { }); describe('With packetbeat', () => { - before(() => esArchiver.load('packetbeat/overview')); - after(() => esArchiver.unload('packetbeat/overview')); + before(() => esArchiver.load('x-pack/test/functional/es_archives/packetbeat/overview')); + after(() => esArchiver.unload('x-pack/test/functional/es_archives/packetbeat/overview')); const FROM = '2000-01-01T00:00:00.000Z'; const TO = '3000-01-01T00:00:00.000Z'; @@ -99,8 +99,8 @@ export default function ({ getService }: FtrProviderContext) { }); describe('With auditbeat', () => { - before(() => esArchiver.load('auditbeat/overview')); - after(() => esArchiver.unload('auditbeat/overview')); + before(() => esArchiver.load('x-pack/test/functional/es_archives/auditbeat/overview')); + after(() => esArchiver.unload('x-pack/test/functional/es_archives/auditbeat/overview')); const FROM = '2000-01-01T00:00:00.000Z'; const TO = '3000-01-01T00:00:00.000Z'; diff --git a/x-pack/test/api_integration/apis/security_solution/saved_objects/notes.ts b/x-pack/test/api_integration/apis/security_solution/saved_objects/notes.ts index 0d4f3a4fb9ea9..03ea91775d1bf 100644 --- a/x-pack/test/api_integration/apis/security_solution/saved_objects/notes.ts +++ b/x-pack/test/api_integration/apis/security_solution/saved_objects/notes.ts @@ -14,8 +14,8 @@ export default function ({ getService }: FtrProviderContext) { const supertest = getService('supertest'); describe('Note - Saved Objects', () => { - beforeEach(() => esArchiver.load('empty_kibana')); - afterEach(() => esArchiver.unload('empty_kibana')); + beforeEach(() => esArchiver.load('x-pack/test/functional/es_archives/empty_kibana')); + afterEach(() => esArchiver.unload('x-pack/test/functional/es_archives/empty_kibana')); describe('create a note', () => { it('should return a timelineId, timelineVersion, noteId and version', async () => { diff --git a/x-pack/test/api_integration/apis/security_solution/saved_objects/pinned_events.ts b/x-pack/test/api_integration/apis/security_solution/saved_objects/pinned_events.ts index b77c654b038c2..8391f2f9ab18a 100644 --- a/x-pack/test/api_integration/apis/security_solution/saved_objects/pinned_events.ts +++ b/x-pack/test/api_integration/apis/security_solution/saved_objects/pinned_events.ts @@ -14,8 +14,8 @@ export default function ({ getService }: FtrProviderContext) { const supertest = getService('supertest'); describe('Pinned Events - Saved Objects', () => { - beforeEach(() => esArchiver.load('empty_kibana')); - afterEach(() => esArchiver.unload('empty_kibana')); + beforeEach(() => esArchiver.load('x-pack/test/functional/es_archives/empty_kibana')); + afterEach(() => esArchiver.unload('x-pack/test/functional/es_archives/empty_kibana')); describe('Pinned an event', () => { it('return a timelineId, timelineVersion, pinnedEventId and version', async () => { diff --git a/x-pack/test/api_integration/apis/security_solution/saved_objects/timeline.ts b/x-pack/test/api_integration/apis/security_solution/saved_objects/timeline.ts index ed1d4719b9073..5bdbb76d53908 100644 --- a/x-pack/test/api_integration/apis/security_solution/saved_objects/timeline.ts +++ b/x-pack/test/api_integration/apis/security_solution/saved_objects/timeline.ts @@ -20,8 +20,8 @@ export default function ({ getService }: FtrProviderContext) { const supertest = getService('supertest'); describe('Timeline - Saved Objects', () => { - beforeEach(() => esArchiver.load('empty_kibana')); - afterEach(() => esArchiver.unload('empty_kibana')); + beforeEach(() => esArchiver.load('x-pack/test/functional/es_archives/empty_kibana')); + afterEach(() => esArchiver.unload('x-pack/test/functional/es_archives/empty_kibana')); describe('Persist a timeline', () => { it('Create a timeline just with a title', async () => { diff --git a/x-pack/test/api_integration/apis/security_solution/sources.ts b/x-pack/test/api_integration/apis/security_solution/sources.ts index d9ae88cdc7b4e..db9156a53048b 100644 --- a/x-pack/test/api_integration/apis/security_solution/sources.ts +++ b/x-pack/test/api_integration/apis/security_solution/sources.ts @@ -14,8 +14,8 @@ export default function ({ getService }: FtrProviderContext) { const supertest = getService('supertest'); describe('sources', () => { - before(() => esArchiver.load('auditbeat/default')); - after(() => esArchiver.unload('auditbeat/default')); + before(() => esArchiver.load('x-pack/test/functional/es_archives/auditbeat/default')); + after(() => esArchiver.unload('x-pack/test/functional/es_archives/auditbeat/default')); it('Make sure that we get source information when auditbeat indices is there', async () => { const { body: sourceStatus } = await supertest diff --git a/x-pack/test/api_integration/apis/security_solution/timeline_details.ts b/x-pack/test/api_integration/apis/security_solution/timeline_details.ts index 61b75931c3c14..e1eaef823d2e0 100644 --- a/x-pack/test/api_integration/apis/security_solution/timeline_details.ts +++ b/x-pack/test/api_integration/apis/security_solution/timeline_details.ts @@ -673,8 +673,8 @@ export default function ({ getService }: FtrProviderContext) { const supertest = getService('supertest'); describe('Timeline Details', () => { - before(() => esArchiver.load('filebeat/default')); - after(() => esArchiver.unload('filebeat/default')); + before(() => esArchiver.load('x-pack/test/functional/es_archives/filebeat/default')); + after(() => esArchiver.unload('x-pack/test/functional/es_archives/filebeat/default')); it('Make sure that we get Event Details data', async () => { await retry.try(async () => { diff --git a/x-pack/test/api_integration/apis/security_solution/tls.ts b/x-pack/test/api_integration/apis/security_solution/tls.ts index eadf7d2aac7ae..2308ad7a0bf34 100644 --- a/x-pack/test/api_integration/apis/security_solution/tls.ts +++ b/x-pack/test/api_integration/apis/security_solution/tls.ts @@ -86,8 +86,8 @@ export default function ({ getService }: FtrProviderContext) { describe('Tls Test with Packetbeat', () => { describe('Tls Test', () => { - before(() => esArchiver.load('packetbeat/tls')); - after(() => esArchiver.unload('packetbeat/tls')); + before(() => esArchiver.load('x-pack/test/functional/es_archives/packetbeat/tls')); + after(() => esArchiver.unload('x-pack/test/functional/es_archives/packetbeat/tls')); it('Ensure data is returned for FlowTarget.Source', async () => { const { body: tls } = await supertest @@ -153,8 +153,8 @@ export default function ({ getService }: FtrProviderContext) { }); describe('Tls Overview Test', () => { - before(() => esArchiver.load('packetbeat/tls')); - after(() => esArchiver.unload('packetbeat/tls')); + before(() => esArchiver.load('x-pack/test/functional/es_archives/packetbeat/tls')); + after(() => esArchiver.unload('x-pack/test/functional/es_archives/packetbeat/tls')); it('Ensure data is returned for FlowTarget.Source', async () => { const { body: tls } = await supertest diff --git a/x-pack/test/api_integration/apis/security_solution/uncommon_processes.ts b/x-pack/test/api_integration/apis/security_solution/uncommon_processes.ts index 1b3cd8fc34a57..d39cc0afb6461 100644 --- a/x-pack/test/api_integration/apis/security_solution/uncommon_processes.ts +++ b/x-pack/test/api_integration/apis/security_solution/uncommon_processes.ts @@ -29,8 +29,12 @@ export default function ({ getService }: FtrProviderContext) { const supertest = getService('supertest'); describe('uncommon_processes', () => { - before(() => esArchiver.load('auditbeat/uncommon_processes')); - after(() => esArchiver.unload('auditbeat/uncommon_processes')); + before(() => + esArchiver.load('x-pack/test/functional/es_archives/auditbeat/uncommon_processes') + ); + after(() => + esArchiver.unload('x-pack/test/functional/es_archives/auditbeat/uncommon_processes') + ); it('should return an edge of length 1 when given a pagination of length 1', async () => { await retry.try(async () => { diff --git a/x-pack/test/api_integration/apis/security_solution/users.ts b/x-pack/test/api_integration/apis/security_solution/users.ts index 5afb2bba745a9..84335cc2695ce 100644 --- a/x-pack/test/api_integration/apis/security_solution/users.ts +++ b/x-pack/test/api_integration/apis/security_solution/users.ts @@ -25,8 +25,8 @@ export default function ({ getService }: FtrProviderContext) { const supertest = getService('supertest'); describe('Users', () => { describe('With auditbeat', () => { - before(() => esArchiver.load('auditbeat/users')); - after(() => esArchiver.unload('auditbeat/users')); + before(() => esArchiver.load('x-pack/test/functional/es_archives/auditbeat/users')); + after(() => esArchiver.unload('x-pack/test/functional/es_archives/auditbeat/users')); it('Ensure data is returned from auditbeat', async () => { await retry.try(async () => { diff --git a/x-pack/test/api_integration/apis/telemetry/telemetry.ts b/x-pack/test/api_integration/apis/telemetry/telemetry.ts index fdf55fd6f4670..484eb3683a307 100644 --- a/x-pack/test/api_integration/apis/telemetry/telemetry.ts +++ b/x-pack/test/api_integration/apis/telemetry/telemetry.ts @@ -85,7 +85,7 @@ export default function ({ getService }: FtrProviderContext) { let localXPack: Record; let monitoring: Array>; - const archive = 'monitoring/multicluster'; + const archive = 'x-pack/test/functional/es_archives/monitoring/multicluster'; const fromTimestamp = '2017-08-15T21:00:00.000Z'; const toTimestamp = '2017-08-16T00:00:00.000Z'; @@ -134,7 +134,7 @@ export default function ({ getService }: FtrProviderContext) { }); describe('with basic cluster and reporting and canvas usage info', () => { - const archive = 'monitoring/basic_6.3.x'; + const archive = 'x-pack/test/functional/es_archives/monitoring/basic_6.3.x'; const fromTimestamp = '2018-07-23T22:54:59.087Z'; const toTimestamp = '2018-07-23T22:55:05.933Z'; before(async () => { diff --git a/x-pack/test/api_integration/apis/transform/delete_transforms.ts b/x-pack/test/api_integration/apis/transform/delete_transforms.ts index e528fc62b76dc..5dfc318571e9a 100644 --- a/x-pack/test/api_integration/apis/transform/delete_transforms.ts +++ b/x-pack/test/api_integration/apis/transform/delete_transforms.ts @@ -29,7 +29,7 @@ export default ({ getService }: FtrProviderContext) => { describe('/api/transform/delete_transforms', function () { before(async () => { - await esArchiver.loadIfNeeded('ml/farequote'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/ml/farequote'); await transform.testResources.setKibanaTimeZoneToUTC(); }); diff --git a/x-pack/test/api_integration/apis/transform/index.ts b/x-pack/test/api_integration/apis/transform/index.ts index d0aa9533c3860..351008f3f735e 100644 --- a/x-pack/test/api_integration/apis/transform/index.ts +++ b/x-pack/test/api_integration/apis/transform/index.ts @@ -23,7 +23,7 @@ export default function ({ getService, loadTestFile }: FtrProviderContext) { await transform.securityCommon.cleanTransformUsers(); await transform.securityCommon.cleanTransformRoles(); - await esArchiver.unload('ml/farequote'); + await esArchiver.unload('x-pack/test/functional/es_archives/ml/farequote'); await transform.testResources.resetKibanaTimeZone(); }); diff --git a/x-pack/test/api_integration/apis/transform/start_transforms.ts b/x-pack/test/api_integration/apis/transform/start_transforms.ts index 386d20bdc7ead..5abfa92bd5d9b 100644 --- a/x-pack/test/api_integration/apis/transform/start_transforms.ts +++ b/x-pack/test/api_integration/apis/transform/start_transforms.ts @@ -29,7 +29,7 @@ export default ({ getService }: FtrProviderContext) => { describe('/api/transform/start_transforms', function () { before(async () => { - await esArchiver.loadIfNeeded('ml/farequote'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/ml/farequote'); await transform.testResources.setKibanaTimeZoneToUTC(); }); diff --git a/x-pack/test/api_integration/apis/transform/stop_transforms.ts b/x-pack/test/api_integration/apis/transform/stop_transforms.ts index 25e54b2e74a37..295c6cea7f595 100644 --- a/x-pack/test/api_integration/apis/transform/stop_transforms.ts +++ b/x-pack/test/api_integration/apis/transform/stop_transforms.ts @@ -45,7 +45,7 @@ export default ({ getService }: FtrProviderContext) => { describe('/api/transform/stop_transforms', function () { before(async () => { - await esArchiver.loadIfNeeded('ml/farequote'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/ml/farequote'); await transform.testResources.setKibanaTimeZoneToUTC(); }); diff --git a/x-pack/test/api_integration/apis/transform/transforms.ts b/x-pack/test/api_integration/apis/transform/transforms.ts index d4fb613c55f3d..9993cbe0328ff 100644 --- a/x-pack/test/api_integration/apis/transform/transforms.ts +++ b/x-pack/test/api_integration/apis/transform/transforms.ts @@ -82,7 +82,7 @@ export default ({ getService }: FtrProviderContext) => { describe('/api/transform/transforms', function () { before(async () => { - await esArchiver.loadIfNeeded('ml/farequote'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/ml/farequote'); await transform.testResources.setKibanaTimeZoneToUTC(); await createTransform('transform-test-get-1'); await createTransform('transform-test-get-2'); diff --git a/x-pack/test/api_integration/apis/transform/transforms_create.ts b/x-pack/test/api_integration/apis/transform/transforms_create.ts index 44a6d658bf748..46112ced0619e 100644 --- a/x-pack/test/api_integration/apis/transform/transforms_create.ts +++ b/x-pack/test/api_integration/apis/transform/transforms_create.ts @@ -19,7 +19,7 @@ export default ({ getService }: FtrProviderContext) => { describe('/api/transform/transforms/{transformId}/ create', function () { before(async () => { - await esArchiver.loadIfNeeded('ml/farequote'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/ml/farequote'); await transform.testResources.setKibanaTimeZoneToUTC(); }); diff --git a/x-pack/test/api_integration/apis/transform/transforms_preview.ts b/x-pack/test/api_integration/apis/transform/transforms_preview.ts index 1acac929ef359..5fd75a6bb98ab 100644 --- a/x-pack/test/api_integration/apis/transform/transforms_preview.ts +++ b/x-pack/test/api_integration/apis/transform/transforms_preview.ts @@ -37,7 +37,7 @@ export default ({ getService }: FtrProviderContext) => { describe('/api/transform/transforms/_preview', function () { before(async () => { - await esArchiver.loadIfNeeded('ml/farequote'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/ml/farequote'); await transform.testResources.setKibanaTimeZoneToUTC(); await transform.api.waitForIndicesToExist('ft_farequote'); }); diff --git a/x-pack/test/api_integration/apis/transform/transforms_stats.ts b/x-pack/test/api_integration/apis/transform/transforms_stats.ts index 03edfe5d09a74..82a7d7efcc270 100644 --- a/x-pack/test/api_integration/apis/transform/transforms_stats.ts +++ b/x-pack/test/api_integration/apis/transform/transforms_stats.ts @@ -62,7 +62,7 @@ export default ({ getService }: FtrProviderContext) => { describe('/api/transform/transforms/_stats', function () { before(async () => { - await esArchiver.loadIfNeeded('ml/farequote'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/ml/farequote'); await transform.testResources.setKibanaTimeZoneToUTC(); await createTransform('transform-test-stats-1'); await createTransform('transform-test-stats-2'); diff --git a/x-pack/test/api_integration/apis/transform/transforms_update.ts b/x-pack/test/api_integration/apis/transform/transforms_update.ts index d9ab7cb8f9430..e5f1ce76a997b 100644 --- a/x-pack/test/api_integration/apis/transform/transforms_update.ts +++ b/x-pack/test/api_integration/apis/transform/transforms_update.ts @@ -59,7 +59,7 @@ export default ({ getService }: FtrProviderContext) => { describe('/api/transform/transforms/{transformId}/_update', function () { before(async () => { - await esArchiver.loadIfNeeded('ml/farequote'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/ml/farequote'); await transform.testResources.setKibanaTimeZoneToUTC(); await createTransform('transform-test-update-1'); }); diff --git a/x-pack/test/api_integration/apis/uptime/get_all_pings.ts b/x-pack/test/api_integration/apis/uptime/get_all_pings.ts index 18aa80bf61a9f..cf52d72823095 100644 --- a/x-pack/test/api_integration/apis/uptime/get_all_pings.ts +++ b/x-pack/test/api_integration/apis/uptime/get_all_pings.ts @@ -15,7 +15,7 @@ export default function ({ getService }: FtrProviderContext) { const esArchiver = getService('esArchiver'); describe('get_all_pings', () => { - const archive = 'uptime/pings'; + const archive = 'x-pack/test/functional/es_archives/uptime/pings'; before('load heartbeat data', async () => await esArchiver.load(archive)); after('unload heartbeat data', async () => await esArchiver.unload(archive)); diff --git a/x-pack/test/api_integration/apis/uptime/rest/certs.ts b/x-pack/test/api_integration/apis/uptime/rest/certs.ts index d7c0a4eed4a72..c9c8efe3f3a11 100644 --- a/x-pack/test/api_integration/apis/uptime/rest/certs.ts +++ b/x-pack/test/api_integration/apis/uptime/rest/certs.ts @@ -63,7 +63,7 @@ export default function ({ getService }: FtrProviderContext) { ); }); after('unload test docs', () => { - esArchiver.unload('uptime/blank'); + esArchiver.unload('x-pack/test/functional/es_archives/uptime/blank'); }); it('retrieves expected cert data', async () => { diff --git a/x-pack/test/api_integration/apis/uptime/rest/index.ts b/x-pack/test/api_integration/apis/uptime/rest/index.ts index 9f90d3739797b..ded9d1392231a 100644 --- a/x-pack/test/api_integration/apis/uptime/rest/index.ts +++ b/x-pack/test/api_integration/apis/uptime/rest/index.ts @@ -39,12 +39,14 @@ export default function ({ getService, loadTestFile }: FtrProviderContext) { describe('with generated data', () => { beforeEach('load heartbeat data', async () => { - await esArchiver.loadIfNeeded('uptime/blank'); - await esArchiver.loadIfNeeded('uptime/blank_data_stream'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/uptime/blank'); + await esArchiver.loadIfNeeded( + 'x-pack/test/functional/es_archives/uptime/blank_data_stream' + ); }); after('unload', async () => { - await esArchiver.unload('uptime/blank'); - await esArchiver.unload('uptime/blank_data_stream'); + await esArchiver.unload('x-pack/test/functional/es_archives/uptime/blank'); + await esArchiver.unload('x-pack/test/functional/es_archives/uptime/blank_data_stream'); }); loadTestFile(require.resolve('./certs')); @@ -56,8 +58,16 @@ export default function ({ getService, loadTestFile }: FtrProviderContext) { }); describe('with real-world data', () => { - beforeEach('load heartbeat data', async () => await esArchiver.load('uptime/full_heartbeat')); - afterEach('unload', async () => await esArchiver.unload('uptime/full_heartbeat')); + beforeEach( + 'load heartbeat data', + async () => + await esArchiver.load('x-pack/test/functional/es_archives/uptime/full_heartbeat') + ); + afterEach( + 'unload', + async () => + await esArchiver.unload('x-pack/test/functional/es_archives/uptime/full_heartbeat') + ); loadTestFile(require.resolve('./monitor_latest_status')); loadTestFile(require.resolve('./ping_histogram')); loadTestFile(require.resolve('./ping_list')); diff --git a/x-pack/test/api_integration/apis/uptime/rest/monitor_states_generated.ts b/x-pack/test/api_integration/apis/uptime/rest/monitor_states_generated.ts index 5268a2146d123..05e79d91ddc3a 100644 --- a/x-pack/test/api_integration/apis/uptime/rest/monitor_states_generated.ts +++ b/x-pack/test/api_integration/apis/uptime/rest/monitor_states_generated.ts @@ -24,8 +24,12 @@ export default function ({ getService }: FtrProviderContext) { const getBaseUrl = (from: string, to: string) => `${API_URLS.MONITOR_LIST}?dateRangeStart=${from}&dateRangeEnd=${to}&pageSize=10`; - before('load heartbeat data', () => getService('esArchiver').load('uptime/blank')); - after('unload heartbeat index', () => getService('esArchiver').unload('uptime/blank')); + before('load heartbeat data', () => + getService('esArchiver').load('x-pack/test/functional/es_archives/uptime/blank') + ); + after('unload heartbeat index', () => + getService('esArchiver').unload('x-pack/test/functional/es_archives/uptime/blank') + ); // In this case we don't actually have any monitors to display // but the query should still return successfully. This has @@ -139,7 +143,7 @@ export default function ({ getService }: FtrProviderContext) { const downMonitorId = 'down-test-id'; const mixMonitorId = 'mix-test-id'; before('generate three monitors with up, down, mix state', async () => { - await getService('esArchiver').load('uptime/blank'); + await getService('esArchiver').load('x-pack/test/functional/es_archives/uptime/blank'); const es = getService('es'); @@ -169,7 +173,9 @@ export default function ({ getService }: FtrProviderContext) { dateRangeEnd = new Date().toISOString(); }); - after('unload heartbeat index', () => getService('esArchiver').unload('uptime/blank')); + after('unload heartbeat index', () => + getService('esArchiver').unload('x-pack/test/functional/es_archives/uptime/blank') + ); it('should return all monitor when no status filter', async () => { const apiResponse = await supertest.get(getBaseUrl(dateRangeStart, dateRangeEnd)); diff --git a/x-pack/test/api_integration/apis/uptime/rest/ping_list.ts b/x-pack/test/api_integration/apis/uptime/rest/ping_list.ts index e7f60ed8e522b..860aae81703f4 100644 --- a/x-pack/test/api_integration/apis/uptime/rest/ping_list.ts +++ b/x-pack/test/api_integration/apis/uptime/rest/ping_list.ts @@ -22,8 +22,12 @@ function decodePingsResponseData(response: any) { export default function ({ getService }: FtrProviderContext) { const supertest = getService('supertest'); describe('pingList query', () => { - before('load heartbeat data', () => getService('esArchiver').load('uptime/full_heartbeat')); - after('unload heartbeat index', () => getService('esArchiver').unload('uptime/full_heartbeat')); + before('load heartbeat data', () => + getService('esArchiver').load('x-pack/test/functional/es_archives/uptime/full_heartbeat') + ); + after('unload heartbeat index', () => + getService('esArchiver').unload('x-pack/test/functional/es_archives/uptime/full_heartbeat') + ); it('returns a list of pings for the given date range and default size', async () => { const from = '2019-01-28T17:40:08.078Z'; diff --git a/x-pack/test/api_integration/apis/uptime/rest/telemetry_collectors.ts b/x-pack/test/api_integration/apis/uptime/rest/telemetry_collectors.ts index fd8894d7e9164..8e80208b3d805 100644 --- a/x-pack/test/api_integration/apis/uptime/rest/telemetry_collectors.ts +++ b/x-pack/test/api_integration/apis/uptime/rest/telemetry_collectors.ts @@ -16,7 +16,7 @@ export default function ({ getService }: FtrProviderContext) { describe('telemetry collectors heartbeat', () => { before('generating data', async () => { - await getService('esArchiver').load('uptime/blank'); + await getService('esArchiver').load('x-pack/test/functional/es_archives/uptime/blank'); const observer = { geo: { @@ -83,7 +83,7 @@ export default function ({ getService }: FtrProviderContext) { }); after('unload heartbeat index', () => { - getService('esArchiver').unload('uptime/blank'); + getService('esArchiver').unload('x-pack/test/functional/es_archives/uptime/blank'); }); beforeEach(async () => { diff --git a/x-pack/test/api_integration/apis/uptime/rest/telemetry_collectors_fleet.ts b/x-pack/test/api_integration/apis/uptime/rest/telemetry_collectors_fleet.ts index 8c462f1db431b..df741fe56381e 100644 --- a/x-pack/test/api_integration/apis/uptime/rest/telemetry_collectors_fleet.ts +++ b/x-pack/test/api_integration/apis/uptime/rest/telemetry_collectors_fleet.ts @@ -17,7 +17,9 @@ export default function ({ getService }: FtrProviderContext) { describe('telemetry collectors fleet', () => { before('generating data', async () => { - await getService('esArchiver').load('uptime/blank_data_stream'); + await getService('esArchiver').load( + 'x-pack/test/functional/es_archives/uptime/blank_data_stream' + ); const observer = { geo: { @@ -123,7 +125,9 @@ export default function ({ getService }: FtrProviderContext) { }); after('unload heartbeat index', () => { - getService('esArchiver').unload('uptime/blank_data_stream'); + getService('esArchiver').unload( + 'x-pack/test/functional/es_archives/uptime/blank_data_stream' + ); /** * Data streams aren't included in the javascript elasticsearch client in kibana yet so we * need to do raw requests here. Delete a data stream is slightly different than that of a regular index which diff --git a/x-pack/test/api_integration/apis/xpack_legacy/settings/settings.js b/x-pack/test/api_integration/apis/xpack_legacy/settings/settings.js index c1c686e891a09..6a82c5468a2c4 100644 --- a/x-pack/test/api_integration/apis/xpack_legacy/settings/settings.js +++ b/x-pack/test/api_integration/apis/xpack_legacy/settings/settings.js @@ -13,7 +13,7 @@ export default function ({ getService }) { describe('/api/settings', () => { describe('with trial license clusters', () => { - const archive = 'monitoring/multicluster'; + const archive = 'x-pack/test/functional/es_archives/monitoring/multicluster'; before('load clusters archive', () => { return esArchiver.load(archive); diff --git a/x-pack/test/api_integration/config.ts b/x-pack/test/api_integration/config.ts index 5c998a4322480..6708a6d55f402 100644 --- a/x-pack/test/api_integration/config.ts +++ b/x-pack/test/api_integration/config.ts @@ -18,7 +18,6 @@ export async function getApiIntegrationConfig({ readConfigFile }: FtrConfigProvi services, servers: xPackFunctionalTestsConfig.get('servers'), security: xPackFunctionalTestsConfig.get('security'), - esArchiver: xPackFunctionalTestsConfig.get('esArchiver'), junit: { reportName: 'X-Pack API Integration Tests', }, diff --git a/x-pack/test/api_integration_basic/apis/ml/index.ts b/x-pack/test/api_integration_basic/apis/ml/index.ts index 73322b21ec3a6..5ca70103f41eb 100644 --- a/x-pack/test/api_integration_basic/apis/ml/index.ts +++ b/x-pack/test/api_integration_basic/apis/ml/index.ts @@ -25,7 +25,7 @@ export default function ({ getService, loadTestFile }: FtrProviderContext) { await ml.testResources.deleteIndexPatternByTitle('ft_farequote'); - await esArchiver.unload('ml/farequote'); + await esArchiver.unload('x-pack/test/functional/es_archives/ml/farequote'); await ml.testResources.resetKibanaTimeZone(); }); diff --git a/x-pack/test/apm_api_integration/common/config.ts b/x-pack/test/apm_api_integration/common/config.ts index 68a0c6b4e9f1c..ef8d4097f21c1 100644 --- a/x-pack/test/apm_api_integration/common/config.ts +++ b/x-pack/test/apm_api_integration/common/config.ts @@ -8,7 +8,6 @@ import { FtrConfigProviderContext } from '@kbn/test'; import supertest from 'supertest'; import { format, UrlObject } from 'url'; -import path from 'path'; import { InheritedFtrProviderContext, InheritedServices } from './ftr_provider_context'; import { PromiseReturnType } from '../../../plugins/observability/typings/common'; import { createApmUser, APM_TEST_PASSWORD, ApmUser } from './authentication'; @@ -55,9 +54,6 @@ export function createTestConfig(config: Config) { return { testFiles: [require.resolve('../tests')], servers, - esArchiver: { - directory: path.resolve(__dirname, './fixtures/es_archiver'), - }, services: { ...services, supertest: supertestAsApmReadUser, diff --git a/x-pack/test/apm_api_integration/common/registry.ts b/x-pack/test/apm_api_integration/common/registry.ts index f27b40903efea..ae55328d63bd2 100644 --- a/x-pack/test/apm_api_integration/common/registry.ts +++ b/x-pack/test/apm_api_integration/common/registry.ts @@ -5,6 +5,7 @@ * 2.0. */ +import Path from 'path'; import { castArray, groupBy } from 'lodash'; import callsites from 'callsites'; import { maybe } from '../../../plugins/apm/common/utils/maybe'; @@ -140,7 +141,12 @@ export const registry = { const log = logWithTimer(); for (const archiveName of condition.archives) { log(`Loading ${archiveName}`); - await esArchiver.load(archiveName); + await esArchiver.load( + Path.join( + 'x-pack/test/apm_api_integration/common/fixtures/es_archiver', + archiveName + ) + ); } if (condition.archives.length) { log('Loaded all archives'); @@ -151,7 +157,12 @@ export const registry = { const log = logWithTimer(); for (const archiveName of condition.archives) { log(`Unloading ${archiveName}`); - await esArchiver.unload(archiveName); + await esArchiver.unload( + Path.join( + 'x-pack/test/apm_api_integration/common/fixtures/es_archiver', + archiveName + ) + ); } if (condition.archives.length) { log('Unloaded all archives'); diff --git a/x-pack/test/banners_functional/config.ts b/x-pack/test/banners_functional/config.ts index a4b2867b8d7ce..c9acff91aecd1 100644 --- a/x-pack/test/banners_functional/config.ts +++ b/x-pack/test/banners_functional/config.ts @@ -5,7 +5,6 @@ * 2.0. */ -import path from 'path'; import { FtrConfigProviderContext } from '@kbn/test'; import { services, pageObjects } from './ftr_provider_context'; @@ -29,10 +28,6 @@ export default async function ({ readConfigFile }: FtrConfigProviderContext) { ...kibanaFunctionalConfig.get('apps'), }, - esArchiver: { - directory: path.resolve(__dirname, '..', 'functional', 'es_archives'), - }, - kbnTestServer: { ...kibanaFunctionalConfig.get('kbnTestServer'), serverArgs: [ diff --git a/x-pack/test/banners_functional/tests/spaces.ts b/x-pack/test/banners_functional/tests/spaces.ts index f8c412c0df0e3..f6e2fbf544557 100644 --- a/x-pack/test/banners_functional/tests/spaces.ts +++ b/x-pack/test/banners_functional/tests/spaces.ts @@ -20,11 +20,11 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { describe('per-spaces banners', () => { before(async () => { - await esArchiver.load('banners/multispace'); + await esArchiver.load('x-pack/test/functional/es_archives/banners/multispace'); }); after(async () => { - await esArchiver.unload('banners/multispace'); + await esArchiver.unload('x-pack/test/functional/es_archives/banners/multispace'); }); before(async () => { diff --git a/x-pack/test/case_api_integration/common/config.ts b/x-pack/test/case_api_integration/common/config.ts index fef5478264fea..6c81f1fcfa264 100644 --- a/x-pack/test/case_api_integration/common/config.ts +++ b/x-pack/test/case_api_integration/common/config.ts @@ -99,7 +99,6 @@ export function createTestConfig(name: string, options: CreateTestConfigOptions) junit: { reportName: 'X-Pack Case API Integration Tests', }, - esArchiver: xPackApiIntegrationTestsConfig.get('esArchiver'), esTestCluster: { ...xPackApiIntegrationTestsConfig.get('esTestCluster'), license, diff --git a/x-pack/test/case_api_integration/security_and_spaces/tests/common/cases/migrations.ts b/x-pack/test/case_api_integration/security_and_spaces/tests/common/cases/migrations.ts index 42fcace768b15..8d158cc1c4f70 100644 --- a/x-pack/test/case_api_integration/security_and_spaces/tests/common/cases/migrations.ts +++ b/x-pack/test/case_api_integration/security_and_spaces/tests/common/cases/migrations.ts @@ -18,11 +18,11 @@ export default function createGetTests({ getService }: FtrProviderContext) { // tests upgrading a 7.10.0 saved object to the latest version describe('7.10.0 -> latest stack version', () => { before(async () => { - await esArchiver.load('cases/migrations/7.10.0'); + await esArchiver.load('x-pack/test/functional/es_archives/cases/migrations/7.10.0'); }); after(async () => { - await esArchiver.unload('cases/migrations/7.10.0'); + await esArchiver.unload('x-pack/test/functional/es_archives/cases/migrations/7.10.0'); }); it('migrates cases connector', async () => { @@ -59,11 +59,11 @@ export default function createGetTests({ getService }: FtrProviderContext) { // tests upgrading a 7.11.1 saved object to the latest version describe('7.11.1 -> latest stack version', () => { before(async () => { - await esArchiver.load('cases/migrations/7.11.1'); + await esArchiver.load('x-pack/test/functional/es_archives/cases/migrations/7.11.1'); }); after(async () => { - await esArchiver.unload('cases/migrations/7.11.1'); + await esArchiver.unload('x-pack/test/functional/es_archives/cases/migrations/7.11.1'); }); it('adds rule info to only alert comments for 7.12', async () => { diff --git a/x-pack/test/case_api_integration/security_and_spaces/tests/common/cases/patch_cases.ts b/x-pack/test/case_api_integration/security_and_spaces/tests/common/cases/patch_cases.ts index 286e08716ebf1..80432f15f70a9 100644 --- a/x-pack/test/case_api_integration/security_and_spaces/tests/common/cases/patch_cases.ts +++ b/x-pack/test/case_api_integration/security_and_spaces/tests/common/cases/patch_cases.ts @@ -507,10 +507,10 @@ export default ({ getService }: FtrProviderContext): void => { const defaultSignalsIndex = '.siem-signals-default-000001'; beforeEach(async () => { - await esArchiver.load('cases/signals/default'); + await esArchiver.load('x-pack/test/functional/es_archives/cases/signals/default'); }); afterEach(async () => { - await esArchiver.unload('cases/signals/default'); + await esArchiver.unload('x-pack/test/functional/es_archives/cases/signals/default'); await deleteAllCaseItems(es); }); @@ -642,10 +642,10 @@ export default ({ getService }: FtrProviderContext): void => { const defaultSignalsIndex = '.siem-signals-default-000001'; beforeEach(async () => { - await esArchiver.load('cases/signals/duplicate_ids'); + await esArchiver.load('x-pack/test/functional/es_archives/cases/signals/duplicate_ids'); }); afterEach(async () => { - await esArchiver.unload('cases/signals/duplicate_ids'); + await esArchiver.unload('x-pack/test/functional/es_archives/cases/signals/duplicate_ids'); await deleteAllCaseItems(es); }); @@ -765,14 +765,14 @@ export default ({ getService }: FtrProviderContext): void => { describe('detections rule', () => { beforeEach(async () => { - await esArchiver.load('auditbeat/hosts'); + await esArchiver.load('x-pack/test/functional/es_archives/auditbeat/hosts'); await createSignalsIndex(supertest); }); afterEach(async () => { await deleteSignalsIndex(supertest); await deleteAllAlerts(supertest); - await esArchiver.unload('auditbeat/hosts'); + await esArchiver.unload('x-pack/test/functional/es_archives/auditbeat/hosts'); }); it('updates alert status when the status is updated and syncAlerts=true', async () => { diff --git a/x-pack/test/case_api_integration/security_and_spaces/tests/common/client/update_alert_status.ts b/x-pack/test/case_api_integration/security_and_spaces/tests/common/client/update_alert_status.ts index 44284c0aec639..15df0f0b40d0f 100644 --- a/x-pack/test/case_api_integration/security_and_spaces/tests/common/client/update_alert_status.ts +++ b/x-pack/test/case_api_integration/security_and_spaces/tests/common/client/update_alert_status.ts @@ -27,10 +27,10 @@ export default ({ getService }: FtrProviderContext): void => { const defaultSignalsIndex = '.siem-signals-default-000001'; beforeEach(async () => { - await esArchiver.load('cases/signals/default'); + await esArchiver.load('x-pack/test/functional/es_archives/cases/signals/default'); }); afterEach(async () => { - await esArchiver.unload('cases/signals/default'); + await esArchiver.unload('x-pack/test/functional/es_archives/cases/signals/default'); await deleteAllCaseItems(es); }); diff --git a/x-pack/test/case_api_integration/security_and_spaces/tests/common/comments/migrations.ts b/x-pack/test/case_api_integration/security_and_spaces/tests/common/comments/migrations.ts index 50a219c5e84b3..357373e7805ee 100644 --- a/x-pack/test/case_api_integration/security_and_spaces/tests/common/comments/migrations.ts +++ b/x-pack/test/case_api_integration/security_and_spaces/tests/common/comments/migrations.ts @@ -16,11 +16,11 @@ export default function createGetTests({ getService }: FtrProviderContext) { describe('migrations', () => { before(async () => { - await esArchiver.load('cases/migrations/7.10.0'); + await esArchiver.load('x-pack/test/functional/es_archives/cases/migrations/7.10.0'); }); after(async () => { - await esArchiver.unload('cases/migrations/7.10.0'); + await esArchiver.unload('x-pack/test/functional/es_archives/cases/migrations/7.10.0'); }); it('7.11.0 migrates cases comments', async () => { diff --git a/x-pack/test/case_api_integration/security_and_spaces/tests/common/comments/post_comment.ts b/x-pack/test/case_api_integration/security_and_spaces/tests/common/comments/post_comment.ts index a1f24de1b87da..e30e276c7b717 100644 --- a/x-pack/test/case_api_integration/security_and_spaces/tests/common/comments/post_comment.ts +++ b/x-pack/test/case_api_integration/security_and_spaces/tests/common/comments/post_comment.ts @@ -335,14 +335,14 @@ export default ({ getService }: FtrProviderContext): void => { describe('alerts', () => { beforeEach(async () => { - await esArchiver.load('auditbeat/hosts'); + await esArchiver.load('x-pack/test/functional/es_archives/auditbeat/hosts'); await createSignalsIndex(supertest); }); afterEach(async () => { await deleteSignalsIndex(supertest); await deleteAllAlerts(supertest); - await esArchiver.unload('auditbeat/hosts'); + await esArchiver.unload('x-pack/test/functional/es_archives/auditbeat/hosts'); }); it('should change the status of the alert if sync alert is on', async () => { diff --git a/x-pack/test/case_api_integration/security_and_spaces/tests/common/configure/migrations.ts b/x-pack/test/case_api_integration/security_and_spaces/tests/common/configure/migrations.ts index cc2f6c414503d..c6d892e3435f1 100644 --- a/x-pack/test/case_api_integration/security_and_spaces/tests/common/configure/migrations.ts +++ b/x-pack/test/case_api_integration/security_and_spaces/tests/common/configure/migrations.ts @@ -16,11 +16,11 @@ export default function createGetTests({ getService }: FtrProviderContext) { describe('migrations', () => { before(async () => { - await esArchiver.load('cases/migrations/7.10.0'); + await esArchiver.load('x-pack/test/functional/es_archives/cases/migrations/7.10.0'); }); after(async () => { - await esArchiver.unload('cases/migrations/7.10.0'); + await esArchiver.unload('x-pack/test/functional/es_archives/cases/migrations/7.10.0'); }); it('7.10.0 migrates configure cases connector', async () => { diff --git a/x-pack/test/case_api_integration/security_and_spaces/tests/common/connectors/case.ts b/x-pack/test/case_api_integration/security_and_spaces/tests/common/connectors/case.ts index fd9ec8142b49f..41d8cc12aaaab 100644 --- a/x-pack/test/case_api_integration/security_and_spaces/tests/common/connectors/case.ts +++ b/x-pack/test/case_api_integration/security_and_spaces/tests/common/connectors/case.ts @@ -707,14 +707,14 @@ export default ({ getService }: FtrProviderContext): void => { describe('adding alerts using a connector', () => { beforeEach(async () => { - await esArchiver.load('auditbeat/hosts'); + await esArchiver.load('x-pack/test/functional/es_archives/auditbeat/hosts'); await createSignalsIndex(supertest); }); afterEach(async () => { await deleteSignalsIndex(supertest); await deleteAllAlerts(supertest); - await esArchiver.unload('auditbeat/hosts'); + await esArchiver.unload('x-pack/test/functional/es_archives/auditbeat/hosts'); }); it('should add a comment of type alert', async () => { diff --git a/x-pack/test/case_api_integration/security_and_spaces/tests/common/sub_cases/patch_sub_cases.ts b/x-pack/test/case_api_integration/security_and_spaces/tests/common/sub_cases/patch_sub_cases.ts index 442644463fa38..45fada30ab567 100644 --- a/x-pack/test/case_api_integration/security_and_spaces/tests/common/sub_cases/patch_sub_cases.ts +++ b/x-pack/test/case_api_integration/security_and_spaces/tests/common/sub_cases/patch_sub_cases.ts @@ -56,10 +56,10 @@ export default function ({ getService }: FtrProviderContext) { await deleteCaseAction(supertest, actionID); }); beforeEach(async () => { - await esArchiver.load('cases/signals/default'); + await esArchiver.load('x-pack/test/functional/es_archives/cases/signals/default'); }); afterEach(async () => { - await esArchiver.unload('cases/signals/default'); + await esArchiver.unload('x-pack/test/functional/es_archives/cases/signals/default'); await deleteAllCaseItems(es); }); diff --git a/x-pack/test/case_api_integration/security_and_spaces/tests/common/user_actions/migrations.ts b/x-pack/test/case_api_integration/security_and_spaces/tests/common/user_actions/migrations.ts index e198260e88a9c..030441028c502 100644 --- a/x-pack/test/case_api_integration/security_and_spaces/tests/common/user_actions/migrations.ts +++ b/x-pack/test/case_api_integration/security_and_spaces/tests/common/user_actions/migrations.ts @@ -16,11 +16,11 @@ export default function createGetTests({ getService }: FtrProviderContext) { describe('migrations', () => { before(async () => { - await esArchiver.load('cases/migrations/7.10.0'); + await esArchiver.load('x-pack/test/functional/es_archives/cases/migrations/7.10.0'); }); after(async () => { - await esArchiver.unload('cases/migrations/7.10.0'); + await esArchiver.unload('x-pack/test/functional/es_archives/cases/migrations/7.10.0'); }); it('7.10.0 migrates user actions connector', async () => { diff --git a/x-pack/test/detection_engine_api_integration/basic/tests/create_rules.ts b/x-pack/test/detection_engine_api_integration/basic/tests/create_rules.ts index 59366c4d5e477..9c79c19b6ad70 100644 --- a/x-pack/test/detection_engine_api_integration/basic/tests/create_rules.ts +++ b/x-pack/test/detection_engine_api_integration/basic/tests/create_rules.ts @@ -48,13 +48,13 @@ export default ({ getService }: FtrProviderContext) => { describe('creating rules', () => { beforeEach(async () => { await createSignalsIndex(supertest); - await esArchiver.load('auditbeat/hosts'); + await esArchiver.load('x-pack/test/functional/es_archives/auditbeat/hosts'); }); afterEach(async () => { await deleteSignalsIndex(supertest); await deleteAllAlerts(supertest); - await esArchiver.unload('auditbeat/hosts'); + await esArchiver.unload('x-pack/test/functional/es_archives/auditbeat/hosts'); }); it('should create a single rule with a rule_id', async () => { diff --git a/x-pack/test/detection_engine_api_integration/basic/tests/create_rules_bulk.ts b/x-pack/test/detection_engine_api_integration/basic/tests/create_rules_bulk.ts index 7add76b97ed0b..759c9b25dc1e8 100644 --- a/x-pack/test/detection_engine_api_integration/basic/tests/create_rules_bulk.ts +++ b/x-pack/test/detection_engine_api_integration/basic/tests/create_rules_bulk.ts @@ -51,13 +51,13 @@ export default ({ getService }: FtrProviderContext): void => { describe('creating rules in bulk', () => { beforeEach(async () => { await createSignalsIndex(supertest); - await esArchiver.load('auditbeat/hosts'); + await esArchiver.load('x-pack/test/functional/es_archives/auditbeat/hosts'); }); afterEach(async () => { await deleteSignalsIndex(supertest); await deleteAllAlerts(supertest); - await esArchiver.unload('auditbeat/hosts'); + await esArchiver.unload('x-pack/test/functional/es_archives/auditbeat/hosts'); }); it('should create a single rule with a rule_id', async () => { diff --git a/x-pack/test/detection_engine_api_integration/basic/tests/find_statuses.ts b/x-pack/test/detection_engine_api_integration/basic/tests/find_statuses.ts index 1a64b21d869c5..a5e96271d923f 100644 --- a/x-pack/test/detection_engine_api_integration/basic/tests/find_statuses.ts +++ b/x-pack/test/detection_engine_api_integration/basic/tests/find_statuses.ts @@ -28,14 +28,14 @@ export default ({ getService }: FtrProviderContext): void => { describe('find_statuses', () => { beforeEach(async () => { await createSignalsIndex(supertest); - await esArchiver.load('auditbeat/hosts'); + await esArchiver.load('x-pack/test/functional/es_archives/auditbeat/hosts'); }); afterEach(async () => { await deleteSignalsIndex(supertest); await deleteAllAlerts(supertest); await deleteAllRulesStatuses(es); - await esArchiver.unload('auditbeat/hosts'); + await esArchiver.unload('x-pack/test/functional/es_archives/auditbeat/hosts'); }); it('should return an empty find statuses body correctly if no statuses are loaded', async () => { diff --git a/x-pack/test/detection_engine_api_integration/basic/tests/open_close_signals.ts b/x-pack/test/detection_engine_api_integration/basic/tests/open_close_signals.ts index 3c52e779666f6..8c6a698f88109 100644 --- a/x-pack/test/detection_engine_api_integration/basic/tests/open_close_signals.ts +++ b/x-pack/test/detection_engine_api_integration/basic/tests/open_close_signals.ts @@ -69,12 +69,12 @@ export default ({ getService }: FtrProviderContext) => { beforeEach(async () => { await deleteAllAlerts(supertest); await createSignalsIndex(supertest); - await esArchiver.load('auditbeat/hosts'); + await esArchiver.load('x-pack/test/functional/es_archives/auditbeat/hosts'); }); afterEach(async () => { await deleteSignalsIndex(supertest); await deleteAllAlerts(supertest); - await esArchiver.unload('auditbeat/hosts'); + await esArchiver.unload('x-pack/test/functional/es_archives/auditbeat/hosts'); }); it('should be able to execute and get 10 signals', async () => { diff --git a/x-pack/test/detection_engine_api_integration/common/config.ts b/x-pack/test/detection_engine_api_integration/common/config.ts index 659c836eb9207..5cbf9598dc4a1 100644 --- a/x-pack/test/detection_engine_api_integration/common/config.ts +++ b/x-pack/test/detection_engine_api_integration/common/config.ts @@ -53,7 +53,6 @@ export function createTestConfig(name: string, options: CreateTestConfigOptions) junit: { reportName: 'X-Pack Detection Engine API Integration Tests', }, - esArchiver: xPackApiIntegrationTestsConfig.get('esArchiver'), esTestCluster: { ...xPackApiIntegrationTestsConfig.get('esTestCluster'), license, diff --git a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/add_actions.ts b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/add_actions.ts index 9d086717f4753..8b31877e11bbe 100644 --- a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/add_actions.ts +++ b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/add_actions.ts @@ -30,14 +30,14 @@ export default ({ getService }: FtrProviderContext) => { describe('add_actions', () => { describe('adding actions', () => { beforeEach(async () => { - await esArchiver.load('auditbeat/hosts'); + await esArchiver.load('x-pack/test/functional/es_archives/auditbeat/hosts'); await createSignalsIndex(supertest); }); afterEach(async () => { await deleteSignalsIndex(supertest); await deleteAllAlerts(supertest); - await esArchiver.unload('auditbeat/hosts'); + await esArchiver.unload('x-pack/test/functional/es_archives/auditbeat/hosts'); }); it('should be able to create a new webhook action and attach it to a rule', async () => { diff --git a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/aliases.ts b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/aliases.ts index d21253199d733..3a6c9f96b7e88 100644 --- a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/aliases.ts +++ b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/aliases.ts @@ -30,13 +30,13 @@ export default ({ getService }: FtrProviderContext) => { describe('Tests involving aliases of source indexes and the signals index', () => { beforeEach(async () => { await createSignalsIndex(supertest); - await esArchiver.load('security_solution/alias'); + await esArchiver.load('x-pack/test/functional/es_archives/security_solution/alias'); }); afterEach(async () => { await deleteSignalsIndex(supertest); await deleteAllAlerts(supertest); - await esArchiver.unload('security_solution/alias'); + await esArchiver.unload('x-pack/test/functional/es_archives/security_solution/alias'); }); it('Should keep the original alias value such as "host_alias" from a source index when the value is indexed', async () => { diff --git a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/create_exceptions.ts b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/create_exceptions.ts index 6a14de3c47608..05b097cc87b61 100644 --- a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/create_exceptions.ts +++ b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/create_exceptions.ts @@ -65,14 +65,14 @@ export default ({ getService }: FtrProviderContext) => { describe('creating rules with exceptions', () => { beforeEach(async () => { await createSignalsIndex(supertest); - await esArchiver.load('auditbeat/hosts'); + await esArchiver.load('x-pack/test/functional/es_archives/auditbeat/hosts'); }); afterEach(async () => { await deleteSignalsIndex(supertest); await deleteAllAlerts(supertest); await deleteAllExceptions(es); - await esArchiver.unload('auditbeat/hosts'); + await esArchiver.unload('x-pack/test/functional/es_archives/auditbeat/hosts'); }); describe('elastic admin', () => { @@ -530,14 +530,14 @@ export default ({ getService }: FtrProviderContext) => { describe('tests with auditbeat data', () => { beforeEach(async () => { await createSignalsIndex(supertest); - await esArchiver.load('auditbeat/hosts'); + await esArchiver.load('x-pack/test/functional/es_archives/auditbeat/hosts'); }); afterEach(async () => { await deleteSignalsIndex(supertest); await deleteAllAlerts(supertest); await deleteAllExceptions(es); - await esArchiver.unload('auditbeat/hosts'); + await esArchiver.unload('x-pack/test/functional/es_archives/auditbeat/hosts'); }); it('should be able to execute against an exception list that does not include valid entries and get back 10 signals', async () => { diff --git a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/create_ml.ts b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/create_ml.ts index 9e7fb0ea7c84b..491f7bb9c417e 100644 --- a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/create_ml.ts +++ b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/create_ml.ts @@ -76,14 +76,14 @@ export default ({ getService }: FtrProviderContext) => { before(async () => { // Order is critical here: auditbeat data must be loaded before attempting to start the ML job, // as the job looks for certain indices on start - await esArchiver.load('auditbeat/hosts'); + await esArchiver.load('x-pack/test/functional/es_archives/auditbeat/hosts'); await executeSetupModuleRequest(siemModule, 200); await forceStartDatafeeds(mlJobId, 200); - await esArchiver.load('security_solution/anomalies'); + await esArchiver.load('x-pack/test/functional/es_archives/security_solution/anomalies'); }); after(async () => { - await esArchiver.unload('auditbeat/hosts'); - await esArchiver.unload('security_solution/anomalies'); + await esArchiver.unload('x-pack/test/functional/es_archives/auditbeat/hosts'); + await esArchiver.unload('x-pack/test/functional/es_archives/security_solution/anomalies'); }); beforeEach(async () => { diff --git a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/create_rules.ts b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/create_rules.ts index 5ec3374598776..cd63ee36da801 100644 --- a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/create_rules.ts +++ b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/create_rules.ts @@ -61,13 +61,13 @@ export default ({ getService }: FtrProviderContext) => { describe('creating rules', () => { beforeEach(async () => { await createSignalsIndex(supertest); - await esArchiver.load('auditbeat/hosts'); + await esArchiver.load('x-pack/test/functional/es_archives/auditbeat/hosts'); }); afterEach(async () => { await deleteSignalsIndex(supertest); await deleteAllAlerts(supertest); - await esArchiver.unload('auditbeat/hosts'); + await esArchiver.unload('x-pack/test/functional/es_archives/auditbeat/hosts'); }); describe('elastic admin', () => { @@ -297,12 +297,16 @@ export default ({ getService }: FtrProviderContext) => { await createSignalsIndex(supertest); // to edit these files run the following script // cd $HOME/kibana/x-pack && nvm use && node ../scripts/es_archiver edit security_solution/timestamp_override - await esArchiver.load('security_solution/timestamp_override'); + await esArchiver.load( + 'x-pack/test/functional/es_archives/security_solution/timestamp_override' + ); }); afterEach(async () => { await deleteSignalsIndex(supertest); await deleteAllAlerts(supertest); - await esArchiver.unload('security_solution/timestamp_override'); + await esArchiver.unload( + 'x-pack/test/functional/es_archives/security_solution/timestamp_override' + ); }); it('should create a single rule which has a timestamp override for an index pattern that does not exist and write a partial failure status', async () => { diff --git a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/create_rules_bulk.ts b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/create_rules_bulk.ts index 378edd5b2503d..e1fea9afa9ed5 100644 --- a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/create_rules_bulk.ts +++ b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/create_rules_bulk.ts @@ -56,13 +56,13 @@ export default ({ getService }: FtrProviderContext): void => { describe('creating rules in bulk', () => { beforeEach(async () => { await createSignalsIndex(supertest); - await esArchiver.load('auditbeat/hosts'); + await esArchiver.load('x-pack/test/functional/es_archives/auditbeat/hosts'); }); afterEach(async () => { await deleteSignalsIndex(supertest); await deleteAllAlerts(supertest); - await esArchiver.unload('auditbeat/hosts'); + await esArchiver.unload('x-pack/test/functional/es_archives/auditbeat/hosts'); }); it('should create a single rule with a rule_id', async () => { diff --git a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/create_signals_migrations.ts b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/create_signals_migrations.ts index 8f7d2a0c01771..1d33c4c3047cd 100644 --- a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/create_signals_migrations.ts +++ b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/create_signals_migrations.ts @@ -47,16 +47,16 @@ export default ({ getService }: FtrProviderContext): void => { await createSignalsIndex(supertest); legacySignalsIndexName = getIndexNameFromLoad( - await esArchiver.load('signals/legacy_signals_index') + await esArchiver.load('x-pack/test/functional/es_archives/signals/legacy_signals_index') ); outdatedSignalsIndexName = getIndexNameFromLoad( - await esArchiver.load('signals/outdated_signals_index') + await esArchiver.load('x-pack/test/functional/es_archives/signals/outdated_signals_index') ); }); afterEach(async () => { - await esArchiver.unload('signals/outdated_signals_index'); - await esArchiver.unload('signals/legacy_signals_index'); + await esArchiver.unload('x-pack/test/functional/es_archives/signals/outdated_signals_index'); + await esArchiver.unload('x-pack/test/functional/es_archives/signals/legacy_signals_index'); await deleteMigrations({ kbnClient, ids: createdMigrations.filter((m) => m?.migration_id).map((m) => m.migration_id), diff --git a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/create_threat_matching.ts b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/create_threat_matching.ts index 43576b80b3738..755847e8b645d 100644 --- a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/create_threat_matching.ts +++ b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/create_threat_matching.ts @@ -68,13 +68,13 @@ export default ({ getService }: FtrProviderContext) => { describe('creating threat match rule', () => { beforeEach(async () => { await createSignalsIndex(supertest); - await esArchiver.load('auditbeat/hosts'); + await esArchiver.load('x-pack/test/functional/es_archives/auditbeat/hosts'); }); afterEach(async () => { await deleteSignalsIndex(supertest); await deleteAllAlerts(supertest); - await esArchiver.unload('auditbeat/hosts'); + await esArchiver.unload('x-pack/test/functional/es_archives/auditbeat/hosts'); }); it('should create a single rule with a rule_id', async () => { @@ -107,13 +107,13 @@ export default ({ getService }: FtrProviderContext) => { beforeEach(async () => { await deleteAllAlerts(supertest); await createSignalsIndex(supertest); - await esArchiver.load('auditbeat/hosts'); + await esArchiver.load('x-pack/test/functional/es_archives/auditbeat/hosts'); }); afterEach(async () => { await deleteSignalsIndex(supertest); await deleteAllAlerts(supertest); - await esArchiver.unload('auditbeat/hosts'); + await esArchiver.unload('x-pack/test/functional/es_archives/auditbeat/hosts'); }); it('should be able to execute and get 10 signals when doing a specific query', async () => { @@ -358,11 +358,11 @@ export default ({ getService }: FtrProviderContext) => { describe('indicator enrichment', () => { beforeEach(async () => { - await esArchiver.load('filebeat/threat_intel'); + await esArchiver.load('x-pack/test/functional/es_archives/filebeat/threat_intel'); }); afterEach(async () => { - await esArchiver.unload('filebeat/threat_intel'); + await esArchiver.unload('x-pack/test/functional/es_archives/filebeat/threat_intel'); }); it('enriches signals with the single indicator that matched', async () => { diff --git a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/delete_signals_migrations.ts b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/delete_signals_migrations.ts index 8c4ad5a2e8117..4539b8de8e6dc 100644 --- a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/delete_signals_migrations.ts +++ b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/delete_signals_migrations.ts @@ -43,7 +43,7 @@ export default ({ getService }: FtrProviderContext): void => { beforeEach(async () => { await createSignalsIndex(supertest); outdatedSignalsIndexName = getIndexNameFromLoad( - await esArchiver.load('signals/outdated_signals_index') + await esArchiver.load('x-pack/test/functional/es_archives/signals/outdated_signals_index') ); ({ @@ -72,7 +72,7 @@ export default ({ getService }: FtrProviderContext): void => { }); afterEach(async () => { - await esArchiver.unload('signals/outdated_signals_index'); + await esArchiver.unload('x-pack/test/functional/es_archives/signals/outdated_signals_index'); await deleteSignalsIndex(supertest); }); diff --git a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/exception_operators_data_types/date.ts b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/exception_operators_data_types/date.ts index a5ea14b9c1f13..ebbf91fed451a 100644 --- a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/exception_operators_data_types/date.ts +++ b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/exception_operators_data_types/date.ts @@ -36,7 +36,7 @@ export default ({ getService }: FtrProviderContext) => { beforeEach(async () => { await createSignalsIndex(supertest); await createListsIndex(supertest); - await esArchiver.load('rule_exceptions/date'); + await esArchiver.load('x-pack/test/functional/es_archives/rule_exceptions/date'); }); afterEach(async () => { @@ -44,7 +44,7 @@ export default ({ getService }: FtrProviderContext) => { await deleteAllAlerts(supertest); await deleteAllExceptions(es); await deleteListsIndex(supertest); - await esArchiver.unload('rule_exceptions/date'); + await esArchiver.unload('x-pack/test/functional/es_archives/rule_exceptions/date'); }); describe('"is" operator', () => { diff --git a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/exception_operators_data_types/double.ts b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/exception_operators_data_types/double.ts index eabc6f6469c93..0ae52b86e3d77 100644 --- a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/exception_operators_data_types/double.ts +++ b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/exception_operators_data_types/double.ts @@ -36,8 +36,8 @@ export default ({ getService }: FtrProviderContext) => { beforeEach(async () => { await createSignalsIndex(supertest); await createListsIndex(supertest); - await esArchiver.load('rule_exceptions/double'); - await esArchiver.load('rule_exceptions/double_as_string'); + await esArchiver.load('x-pack/test/functional/es_archives/rule_exceptions/double'); + await esArchiver.load('x-pack/test/functional/es_archives/rule_exceptions/double_as_string'); }); afterEach(async () => { @@ -45,8 +45,10 @@ export default ({ getService }: FtrProviderContext) => { await deleteAllAlerts(supertest); await deleteAllExceptions(es); await deleteListsIndex(supertest); - await esArchiver.unload('rule_exceptions/double'); - await esArchiver.unload('rule_exceptions/double_as_string'); + await esArchiver.unload('x-pack/test/functional/es_archives/rule_exceptions/double'); + await esArchiver.unload( + 'x-pack/test/functional/es_archives/rule_exceptions/double_as_string' + ); }); describe('"is" operator', () => { diff --git a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/exception_operators_data_types/float.ts b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/exception_operators_data_types/float.ts index 995692189d710..7d5d8a215a982 100644 --- a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/exception_operators_data_types/float.ts +++ b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/exception_operators_data_types/float.ts @@ -36,8 +36,8 @@ export default ({ getService }: FtrProviderContext) => { beforeEach(async () => { await createSignalsIndex(supertest); await createListsIndex(supertest); - await esArchiver.load('rule_exceptions/float'); - await esArchiver.load('rule_exceptions/float_as_string'); + await esArchiver.load('x-pack/test/functional/es_archives/rule_exceptions/float'); + await esArchiver.load('x-pack/test/functional/es_archives/rule_exceptions/float_as_string'); }); afterEach(async () => { @@ -45,8 +45,8 @@ export default ({ getService }: FtrProviderContext) => { await deleteAllAlerts(supertest); await deleteAllExceptions(es); await deleteListsIndex(supertest); - await esArchiver.unload('rule_exceptions/float'); - await esArchiver.unload('rule_exceptions/float_as_string'); + await esArchiver.unload('x-pack/test/functional/es_archives/rule_exceptions/float'); + await esArchiver.unload('x-pack/test/functional/es_archives/rule_exceptions/float_as_string'); }); describe('"is" operator', () => { diff --git a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/exception_operators_data_types/integer.ts b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/exception_operators_data_types/integer.ts index 3e347239f6951..8d73262147287 100644 --- a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/exception_operators_data_types/integer.ts +++ b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/exception_operators_data_types/integer.ts @@ -36,8 +36,8 @@ export default ({ getService }: FtrProviderContext) => { beforeEach(async () => { await createSignalsIndex(supertest); await createListsIndex(supertest); - await esArchiver.load('rule_exceptions/integer'); - await esArchiver.load('rule_exceptions/integer_as_string'); + await esArchiver.load('x-pack/test/functional/es_archives/rule_exceptions/integer'); + await esArchiver.load('x-pack/test/functional/es_archives/rule_exceptions/integer_as_string'); }); afterEach(async () => { @@ -45,8 +45,10 @@ export default ({ getService }: FtrProviderContext) => { await deleteAllAlerts(supertest); await deleteAllExceptions(es); await deleteListsIndex(supertest); - await esArchiver.unload('rule_exceptions/integer'); - await esArchiver.unload('rule_exceptions/integer_as_string'); + await esArchiver.unload('x-pack/test/functional/es_archives/rule_exceptions/integer'); + await esArchiver.unload( + 'x-pack/test/functional/es_archives/rule_exceptions/integer_as_string' + ); }); describe('"is" operator', () => { diff --git a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/exception_operators_data_types/ip.ts b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/exception_operators_data_types/ip.ts index 521a5c01a1203..9acbe0da6f27c 100644 --- a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/exception_operators_data_types/ip.ts +++ b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/exception_operators_data_types/ip.ts @@ -36,7 +36,7 @@ export default ({ getService }: FtrProviderContext) => { beforeEach(async () => { await createSignalsIndex(supertest); await createListsIndex(supertest); - await esArchiver.load('rule_exceptions/ip'); + await esArchiver.load('x-pack/test/functional/es_archives/rule_exceptions/ip'); }); afterEach(async () => { @@ -44,7 +44,7 @@ export default ({ getService }: FtrProviderContext) => { await deleteAllAlerts(supertest); await deleteAllExceptions(es); await deleteListsIndex(supertest); - await esArchiver.unload('rule_exceptions/ip'); + await esArchiver.unload('x-pack/test/functional/es_archives/rule_exceptions/ip'); }); describe('"is" operator', () => { diff --git a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/exception_operators_data_types/ip_array.ts b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/exception_operators_data_types/ip_array.ts index cc17f608eeaed..16b3ab2958c9f 100644 --- a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/exception_operators_data_types/ip_array.ts +++ b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/exception_operators_data_types/ip_array.ts @@ -36,7 +36,7 @@ export default ({ getService }: FtrProviderContext) => { beforeEach(async () => { await createSignalsIndex(supertest); await createListsIndex(supertest); - await esArchiver.load('rule_exceptions/ip_as_array'); + await esArchiver.load('x-pack/test/functional/es_archives/rule_exceptions/ip_as_array'); }); afterEach(async () => { @@ -44,7 +44,7 @@ export default ({ getService }: FtrProviderContext) => { await deleteAllAlerts(supertest); await deleteAllExceptions(es); await deleteListsIndex(supertest); - await esArchiver.unload('rule_exceptions/ip_as_array'); + await esArchiver.unload('x-pack/test/functional/es_archives/rule_exceptions/ip_as_array'); }); describe('"is" operator', () => { diff --git a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/exception_operators_data_types/keyword.ts b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/exception_operators_data_types/keyword.ts index 38c86c4b84135..29fbd2423956f 100644 --- a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/exception_operators_data_types/keyword.ts +++ b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/exception_operators_data_types/keyword.ts @@ -36,7 +36,7 @@ export default ({ getService }: FtrProviderContext) => { beforeEach(async () => { await createSignalsIndex(supertest); await createListsIndex(supertest); - await esArchiver.load('rule_exceptions/keyword'); + await esArchiver.load('x-pack/test/functional/es_archives/rule_exceptions/keyword'); }); afterEach(async () => { @@ -44,7 +44,7 @@ export default ({ getService }: FtrProviderContext) => { await deleteAllAlerts(supertest); await deleteAllExceptions(es); await deleteListsIndex(supertest); - await esArchiver.unload('rule_exceptions/keyword'); + await esArchiver.unload('x-pack/test/functional/es_archives/rule_exceptions/keyword'); }); describe('"is" operator', () => { diff --git a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/exception_operators_data_types/keyword_array.ts b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/exception_operators_data_types/keyword_array.ts index c1e1aaabcc36a..f3b49558bb99d 100644 --- a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/exception_operators_data_types/keyword_array.ts +++ b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/exception_operators_data_types/keyword_array.ts @@ -36,7 +36,7 @@ export default ({ getService }: FtrProviderContext) => { beforeEach(async () => { await createSignalsIndex(supertest); await createListsIndex(supertest); - await esArchiver.load('rule_exceptions/keyword_as_array'); + await esArchiver.load('x-pack/test/functional/es_archives/rule_exceptions/keyword_as_array'); }); afterEach(async () => { @@ -44,7 +44,9 @@ export default ({ getService }: FtrProviderContext) => { await deleteAllAlerts(supertest); await deleteAllExceptions(es); await deleteListsIndex(supertest); - await esArchiver.unload('rule_exceptions/keyword_as_array'); + await esArchiver.unload( + 'x-pack/test/functional/es_archives/rule_exceptions/keyword_as_array' + ); }); describe('"is" operator', () => { diff --git a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/exception_operators_data_types/long.ts b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/exception_operators_data_types/long.ts index d526dae0747f1..55896212c2fd8 100644 --- a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/exception_operators_data_types/long.ts +++ b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/exception_operators_data_types/long.ts @@ -36,8 +36,8 @@ export default ({ getService }: FtrProviderContext) => { beforeEach(async () => { await createSignalsIndex(supertest); await createListsIndex(supertest); - await esArchiver.load('rule_exceptions/long'); - await esArchiver.load('rule_exceptions/long_as_string'); + await esArchiver.load('x-pack/test/functional/es_archives/rule_exceptions/long'); + await esArchiver.load('x-pack/test/functional/es_archives/rule_exceptions/long_as_string'); }); afterEach(async () => { @@ -45,8 +45,8 @@ export default ({ getService }: FtrProviderContext) => { await deleteAllAlerts(supertest); await deleteAllExceptions(es); await deleteListsIndex(supertest); - await esArchiver.unload('rule_exceptions/long'); - await esArchiver.unload('rule_exceptions/long_as_string'); + await esArchiver.unload('x-pack/test/functional/es_archives/rule_exceptions/long'); + await esArchiver.unload('x-pack/test/functional/es_archives/rule_exceptions/long_as_string'); }); describe('"is" operator', () => { diff --git a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/exception_operators_data_types/text.ts b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/exception_operators_data_types/text.ts index 34d4b467f1c4f..046d4100b1ee4 100644 --- a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/exception_operators_data_types/text.ts +++ b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/exception_operators_data_types/text.ts @@ -37,8 +37,8 @@ export default ({ getService }: FtrProviderContext) => { beforeEach(async () => { await createSignalsIndex(supertest); await createListsIndex(supertest); - await esArchiver.load('rule_exceptions/text'); - await esArchiver.load('rule_exceptions/text_no_spaces'); + await esArchiver.load('x-pack/test/functional/es_archives/rule_exceptions/text'); + await esArchiver.load('x-pack/test/functional/es_archives/rule_exceptions/text_no_spaces'); }); afterEach(async () => { @@ -46,8 +46,8 @@ export default ({ getService }: FtrProviderContext) => { await deleteAllAlerts(supertest); await deleteAllExceptions(es); await deleteListsIndex(supertest); - await esArchiver.unload('rule_exceptions/text'); - await esArchiver.unload('rule_exceptions/text_no_spaces'); + await esArchiver.unload('x-pack/test/functional/es_archives/rule_exceptions/text'); + await esArchiver.unload('x-pack/test/functional/es_archives/rule_exceptions/text_no_spaces'); }); describe('"is" operator', () => { diff --git a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/exception_operators_data_types/text_array.ts b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/exception_operators_data_types/text_array.ts index 0c9e9b6ed59c2..377019e4e40e6 100644 --- a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/exception_operators_data_types/text_array.ts +++ b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/exception_operators_data_types/text_array.ts @@ -36,7 +36,7 @@ export default ({ getService }: FtrProviderContext) => { beforeEach(async () => { await createSignalsIndex(supertest); await createListsIndex(supertest); - await esArchiver.load('rule_exceptions/text_as_array'); + await esArchiver.load('x-pack/test/functional/es_archives/rule_exceptions/text_as_array'); }); afterEach(async () => { @@ -44,7 +44,7 @@ export default ({ getService }: FtrProviderContext) => { await deleteAllAlerts(supertest); await deleteAllExceptions(es); await deleteListsIndex(supertest); - await esArchiver.unload('rule_exceptions/text_as_array'); + await esArchiver.unload('x-pack/test/functional/es_archives/rule_exceptions/text_as_array'); }); describe('"is" operator', () => { diff --git a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/finalize_signals_migrations.ts b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/finalize_signals_migrations.ts index 6ab23edae9b3b..0c274a8f4678b 100644 --- a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/finalize_signals_migrations.ts +++ b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/finalize_signals_migrations.ts @@ -58,10 +58,10 @@ export default ({ getService }: FtrProviderContext): void => { createdMigrations = []; await createSignalsIndex(supertest); legacySignalsIndexName = getIndexNameFromLoad( - await esArchiver.load('signals/legacy_signals_index') + await esArchiver.load('x-pack/test/functional/es_archives/signals/legacy_signals_index') ); outdatedSignalsIndexName = getIndexNameFromLoad( - await esArchiver.load('signals/outdated_signals_index') + await esArchiver.load('x-pack/test/functional/es_archives/signals/outdated_signals_index') ); ({ @@ -76,8 +76,8 @@ export default ({ getService }: FtrProviderContext): void => { }); afterEach(async () => { - await esArchiver.unload('signals/outdated_signals_index'); - await esArchiver.unload('signals/legacy_signals_index'); + await esArchiver.unload('x-pack/test/functional/es_archives/signals/outdated_signals_index'); + await esArchiver.unload('x-pack/test/functional/es_archives/signals/legacy_signals_index'); await deleteMigrations({ kbnClient, ids: createdMigrations.filter((m) => m?.migration_id).map((m) => m.migration_id), diff --git a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/find_statuses.ts b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/find_statuses.ts index 29a5433d86c36..b423fb80609c1 100644 --- a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/find_statuses.ts +++ b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/find_statuses.ts @@ -28,14 +28,14 @@ export default ({ getService }: FtrProviderContext): void => { describe('find_statuses', () => { beforeEach(async () => { await createSignalsIndex(supertest); - await esArchiver.load('auditbeat/hosts'); + await esArchiver.load('x-pack/test/functional/es_archives/auditbeat/hosts'); }); afterEach(async () => { await deleteSignalsIndex(supertest); await deleteAllAlerts(supertest); await deleteAllRulesStatuses(es); - await esArchiver.unload('auditbeat/hosts'); + await esArchiver.unload('x-pack/test/functional/es_archives/auditbeat/hosts'); }); it('should return an empty find statuses body correctly if no statuses are loaded', async () => { diff --git a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/generating_signals.ts b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/generating_signals.ts index 8638f6c1bd7ed..0ba0749e75b08 100644 --- a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/generating_signals.ts +++ b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/generating_signals.ts @@ -55,11 +55,11 @@ export default ({ getService }: FtrProviderContext) => { describe('Signals from audit beat are of the expected structure', () => { beforeEach(async () => { - await esArchiver.load('auditbeat/hosts'); + await esArchiver.load('x-pack/test/functional/es_archives/auditbeat/hosts'); }); afterEach(async () => { - await esArchiver.unload('auditbeat/hosts'); + await esArchiver.unload('x-pack/test/functional/es_archives/auditbeat/hosts'); }); it('should have the specific audit record for _id or none of these tests below will pass', async () => { @@ -1160,11 +1160,11 @@ export default ({ getService }: FtrProviderContext) => { */ describe('Signals generated from name clashes', () => { beforeEach(async () => { - await esArchiver.load('signals/numeric_name_clash'); + await esArchiver.load('x-pack/test/functional/es_archives/signals/numeric_name_clash'); }); afterEach(async () => { - await esArchiver.unload('signals/numeric_name_clash'); + await esArchiver.unload('x-pack/test/functional/es_archives/signals/numeric_name_clash'); }); it('should have the specific audit record for _id or none of these tests below will pass', async () => { @@ -1314,11 +1314,11 @@ export default ({ getService }: FtrProviderContext) => { */ describe('Signals generated from object clashes', () => { beforeEach(async () => { - await esArchiver.load('signals/object_clash'); + await esArchiver.load('x-pack/test/functional/es_archives/signals/object_clash'); }); afterEach(async () => { - await esArchiver.unload('signals/object_clash'); + await esArchiver.unload('x-pack/test/functional/es_archives/signals/object_clash'); }); it('should have the specific audit record for _id or none of these tests below will pass', async () => { @@ -1471,11 +1471,13 @@ export default ({ getService }: FtrProviderContext) => { */ describe('Signals generated from events with custom severity and risk score fields', () => { beforeEach(async () => { - await esArchiver.load('signals/severity_risk_overrides'); + await esArchiver.load('x-pack/test/functional/es_archives/signals/severity_risk_overrides'); }); afterEach(async () => { - await esArchiver.unload('signals/severity_risk_overrides'); + await esArchiver.unload( + 'x-pack/test/functional/es_archives/signals/severity_risk_overrides' + ); }); const executeRuleAndGetSignals = async (rule: QueryCreateSchema) => { @@ -1620,13 +1622,13 @@ export default ({ getService }: FtrProviderContext) => { beforeEach(async () => { await deleteSignalsIndex(supertest); await createSignalsIndex(supertest); - await esArchiver.load('auditbeat/hosts'); + await esArchiver.load('x-pack/test/functional/es_archives/auditbeat/hosts'); }); afterEach(async () => { await deleteSignalsIndex(supertest); await deleteAllAlerts(supertest); - await esArchiver.load('auditbeat/hosts'); + await esArchiver.load('x-pack/test/functional/es_archives/auditbeat/hosts'); }); it('should generate signals with name_override field', async () => { diff --git a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/get_signals_migration_status.ts b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/get_signals_migration_status.ts index 869d1672150cc..6bb00c55f690e 100644 --- a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/get_signals_migration_status.ts +++ b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/get_signals_migration_status.ts @@ -25,12 +25,12 @@ export default ({ getService }: FtrProviderContext): void => { beforeEach(async () => { await createSignalsIndex(supertest); legacySignalsIndexName = getIndexNameFromLoad( - await esArchiver.load('signals/legacy_signals_index') + await esArchiver.load('x-pack/test/functional/es_archives/signals/legacy_signals_index') ); }); afterEach(async () => { - await esArchiver.unload('signals/legacy_signals_index'); + await esArchiver.unload('x-pack/test/functional/es_archives/signals/legacy_signals_index'); await deleteSignalsIndex(supertest); }); @@ -59,7 +59,7 @@ export default ({ getService }: FtrProviderContext): void => { it("returns the mappings version and a breakdown of signals' version", async () => { const outdatedIndexName = getIndexNameFromLoad( - await esArchiver.load('signals/outdated_signals_index') + await esArchiver.load('x-pack/test/functional/es_archives/signals/outdated_signals_index') ); const { body } = await supertest @@ -95,7 +95,7 @@ export default ({ getService }: FtrProviderContext): void => { }, ]); - await esArchiver.unload('signals/outdated_signals_index'); + await esArchiver.unload('x-pack/test/functional/es_archives/signals/outdated_signals_index'); }); it('rejects the request if the user does not have sufficient privileges', async () => { diff --git a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/keyword_family/const_keyword.ts b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/keyword_family/const_keyword.ts index 43366915f154e..fccfe4d74e241 100644 --- a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/keyword_family/const_keyword.ts +++ b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/keyword_family/const_keyword.ts @@ -36,13 +36,15 @@ export default ({ getService }: FtrProviderContext) => { describe('Rule detects against a keyword of event.dataset', () => { beforeEach(async () => { await createSignalsIndex(supertest); - await esArchiver.load('rule_keyword_family/const_keyword'); + await esArchiver.load('x-pack/test/functional/es_archives/rule_keyword_family/const_keyword'); }); afterEach(async () => { await deleteSignalsIndex(supertest); await deleteAllAlerts(supertest); - await esArchiver.unload('rule_keyword_family/const_keyword'); + await esArchiver.unload( + 'x-pack/test/functional/es_archives/rule_keyword_family/const_keyword' + ); }); describe('"kql" rule type', () => { diff --git a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/keyword_family/keyword.ts b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/keyword_family/keyword.ts index 7ba013184548b..d2d2898587ee2 100644 --- a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/keyword_family/keyword.ts +++ b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/keyword_family/keyword.ts @@ -36,13 +36,13 @@ export default ({ getService }: FtrProviderContext) => { describe('Rule detects against a keyword of event.dataset', () => { beforeEach(async () => { await createSignalsIndex(supertest); - await esArchiver.load('rule_keyword_family/keyword'); + await esArchiver.load('x-pack/test/functional/es_archives/rule_keyword_family/keyword'); }); afterEach(async () => { await deleteSignalsIndex(supertest); await deleteAllAlerts(supertest); - await esArchiver.unload('rule_keyword_family/keyword'); + await esArchiver.unload('x-pack/test/functional/es_archives/rule_keyword_family/keyword'); }); describe('"kql" rule type', () => { diff --git a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/keyword_family/keyword_mixed_with_const.ts b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/keyword_family/keyword_mixed_with_const.ts index a5c69f98c3fe2..3802d1f7a7bef 100644 --- a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/keyword_family/keyword_mixed_with_const.ts +++ b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/keyword_family/keyword_mixed_with_const.ts @@ -36,15 +36,17 @@ export default ({ getService }: FtrProviderContext) => { describe('Rule detects against a keyword and constant_keyword of event.dataset', () => { beforeEach(async () => { await createSignalsIndex(supertest); - await esArchiver.load('rule_keyword_family/const_keyword'); - await esArchiver.load('rule_keyword_family/keyword'); + await esArchiver.load('x-pack/test/functional/es_archives/rule_keyword_family/const_keyword'); + await esArchiver.load('x-pack/test/functional/es_archives/rule_keyword_family/keyword'); }); afterEach(async () => { await deleteSignalsIndex(supertest); await deleteAllAlerts(supertest); - await esArchiver.unload('rule_keyword_family/const_keyword'); - await esArchiver.unload('rule_keyword_family/keyword'); + await esArchiver.unload( + 'x-pack/test/functional/es_archives/rule_keyword_family/const_keyword' + ); + await esArchiver.unload('x-pack/test/functional/es_archives/rule_keyword_family/keyword'); }); describe('"kql" rule type', () => { diff --git a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/open_close_signals.ts b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/open_close_signals.ts index 36a05f0ae8c0e..d56463770e84f 100644 --- a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/open_close_signals.ts +++ b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/open_close_signals.ts @@ -71,12 +71,12 @@ export default ({ getService }: FtrProviderContext) => { beforeEach(async () => { await deleteAllAlerts(supertest); await createSignalsIndex(supertest); - await esArchiver.load('auditbeat/hosts'); + await esArchiver.load('x-pack/test/functional/es_archives/auditbeat/hosts'); }); afterEach(async () => { await deleteSignalsIndex(supertest); await deleteAllAlerts(supertest); - await esArchiver.unload('auditbeat/hosts'); + await esArchiver.unload('x-pack/test/functional/es_archives/auditbeat/hosts'); }); it('should be able to execute and get 10 signals', async () => { diff --git a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/timestamps.ts b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/timestamps.ts index 16610e6a44915..8645fec287b07 100644 --- a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/timestamps.ts +++ b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/timestamps.ts @@ -35,15 +35,23 @@ export default ({ getService }: FtrProviderContext) => { describe('Signals generated from events with a timestamp in seconds is converted correctly into the forced ISO8601 format when copying', () => { beforeEach(async () => { await createSignalsIndex(supertest); - await esArchiver.load('security_solution/timestamp_in_seconds'); - await esArchiver.load('security_solution/timestamp_override_5'); + await esArchiver.load( + 'x-pack/test/functional/es_archives/security_solution/timestamp_in_seconds' + ); + await esArchiver.load( + 'x-pack/test/functional/es_archives/security_solution/timestamp_override_5' + ); }); afterEach(async () => { await deleteSignalsIndex(supertest); await deleteAllAlerts(supertest); - await esArchiver.unload('security_solution/timestamp_in_seconds'); - await esArchiver.unload('security_solution/timestamp_override_5'); + await esArchiver.unload( + 'x-pack/test/functional/es_archives/security_solution/timestamp_in_seconds' + ); + await esArchiver.unload( + 'x-pack/test/functional/es_archives/security_solution/timestamp_override_5' + ); }); it('should convert the @timestamp which is epoch_seconds into the correct ISO format', async () => { @@ -80,19 +88,35 @@ export default ({ getService }: FtrProviderContext) => { beforeEach(async () => { await deleteSignalsIndex(supertest); await createSignalsIndex(supertest); - await esArchiver.load('security_solution/timestamp_override_1'); - await esArchiver.load('security_solution/timestamp_override_2'); - await esArchiver.load('security_solution/timestamp_override_3'); - await esArchiver.load('security_solution/timestamp_override_4'); + await esArchiver.load( + 'x-pack/test/functional/es_archives/security_solution/timestamp_override_1' + ); + await esArchiver.load( + 'x-pack/test/functional/es_archives/security_solution/timestamp_override_2' + ); + await esArchiver.load( + 'x-pack/test/functional/es_archives/security_solution/timestamp_override_3' + ); + await esArchiver.load( + 'x-pack/test/functional/es_archives/security_solution/timestamp_override_4' + ); }); afterEach(async () => { await deleteSignalsIndex(supertest); await deleteAllAlerts(supertest); - await esArchiver.unload('security_solution/timestamp_override_1'); - await esArchiver.unload('security_solution/timestamp_override_2'); - await esArchiver.unload('security_solution/timestamp_override_3'); - await esArchiver.unload('security_solution/timestamp_override_4'); + await esArchiver.unload( + 'x-pack/test/functional/es_archives/security_solution/timestamp_override_1' + ); + await esArchiver.unload( + 'x-pack/test/functional/es_archives/security_solution/timestamp_override_2' + ); + await esArchiver.unload( + 'x-pack/test/functional/es_archives/security_solution/timestamp_override_3' + ); + await esArchiver.unload( + 'x-pack/test/functional/es_archives/security_solution/timestamp_override_4' + ); }); it('should generate signals with event.ingested, @timestamp and (event.ingested + timestamp)', async () => { @@ -168,13 +192,13 @@ export default ({ getService }: FtrProviderContext) => { describe('Signals generated from events with timestamp override field and ensures search_after continues to work when documents are missing timestamp override field', () => { beforeEach(async () => { await createSignalsIndex(supertest); - await esArchiver.load('auditbeat/hosts'); + await esArchiver.load('x-pack/test/functional/es_archives/auditbeat/hosts'); }); afterEach(async () => { await deleteSignalsIndex(supertest); await deleteAllAlerts(supertest); - await esArchiver.unload('auditbeat/hosts'); + await esArchiver.unload('x-pack/test/functional/es_archives/auditbeat/hosts'); }); /** diff --git a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/update_actions.ts b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/update_actions.ts index 12841b9072624..59a99495c14c6 100644 --- a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/update_actions.ts +++ b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/update_actions.ts @@ -37,14 +37,14 @@ export default ({ getService }: FtrProviderContext) => { describe('update_actions', () => { describe('updating actions', () => { beforeEach(async () => { - await esArchiver.load('auditbeat/hosts'); + await esArchiver.load('x-pack/test/functional/es_archives/auditbeat/hosts'); await createSignalsIndex(supertest); }); afterEach(async () => { await deleteSignalsIndex(supertest); await deleteAllAlerts(supertest); - await esArchiver.unload('auditbeat/hosts'); + await esArchiver.unload('x-pack/test/functional/es_archives/auditbeat/hosts'); }); it('should be able to create a new webhook action and update a rule with the webhook action', async () => { diff --git a/x-pack/test/encrypted_saved_objects_api_integration/config.ts b/x-pack/test/encrypted_saved_objects_api_integration/config.ts index 9305431711de6..1eed95568b3fc 100644 --- a/x-pack/test/encrypted_saved_objects_api_integration/config.ts +++ b/x-pack/test/encrypted_saved_objects_api_integration/config.ts @@ -19,9 +19,6 @@ export default async function ({ readConfigFile }: FtrConfigProviderContext) { junit: { reportName: 'X-Pack Encrypted Saved Objects API Integration Tests', }, - esArchiver: { - directory: path.join(__dirname, 'fixtures', 'es_archiver'), - }, esTestCluster: xPackAPITestsConfig.get('esTestCluster'), kbnTestServer: { ...xPackAPITestsConfig.get('kbnTestServer'), diff --git a/x-pack/test/encrypted_saved_objects_api_integration/tests/encrypted_saved_objects_api.ts b/x-pack/test/encrypted_saved_objects_api_integration/tests/encrypted_saved_objects_api.ts index 9ee92a8a1848f..0b01f4f385da6 100644 --- a/x-pack/test/encrypted_saved_objects_api_integration/tests/encrypted_saved_objects_api.ts +++ b/x-pack/test/encrypted_saved_objects_api_integration/tests/encrypted_saved_objects_api.ts @@ -516,11 +516,15 @@ export default function ({ getService }: FtrProviderContext) { describe('migrations', () => { before(async () => { - await esArchiver.load('encrypted_saved_objects'); + await esArchiver.load( + 'x-pack/test/encrypted_saved_objects_api_integration/fixtures/es_archiver/encrypted_saved_objects' + ); }); after(async () => { - await esArchiver.unload('encrypted_saved_objects'); + await esArchiver.unload( + 'x-pack/test/encrypted_saved_objects_api_integration/fixtures/es_archiver/encrypted_saved_objects' + ); }); it('migrates unencrypted fields on saved objects', async () => { @@ -580,11 +584,15 @@ export default function ({ getService }: FtrProviderContext) { roles: ['kibana_admin'], full_name: 'a kibana admin', }); - await esArchiver.load('key_rotation'); + await esArchiver.load( + 'x-pack/test/encrypted_saved_objects_api_integration/fixtures/es_archiver/key_rotation' + ); }); after(async () => { - await esArchiver.unload('key_rotation'); + await esArchiver.unload( + 'x-pack/test/encrypted_saved_objects_api_integration/fixtures/es_archiver/key_rotation' + ); await security.user.delete('admin'); }); diff --git a/x-pack/test/endpoint_api_integration_no_ingest/apis/metadata.ts b/x-pack/test/endpoint_api_integration_no_ingest/apis/metadata.ts index d56310709f9f2..d7468bde4c603 100644 --- a/x-pack/test/endpoint_api_integration_no_ingest/apis/metadata.ts +++ b/x-pack/test/endpoint_api_integration_no_ingest/apis/metadata.ts @@ -11,8 +11,14 @@ export default function ({ getService }: FtrProviderContext) { const esArchiver = getService('esArchiver'); const supertest = getService('supertest'); describe('test metadata api when ingest manager is not initialized', () => { - before(async () => await esArchiver.load('endpoint/metadata/api_feature')); - after(async () => await esArchiver.unload('endpoint/metadata/api_feature')); + before( + async () => + await esArchiver.load('x-pack/test/functional/es_archives/endpoint/metadata/api_feature') + ); + after( + async () => + await esArchiver.unload('x-pack/test/functional/es_archives/endpoint/metadata/api_feature') + ); it('metadata api should not return results', async () => { await supertest.post('/api/endpoint/metadata').set('kbn-xsrf', 'xxx').send().expect(500); }); diff --git a/x-pack/test/examples/search_examples/index.ts b/x-pack/test/examples/search_examples/index.ts index eaaeb22410183..41c4945ca4569 100644 --- a/x-pack/test/examples/search_examples/index.ts +++ b/x-pack/test/examples/search_examples/index.ts @@ -15,12 +15,12 @@ export default function ({ getService, loadTestFile }: PluginFunctionalProviderC this.tags('ciGroup13'); before(async () => { await esArchiver.emptyKibanaIndex(); - await esArchiver.loadIfNeeded('logstash_functional'); - await esArchiver.loadIfNeeded('lens/basic'); // need at least one index pattern + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/logstash_functional'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/lens/basic'); // need at least one index pattern }); after(async () => { - await esArchiver.unload('lens/basic'); + await esArchiver.unload('x-pack/test/functional/es_archives/lens/basic'); }); loadTestFile(require.resolve('./search_session_example')); diff --git a/x-pack/test/fleet_api_integration/apis/agent_policy/agent_policy.ts b/x-pack/test/fleet_api_integration/apis/agent_policy/agent_policy.ts index 33a4e40482781..a40d445f45ecb 100644 --- a/x-pack/test/fleet_api_integration/apis/agent_policy/agent_policy.ts +++ b/x-pack/test/fleet_api_integration/apis/agent_policy/agent_policy.ts @@ -15,10 +15,10 @@ export default function ({ getService }: FtrProviderContext) { describe('fleet_agent_policies', () => { describe('POST /api/fleet/agent_policies', () => { before(async () => { - await esArchiver.load('fleet/empty_fleet_server'); + await esArchiver.load('x-pack/test/functional/es_archives/fleet/empty_fleet_server'); }); after(async () => { - await esArchiver.unload('fleet/empty_fleet_server'); + await esArchiver.unload('x-pack/test/functional/es_archives/fleet/empty_fleet_server'); }); it('should work with valid minimum required values', async () => { const { @@ -117,10 +117,10 @@ export default function ({ getService }: FtrProviderContext) { describe('POST /api/fleet/agent_policies/{agentPolicyId}/copy', () => { before(async () => { - await esArchiver.loadIfNeeded('fleet/agents'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/fleet/agents'); }); after(async () => { - await esArchiver.unload('fleet/agents'); + await esArchiver.unload('x-pack/test/functional/es_archives/fleet/agents'); }); const TEST_POLICY_ID = 'policy1'; @@ -198,7 +198,7 @@ export default function ({ getService }: FtrProviderContext) { describe('PUT /api/fleet/agent_policies/{agentPolicyId}', () => { before(async () => { - await esArchiver.load('fleet/empty_fleet_server'); + await esArchiver.load('x-pack/test/functional/es_archives/fleet/empty_fleet_server'); }); const createdPolicyIds: string[] = []; after(async () => { @@ -212,7 +212,7 @@ export default function ({ getService }: FtrProviderContext) { await Promise.all(deletedPromises); }); after(async () => { - await esArchiver.unload('fleet/empty_fleet_server'); + await esArchiver.unload('x-pack/test/functional/es_archives/fleet/empty_fleet_server'); }); let agentPolicyId: undefined | string; it('should work with valid values', async () => { @@ -325,10 +325,10 @@ export default function ({ getService }: FtrProviderContext) { describe('POST /api/fleet/agent_policies/delete', () => { before(async () => { - await esArchiver.load('fleet/empty_fleet_server'); + await esArchiver.load('x-pack/test/functional/es_archives/fleet/empty_fleet_server'); }); after(async () => { - await esArchiver.unload('fleet/empty_fleet_server'); + await esArchiver.unload('x-pack/test/functional/es_archives/fleet/empty_fleet_server'); }); let hostedPolicy: any | undefined; it('should prevent hosted policies being deleted', async () => { diff --git a/x-pack/test/fleet_api_integration/apis/agent_policy/agent_policy_with_agents_setup.ts b/x-pack/test/fleet_api_integration/apis/agent_policy/agent_policy_with_agents_setup.ts index 48b7513c87da2..a4f67cd58d935 100644 --- a/x-pack/test/fleet_api_integration/apis/agent_policy/agent_policy_with_agents_setup.ts +++ b/x-pack/test/fleet_api_integration/apis/agent_policy/agent_policy_with_agents_setup.ts @@ -58,14 +58,14 @@ export default function (providerContext: FtrProviderContext) { skipIfNoDockerRegistry(providerContext); before(async () => { - await esArchiver.loadIfNeeded('fleet/agents'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/fleet/agents'); }); after(async () => { // Wait before agent status is updated return new Promise((resolve) => setTimeout(resolve, AGENT_UPDATE_LAST_CHECKIN_INTERVAL_MS)); }); after(async () => { - await esArchiver.unload('fleet/agents'); + await esArchiver.unload('x-pack/test/functional/es_archives/fleet/agents'); }); setupFleetAndAgents(providerContext); diff --git a/x-pack/test/fleet_api_integration/apis/agents/actions.ts b/x-pack/test/fleet_api_integration/apis/agents/actions.ts index dc951ab4055c2..a701d44319a95 100644 --- a/x-pack/test/fleet_api_integration/apis/agents/actions.ts +++ b/x-pack/test/fleet_api_integration/apis/agents/actions.ts @@ -15,10 +15,10 @@ export default function (providerContext: FtrProviderContext) { describe('fleet_agents_actions', () => { before(async () => { - await esArchiver.load('fleet/agents'); + await esArchiver.load('x-pack/test/functional/es_archives/fleet/agents'); }); after(async () => { - await esArchiver.unload('fleet/agents'); + await esArchiver.unload('x-pack/test/functional/es_archives/fleet/agents'); }); it('should return a 200 if this a valid actions request', async () => { diff --git a/x-pack/test/fleet_api_integration/apis/agents/delete.ts b/x-pack/test/fleet_api_integration/apis/agents/delete.ts index 15afb34f76ea6..45c468e095e70 100644 --- a/x-pack/test/fleet_api_integration/apis/agents/delete.ts +++ b/x-pack/test/fleet_api_integration/apis/agents/delete.ts @@ -58,10 +58,10 @@ export default function ({ getService }: FtrProviderContext) { } } - await esArchiver.load('fleet/agents'); + await esArchiver.load('x-pack/test/functional/es_archives/fleet/agents'); }); after(async () => { - await esArchiver.unload('fleet/agents'); + await esArchiver.unload('x-pack/test/functional/es_archives/fleet/agents'); }); it('should return a 403 if user lacks fleet-write permissions', async () => { diff --git a/x-pack/test/fleet_api_integration/apis/agents/list.ts b/x-pack/test/fleet_api_integration/apis/agents/list.ts index 7fa88be708077..a11f4d49fe0f1 100644 --- a/x-pack/test/fleet_api_integration/apis/agents/list.ts +++ b/x-pack/test/fleet_api_integration/apis/agents/list.ts @@ -68,10 +68,10 @@ export default function ({ getService }: FtrProviderContext) { } } - await esArchiver.loadIfNeeded('fleet/agents'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/fleet/agents'); }); after(async () => { - await esArchiver.unload('fleet/agents'); + await esArchiver.unload('x-pack/test/functional/es_archives/fleet/agents'); }); it('should return a 403 if a user without the superuser role try to access the APU', async () => { diff --git a/x-pack/test/fleet_api_integration/apis/agents/reassign.ts b/x-pack/test/fleet_api_integration/apis/agents/reassign.ts index ac5aabc5c5084..6d2132577da97 100644 --- a/x-pack/test/fleet_api_integration/apis/agents/reassign.ts +++ b/x-pack/test/fleet_api_integration/apis/agents/reassign.ts @@ -16,20 +16,20 @@ export default function (providerContext: FtrProviderContext) { describe('reassign agent(s)', () => { before(async () => { - await esArchiver.load('fleet/empty_fleet_server'); + await esArchiver.load('x-pack/test/functional/es_archives/fleet/empty_fleet_server'); }); beforeEach(async () => { - await esArchiver.unload('fleet/empty_fleet_server'); - await esArchiver.load('fleet/agents'); + await esArchiver.unload('x-pack/test/functional/es_archives/fleet/empty_fleet_server'); + await esArchiver.load('x-pack/test/functional/es_archives/fleet/agents'); await getService('supertest').post(`/api/fleet/setup`).set('kbn-xsrf', 'xxx').send(); }); setupFleetAndAgents(providerContext); afterEach(async () => { - await esArchiver.unload('fleet/agents'); - await esArchiver.load('fleet/empty_fleet_server'); + await esArchiver.unload('x-pack/test/functional/es_archives/fleet/agents'); + await esArchiver.load('x-pack/test/functional/es_archives/fleet/empty_fleet_server'); }); after(async () => { - await esArchiver.unload('fleet/empty_fleet_server'); + await esArchiver.unload('x-pack/test/functional/es_archives/fleet/empty_fleet_server'); }); describe('reassign single agent', () => { diff --git a/x-pack/test/fleet_api_integration/apis/agents/status.ts b/x-pack/test/fleet_api_integration/apis/agents/status.ts index f79ff15b64d33..a20007cee1f6a 100644 --- a/x-pack/test/fleet_api_integration/apis/agents/status.ts +++ b/x-pack/test/fleet_api_integration/apis/agents/status.ts @@ -17,7 +17,7 @@ export default function ({ getService }: FtrProviderContext) { describe('fleet_agents_status', () => { before(async () => { - await esArchiver.loadIfNeeded('fleet/agents'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/fleet/agents'); // 2 agents online await es.update({ id: 'agent1', @@ -64,7 +64,7 @@ export default function ({ getService }: FtrProviderContext) { }); }); after(async () => { - await esArchiver.unload('fleet/agents'); + await esArchiver.unload('x-pack/test/functional/es_archives/fleet/agents'); }); it('should return the status of agents', async () => { diff --git a/x-pack/test/fleet_api_integration/apis/agents/unenroll.ts b/x-pack/test/fleet_api_integration/apis/agents/unenroll.ts index df213e82bac7c..05ada4cc6a388 100644 --- a/x-pack/test/fleet_api_integration/apis/agents/unenroll.ts +++ b/x-pack/test/fleet_api_integration/apis/agents/unenroll.ts @@ -23,12 +23,12 @@ export default function (providerContext: FtrProviderContext) { let accessAPIKeyId: string; let outputAPIKeyId: string; before(async () => { - await esArchiver.load('fleet/empty_fleet_server'); + await esArchiver.load('x-pack/test/functional/es_archives/fleet/empty_fleet_server'); }); setupFleetAndAgents(providerContext); beforeEach(async () => { - await esArchiver.unload('fleet/empty_fleet_server'); - await esArchiver.load('fleet/agents'); + await esArchiver.unload('x-pack/test/functional/es_archives/fleet/empty_fleet_server'); + await esArchiver.load('x-pack/test/functional/es_archives/fleet/agents'); await getService('supertest').post(`/api/fleet/setup`).set('kbn-xsrf', 'xxx').send(); const { body: accessAPIKeyBody } = await esClient.security.createApiKey({ body: { @@ -67,11 +67,11 @@ export default function (providerContext: FtrProviderContext) { }); }); afterEach(async () => { - await esArchiver.unload('fleet/agents'); - await esArchiver.load('fleet/empty_fleet_server'); + await esArchiver.unload('x-pack/test/functional/es_archives/fleet/agents'); + await esArchiver.load('x-pack/test/functional/es_archives/fleet/empty_fleet_server'); }); after(async () => { - await esArchiver.unload('fleet/empty_fleet_server'); + await esArchiver.unload('x-pack/test/functional/es_archives/fleet/empty_fleet_server'); }); it('/agents/{agent_id}/unenroll should fail for hosted agent policy', async () => { diff --git a/x-pack/test/fleet_api_integration/apis/agents/upgrade.ts b/x-pack/test/fleet_api_integration/apis/agents/upgrade.ts index 143dc123bc722..8708b035050cc 100644 --- a/x-pack/test/fleet_api_integration/apis/agents/upgrade.ts +++ b/x-pack/test/fleet_api_integration/apis/agents/upgrade.ts @@ -26,17 +26,17 @@ export default function (providerContext: FtrProviderContext) { describe('fleet upgrade', () => { skipIfNoDockerRegistry(providerContext); before(async () => { - await esArchiver.load('fleet/agents'); + await esArchiver.load('x-pack/test/functional/es_archives/fleet/agents'); }); setupFleetAndAgents(providerContext); beforeEach(async () => { - await esArchiver.load('fleet/agents'); + await esArchiver.load('x-pack/test/functional/es_archives/fleet/agents'); }); afterEach(async () => { - await esArchiver.unload('fleet/agents'); + await esArchiver.unload('x-pack/test/functional/es_archives/fleet/agents'); }); after(async () => { - await esArchiver.unload('fleet/agents'); + await esArchiver.unload('x-pack/test/functional/es_archives/fleet/agents'); }); describe('one agent', () => { diff --git a/x-pack/test/fleet_api_integration/apis/enrollment_api_keys/crud.ts b/x-pack/test/fleet_api_integration/apis/enrollment_api_keys/crud.ts index b38458f7334c4..429bc3b80a54f 100644 --- a/x-pack/test/fleet_api_integration/apis/enrollment_api_keys/crud.ts +++ b/x-pack/test/fleet_api_integration/apis/enrollment_api_keys/crud.ts @@ -21,11 +21,11 @@ export default function (providerContext: FtrProviderContext) { describe('fleet_enrollment_api_keys_crud', () => { before(async () => { - await esArchiver.loadIfNeeded('fleet/agents'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/fleet/agents'); }); after(async () => { - await esArchiver.unload('fleet/agents'); + await esArchiver.unload('x-pack/test/functional/es_archives/fleet/agents'); }); skipIfNoDockerRegistry(providerContext); diff --git a/x-pack/test/fleet_api_integration/apis/epm/final_pipeline.ts b/x-pack/test/fleet_api_integration/apis/epm/final_pipeline.ts index 1ab7b00da5d76..a800546a27a3e 100644 --- a/x-pack/test/fleet_api_integration/apis/epm/final_pipeline.ts +++ b/x-pack/test/fleet_api_integration/apis/epm/final_pipeline.ts @@ -34,7 +34,7 @@ export default function (providerContext: FtrProviderContext) { describe('fleet_final_pipeline', () => { skipIfNoDockerRegistry(providerContext); before(async () => { - await esArchiver.load('fleet/empty_fleet_server'); + await esArchiver.load('x-pack/test/functional/es_archives/fleet/empty_fleet_server'); }); setupFleetAndAgents(providerContext); @@ -66,7 +66,7 @@ export default function (providerContext: FtrProviderContext) { }); after(async () => { - await esArchiver.unload('fleet/empty_fleet_server'); + await esArchiver.unload('x-pack/test/functional/es_archives/fleet/empty_fleet_server'); }); after(async () => { diff --git a/x-pack/test/fleet_api_integration/apis/epm/install_error_rollback.ts b/x-pack/test/fleet_api_integration/apis/epm/install_error_rollback.ts index 6e2ea3b96aa58..faf95c79d6fe2 100644 --- a/x-pack/test/fleet_api_integration/apis/epm/install_error_rollback.ts +++ b/x-pack/test/fleet_api_integration/apis/epm/install_error_rollback.ts @@ -30,10 +30,10 @@ export default function (providerContext: FtrProviderContext) { describe('package installation error handling and rollback', async () => { skipIfNoDockerRegistry(providerContext); beforeEach(async () => { - await esArchiver.load('empty_kibana'); + await esArchiver.load('x-pack/test/functional/es_archives/empty_kibana'); }); afterEach(async () => { - await esArchiver.unload('empty_kibana'); + await esArchiver.unload('x-pack/test/functional/es_archives/empty_kibana'); }); it('on a fresh install, it should uninstall a broken package during rollback', async function () { diff --git a/x-pack/test/fleet_api_integration/apis/epm/list.ts b/x-pack/test/fleet_api_integration/apis/epm/list.ts index c482f4012d2e5..931e494798220 100644 --- a/x-pack/test/fleet_api_integration/apis/epm/list.ts +++ b/x-pack/test/fleet_api_integration/apis/epm/list.ts @@ -22,11 +22,11 @@ export default function (providerContext: FtrProviderContext) { describe('EPM - list', async function () { skipIfNoDockerRegistry(providerContext); before(async () => { - await esArchiver.load('fleet/empty_fleet_server'); + await esArchiver.load('x-pack/test/functional/es_archives/fleet/empty_fleet_server'); }); setupFleetAndAgents(providerContext); after(async () => { - await esArchiver.unload('fleet/empty_fleet_server'); + await esArchiver.unload('x-pack/test/functional/es_archives/fleet/empty_fleet_server'); }); describe('list api tests', async () => { diff --git a/x-pack/test/fleet_api_integration/apis/fleet_setup.ts b/x-pack/test/fleet_api_integration/apis/fleet_setup.ts index 762a9f5302cef..c399f53fe8366 100644 --- a/x-pack/test/fleet_api_integration/apis/fleet_setup.ts +++ b/x-pack/test/fleet_api_integration/apis/fleet_setup.ts @@ -18,13 +18,13 @@ export default function (providerContext: FtrProviderContext) { describe('fleet_setup', () => { skipIfNoDockerRegistry(providerContext); before(async () => { - await esArchiver.load('empty_kibana'); - await esArchiver.load('fleet/empty_fleet_server'); + await esArchiver.load('x-pack/test/functional/es_archives/empty_kibana'); + await esArchiver.load('x-pack/test/functional/es_archives/fleet/empty_fleet_server'); }); after(async () => { - await esArchiver.unload('empty_kibana'); - await esArchiver.unload('fleet/empty_fleet_server'); + await esArchiver.unload('x-pack/test/functional/es_archives/empty_kibana'); + await esArchiver.unload('x-pack/test/functional/es_archives/fleet/empty_fleet_server'); }); beforeEach(async () => { try { diff --git a/x-pack/test/fleet_api_integration/apis/outputs/crud.ts b/x-pack/test/fleet_api_integration/apis/outputs/crud.ts index 4238832fb32f0..521675b87fb11 100644 --- a/x-pack/test/fleet_api_integration/apis/outputs/crud.ts +++ b/x-pack/test/fleet_api_integration/apis/outputs/crud.ts @@ -18,7 +18,7 @@ export default function (providerContext: FtrProviderContext) { describe('fleet_output_crud', async function () { skipIfNoDockerRegistry(providerContext); before(async () => { - await esArchiver.load('fleet/empty_fleet_server'); + await esArchiver.load('x-pack/test/functional/es_archives/fleet/empty_fleet_server'); }); setupFleetAndAgents(providerContext); @@ -36,7 +36,7 @@ export default function (providerContext: FtrProviderContext) { }); after(async () => { - await esArchiver.unload('fleet/empty_fleet_server'); + await esArchiver.unload('x-pack/test/functional/es_archives/fleet/empty_fleet_server'); }); it('GET /outputs should list the default output', async () => { diff --git a/x-pack/test/fleet_api_integration/apis/package_policy/create.ts b/x-pack/test/fleet_api_integration/apis/package_policy/create.ts index 27c5328b3ab08..6a0d46a605386 100644 --- a/x-pack/test/fleet_api_integration/apis/package_policy/create.ts +++ b/x-pack/test/fleet_api_integration/apis/package_policy/create.ts @@ -20,12 +20,16 @@ export default function (providerContext: FtrProviderContext) { skipIfNoDockerRegistry(providerContext); let agentPolicyId: string; before(async () => { - await getService('esArchiver').load('empty_kibana'); - await getService('esArchiver').load('fleet/empty_fleet_server'); + await getService('esArchiver').load('x-pack/test/functional/es_archives/empty_kibana'); + await getService('esArchiver').load( + 'x-pack/test/functional/es_archives/fleet/empty_fleet_server' + ); }); after(async () => { - await getService('esArchiver').unload('empty_kibana'); - await getService('esArchiver').unload('fleet/empty_fleet_server'); + await getService('esArchiver').unload('x-pack/test/functional/es_archives/empty_kibana'); + await getService('esArchiver').unload( + 'x-pack/test/functional/es_archives/fleet/empty_fleet_server' + ); }); before(async function () { diff --git a/x-pack/test/fleet_api_integration/apis/package_policy/delete.ts b/x-pack/test/fleet_api_integration/apis/package_policy/delete.ts index 5889349f57fa0..5a5fb68a1dbc7 100644 --- a/x-pack/test/fleet_api_integration/apis/package_policy/delete.ts +++ b/x-pack/test/fleet_api_integration/apis/package_policy/delete.ts @@ -21,8 +21,10 @@ export default function (providerContext: FtrProviderContext) { let agentPolicy: any; let packagePolicy: any; before(async () => { - await getService('esArchiver').load('empty_kibana'); - await getService('esArchiver').load('fleet/empty_fleet_server'); + await getService('esArchiver').load('x-pack/test/functional/es_archives/empty_kibana'); + await getService('esArchiver').load( + 'x-pack/test/functional/es_archives/fleet/empty_fleet_server' + ); }); before(async function () { let agentPolicyResponse = await supertest @@ -83,8 +85,10 @@ export default function (providerContext: FtrProviderContext) { .send({ force: true, packagePolicyIds: [packagePolicy.id] }); }); after(async () => { - await getService('esArchiver').unload('empty_kibana'); - await getService('esArchiver').unload('fleet/empty_fleet_server'); + await getService('esArchiver').unload('x-pack/test/functional/es_archives/empty_kibana'); + await getService('esArchiver').unload( + 'x-pack/test/functional/es_archives/fleet/empty_fleet_server' + ); }); it('should fail on hosted agent policies', async function () { diff --git a/x-pack/test/fleet_api_integration/apis/package_policy/get.ts b/x-pack/test/fleet_api_integration/apis/package_policy/get.ts index b2d51cca75d4d..1e90ab76666fe 100644 --- a/x-pack/test/fleet_api_integration/apis/package_policy/get.ts +++ b/x-pack/test/fleet_api_integration/apis/package_policy/get.ts @@ -23,8 +23,10 @@ export default function (providerContext: FtrProviderContext) { let agentPolicyId: string; let packagePolicyId: string; before(async () => { - await getService('esArchiver').load('empty_kibana'); - await getService('esArchiver').load('fleet/empty_fleet_server'); + await getService('esArchiver').load('x-pack/test/functional/es_archives/empty_kibana'); + await getService('esArchiver').load( + 'x-pack/test/functional/es_archives/fleet/empty_fleet_server' + ); }); before(async function () { @@ -78,8 +80,10 @@ export default function (providerContext: FtrProviderContext) { .expect(200); }); after(async () => { - await getService('esArchiver').unload('fleet/empty_fleet_server'); - await getService('esArchiver').unload('empty_kibana'); + await getService('esArchiver').unload( + 'x-pack/test/functional/es_archives/fleet/empty_fleet_server' + ); + await getService('esArchiver').unload('x-pack/test/functional/es_archives/empty_kibana'); }); it('should succeed with a valid id', async function () { await supertest.get(`/api/fleet/package_policies/${packagePolicyId}`).expect(200); diff --git a/x-pack/test/fleet_api_integration/apis/package_policy/update.ts b/x-pack/test/fleet_api_integration/apis/package_policy/update.ts index 0956b6b0f515f..315ca276c393f 100644 --- a/x-pack/test/fleet_api_integration/apis/package_policy/update.ts +++ b/x-pack/test/fleet_api_integration/apis/package_policy/update.ts @@ -24,8 +24,10 @@ export default function (providerContext: FtrProviderContext) { let packagePolicyId: string; let packagePolicyId2: string; before(async () => { - await getService('esArchiver').load('empty_kibana'); - await getService('esArchiver').load('fleet/empty_fleet_server'); + await getService('esArchiver').load('x-pack/test/functional/es_archives/empty_kibana'); + await getService('esArchiver').load( + 'x-pack/test/functional/es_archives/fleet/empty_fleet_server' + ); }); before(async function () { @@ -110,8 +112,10 @@ export default function (providerContext: FtrProviderContext) { }); after(async () => { - await getService('esArchiver').unload('fleet/empty_fleet_server'); - await getService('esArchiver').unload('empty_kibana'); + await getService('esArchiver').unload( + 'x-pack/test/functional/es_archives/fleet/empty_fleet_server' + ); + await getService('esArchiver').unload('x-pack/test/functional/es_archives/empty_kibana'); }); it('should work with valid values on "regular" policies', async function () { diff --git a/x-pack/test/fleet_api_integration/apis/preconfiguration/preconfiguration.ts b/x-pack/test/fleet_api_integration/apis/preconfiguration/preconfiguration.ts index 7d9534cae364a..7fc784ee11af1 100644 --- a/x-pack/test/fleet_api_integration/apis/preconfiguration/preconfiguration.ts +++ b/x-pack/test/fleet_api_integration/apis/preconfiguration/preconfiguration.ts @@ -21,13 +21,17 @@ export default function (providerContext: FtrProviderContext) { describe('Preconfiguration', async () => { skipIfNoDockerRegistry(providerContext); before(async () => { - await getService('esArchiver').load('empty_kibana'); - await getService('esArchiver').load('fleet/empty_fleet_server'); + await getService('esArchiver').load('x-pack/test/functional/es_archives/empty_kibana'); + await getService('esArchiver').load( + 'x-pack/test/functional/es_archives/fleet/empty_fleet_server' + ); }); after(async () => { - await getService('esArchiver').unload('fleet/empty_fleet_server'); - await getService('esArchiver').unload('empty_kibana'); + await getService('esArchiver').unload( + 'x-pack/test/functional/es_archives/fleet/empty_fleet_server' + ); + await getService('esArchiver').unload('x-pack/test/functional/es_archives/empty_kibana'); }); // Basic health check for the API; functionality is covered by the unit tests diff --git a/x-pack/test/fleet_api_integration/apis/service_tokens.ts b/x-pack/test/fleet_api_integration/apis/service_tokens.ts index ddd4aed30f76b..0399778b2e13c 100644 --- a/x-pack/test/fleet_api_integration/apis/service_tokens.ts +++ b/x-pack/test/fleet_api_integration/apis/service_tokens.ts @@ -16,11 +16,11 @@ export default function (providerContext: FtrProviderContext) { describe('fleet_service_tokens', async () => { before(async () => { - await esArchiver.load('empty_kibana'); + await esArchiver.load('x-pack/test/functional/es_archives/empty_kibana'); }); after(async () => { - await esArchiver.unload('empty_kibana'); + await esArchiver.unload('x-pack/test/functional/es_archives/empty_kibana'); }); describe('POST /api/fleet/service-tokens', () => { diff --git a/x-pack/test/fleet_api_integration/apis/settings/update.ts b/x-pack/test/fleet_api_integration/apis/settings/update.ts index 31fcb74627915..1db0fc7e39441 100644 --- a/x-pack/test/fleet_api_integration/apis/settings/update.ts +++ b/x-pack/test/fleet_api_integration/apis/settings/update.ts @@ -21,7 +21,7 @@ export default function (providerContext: FtrProviderContext) { describe('Settings - update', async function () { skipIfNoDockerRegistry(providerContext); before(async () => { - await esArchiver.load('fleet/empty_fleet_server'); + await esArchiver.load('x-pack/test/functional/es_archives/fleet/empty_fleet_server'); }); setupFleetAndAgents(providerContext); @@ -36,7 +36,7 @@ export default function (providerContext: FtrProviderContext) { await Promise.all(deletedPromises); }); after(async () => { - await esArchiver.unload('fleet/empty_fleet_server'); + await esArchiver.unload('x-pack/test/functional/es_archives/fleet/empty_fleet_server'); }); it('should explicitly set port on fleet_server_hosts', async function () { diff --git a/x-pack/test/fleet_api_integration/config.ts b/x-pack/test/fleet_api_integration/config.ts index cd47da8ef5fc3..e17c5cbee9a46 100644 --- a/x-pack/test/fleet_api_integration/config.ts +++ b/x-pack/test/fleet_api_integration/config.ts @@ -50,7 +50,6 @@ export default async function ({ readConfigFile }: FtrConfigProviderContext) { waitForLogLine: 'package manifests loaded', }, }), - esArchiver: xPackAPITestsConfig.get('esArchiver'), services: { ...xPackAPITestsConfig.get('services'), }, diff --git a/x-pack/test/functional/apps/advanced_settings/feature_controls/advanced_settings_security.ts b/x-pack/test/functional/apps/advanced_settings/feature_controls/advanced_settings_security.ts index b93e20ffeed6e..ebe76ee52499b 100644 --- a/x-pack/test/functional/apps/advanced_settings/feature_controls/advanced_settings_security.ts +++ b/x-pack/test/functional/apps/advanced_settings/feature_controls/advanced_settings_security.ts @@ -19,11 +19,11 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { describe('security feature controls', () => { before(async () => { - await esArchiver.load('empty_kibana'); + await esArchiver.load('x-pack/test/functional/es_archives/empty_kibana'); }); after(async () => { - await esArchiver.unload('empty_kibana'); + await esArchiver.unload('x-pack/test/functional/es_archives/empty_kibana'); }); describe('global advanced_settings all privileges', () => { diff --git a/x-pack/test/functional/apps/advanced_settings/feature_controls/advanced_settings_spaces.ts b/x-pack/test/functional/apps/advanced_settings/feature_controls/advanced_settings_spaces.ts index dae03df74f26a..41a03b36d3c43 100644 --- a/x-pack/test/functional/apps/advanced_settings/feature_controls/advanced_settings_spaces.ts +++ b/x-pack/test/functional/apps/advanced_settings/feature_controls/advanced_settings_spaces.ts @@ -18,14 +18,14 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { describe('spaces feature controls', () => { before(async () => { - await esArchiver.loadIfNeeded('logstash_functional'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/logstash_functional'); }); describe('space with no features disabled', () => { before(async () => { // we need to load the following in every situation as deleting // a space deletes all of the associated saved objects - await esArchiver.load('empty_kibana'); + await esArchiver.load('x-pack/test/functional/es_archives/empty_kibana'); await spacesService.create({ id: 'custom_space', @@ -36,7 +36,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { after(async () => { await spacesService.delete('custom_space'); - await esArchiver.unload('empty_kibana'); + await esArchiver.unload('x-pack/test/functional/es_archives/empty_kibana'); }); it('shows Management navlink', async () => { @@ -64,7 +64,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { before(async () => { // we need to load the following in every situation as deleting // a space deletes all of the associated saved objects - await esArchiver.load('empty_kibana'); + await esArchiver.load('x-pack/test/functional/es_archives/empty_kibana'); await spacesService.create({ id: 'custom_space', name: 'custom_space', @@ -74,7 +74,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { after(async () => { await spacesService.delete('custom_space'); - await esArchiver.unload('empty_kibana'); + await esArchiver.unload('x-pack/test/functional/es_archives/empty_kibana'); }); it(`redirects to management home`, async () => { diff --git a/x-pack/test/functional/apps/api_keys/feature_controls/api_keys_security.ts b/x-pack/test/functional/apps/api_keys/feature_controls/api_keys_security.ts index aed7fc63c7b1b..9e25ca1d79f9b 100644 --- a/x-pack/test/functional/apps/api_keys/feature_controls/api_keys_security.ts +++ b/x-pack/test/functional/apps/api_keys/feature_controls/api_keys_security.ts @@ -17,12 +17,12 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { describe('security', () => { before(async () => { - await esArchiver.load('empty_kibana'); + await esArchiver.load('x-pack/test/functional/es_archives/empty_kibana'); await PageObjects.common.navigateToApp('home'); }); after(async () => { - await esArchiver.unload('empty_kibana'); + await esArchiver.unload('x-pack/test/functional/es_archives/empty_kibana'); }); describe('global all privileges (aka kibana_admin)', () => { diff --git a/x-pack/test/functional/apps/apm/feature_controls/apm_security.ts b/x-pack/test/functional/apps/apm/feature_controls/apm_security.ts index 5952c4641344c..7cfdf87aaf9ea 100644 --- a/x-pack/test/functional/apps/apm/feature_controls/apm_security.ts +++ b/x-pack/test/functional/apps/apm/feature_controls/apm_security.ts @@ -18,7 +18,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { describe('security', () => { before(async () => { - await esArchiver.load('empty_kibana'); + await esArchiver.load('x-pack/test/functional/es_archives/empty_kibana'); // ensure we're logged out so we can login as the appropriate users await PageObjects.security.forceLogout(); }); diff --git a/x-pack/test/functional/apps/canvas/custom_elements.ts b/x-pack/test/functional/apps/canvas/custom_elements.ts index c5b74f1be2b45..026cfbb2f037c 100644 --- a/x-pack/test/functional/apps/canvas/custom_elements.ts +++ b/x-pack/test/functional/apps/canvas/custom_elements.ts @@ -24,7 +24,7 @@ export default function canvasCustomElementTest({ this.tags('skipFirefox'); before(async () => { - await esArchiver.load('canvas/default'); + await esArchiver.load('x-pack/test/functional/es_archives/canvas/default'); // open canvas home await PageObjects.common.navigateToApp('canvas'); // load test workpad diff --git a/x-pack/test/functional/apps/canvas/expression.ts b/x-pack/test/functional/apps/canvas/expression.ts index b2d2da0553ac5..3e2c20d4dc7da 100644 --- a/x-pack/test/functional/apps/canvas/expression.ts +++ b/x-pack/test/functional/apps/canvas/expression.ts @@ -21,7 +21,7 @@ export default function canvasExpressionTest({ getService, getPageObjects }: Ftr this.tags('skipFirefox'); before(async () => { - await esArchiver.load('canvas/default'); + await esArchiver.load('x-pack/test/functional/es_archives/canvas/default'); // load test workpad await PageObjects.common.navigateToApp('canvas', { hash: '/workpad/workpad-1705f884-6224-47de-ba49-ca224fe6ec31/page/1', diff --git a/x-pack/test/functional/apps/canvas/feature_controls/canvas_security.ts b/x-pack/test/functional/apps/canvas/feature_controls/canvas_security.ts index cb2f3f72a8312..cc6d1b8720462 100644 --- a/x-pack/test/functional/apps/canvas/feature_controls/canvas_security.ts +++ b/x-pack/test/functional/apps/canvas/feature_controls/canvas_security.ts @@ -19,11 +19,11 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { describe('security feature controls', function () { this.tags(['skipFirefox']); before(async () => { - await esArchiver.load('canvas/default'); + await esArchiver.load('x-pack/test/functional/es_archives/canvas/default'); }); after(async () => { - await esArchiver.unload('canvas/default'); + await esArchiver.unload('x-pack/test/functional/es_archives/canvas/default'); }); describe('global canvas all privileges', () => { diff --git a/x-pack/test/functional/apps/canvas/feature_controls/canvas_spaces.ts b/x-pack/test/functional/apps/canvas/feature_controls/canvas_spaces.ts index 8c6f7d5fee3a4..3e6c7b9b3080a 100644 --- a/x-pack/test/functional/apps/canvas/feature_controls/canvas_spaces.ts +++ b/x-pack/test/functional/apps/canvas/feature_controls/canvas_spaces.ts @@ -18,14 +18,14 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { describe('spaces feature controls', function () { this.tags(['skipFirefox']); before(async () => { - await esArchiver.loadIfNeeded('logstash_functional'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/logstash_functional'); }); describe('space with no features disabled', () => { before(async () => { // we need to load the following in every situation as deleting // a space deletes all of the associated saved objects - await esArchiver.load('canvas/default'); + await esArchiver.load('x-pack/test/functional/es_archives/canvas/default'); await spacesService.create({ id: 'custom_space', @@ -36,7 +36,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { after(async () => { await spacesService.delete('custom_space'); - await esArchiver.unload('canvas/default'); + await esArchiver.unload('x-pack/test/functional/es_archives/canvas/default'); }); it('shows canvas navlink', async () => { @@ -84,7 +84,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { before(async () => { // we need to load the following in every situation as deleting // a space deletes all of the associated saved objects - await esArchiver.load('spaces/disabled_features'); + await esArchiver.load('x-pack/test/functional/es_archives/spaces/disabled_features'); await spacesService.create({ id: 'custom_space', name: 'custom_space', @@ -94,7 +94,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { after(async () => { await spacesService.delete('custom_space'); - await esArchiver.unload('spaces/disabled_features'); + await esArchiver.unload('x-pack/test/functional/es_archives/spaces/disabled_features'); }); it(`doesn't show canvas navlink`, async () => { diff --git a/x-pack/test/functional/apps/canvas/filters.ts b/x-pack/test/functional/apps/canvas/filters.ts index 26d9817a8108c..5a82aaa24d64b 100644 --- a/x-pack/test/functional/apps/canvas/filters.ts +++ b/x-pack/test/functional/apps/canvas/filters.ts @@ -21,7 +21,7 @@ export default function canvasFiltersTest({ getService, getPageObjects }: FtrPro this.tags('skipFirefox'); before(async () => { - await esArchiver.load('canvas/filter'); + await esArchiver.load('x-pack/test/functional/es_archives/canvas/filter'); // load test workpad await PageObjects.common.navigateToApp('canvas', { hash: '/workpad/workpad-b5618217-56d2-47fa-b756-1be2306cda68/page/1', diff --git a/x-pack/test/functional/apps/canvas/index.js b/x-pack/test/functional/apps/canvas/index.js index 6796e439ce24f..bf51a326d460d 100644 --- a/x-pack/test/functional/apps/canvas/index.js +++ b/x-pack/test/functional/apps/canvas/index.js @@ -13,7 +13,7 @@ export default function canvasApp({ loadTestFile, getService }) { before(async () => { // init data await security.testUser.setRoles(['test_logstash_reader', 'global_canvas_all']); - await esArchiver.loadIfNeeded('logstash_functional'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/logstash_functional'); }); after(async () => { diff --git a/x-pack/test/functional/apps/canvas/lens.ts b/x-pack/test/functional/apps/canvas/lens.ts index 3e5db81a6cae5..ed1bf246fae65 100644 --- a/x-pack/test/functional/apps/canvas/lens.ts +++ b/x-pack/test/functional/apps/canvas/lens.ts @@ -13,7 +13,7 @@ export default function canvasLensTest({ getService, getPageObjects }: FtrProvid describe('lens in canvas', function () { before(async () => { - await esArchiver.load('canvas/lens'); + await esArchiver.load('x-pack/test/functional/es_archives/canvas/lens'); // open canvas home await PageObjects.common.navigateToApp('canvas'); // load test workpad diff --git a/x-pack/test/functional/apps/canvas/reports.ts b/x-pack/test/functional/apps/canvas/reports.ts index 7edbca783d928..2c5a027df21aa 100644 --- a/x-pack/test/functional/apps/canvas/reports.ts +++ b/x-pack/test/functional/apps/canvas/reports.ts @@ -31,11 +31,11 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { ], }); await security.testUser.setRoles(['kibana_admin', 'test_reporting_user']); - await esArchiver.load('canvas/reports'); + await esArchiver.load('x-pack/test/functional/es_archives/canvas/reports'); await browser.setWindowSize(1600, 850); }); after('clean up archives', async () => { - await esArchiver.unload('canvas/reports'); + await esArchiver.unload('x-pack/test/functional/es_archives/canvas/reports'); await es.deleteByQuery({ index: '.reporting-*', refresh: true, diff --git a/x-pack/test/functional/apps/canvas/smoke_test.js b/x-pack/test/functional/apps/canvas/smoke_test.js index 58f811c0812a4..5280ad0118fba 100644 --- a/x-pack/test/functional/apps/canvas/smoke_test.js +++ b/x-pack/test/functional/apps/canvas/smoke_test.js @@ -21,7 +21,7 @@ export default function canvasSmokeTest({ getService, getPageObjects }) { const testWorkpadId = 'workpad-1705f884-6224-47de-ba49-ca224fe6ec31'; before(async () => { - await esArchiver.load('canvas/default'); + await esArchiver.load('x-pack/test/functional/es_archives/canvas/default'); await PageObjects.common.navigateToApp('canvas'); }); diff --git a/x-pack/test/functional/apps/cross_cluster_replication/feature_controls/ccr_security.ts b/x-pack/test/functional/apps/cross_cluster_replication/feature_controls/ccr_security.ts index 421814f550e68..9c5b20b3f2f0f 100644 --- a/x-pack/test/functional/apps/cross_cluster_replication/feature_controls/ccr_security.ts +++ b/x-pack/test/functional/apps/cross_cluster_replication/feature_controls/ccr_security.ts @@ -17,12 +17,12 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { describe('security', () => { before(async () => { - await esArchiver.load('empty_kibana'); + await esArchiver.load('x-pack/test/functional/es_archives/empty_kibana'); await PageObjects.common.navigateToApp('home'); }); after(async () => { - await esArchiver.unload('empty_kibana'); + await esArchiver.unload('x-pack/test/functional/es_archives/empty_kibana'); }); describe('global all privileges (aka kibana_admin)', () => { diff --git a/x-pack/test/functional/apps/dashboard/dashboard_lens_by_value.ts b/x-pack/test/functional/apps/dashboard/dashboard_lens_by_value.ts index 865f4c64f0f1a..b1d7c1194e7bc 100644 --- a/x-pack/test/functional/apps/dashboard/dashboard_lens_by_value.ts +++ b/x-pack/test/functional/apps/dashboard/dashboard_lens_by_value.ts @@ -18,8 +18,8 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { describe('dashboard lens by value', function () { before(async () => { - await esArchiver.loadIfNeeded('logstash_functional'); - await esArchiver.loadIfNeeded('lens/basic'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/logstash_functional'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/lens/basic'); await PageObjects.common.navigateToApp('dashboard'); await PageObjects.dashboard.preserveCrossAppState(); await PageObjects.dashboard.clickNewDashboard(); diff --git a/x-pack/test/functional/apps/dashboard/dashboard_maps_by_value.ts b/x-pack/test/functional/apps/dashboard/dashboard_maps_by_value.ts index 487dc90e1877e..043acf90bb893 100644 --- a/x-pack/test/functional/apps/dashboard/dashboard_maps_by_value.ts +++ b/x-pack/test/functional/apps/dashboard/dashboard_maps_by_value.ts @@ -76,8 +76,8 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { describe('dashboard maps by value', function () { before(async () => { - await esArchiver.loadIfNeeded('logstash_functional'); - await esArchiver.loadIfNeeded('lens/basic'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/logstash_functional'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/lens/basic'); }); describe('adding a map by value', () => { diff --git a/x-pack/test/functional/apps/dashboard/drilldowns/index.ts b/x-pack/test/functional/apps/dashboard/drilldowns/index.ts index fa24a4ba6a19e..fac0c355ce4d0 100644 --- a/x-pack/test/functional/apps/dashboard/drilldowns/index.ts +++ b/x-pack/test/functional/apps/dashboard/drilldowns/index.ts @@ -15,13 +15,13 @@ export default function ({ loadTestFile, getService }: FtrProviderContext) { this.tags(['skipFirefox']); before(async () => { - await esArchiver.loadIfNeeded('logstash_functional'); - await esArchiver.load('dashboard/drilldowns'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/logstash_functional'); + await esArchiver.load('x-pack/test/functional/es_archives/dashboard/drilldowns'); await kibanaServer.uiSettings.replace({ defaultIndex: 'logstash-*' }); }); after(async () => { - await esArchiver.unload('dashboard/drilldowns'); + await esArchiver.unload('x-pack/test/functional/es_archives/dashboard/drilldowns'); }); loadTestFile(require.resolve('./dashboard_to_dashboard_drilldown')); diff --git a/x-pack/test/functional/apps/dashboard/feature_controls/dashboard_security.ts b/x-pack/test/functional/apps/dashboard/feature_controls/dashboard_security.ts index 94a0eedd07c54..70f6fc49f0063 100644 --- a/x-pack/test/functional/apps/dashboard/feature_controls/dashboard_security.ts +++ b/x-pack/test/functional/apps/dashboard/feature_controls/dashboard_security.ts @@ -33,15 +33,19 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { describe('dashboard feature controls security', () => { before(async () => { - await esArchiver.load('dashboard/feature_controls/security'); - await esArchiver.loadIfNeeded('logstash_functional'); + await esArchiver.load( + 'x-pack/test/functional/es_archives/dashboard/feature_controls/security' + ); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/logstash_functional'); // ensure we're logged out so we can login as the appropriate users await PageObjects.security.forceLogout(); }); after(async () => { - await esArchiver.unload('dashboard/feature_controls/security'); + await esArchiver.unload( + 'x-pack/test/functional/es_archives/dashboard/feature_controls/security' + ); // logout, so the other tests don't accidentally run as the custom users we're testing below await PageObjects.security.forceLogout(); diff --git a/x-pack/test/functional/apps/dashboard/feature_controls/dashboard_spaces.ts b/x-pack/test/functional/apps/dashboard/feature_controls/dashboard_spaces.ts index eb92db32abd73..2cab9263b5f49 100644 --- a/x-pack/test/functional/apps/dashboard/feature_controls/dashboard_spaces.ts +++ b/x-pack/test/functional/apps/dashboard/feature_controls/dashboard_spaces.ts @@ -22,14 +22,16 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { describe('spaces', () => { before(async () => { - await esArchiver.loadIfNeeded('logstash_functional'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/logstash_functional'); }); describe('space with no features disabled', () => { before(async () => { // we need to load the following in every situation as deleting // a space deletes all of the associated saved objects - await esArchiver.load('dashboard/feature_controls/spaces'); + await esArchiver.load( + 'x-pack/test/functional/es_archives/dashboard/feature_controls/spaces' + ); await spacesService.create({ id: 'custom_space', name: 'custom_space', @@ -39,7 +41,9 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { after(async () => { await spacesService.delete('custom_space'); - await esArchiver.unload('dashboard/feature_controls/spaces'); + await esArchiver.unload( + 'x-pack/test/functional/es_archives/dashboard/feature_controls/spaces' + ); }); it('shows dashboard navlink', async () => { @@ -101,7 +105,9 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { before(async () => { // we need to load the following in every situation as deleting // a space deletes all of the associated saved objects - await esArchiver.load('dashboard/feature_controls/spaces'); + await esArchiver.load( + 'x-pack/test/functional/es_archives/dashboard/feature_controls/spaces' + ); await spacesService.create({ id: 'custom_space', name: 'custom_space', @@ -111,7 +117,9 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { after(async () => { await spacesService.delete('custom_space'); - await esArchiver.unload('dashboard/feature_controls/spaces'); + await esArchiver.unload( + 'x-pack/test/functional/es_archives/dashboard/feature_controls/spaces' + ); }); it(`doesn't show dashboard navlink`, async () => { diff --git a/x-pack/test/functional/apps/dashboard/feature_controls/time_to_visualize_security.ts b/x-pack/test/functional/apps/dashboard/feature_controls/time_to_visualize_security.ts index 730c00a8d5e4f..1a5f8c34a183c 100644 --- a/x-pack/test/functional/apps/dashboard/feature_controls/time_to_visualize_security.ts +++ b/x-pack/test/functional/apps/dashboard/feature_controls/time_to_visualize_security.ts @@ -31,8 +31,10 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { describe('dashboard time to visualize security', () => { before(async () => { - await esArchiver.load('dashboard/feature_controls/security'); - await esArchiver.loadIfNeeded('logstash_functional'); + await esArchiver.load( + 'x-pack/test/functional/es_archives/dashboard/feature_controls/security' + ); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/logstash_functional'); // ensure we're logged out so we can login as the appropriate users await PageObjects.security.forceLogout(); @@ -71,7 +73,9 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { await security.role.delete('dashboard_write_vis_read'); await security.user.delete('dashboard_write_vis_read_user'); - await esArchiver.unload('dashboard/feature_controls/security'); + await esArchiver.unload( + 'x-pack/test/functional/es_archives/dashboard/feature_controls/security' + ); // logout, so the other tests don't accidentally run as the custom users we're testing below await PageObjects.security.forceLogout(); diff --git a/x-pack/test/functional/apps/dashboard/preserve_url.ts b/x-pack/test/functional/apps/dashboard/preserve_url.ts index 2eb51a07c5d69..e391a8b346f6f 100644 --- a/x-pack/test/functional/apps/dashboard/preserve_url.ts +++ b/x-pack/test/functional/apps/dashboard/preserve_url.ts @@ -16,11 +16,11 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('preserve url', function () { before(async function () { - await esArchiver.load('spaces/multi_space'); + await esArchiver.load('x-pack/test/functional/es_archives/spaces/multi_space'); }); after(function () { - return esArchiver.unload('spaces/multi_space'); + return esArchiver.unload('x-pack/test/functional/es_archives/spaces/multi_space'); }); it('goes back to last opened url', async function () { diff --git a/x-pack/test/functional/apps/dashboard/reporting/download_csv.ts b/x-pack/test/functional/apps/dashboard/reporting/download_csv.ts index d4a909f6a0474..e736fe08eba99 100644 --- a/x-pack/test/functional/apps/dashboard/reporting/download_csv.ts +++ b/x-pack/test/functional/apps/dashboard/reporting/download_csv.ts @@ -66,12 +66,12 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('E-Commerce Data', () => { before(async () => { - await esArchiver.load('reporting/ecommerce'); - await esArchiver.load('reporting/ecommerce_kibana'); + await esArchiver.load('x-pack/test/functional/es_archives/reporting/ecommerce'); + await esArchiver.load('x-pack/test/functional/es_archives/reporting/ecommerce_kibana'); }); after(async () => { - await esArchiver.unload('reporting/ecommerce'); - await esArchiver.unload('reporting/ecommerce_kibana'); + await esArchiver.unload('x-pack/test/functional/es_archives/reporting/ecommerce'); + await esArchiver.unload('x-pack/test/functional/es_archives/reporting/ecommerce_kibana'); }); it('Download CSV export of a saved search panel', async function () { @@ -116,10 +116,10 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('Field Formatters and Scripted Fields', () => { before(async () => { - await esArchiver.load('reporting/hugedata'); + await esArchiver.load('x-pack/test/functional/es_archives/reporting/hugedata'); }); after(async () => { - await esArchiver.unload('reporting/hugedata'); + await esArchiver.unload('x-pack/test/functional/es_archives/reporting/hugedata'); }); it('Download CSV export of a saved search panel', async () => { diff --git a/x-pack/test/functional/apps/dashboard/reporting/screenshots.ts b/x-pack/test/functional/apps/dashboard/reporting/screenshots.ts index 94de5999a6a07..7c5e4b2d12baa 100644 --- a/x-pack/test/functional/apps/dashboard/reporting/screenshots.ts +++ b/x-pack/test/functional/apps/dashboard/reporting/screenshots.ts @@ -30,8 +30,10 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { describe('Dashboard Reporting Screenshots', () => { before('initialize tests', async () => { - await esArchiver.loadIfNeeded('reporting/ecommerce'); - await esArchiver.loadIfNeeded('reporting/ecommerce_kibana'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/reporting/ecommerce'); + await esArchiver.loadIfNeeded( + 'x-pack/test/functional/es_archives/reporting/ecommerce_kibana' + ); await browser.setWindowSize(1600, 850); await security.role.create('test_reporting_user', { @@ -58,8 +60,8 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { await security.testUser.setRoles(['test_reporting_user']); }); after('clean up archives', async () => { - await esArchiver.unload('reporting/ecommerce'); - await esArchiver.unload('reporting/ecommerce_kibana'); + await esArchiver.unload('x-pack/test/functional/es_archives/reporting/ecommerce'); + await esArchiver.unload('x-pack/test/functional/es_archives/reporting/ecommerce_kibana'); await es.deleteByQuery({ index: '.reporting-*', refresh: true, diff --git a/x-pack/test/functional/apps/dashboard/sync_colors.ts b/x-pack/test/functional/apps/dashboard/sync_colors.ts index 3a135fb41a58d..2fcc1cf5614fb 100644 --- a/x-pack/test/functional/apps/dashboard/sync_colors.ts +++ b/x-pack/test/functional/apps/dashboard/sync_colors.ts @@ -36,13 +36,13 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { // FLAKY: https://github.com/elastic/kibana/issues/97403 describe.skip('sync colors', function () { before(async function () { - await esArchiver.loadIfNeeded('logstash_functional'); - await esArchiver.loadIfNeeded('lens/basic'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/logstash_functional'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/lens/basic'); }); after(async function () { - await esArchiver.unload('logstash_functional'); - await esArchiver.unload('lens/basic'); + await esArchiver.unload('x-pack/test/functional/es_archives/logstash_functional'); + await esArchiver.unload('x-pack/test/functional/es_archives/lens/basic'); }); it('should sync colors on dashboard by default', async function () { diff --git a/x-pack/test/functional/apps/dashboard_mode/dashboard_empty_screen.js b/x-pack/test/functional/apps/dashboard_mode/dashboard_empty_screen.js index 37311de534195..96c40bc4cf409 100644 --- a/x-pack/test/functional/apps/dashboard_mode/dashboard_empty_screen.js +++ b/x-pack/test/functional/apps/dashboard_mode/dashboard_empty_screen.js @@ -15,8 +15,8 @@ export default function ({ getPageObjects, getService }) { describe('empty dashboard', function () { before(async () => { - await esArchiver.loadIfNeeded('logstash_functional'); - await esArchiver.loadIfNeeded('lens/basic'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/logstash_functional'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/lens/basic'); await PageObjects.common.navigateToApp('dashboard'); await PageObjects.dashboard.preserveCrossAppState(); await PageObjects.dashboard.clickNewDashboard(); diff --git a/x-pack/test/functional/apps/dashboard_mode/dashboard_view_mode.js b/x-pack/test/functional/apps/dashboard_mode/dashboard_view_mode.js index 51e41fe760ddd..b3f15e2dffa0b 100644 --- a/x-pack/test/functional/apps/dashboard_mode/dashboard_view_mode.js +++ b/x-pack/test/functional/apps/dashboard_mode/dashboard_view_mode.js @@ -37,8 +37,8 @@ export default function ({ getService, getPageObjects }) { before('initialize tests', async () => { log.debug('Dashboard View Mode:initTests'); - await esArchiver.loadIfNeeded('logstash_functional'); - await esArchiver.load('dashboard_view_mode'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/logstash_functional'); + await esArchiver.load('x-pack/test/functional/es_archives/dashboard_view_mode'); await kibanaServer.uiSettings.replace({ defaultIndex: 'logstash-*' }); await browser.setWindowSize(1600, 1000); diff --git a/x-pack/test/functional/apps/dev_tools/feature_controls/dev_tools_security.ts b/x-pack/test/functional/apps/dev_tools/feature_controls/dev_tools_security.ts index 9f081983a2965..5b80f6589281a 100644 --- a/x-pack/test/functional/apps/dev_tools/feature_controls/dev_tools_security.ts +++ b/x-pack/test/functional/apps/dev_tools/feature_controls/dev_tools_security.ts @@ -19,7 +19,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { describe('security', () => { before(async () => { - await esArchiver.load('empty_kibana'); + await esArchiver.load('x-pack/test/functional/es_archives/empty_kibana'); // ensure we're logged out so we can login as the appropriate users await PageObjects.security.forceLogout(); diff --git a/x-pack/test/functional/apps/dev_tools/feature_controls/dev_tools_spaces.ts b/x-pack/test/functional/apps/dev_tools/feature_controls/dev_tools_spaces.ts index 58bf5d12c19a5..2aa9a4de922f0 100644 --- a/x-pack/test/functional/apps/dev_tools/feature_controls/dev_tools_spaces.ts +++ b/x-pack/test/functional/apps/dev_tools/feature_controls/dev_tools_spaces.ts @@ -18,11 +18,11 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { describe('spaces', () => { before(async () => { - await esArchiver.load('empty_kibana'); + await esArchiver.load('x-pack/test/functional/es_archives/empty_kibana'); }); after(async () => { - await esArchiver.unload('empty_kibana'); + await esArchiver.unload('x-pack/test/functional/es_archives/empty_kibana'); }); describe('space with no features disabled', () => { diff --git a/x-pack/test/functional/apps/discover/async_scripted_fields.js b/x-pack/test/functional/apps/discover/async_scripted_fields.js index 7364f2883bd1a..2c18051405964 100644 --- a/x-pack/test/functional/apps/discover/async_scripted_fields.js +++ b/x-pack/test/functional/apps/discover/async_scripted_fields.js @@ -23,8 +23,10 @@ export default function ({ getService, getPageObjects }) { this.tags(['skipFirefox']); before(async function () { - await esArchiver.load('kibana_scripted_fields_on_logstash'); - await esArchiver.loadIfNeeded('logstash_functional'); + await esArchiver.load( + 'x-pack/test/functional/es_archives/kibana_scripted_fields_on_logstash' + ); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/logstash_functional'); await security.testUser.setRoles(['test_logstash_reader', 'global_discover_read']); // changing the timepicker default here saves us from having to set it in Discover (~8s) await kibanaServer.uiSettings.update({ @@ -36,8 +38,8 @@ export default function ({ getService, getPageObjects }) { after(async function afterAll() { await kibanaServer.uiSettings.replace({}); await kibanaServer.uiSettings.update({}); - await esArchiver.unload('logstash_functional'); - await esArchiver.load('empty_kibana'); + await esArchiver.unload('x-pack/test/functional/es_archives/logstash_functional'); + await esArchiver.load('x-pack/test/functional/es_archives/empty_kibana'); await security.testUser.restoreDefaults(); }); diff --git a/x-pack/test/functional/apps/discover/error_handling.ts b/x-pack/test/functional/apps/discover/error_handling.ts index 751b6b1032950..19cedc8ecb555 100644 --- a/x-pack/test/functional/apps/discover/error_handling.ts +++ b/x-pack/test/functional/apps/discover/error_handling.ts @@ -15,14 +15,14 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('errors', function describeIndexTests() { before(async function () { - await esArchiver.loadIfNeeded('logstash_functional'); - await esArchiver.load('invalid_scripted_field'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/logstash_functional'); + await esArchiver.load('x-pack/test/functional/es_archives/invalid_scripted_field'); await PageObjects.timePicker.setDefaultAbsoluteRangeViaUiSettings(); await PageObjects.common.navigateToApp('discover'); }); after(async function () { - await esArchiver.unload('invalid_scripted_field'); + await esArchiver.unload('x-pack/test/functional/es_archives/invalid_scripted_field'); }); // this is the same test as in OSS but it catches different error message issue in different licences diff --git a/x-pack/test/functional/apps/discover/feature_controls/discover_security.ts b/x-pack/test/functional/apps/discover/feature_controls/discover_security.ts index f44d7c42a23c1..6c3e5b8f01102 100644 --- a/x-pack/test/functional/apps/discover/feature_controls/discover_security.ts +++ b/x-pack/test/functional/apps/discover/feature_controls/discover_security.ts @@ -32,15 +32,19 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { describe('discover feature controls security', () => { before(async () => { - await esArchiver.load('discover/feature_controls/security'); - await esArchiver.loadIfNeeded('logstash_functional'); + await esArchiver.load( + 'x-pack/test/functional/es_archives/discover/feature_controls/security' + ); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/logstash_functional'); // ensure we're logged out so we can login as the appropriate users await PageObjects.security.forceLogout(); }); after(async () => { - await esArchiver.unload('discover/feature_controls/security'); + await esArchiver.unload( + 'x-pack/test/functional/es_archives/discover/feature_controls/security' + ); // logout, so the other tests don't accidentally run as the custom users we're testing below await PageObjects.security.forceLogout(); diff --git a/x-pack/test/functional/apps/discover/feature_controls/discover_spaces.ts b/x-pack/test/functional/apps/discover/feature_controls/discover_spaces.ts index 3c77ff0527827..c05b15905b932 100644 --- a/x-pack/test/functional/apps/discover/feature_controls/discover_spaces.ts +++ b/x-pack/test/functional/apps/discover/feature_controls/discover_spaces.ts @@ -29,14 +29,16 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { describe('spaces', () => { before(async () => { - await esArchiver.loadIfNeeded('logstash_functional'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/logstash_functional'); }); describe('space with no features disabled', () => { before(async () => { // we need to load the following in every situation as deleting // a space deletes all of the associated saved objects - await esArchiver.load('discover/feature_controls/spaces'); + await esArchiver.load( + 'x-pack/test/functional/es_archives/discover/feature_controls/spaces' + ); await spacesService.create({ id: 'custom_space', name: 'custom_space', @@ -46,7 +48,9 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { after(async () => { await spacesService.delete('custom_space'); - await esArchiver.unload('discover/feature_controls/spaces'); + await esArchiver.unload( + 'x-pack/test/functional/es_archives/discover/feature_controls/spaces' + ); }); it('shows discover navlink', async () => { @@ -80,7 +84,9 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { before(async () => { // we need to load the following in every situation as deleting // a space deletes all of the associated saved objects - await esArchiver.load('discover/feature_controls/spaces'); + await esArchiver.load( + 'x-pack/test/functional/es_archives/discover/feature_controls/spaces' + ); await spacesService.create({ id: 'custom_space', name: 'custom_space', @@ -90,7 +96,9 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { after(async () => { await spacesService.delete('custom_space'); - await esArchiver.unload('discover/feature_controls/spaces'); + await esArchiver.unload( + 'x-pack/test/functional/es_archives/discover/feature_controls/spaces' + ); }); it(`doesn't show discover navlink`, async () => { @@ -116,7 +124,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { before(async () => { // we need to load the following in every situation as deleting // a space deletes all of the associated saved objects - await esArchiver.load('spaces/disabled_features'); + await esArchiver.load('x-pack/test/functional/es_archives/spaces/disabled_features'); await spacesService.create({ id: 'custom_space', name: 'custom_space', @@ -126,7 +134,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { after(async () => { await spacesService.delete('custom_space'); - await esArchiver.unload('spaces/disabled_features'); + await esArchiver.unload('x-pack/test/functional/es_archives/spaces/disabled_features'); }); it('Does not show the "visualize" field button', async () => { diff --git a/x-pack/test/functional/apps/discover/preserve_url.ts b/x-pack/test/functional/apps/discover/preserve_url.ts index 649b8a0996106..aa11b99867371 100644 --- a/x-pack/test/functional/apps/discover/preserve_url.ts +++ b/x-pack/test/functional/apps/discover/preserve_url.ts @@ -15,11 +15,11 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('preserve url', function () { before(async function () { - await esArchiver.load('spaces/multi_space'); + await esArchiver.load('x-pack/test/functional/es_archives/spaces/multi_space'); }); after(function () { - return esArchiver.unload('spaces/multi_space'); + return esArchiver.unload('x-pack/test/functional/es_archives/spaces/multi_space'); }); it('goes back to last opened url', async function () { diff --git a/x-pack/test/functional/apps/discover/reporting.ts b/x-pack/test/functional/apps/discover/reporting.ts index 25a7674e47e84..2b424b94b7236 100644 --- a/x-pack/test/functional/apps/discover/reporting.ts +++ b/x-pack/test/functional/apps/discover/reporting.ts @@ -24,13 +24,13 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('Discover CSV Export', () => { before('initialize tests', async () => { log.debug('ReportingPage:initTests'); - await esArchiver.load('reporting/ecommerce'); - await esArchiver.load('reporting/ecommerce_kibana'); + await esArchiver.load('x-pack/test/functional/es_archives/reporting/ecommerce'); + await esArchiver.load('x-pack/test/functional/es_archives/reporting/ecommerce_kibana'); await browser.setWindowSize(1600, 850); }); after('clean up archives', async () => { - await esArchiver.unload('reporting/ecommerce'); - await esArchiver.unload('reporting/ecommerce_kibana'); + await esArchiver.unload('x-pack/test/functional/es_archives/reporting/ecommerce'); + await esArchiver.unload('x-pack/test/functional/es_archives/reporting/ecommerce_kibana'); await es.deleteByQuery({ index: '.reporting-*', refresh: true, @@ -74,7 +74,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('Generate CSV: new search', () => { beforeEach(async () => { - await esArchiver.load('reporting/ecommerce_kibana'); // reload the archive to wipe out changes made by each test + await esArchiver.load('x-pack/test/functional/es_archives/reporting/ecommerce_kibana'); // reload the archive to wipe out changes made by each test await PageObjects.common.navigateToApp('discover'); }); @@ -150,13 +150,13 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }; before(async () => { - await esArchiver.load('reporting/ecommerce'); - await esArchiver.load('reporting/ecommerce_kibana'); + await esArchiver.load('x-pack/test/functional/es_archives/reporting/ecommerce'); + await esArchiver.load('x-pack/test/functional/es_archives/reporting/ecommerce_kibana'); }); after(async () => { - await esArchiver.unload('reporting/ecommerce'); - await esArchiver.unload('reporting/ecommerce_kibana'); + await esArchiver.unload('x-pack/test/functional/es_archives/reporting/ecommerce'); + await esArchiver.unload('x-pack/test/functional/es_archives/reporting/ecommerce_kibana'); }); beforeEach(() => PageObjects.common.navigateToApp('discover')); diff --git a/x-pack/test/functional/apps/discover/saved_searches.ts b/x-pack/test/functional/apps/discover/saved_searches.ts index f811e705e1967..5df9bf9949128 100644 --- a/x-pack/test/functional/apps/discover/saved_searches.ts +++ b/x-pack/test/functional/apps/discover/saved_searches.ts @@ -19,13 +19,13 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('Discover Saved Searches', () => { before('initialize tests', async () => { - await esArchiver.load('reporting/ecommerce'); - await esArchiver.load('reporting/ecommerce_kibana'); + await esArchiver.load('x-pack/test/functional/es_archives/reporting/ecommerce'); + await esArchiver.load('x-pack/test/functional/es_archives/reporting/ecommerce_kibana'); await kibanaServer.uiSettings.update({ 'doc_table:legacy': false }); }); after('clean up archives', async () => { - await esArchiver.unload('reporting/ecommerce'); - await esArchiver.unload('reporting/ecommerce_kibana'); + await esArchiver.unload('x-pack/test/functional/es_archives/reporting/ecommerce'); + await esArchiver.unload('x-pack/test/functional/es_archives/reporting/ecommerce_kibana'); await kibanaServer.uiSettings.unset('doc_table:legacy'); }); diff --git a/x-pack/test/functional/apps/discover/value_suggestions.ts b/x-pack/test/functional/apps/discover/value_suggestions.ts index 087c952040cbf..7d5f500992eb7 100644 --- a/x-pack/test/functional/apps/discover/value_suggestions.ts +++ b/x-pack/test/functional/apps/discover/value_suggestions.ts @@ -15,14 +15,14 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('value suggestions', function describeIndexTests() { before(async function () { - await esArchiver.loadIfNeeded('logstash_functional'); - await esArchiver.load('dashboard/drilldowns'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/logstash_functional'); + await esArchiver.load('x-pack/test/functional/es_archives/dashboard/drilldowns'); await PageObjects.common.navigateToApp('discover'); await PageObjects.timePicker.setDefaultAbsoluteRange(); }); after(async () => { - await esArchiver.unload('dashboard/drilldowns'); + await esArchiver.unload('x-pack/test/functional/es_archives/dashboard/drilldowns'); }); it('show up', async () => { diff --git a/x-pack/test/functional/apps/discover/visualize_field.ts b/x-pack/test/functional/apps/discover/visualize_field.ts index d0d7c25c205e5..650d67f05129c 100644 --- a/x-pack/test/functional/apps/discover/visualize_field.ts +++ b/x-pack/test/functional/apps/discover/visualize_field.ts @@ -30,14 +30,14 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { describe('discover field visualize button', () => { beforeEach(async () => { - await esArchiver.loadIfNeeded('logstash_functional'); - await esArchiver.loadIfNeeded('lens/basic'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/logstash_functional'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/lens/basic'); await PageObjects.common.navigateToApp('discover'); await setDiscoverTimeRange(); }); after(async () => { - await esArchiver.unload('lens/basic'); + await esArchiver.unload('x-pack/test/functional/es_archives/lens/basic'); }); it('shows "visualize" field button', async () => { diff --git a/x-pack/test/functional/apps/graph/feature_controls/graph_security.ts b/x-pack/test/functional/apps/graph/feature_controls/graph_security.ts index 206d0f2dd0f99..cc121dccfb13e 100644 --- a/x-pack/test/functional/apps/graph/feature_controls/graph_security.ts +++ b/x-pack/test/functional/apps/graph/feature_controls/graph_security.ts @@ -18,7 +18,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { describe('security', () => { before(async () => { - await esArchiver.load('empty_kibana'); + await esArchiver.load('x-pack/test/functional/es_archives/empty_kibana'); // ensure we're logged out so we can login as the appropriate users await PageObjects.security.forceLogout(); }); diff --git a/x-pack/test/functional/apps/graph/feature_controls/graph_spaces.ts b/x-pack/test/functional/apps/graph/feature_controls/graph_spaces.ts index 9ef9929a08c33..a1911bf5f02be 100644 --- a/x-pack/test/functional/apps/graph/feature_controls/graph_spaces.ts +++ b/x-pack/test/functional/apps/graph/feature_controls/graph_spaces.ts @@ -17,7 +17,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { describe('spaces', () => { before(async () => { - await esArchiver.load('empty_kibana'); + await esArchiver.load('x-pack/test/functional/es_archives/empty_kibana'); }); describe('space with no features disabled', () => { before(async () => { diff --git a/x-pack/test/functional/apps/graph/graph.ts b/x-pack/test/functional/apps/graph/graph.ts index 172120e2a9e7a..172686692110e 100644 --- a/x-pack/test/functional/apps/graph/graph.ts +++ b/x-pack/test/functional/apps/graph/graph.ts @@ -18,8 +18,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { before(async () => { await browser.setWindowSize(1600, 1000); log.debug('load graph/secrepo data'); - await esArchiver.loadIfNeeded('graph/secrepo'); - await esArchiver.load('empty_kibana'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/graph/secrepo'); + await esArchiver.load('x-pack/test/functional/es_archives/empty_kibana'); await PageObjects.common.navigateToApp('settings'); log.debug('create secrepo index pattern'); await PageObjects.settings.createIndexPattern('secrepo', '@timestamp'); diff --git a/x-pack/test/functional/apps/grok_debugger/grok_debugger.js b/x-pack/test/functional/apps/grok_debugger/grok_debugger.js index 77753641916f6..68cd5820e2a32 100644 --- a/x-pack/test/functional/apps/grok_debugger/grok_debugger.js +++ b/x-pack/test/functional/apps/grok_debugger/grok_debugger.js @@ -15,7 +15,7 @@ export default function ({ getService, getPageObjects }) { describe.skip('grok debugger app', function () { this.tags('includeFirefox'); before(async () => { - await esArchiver.load('empty_kibana'); + await esArchiver.load('x-pack/test/functional/es_archives/empty_kibana'); // Increase window height to ensure "Simulate" button is shown above the // fold. Otherwise it can't be clicked by the browser driver. await browser.setWindowSize(1600, 1000); diff --git a/x-pack/test/functional/apps/home/feature_controls/home_security.ts b/x-pack/test/functional/apps/home/feature_controls/home_security.ts index 9bd6e1f5da094..92d477a92f270 100644 --- a/x-pack/test/functional/apps/home/feature_controls/home_security.ts +++ b/x-pack/test/functional/apps/home/feature_controls/home_security.ts @@ -16,15 +16,19 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { describe('security', () => { before(async () => { - await esArchiver.load('dashboard/feature_controls/security'); - await esArchiver.loadIfNeeded('logstash_functional'); + await esArchiver.load( + 'x-pack/test/functional/es_archives/dashboard/feature_controls/security' + ); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/logstash_functional'); // ensure we're logged out so we can login as the appropriate users await PageObjects.security.forceLogout(); }); after(async () => { - await esArchiver.unload('dashboard/feature_controls/security'); + await esArchiver.unload( + 'x-pack/test/functional/es_archives/dashboard/feature_controls/security' + ); // logout, so the other tests don't accidentally run as the custom users we're testing below await PageObjects.security.forceLogout(); diff --git a/x-pack/test/functional/apps/index_lifecycle_management/feature_controls/ilm_security.ts b/x-pack/test/functional/apps/index_lifecycle_management/feature_controls/ilm_security.ts index f71f7e827980c..a392df276a34c 100644 --- a/x-pack/test/functional/apps/index_lifecycle_management/feature_controls/ilm_security.ts +++ b/x-pack/test/functional/apps/index_lifecycle_management/feature_controls/ilm_security.ts @@ -17,12 +17,12 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { describe('security', () => { before(async () => { - await esArchiver.load('empty_kibana'); + await esArchiver.load('x-pack/test/functional/es_archives/empty_kibana'); await PageObjects.common.navigateToApp('home'); }); after(async () => { - await esArchiver.unload('empty_kibana'); + await esArchiver.unload('x-pack/test/functional/es_archives/empty_kibana'); }); describe('global all privileges (aka kibana_admin)', () => { diff --git a/x-pack/test/functional/apps/index_management/feature_controls/index_management_security.ts b/x-pack/test/functional/apps/index_management/feature_controls/index_management_security.ts index 4b453c519fa07..cb590fe4c3812 100644 --- a/x-pack/test/functional/apps/index_management/feature_controls/index_management_security.ts +++ b/x-pack/test/functional/apps/index_management/feature_controls/index_management_security.ts @@ -17,12 +17,12 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { describe('security', () => { before(async () => { - await esArchiver.load('empty_kibana'); + await esArchiver.load('x-pack/test/functional/es_archives/empty_kibana'); await PageObjects.common.navigateToApp('home'); }); after(async () => { - await esArchiver.unload('empty_kibana'); + await esArchiver.unload('x-pack/test/functional/es_archives/empty_kibana'); }); describe('global all privileges (aka kibana_admin)', () => { diff --git a/x-pack/test/functional/apps/index_patterns/feature_controls/index_patterns_security.ts b/x-pack/test/functional/apps/index_patterns/feature_controls/index_patterns_security.ts index 8da6871842b15..04f251d247d1b 100644 --- a/x-pack/test/functional/apps/index_patterns/feature_controls/index_patterns_security.ts +++ b/x-pack/test/functional/apps/index_patterns/feature_controls/index_patterns_security.ts @@ -19,11 +19,11 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { describe('security', () => { before(async () => { - await esArchiver.load('empty_kibana'); + await esArchiver.load('x-pack/test/functional/es_archives/empty_kibana'); }); after(async () => { - await esArchiver.unload('empty_kibana'); + await esArchiver.unload('x-pack/test/functional/es_archives/empty_kibana'); }); describe('global index_patterns all privileges', () => { diff --git a/x-pack/test/functional/apps/index_patterns/feature_controls/index_patterns_spaces.ts b/x-pack/test/functional/apps/index_patterns/feature_controls/index_patterns_spaces.ts index cc3dadb69b103..10a25da4ef0fa 100644 --- a/x-pack/test/functional/apps/index_patterns/feature_controls/index_patterns_spaces.ts +++ b/x-pack/test/functional/apps/index_patterns/feature_controls/index_patterns_spaces.ts @@ -18,14 +18,14 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { describe('spaces', () => { before(async () => { - await esArchiver.loadIfNeeded('logstash_functional'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/logstash_functional'); }); describe('space with no features disabled', () => { before(async () => { // we need to load the following in every situation as deleting // a space deletes all of the associated saved objects - await esArchiver.load('empty_kibana'); + await esArchiver.load('x-pack/test/functional/es_archives/empty_kibana'); await spacesService.create({ id: 'custom_space', @@ -36,7 +36,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { after(async () => { await spacesService.delete('custom_space'); - await esArchiver.unload('empty_kibana'); + await esArchiver.unload('x-pack/test/functional/es_archives/empty_kibana'); }); it('shows Management navlink', async () => { @@ -58,7 +58,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { before(async () => { // we need to load the following in every situation as deleting // a space deletes all of the associated saved objects - await esArchiver.load('empty_kibana'); + await esArchiver.load('x-pack/test/functional/es_archives/empty_kibana'); await spacesService.create({ id: 'custom_space', name: 'custom_space', @@ -68,7 +68,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { after(async () => { await spacesService.delete('custom_space'); - await esArchiver.unload('empty_kibana'); + await esArchiver.unload('x-pack/test/functional/es_archives/empty_kibana'); }); it(`redirects to management home`, async () => { diff --git a/x-pack/test/functional/apps/infra/feature_controls/infrastructure_security.ts b/x-pack/test/functional/apps/infra/feature_controls/infrastructure_security.ts index 2d4f3040ecdc9..0118cfdafc2b3 100644 --- a/x-pack/test/functional/apps/infra/feature_controls/infrastructure_security.ts +++ b/x-pack/test/functional/apps/infra/feature_controls/infrastructure_security.ts @@ -82,11 +82,11 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { describe('infrastructure landing page with data', () => { before(async () => { - await esArchiver.load('infra/metrics_and_logs'); + await esArchiver.load('x-pack/test/functional/es_archives/infra/metrics_and_logs'); }); after(async () => { - await esArchiver.unload('infra/metrics_and_logs'); + await esArchiver.unload('x-pack/test/functional/es_archives/infra/metrics_and_logs'); }); it(`shows Wafflemap`, async () => { @@ -180,11 +180,11 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { describe('infrastructure landing page with data', () => { before(async () => { - await esArchiver.load('infra/metrics_and_logs'); + await esArchiver.load('x-pack/test/functional/es_archives/infra/metrics_and_logs'); }); after(async () => { - await esArchiver.unload('infra/metrics_and_logs'); + await esArchiver.unload('x-pack/test/functional/es_archives/infra/metrics_and_logs'); }); it(`shows Wafflemap`, async () => { @@ -259,11 +259,11 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { describe('infrastructure landing page with data', () => { before(async () => { - await esArchiver.load('infra/metrics_and_logs'); + await esArchiver.load('x-pack/test/functional/es_archives/infra/metrics_and_logs'); }); after(async () => { - await esArchiver.unload('infra/metrics_and_logs'); + await esArchiver.unload('x-pack/test/functional/es_archives/infra/metrics_and_logs'); }); }); }); @@ -312,11 +312,11 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { describe('infrastructure landing page with data', () => { before(async () => { - await esArchiver.load('infra/metrics_and_logs'); + await esArchiver.load('x-pack/test/functional/es_archives/infra/metrics_and_logs'); }); after(async () => { - await esArchiver.unload('infra/metrics_and_logs'); + await esArchiver.unload('x-pack/test/functional/es_archives/infra/metrics_and_logs'); }); }); }); diff --git a/x-pack/test/functional/apps/infra/feature_controls/infrastructure_spaces.ts b/x-pack/test/functional/apps/infra/feature_controls/infrastructure_spaces.ts index 7059d26f6c977..94886a89002b2 100644 --- a/x-pack/test/functional/apps/infra/feature_controls/infrastructure_spaces.ts +++ b/x-pack/test/functional/apps/infra/feature_controls/infrastructure_spaces.ts @@ -17,11 +17,11 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { describe('infrastructure spaces', () => { before(async () => { - await esArchiver.load('empty_kibana'); + await esArchiver.load('x-pack/test/functional/es_archives/empty_kibana'); }); after(async () => { - await esArchiver.unload('empty_kibana'); + await esArchiver.unload('x-pack/test/functional/es_archives/empty_kibana'); }); describe('space with no features disabled', () => { @@ -59,7 +59,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { before(async () => { // we need to load the following in every situation as deleting // a space deletes all of the associated saved objects - await esArchiver.load('empty_kibana'); + await esArchiver.load('x-pack/test/functional/es_archives/empty_kibana'); await spacesService.create({ id: 'custom_space', name: 'custom_space', @@ -69,7 +69,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { after(async () => { await spacesService.delete('custom_space'); - await esArchiver.unload('empty_kibana'); + await esArchiver.unload('x-pack/test/functional/es_archives/empty_kibana'); }); it(`doesn't show metrics navlink`, async () => { @@ -101,7 +101,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { before(async () => { // we need to load the following in every situation as deleting // a space deletes all of the associated saved objects - await esArchiver.load('empty_kibana'); + await esArchiver.load('x-pack/test/functional/es_archives/empty_kibana'); await spacesService.create({ id: 'custom_space', name: 'custom_space', @@ -111,7 +111,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { after(async () => { await spacesService.delete('custom_space'); - await esArchiver.unload('empty_kibana'); + await esArchiver.unload('x-pack/test/functional/es_archives/empty_kibana'); }); it(`Metrics app is accessible`, async () => { @@ -126,7 +126,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { before(async () => { // we need to load the following in every situation as deleting // a space deletes all of the associated saved objects - await esArchiver.load('empty_kibana'); + await esArchiver.load('x-pack/test/functional/es_archives/empty_kibana'); await spacesService.create({ id: 'custom_space', name: 'custom_space', @@ -136,7 +136,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { after(async () => { await spacesService.delete('custom_space'); - await esArchiver.unload('empty_kibana'); + await esArchiver.unload('x-pack/test/functional/es_archives/empty_kibana'); }); it(`Metrics app is accessible`, async () => { diff --git a/x-pack/test/functional/apps/infra/feature_controls/logs_security.ts b/x-pack/test/functional/apps/infra/feature_controls/logs_security.ts index d231bd77e8dfa..d5e22af657d6a 100644 --- a/x-pack/test/functional/apps/infra/feature_controls/logs_security.ts +++ b/x-pack/test/functional/apps/infra/feature_controls/logs_security.ts @@ -18,7 +18,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { describe('logs security', () => { before(async () => { - await esArchiver.load('empty_kibana'); + await esArchiver.load('x-pack/test/functional/es_archives/empty_kibana'); }); describe('global logs all privileges', () => { before(async () => { diff --git a/x-pack/test/functional/apps/infra/feature_controls/logs_spaces.ts b/x-pack/test/functional/apps/infra/feature_controls/logs_spaces.ts index 2a8bbc75d0db9..a67d7d1858af3 100644 --- a/x-pack/test/functional/apps/infra/feature_controls/logs_spaces.ts +++ b/x-pack/test/functional/apps/infra/feature_controls/logs_spaces.ts @@ -20,7 +20,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { before(async () => { // we need to load the following in every situation as deleting // a space deletes all of the associated saved objects - await esArchiver.load('empty_kibana'); + await esArchiver.load('x-pack/test/functional/es_archives/empty_kibana'); await spacesService.create({ id: 'custom_space', @@ -31,7 +31,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { after(async () => { await spacesService.delete('custom_space'); - await esArchiver.unload('empty_kibana'); + await esArchiver.unload('x-pack/test/functional/es_archives/empty_kibana'); }); it('shows Logs navlink', async () => { @@ -60,7 +60,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { before(async () => { // we need to load the following in every situation as deleting // a space deletes all of the associated saved objects - await esArchiver.load('empty_kibana'); + await esArchiver.load('x-pack/test/functional/es_archives/empty_kibana'); await spacesService.create({ id: 'custom_space', name: 'custom_space', @@ -70,7 +70,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { after(async () => { await spacesService.delete('custom_space'); - await esArchiver.unload('empty_kibana'); + await esArchiver.unload('x-pack/test/functional/es_archives/empty_kibana'); }); it(`doesn't show Logs navlink`, async () => { diff --git a/x-pack/test/functional/apps/infra/home_page.ts b/x-pack/test/functional/apps/infra/home_page.ts index 7578abbad33e7..3e2d356edc69f 100644 --- a/x-pack/test/functional/apps/infra/home_page.ts +++ b/x-pack/test/functional/apps/infra/home_page.ts @@ -18,11 +18,14 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { describe('Home page', function () { this.tags('includeFirefox'); before(async () => { - await esArchiver.load('empty_kibana'); + await esArchiver.load('x-pack/test/functional/es_archives/empty_kibana'); }); describe('without metrics present', () => { - before(async () => await esArchiver.unload('infra/metrics_and_logs')); + before( + async () => + await esArchiver.unload('x-pack/test/functional/es_archives/infra/metrics_and_logs') + ); it('renders an empty data prompt', async () => { await pageObjects.common.navigateToApp('infraOps'); @@ -32,11 +35,14 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { describe('with metrics present', () => { before(async () => { - await esArchiver.load('infra/metrics_and_logs'); + await esArchiver.load('x-pack/test/functional/es_archives/infra/metrics_and_logs'); await pageObjects.common.navigateToApp('infraOps'); await pageObjects.infraHome.waitForLoading(); }); - after(async () => await esArchiver.unload('infra/metrics_and_logs')); + after( + async () => + await esArchiver.unload('x-pack/test/functional/es_archives/infra/metrics_and_logs') + ); it('renders the waffle map and tooltips for dates with data', async () => { await pageObjects.infraHome.goToTime(DATE_WITH_DATA); diff --git a/x-pack/test/functional/apps/infra/logs_source_configuration.ts b/x-pack/test/functional/apps/infra/logs_source_configuration.ts index 737fea2adedb9..b84109637885c 100644 --- a/x-pack/test/functional/apps/infra/logs_source_configuration.ts +++ b/x-pack/test/functional/apps/infra/logs_source_configuration.ts @@ -24,18 +24,18 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { describe('Logs Source Configuration', function () { before(async () => { - await esArchiver.load('empty_kibana'); + await esArchiver.load('x-pack/test/functional/es_archives/empty_kibana'); }); after(async () => { - await esArchiver.unload('empty_kibana'); + await esArchiver.unload('x-pack/test/functional/es_archives/empty_kibana'); }); describe('Allows indices configuration', () => { before(async () => { - await esArchiver.load('infra/metrics_and_logs'); + await esArchiver.load('x-pack/test/functional/es_archives/infra/metrics_and_logs'); }); after(async () => { - await esArchiver.unload('infra/metrics_and_logs'); + await esArchiver.unload('x-pack/test/functional/es_archives/infra/metrics_and_logs'); }); it('can change the log indices to a pattern that matches nothing', async () => { diff --git a/x-pack/test/functional/apps/infra/metrics_anomalies.ts b/x-pack/test/functional/apps/infra/metrics_anomalies.ts index a3160c023d4a7..5b481abae48d7 100644 --- a/x-pack/test/functional/apps/infra/metrics_anomalies.ts +++ b/x-pack/test/functional/apps/infra/metrics_anomalies.ts @@ -18,10 +18,10 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { // Failing: See https://github.com/elastic/kibana/issues/100445 describe('Metrics UI Anomaly Flyout', function () { before(async () => { - await esArchiver.load('empty_kibana'); + await esArchiver.load('x-pack/test/functional/es_archives/empty_kibana'); }); after(async () => { - await esArchiver.unload('empty_kibana'); + await esArchiver.unload('x-pack/test/functional/es_archives/empty_kibana'); }); describe('with no anomalies present', () => { @@ -41,7 +41,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { describe('with anomalies present', () => { before(async () => { - await esArchiver.load('infra/metrics_anomalies'); + await esArchiver.load('x-pack/test/functional/es_archives/infra/metrics_anomalies'); // create the ml jobs saved objects await Promise.all( ML_JOB_IDS.map((id) => @@ -59,7 +59,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { ); }); after(async () => { - await esArchiver.unload('infra/metrics_anomalies'); + await esArchiver.unload('x-pack/test/functional/es_archives/infra/metrics_anomalies'); }); it('renders the anomaly table with anomalies', async () => { // default threshold should already be 50 but trying to prevent unknown flakiness by setting it diff --git a/x-pack/test/functional/apps/infra/metrics_source_configuration.ts b/x-pack/test/functional/apps/infra/metrics_source_configuration.ts index 7b7e1e5618256..5d2f7b09ab167 100644 --- a/x-pack/test/functional/apps/infra/metrics_source_configuration.ts +++ b/x-pack/test/functional/apps/infra/metrics_source_configuration.ts @@ -17,18 +17,18 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { describe('Infrastructure Source Configuration', function () { before(async () => { - await esArchiver.load('empty_kibana'); + await esArchiver.load('x-pack/test/functional/es_archives/empty_kibana'); }); after(async () => { - await esArchiver.unload('empty_kibana'); + await esArchiver.unload('x-pack/test/functional/es_archives/empty_kibana'); }); describe('with metrics present', () => { before(async () => { - await esArchiver.load('infra/metrics_and_logs'); + await esArchiver.load('x-pack/test/functional/es_archives/infra/metrics_and_logs'); }); after(async () => { - await esArchiver.unload('infra/metrics_and_logs'); + await esArchiver.unload('x-pack/test/functional/es_archives/infra/metrics_and_logs'); }); it('renders the waffle map', async () => { diff --git a/x-pack/test/functional/apps/ingest_pipelines/feature_controls/ingest_pipelines_security.ts b/x-pack/test/functional/apps/ingest_pipelines/feature_controls/ingest_pipelines_security.ts index 6c22ccaa76245..ea3781de58f15 100644 --- a/x-pack/test/functional/apps/ingest_pipelines/feature_controls/ingest_pipelines_security.ts +++ b/x-pack/test/functional/apps/ingest_pipelines/feature_controls/ingest_pipelines_security.ts @@ -17,12 +17,12 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { describe('security', () => { before(async () => { - await esArchiver.load('empty_kibana'); + await esArchiver.load('x-pack/test/functional/es_archives/empty_kibana'); await PageObjects.common.navigateToApp('home'); }); after(async () => { - await esArchiver.unload('empty_kibana'); + await esArchiver.unload('x-pack/test/functional/es_archives/empty_kibana'); }); describe('global all privileges (aka kibana_admin)', () => { diff --git a/x-pack/test/functional/apps/lens/index.ts b/x-pack/test/functional/apps/lens/index.ts index bff0b590a8e68..1efceace8b167 100644 --- a/x-pack/test/functional/apps/lens/index.ts +++ b/x-pack/test/functional/apps/lens/index.ts @@ -16,13 +16,13 @@ export default function ({ getService, loadTestFile }: FtrProviderContext) { before(async () => { log.debug('Starting lens before method'); await browser.setWindowSize(1280, 800); - await esArchiver.load('logstash_functional'); - await esArchiver.load('lens/basic'); + await esArchiver.load('x-pack/test/functional/es_archives/logstash_functional'); + await esArchiver.load('x-pack/test/functional/es_archives/lens/basic'); }); after(async () => { - await esArchiver.unload('logstash_functional'); - await esArchiver.unload('lens/basic'); + await esArchiver.unload('x-pack/test/functional/es_archives/logstash_functional'); + await esArchiver.unload('x-pack/test/functional/es_archives/lens/basic'); }); describe('', function () { diff --git a/x-pack/test/functional/apps/lens/lens_reporting.ts b/x-pack/test/functional/apps/lens/lens_reporting.ts index 658a9dbcac822..fb4c501baaf80 100644 --- a/x-pack/test/functional/apps/lens/lens_reporting.ts +++ b/x-pack/test/functional/apps/lens/lens_reporting.ts @@ -17,7 +17,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('lens reporting', () => { before(async () => { - await esArchiver.loadIfNeeded('lens/reporting'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/lens/reporting'); await security.role.create('test_reporting_user', { elasticsearch: { cluster: [], indices: [], run_as: [] }, kibana: [ @@ -35,7 +35,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); after(async () => { - await esArchiver.unload('lens/reporting'); + await esArchiver.unload('x-pack/test/functional/es_archives/lens/reporting'); await es.deleteByQuery({ index: '.reporting-*', refresh: true, diff --git a/x-pack/test/functional/apps/lens/lens_tagging.ts b/x-pack/test/functional/apps/lens/lens_tagging.ts index 6fff2baa2d0cc..b659515a6031c 100644 --- a/x-pack/test/functional/apps/lens/lens_tagging.ts +++ b/x-pack/test/functional/apps/lens/lens_tagging.ts @@ -30,8 +30,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('lens tagging', () => { before(async () => { - await esArchiver.loadIfNeeded('logstash_functional'); - await esArchiver.loadIfNeeded('lens/basic'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/logstash_functional'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/lens/basic'); await PageObjects.common.navigateToApp('dashboard'); await PageObjects.dashboard.preserveCrossAppState(); await PageObjects.dashboard.clickNewDashboard(); diff --git a/x-pack/test/functional/apps/lens/rollup.ts b/x-pack/test/functional/apps/lens/rollup.ts index 86b34e893e7b1..34620a734cfd7 100644 --- a/x-pack/test/functional/apps/lens/rollup.ts +++ b/x-pack/test/functional/apps/lens/rollup.ts @@ -16,13 +16,13 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('lens rollup tests', () => { before(async () => { - await esArchiver.loadIfNeeded('lens/rollup/data'); - await esArchiver.loadIfNeeded('lens/rollup/config'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/lens/rollup/data'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/lens/rollup/config'); }); after(async () => { - await esArchiver.unload('lens/rollup/data'); - await esArchiver.unload('lens/rollup/config'); + await esArchiver.unload('x-pack/test/functional/es_archives/lens/rollup/data'); + await esArchiver.unload('x-pack/test/functional/es_archives/lens/rollup/config'); }); it('should allow creation of lens xy chart', async () => { diff --git a/x-pack/test/functional/apps/license_management/feature_controls/license_management_security.ts b/x-pack/test/functional/apps/license_management/feature_controls/license_management_security.ts index f46cb7100902e..9608bffb302d1 100644 --- a/x-pack/test/functional/apps/license_management/feature_controls/license_management_security.ts +++ b/x-pack/test/functional/apps/license_management/feature_controls/license_management_security.ts @@ -17,12 +17,12 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { describe('security', () => { before(async () => { - await esArchiver.load('empty_kibana'); + await esArchiver.load('x-pack/test/functional/es_archives/empty_kibana'); await PageObjects.common.navigateToApp('home'); }); after(async () => { - await esArchiver.unload('empty_kibana'); + await esArchiver.unload('x-pack/test/functional/es_archives/empty_kibana'); }); describe('global all privileges (aka kibana_admin)', () => { diff --git a/x-pack/test/functional/apps/logstash/feature_controls/logstash_security.ts b/x-pack/test/functional/apps/logstash/feature_controls/logstash_security.ts index 587b62547ad8b..ad570f5cf82d6 100644 --- a/x-pack/test/functional/apps/logstash/feature_controls/logstash_security.ts +++ b/x-pack/test/functional/apps/logstash/feature_controls/logstash_security.ts @@ -17,12 +17,12 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { describe('security', () => { before(async () => { - await esArchiver.load('empty_kibana'); + await esArchiver.load('x-pack/test/functional/es_archives/empty_kibana'); await PageObjects.common.navigateToApp('home'); }); after(async () => { - await esArchiver.unload('empty_kibana'); + await esArchiver.unload('x-pack/test/functional/es_archives/empty_kibana'); }); describe('global all privileges (aka kibana_admin)', () => { diff --git a/x-pack/test/functional/apps/logstash/pipeline_create.js b/x-pack/test/functional/apps/logstash/pipeline_create.js index c4715eba19a0b..f576182eb8f21 100644 --- a/x-pack/test/functional/apps/logstash/pipeline_create.js +++ b/x-pack/test/functional/apps/logstash/pipeline_create.js @@ -23,11 +23,11 @@ export default function ({ getService, getPageObjects }) { before(async () => { originalWindowSize = await browser.getWindowSize(); await browser.setWindowSize(1600, 1000); - await esArchiver.load('logstash/empty'); + await esArchiver.load('x-pack/test/functional/es_archives/logstash/empty'); }); after(async () => { - await esArchiver.unload('logstash/empty'); + await esArchiver.unload('x-pack/test/functional/es_archives/logstash/empty'); await browser.setWindowSize(originalWindowSize.width, originalWindowSize.height); }); diff --git a/x-pack/test/functional/apps/logstash/pipeline_list.js b/x-pack/test/functional/apps/logstash/pipeline_list.js index 8235297f213ec..cf0a6dd42c85e 100644 --- a/x-pack/test/functional/apps/logstash/pipeline_list.js +++ b/x-pack/test/functional/apps/logstash/pipeline_list.js @@ -22,7 +22,7 @@ export default function ({ getService, getPageObjects }) { before(async () => { originalWindowSize = await browser.getWindowSize(); await browser.setWindowSize(1600, 1000); - await esArchiver.load('logstash/example_pipelines'); + await esArchiver.load('x-pack/test/functional/es_archives/logstash/example_pipelines'); }); beforeEach(async () => { @@ -30,7 +30,7 @@ export default function ({ getService, getPageObjects }) { }); after(async () => { - await esArchiver.unload('logstash/example_pipelines'); + await esArchiver.unload('x-pack/test/functional/es_archives/logstash/example_pipelines'); await browser.setWindowSize(originalWindowSize.width, originalWindowSize.height); }); diff --git a/x-pack/test/functional/apps/management/feature_controls/management_security.ts b/x-pack/test/functional/apps/management/feature_controls/management_security.ts index 24d3455219fe5..edca9b64d4fca 100644 --- a/x-pack/test/functional/apps/management/feature_controls/management_security.ts +++ b/x-pack/test/functional/apps/management/feature_controls/management_security.ts @@ -18,12 +18,12 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { describe('security', () => { before(async () => { - await esArchiver.load('empty_kibana'); + await esArchiver.load('x-pack/test/functional/es_archives/empty_kibana'); await PageObjects.common.navigateToApp('home'); }); after(async () => { - await esArchiver.unload('empty_kibana'); + await esArchiver.unload('x-pack/test/functional/es_archives/empty_kibana'); }); describe('no management privileges', () => { diff --git a/x-pack/test/functional/apps/maps/index.js b/x-pack/test/functional/apps/maps/index.js index dd20ed58afbc6..4a9262f97ee36 100644 --- a/x-pack/test/functional/apps/maps/index.js +++ b/x-pack/test/functional/apps/maps/index.js @@ -14,9 +14,9 @@ export default function ({ loadTestFile, getService }) { this.tags(['skipFirefox']); before(async () => { - await esArchiver.loadIfNeeded('logstash_functional'); - await esArchiver.load('maps/data'); - await esArchiver.load('maps/kibana'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/logstash_functional'); + await esArchiver.load('x-pack/test/functional/es_archives/maps/data'); + await esArchiver.load('x-pack/test/functional/es_archives/maps/kibana'); await kibanaServer.uiSettings.replace({ defaultIndex: 'c698b940-e149-11e8-a35a-370a8516603a', }); @@ -24,8 +24,8 @@ export default function ({ loadTestFile, getService }) { }); after(async () => { - await esArchiver.unload('maps/data'); - await esArchiver.unload('maps/kibana'); + await esArchiver.unload('x-pack/test/functional/es_archives/maps/data'); + await esArchiver.unload('x-pack/test/functional/es_archives/maps/kibana'); }); describe('', async function () { diff --git a/x-pack/test/functional/apps/ml/anomaly_detection/advanced_job.ts b/x-pack/test/functional/apps/ml/anomaly_detection/advanced_job.ts index bc2f327720690..e6bff43383de6 100644 --- a/x-pack/test/functional/apps/ml/anomaly_detection/advanced_job.ts +++ b/x-pack/test/functional/apps/ml/anomaly_detection/advanced_job.ts @@ -222,7 +222,7 @@ export default function ({ getService }: FtrProviderContext) { describe('advanced job', function () { this.tags(['mlqa']); before(async () => { - await esArchiver.loadIfNeeded('ml/ecommerce'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/ml/ecommerce'); await ml.testResources.createIndexPatternIfNeeded('ft_ecommerce', 'order_date'); await ml.testResources.setKibanaTimeZoneToUTC(); diff --git a/x-pack/test/functional/apps/ml/anomaly_detection/aggregated_scripted_job.ts b/x-pack/test/functional/apps/ml/anomaly_detection/aggregated_scripted_job.ts index 980060fea1c47..b96e029caa49f 100644 --- a/x-pack/test/functional/apps/ml/anomaly_detection/aggregated_scripted_job.ts +++ b/x-pack/test/functional/apps/ml/anomaly_detection/aggregated_scripted_job.ts @@ -366,8 +366,8 @@ export default function ({ getService }: FtrProviderContext) { describe('aggregated or scripted job', function () { this.tags(['mlqa']); before(async () => { - await esArchiver.loadIfNeeded('ml/farequote'); - await esArchiver.loadIfNeeded('ml/ecommerce'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/ml/farequote'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/ml/ecommerce'); await ml.testResources.createIndexPatternIfNeeded('ft_farequote', '@timestamp'); await ml.testResources.createIndexPatternIfNeeded('ft_ecommerce', 'order_date'); await ml.testResources.setKibanaTimeZoneToUTC(); diff --git a/x-pack/test/functional/apps/ml/anomaly_detection/annotations.ts b/x-pack/test/functional/apps/ml/anomaly_detection/annotations.ts index 97cc6be95ed93..b6d23f1c1a3ea 100644 --- a/x-pack/test/functional/apps/ml/anomaly_detection/annotations.ts +++ b/x-pack/test/functional/apps/ml/anomaly_detection/annotations.ts @@ -43,7 +43,7 @@ export default function ({ getService }: FtrProviderContext) { describe('annotations', function () { this.tags(['mlqa']); before(async () => { - await esArchiver.loadIfNeeded('ml/farequote'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/ml/farequote'); await ml.testResources.createIndexPatternIfNeeded('ft_farequote', '@timestamp'); await ml.testResources.setKibanaTimeZoneToUTC(); diff --git a/x-pack/test/functional/apps/ml/anomaly_detection/anomaly_explorer.ts b/x-pack/test/functional/apps/ml/anomaly_detection/anomaly_explorer.ts index 693b8b5a403f1..4373da71512e4 100644 --- a/x-pack/test/functional/apps/ml/anomaly_detection/anomaly_explorer.ts +++ b/x-pack/test/functional/apps/ml/anomaly_detection/anomaly_explorer.ts @@ -66,7 +66,7 @@ export default function ({ getService }: FtrProviderContext) { describe('anomaly explorer', function () { this.tags(['mlqa']); before(async () => { - await esArchiver.loadIfNeeded('ml/farequote'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/ml/farequote'); await ml.testResources.createIndexPatternIfNeeded('ft_farequote', '@timestamp'); await ml.testResources.createMLTestDashboardIfNeeded(); await ml.testResources.setKibanaTimeZoneToUTC(); diff --git a/x-pack/test/functional/apps/ml/anomaly_detection/categorization_job.ts b/x-pack/test/functional/apps/ml/anomaly_detection/categorization_job.ts index 85eeacc58514e..15f082dda4337 100644 --- a/x-pack/test/functional/apps/ml/anomaly_detection/categorization_job.ts +++ b/x-pack/test/functional/apps/ml/anomaly_detection/categorization_job.ts @@ -77,7 +77,7 @@ export default function ({ getService }: FtrProviderContext) { describe('categorization', function () { this.tags(['mlqa']); before(async () => { - await esArchiver.loadIfNeeded('ml/categorization'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/ml/categorization'); await ml.testResources.createIndexPatternIfNeeded('ft_categorization', '@timestamp'); await ml.testResources.setKibanaTimeZoneToUTC(); diff --git a/x-pack/test/functional/apps/ml/anomaly_detection/custom_urls.ts b/x-pack/test/functional/apps/ml/anomaly_detection/custom_urls.ts index a743e00b64add..0dcb767309608 100644 --- a/x-pack/test/functional/apps/ml/anomaly_detection/custom_urls.ts +++ b/x-pack/test/functional/apps/ml/anomaly_detection/custom_urls.ts @@ -84,7 +84,7 @@ export default function ({ getService }: FtrProviderContext) { describe('custom urls', function () { this.tags(['mlqa']); before(async () => { - await esArchiver.loadIfNeeded('ml/farequote'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/ml/farequote'); await ml.testResources.createIndexPatternIfNeeded('ft_farequote', '@timestamp'); await ml.testResources.createMLTestDashboardIfNeeded(); await ml.testResources.setKibanaTimeZoneToUTC(); diff --git a/x-pack/test/functional/apps/ml/anomaly_detection/date_nanos_job.ts b/x-pack/test/functional/apps/ml/anomaly_detection/date_nanos_job.ts index 4ba3f612c4cf5..024735e939024 100644 --- a/x-pack/test/functional/apps/ml/anomaly_detection/date_nanos_job.ts +++ b/x-pack/test/functional/apps/ml/anomaly_detection/date_nanos_job.ts @@ -117,14 +117,14 @@ export default function ({ getService }: FtrProviderContext) { describe('job on data set with date_nanos time field', function () { this.tags(['mlqa']); before(async () => { - await esArchiver.loadIfNeeded('ml/event_rate_nanos'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/ml/event_rate_nanos'); await ml.testResources.createIndexPatternIfNeeded( 'ft_event_rate_gen_trend_nanos', '@timestamp' ); await ml.testResources.setKibanaTimeZoneToUTC(); - await esArchiver.loadIfNeeded('ml/event_rate_nanos'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/ml/event_rate_nanos'); await ml.securityUI.loginAsMlPowerUser(); }); diff --git a/x-pack/test/functional/apps/ml/anomaly_detection/multi_metric_job.ts b/x-pack/test/functional/apps/ml/anomaly_detection/multi_metric_job.ts index 256f9da313e4e..0c1b1620eb413 100644 --- a/x-pack/test/functional/apps/ml/anomaly_detection/multi_metric_job.ts +++ b/x-pack/test/functional/apps/ml/anomaly_detection/multi_metric_job.ts @@ -74,7 +74,7 @@ export default function ({ getService }: FtrProviderContext) { describe('multi metric', function () { this.tags(['mlqa']); before(async () => { - await esArchiver.loadIfNeeded('ml/farequote'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/ml/farequote'); await ml.testResources.createIndexPatternIfNeeded('ft_farequote', '@timestamp'); await ml.testResources.setKibanaTimeZoneToUTC(); diff --git a/x-pack/test/functional/apps/ml/anomaly_detection/population_job.ts b/x-pack/test/functional/apps/ml/anomaly_detection/population_job.ts index 2bdda2c81c71d..9f86c9d508f80 100644 --- a/x-pack/test/functional/apps/ml/anomaly_detection/population_job.ts +++ b/x-pack/test/functional/apps/ml/anomaly_detection/population_job.ts @@ -88,7 +88,7 @@ export default function ({ getService }: FtrProviderContext) { describe('population', function () { this.tags(['mlqa']); before(async () => { - await esArchiver.loadIfNeeded('ml/ecommerce'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/ml/ecommerce'); await ml.testResources.createIndexPatternIfNeeded('ft_ecommerce', 'order_date'); await ml.testResources.setKibanaTimeZoneToUTC(); diff --git a/x-pack/test/functional/apps/ml/anomaly_detection/saved_search_job.ts b/x-pack/test/functional/apps/ml/anomaly_detection/saved_search_job.ts index 3415cd2016f9e..fb10414d2d9ef 100644 --- a/x-pack/test/functional/apps/ml/anomaly_detection/saved_search_job.ts +++ b/x-pack/test/functional/apps/ml/anomaly_detection/saved_search_job.ts @@ -268,7 +268,7 @@ export default function ({ getService }: FtrProviderContext) { describe('saved search', function () { this.tags(['mlqa']); before(async () => { - await esArchiver.loadIfNeeded('ml/farequote'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/ml/farequote'); await ml.testResources.createIndexPatternIfNeeded('ft_farequote', '@timestamp'); await ml.testResources.createSavedSearchFarequoteFilterIfNeeded(); await ml.testResources.createSavedSearchFarequoteLuceneIfNeeded(); diff --git a/x-pack/test/functional/apps/ml/anomaly_detection/single_metric_job.ts b/x-pack/test/functional/apps/ml/anomaly_detection/single_metric_job.ts index eedb130215f7f..97b340c081958 100644 --- a/x-pack/test/functional/apps/ml/anomaly_detection/single_metric_job.ts +++ b/x-pack/test/functional/apps/ml/anomaly_detection/single_metric_job.ts @@ -73,7 +73,7 @@ export default function ({ getService }: FtrProviderContext) { describe('single metric', function () { this.tags(['mlqa']); before(async () => { - await esArchiver.loadIfNeeded('ml/farequote'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/ml/farequote'); await ml.testResources.createIndexPatternIfNeeded('ft_farequote', '@timestamp'); await ml.testResources.setKibanaTimeZoneToUTC(); diff --git a/x-pack/test/functional/apps/ml/anomaly_detection/single_metric_job_without_datafeed_start.ts b/x-pack/test/functional/apps/ml/anomaly_detection/single_metric_job_without_datafeed_start.ts index 1e7d8f184a64c..889c1b6c59931 100644 --- a/x-pack/test/functional/apps/ml/anomaly_detection/single_metric_job_without_datafeed_start.ts +++ b/x-pack/test/functional/apps/ml/anomaly_detection/single_metric_job_without_datafeed_start.ts @@ -59,7 +59,7 @@ export default function ({ getService }: FtrProviderContext) { describe('single metric without datafeed start', function () { this.tags(['mlqa']); before(async () => { - await esArchiver.loadIfNeeded('ml/farequote'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/ml/farequote'); await ml.testResources.createIndexPatternIfNeeded('ft_farequote', '@timestamp'); await ml.testResources.setKibanaTimeZoneToUTC(); diff --git a/x-pack/test/functional/apps/ml/anomaly_detection/single_metric_viewer.ts b/x-pack/test/functional/apps/ml/anomaly_detection/single_metric_viewer.ts index 950ad2a702b06..1cf499d2625d8 100644 --- a/x-pack/test/functional/apps/ml/anomaly_detection/single_metric_viewer.ts +++ b/x-pack/test/functional/apps/ml/anomaly_detection/single_metric_viewer.ts @@ -45,7 +45,7 @@ export default function ({ getService }: FtrProviderContext) { describe('with single metric job', function () { before(async () => { - await esArchiver.loadIfNeeded('ml/farequote'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/ml/farequote'); await ml.testResources.createIndexPatternIfNeeded('ft_farequote', '@timestamp'); await ml.testResources.setKibanaTimeZoneToUTC(); @@ -133,7 +133,7 @@ export default function ({ getService }: FtrProviderContext) { }; before(async () => { - await esArchiver.loadIfNeeded('ml/ecommerce'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/ml/ecommerce'); await ml.testResources.createIndexPatternIfNeeded('ft_ecommerce', 'order_date'); await ml.testResources.setKibanaTimeZoneToUTC(); await ml.api.createAndRunAnomalyDetectionLookbackJob(jobConfig, datafeedConfig); diff --git a/x-pack/test/functional/apps/ml/data_frame_analytics/classification_creation.ts b/x-pack/test/functional/apps/ml/data_frame_analytics/classification_creation.ts index 1c1c5d956aae8..9a440f758ea26 100644 --- a/x-pack/test/functional/apps/ml/data_frame_analytics/classification_creation.ts +++ b/x-pack/test/functional/apps/ml/data_frame_analytics/classification_creation.ts @@ -15,7 +15,7 @@ export default function ({ getService }: FtrProviderContext) { describe('classification creation', function () { before(async () => { - await esArchiver.loadIfNeeded('ml/bm_classification'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/ml/bm_classification'); await ml.testResources.createIndexPatternIfNeeded('ft_bank_marketing', '@timestamp'); await ml.testResources.setKibanaTimeZoneToUTC(); diff --git a/x-pack/test/functional/apps/ml/data_frame_analytics/cloning.ts b/x-pack/test/functional/apps/ml/data_frame_analytics/cloning.ts index cbd840f7a2c56..84409498fc3f0 100644 --- a/x-pack/test/functional/apps/ml/data_frame_analytics/cloning.ts +++ b/x-pack/test/functional/apps/ml/data_frame_analytics/cloning.ts @@ -27,7 +27,7 @@ export default function ({ getService }: FtrProviderContext) { return [ { suiteTitle: 'classification job supported by the form', - archive: 'ml/bm_classification', + archive: 'x-pack/test/functional/es_archives/ml/bm_classification', indexPattern: { name: 'ft_bank_marketing', timeField: '@timestamp' }, job: { id: `bm_1_${timestamp}`, @@ -62,7 +62,7 @@ export default function ({ getService }: FtrProviderContext) { }, { suiteTitle: 'outlier detection job supported by the form', - archive: 'ml/ihp_outlier', + archive: 'x-pack/test/functional/es_archives/ml/ihp_outlier', indexPattern: { name: 'ft_ihp_outlier', timeField: '@timestamp' }, job: { id: `ihp_1_${timestamp}`, @@ -91,7 +91,7 @@ export default function ({ getService }: FtrProviderContext) { }, { suiteTitle: 'regression job supported by the form', - archive: 'ml/egs_regression', + archive: 'x-pack/test/functional/es_archives/ml/egs_regression', indexPattern: { name: 'ft_egs_regression', timeField: '@timestamp' }, job: { id: `egs_1_${timestamp}`, diff --git a/x-pack/test/functional/apps/ml/data_frame_analytics/feature_importance.ts b/x-pack/test/functional/apps/ml/data_frame_analytics/feature_importance.ts index 3c6a3fec01879..fbd6cc70418d3 100644 --- a/x-pack/test/functional/apps/ml/data_frame_analytics/feature_importance.ts +++ b/x-pack/test/functional/apps/ml/data_frame_analytics/feature_importance.ts @@ -26,7 +26,7 @@ export default function ({ getService }: FtrProviderContext) { return [ { suiteTitle: 'binary classification job', - archive: 'ml/ihp_outlier', + archive: 'x-pack/test/functional/es_archives/ml/ihp_outlier', indexPattern: { name: 'ft_ihp_outlier', timeField: '@timestamp' }, job: { id: `ihp_fi_binary_${timestamp}`, @@ -71,7 +71,7 @@ export default function ({ getService }: FtrProviderContext) { }, { suiteTitle: 'multi class classification job', - archive: 'ml/ihp_outlier', + archive: 'x-pack/test/functional/es_archives/ml/ihp_outlier', indexPattern: { name: 'ft_ihp_outlier', timeField: '@timestamp' }, job: { id: `ihp_fi_multi_${timestamp}`, @@ -116,7 +116,7 @@ export default function ({ getService }: FtrProviderContext) { }, { suiteTitle: 'regression job', - archive: 'ml/egs_regression', + archive: 'x-pack/test/functional/es_archives/ml/egs_regression', indexPattern: { name: 'ft_egs_regression', timeField: '@timestamp' }, job: { id: `egs_fi_reg_${timestamp}`, diff --git a/x-pack/test/functional/apps/ml/data_frame_analytics/outlier_detection_creation.ts b/x-pack/test/functional/apps/ml/data_frame_analytics/outlier_detection_creation.ts index 62c506e06d7e6..ef86de29febc7 100644 --- a/x-pack/test/functional/apps/ml/data_frame_analytics/outlier_detection_creation.ts +++ b/x-pack/test/functional/apps/ml/data_frame_analytics/outlier_detection_creation.ts @@ -15,7 +15,7 @@ export default function ({ getService }: FtrProviderContext) { describe('outlier detection creation', function () { before(async () => { - await esArchiver.loadIfNeeded('ml/ihp_outlier'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/ml/ihp_outlier'); await ml.testResources.createIndexPatternIfNeeded('ft_ihp_outlier', '@timestamp'); await ml.testResources.setKibanaTimeZoneToUTC(); diff --git a/x-pack/test/functional/apps/ml/data_frame_analytics/regression_creation.ts b/x-pack/test/functional/apps/ml/data_frame_analytics/regression_creation.ts index 692de607c7d36..b2bd54ae639ae 100644 --- a/x-pack/test/functional/apps/ml/data_frame_analytics/regression_creation.ts +++ b/x-pack/test/functional/apps/ml/data_frame_analytics/regression_creation.ts @@ -15,7 +15,7 @@ export default function ({ getService }: FtrProviderContext) { describe('regression creation', function () { before(async () => { - await esArchiver.loadIfNeeded('ml/egs_regression'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/ml/egs_regression'); await ml.testResources.createIndexPatternIfNeeded('ft_egs_regression', '@timestamp'); await ml.testResources.setKibanaTimeZoneToUTC(); diff --git a/x-pack/test/functional/apps/ml/data_visualizer/index_data_visualizer.ts b/x-pack/test/functional/apps/ml/data_visualizer/index_data_visualizer.ts index d83d151e7125e..031074876f39c 100644 --- a/x-pack/test/functional/apps/ml/data_visualizer/index_data_visualizer.ts +++ b/x-pack/test/functional/apps/ml/data_visualizer/index_data_visualizer.ts @@ -499,8 +499,8 @@ export default function ({ getService }: FtrProviderContext) { describe('index based', function () { this.tags(['mlqa']); before(async () => { - await esArchiver.loadIfNeeded('ml/farequote'); - await esArchiver.loadIfNeeded('ml/module_sample_logs'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/ml/farequote'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/ml/module_sample_logs'); await ml.testResources.createIndexPatternIfNeeded('ft_farequote', '@timestamp'); await ml.testResources.createIndexPatternIfNeeded('ft_module_sample_logs', '@timestamp'); diff --git a/x-pack/test/functional/apps/ml/data_visualizer/index_data_visualizer_actions_panel.ts b/x-pack/test/functional/apps/ml/data_visualizer/index_data_visualizer_actions_panel.ts index 2c89f34c41a3d..93e3b67ca1565 100644 --- a/x-pack/test/functional/apps/ml/data_visualizer/index_data_visualizer_actions_panel.ts +++ b/x-pack/test/functional/apps/ml/data_visualizer/index_data_visualizer_actions_panel.ts @@ -27,7 +27,7 @@ export default function ({ getService }: FtrProviderContext) { // }`; // Note query is not currently passed to the wizard before(async () => { - await esArchiver.loadIfNeeded('ml/farequote'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/ml/farequote'); await ml.testResources.createIndexPatternIfNeeded(indexPatternName, '@timestamp'); await ml.testResources.createSavedSearchFarequoteKueryIfNeeded(); await ml.testResources.setKibanaTimeZoneToUTC(); diff --git a/x-pack/test/functional/apps/ml/embeddables/anomaly_charts_dashboard_embeddables.ts b/x-pack/test/functional/apps/ml/embeddables/anomaly_charts_dashboard_embeddables.ts index d4eb45619b7f7..1c47893dbafd0 100644 --- a/x-pack/test/functional/apps/ml/embeddables/anomaly_charts_dashboard_embeddables.ts +++ b/x-pack/test/functional/apps/ml/embeddables/anomaly_charts_dashboard_embeddables.ts @@ -63,7 +63,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { this.tags(['mlqa']); before(async () => { - await esArchiver.loadIfNeeded('ml/farequote'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/ml/farequote'); await ml.testResources.createIndexPatternIfNeeded('ft_farequote', '@timestamp'); await ml.testResources.setKibanaTimeZoneToUTC(); await ml.securityUI.loginAsMlPowerUser(); diff --git a/x-pack/test/functional/apps/ml/index.ts b/x-pack/test/functional/apps/ml/index.ts index 73207bc91e8d3..abaa387336c88 100644 --- a/x-pack/test/functional/apps/ml/index.ts +++ b/x-pack/test/functional/apps/ml/index.ts @@ -33,14 +33,14 @@ export default function ({ getService, loadTestFile }: FtrProviderContext) { await ml.testResources.deleteIndexPatternByTitle('ft_ihp_outlier'); await ml.testResources.deleteIndexPatternByTitle('ft_egs_regression'); await ml.testResources.deleteIndexPatternByTitle('ft_module_sample_ecommerce'); - await esArchiver.unload('ml/farequote'); - await esArchiver.unload('ml/ecommerce'); - await esArchiver.unload('ml/categorization'); - await esArchiver.unload('ml/event_rate_nanos'); - await esArchiver.unload('ml/bm_classification'); - await esArchiver.unload('ml/ihp_outlier'); - await esArchiver.unload('ml/egs_regression'); - await esArchiver.unload('ml/module_sample_ecommerce'); + await esArchiver.unload('x-pack/test/functional/es_archives/ml/farequote'); + await esArchiver.unload('x-pack/test/functional/es_archives/ml/ecommerce'); + await esArchiver.unload('x-pack/test/functional/es_archives/ml/categorization'); + await esArchiver.unload('x-pack/test/functional/es_archives/ml/event_rate_nanos'); + await esArchiver.unload('x-pack/test/functional/es_archives/ml/bm_classification'); + await esArchiver.unload('x-pack/test/functional/es_archives/ml/ihp_outlier'); + await esArchiver.unload('x-pack/test/functional/es_archives/ml/egs_regression'); + await esArchiver.unload('x-pack/test/functional/es_archives/ml/module_sample_ecommerce'); await ml.testResources.resetKibanaTimeZone(); await ml.securityUI.logout(); }); @@ -73,14 +73,14 @@ export default function ({ getService, loadTestFile }: FtrProviderContext) { await ml.testResources.deleteIndexPatternByTitle('ft_ihp_outlier'); await ml.testResources.deleteIndexPatternByTitle('ft_egs_regression'); await ml.testResources.deleteIndexPatternByTitle('ft_module_sample_ecommerce'); - await esArchiver.unload('ml/farequote'); - await esArchiver.unload('ml/ecommerce'); - await esArchiver.unload('ml/categorization'); - await esArchiver.unload('ml/event_rate_nanos'); - await esArchiver.unload('ml/bm_classification'); - await esArchiver.unload('ml/ihp_outlier'); - await esArchiver.unload('ml/egs_regression'); - await esArchiver.unload('ml/module_sample_ecommerce'); + await esArchiver.unload('x-pack/test/functional/es_archives/ml/farequote'); + await esArchiver.unload('x-pack/test/functional/es_archives/ml/ecommerce'); + await esArchiver.unload('x-pack/test/functional/es_archives/ml/categorization'); + await esArchiver.unload('x-pack/test/functional/es_archives/ml/event_rate_nanos'); + await esArchiver.unload('x-pack/test/functional/es_archives/ml/bm_classification'); + await esArchiver.unload('x-pack/test/functional/es_archives/ml/ihp_outlier'); + await esArchiver.unload('x-pack/test/functional/es_archives/ml/egs_regression'); + await esArchiver.unload('x-pack/test/functional/es_archives/ml/module_sample_ecommerce'); await ml.testResources.resetKibanaTimeZone(); await ml.securityUI.logout(); }); diff --git a/x-pack/test/functional/apps/ml/permissions/full_ml_access.ts b/x-pack/test/functional/apps/ml/permissions/full_ml_access.ts index 30f5f9aa6be2b..bbc7f5992506b 100644 --- a/x-pack/test/functional/apps/ml/permissions/full_ml_access.ts +++ b/x-pack/test/functional/apps/ml/permissions/full_ml_access.ts @@ -114,9 +114,11 @@ export default function ({ getService }: FtrProviderContext) { const expectedUploadFileTitle = 'artificial_server_log'; before(async () => { - await esArchiver.loadIfNeeded('ml/farequote'); - await esArchiver.loadIfNeeded('ml/ihp_outlier'); - await esArchiver.loadIfNeeded('ml/module_sample_ecommerce'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/ml/farequote'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/ml/ihp_outlier'); + await esArchiver.loadIfNeeded( + 'x-pack/test/functional/es_archives/ml/module_sample_ecommerce' + ); await ml.testResources.createIndexPatternIfNeeded('ft_farequote', '@timestamp'); await ml.testResources.createIndexPatternIfNeeded('ft_ihp_outlier', '@timestamp'); await ml.testResources.createIndexPatternIfNeeded(ecIndexPattern, 'order_date'); diff --git a/x-pack/test/functional/apps/ml/permissions/read_ml_access.ts b/x-pack/test/functional/apps/ml/permissions/read_ml_access.ts index 1aa3b54d2a278..dbf467e998f25 100644 --- a/x-pack/test/functional/apps/ml/permissions/read_ml_access.ts +++ b/x-pack/test/functional/apps/ml/permissions/read_ml_access.ts @@ -114,9 +114,11 @@ export default function ({ getService }: FtrProviderContext) { const expectedUploadFileTitle = 'artificial_server_log'; before(async () => { - await esArchiver.loadIfNeeded('ml/farequote'); - await esArchiver.loadIfNeeded('ml/ihp_outlier'); - await esArchiver.loadIfNeeded('ml/module_sample_ecommerce'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/ml/farequote'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/ml/ihp_outlier'); + await esArchiver.loadIfNeeded( + 'x-pack/test/functional/es_archives/ml/module_sample_ecommerce' + ); await ml.testResources.createIndexPatternIfNeeded('ft_farequote', '@timestamp'); await ml.testResources.createIndexPatternIfNeeded('ft_ihp_outlier', '@timestamp'); await ml.testResources.createIndexPatternIfNeeded(ecIndexPattern, 'order_date'); diff --git a/x-pack/test/functional/apps/ml/settings/calendar_creation.ts b/x-pack/test/functional/apps/ml/settings/calendar_creation.ts index 2beae2ad007b5..242163d83c456 100644 --- a/x-pack/test/functional/apps/ml/settings/calendar_creation.ts +++ b/x-pack/test/functional/apps/ml/settings/calendar_creation.ts @@ -17,7 +17,7 @@ export default function ({ getService }: FtrProviderContext) { describe('calendar creation', function () { before(async () => { - await esArchiver.loadIfNeeded('ml/farequote'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/ml/farequote'); await ml.testResources.createIndexPatternIfNeeded('ft_farequote', '@timestamp'); await asyncForEach(jobConfigs, async (jobConfig) => { diff --git a/x-pack/test/functional/apps/ml/settings/calendar_edit.ts b/x-pack/test/functional/apps/ml/settings/calendar_edit.ts index a643c4eb34299..8bbddc74a5c44 100644 --- a/x-pack/test/functional/apps/ml/settings/calendar_edit.ts +++ b/x-pack/test/functional/apps/ml/settings/calendar_edit.ts @@ -23,7 +23,7 @@ export default function ({ getService }: FtrProviderContext) { describe('calendar edit', function () { before(async () => { - await esArchiver.loadIfNeeded('ml/farequote'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/ml/farequote'); await ml.testResources.createIndexPatternIfNeeded('ft_farequote', '@timestamp'); await asyncForEach(jobConfigs, async (jobConfig) => { diff --git a/x-pack/test/functional/apps/monitoring/beats/beat_detail.js b/x-pack/test/functional/apps/monitoring/beats/beat_detail.js index af9a7374ec164..f3d89ebdeddbd 100644 --- a/x-pack/test/functional/apps/monitoring/beats/beat_detail.js +++ b/x-pack/test/functional/apps/monitoring/beats/beat_detail.js @@ -17,7 +17,7 @@ export default function ({ getService, getPageObjects }) { const { setup, tearDown } = getLifecycleMethods(getService, getPageObjects); before(async () => { - await setup('monitoring/beats', { + await setup('x-pack/test/functional/es_archives/monitoring/beats', { from: 'Dec 19, 2017 @ 17:14:09.000', to: 'Dec 19, 2017 @ 18:15:09.000', }); diff --git a/x-pack/test/functional/apps/monitoring/beats/cluster.js b/x-pack/test/functional/apps/monitoring/beats/cluster.js index 83074ffe6be65..7f8f1b181b724 100644 --- a/x-pack/test/functional/apps/monitoring/beats/cluster.js +++ b/x-pack/test/functional/apps/monitoring/beats/cluster.js @@ -15,7 +15,7 @@ export default function ({ getService, getPageObjects }) { const { setup, tearDown } = getLifecycleMethods(getService, getPageObjects); before(async () => { - await setup('monitoring/beats', { + await setup('x-pack/test/functional/es_archives/monitoring/beats', { from: 'Dec 19, 2017 @ 17:14:09.000', to: 'Dec 19, 2017 @ 18:15:09.000', }); diff --git a/x-pack/test/functional/apps/monitoring/beats/listing.js b/x-pack/test/functional/apps/monitoring/beats/listing.js index 9a461d93a405f..4030f80f5b8b9 100644 --- a/x-pack/test/functional/apps/monitoring/beats/listing.js +++ b/x-pack/test/functional/apps/monitoring/beats/listing.js @@ -17,7 +17,7 @@ export default function ({ getService, getPageObjects }) { const { setup, tearDown } = getLifecycleMethods(getService, getPageObjects); before(async () => { - await setup('monitoring/beats', { + await setup('x-pack/test/functional/es_archives/monitoring/beats', { from: 'Dec 19, 2017 @ 17:14:09.000', to: 'Dec 19, 2017 @ 18:15:09.000', }); diff --git a/x-pack/test/functional/apps/monitoring/beats/overview.js b/x-pack/test/functional/apps/monitoring/beats/overview.js index c0c3abf11b164..cf544f5e659fd 100644 --- a/x-pack/test/functional/apps/monitoring/beats/overview.js +++ b/x-pack/test/functional/apps/monitoring/beats/overview.js @@ -17,7 +17,7 @@ export default function ({ getService, getPageObjects }) { const { setup, tearDown } = getLifecycleMethods(getService, getPageObjects); before(async () => { - await setup('monitoring/beats', { + await setup('x-pack/test/functional/es_archives/monitoring/beats', { from: 'Dec 19, 2017 @ 17:14:09.000', to: 'Dec 19, 2017 @ 18:15:09.000', }); diff --git a/x-pack/test/functional/apps/monitoring/cluster/list.js b/x-pack/test/functional/apps/monitoring/cluster/list.js index 0b5b3a196beb0..98ea3959d6b29 100644 --- a/x-pack/test/functional/apps/monitoring/cluster/list.js +++ b/x-pack/test/functional/apps/monitoring/cluster/list.js @@ -21,7 +21,7 @@ export default function ({ getService, getPageObjects }) { const UNSUPPORTED_CLUSTER_UUID = '6d-9tDFTRe-qT5GoBytdlQ'; before(async () => { - await setup('monitoring/multicluster', { + await setup('x-pack/test/functional/es_archives/monitoring/multicluster', { from: 'Aug 15, 2017 @ 21:00:00.000', to: 'Aug 16, 2017 @ 00:00:00.000', }); @@ -78,7 +78,7 @@ export default function ({ getService, getPageObjects }) { const SUPPORTED_CLUSTER_UUID = 'NDKg6VXAT6-TaGzEK2Zy7g'; before(async () => { - await setup('monitoring/multi_basic', { + await setup('x-pack/test/functional/es_archives/monitoring/multi_basic', { from: 'Sep 7, 2017 @ 20:12:04.011', to: 'Sep 7, 2017 @ 20:18:55.733', }); diff --git a/x-pack/test/functional/apps/monitoring/cluster/overview.js b/x-pack/test/functional/apps/monitoring/cluster/overview.js index dbdb8edc153b4..389c3313d2954 100644 --- a/x-pack/test/functional/apps/monitoring/cluster/overview.js +++ b/x-pack/test/functional/apps/monitoring/cluster/overview.js @@ -16,7 +16,7 @@ export default function ({ getService, getPageObjects }) { const { setup, tearDown } = getLifecycleMethods(getService, getPageObjects); before(async () => { - await setup('monitoring/singlecluster_green_gold', { + await setup('x-pack/test/functional/es_archives/monitoring/singlecluster_green_gold', { from: 'Aug 23, 2017 @ 21:29:35.267', to: 'Aug 23, 2017 @ 21:47:25.556', }); @@ -67,7 +67,7 @@ export default function ({ getService, getPageObjects }) { const { setup, tearDown } = getLifecycleMethods(getService, getPageObjects); before(async () => { - await setup('monitoring/singlecluster_yellow_platinum', { + await setup('x-pack/test/functional/es_archives/monitoring/singlecluster_yellow_platinum', { from: 'Aug 29, 2017 @ 17:23:47.528', to: 'Aug 29, 2017 @ 17:25:50.701', }); @@ -113,7 +113,7 @@ export default function ({ getService, getPageObjects }) { const { setup, tearDown } = getLifecycleMethods(getService, getPageObjects); before(async () => { - await setup('monitoring/singlecluster_yellow_basic', { + await setup('x-pack/test/functional/es_archives/monitoring/singlecluster_yellow_basic', { from: 'Aug 29, 2017 @ 17:55:43.879', to: 'Aug 29, 2017 @ 18:01:34.958', }); diff --git a/x-pack/test/functional/apps/monitoring/elasticsearch/index_detail.js b/x-pack/test/functional/apps/monitoring/elasticsearch/index_detail.js index 9ac24313c9b7f..5ea7904e039a1 100644 --- a/x-pack/test/functional/apps/monitoring/elasticsearch/index_detail.js +++ b/x-pack/test/functional/apps/monitoring/elasticsearch/index_detail.js @@ -24,10 +24,13 @@ export default function ({ getService, getPageObjects }) { const { setup, tearDown } = getLifecycleMethods(getService, getPageObjects); before(async () => { - await setup('monitoring/singlecluster_three_nodes_shard_relocation', { - from: 'Oct 5, 2017 @ 20:31:48.354', - to: 'Oct 5, 2017 @ 20:35:12.176', - }); + await setup( + 'x-pack/test/functional/es_archives/monitoring/singlecluster_three_nodes_shard_relocation', + { + from: 'Oct 5, 2017 @ 20:31:48.354', + to: 'Oct 5, 2017 @ 20:35:12.176', + } + ); // go to indices listing await overview.clickEsIndices(); diff --git a/x-pack/test/functional/apps/monitoring/elasticsearch/index_detail_mb.js b/x-pack/test/functional/apps/monitoring/elasticsearch/index_detail_mb.js index 2ee2b7bcbe5ca..9d6938fb09c53 100644 --- a/x-pack/test/functional/apps/monitoring/elasticsearch/index_detail_mb.js +++ b/x-pack/test/functional/apps/monitoring/elasticsearch/index_detail_mb.js @@ -24,10 +24,13 @@ export default function ({ getService, getPageObjects }) { const { setup, tearDown } = getLifecycleMethods(getService, getPageObjects); before(async () => { - await setup('monitoring/singlecluster_three_nodes_shard_relocation_mb', { - from: 'Oct 5, 2017 @ 20:31:48.354', - to: 'Oct 5, 2017 @ 20:35:12.176', - }); + await setup( + 'x-pack/test/functional/es_archives/monitoring/singlecluster_three_nodes_shard_relocation_mb', + { + from: 'Oct 5, 2017 @ 20:31:48.354', + to: 'Oct 5, 2017 @ 20:35:12.176', + } + ); // go to indices listing await overview.clickEsIndices(); diff --git a/x-pack/test/functional/apps/monitoring/elasticsearch/indices.js b/x-pack/test/functional/apps/monitoring/elasticsearch/indices.js index a39b08f00c91f..44ded151f0713 100644 --- a/x-pack/test/functional/apps/monitoring/elasticsearch/indices.js +++ b/x-pack/test/functional/apps/monitoring/elasticsearch/indices.js @@ -17,7 +17,7 @@ export default function ({ getService, getPageObjects }) { const { setup, tearDown } = getLifecycleMethods(getService, getPageObjects); before(async () => { - await setup('monitoring/singlecluster_red_platinum', { + await setup('x-pack/test/functional/es_archives/monitoring/singlecluster_red_platinum', { from: 'Oct 6, 2017 @ 19:53:06.748', to: 'Oct 6, 2017 @ 20:15:30.212', }); diff --git a/x-pack/test/functional/apps/monitoring/elasticsearch/indices_mb.js b/x-pack/test/functional/apps/monitoring/elasticsearch/indices_mb.js index f12e6b5f80c8a..551afbc71b725 100644 --- a/x-pack/test/functional/apps/monitoring/elasticsearch/indices_mb.js +++ b/x-pack/test/functional/apps/monitoring/elasticsearch/indices_mb.js @@ -17,7 +17,7 @@ export default function ({ getService, getPageObjects }) { const { setup, tearDown } = getLifecycleMethods(getService, getPageObjects); before(async () => { - await setup('monitoring/singlecluster_red_platinum_mb', { + await setup('x-pack/test/functional/es_archives/monitoring/singlecluster_red_platinum_mb', { from: 'Oct 6, 2017 @ 19:53:06.748', to: 'Oct 6, 2017 @ 20:15:30.212', }); diff --git a/x-pack/test/functional/apps/monitoring/elasticsearch/node_detail.js b/x-pack/test/functional/apps/monitoring/elasticsearch/node_detail.js index 6627f8b37c6ff..79fb399db8a4e 100644 --- a/x-pack/test/functional/apps/monitoring/elasticsearch/node_detail.js +++ b/x-pack/test/functional/apps/monitoring/elasticsearch/node_detail.js @@ -19,10 +19,13 @@ export default function ({ getService, getPageObjects }) { const { setup, tearDown } = getLifecycleMethods(getService, getPageObjects); before(async () => { - await setup('monitoring/singlecluster_three_nodes_shard_relocation', { - from: 'Oct 5, 2017 @ 20:31:48.354', - to: 'Oct 5, 2017 @ 20:35:12.176', - }); + await setup( + 'x-pack/test/functional/es_archives/monitoring/singlecluster_three_nodes_shard_relocation', + { + from: 'Oct 5, 2017 @ 20:31:48.354', + to: 'Oct 5, 2017 @ 20:35:12.176', + } + ); // go to nodes listing await overview.clickEsNodes(); @@ -74,7 +77,7 @@ export default function ({ getService, getPageObjects }) { const { setup, tearDown } = getLifecycleMethods(getService, getPageObjects); before(async () => { - await setup('monitoring/singlecluster_red_platinum', { + await setup('x-pack/test/functional/es_archives/monitoring/singlecluster_red_platinum', { from: 'Oct 6, 2017 @ 19:53:06.748', to: 'Oct 6, 2017 @ 20:15:30.212', }); @@ -110,10 +113,13 @@ export default function ({ getService, getPageObjects }) { const { setup, tearDown } = getLifecycleMethods(getService, getPageObjects); before(async () => { - await setup('monitoring/singlecluster_three_nodes_shard_relocation', { - from: 'Oct 5, 2017 @ 20:31:48.354', - to: 'Oct 5, 2017 @ 20:35:12.176', - }); + await setup( + 'x-pack/test/functional/es_archives/monitoring/singlecluster_three_nodes_shard_relocation', + { + from: 'Oct 5, 2017 @ 20:31:48.354', + to: 'Oct 5, 2017 @ 20:35:12.176', + } + ); // go to nodes listing await overview.clickEsNodes(); diff --git a/x-pack/test/functional/apps/monitoring/elasticsearch/node_detail_mb.js b/x-pack/test/functional/apps/monitoring/elasticsearch/node_detail_mb.js index 360849916e0dd..342668533e963 100644 --- a/x-pack/test/functional/apps/monitoring/elasticsearch/node_detail_mb.js +++ b/x-pack/test/functional/apps/monitoring/elasticsearch/node_detail_mb.js @@ -19,10 +19,13 @@ export default function ({ getService, getPageObjects }) { const { setup, tearDown } = getLifecycleMethods(getService, getPageObjects); before(async () => { - await setup('monitoring/singlecluster_three_nodes_shard_relocation_mb', { - from: 'Oct 5, 2017 @ 20:31:48.354', - to: 'Oct 5, 2017 @ 20:35:12.176', - }); + await setup( + 'x-pack/test/functional/es_archives/monitoring/singlecluster_three_nodes_shard_relocation_mb', + { + from: 'Oct 5, 2017 @ 20:31:48.354', + to: 'Oct 5, 2017 @ 20:35:12.176', + } + ); // go to nodes listing await overview.clickEsNodes(); @@ -74,7 +77,7 @@ export default function ({ getService, getPageObjects }) { const { setup, tearDown } = getLifecycleMethods(getService, getPageObjects); before(async () => { - await setup('monitoring/singlecluster_red_platinum', { + await setup('x-pack/test/functional/es_archives/monitoring/singlecluster_red_platinum', { from: 'Oct 6, 2017 @ 19:53:06.748', to: 'Oct 6, 2017 @ 20:15:30.212', }); @@ -110,10 +113,13 @@ export default function ({ getService, getPageObjects }) { const { setup, tearDown } = getLifecycleMethods(getService, getPageObjects); before(async () => { - await setup('monitoring/singlecluster_three_nodes_shard_relocation', { - from: 'Oct 5, 2017 @ 20:31:48.354', - to: 'Oct 5, 2017 @ 20:35:12.176', - }); + await setup( + 'x-pack/test/functional/es_archives/monitoring/singlecluster_three_nodes_shard_relocation', + { + from: 'Oct 5, 2017 @ 20:31:48.354', + to: 'Oct 5, 2017 @ 20:35:12.176', + } + ); // go to nodes listing await overview.clickEsNodes(); diff --git a/x-pack/test/functional/apps/monitoring/elasticsearch/nodes.js b/x-pack/test/functional/apps/monitoring/elasticsearch/nodes.js index eb2075f017175..02f65fd5579da 100644 --- a/x-pack/test/functional/apps/monitoring/elasticsearch/nodes.js +++ b/x-pack/test/functional/apps/monitoring/elasticsearch/nodes.js @@ -21,10 +21,13 @@ export default function ({ getService, getPageObjects }) { const { setup, tearDown } = getLifecycleMethods(getService, getPageObjects); before(async () => { - await setup('monitoring/singlecluster_three_nodes_shard_relocation', { - from: 'Oct 5, 2017 @ 20:28:28.475', - to: 'Oct 5, 2017 @ 20:34:38.341', - }); + await setup( + 'x-pack/test/functional/es_archives/monitoring/singlecluster_three_nodes_shard_relocation', + { + from: 'Oct 5, 2017 @ 20:28:28.475', + to: 'Oct 5, 2017 @ 20:34:38.341', + } + ); // go to nodes listing await overview.clickEsNodes(); @@ -250,10 +253,13 @@ export default function ({ getService, getPageObjects }) { const { setup, tearDown } = getLifecycleMethods(getService, getPageObjects); before(async () => { - await setup('monitoring/singlecluster_three_nodes_shard_relocation', { - from: 'Oct 5, 2017 @ 20:31:48.354', - to: 'Oct 5, 2017 @ 20:35:12.176', - }); + await setup( + 'x-pack/test/functional/es_archives/monitoring/singlecluster_three_nodes_shard_relocation', + { + from: 'Oct 5, 2017 @ 20:31:48.354', + to: 'Oct 5, 2017 @ 20:35:12.176', + } + ); // go to nodes listing await overview.clickEsNodes(); diff --git a/x-pack/test/functional/apps/monitoring/elasticsearch/nodes_mb.js b/x-pack/test/functional/apps/monitoring/elasticsearch/nodes_mb.js index 3727a841ba917..78462e0d5ec3d 100644 --- a/x-pack/test/functional/apps/monitoring/elasticsearch/nodes_mb.js +++ b/x-pack/test/functional/apps/monitoring/elasticsearch/nodes_mb.js @@ -21,10 +21,13 @@ export default function ({ getService, getPageObjects }) { const { setup, tearDown } = getLifecycleMethods(getService, getPageObjects); before(async () => { - await setup('monitoring/singlecluster_three_nodes_shard_relocation_mb', { - from: 'Oct 5, 2017 @ 20:28:28.475', - to: 'Oct 5, 2017 @ 20:34:38.341', - }); + await setup( + 'x-pack/test/functional/es_archives/monitoring/singlecluster_three_nodes_shard_relocation_mb', + { + from: 'Oct 5, 2017 @ 20:28:28.475', + to: 'Oct 5, 2017 @ 20:34:38.341', + } + ); // go to nodes listing await overview.clickEsNodes(); @@ -250,10 +253,13 @@ export default function ({ getService, getPageObjects }) { const { setup, tearDown } = getLifecycleMethods(getService, getPageObjects); before(async () => { - await setup('monitoring/singlecluster_three_nodes_shard_relocation', { - from: 'Oct 5, 2017 @ 20:31:48.354', - to: 'Oct 5, 2017 @ 20:35:12.176', - }); + await setup( + 'x-pack/test/functional/es_archives/monitoring/singlecluster_three_nodes_shard_relocation', + { + from: 'Oct 5, 2017 @ 20:31:48.354', + to: 'Oct 5, 2017 @ 20:35:12.176', + } + ); // go to nodes listing await overview.clickEsNodes(); diff --git a/x-pack/test/functional/apps/monitoring/elasticsearch/overview.js b/x-pack/test/functional/apps/monitoring/elasticsearch/overview.js index 57d354cebbfe0..61c8c6b266b0d 100644 --- a/x-pack/test/functional/apps/monitoring/elasticsearch/overview.js +++ b/x-pack/test/functional/apps/monitoring/elasticsearch/overview.js @@ -17,10 +17,13 @@ export default function ({ getService, getPageObjects }) { const { setup, tearDown } = getLifecycleMethods(getService, getPageObjects); before(async () => { - await setup('monitoring/singlecluster_three_nodes_shard_relocation', { - from: 'Oct 5, 2017 @ 20:31:48.354', - to: 'Oct 5, 2017 @ 20:35:12.176', - }); + await setup( + 'x-pack/test/functional/es_archives/monitoring/singlecluster_three_nodes_shard_relocation', + { + from: 'Oct 5, 2017 @ 20:31:48.354', + to: 'Oct 5, 2017 @ 20:35:12.176', + } + ); // go to overview await clusterOverview.clickEsOverview(); diff --git a/x-pack/test/functional/apps/monitoring/elasticsearch/overview_mb.js b/x-pack/test/functional/apps/monitoring/elasticsearch/overview_mb.js index 65e77be0e27b9..7c279119e65d7 100644 --- a/x-pack/test/functional/apps/monitoring/elasticsearch/overview_mb.js +++ b/x-pack/test/functional/apps/monitoring/elasticsearch/overview_mb.js @@ -17,10 +17,13 @@ export default function ({ getService, getPageObjects }) { const { setup, tearDown } = getLifecycleMethods(getService, getPageObjects); before(async () => { - await setup('monitoring/singlecluster_three_nodes_shard_relocation_mb', { - from: 'Oct 5, 2017 @ 20:31:48.354', - to: 'Oct 5, 2017 @ 20:35:12.176', - }); + await setup( + 'x-pack/test/functional/es_archives/monitoring/singlecluster_three_nodes_shard_relocation_mb', + { + from: 'Oct 5, 2017 @ 20:31:48.354', + to: 'Oct 5, 2017 @ 20:35:12.176', + } + ); // go to overview await clusterOverview.clickEsOverview(); diff --git a/x-pack/test/functional/apps/monitoring/elasticsearch/shards.js b/x-pack/test/functional/apps/monitoring/elasticsearch/shards.js index 36b2aa46e7abb..b4b2ba521cb1e 100644 --- a/x-pack/test/functional/apps/monitoring/elasticsearch/shards.js +++ b/x-pack/test/functional/apps/monitoring/elasticsearch/shards.js @@ -21,10 +21,13 @@ export default function ({ getService, getPageObjects }) { const { setup, tearDown } = getLifecycleMethods(getService, getPageObjects); before(async () => { - await setup('monitoring/singlecluster_three_nodes_shard_relocation', { - from: 'Oct 5, 2017 @ 19:34:48.000', - to: 'Oct 5, 2017 @ 20:35:12.000', - }); + await setup( + 'x-pack/test/functional/es_archives/monitoring/singlecluster_three_nodes_shard_relocation', + { + from: 'Oct 5, 2017 @ 19:34:48.000', + to: 'Oct 5, 2017 @ 20:35:12.000', + } + ); }); after(async () => { diff --git a/x-pack/test/functional/apps/monitoring/feature_controls/monitoring_security.ts b/x-pack/test/functional/apps/monitoring/feature_controls/monitoring_security.ts index f56ab612dc33d..988bbdc621f5f 100644 --- a/x-pack/test/functional/apps/monitoring/feature_controls/monitoring_security.ts +++ b/x-pack/test/functional/apps/monitoring/feature_controls/monitoring_security.ts @@ -16,7 +16,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { describe('security', () => { before(async () => { - await esArchiver.load('empty_kibana'); + await esArchiver.load('x-pack/test/functional/es_archives/empty_kibana'); await security.role.create('global_all_role', { elasticsearch: { @@ -35,7 +35,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { }); after(async () => { - await esArchiver.unload('empty_kibana'); + await esArchiver.unload('x-pack/test/functional/es_archives/empty_kibana'); await security.role.delete('global_all_role'); // logout, so the other tests don't accidentally run as the custom users we're testing below diff --git a/x-pack/test/functional/apps/monitoring/feature_controls/monitoring_spaces.ts b/x-pack/test/functional/apps/monitoring/feature_controls/monitoring_spaces.ts index 5b6bd8b254c37..f2b872bccbaa7 100644 --- a/x-pack/test/functional/apps/monitoring/feature_controls/monitoring_spaces.ts +++ b/x-pack/test/functional/apps/monitoring/feature_controls/monitoring_spaces.ts @@ -17,11 +17,11 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { describe('spaces', () => { before(async () => { - await esArchiver.load('empty_kibana'); + await esArchiver.load('x-pack/test/functional/es_archives/empty_kibana'); }); after(async () => { - await esArchiver.unload('empty_kibana'); + await esArchiver.unload('x-pack/test/functional/es_archives/empty_kibana'); await PageObjects.common.navigateToApp('home'); await PageObjects.security.forceLogout(); }); diff --git a/x-pack/test/functional/apps/monitoring/kibana/instance.js b/x-pack/test/functional/apps/monitoring/kibana/instance.js index e96c4639ee58a..97f73795e44e0 100644 --- a/x-pack/test/functional/apps/monitoring/kibana/instance.js +++ b/x-pack/test/functional/apps/monitoring/kibana/instance.js @@ -17,7 +17,7 @@ export default function ({ getService, getPageObjects }) { const { setup, tearDown } = getLifecycleMethods(getService, getPageObjects); before(async () => { - await setup('monitoring/singlecluster_yellow_platinum', { + await setup('x-pack/test/functional/es_archives/monitoring/singlecluster_yellow_platinum', { from: 'Aug 29, 2017 @ 17:24:14.254', to: 'Aug 29, 2017 @ 17:25:44.142', }); diff --git a/x-pack/test/functional/apps/monitoring/kibana/instance_mb.js b/x-pack/test/functional/apps/monitoring/kibana/instance_mb.js index c0164b3e0796c..a615ed0cf9d59 100644 --- a/x-pack/test/functional/apps/monitoring/kibana/instance_mb.js +++ b/x-pack/test/functional/apps/monitoring/kibana/instance_mb.js @@ -17,10 +17,13 @@ export default function ({ getService, getPageObjects }) { const { setup, tearDown } = getLifecycleMethods(getService, getPageObjects); before(async () => { - await setup('monitoring/singlecluster_yellow_platinum_mb', { - from: 'Aug 29, 2017 @ 17:24:14.254', - to: 'Aug 29, 2017 @ 17:25:44.142', - }); + await setup( + 'x-pack/test/functional/es_archives/monitoring/singlecluster_yellow_platinum_mb', + { + from: 'Aug 29, 2017 @ 17:24:14.254', + to: 'Aug 29, 2017 @ 17:25:44.142', + } + ); // go to kibana instance await clusterOverview.clickKibanaInstances(); diff --git a/x-pack/test/functional/apps/monitoring/kibana/instances.js b/x-pack/test/functional/apps/monitoring/kibana/instances.js index 2b6a9a3f35f69..554c3c3ece0e1 100644 --- a/x-pack/test/functional/apps/monitoring/kibana/instances.js +++ b/x-pack/test/functional/apps/monitoring/kibana/instances.js @@ -17,7 +17,7 @@ export default function ({ getService, getPageObjects }) { const { setup, tearDown } = getLifecycleMethods(getService, getPageObjects); before(async () => { - await setup('monitoring/singlecluster_yellow_platinum', { + await setup('x-pack/test/functional/es_archives/monitoring/singlecluster_yellow_platinum', { from: 'Aug 29, 2017 @ 17:24:14.254', to: 'Aug 29, 2017 @ 17:25:44.142', }); diff --git a/x-pack/test/functional/apps/monitoring/kibana/instances_mb.js b/x-pack/test/functional/apps/monitoring/kibana/instances_mb.js index 3317513f8157d..695ef81bf71fb 100644 --- a/x-pack/test/functional/apps/monitoring/kibana/instances_mb.js +++ b/x-pack/test/functional/apps/monitoring/kibana/instances_mb.js @@ -18,10 +18,13 @@ export default function ({ getService, getPageObjects }) { const { setup, tearDown } = getLifecycleMethods(getService, getPageObjects); before(async () => { - await setup('monitoring/singlecluster_yellow_platinum_mb', { - from: 'Aug 29, 2017 @ 17:24:14.254', - to: 'Aug 29, 2017 @ 17:25:44.142', - }); + await setup( + 'x-pack/test/functional/es_archives/monitoring/singlecluster_yellow_platinum_mb', + { + from: 'Aug 29, 2017 @ 17:24:14.254', + to: 'Aug 29, 2017 @ 17:25:44.142', + } + ); // go to kibana instances await clusterOverview.clickKibanaInstances(); diff --git a/x-pack/test/functional/apps/monitoring/kibana/overview.js b/x-pack/test/functional/apps/monitoring/kibana/overview.js index 9fc33fd1aa4da..060c368563a95 100644 --- a/x-pack/test/functional/apps/monitoring/kibana/overview.js +++ b/x-pack/test/functional/apps/monitoring/kibana/overview.js @@ -17,7 +17,7 @@ export default function ({ getService, getPageObjects }) { const { setup, tearDown } = getLifecycleMethods(getService, getPageObjects); before(async () => { - await setup('monitoring/singlecluster_yellow_platinum', { + await setup('x-pack/test/functional/es_archives/monitoring/singlecluster_yellow_platinum', { from: 'Aug 29, 2017 @ 17:24:14.254', to: 'Aug 29, 2017 @ 17:25:44.142', }); diff --git a/x-pack/test/functional/apps/monitoring/kibana/overview_mb.js b/x-pack/test/functional/apps/monitoring/kibana/overview_mb.js index 581c321e98c94..5f8b926e5d17c 100644 --- a/x-pack/test/functional/apps/monitoring/kibana/overview_mb.js +++ b/x-pack/test/functional/apps/monitoring/kibana/overview_mb.js @@ -17,10 +17,13 @@ export default function ({ getService, getPageObjects }) { const { setup, tearDown } = getLifecycleMethods(getService, getPageObjects); before(async () => { - await setup('monitoring/singlecluster_yellow_platinum_mb', { - from: 'Aug 29, 2017 @ 17:24:14.254', - to: 'Aug 29, 2017 @ 17:25:44.142', - }); + await setup( + 'x-pack/test/functional/es_archives/monitoring/singlecluster_yellow_platinum_mb', + { + from: 'Aug 29, 2017 @ 17:24:14.254', + to: 'Aug 29, 2017 @ 17:25:44.142', + } + ); // go to kibana overview await clusterOverview.clickKibanaOverview(); diff --git a/x-pack/test/functional/apps/monitoring/logstash/pipelines.js b/x-pack/test/functional/apps/monitoring/logstash/pipelines.js index 07b9702ac432f..2f698f83912c1 100644 --- a/x-pack/test/functional/apps/monitoring/logstash/pipelines.js +++ b/x-pack/test/functional/apps/monitoring/logstash/pipelines.js @@ -19,7 +19,7 @@ export default function ({ getService, getPageObjects }) { const { setup, tearDown } = getLifecycleMethods(getService, getPageObjects); before(async () => { - await setup('monitoring/logstash_pipelines', { + await setup('x-pack/test/functional/es_archives/monitoring/logstash_pipelines', { from: 'Jan 22, 2018 @ 09:10:00.000', to: 'Jan 22, 2018 @ 09:41:00.000', }); diff --git a/x-pack/test/functional/apps/monitoring/logstash/pipelines_mb.js b/x-pack/test/functional/apps/monitoring/logstash/pipelines_mb.js index 5f47d3832caa1..508f919d97efd 100644 --- a/x-pack/test/functional/apps/monitoring/logstash/pipelines_mb.js +++ b/x-pack/test/functional/apps/monitoring/logstash/pipelines_mb.js @@ -19,7 +19,7 @@ export default function ({ getService, getPageObjects }) { const { setup, tearDown } = getLifecycleMethods(getService, getPageObjects); before(async () => { - await setup('monitoring/logstash_pipelines_mb', { + await setup('x-pack/test/functional/es_archives/monitoring/logstash_pipelines_mb', { from: 'Jan 22, 2018 @ 09:10:00.000', to: 'Jan 22, 2018 @ 09:41:00.000', }); diff --git a/x-pack/test/functional/apps/monitoring/setup/metricbeat_migration.js b/x-pack/test/functional/apps/monitoring/setup/metricbeat_migration.js index a0986fa1c68b8..a9a58f8b373ff 100644 --- a/x-pack/test/functional/apps/monitoring/setup/metricbeat_migration.js +++ b/x-pack/test/functional/apps/monitoring/setup/metricbeat_migration.js @@ -19,11 +19,14 @@ export default function ({ getService, getPageObjects }) { const { setup, tearDown } = getLifecycleMethods(getService, getPageObjects); before(async () => { - await setup('monitoring/setup/collection/es_and_kibana', { - from: 'Apr 9, 2019 @ 00:00:00.741', - to: 'Apr 9, 2019 @ 23:59:59.741', - useSuperUser: true, - }); + await setup( + 'x-pack/test/functional/es_archives/monitoring/setup/collection/es_and_kibana', + { + from: 'Apr 9, 2019 @ 00:00:00.741', + to: 'Apr 9, 2019 @ 23:59:59.741', + useSuperUser: true, + } + ); }); after(async () => { diff --git a/x-pack/test/functional/apps/monitoring/setup/metricbeat_migration_mb.js b/x-pack/test/functional/apps/monitoring/setup/metricbeat_migration_mb.js index 04bee66dfb03b..d5402dda790e5 100644 --- a/x-pack/test/functional/apps/monitoring/setup/metricbeat_migration_mb.js +++ b/x-pack/test/functional/apps/monitoring/setup/metricbeat_migration_mb.js @@ -19,11 +19,14 @@ export default function ({ getService, getPageObjects }) { const { setup, tearDown } = getLifecycleMethods(getService, getPageObjects); before(async () => { - await setup('monitoring/setup/collection/es_and_kibana_mb', { - from: 'Apr 9, 2019 @ 00:00:00.741', - to: 'Apr 9, 2019 @ 23:59:59.741', - useSuperUser: true, - }); + await setup( + 'x-pack/test/functional/es_archives/monitoring/setup/collection/es_and_kibana_mb', + { + from: 'Apr 9, 2019 @ 00:00:00.741', + to: 'Apr 9, 2019 @ 23:59:59.741', + useSuperUser: true, + } + ); }); after(async () => { diff --git a/x-pack/test/functional/apps/monitoring/time_filter.js b/x-pack/test/functional/apps/monitoring/time_filter.js index 21f0aaf5a60c9..910b91d07039d 100644 --- a/x-pack/test/functional/apps/monitoring/time_filter.js +++ b/x-pack/test/functional/apps/monitoring/time_filter.js @@ -17,7 +17,7 @@ export default function ({ getService, getPageObjects }) { const { setup, tearDown } = getLifecycleMethods(getService, getPageObjects); before(async () => { - await setup('monitoring/multicluster', { + await setup('x-pack/test/functional/es_archives/monitoring/multicluster', { from: 'Aug 15, 2017 @ 21:00:00.000', to: 'Aug 16, 2017 @ 00:00:00.000', }); diff --git a/x-pack/test/functional/apps/remote_clusters/feature_controls/remote_clusters_security.ts b/x-pack/test/functional/apps/remote_clusters/feature_controls/remote_clusters_security.ts index 0406419098168..dee8433f37037 100644 --- a/x-pack/test/functional/apps/remote_clusters/feature_controls/remote_clusters_security.ts +++ b/x-pack/test/functional/apps/remote_clusters/feature_controls/remote_clusters_security.ts @@ -17,12 +17,12 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { describe('security', () => { before(async () => { - await esArchiver.load('empty_kibana'); + await esArchiver.load('x-pack/test/functional/es_archives/empty_kibana'); await PageObjects.common.navigateToApp('home'); }); after(async () => { - await esArchiver.unload('empty_kibana'); + await esArchiver.unload('x-pack/test/functional/es_archives/empty_kibana'); }); describe('global all privileges (aka kibana_admin)', () => { diff --git a/x-pack/test/functional/apps/reporting/reporting.ts b/x-pack/test/functional/apps/reporting/reporting.ts index a9d089e9fd397..bd1626ec32380 100644 --- a/x-pack/test/functional/apps/reporting/reporting.ts +++ b/x-pack/test/functional/apps/reporting/reporting.ts @@ -16,11 +16,11 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('Reporting', function () { this.tags(['smoke', 'ciGroup2']); before(async () => { - await esArchiver.loadIfNeeded('packaging'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/packaging'); }); after(async () => { - await esArchiver.unload('packaging'); + await esArchiver.unload('x-pack/test/functional/es_archives/packaging'); await es.deleteByQuery({ index: '.reporting-*', refresh: true, diff --git a/x-pack/test/functional/apps/reporting_management/report_listing.ts b/x-pack/test/functional/apps/reporting_management/report_listing.ts index e6503b1550001..0b1fce3700986 100644 --- a/x-pack/test/functional/apps/reporting_management/report_listing.ts +++ b/x-pack/test/functional/apps/reporting_management/report_listing.ts @@ -30,23 +30,23 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { ], }); await security.testUser.setRoles(['kibana_admin', 'test_reporting_user']); - await esArchiver.load('empty_kibana'); + await esArchiver.load('x-pack/test/functional/es_archives/empty_kibana'); }); beforeEach(async () => { // to reset the data after deletion testing - await esArchiver.load('reporting/archived_reports'); + await esArchiver.load('x-pack/test/functional/es_archives/reporting/archived_reports'); await pageObjects.common.navigateToApp('reporting'); await testSubjects.existOrFail('reportJobListing', { timeout: 200000 }); }); after(async () => { - await esArchiver.unload('empty_kibana'); + await esArchiver.unload('x-pack/test/functional/es_archives/empty_kibana'); await security.testUser.restoreDefaults(); }); afterEach(async () => { - await esArchiver.unload('reporting/archived_reports'); + await esArchiver.unload('x-pack/test/functional/es_archives/reporting/archived_reports'); }); it('Confirm single report deletion works', async () => { diff --git a/x-pack/test/functional/apps/rollup_job/hybrid_index_pattern.js b/x-pack/test/functional/apps/rollup_job/hybrid_index_pattern.js index 1eb2862901277..1986efe202224 100644 --- a/x-pack/test/functional/apps/rollup_job/hybrid_index_pattern.js +++ b/x-pack/test/functional/apps/rollup_job/hybrid_index_pattern.js @@ -111,7 +111,7 @@ export default function ({ getService, getPageObjects }) { `${rollupSourceIndexPrefix}*`, ]); - await esArchiver.load('empty_kibana'); + await esArchiver.load('x-pack/test/functional/es_archives/empty_kibana'); }); }); } diff --git a/x-pack/test/functional/apps/rollup_job/rollup_jobs.js b/x-pack/test/functional/apps/rollup_job/rollup_jobs.js index a0684a77748b7..4f535ae3e3ef0 100644 --- a/x-pack/test/functional/apps/rollup_job/rollup_jobs.js +++ b/x-pack/test/functional/apps/rollup_job/rollup_jobs.js @@ -71,7 +71,7 @@ export default function ({ getService, getPageObjects }) { //Delete all data indices that were created. await esDeleteAllIndices([targetIndexName, rollupSourceIndexPattern]); - await esArchiver.load('empty_kibana'); + await esArchiver.load('x-pack/test/functional/es_archives/empty_kibana'); await security.testUser.restoreDefaults(); }); }); diff --git a/x-pack/test/functional/apps/rollup_job/tsvb.js b/x-pack/test/functional/apps/rollup_job/tsvb.js index 891805acb3256..ba39a8aaa436b 100644 --- a/x-pack/test/functional/apps/rollup_job/tsvb.js +++ b/x-pack/test/functional/apps/rollup_job/tsvb.js @@ -35,7 +35,7 @@ export default function ({ getService, getPageObjects }) { before(async () => { // load visualize to have an index pattern ready, otherwise visualize will redirect - await esArchiver.load('visualize/default'); + await esArchiver.load('x-pack/test/functional/es_archives/visualize/default'); }); it('create rollup tsvb', async () => { @@ -100,7 +100,7 @@ export default function ({ getService, getPageObjects }) { }); await esDeleteAllIndices([rollupTargetIndexName, rollupSourceIndexName]); - await esArchiver.load('empty_kibana'); + await esArchiver.load('x-pack/test/functional/es_archives/empty_kibana'); }); }); } diff --git a/x-pack/test/functional/apps/saved_objects_management/feature_controls/saved_objects_management_security.ts b/x-pack/test/functional/apps/saved_objects_management/feature_controls/saved_objects_management_security.ts index d9ba3a78eff13..c25c81b9a38b3 100644 --- a/x-pack/test/functional/apps/saved_objects_management/feature_controls/saved_objects_management_security.ts +++ b/x-pack/test/functional/apps/saved_objects_management/feature_controls/saved_objects_management_security.ts @@ -17,13 +17,17 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { describe('feature controls saved objects management', () => { before(async () => { - await esArchiver.load('saved_objects_management/feature_controls/security'); + await esArchiver.load( + 'x-pack/test/functional/es_archives/saved_objects_management/feature_controls/security' + ); const versionService = getService('kibanaServer').version; version = await versionService.get(); }); after(async () => { - await esArchiver.unload('saved_objects_management/feature_controls/security'); + await esArchiver.unload( + 'x-pack/test/functional/es_archives/saved_objects_management/feature_controls/security' + ); }); describe('global all privileges', () => { diff --git a/x-pack/test/functional/apps/saved_objects_management/import_saved_objects_between_versions.ts b/x-pack/test/functional/apps/saved_objects_management/import_saved_objects_between_versions.ts index 919ba205a0762..b83263eafd9d9 100644 --- a/x-pack/test/functional/apps/saved_objects_management/import_saved_objects_between_versions.ts +++ b/x-pack/test/functional/apps/saved_objects_management/import_saved_objects_between_versions.ts @@ -22,17 +22,17 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('Export import saved objects between versions', function () { beforeEach(async function () { - await esArchiver.load('logstash_functional'); - await esArchiver.load('getting_started/shakespeare'); + await esArchiver.load('x-pack/test/functional/es_archives/logstash_functional'); + await esArchiver.load('x-pack/test/functional/es_archives/getting_started/shakespeare'); await kibanaServer.uiSettings.replace({}); await PageObjects.settings.navigateTo(); await PageObjects.settings.clickKibanaSavedObjects(); }); after(async () => { - await esArchiver.unload('logstash_functional'); - await esArchiver.unload('getting_started/shakespeare'); - await esArchiver.load('empty_kibana'); + await esArchiver.unload('x-pack/test/functional/es_archives/logstash_functional'); + await esArchiver.unload('x-pack/test/functional/es_archives/getting_started/shakespeare'); + await esArchiver.load('x-pack/test/functional/es_archives/empty_kibana'); }); it('should be able to import 7.13 saved objects into 8.0.0', async function () { diff --git a/x-pack/test/functional/apps/saved_objects_management/spaces_integration.ts b/x-pack/test/functional/apps/saved_objects_management/spaces_integration.ts index 602a8c01a0525..28d04c1f9c54c 100644 --- a/x-pack/test/functional/apps/saved_objects_management/spaces_integration.ts +++ b/x-pack/test/functional/apps/saved_objects_management/spaces_integration.ts @@ -27,11 +27,15 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { describe('spaces integration', () => { before(async () => { - await esArchiver.load('saved_objects_management/spaces_integration'); + await esArchiver.load( + 'x-pack/test/functional/es_archives/saved_objects_management/spaces_integration' + ); }); after(async () => { - await esArchiver.unload('saved_objects_management/spaces_integration'); + await esArchiver.unload( + 'x-pack/test/functional/es_archives/saved_objects_management/spaces_integration' + ); }); beforeEach(async () => { diff --git a/x-pack/test/functional/apps/security/doc_level_security_roles.js b/x-pack/test/functional/apps/security/doc_level_security_roles.js index 4fbb120e13785..2cbaae144d722 100644 --- a/x-pack/test/functional/apps/security/doc_level_security_roles.js +++ b/x-pack/test/functional/apps/security/doc_level_security_roles.js @@ -18,8 +18,8 @@ export default function ({ getService, getPageObjects }) { describe('dls', function () { before('initialize tests', async () => { - await esArchiver.load('empty_kibana'); - await esArchiver.loadIfNeeded('security/dlstest'); + await esArchiver.load('x-pack/test/functional/es_archives/empty_kibana'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/security/dlstest'); await browser.setWindowSize(1600, 1000); await PageObjects.common.navigateToApp('settings'); diff --git a/x-pack/test/functional/apps/security/field_level_security.js b/x-pack/test/functional/apps/security/field_level_security.js index 220a70b2ae9f0..f58e6837b9441 100644 --- a/x-pack/test/functional/apps/security/field_level_security.js +++ b/x-pack/test/functional/apps/security/field_level_security.js @@ -17,8 +17,8 @@ export default function ({ getService, getPageObjects }) { describe('field_level_security', () => { before('initialize tests', async () => { - await esArchiver.loadIfNeeded('security/flstest/data'); //( data) - await esArchiver.load('security/flstest/kibana'); //(savedobject) + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/security/flstest/data'); //( data) + await esArchiver.load('x-pack/test/functional/es_archives/security/flstest/kibana'); //(savedobject) await browser.setWindowSize(1600, 1000); }); diff --git a/x-pack/test/functional/apps/security/secure_roles_perm.js b/x-pack/test/functional/apps/security/secure_roles_perm.js index 33913bcbbf7f0..027d7027d46ee 100644 --- a/x-pack/test/functional/apps/security/secure_roles_perm.js +++ b/x-pack/test/functional/apps/security/secure_roles_perm.js @@ -27,9 +27,9 @@ export default function ({ getService, getPageObjects }) { before(async () => { await browser.setWindowSize(1600, 1000); log.debug('users'); - await esArchiver.loadIfNeeded('logstash_functional'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/logstash_functional'); log.debug('load kibana index with default index pattern'); - await esArchiver.load('security/discover'); + await esArchiver.load('x-pack/test/functional/es_archives/security/discover'); await kibanaServer.uiSettings.replace({ defaultIndex: 'logstash-*' }); await PageObjects.settings.navigateTo(); }); diff --git a/x-pack/test/functional/apps/security/security.ts b/x-pack/test/functional/apps/security/security.ts index 70db20d6d0c48..8cee43d0f3c11 100644 --- a/x-pack/test/functional/apps/security/security.ts +++ b/x-pack/test/functional/apps/security/security.ts @@ -20,12 +20,12 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { this.tags('includeFirefox'); describe('Login Page', () => { before(async () => { - await esArchiver.load('empty_kibana'); + await esArchiver.load('x-pack/test/functional/es_archives/empty_kibana'); await PageObjects.security.forceLogout(); }); after(async () => { - await esArchiver.unload('empty_kibana'); + await esArchiver.unload('x-pack/test/functional/es_archives/empty_kibana'); }); afterEach(async () => { diff --git a/x-pack/test/functional/apps/security/user_email.js b/x-pack/test/functional/apps/security/user_email.js index ba97be40b2a49..bb9b0a865ee6b 100644 --- a/x-pack/test/functional/apps/security/user_email.js +++ b/x-pack/test/functional/apps/security/user_email.js @@ -14,7 +14,7 @@ export default function ({ getService, getPageObjects }) { describe('useremail', function () { before(async () => { - await esArchiver.load('security/discover'); + await esArchiver.load('x-pack/test/functional/es_archives/security/discover'); await PageObjects.settings.navigateTo(); await PageObjects.security.clickElasticsearchUsers(); }); diff --git a/x-pack/test/functional/apps/spaces/copy_saved_objects.ts b/x-pack/test/functional/apps/spaces/copy_saved_objects.ts index 742546a53258a..2d2fdf61a94b6 100644 --- a/x-pack/test/functional/apps/spaces/copy_saved_objects.ts +++ b/x-pack/test/functional/apps/spaces/copy_saved_objects.ts @@ -19,7 +19,7 @@ export default function spaceSelectorFunctonalTests({ describe('Copy Saved Objects to Space', function () { before(async () => { - await esArchiver.load('spaces/copy_saved_objects'); + await esArchiver.load('x-pack/test/functional/es_archives/spaces/copy_saved_objects'); await spaces.create({ id: 'marketing', @@ -45,7 +45,7 @@ export default function spaceSelectorFunctonalTests({ after(async () => { await spaces.delete('sales'); await spaces.delete('marketing'); - await esArchiver.unload('spaces/copy_saved_objects'); + await esArchiver.unload('x-pack/test/functional/es_archives/spaces/copy_saved_objects'); }); it('allows a dashboard to be copied to the marketing space, with all references', async () => { diff --git a/x-pack/test/functional/apps/spaces/enter_space.ts b/x-pack/test/functional/apps/spaces/enter_space.ts index b2619ab0385ea..f708282393d83 100644 --- a/x-pack/test/functional/apps/spaces/enter_space.ts +++ b/x-pack/test/functional/apps/spaces/enter_space.ts @@ -18,10 +18,12 @@ export default function enterSpaceFunctonalTests({ describe.skip('Enter Space', function () { this.tags('includeFirefox'); before(async () => { - await esArchiver.load('spaces/enter_space'); + await esArchiver.load('x-pack/test/functional/es_archives/spaces/enter_space'); await PageObjects.security.forceLogout(); }); - after(async () => await esArchiver.unload('spaces/enter_space')); + after( + async () => await esArchiver.unload('x-pack/test/functional/es_archives/spaces/enter_space') + ); afterEach(async () => { await PageObjects.security.forceLogout(); diff --git a/x-pack/test/functional/apps/spaces/feature_controls/spaces_security.ts b/x-pack/test/functional/apps/spaces/feature_controls/spaces_security.ts index 8a5e9495d5378..a91166810b626 100644 --- a/x-pack/test/functional/apps/spaces/feature_controls/spaces_security.ts +++ b/x-pack/test/functional/apps/spaces/feature_controls/spaces_security.ts @@ -17,11 +17,11 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { describe('security feature controls', () => { before(async () => { - await esArchiver.load('empty_kibana'); + await esArchiver.load('x-pack/test/functional/es_archives/empty_kibana'); }); after(async () => { - await esArchiver.unload('empty_kibana'); + await esArchiver.unload('x-pack/test/functional/es_archives/empty_kibana'); }); describe('global all base privilege', () => { diff --git a/x-pack/test/functional/apps/spaces/spaces_selection.ts b/x-pack/test/functional/apps/spaces/spaces_selection.ts index f3d3665bf9f61..0b9d1f420c663 100644 --- a/x-pack/test/functional/apps/spaces/spaces_selection.ts +++ b/x-pack/test/functional/apps/spaces/spaces_selection.ts @@ -27,10 +27,12 @@ export default function spaceSelectorFunctionalTests({ this.tags('includeFirefox'); describe('Space Selector', () => { before(async () => { - await esArchiver.load('spaces/selector'); + await esArchiver.load('x-pack/test/functional/es_archives/spaces/selector'); await PageObjects.security.forceLogout(); }); - after(async () => await esArchiver.unload('spaces/selector')); + after( + async () => await esArchiver.unload('x-pack/test/functional/es_archives/spaces/selector') + ); afterEach(async () => { await PageObjects.security.forceLogout(); @@ -69,7 +71,7 @@ export default function spaceSelectorFunctionalTests({ }; before(async () => { - await esArchiver.load('spaces/selector'); + await esArchiver.load('x-pack/test/functional/es_archives/spaces/selector'); await PageObjects.security.login(undefined, undefined, { expectSpaceSelector: true, }); @@ -89,13 +91,13 @@ export default function spaceSelectorFunctionalTests({ // No need to remove the same sample data in both spaces, the index // data will be removed in the first call. By feature limitation, // the created saved objects in the second space will be broken but removed - // when we call esArchiver.unload('spaces'). + // when we call esArchiver.unload('x-pack/test/functional/es_archives/spaces'). await PageObjects.common.navigateToApp('home', { hash: sampleDataHash, }); await PageObjects.home.removeSampleDataSet('logs'); await PageObjects.security.forceLogout(); - await esArchiver.unload('spaces/selector'); + await esArchiver.unload('x-pack/test/functional/es_archives/spaces/selector'); }); describe('displays separate data for each space', () => { diff --git a/x-pack/test/functional/apps/status_page/status_page.ts b/x-pack/test/functional/apps/status_page/status_page.ts index ecef6225632e9..f69ef94095098 100644 --- a/x-pack/test/functional/apps/status_page/status_page.ts +++ b/x-pack/test/functional/apps/status_page/status_page.ts @@ -16,8 +16,8 @@ export default function statusPageFunctonalTests({ describe('Status Page', function () { this.tags(['skipCloud', 'includeFirefox']); - before(async () => await esArchiver.load('empty_kibana')); - after(async () => await esArchiver.unload('empty_kibana')); + before(async () => await esArchiver.load('x-pack/test/functional/es_archives/empty_kibana')); + after(async () => await esArchiver.unload('x-pack/test/functional/es_archives/empty_kibana')); it('allows user to navigate without authentication', async () => { await PageObjects.security.forceLogout(); diff --git a/x-pack/test/functional/apps/timelion/feature_controls/timelion_security.ts b/x-pack/test/functional/apps/timelion/feature_controls/timelion_security.ts index bba81b81311d6..e83eabfb05f44 100644 --- a/x-pack/test/functional/apps/timelion/feature_controls/timelion_security.ts +++ b/x-pack/test/functional/apps/timelion/feature_controls/timelion_security.ts @@ -24,8 +24,8 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { describe('feature controls security', () => { before(async () => { - await esArchiver.loadIfNeeded('timelion/feature_controls'); - await esArchiver.loadIfNeeded('logstash_functional'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/timelion/feature_controls'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/logstash_functional'); }); describe('global timelion all privileges', () => { diff --git a/x-pack/test/functional/apps/timelion/feature_controls/timelion_spaces.ts b/x-pack/test/functional/apps/timelion/feature_controls/timelion_spaces.ts index 8b9eefddb3323..91c357f37085e 100644 --- a/x-pack/test/functional/apps/timelion/feature_controls/timelion_spaces.ts +++ b/x-pack/test/functional/apps/timelion/feature_controls/timelion_spaces.ts @@ -16,14 +16,14 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { describe('timelion', () => { before(async () => { - await esArchiver.loadIfNeeded('logstash_functional'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/logstash_functional'); }); describe('space with no features disabled', () => { before(async () => { // we need to load the following in every situation as deleting // a space deletes all of the associated saved objects - await esArchiver.load('timelion/feature_controls'); + await esArchiver.load('x-pack/test/functional/es_archives/timelion/feature_controls'); await spacesService.create({ id: 'custom_space', name: 'custom_space', @@ -33,7 +33,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { after(async () => { await spacesService.delete('custom_space'); - await esArchiver.unload('timelion/feature_controls'); + await esArchiver.unload('x-pack/test/functional/es_archives/timelion/feature_controls'); }); it('shows timelion navlink', async () => { @@ -54,7 +54,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { before(async () => { // we need to load the following in every situation as deleting // a space deletes all of the associated saved objects - await esArchiver.load('timelion/feature_controls'); + await esArchiver.load('x-pack/test/functional/es_archives/timelion/feature_controls'); await spacesService.create({ id: 'custom_space', name: 'custom_space', @@ -64,7 +64,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { after(async () => { await spacesService.delete('custom_space'); - await esArchiver.unload('timelion/feature_controls'); + await esArchiver.unload('x-pack/test/functional/es_archives/timelion/feature_controls'); }); it(`doesn't show timelion navlink`, async () => { diff --git a/x-pack/test/functional/apps/transform/cloning.ts b/x-pack/test/functional/apps/transform/cloning.ts index 3084871befe37..6bf3c9afb3547 100644 --- a/x-pack/test/functional/apps/transform/cloning.ts +++ b/x-pack/test/functional/apps/transform/cloning.ts @@ -89,7 +89,7 @@ export default function ({ getService }: FtrProviderContext) { const transformConfigWithLatest = getLatestTransformConfig('cloning'); before(async () => { - await esArchiver.loadIfNeeded('ml/ecommerce'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/ml/ecommerce'); await transform.testResources.createIndexPatternIfNeeded('ft_ecommerce', 'order_date'); await transform.api.createAndRunTransform( transformConfigWithPivot.id, diff --git a/x-pack/test/functional/apps/transform/creation_index_pattern.ts b/x-pack/test/functional/apps/transform/creation_index_pattern.ts index b01d5d8f66863..8b5a8c93b00b8 100644 --- a/x-pack/test/functional/apps/transform/creation_index_pattern.ts +++ b/x-pack/test/functional/apps/transform/creation_index_pattern.ts @@ -23,7 +23,7 @@ export default function ({ getService }: FtrProviderContext) { describe('creation_index_pattern', function () { before(async () => { - await esArchiver.loadIfNeeded('ml/ecommerce'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/ml/ecommerce'); await transform.testResources.createIndexPatternIfNeeded('ft_ecommerce', 'order_date'); await transform.testResources.setKibanaTimeZoneToUTC(); diff --git a/x-pack/test/functional/apps/transform/creation_runtime_mappings.ts b/x-pack/test/functional/apps/transform/creation_runtime_mappings.ts index 6add0a3ca5408..5fe9d02c58dc7 100644 --- a/x-pack/test/functional/apps/transform/creation_runtime_mappings.ts +++ b/x-pack/test/functional/apps/transform/creation_runtime_mappings.ts @@ -35,7 +35,7 @@ export default function ({ getService }: FtrProviderContext) { }; describe('creation with runtime mappings', function () { before(async () => { - await esArchiver.loadIfNeeded('ml/farequote'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/ml/farequote'); await transform.testResources.createIndexPatternIfNeeded('ft_farequote', '@timestamp'); await transform.testResources.setKibanaTimeZoneToUTC(); diff --git a/x-pack/test/functional/apps/transform/creation_saved_search.ts b/x-pack/test/functional/apps/transform/creation_saved_search.ts index 673f5b3217fb5..e5944c7f12578 100644 --- a/x-pack/test/functional/apps/transform/creation_saved_search.ts +++ b/x-pack/test/functional/apps/transform/creation_saved_search.ts @@ -22,7 +22,7 @@ export default function ({ getService }: FtrProviderContext) { describe('creation_saved_search', function () { before(async () => { - await esArchiver.loadIfNeeded('ml/farequote'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/ml/farequote'); await transform.testResources.createIndexPatternIfNeeded('ft_farequote', '@timestamp'); await transform.testResources.createSavedSearchFarequoteFilterIfNeeded(); await transform.testResources.setKibanaTimeZoneToUTC(); diff --git a/x-pack/test/functional/apps/transform/deleting.ts b/x-pack/test/functional/apps/transform/deleting.ts index 575058f8147b5..ce75c4c8b27c2 100644 --- a/x-pack/test/functional/apps/transform/deleting.ts +++ b/x-pack/test/functional/apps/transform/deleting.ts @@ -58,7 +58,7 @@ export default function ({ getService }: FtrProviderContext) { ]; before(async () => { - await esArchiver.loadIfNeeded('ml/ecommerce'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/ml/ecommerce'); await transform.testResources.createIndexPatternIfNeeded('ft_ecommerce', 'order_date'); for (const testData of testDataList) { diff --git a/x-pack/test/functional/apps/transform/editing.ts b/x-pack/test/functional/apps/transform/editing.ts index c1e08e3a4cdd7..b1e24eeb3de95 100644 --- a/x-pack/test/functional/apps/transform/editing.ts +++ b/x-pack/test/functional/apps/transform/editing.ts @@ -35,7 +35,7 @@ export default function ({ getService }: FtrProviderContext) { const transformConfigWithLatest = getLatestTransformConfig('editing'); before(async () => { - await esArchiver.loadIfNeeded('ml/ecommerce'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/ml/ecommerce'); await transform.testResources.createIndexPatternIfNeeded('ft_ecommerce', 'order_date'); await transform.api.createAndRunTransform( diff --git a/x-pack/test/functional/apps/transform/feature_controls/transform_security.ts b/x-pack/test/functional/apps/transform/feature_controls/transform_security.ts index 04c94e0a3e381..caaa37e9fdeab 100644 --- a/x-pack/test/functional/apps/transform/feature_controls/transform_security.ts +++ b/x-pack/test/functional/apps/transform/feature_controls/transform_security.ts @@ -17,13 +17,13 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { describe('security', () => { before(async () => { - await esArchiver.load('empty_kibana'); + await esArchiver.load('x-pack/test/functional/es_archives/empty_kibana'); await PageObjects.security.forceLogout(); await PageObjects.common.navigateToApp('home'); }); after(async () => { - await esArchiver.unload('empty_kibana'); + await esArchiver.unload('x-pack/test/functional/es_archives/empty_kibana'); }); describe('global all privileges (aka kibana_admin)', () => { diff --git a/x-pack/test/functional/apps/transform/index.ts b/x-pack/test/functional/apps/transform/index.ts index ca82459c47f2f..2e8fd69e8580b 100644 --- a/x-pack/test/functional/apps/transform/index.ts +++ b/x-pack/test/functional/apps/transform/index.ts @@ -32,8 +32,8 @@ export default function ({ getService, loadTestFile }: FtrProviderContext) { await transform.testResources.deleteIndexPatternByTitle('ft_farequote'); await transform.testResources.deleteIndexPatternByTitle('ft_ecommerce'); - await esArchiver.unload('ml/farequote'); - await esArchiver.unload('ml/ecommerce'); + await esArchiver.unload('x-pack/test/functional/es_archives/ml/farequote'); + await esArchiver.unload('x-pack/test/functional/es_archives/ml/ecommerce'); await transform.testResources.resetKibanaTimeZone(); await transform.securityUI.logout(); diff --git a/x-pack/test/functional/apps/transform/starting.ts b/x-pack/test/functional/apps/transform/starting.ts index e37d6e4dcd5f3..2de0bd2eea257 100644 --- a/x-pack/test/functional/apps/transform/starting.ts +++ b/x-pack/test/functional/apps/transform/starting.ts @@ -39,7 +39,7 @@ export default function ({ getService }: FtrProviderContext) { ]; before(async () => { - await esArchiver.loadIfNeeded('ml/ecommerce'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/ml/ecommerce'); await transform.testResources.createIndexPatternIfNeeded('ft_ecommerce', 'order_date'); for (const testData of testDataList) { diff --git a/x-pack/test/functional/apps/upgrade_assistant/feature_controls/upgrade_assistant_security.ts b/x-pack/test/functional/apps/upgrade_assistant/feature_controls/upgrade_assistant_security.ts index e30ac06abc7ca..3de9e252e032a 100644 --- a/x-pack/test/functional/apps/upgrade_assistant/feature_controls/upgrade_assistant_security.ts +++ b/x-pack/test/functional/apps/upgrade_assistant/feature_controls/upgrade_assistant_security.ts @@ -17,12 +17,12 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { describe('security', function () { before(async () => { - await esArchiver.load('empty_kibana'); + await esArchiver.load('x-pack/test/functional/es_archives/empty_kibana'); await PageObjects.common.navigateToApp('home'); }); after(async () => { - await esArchiver.unload('empty_kibana'); + await esArchiver.unload('x-pack/test/functional/es_archives/empty_kibana'); }); describe('global all privileges (aka kibana_admin)', () => { diff --git a/x-pack/test/functional/apps/upgrade_assistant/upgrade_assistant.ts b/x-pack/test/functional/apps/upgrade_assistant/upgrade_assistant.ts index 693b898f46636..09900b6ababef 100644 --- a/x-pack/test/functional/apps/upgrade_assistant/upgrade_assistant.ts +++ b/x-pack/test/functional/apps/upgrade_assistant/upgrade_assistant.ts @@ -24,13 +24,13 @@ export default function upgradeAssistantFunctionalTests({ this.tags('skipFirefox'); before(async () => { - await esArchiver.load('empty_kibana'); + await esArchiver.load('x-pack/test/functional/es_archives/empty_kibana'); await security.testUser.setRoles(['global_upgrade_assistant_role']); }); after(async () => { await PageObjects.upgradeAssistant.waitForTelemetryHidden(); - await esArchiver.unload('empty_kibana'); + await esArchiver.unload('x-pack/test/functional/es_archives/empty_kibana'); await security.testUser.restoreDefaults(); }); diff --git a/x-pack/test/functional/apps/uptime/feature_controls/uptime_security.ts b/x-pack/test/functional/apps/uptime/feature_controls/uptime_security.ts index aacdb18a402c1..7867170c1801c 100644 --- a/x-pack/test/functional/apps/uptime/feature_controls/uptime_security.ts +++ b/x-pack/test/functional/apps/uptime/feature_controls/uptime_security.ts @@ -18,7 +18,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { describe('security', () => { before(async () => { - await esArchiver.load('empty_kibana'); + await esArchiver.load('x-pack/test/functional/es_archives/empty_kibana'); // ensure we're logged out so we can login as the appropriate users await PageObjects.security.forceLogout(); }); diff --git a/x-pack/test/functional/apps/uptime/index.ts b/x-pack/test/functional/apps/uptime/index.ts index 0b02fd2bf322b..501fec5002666 100644 --- a/x-pack/test/functional/apps/uptime/index.ts +++ b/x-pack/test/functional/apps/uptime/index.ts @@ -11,7 +11,7 @@ import { settingsObjectType, } from '../../../../plugins/uptime/server/lib/saved_objects'; -const ARCHIVE = 'uptime/full_heartbeat'; +const ARCHIVE = 'x-pack/test/functional/es_archives/uptime/full_heartbeat'; export const deleteUptimeSettingsObject = async (server: any) => { // delete the saved object @@ -50,10 +50,10 @@ export default ({ loadTestFile, getService }: FtrProviderContext) => { describe('with generated data', () => { beforeEach('load heartbeat data', async () => { - await esArchiver.load('uptime/blank'); + await esArchiver.load('x-pack/test/functional/es_archives/uptime/blank'); }); afterEach('unload', async () => { - await esArchiver.unload('uptime/blank'); + await esArchiver.unload('x-pack/test/functional/es_archives/uptime/blank'); }); loadTestFile(require.resolve('./locations')); diff --git a/x-pack/test/functional/apps/uptime/ml_anomaly.ts b/x-pack/test/functional/apps/uptime/ml_anomaly.ts index 83f4c8081a06c..38b5f47011409 100644 --- a/x-pack/test/functional/apps/uptime/ml_anomaly.ts +++ b/x-pack/test/functional/apps/uptime/ml_anomaly.ts @@ -12,7 +12,7 @@ export default ({ getService }: FtrProviderContext) => { const uptime = getService('uptime'); const log = getService('log'); const esArchiver = getService('esArchiver'); - const archive = 'uptime/full_heartbeat'; + const archive = 'x-pack/test/functional/es_archives/uptime/full_heartbeat'; describe('uptime ml anomaly', function () { this.tags(['skipFirefox']); diff --git a/x-pack/test/functional/apps/uptime/monitor.ts b/x-pack/test/functional/apps/uptime/monitor.ts index 918fa45b603f1..0ddff37eb14fc 100644 --- a/x-pack/test/functional/apps/uptime/monitor.ts +++ b/x-pack/test/functional/apps/uptime/monitor.ts @@ -11,7 +11,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { const esArchiver = getService('esArchiver'); const uptimeService = getService('uptime'); const { uptime } = getPageObjects(['uptime']); - const archive = 'uptime/full_heartbeat'; + const archive = 'x-pack/test/functional/es_archives/uptime/full_heartbeat'; describe('monitor page', function () { this.tags(['skipFirefox']); diff --git a/x-pack/test/functional/apps/uptime/overview.ts b/x-pack/test/functional/apps/uptime/overview.ts index 1e52accfde1a3..2d2c3a8d5faa7 100644 --- a/x-pack/test/functional/apps/uptime/overview.ts +++ b/x-pack/test/functional/apps/uptime/overview.ts @@ -20,7 +20,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { const DEFAULT_DATE_END = 'Sep 11, 2019 @ 19:40:08.078'; before(async () => { - await esArchiver.loadIfNeeded('uptime/full_heartbeat'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/uptime/full_heartbeat'); }); beforeEach(async () => { diff --git a/x-pack/test/functional/apps/uptime/ping_redirects.ts b/x-pack/test/functional/apps/uptime/ping_redirects.ts index 39d9292dbbbb8..03185ac9f1466 100644 --- a/x-pack/test/functional/apps/uptime/ping_redirects.ts +++ b/x-pack/test/functional/apps/uptime/ping_redirects.ts @@ -15,7 +15,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { const uptime = getService('uptime'); const esArchiver = getService('esArchiver'); - const archive = 'uptime/blank'; + const archive = 'x-pack/test/functional/es_archives/uptime/blank'; const monitor = () => uptime.monitor; diff --git a/x-pack/test/functional/apps/visualize/feature_controls/visualize_security.ts b/x-pack/test/functional/apps/visualize/feature_controls/visualize_security.ts index f650ac08de166..2994e18fa9ab7 100644 --- a/x-pack/test/functional/apps/visualize/feature_controls/visualize_security.ts +++ b/x-pack/test/functional/apps/visualize/feature_controls/visualize_security.ts @@ -30,12 +30,12 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { describe('visualize feature controls security', () => { before(async () => { - await esArchiver.load('visualize/default'); - await esArchiver.loadIfNeeded('logstash_functional'); + await esArchiver.load('x-pack/test/functional/es_archives/visualize/default'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/logstash_functional'); }); after(async () => { - await esArchiver.unload('visualize/default'); + await esArchiver.unload('x-pack/test/functional/es_archives/visualize/default'); // logout, so the other tests don't accidentally run as the custom users we're testing below await PageObjects.security.forceLogout(); }); diff --git a/x-pack/test/functional/apps/visualize/feature_controls/visualize_spaces.ts b/x-pack/test/functional/apps/visualize/feature_controls/visualize_spaces.ts index 469a337177065..cad437bbadc3e 100644 --- a/x-pack/test/functional/apps/visualize/feature_controls/visualize_spaces.ts +++ b/x-pack/test/functional/apps/visualize/feature_controls/visualize_spaces.ts @@ -19,14 +19,14 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { describe('visualize', () => { before(async () => { - await esArchiver.loadIfNeeded('logstash_functional'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/logstash_functional'); }); describe('space with no features disabled', () => { before(async () => { // we need to load the following in every situation as deleting // a space deletes all of the associated saved objects - await esArchiver.load('visualize/default'); + await esArchiver.load('x-pack/test/functional/es_archives/visualize/default'); await spacesService.create({ id: 'custom_space', name: 'custom_space', @@ -36,7 +36,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { after(async () => { await spacesService.delete('custom_space'); - await esArchiver.unload('visualize/default'); + await esArchiver.unload('x-pack/test/functional/es_archives/visualize/default'); }); it('shows visualize navlink', async () => { @@ -67,7 +67,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { before(async () => { // we need to load the following in every situation as deleting // a space deletes all of the associated saved objects - await esArchiver.load('visualize/default'); + await esArchiver.load('x-pack/test/functional/es_archives/visualize/default'); await spacesService.create({ id: 'custom_space', name: 'custom_space', @@ -77,7 +77,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { after(async () => { await spacesService.delete('custom_space'); - await esArchiver.unload('visualize/default'); + await esArchiver.unload('x-pack/test/functional/es_archives/visualize/default'); }); it(`doesn't show visualize navlink`, async () => { diff --git a/x-pack/test/functional/apps/visualize/hybrid_visualization.ts b/x-pack/test/functional/apps/visualize/hybrid_visualization.ts index 0bde8e2816c84..41c393398b256 100644 --- a/x-pack/test/functional/apps/visualize/hybrid_visualization.ts +++ b/x-pack/test/functional/apps/visualize/hybrid_visualization.ts @@ -14,15 +14,15 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { describe('hybrid index pattern', () => { before(async () => { - await esArchiver.load('hybrid/kibana'); - await esArchiver.load('hybrid/logstash'); - await esArchiver.load('hybrid/rollup'); + await esArchiver.load('x-pack/test/functional/es_archives/hybrid/kibana'); + await esArchiver.load('x-pack/test/functional/es_archives/hybrid/logstash'); + await esArchiver.load('x-pack/test/functional/es_archives/hybrid/rollup'); }); after(async () => { - await esArchiver.unload('hybrid/kibana'); - await esArchiver.unload('hybrid/logstash'); - await esArchiver.unload('hybrid/rollup'); + await esArchiver.unload('x-pack/test/functional/es_archives/hybrid/kibana'); + await esArchiver.unload('x-pack/test/functional/es_archives/hybrid/logstash'); + await esArchiver.unload('x-pack/test/functional/es_archives/hybrid/rollup'); }); it('should render histogram line chart', async () => { diff --git a/x-pack/test/functional/apps/visualize/precalculated_histogram.ts b/x-pack/test/functional/apps/visualize/precalculated_histogram.ts index 20111b8f4f1e0..bee6b3e8ddd20 100644 --- a/x-pack/test/functional/apps/visualize/precalculated_histogram.ts +++ b/x-pack/test/functional/apps/visualize/precalculated_histogram.ts @@ -17,12 +17,12 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('pre_calculated_histogram', function () { before(async function () { log.debug('Starting pre_calculated_histogram before method'); - await esArchiver.load('pre_calculated_histogram'); + await esArchiver.load('x-pack/test/functional/es_archives/pre_calculated_histogram'); await kibanaServer.uiSettings.replace({ defaultIndex: 'test-histogram' }); }); after(function () { - return esArchiver.unload('pre_calculated_histogram'); + return esArchiver.unload('x-pack/test/functional/es_archives/pre_calculated_histogram'); }); it('appears correctly in discover', async function () { diff --git a/x-pack/test/functional/apps/visualize/preserve_url.ts b/x-pack/test/functional/apps/visualize/preserve_url.ts index 16267a544275c..58e4d2ffcd4b2 100644 --- a/x-pack/test/functional/apps/visualize/preserve_url.ts +++ b/x-pack/test/functional/apps/visualize/preserve_url.ts @@ -16,11 +16,11 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('preserve url', function () { before(async function () { - await esArchiver.load('spaces/multi_space'); + await esArchiver.load('x-pack/test/functional/es_archives/spaces/multi_space'); }); after(function () { - return esArchiver.unload('spaces/multi_space'); + return esArchiver.unload('x-pack/test/functional/es_archives/spaces/multi_space'); }); it('goes back to last opened url', async function () { diff --git a/x-pack/test/functional/apps/visualize/reporting.ts b/x-pack/test/functional/apps/visualize/reporting.ts index 8add80996e270..799006337300f 100644 --- a/x-pack/test/functional/apps/visualize/reporting.ts +++ b/x-pack/test/functional/apps/visualize/reporting.ts @@ -24,13 +24,15 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('Visualize Reporting Screenshots', () => { before('initialize tests', async () => { log.debug('ReportingPage:initTests'); - await esArchiver.loadIfNeeded('reporting/ecommerce'); - await esArchiver.loadIfNeeded('reporting/ecommerce_kibana'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/reporting/ecommerce'); + await esArchiver.loadIfNeeded( + 'x-pack/test/functional/es_archives/reporting/ecommerce_kibana' + ); await browser.setWindowSize(1600, 850); }); after('clean up archives', async () => { - await esArchiver.unload('reporting/ecommerce'); - await esArchiver.unload('reporting/ecommerce_kibana'); + await esArchiver.unload('x-pack/test/functional/es_archives/reporting/ecommerce'); + await esArchiver.unload('x-pack/test/functional/es_archives/reporting/ecommerce_kibana'); await es.deleteByQuery({ index: '.reporting-*', refresh: true, diff --git a/x-pack/test/functional/config.js b/x-pack/test/functional/config.js index ee5be48a07663..20487047a3a56 100644 --- a/x-pack/test/functional/config.js +++ b/x-pack/test/functional/config.js @@ -208,11 +208,6 @@ export default async function ({ readConfigFile }) { }, }, - // choose where esArchiver should load archives from - esArchiver: { - directory: resolve(__dirname, 'es_archives'), - }, - // choose where screenshots should be saved screenshots: { directory: resolve(__dirname, 'screenshots'), diff --git a/x-pack/test/functional/config_security_basic.ts b/x-pack/test/functional/config_security_basic.ts index 4deb598fe8769..dc4bfc437347e 100644 --- a/x-pack/test/functional/config_security_basic.ts +++ b/x-pack/test/functional/config_security_basic.ts @@ -60,11 +60,6 @@ export default async function ({ readConfigFile }: FtrConfigProviderContext) { ...kibanaFunctionalConfig.get('apps'), }, - // choose where esArchiver should load archives from - esArchiver: { - directory: resolve(__dirname, 'es_archives'), - }, - // choose where screenshots should be saved screenshots: { directory: resolve(__dirname, 'screenshots'), diff --git a/x-pack/test/functional/page_objects/security_page.ts b/x-pack/test/functional/page_objects/security_page.ts index f9128ce21b565..437749d31c15e 100644 --- a/x-pack/test/functional/page_objects/security_page.ts +++ b/x-pack/test/functional/page_objects/security_page.ts @@ -217,8 +217,8 @@ export class SecurityPageObject extends FtrService { async initTests() { this.log.debug('SecurityPage:initTests'); - await this.esArchiver.load('empty_kibana'); - await this.esArchiver.loadIfNeeded('logstash_functional'); + await this.esArchiver.load('x-pack/test/functional/es_archives/empty_kibana'); + await this.esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/logstash_functional'); await this.browser.setWindowSize(1600, 1000); } diff --git a/x-pack/test/functional/services/dashboard/drilldowns_manage.ts b/x-pack/test/functional/services/dashboard/drilldowns_manage.ts index 34212262aedba..10634ab371345 100644 --- a/x-pack/test/functional/services/dashboard/drilldowns_manage.ts +++ b/x-pack/test/functional/services/dashboard/drilldowns_manage.ts @@ -27,12 +27,12 @@ export function DashboardDrilldownsManageProvider({ getService }: FtrProviderCon async loadData() { log.debug('loadData'); - await esArchiver.load('dashboard/drilldowns'); + await esArchiver.load('x-pack/test/functional/es_archives/dashboard/drilldowns'); } async unloadData() { log.debug('unloadData'); - await esArchiver.unload('dashboard/drilldowns'); + await esArchiver.unload('x-pack/test/functional/es_archives/dashboard/drilldowns'); } async expectsCreateDrilldownFlyoutOpen() { diff --git a/x-pack/test/functional_basic/apps/ml/data_visualizer/index_data_visualizer_actions_panel.ts b/x-pack/test/functional_basic/apps/ml/data_visualizer/index_data_visualizer_actions_panel.ts index 642cc60e90441..a2a135b8cef0c 100644 --- a/x-pack/test/functional_basic/apps/ml/data_visualizer/index_data_visualizer_actions_panel.ts +++ b/x-pack/test/functional_basic/apps/ml/data_visualizer/index_data_visualizer_actions_panel.ts @@ -19,7 +19,7 @@ export default function ({ getService }: FtrProviderContext) { const expectedQuery = 'airline: A* and responsetime > 5'; before(async () => { - await esArchiver.loadIfNeeded('ml/farequote'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/ml/farequote'); await ml.testResources.createIndexPatternIfNeeded(indexPatternName, '@timestamp'); await ml.testResources.createSavedSearchFarequoteKueryIfNeeded(); await ml.testResources.setKibanaTimeZoneToUTC(); diff --git a/x-pack/test/functional_basic/apps/ml/index.ts b/x-pack/test/functional_basic/apps/ml/index.ts index 4d426967158ec..ed1ab4f417584 100644 --- a/x-pack/test/functional_basic/apps/ml/index.ts +++ b/x-pack/test/functional_basic/apps/ml/index.ts @@ -28,8 +28,8 @@ export default function ({ getService, loadTestFile }: FtrProviderContext) { await ml.testResources.deleteIndexPatternByTitle('ft_farequote'); await ml.testResources.deleteIndexPatternByTitle('ft_module_sample_ecommerce'); - await esArchiver.unload('ml/farequote'); - await esArchiver.unload('ml/module_sample_ecommerce'); + await esArchiver.unload('x-pack/test/functional/es_archives/ml/farequote'); + await esArchiver.unload('x-pack/test/functional/es_archives/ml/module_sample_ecommerce'); await ml.testResources.resetKibanaTimeZone(); }); diff --git a/x-pack/test/functional_basic/apps/ml/permissions/full_ml_access.ts b/x-pack/test/functional_basic/apps/ml/permissions/full_ml_access.ts index abd494df7a853..7fdfbb45269c3 100644 --- a/x-pack/test/functional_basic/apps/ml/permissions/full_ml_access.ts +++ b/x-pack/test/functional_basic/apps/ml/permissions/full_ml_access.ts @@ -45,7 +45,9 @@ export default function ({ getService }: FtrProviderContext) { before(async () => { await ml.api.cleanMlIndices(); - await esArchiver.loadIfNeeded('ml/module_sample_ecommerce'); + await esArchiver.loadIfNeeded( + 'x-pack/test/functional/es_archives/ml/module_sample_ecommerce' + ); await ml.testResources.createIndexPatternIfNeeded(ecIndexPattern, 'order_date'); await ml.securityUI.loginAs(testUser.user); diff --git a/x-pack/test/functional_basic/apps/ml/permissions/read_ml_access.ts b/x-pack/test/functional_basic/apps/ml/permissions/read_ml_access.ts index ce72a25a2ee37..e58e46e985fd9 100644 --- a/x-pack/test/functional_basic/apps/ml/permissions/read_ml_access.ts +++ b/x-pack/test/functional_basic/apps/ml/permissions/read_ml_access.ts @@ -46,7 +46,9 @@ export default function ({ getService }: FtrProviderContext) { before(async () => { await ml.api.cleanMlIndices(); - await esArchiver.loadIfNeeded('ml/module_sample_ecommerce'); + await esArchiver.loadIfNeeded( + 'x-pack/test/functional/es_archives/ml/module_sample_ecommerce' + ); await ml.testResources.createIndexPatternIfNeeded(ecIndexPattern, 'order_date'); await ml.securityUI.loginAs(testUser.user); diff --git a/x-pack/test/functional_enterprise_search/apps/enterprise_search/with_host_configured/app_search/engines.ts b/x-pack/test/functional_enterprise_search/apps/enterprise_search/with_host_configured/app_search/engines.ts index 68787859127af..142f6af984994 100644 --- a/x-pack/test/functional_enterprise_search/apps/enterprise_search/with_host_configured/app_search/engines.ts +++ b/x-pack/test/functional_enterprise_search/apps/enterprise_search/with_host_configured/app_search/engines.ts @@ -28,14 +28,14 @@ export default function enterpriseSearchSetupEnginesTests({ let metaEngine: IEngine; before(async () => { - await esArchiver.load('empty_kibana'); + await esArchiver.load('x-pack/test/functional/es_archives/empty_kibana'); engine1 = await appSearch.createEngine(); engine2 = await appSearch.createEngine(); metaEngine = await appSearch.createMetaEngine([engine1.name, engine2.name]); }); after(async () => { - await esArchiver.unload('empty_kibana'); + await esArchiver.unload('x-pack/test/functional/es_archives/empty_kibana'); appSearch.destroyEngine(engine1.name); appSearch.destroyEngine(engine2.name); appSearch.destroyEngine(metaEngine.name); diff --git a/x-pack/test/functional_enterprise_search/apps/enterprise_search/without_host_configured/app_search/setup_guide.ts b/x-pack/test/functional_enterprise_search/apps/enterprise_search/without_host_configured/app_search/setup_guide.ts index c0fa72680d861..e7bec22936d12 100644 --- a/x-pack/test/functional_enterprise_search/apps/enterprise_search/without_host_configured/app_search/setup_guide.ts +++ b/x-pack/test/functional_enterprise_search/apps/enterprise_search/without_host_configured/app_search/setup_guide.ts @@ -19,9 +19,9 @@ export default function enterpriseSearchSetupGuideTests({ const PageObjects = getPageObjects(['appSearch']); describe('Setup Guide', function () { - before(async () => await esArchiver.load('empty_kibana')); + before(async () => await esArchiver.load('x-pack/test/functional/es_archives/empty_kibana')); after(async () => { - await esArchiver.unload('empty_kibana'); + await esArchiver.unload('x-pack/test/functional/es_archives/empty_kibana'); }); describe('when no enterpriseSearch.host is configured', () => { diff --git a/x-pack/test/functional_enterprise_search/apps/enterprise_search/without_host_configured/workplace_search/setup_guide.ts b/x-pack/test/functional_enterprise_search/apps/enterprise_search/without_host_configured/workplace_search/setup_guide.ts index ad1d207c4acc5..e1e78885e6401 100644 --- a/x-pack/test/functional_enterprise_search/apps/enterprise_search/without_host_configured/workplace_search/setup_guide.ts +++ b/x-pack/test/functional_enterprise_search/apps/enterprise_search/without_host_configured/workplace_search/setup_guide.ts @@ -19,9 +19,9 @@ export default function enterpriseSearchSetupGuideTests({ const PageObjects = getPageObjects(['workplaceSearch']); describe('Setup Guide', function () { - before(async () => await esArchiver.load('empty_kibana')); + before(async () => await esArchiver.load('x-pack/test/functional/es_archives/empty_kibana')); after(async () => { - await esArchiver.unload('empty_kibana'); + await esArchiver.unload('x-pack/test/functional/es_archives/empty_kibana'); }); describe('when no enterpriseSearch.host is configured', () => { diff --git a/x-pack/test/functional_vis_wizard/apps/visualization_wizard.ts b/x-pack/test/functional_vis_wizard/apps/visualization_wizard.ts index 7e113528de691..2dc7533468db4 100644 --- a/x-pack/test/functional_vis_wizard/apps/visualization_wizard.ts +++ b/x-pack/test/functional_vis_wizard/apps/visualization_wizard.ts @@ -14,13 +14,13 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('lens and maps disabled', function () { before(async function () { - await esArchiver.loadIfNeeded('logstash_functional'); - await esArchiver.loadIfNeeded('visualize/default'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/logstash_functional'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/visualize/default'); }); after(async function () { - await esArchiver.unload('logstash_functional'); - await esArchiver.unload('visualize/default'); + await esArchiver.unload('x-pack/test/functional/es_archives/logstash_functional'); + await esArchiver.unload('x-pack/test/functional/es_archives/visualize/default'); }); it('should not display lens and maps cards', async function () { diff --git a/x-pack/test/functional_with_es_ssl/apps/ml/alert_flyout.ts b/x-pack/test/functional_with_es_ssl/apps/ml/alert_flyout.ts index 2c80f4b2ebd91..0f5e12f226c0e 100644 --- a/x-pack/test/functional_with_es_ssl/apps/ml/alert_flyout.ts +++ b/x-pack/test/functional_with_es_ssl/apps/ml/alert_flyout.ts @@ -71,7 +71,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { this.tags('ciGroup13'); before(async () => { - await esArchiver.loadIfNeeded('ml/ecommerce'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/ml/ecommerce'); await ml.testResources.createIndexPatternIfNeeded('ft_ecommerce', 'order_date'); await ml.testResources.setKibanaTimeZoneToUTC(); diff --git a/x-pack/test/functional_with_es_ssl/apps/ml/index.ts b/x-pack/test/functional_with_es_ssl/apps/ml/index.ts index 3d0a1c0e4cc75..e3a390a5c5486 100644 --- a/x-pack/test/functional_with_es_ssl/apps/ml/index.ts +++ b/x-pack/test/functional_with_es_ssl/apps/ml/index.ts @@ -21,7 +21,7 @@ export default ({ loadTestFile, getService }: FtrProviderContext) => { after(async () => { await ml.testResources.deleteIndexPatternByTitle('ft_ecommerce'); - await esArchiver.unload('ml/ecommerce'); + await esArchiver.unload('x-pack/test/functional/es_archives/ml/ecommerce'); await ml.securityCommon.cleanMlUsers(); await ml.securityCommon.cleanMlRoles(); await ml.testResources.resetKibanaTimeZone(); diff --git a/x-pack/test/functional_with_es_ssl/apps/uptime/index.ts b/x-pack/test/functional_with_es_ssl/apps/uptime/index.ts index be22a53b141b4..222dcd22d6f86 100644 --- a/x-pack/test/functional_with_es_ssl/apps/uptime/index.ts +++ b/x-pack/test/functional_with_es_ssl/apps/uptime/index.ts @@ -7,7 +7,7 @@ import { FtrProviderContext } from '../../ftr_provider_context'; -const ARCHIVE = 'uptime/full_heartbeat'; +const ARCHIVE = 'x-pack/test/functional/es_archives/uptime/full_heartbeat'; export default ({ getService, loadTestFile }: FtrProviderContext) => { const esArchiver = getService('esArchiver'); diff --git a/x-pack/test/lists_api_integration/common/config.ts b/x-pack/test/lists_api_integration/common/config.ts index 24b47472d7945..4983f00cce044 100644 --- a/x-pack/test/lists_api_integration/common/config.ts +++ b/x-pack/test/lists_api_integration/common/config.ts @@ -38,7 +38,6 @@ export function createTestConfig(name: string, options: CreateTestConfigOptions) junit: { reportName: 'X-Pack Lists Integration Tests', }, - esArchiver: xPackApiIntegrationTestsConfig.get('esArchiver'), esTestCluster: { ...xPackApiIntegrationTestsConfig.get('esTestCluster'), license, diff --git a/x-pack/test/load/config.ts b/x-pack/test/load/config.ts index 54789b56d9912..514440fd73f46 100644 --- a/x-pack/test/load/config.ts +++ b/x-pack/test/load/config.ts @@ -23,10 +23,6 @@ export default async function ({ readConfigFile }: FtrConfigProviderContext) { testRunner: GatlingTestRunner, - esArchiver: { - directory: resolve(__dirname, 'es_archives'), - }, - screenshots: { directory: resolve(__dirname, 'screenshots'), }, diff --git a/x-pack/test/plugin_api_integration/config.ts b/x-pack/test/plugin_api_integration/config.ts index 09bec3330c390..0b4369d199c33 100644 --- a/x-pack/test/plugin_api_integration/config.ts +++ b/x-pack/test/plugin_api_integration/config.ts @@ -30,9 +30,6 @@ export default async function ({ readConfigFile }: FtrConfigProviderContext) { servers: integrationConfig.get('servers'), esTestCluster: integrationConfig.get('esTestCluster'), apps: integrationConfig.get('apps'), - esArchiver: { - directory: path.resolve(__dirname, '../functional/es_archives'), - }, screenshots: integrationConfig.get('screenshots'), junit: { reportName: 'Plugin Functional Tests', diff --git a/x-pack/test/plugin_api_integration/test_suites/event_log/public_api_integration.ts b/x-pack/test/plugin_api_integration/test_suites/event_log/public_api_integration.ts index d41dab2741cd5..184b418f5cc63 100644 --- a/x-pack/test/plugin_api_integration/test_suites/event_log/public_api_integration.ts +++ b/x-pack/test/plugin_api_integration/test_suites/event_log/public_api_integration.ts @@ -32,7 +32,7 @@ export default function ({ getService }: FtrProviderContext) { }); after(async () => { - await esArchiver.unload('empty_kibana'); + await esArchiver.unload('x-pack/test/functional/es_archives/empty_kibana'); }); for (const namespace of [undefined, 'namespace-a']) { @@ -161,7 +161,7 @@ export default function ({ getService }: FtrProviderContext) { describe(`Index Lifecycle`, () => { it('should query across indicies matching the Event Log index pattern', async () => { - await esArchiver.load('event_log_multiple_indicies'); + await esArchiver.load('x-pack/test/functional/es_archives/event_log_multiple_indicies'); const id = `421f2511-5cd1-44fd-95df-e0df83e354d5`; @@ -181,7 +181,7 @@ export default function ({ getService }: FtrProviderContext) { 'test 2020-10-28T15:19:55.962Z', ]); - await esArchiver.unload('event_log_multiple_indicies'); + await esArchiver.unload('x-pack/test/functional/es_archives/event_log_multiple_indicies'); }); }); }); diff --git a/x-pack/test/plugin_api_integration/test_suites/task_manager/task_management_removed_types.ts b/x-pack/test/plugin_api_integration/test_suites/task_manager/task_management_removed_types.ts index 7e73bd3b560d1..4941bddbda53c 100644 --- a/x-pack/test/plugin_api_integration/test_suites/task_manager/task_management_removed_types.ts +++ b/x-pack/test/plugin_api_integration/test_suites/task_manager/task_management_removed_types.ts @@ -49,11 +49,11 @@ export default function ({ getService }: FtrProviderContext) { describe('removed task types', () => { before(async () => { - await esArchiver.load('task_manager_removed_types'); + await esArchiver.load('x-pack/test/functional/es_archives/task_manager_removed_types'); }); after(async () => { - await esArchiver.unload('task_manager_removed_types'); + await esArchiver.unload('x-pack/test/functional/es_archives/task_manager_removed_types'); }); function scheduleTask( diff --git a/x-pack/test/plugin_api_perf/config.js b/x-pack/test/plugin_api_perf/config.js index 04f1c26b52125..272af91dcf865 100644 --- a/x-pack/test/plugin_api_perf/config.js +++ b/x-pack/test/plugin_api_perf/config.js @@ -24,9 +24,6 @@ export default async function ({ readConfigFile }) { servers: integrationConfig.get('servers'), esTestCluster: integrationConfig.get('esTestCluster'), apps: integrationConfig.get('apps'), - esArchiver: { - directory: path.resolve(__dirname, '../functional/es_archives'), - }, screenshots: integrationConfig.get('screenshots'), junit: { reportName: 'Plugin Functional Tests', diff --git a/x-pack/test/plugin_functional/config.ts b/x-pack/test/plugin_functional/config.ts index 8b0ad12891dc3..7033836285e3c 100644 --- a/x-pack/test/plugin_functional/config.ts +++ b/x-pack/test/plugin_functional/config.ts @@ -67,11 +67,6 @@ export default async function ({ readConfigFile }: FtrConfigProviderContext) { }, }, - // choose where esArchiver should load archives from - esArchiver: { - directory: resolve(__dirname, 'es_archives'), - }, - // choose where screenshots should be saved screenshots: { directory: resolve(__dirname, 'screenshots'), diff --git a/x-pack/test/plugin_functional/test_suites/global_search/global_search_bar.ts b/x-pack/test/plugin_functional/test_suites/global_search/global_search_bar.ts index a44ded43a0bfe..f22a20dcdee9f 100644 --- a/x-pack/test/plugin_functional/test_suites/global_search/global_search_bar.ts +++ b/x-pack/test/plugin_functional/test_suites/global_search/global_search_bar.ts @@ -15,12 +15,16 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { const browser = getService('browser'); before(async () => { - await esArchiver.load('global_search/search_syntax'); + await esArchiver.load( + 'x-pack/test/plugin_functional/es_archives/global_search/search_syntax' + ); await common.navigateToApp('home'); }); after(async () => { - await esArchiver.unload('global_search/search_syntax'); + await esArchiver.unload( + 'x-pack/test/plugin_functional/es_archives/global_search/search_syntax' + ); }); afterEach(async () => { diff --git a/x-pack/test/plugin_functional/test_suites/global_search/global_search_providers.ts b/x-pack/test/plugin_functional/test_suites/global_search/global_search_providers.ts index 74d1ae48fc86f..24bd4e09a4ea3 100644 --- a/x-pack/test/plugin_functional/test_suites/global_search/global_search_providers.ts +++ b/x-pack/test/plugin_functional/test_suites/global_search/global_search_providers.ts @@ -30,11 +30,11 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { describe('SavedObject provider', function () { before(async () => { - await esArchiver.load('global_search/basic'); + await esArchiver.load('x-pack/test/plugin_functional/es_archives/global_search/basic'); }); after(async () => { - await esArchiver.unload('global_search/basic'); + await esArchiver.unload('x-pack/test/plugin_functional/es_archives/global_search/basic'); }); it('can search for index patterns', async () => { diff --git a/x-pack/test/reporting_api_integration/reporting_and_security/download_csv_dashboard.ts b/x-pack/test/reporting_api_integration/reporting_and_security/download_csv_dashboard.ts index 626cd217bde5f..2a29d6c45dbe1 100644 --- a/x-pack/test/reporting_api_integration/reporting_and_security/download_csv_dashboard.ts +++ b/x-pack/test/reporting_api_integration/reporting_and_security/download_csv_dashboard.ts @@ -227,12 +227,12 @@ export default function ({ getService }: FtrProviderContext) { describe('date formatting', () => { before(async () => { // load test data that contains a saved search and documents - await esArchiver.load('reporting/logs'); - await esArchiver.load('logstash_functional'); + await esArchiver.load('x-pack/test/functional/es_archives/reporting/logs'); + await esArchiver.load('x-pack/test/functional/es_archives/logstash_functional'); }); after(async () => { - await esArchiver.unload('reporting/logs'); - await esArchiver.unload('logstash_functional'); + await esArchiver.unload('x-pack/test/functional/es_archives/reporting/logs'); + await esArchiver.unload('x-pack/test/functional/es_archives/logstash_functional'); }); it('With filters and timebased data, default to UTC', async () => { @@ -311,7 +311,7 @@ export default function ({ getService }: FtrProviderContext) { }); it('Formatted date_nanos data, UTC timezone', async () => { - await esArchiver.load('reporting/nanos'); + await esArchiver.load('x-pack/test/functional/es_archives/reporting/nanos'); const res = await generateAPI.getCSVFromSearchSource( getMockJobParams({ @@ -331,11 +331,11 @@ export default function ({ getService }: FtrProviderContext) { expect(resType).to.eql('text/csv'); expectSnapshot(resText).toMatch(); - await esArchiver.unload('reporting/nanos'); + await esArchiver.unload('x-pack/test/functional/es_archives/reporting/nanos'); }); it('Formatted date_nanos data, custom timezone (New York)', async () => { - await esArchiver.load('reporting/nanos'); + await esArchiver.load('x-pack/test/functional/es_archives/reporting/nanos'); const res = await generateAPI.getCSVFromSearchSource( getMockJobParams({ @@ -356,13 +356,13 @@ export default function ({ getService }: FtrProviderContext) { expect(resType).to.eql('text/csv'); expectSnapshot(resText).toMatch(); - await esArchiver.unload('reporting/nanos'); + await esArchiver.unload('x-pack/test/functional/es_archives/reporting/nanos'); }); }); describe('non-timebased', () => { it('Handle _id and _index columns', async () => { - await esArchiver.load('reporting/nanos'); + await esArchiver.load('x-pack/test/functional/es_archives/reporting/nanos'); const res = await generateAPI.getCSVFromSearchSource( getMockJobParams({ @@ -382,12 +382,12 @@ export default function ({ getService }: FtrProviderContext) { expect(resType).to.eql('text/csv'); expectSnapshot(resText).toMatch(); - await esArchiver.unload('reporting/nanos'); + await esArchiver.unload('x-pack/test/functional/es_archives/reporting/nanos'); }); it('With filters and non-timebased data', async () => { // load test data that contains a saved search and documents - await esArchiver.load('reporting/sales'); + await esArchiver.load('x-pack/test/functional/es_archives/reporting/sales'); const { status: resStatus, @@ -414,7 +414,7 @@ export default function ({ getService }: FtrProviderContext) { expect(resType).to.eql('text/csv'); expectSnapshot(resText).toMatch(); - await esArchiver.unload('reporting/sales'); + await esArchiver.unload('x-pack/test/functional/es_archives/reporting/sales'); }); }); diff --git a/x-pack/test/reporting_api_integration/reporting_and_security/generate_csv_discover.ts b/x-pack/test/reporting_api_integration/reporting_and_security/generate_csv_discover.ts index 3370eb0bb398b..75226901afd64 100644 --- a/x-pack/test/reporting_api_integration/reporting_and_security/generate_csv_discover.ts +++ b/x-pack/test/reporting_api_integration/reporting_and_security/generate_csv_discover.ts @@ -32,13 +32,13 @@ export default function ({ getService }: FtrProviderContext) { describe('Generation from Job Params', () => { before(async () => { - await esArchiver.load('reporting/logs'); - await esArchiver.load('logstash_functional'); + await esArchiver.load('x-pack/test/functional/es_archives/reporting/logs'); + await esArchiver.load('x-pack/test/functional/es_archives/logstash_functional'); }); after(async () => { - await esArchiver.unload('reporting/logs'); - await esArchiver.unload('logstash_functional'); + await esArchiver.unload('x-pack/test/functional/es_archives/reporting/logs'); + await esArchiver.unload('x-pack/test/functional/es_archives/logstash_functional'); await reportingAPI.deleteAllReports(); }); diff --git a/x-pack/test/reporting_api_integration/reporting_and_security/network_policy.ts b/x-pack/test/reporting_api_integration/reporting_and_security/network_policy.ts index e6ac75be9d48a..f097208658467 100644 --- a/x-pack/test/reporting_api_integration/reporting_and_security/network_policy.ts +++ b/x-pack/test/reporting_api_integration/reporting_and_security/network_policy.ts @@ -14,7 +14,7 @@ export default function ({ getService }: FtrProviderContext) { const reportingAPI = getService('reportingAPI'); const retry = getService('retry'); const supertest = getService('supertest'); - const archive = 'reporting/canvas_disallowed_url'; + const archive = 'x-pack/test/functional/es_archives/reporting/canvas_disallowed_url'; /* * The Reporting API Functional Test config implements a network policy that diff --git a/x-pack/test/reporting_api_integration/reporting_and_security/spaces.ts b/x-pack/test/reporting_api_integration/reporting_and_security/spaces.ts index 4fdcc2692387a..e61195e2f95c8 100644 --- a/x-pack/test/reporting_api_integration/reporting_and_security/spaces.ts +++ b/x-pack/test/reporting_api_integration/reporting_and_security/spaces.ts @@ -40,13 +40,15 @@ export default function ({ getService }: FtrProviderContext) { describe('Exports and Spaces', () => { before(async () => { - await esArchiver.load('reporting/ecommerce'); - await esArchiver.load('reporting/ecommerce_kibana_spaces'); // multiple spaces with different config settings + await esArchiver.load('x-pack/test/functional/es_archives/reporting/ecommerce'); + await esArchiver.load('x-pack/test/functional/es_archives/reporting/ecommerce_kibana_spaces'); // multiple spaces with different config settings }); after(async () => { - await esArchiver.unload('reporting/ecommerce'); - await esArchiver.unload('reporting/ecommerce_kibana_spaces'); + await esArchiver.unload('x-pack/test/functional/es_archives/reporting/ecommerce'); + await esArchiver.unload( + 'x-pack/test/functional/es_archives/reporting/ecommerce_kibana_spaces' + ); await reportingAPI.deleteAllReports(); }); diff --git a/x-pack/test/reporting_api_integration/reporting_and_security/usage.ts b/x-pack/test/reporting_api_integration/reporting_and_security/usage.ts index a69534cfc4df7..221d345ac2d5b 100644 --- a/x-pack/test/reporting_api_integration/reporting_and_security/usage.ts +++ b/x-pack/test/reporting_api_integration/reporting_and_security/usage.ts @@ -6,20 +6,12 @@ */ import expect from '@kbn/expect'; -import { REPO_ROOT } from '@kbn/utils'; -import path from 'path'; import { FtrProviderContext } from '../ftr_provider_context'; import * as GenerationUrls from '../services/generation_urls'; import { ReportingUsageStats } from '../services/usage'; -const OSS_KIBANA_ARCHIVE_PATH = path.resolve( - REPO_ROOT, - 'test/functional/fixtures/es_archiver/dashboard/current/kibana' -); -const OSS_DATA_ARCHIVE_PATH = path.resolve( - REPO_ROOT, - 'test/functional/fixtures/es_archiver/dashboard/current/data' -); +const OSS_KIBANA_ARCHIVE_PATH = 'test/functional/fixtures/es_archiver/dashboard/current/kibana'; +const OSS_DATA_ARCHIVE_PATH = 'test/functional/fixtures/es_archiver/dashboard/current/data'; interface UsageStats { reporting: ReportingUsageStats; @@ -86,7 +78,7 @@ export default function ({ getService }: FtrProviderContext) { describe('from archive data', () => { it('generated from 6.2', async () => { - await esArchiver.load('reporting/bwc/6_2'); + await esArchiver.load('x-pack/test/functional/es_archives/reporting/bwc/6_2'); const usage = await usageAPI.getUsageStats(); reportingAPI.expectRecentJobTypeTotalStats(usage, 'csv', 0); @@ -105,11 +97,11 @@ export default function ({ getService }: FtrProviderContext) { reportingAPI.expectAllTimePdfLayoutStats(usage, 'preserve_layout', 0); reportingAPI.expectAllTimePdfLayoutStats(usage, 'print', 0); - await esArchiver.unload('reporting/bwc/6_2'); + await esArchiver.unload('x-pack/test/functional/es_archives/reporting/bwc/6_2'); }); it('generated from 6.3', async () => { - await esArchiver.load('reporting/bwc/6_3'); + await esArchiver.load('x-pack/test/functional/es_archives/reporting/bwc/6_3'); const usage = await usageAPI.getUsageStats(); reportingAPI.expectRecentJobTypeTotalStats(usage, 'csv', 0); @@ -126,7 +118,7 @@ export default function ({ getService }: FtrProviderContext) { reportingAPI.expectAllTimePdfLayoutStats(usage, 'preserve_layout', 3); reportingAPI.expectAllTimePdfLayoutStats(usage, 'print', 3); - await esArchiver.unload('reporting/bwc/6_3'); + await esArchiver.unload('x-pack/test/functional/es_archives/reporting/bwc/6_3'); }); }); diff --git a/x-pack/test/reporting_api_integration/reporting_without_security/job_apis.ts b/x-pack/test/reporting_api_integration/reporting_without_security/job_apis.ts index 194a3d6d1f5bc..3b34e17cd3cb1 100644 --- a/x-pack/test/reporting_api_integration/reporting_without_security/job_apis.ts +++ b/x-pack/test/reporting_api_integration/reporting_without_security/job_apis.ts @@ -18,13 +18,13 @@ export default function ({ getService }: FtrProviderContext) { describe('Job Listing APIs', () => { before(async () => { - await esArchiver.load('reporting/logs'); - await esArchiver.load('logstash_functional'); + await esArchiver.load('x-pack/test/functional/es_archives/reporting/logs'); + await esArchiver.load('x-pack/test/functional/es_archives/logstash_functional'); }); after(async () => { - await esArchiver.unload('reporting/logs'); - await esArchiver.unload('logstash_functional'); + await esArchiver.unload('x-pack/test/functional/es_archives/reporting/logs'); + await esArchiver.unload('x-pack/test/functional/es_archives/logstash_functional'); }); afterEach(async () => { diff --git a/x-pack/test/reporting_api_integration/services/scenarios.ts b/x-pack/test/reporting_api_integration/services/scenarios.ts index eee13b0bf07a2..bfbf030b0887a 100644 --- a/x-pack/test/reporting_api_integration/services/scenarios.ts +++ b/x-pack/test/reporting_api_integration/services/scenarios.ts @@ -31,12 +31,12 @@ export function createScenarios({ getService }: Pick { - await esArchiver.load('reporting/ecommerce'); - await esArchiver.load('reporting/ecommerce_kibana'); + await esArchiver.load('x-pack/test/functional/es_archives/reporting/ecommerce'); + await esArchiver.load('x-pack/test/functional/es_archives/reporting/ecommerce_kibana'); }; const teardownEcommerce = async () => { - await esArchiver.unload('reporting/ecommerce'); - await esArchiver.unload('reporting/ecommerce_kibana'); + await esArchiver.unload('x-pack/test/functional/es_archives/reporting/ecommerce'); + await esArchiver.unload('x-pack/test/functional/es_archives/reporting/ecommerce_kibana'); await deleteAllReports(); }; diff --git a/x-pack/test/reporting_functional/reporting_and_deprecated_security/security_roles_privileges.ts b/x-pack/test/reporting_functional/reporting_and_deprecated_security/security_roles_privileges.ts index 76ccb01477856..bd13e65ed8a25 100644 --- a/x-pack/test/reporting_functional/reporting_and_deprecated_security/security_roles_privileges.ts +++ b/x-pack/test/reporting_functional/reporting_and_deprecated_security/security_roles_privileges.ts @@ -70,11 +70,11 @@ export default function ({ getService }: FtrProviderContext) { const esArchiver = getService('esArchiver'); const reportingApi = getService('reportingAPI'); before('initialize tests', async () => { - await esArchiver.load('canvas/reports'); + await esArchiver.load('x-pack/test/functional/es_archives/canvas/reports'); }); after('teardown tests', async () => { - await esArchiver.unload('canvas/reports'); + await esArchiver.unload('x-pack/test/functional/es_archives/canvas/reports'); await reportingApi.deleteAllReports(); await reportingFunctional.initEcommerce(); }); diff --git a/x-pack/test/reporting_functional/reporting_and_security/security_roles_privileges.ts b/x-pack/test/reporting_functional/reporting_and_security/security_roles_privileges.ts index 20b88b22b542c..c2146e8c9dc5f 100644 --- a/x-pack/test/reporting_functional/reporting_and_security/security_roles_privileges.ts +++ b/x-pack/test/reporting_functional/reporting_and_security/security_roles_privileges.ts @@ -76,11 +76,11 @@ export default function ({ getService }: FtrProviderContext) { const esArchiver = getService('esArchiver'); const reportingApi = getService('reportingAPI'); before('initialize tests', async () => { - await esArchiver.load('canvas/reports'); + await esArchiver.load('x-pack/test/functional/es_archives/canvas/reports'); }); after('teardown tests', async () => { - await esArchiver.unload('canvas/reports'); + await esArchiver.unload('x-pack/test/functional/es_archives/canvas/reports'); await reportingApi.deleteAllReports(); await reportingFunctional.initEcommerce(); }); diff --git a/x-pack/test/reporting_functional/reporting_without_security/management.ts b/x-pack/test/reporting_functional/reporting_without_security/management.ts index b116bb5fe201c..030c890c963b1 100644 --- a/x-pack/test/reporting_functional/reporting_without_security/management.ts +++ b/x-pack/test/reporting_functional/reporting_without_security/management.ts @@ -30,13 +30,13 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { describe('Polling for jobs', () => { beforeEach(async () => { - await esArchiver.load('empty_kibana'); - await esArchiver.load('reporting/ecommerce_kibana'); + await esArchiver.load('x-pack/test/functional/es_archives/empty_kibana'); + await esArchiver.load('x-pack/test/functional/es_archives/reporting/ecommerce_kibana'); }); afterEach(async () => { - await esArchiver.unload('empty_kibana'); - await esArchiver.unload('reporting/ecommerce_kibana'); + await esArchiver.unload('x-pack/test/functional/es_archives/empty_kibana'); + await esArchiver.unload('x-pack/test/functional/es_archives/reporting/ecommerce_kibana'); await reportingApi.deleteAllReports(); }); diff --git a/x-pack/test/saved_object_api_integration/common/config.ts b/x-pack/test/saved_object_api_integration/common/config.ts index f83afb4db2412..9b9e46efa6d5d 100644 --- a/x-pack/test/saved_object_api_integration/common/config.ts +++ b/x-pack/test/saved_object_api_integration/common/config.ts @@ -39,10 +39,6 @@ export function createTestConfig(name: string, options: CreateTestConfigOptions) reportName: 'X-Pack Saved Object API Integration Tests -- ' + name, }, - esArchiver: { - directory: path.join(__dirname, 'fixtures', 'es_archiver'), - }, - esTestCluster: { ...config.xpack.api.get('esTestCluster'), license, diff --git a/x-pack/test/saved_object_api_integration/common/suites/bulk_create.ts b/x-pack/test/saved_object_api_integration/common/suites/bulk_create.ts index d85cfd4d7e12f..5860ec1f193b2 100644 --- a/x-pack/test/saved_object_api_integration/common/suites/bulk_create.ts +++ b/x-pack/test/saved_object_api_integration/common/suites/bulk_create.ts @@ -151,8 +151,16 @@ export function bulkCreateTestSuiteFactory(esArchiver: any, supertest: SuperTest const { user, spaceId = SPACES.DEFAULT.spaceId, tests } = definition; describeFn(description, () => { - before(() => esArchiver.load('saved_objects/spaces')); - after(() => esArchiver.unload('saved_objects/spaces')); + before(() => + esArchiver.load( + 'x-pack/test/saved_object_api_integration/common/fixtures/es_archiver/saved_objects/spaces' + ) + ); + after(() => + esArchiver.unload( + 'x-pack/test/saved_object_api_integration/common/fixtures/es_archiver/saved_objects/spaces' + ) + ); const attrs = { attributes: { [NEW_ATTRIBUTE_KEY]: NEW_ATTRIBUTE_VAL } }; diff --git a/x-pack/test/saved_object_api_integration/common/suites/bulk_get.ts b/x-pack/test/saved_object_api_integration/common/suites/bulk_get.ts index ef942972be0ff..26a693349496d 100644 --- a/x-pack/test/saved_object_api_integration/common/suites/bulk_get.ts +++ b/x-pack/test/saved_object_api_integration/common/suites/bulk_get.ts @@ -91,8 +91,16 @@ export function bulkGetTestSuiteFactory(esArchiver: any, supertest: SuperTest { - before(() => esArchiver.load('saved_objects/spaces')); - after(() => esArchiver.unload('saved_objects/spaces')); + before(() => + esArchiver.load( + 'x-pack/test/saved_object_api_integration/common/fixtures/es_archiver/saved_objects/spaces' + ) + ); + after(() => + esArchiver.unload( + 'x-pack/test/saved_object_api_integration/common/fixtures/es_archiver/saved_objects/spaces' + ) + ); for (const test of tests) { it(`should return ${test.responseStatusCode} ${test.title}`, async () => { diff --git a/x-pack/test/saved_object_api_integration/common/suites/bulk_update.ts b/x-pack/test/saved_object_api_integration/common/suites/bulk_update.ts index 246f84538c1a7..7ac83b3be8d04 100644 --- a/x-pack/test/saved_object_api_integration/common/suites/bulk_update.ts +++ b/x-pack/test/saved_object_api_integration/common/suites/bulk_update.ts @@ -99,8 +99,16 @@ export function bulkUpdateTestSuiteFactory(esArchiver: any, supertest: SuperTest const { user, spaceId = SPACES.DEFAULT.spaceId, tests } = definition; describeFn(description, () => { - before(() => esArchiver.load('saved_objects/spaces')); - after(() => esArchiver.unload('saved_objects/spaces')); + before(() => + esArchiver.load( + 'x-pack/test/saved_object_api_integration/common/fixtures/es_archiver/saved_objects/spaces' + ) + ); + after(() => + esArchiver.unload( + 'x-pack/test/saved_object_api_integration/common/fixtures/es_archiver/saved_objects/spaces' + ) + ); const attrs = { attributes: { [NEW_ATTRIBUTE_KEY]: NEW_ATTRIBUTE_VAL } }; diff --git a/x-pack/test/saved_object_api_integration/common/suites/create.ts b/x-pack/test/saved_object_api_integration/common/suites/create.ts index 190eed0edaef2..ff2bfdefb4c08 100644 --- a/x-pack/test/saved_object_api_integration/common/suites/create.ts +++ b/x-pack/test/saved_object_api_integration/common/suites/create.ts @@ -119,8 +119,16 @@ export function createTestSuiteFactory(esArchiver: any, supertest: SuperTest { - before(() => esArchiver.load('saved_objects/spaces')); - after(() => esArchiver.unload('saved_objects/spaces')); + before(() => + esArchiver.load( + 'x-pack/test/saved_object_api_integration/common/fixtures/es_archiver/saved_objects/spaces' + ) + ); + after(() => + esArchiver.unload( + 'x-pack/test/saved_object_api_integration/common/fixtures/es_archiver/saved_objects/spaces' + ) + ); for (const test of tests) { it(`should return ${test.responseStatusCode} ${test.title}`, async () => { diff --git a/x-pack/test/saved_object_api_integration/common/suites/delete.ts b/x-pack/test/saved_object_api_integration/common/suites/delete.ts index 9726c47a9bc0a..8c861f9debbc1 100644 --- a/x-pack/test/saved_object_api_integration/common/suites/delete.ts +++ b/x-pack/test/saved_object_api_integration/common/suites/delete.ts @@ -78,8 +78,16 @@ export function deleteTestSuiteFactory(esArchiver: any, supertest: SuperTest { - before(() => esArchiver.load('saved_objects/spaces')); - after(() => esArchiver.unload('saved_objects/spaces')); + before(() => + esArchiver.load( + 'x-pack/test/saved_object_api_integration/common/fixtures/es_archiver/saved_objects/spaces' + ) + ); + after(() => + esArchiver.unload( + 'x-pack/test/saved_object_api_integration/common/fixtures/es_archiver/saved_objects/spaces' + ) + ); for (const test of tests) { it(`should return ${test.responseStatusCode} ${test.title}`, async () => { diff --git a/x-pack/test/saved_object_api_integration/common/suites/export.ts b/x-pack/test/saved_object_api_integration/common/suites/export.ts index 94b75f1fd536d..d9ebbac810231 100644 --- a/x-pack/test/saved_object_api_integration/common/suites/export.ts +++ b/x-pack/test/saved_object_api_integration/common/suites/export.ts @@ -219,8 +219,16 @@ export function exportTestSuiteFactory(esArchiver: any, supertest: SuperTest { - before(() => esArchiver.load('saved_objects/spaces')); - after(() => esArchiver.unload('saved_objects/spaces')); + before(() => + esArchiver.load( + 'x-pack/test/saved_object_api_integration/common/fixtures/es_archiver/saved_objects/spaces' + ) + ); + after(() => + esArchiver.unload( + 'x-pack/test/saved_object_api_integration/common/fixtures/es_archiver/saved_objects/spaces' + ) + ); for (const test of tests) { it(`should return ${test.responseStatusCode} ${test.title}`, async () => { diff --git a/x-pack/test/saved_object_api_integration/common/suites/find.ts b/x-pack/test/saved_object_api_integration/common/suites/find.ts index 27905459c29b7..7b5175b906ebe 100644 --- a/x-pack/test/saved_object_api_integration/common/suites/find.ts +++ b/x-pack/test/saved_object_api_integration/common/suites/find.ts @@ -278,8 +278,16 @@ export function findTestSuiteFactory(esArchiver: any, supertest: SuperTest) const { user, spaceId = DEFAULT_SPACE_ID, tests } = definition; describeFn(description, () => { - before(() => esArchiver.load('saved_objects/spaces')); - after(() => esArchiver.unload('saved_objects/spaces')); + before(() => + esArchiver.load( + 'x-pack/test/saved_object_api_integration/common/fixtures/es_archiver/saved_objects/spaces' + ) + ); + after(() => + esArchiver.unload( + 'x-pack/test/saved_object_api_integration/common/fixtures/es_archiver/saved_objects/spaces' + ) + ); for (const test of tests) { it(`should return ${test.responseStatusCode} ${test.title}`, async () => { diff --git a/x-pack/test/saved_object_api_integration/common/suites/get.ts b/x-pack/test/saved_object_api_integration/common/suites/get.ts index b7d0723348513..a4d167276cc71 100644 --- a/x-pack/test/saved_object_api_integration/common/suites/get.ts +++ b/x-pack/test/saved_object_api_integration/common/suites/get.ts @@ -66,8 +66,16 @@ export function getTestSuiteFactory(esArchiver: any, supertest: SuperTest) const { user, spaceId = SPACES.DEFAULT.spaceId, tests } = definition; describeFn(description, () => { - before(() => esArchiver.load('saved_objects/spaces')); - after(() => esArchiver.unload('saved_objects/spaces')); + before(() => + esArchiver.load( + 'x-pack/test/saved_object_api_integration/common/fixtures/es_archiver/saved_objects/spaces' + ) + ); + after(() => + esArchiver.unload( + 'x-pack/test/saved_object_api_integration/common/fixtures/es_archiver/saved_objects/spaces' + ) + ); for (const test of tests) { it(`should return ${test.responseStatusCode} ${test.title}`, async () => { diff --git a/x-pack/test/saved_object_api_integration/common/suites/import.ts b/x-pack/test/saved_object_api_integration/common/suites/import.ts index f2794d1685a23..34c53fc577094 100644 --- a/x-pack/test/saved_object_api_integration/common/suites/import.ts +++ b/x-pack/test/saved_object_api_integration/common/suites/import.ts @@ -237,8 +237,16 @@ export function importTestSuiteFactory( const { user, spaceId = SPACES.DEFAULT.spaceId, tests } = definition; describeFn(description, () => { - before(() => esArchiver.load('saved_objects/spaces')); - after(() => esArchiver.unload('saved_objects/spaces')); + before(() => + esArchiver.load( + 'x-pack/test/saved_object_api_integration/common/fixtures/es_archiver/saved_objects/spaces' + ) + ); + after(() => + esArchiver.unload( + 'x-pack/test/saved_object_api_integration/common/fixtures/es_archiver/saved_objects/spaces' + ) + ); const attrs = { attributes: { [NEW_ATTRIBUTE_KEY]: NEW_ATTRIBUTE_VAL } }; diff --git a/x-pack/test/saved_object_api_integration/common/suites/resolve.ts b/x-pack/test/saved_object_api_integration/common/suites/resolve.ts index 80a4a805224bf..47aafc400ce76 100644 --- a/x-pack/test/saved_object_api_integration/common/suites/resolve.ts +++ b/x-pack/test/saved_object_api_integration/common/suites/resolve.ts @@ -120,8 +120,16 @@ export function resolveTestSuiteFactory(esArchiver: any, supertest: SuperTest { - before(() => esArchiver.load('saved_objects/spaces')); - after(() => esArchiver.unload('saved_objects/spaces')); + before(() => + esArchiver.load( + 'x-pack/test/saved_object_api_integration/common/fixtures/es_archiver/saved_objects/spaces' + ) + ); + after(() => + esArchiver.unload( + 'x-pack/test/saved_object_api_integration/common/fixtures/es_archiver/saved_objects/spaces' + ) + ); for (const test of tests) { it(`should return ${test.responseStatusCode} ${test.title}`, async () => { diff --git a/x-pack/test/saved_object_api_integration/common/suites/resolve_import_errors.ts b/x-pack/test/saved_object_api_integration/common/suites/resolve_import_errors.ts index 8079c74c76322..d3792f7649cc7 100644 --- a/x-pack/test/saved_object_api_integration/common/suites/resolve_import_errors.ts +++ b/x-pack/test/saved_object_api_integration/common/suites/resolve_import_errors.ts @@ -245,8 +245,16 @@ export function resolveImportErrorsTestSuiteFactory( const { user, spaceId = SPACES.DEFAULT.spaceId, tests } = definition; describeFn(description, () => { - before(() => esArchiver.load('saved_objects/spaces')); - after(() => esArchiver.unload('saved_objects/spaces')); + before(() => + esArchiver.load( + 'x-pack/test/saved_object_api_integration/common/fixtures/es_archiver/saved_objects/spaces' + ) + ); + after(() => + esArchiver.unload( + 'x-pack/test/saved_object_api_integration/common/fixtures/es_archiver/saved_objects/spaces' + ) + ); const attrs = { attributes: { [NEW_ATTRIBUTE_KEY]: NEW_ATTRIBUTE_VAL } }; diff --git a/x-pack/test/saved_object_api_integration/common/suites/update.ts b/x-pack/test/saved_object_api_integration/common/suites/update.ts index 7292e4dce5c3b..90dbb366b4e4e 100644 --- a/x-pack/test/saved_object_api_integration/common/suites/update.ts +++ b/x-pack/test/saved_object_api_integration/common/suites/update.ts @@ -77,8 +77,16 @@ export function updateTestSuiteFactory(esArchiver: any, supertest: SuperTest { - before(() => esArchiver.load('saved_objects/spaces')); - after(() => esArchiver.unload('saved_objects/spaces')); + before(() => + esArchiver.load( + 'x-pack/test/saved_object_api_integration/common/fixtures/es_archiver/saved_objects/spaces' + ) + ); + after(() => + esArchiver.unload( + 'x-pack/test/saved_object_api_integration/common/fixtures/es_archiver/saved_objects/spaces' + ) + ); for (const test of tests) { it(`should return ${test.responseStatusCode} ${test.title}`, async () => { diff --git a/x-pack/test/saved_object_tagging/api_integration/security_and_spaces/apis/_bulk_delete.ts b/x-pack/test/saved_object_tagging/api_integration/security_and_spaces/apis/_bulk_delete.ts index 296c92cac75d7..18a87c702ba34 100644 --- a/x-pack/test/saved_object_tagging/api_integration/security_and_spaces/apis/_bulk_delete.ts +++ b/x-pack/test/saved_object_tagging/api_integration/security_and_spaces/apis/_bulk_delete.ts @@ -16,11 +16,15 @@ export default function ({ getService }: FtrProviderContext) { describe('POST /internal/saved_objects_tagging/tags/_bulk_delete', () => { beforeEach(async () => { - await esArchiver.load('rbac_tags'); + await esArchiver.load( + 'x-pack/test/saved_object_tagging/common/fixtures/es_archiver/rbac_tags' + ); }); afterEach(async () => { - await esArchiver.unload('rbac_tags'); + await esArchiver.unload( + 'x-pack/test/saved_object_tagging/common/fixtures/es_archiver/rbac_tags' + ); }); const responses: Record = { diff --git a/x-pack/test/saved_object_tagging/api_integration/security_and_spaces/apis/_find.ts b/x-pack/test/saved_object_tagging/api_integration/security_and_spaces/apis/_find.ts index 3b845fe2e115c..6d8e72c0b9070 100644 --- a/x-pack/test/saved_object_tagging/api_integration/security_and_spaces/apis/_find.ts +++ b/x-pack/test/saved_object_tagging/api_integration/security_and_spaces/apis/_find.ts @@ -16,11 +16,15 @@ export default function ({ getService }: FtrProviderContext) { describe('GET /internal/saved_objects_tagging/tags/_find', () => { before(async () => { - await esArchiver.load('rbac_tags'); + await esArchiver.load( + 'x-pack/test/saved_object_tagging/common/fixtures/es_archiver/rbac_tags' + ); }); after(async () => { - await esArchiver.unload('rbac_tags'); + await esArchiver.unload( + 'x-pack/test/saved_object_tagging/common/fixtures/es_archiver/rbac_tags' + ); }); const responses: Record = { diff --git a/x-pack/test/saved_object_tagging/api_integration/security_and_spaces/apis/_get_assignable_types.ts b/x-pack/test/saved_object_tagging/api_integration/security_and_spaces/apis/_get_assignable_types.ts index 7398f28210c09..a20679ac6002b 100644 --- a/x-pack/test/saved_object_tagging/api_integration/security_and_spaces/apis/_get_assignable_types.ts +++ b/x-pack/test/saved_object_tagging/api_integration/security_and_spaces/apis/_get_assignable_types.ts @@ -16,11 +16,15 @@ export default function ({ getService }: FtrProviderContext) { describe('GET /internal/saved_objects_tagging/assignments/_assignable_types', () => { before(async () => { - await esArchiver.load('rbac_tags'); + await esArchiver.load( + 'x-pack/test/saved_object_tagging/common/fixtures/es_archiver/rbac_tags' + ); }); after(async () => { - await esArchiver.unload('rbac_tags'); + await esArchiver.unload( + 'x-pack/test/saved_object_tagging/common/fixtures/es_archiver/rbac_tags' + ); }); const assignablePerUser = { diff --git a/x-pack/test/saved_object_tagging/api_integration/security_and_spaces/apis/bulk_assign.ts b/x-pack/test/saved_object_tagging/api_integration/security_and_spaces/apis/bulk_assign.ts index 441d4ef0c406d..cf1b7356f94cf 100644 --- a/x-pack/test/saved_object_tagging/api_integration/security_and_spaces/apis/bulk_assign.ts +++ b/x-pack/test/saved_object_tagging/api_integration/security_and_spaces/apis/bulk_assign.ts @@ -16,11 +16,15 @@ export default function ({ getService }: FtrProviderContext) { describe('POST /api/saved_objects_tagging/assignments/update_by_tags', () => { beforeEach(async () => { - await esArchiver.load('bulk_assign'); + await esArchiver.load( + 'x-pack/test/saved_object_tagging/common/fixtures/es_archiver/bulk_assign' + ); }); afterEach(async () => { - await esArchiver.unload('bulk_assign'); + await esArchiver.unload( + 'x-pack/test/saved_object_tagging/common/fixtures/es_archiver/bulk_assign' + ); }); const authorized: ExpectedResponse = { diff --git a/x-pack/test/saved_object_tagging/api_integration/security_and_spaces/apis/create.ts b/x-pack/test/saved_object_tagging/api_integration/security_and_spaces/apis/create.ts index 15a0a2bffc457..fecba696ce623 100644 --- a/x-pack/test/saved_object_tagging/api_integration/security_and_spaces/apis/create.ts +++ b/x-pack/test/saved_object_tagging/api_integration/security_and_spaces/apis/create.ts @@ -16,11 +16,15 @@ export default function ({ getService }: FtrProviderContext) { describe('POST /api/saved_objects_tagging/tags/create', () => { beforeEach(async () => { - await esArchiver.load('rbac_tags'); + await esArchiver.load( + 'x-pack/test/saved_object_tagging/common/fixtures/es_archiver/rbac_tags' + ); }); afterEach(async () => { - await esArchiver.unload('rbac_tags'); + await esArchiver.unload( + 'x-pack/test/saved_object_tagging/common/fixtures/es_archiver/rbac_tags' + ); }); const responses: Record = { diff --git a/x-pack/test/saved_object_tagging/api_integration/security_and_spaces/apis/delete.ts b/x-pack/test/saved_object_tagging/api_integration/security_and_spaces/apis/delete.ts index 998fddafe6a3f..edb430767135a 100644 --- a/x-pack/test/saved_object_tagging/api_integration/security_and_spaces/apis/delete.ts +++ b/x-pack/test/saved_object_tagging/api_integration/security_and_spaces/apis/delete.ts @@ -16,11 +16,15 @@ export default function ({ getService }: FtrProviderContext) { describe('DELETE /api/saved_objects_tagging/tags/{id}', () => { beforeEach(async () => { - await esArchiver.load('rbac_tags'); + await esArchiver.load( + 'x-pack/test/saved_object_tagging/common/fixtures/es_archiver/rbac_tags' + ); }); afterEach(async () => { - await esArchiver.unload('rbac_tags'); + await esArchiver.unload( + 'x-pack/test/saved_object_tagging/common/fixtures/es_archiver/rbac_tags' + ); }); const responses: Record = { diff --git a/x-pack/test/saved_object_tagging/api_integration/security_and_spaces/apis/get.ts b/x-pack/test/saved_object_tagging/api_integration/security_and_spaces/apis/get.ts index 03fecaec21c90..73b553f912add 100644 --- a/x-pack/test/saved_object_tagging/api_integration/security_and_spaces/apis/get.ts +++ b/x-pack/test/saved_object_tagging/api_integration/security_and_spaces/apis/get.ts @@ -16,11 +16,15 @@ export default function ({ getService }: FtrProviderContext) { describe('GET /api/saved_objects_tagging/tags/{id}', () => { before(async () => { - await esArchiver.load('rbac_tags'); + await esArchiver.load( + 'x-pack/test/saved_object_tagging/common/fixtures/es_archiver/rbac_tags' + ); }); after(async () => { - await esArchiver.unload('rbac_tags'); + await esArchiver.unload( + 'x-pack/test/saved_object_tagging/common/fixtures/es_archiver/rbac_tags' + ); }); const responses: Record = { diff --git a/x-pack/test/saved_object_tagging/api_integration/security_and_spaces/apis/get_all.ts b/x-pack/test/saved_object_tagging/api_integration/security_and_spaces/apis/get_all.ts index 87e7eda12f3ab..06f693de631e5 100644 --- a/x-pack/test/saved_object_tagging/api_integration/security_and_spaces/apis/get_all.ts +++ b/x-pack/test/saved_object_tagging/api_integration/security_and_spaces/apis/get_all.ts @@ -16,11 +16,15 @@ export default function ({ getService }: FtrProviderContext) { describe('GET /api/saved_objects_tagging/tags', () => { before(async () => { - await esArchiver.load('rbac_tags'); + await esArchiver.load( + 'x-pack/test/saved_object_tagging/common/fixtures/es_archiver/rbac_tags' + ); }); after(async () => { - await esArchiver.unload('rbac_tags'); + await esArchiver.unload( + 'x-pack/test/saved_object_tagging/common/fixtures/es_archiver/rbac_tags' + ); }); const responses: Record = { diff --git a/x-pack/test/saved_object_tagging/api_integration/security_and_spaces/apis/update.ts b/x-pack/test/saved_object_tagging/api_integration/security_and_spaces/apis/update.ts index d333392aa326f..c9bed41de2d36 100644 --- a/x-pack/test/saved_object_tagging/api_integration/security_and_spaces/apis/update.ts +++ b/x-pack/test/saved_object_tagging/api_integration/security_and_spaces/apis/update.ts @@ -16,11 +16,15 @@ export default function ({ getService }: FtrProviderContext) { describe('POST /api/saved_objects_tagging/tags/{id}', () => { beforeEach(async () => { - await esArchiver.load('rbac_tags'); + await esArchiver.load( + 'x-pack/test/saved_object_tagging/common/fixtures/es_archiver/rbac_tags' + ); }); afterEach(async () => { - await esArchiver.unload('rbac_tags'); + await esArchiver.unload( + 'x-pack/test/saved_object_tagging/common/fixtures/es_archiver/rbac_tags' + ); }); const responses: Record = { diff --git a/x-pack/test/saved_object_tagging/api_integration/security_and_spaces/config.ts b/x-pack/test/saved_object_tagging/api_integration/security_and_spaces/config.ts index 08ba10b64e579..0e2ecc8c48ebf 100644 --- a/x-pack/test/saved_object_tagging/api_integration/security_and_spaces/config.ts +++ b/x-pack/test/saved_object_tagging/api_integration/security_and_spaces/config.ts @@ -5,7 +5,6 @@ * 2.0. */ -import path from 'path'; import { FtrConfigProviderContext } from '@kbn/test'; import { services } from './services'; @@ -23,9 +22,6 @@ export default async function ({ readConfigFile }: FtrConfigProviderContext) { reportName: 'X-Pack Saved Object Tagging API Integration Tests - Security and Spaces integration', }, - esArchiver: { - directory: path.resolve(__dirname, '..', '..', 'common', 'fixtures', 'es_archiver'), - }, esTestCluster: { ...apiIntegrationConfig.get('esTestCluster'), license: 'trial', diff --git a/x-pack/test/saved_object_tagging/api_integration/tagging_api/apis/bulk_assign.ts b/x-pack/test/saved_object_tagging/api_integration/tagging_api/apis/bulk_assign.ts index 0a4480bb74a99..75471900201d3 100644 --- a/x-pack/test/saved_object_tagging/api_integration/tagging_api/apis/bulk_assign.ts +++ b/x-pack/test/saved_object_tagging/api_integration/tagging_api/apis/bulk_assign.ts @@ -15,11 +15,15 @@ export default function ({ getService }: FtrProviderContext) { describe('POST /api/saved_objects_tagging/assignments/update_by_tags', () => { beforeEach(async () => { - await esArchiver.load('bulk_assign'); + await esArchiver.load( + 'x-pack/test/saved_object_tagging/common/fixtures/es_archiver/bulk_assign' + ); }); afterEach(async () => { - await esArchiver.unload('bulk_assign'); + await esArchiver.unload( + 'x-pack/test/saved_object_tagging/common/fixtures/es_archiver/bulk_assign' + ); }); it('allows to update tag assignments', async () => { diff --git a/x-pack/test/saved_object_tagging/api_integration/tagging_api/apis/create.ts b/x-pack/test/saved_object_tagging/api_integration/tagging_api/apis/create.ts index cdbe249bd5f3e..b324a6138838b 100644 --- a/x-pack/test/saved_object_tagging/api_integration/tagging_api/apis/create.ts +++ b/x-pack/test/saved_object_tagging/api_integration/tagging_api/apis/create.ts @@ -15,11 +15,15 @@ export default function ({ getService }: FtrProviderContext) { describe('POST /api/saved_objects_tagging/tags/create', () => { beforeEach(async () => { - await esArchiver.load('functional_base'); + await esArchiver.load( + 'x-pack/test/saved_object_tagging/common/fixtures/es_archiver/functional_base' + ); }); afterEach(async () => { - await esArchiver.unload('functional_base'); + await esArchiver.unload( + 'x-pack/test/saved_object_tagging/common/fixtures/es_archiver/functional_base' + ); }); it('should create the tag when validation succeed', async () => { diff --git a/x-pack/test/saved_object_tagging/api_integration/tagging_api/apis/delete.ts b/x-pack/test/saved_object_tagging/api_integration/tagging_api/apis/delete.ts index c0cf77c7d2b8c..55c88b212fd1c 100644 --- a/x-pack/test/saved_object_tagging/api_integration/tagging_api/apis/delete.ts +++ b/x-pack/test/saved_object_tagging/api_integration/tagging_api/apis/delete.ts @@ -15,11 +15,15 @@ export default function ({ getService }: FtrProviderContext) { describe('DELETE /api/saved_objects_tagging/tags/{id}', () => { beforeEach(async () => { - await esArchiver.load('delete_with_references'); + await esArchiver.load( + 'x-pack/test/saved_object_tagging/common/fixtures/es_archiver/delete_with_references' + ); }); afterEach(async () => { - await esArchiver.unload('delete_with_references'); + await esArchiver.unload( + 'x-pack/test/saved_object_tagging/common/fixtures/es_archiver/delete_with_references' + ); }); it('should delete the tag', async () => { diff --git a/x-pack/test/saved_object_tagging/api_integration/tagging_api/apis/update.ts b/x-pack/test/saved_object_tagging/api_integration/tagging_api/apis/update.ts index 2c9daddc01ec5..899d96a7bd061 100644 --- a/x-pack/test/saved_object_tagging/api_integration/tagging_api/apis/update.ts +++ b/x-pack/test/saved_object_tagging/api_integration/tagging_api/apis/update.ts @@ -15,11 +15,15 @@ export default function ({ getService }: FtrProviderContext) { describe('POST /api/saved_objects_tagging/tags/{id}', () => { beforeEach(async () => { - await esArchiver.load('functional_base'); + await esArchiver.load( + 'x-pack/test/saved_object_tagging/common/fixtures/es_archiver/functional_base' + ); }); afterEach(async () => { - await esArchiver.unload('functional_base'); + await esArchiver.unload( + 'x-pack/test/saved_object_tagging/common/fixtures/es_archiver/functional_base' + ); }); it('should update the tag when validation succeed', async () => { diff --git a/x-pack/test/saved_object_tagging/api_integration/tagging_api/apis/usage_collection.ts b/x-pack/test/saved_object_tagging/api_integration/tagging_api/apis/usage_collection.ts index cd834cb034b6d..b6ec4aa8dcfa5 100644 --- a/x-pack/test/saved_object_tagging/api_integration/tagging_api/apis/usage_collection.ts +++ b/x-pack/test/saved_object_tagging/api_integration/tagging_api/apis/usage_collection.ts @@ -15,11 +15,15 @@ export default function ({ getService }: FtrProviderContext) { describe('saved_object_tagging usage collector data', () => { beforeEach(async () => { - await esArchiver.load('usage_collection'); + await esArchiver.load( + 'x-pack/test/saved_object_tagging/common/fixtures/es_archiver/usage_collection' + ); }); afterEach(async () => { - await esArchiver.unload('usage_collection'); + await esArchiver.unload( + 'x-pack/test/saved_object_tagging/common/fixtures/es_archiver/usage_collection' + ); }); /* diff --git a/x-pack/test/saved_object_tagging/api_integration/tagging_api/config.ts b/x-pack/test/saved_object_tagging/api_integration/tagging_api/config.ts index ebdb055bd5e89..4d2b2a4313357 100644 --- a/x-pack/test/saved_object_tagging/api_integration/tagging_api/config.ts +++ b/x-pack/test/saved_object_tagging/api_integration/tagging_api/config.ts @@ -5,7 +5,6 @@ * 2.0. */ -import path from 'path'; import { FtrConfigProviderContext } from '@kbn/test'; import { services } from './services'; @@ -22,9 +21,6 @@ export default async function ({ readConfigFile }: FtrConfigProviderContext) { junit: { reportName: 'X-Pack Saved Object Tagging API Integration Tests', }, - esArchiver: { - directory: path.resolve(__dirname, '..', '..', 'common', 'fixtures', 'es_archiver'), - }, esTestCluster: { ...apiIntegrationConfig.get('esTestCluster'), license: 'trial', diff --git a/x-pack/test/saved_object_tagging/functional/config.ts b/x-pack/test/saved_object_tagging/functional/config.ts index 0044063e18c69..6ad1f05e2be5b 100644 --- a/x-pack/test/saved_object_tagging/functional/config.ts +++ b/x-pack/test/saved_object_tagging/functional/config.ts @@ -5,7 +5,6 @@ * 2.0. */ -import path from 'path'; import { FtrConfigProviderContext } from '@kbn/test'; import { services, pageObjects } from './ftr_provider_context'; @@ -23,10 +22,6 @@ export default async function ({ readConfigFile }: FtrConfigProviderContext) { services, pageObjects, - esArchiver: { - directory: path.resolve(__dirname, '..', 'common', 'fixtures', 'es_archiver'), - }, - junit: { reportName: 'X-Pack Saved Object Tagging Functional Tests', }, diff --git a/x-pack/test/saved_object_tagging/functional/tests/bulk_actions.ts b/x-pack/test/saved_object_tagging/functional/tests/bulk_actions.ts index 5beea64490f24..3c7a24b281f6f 100644 --- a/x-pack/test/saved_object_tagging/functional/tests/bulk_actions.ts +++ b/x-pack/test/saved_object_tagging/functional/tests/bulk_actions.ts @@ -16,11 +16,15 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { describe('table bulk actions', () => { beforeEach(async () => { - await esArchiver.load('functional_base'); + await esArchiver.load( + 'x-pack/test/saved_object_tagging/common/fixtures/es_archiver/functional_base' + ); await tagManagementPage.navigateTo(); }); afterEach(async () => { - await esArchiver.unload('functional_base'); + await esArchiver.unload( + 'x-pack/test/saved_object_tagging/common/fixtures/es_archiver/functional_base' + ); }); describe('bulk delete', () => { diff --git a/x-pack/test/saved_object_tagging/functional/tests/bulk_assign.ts b/x-pack/test/saved_object_tagging/functional/tests/bulk_assign.ts index b01698573e3c8..1da08acbc7e01 100644 --- a/x-pack/test/saved_object_tagging/functional/tests/bulk_assign.ts +++ b/x-pack/test/saved_object_tagging/functional/tests/bulk_assign.ts @@ -19,12 +19,16 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { beforeEach(async () => { assignFlyout = tagManagementPage.assignFlyout; - await esArchiver.load('bulk_assign'); + await esArchiver.load( + 'x-pack/test/saved_object_tagging/common/fixtures/es_archiver/bulk_assign' + ); await tagManagementPage.navigateTo(); }); afterEach(async () => { - await esArchiver.unload('bulk_assign'); + await esArchiver.unload( + 'x-pack/test/saved_object_tagging/common/fixtures/es_archiver/bulk_assign' + ); }); it('can bulk assign tags to objects', async () => { diff --git a/x-pack/test/saved_object_tagging/functional/tests/create.ts b/x-pack/test/saved_object_tagging/functional/tests/create.ts index 7848664b56ff8..ea2697bf37b75 100644 --- a/x-pack/test/saved_object_tagging/functional/tests/create.ts +++ b/x-pack/test/saved_object_tagging/functional/tests/create.ts @@ -20,11 +20,15 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { before(async () => { tagModal = tagManagementPage.tagModal; - await esArchiver.load('functional_base'); + await esArchiver.load( + 'x-pack/test/saved_object_tagging/common/fixtures/es_archiver/functional_base' + ); await tagManagementPage.navigateTo(); }); after(async () => { - await esArchiver.unload('functional_base'); + await esArchiver.unload( + 'x-pack/test/saved_object_tagging/common/fixtures/es_archiver/functional_base' + ); }); afterEach(async () => { diff --git a/x-pack/test/saved_object_tagging/functional/tests/dashboard_integration.ts b/x-pack/test/saved_object_tagging/functional/tests/dashboard_integration.ts index f5b81e49f8c2f..ffaa595c16bec 100644 --- a/x-pack/test/saved_object_tagging/functional/tests/dashboard_integration.ts +++ b/x-pack/test/saved_object_tagging/functional/tests/dashboard_integration.ts @@ -38,12 +38,20 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { describe('dashboard integration', () => { before(async () => { - await esArchiver.load('dashboard'); - await esArchiver.loadIfNeeded('logstash_functional'); + await esArchiver.load( + 'x-pack/test/saved_object_tagging/common/fixtures/es_archiver/dashboard' + ); + await esArchiver.loadIfNeeded( + 'x-pack/test/saved_object_tagging/common/fixtures/es_archiver/logstash_functional' + ); }); after(async () => { - await esArchiver.unload('dashboard'); - await esArchiver.unload('logstash_functional'); + await esArchiver.unload( + 'x-pack/test/saved_object_tagging/common/fixtures/es_archiver/dashboard' + ); + await esArchiver.unload( + 'x-pack/test/saved_object_tagging/common/fixtures/es_archiver/logstash_functional' + ); }); describe('listing', () => { diff --git a/x-pack/test/saved_object_tagging/functional/tests/edit.ts b/x-pack/test/saved_object_tagging/functional/tests/edit.ts index d2cb2ac24b605..f5d3f11e25b6e 100644 --- a/x-pack/test/saved_object_tagging/functional/tests/edit.ts +++ b/x-pack/test/saved_object_tagging/functional/tests/edit.ts @@ -20,11 +20,15 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { before(async () => { tagModal = tagManagementPage.tagModal; - await esArchiver.load('functional_base'); + await esArchiver.load( + 'x-pack/test/saved_object_tagging/common/fixtures/es_archiver/functional_base' + ); await tagManagementPage.navigateTo(); }); after(async () => { - await esArchiver.unload('functional_base'); + await esArchiver.unload( + 'x-pack/test/saved_object_tagging/common/fixtures/es_archiver/functional_base' + ); }); afterEach(async () => { diff --git a/x-pack/test/saved_object_tagging/functional/tests/feature_control.ts b/x-pack/test/saved_object_tagging/functional/tests/feature_control.ts index 02e3a84d7af64..1f6197b02afa3 100644 --- a/x-pack/test/saved_object_tagging/functional/tests/feature_control.ts +++ b/x-pack/test/saved_object_tagging/functional/tests/feature_control.ts @@ -88,10 +88,14 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { describe('feature controls', () => { before(async () => { - await esArchiver.load('functional_base'); + await esArchiver.load( + 'x-pack/test/saved_object_tagging/common/fixtures/es_archiver/functional_base' + ); }); after(async () => { - await esArchiver.unload('functional_base'); + await esArchiver.unload( + 'x-pack/test/saved_object_tagging/common/fixtures/es_archiver/functional_base' + ); }); addFeatureControlSuite({ diff --git a/x-pack/test/saved_object_tagging/functional/tests/listing.ts b/x-pack/test/saved_object_tagging/functional/tests/listing.ts index 95b2ba13473f7..d1ab68e57ef63 100644 --- a/x-pack/test/saved_object_tagging/functional/tests/listing.ts +++ b/x-pack/test/saved_object_tagging/functional/tests/listing.ts @@ -16,11 +16,15 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { describe('table listing', () => { before(async () => { - await esArchiver.load('functional_base'); + await esArchiver.load( + 'x-pack/test/saved_object_tagging/common/fixtures/es_archiver/functional_base' + ); await tagManagementPage.navigateTo(); }); after(async () => { - await esArchiver.unload('functional_base'); + await esArchiver.unload( + 'x-pack/test/saved_object_tagging/common/fixtures/es_archiver/functional_base' + ); }); describe('searching', () => { diff --git a/x-pack/test/saved_object_tagging/functional/tests/maps_integration.ts b/x-pack/test/saved_object_tagging/functional/tests/maps_integration.ts index f1aac575f430d..632610fee0f53 100644 --- a/x-pack/test/saved_object_tagging/functional/tests/maps_integration.ts +++ b/x-pack/test/saved_object_tagging/functional/tests/maps_integration.ts @@ -37,10 +37,10 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { // Failing: See https://github.com/elastic/kibana/issues/89073 describe.skip('maps integration', () => { before(async () => { - await esArchiver.load('maps'); + await esArchiver.load('x-pack/test/saved_object_tagging/common/fixtures/es_archiver/maps'); }); after(async () => { - await esArchiver.unload('maps'); + await esArchiver.unload('x-pack/test/saved_object_tagging/common/fixtures/es_archiver/maps'); }); describe('listing', () => { diff --git a/x-pack/test/saved_object_tagging/functional/tests/som_integration.ts b/x-pack/test/saved_object_tagging/functional/tests/som_integration.ts index 549aea36f5b60..4688cfba4b864 100644 --- a/x-pack/test/saved_object_tagging/functional/tests/som_integration.ts +++ b/x-pack/test/saved_object_tagging/functional/tests/som_integration.ts @@ -39,10 +39,14 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { describe('saved objects management integration', () => { before(async () => { - await esArchiver.load('so_management'); + await esArchiver.load( + 'x-pack/test/saved_object_tagging/common/fixtures/es_archiver/so_management' + ); }); after(async () => { - await esArchiver.unload('so_management'); + await esArchiver.unload( + 'x-pack/test/saved_object_tagging/common/fixtures/es_archiver/so_management' + ); }); describe('navigating from the tag section', () => { diff --git a/x-pack/test/saved_object_tagging/functional/tests/visualize_integration.ts b/x-pack/test/saved_object_tagging/functional/tests/visualize_integration.ts index 4877b0d5d8540..9789b4146c05d 100644 --- a/x-pack/test/saved_object_tagging/functional/tests/visualize_integration.ts +++ b/x-pack/test/saved_object_tagging/functional/tests/visualize_integration.ts @@ -49,12 +49,20 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { // Failing: See https://github.com/elastic/kibana/issues/89958 describe.skip('visualize integration', () => { before(async () => { - await esArchiver.load('visualize'); - await esArchiver.loadIfNeeded('logstash_functional'); + await esArchiver.load( + 'x-pack/test/saved_object_tagging/common/fixtures/es_archiver/visualize' + ); + await esArchiver.loadIfNeeded( + 'x-pack/test/saved_object_tagging/common/fixtures/es_archiver/logstash_functional' + ); }); after(async () => { - await esArchiver.unload('visualize'); - await esArchiver.unload('logstash_functional'); + await esArchiver.unload( + 'x-pack/test/saved_object_tagging/common/fixtures/es_archiver/visualize' + ); + await esArchiver.unload( + 'x-pack/test/saved_object_tagging/common/fixtures/es_archiver/logstash_functional' + ); }); describe('listing', () => { diff --git a/x-pack/test/search_sessions_integration/tests/apps/dashboard/async_search/index.ts b/x-pack/test/search_sessions_integration/tests/apps/dashboard/async_search/index.ts index 6992469a31a7c..a534da5b2572b 100644 --- a/x-pack/test/search_sessions_integration/tests/apps/dashboard/async_search/index.ts +++ b/x-pack/test/search_sessions_integration/tests/apps/dashboard/async_search/index.ts @@ -17,8 +17,8 @@ export default function ({ loadTestFile, getService, getPageObjects }: FtrProvid this.tags('ciGroup3'); before(async () => { - await esArchiver.loadIfNeeded('logstash_functional'); - await esArchiver.load('dashboard/async_search'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/logstash_functional'); + await esArchiver.load('x-pack/test/functional/es_archives/dashboard/async_search'); await kibanaServer.uiSettings.replace({ defaultIndex: 'logstash-*' }); await kibanaServer.uiSettings.replace({ 'search:timeout': 10000 }); await PageObjects.common.navigateToApp('dashboard'); @@ -29,7 +29,7 @@ export default function ({ loadTestFile, getService, getPageObjects }: FtrProvid }); after(async () => { - await esArchiver.unload('dashboard/async_search'); + await esArchiver.unload('x-pack/test/functional/es_archives/dashboard/async_search'); }); loadTestFile(require.resolve('./async_search')); diff --git a/x-pack/test/search_sessions_integration/tests/apps/dashboard/async_search/sessions_in_space.ts b/x-pack/test/search_sessions_integration/tests/apps/dashboard/async_search/sessions_in_space.ts index 9a7a060e57c81..d05ac46d5b88f 100644 --- a/x-pack/test/search_sessions_integration/tests/apps/dashboard/async_search/sessions_in_space.ts +++ b/x-pack/test/search_sessions_integration/tests/apps/dashboard/async_search/sessions_in_space.ts @@ -26,7 +26,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('dashboard in space', () => { describe('Storing search sessions in space', () => { before(async () => { - await esArchiver.load('dashboard/session_in_space'); + await esArchiver.load('x-pack/test/functional/es_archives/dashboard/session_in_space'); await security.role.create('data_analyst', { elasticsearch: { @@ -59,7 +59,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await security.role.delete('data_analyst'); await security.user.delete('analyst'); - await esArchiver.unload('dashboard/session_in_space'); + await esArchiver.unload('x-pack/test/functional/es_archives/dashboard/session_in_space'); await PageObjects.security.forceLogout(); }); @@ -96,7 +96,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('Disabled storing search sessions', () => { before(async () => { - await esArchiver.load('dashboard/session_in_space'); + await esArchiver.load('x-pack/test/functional/es_archives/dashboard/session_in_space'); await security.role.create('data_analyst', { elasticsearch: { @@ -129,7 +129,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await security.role.delete('data_analyst'); await security.user.delete('analyst'); - await esArchiver.unload('dashboard/session_in_space'); + await esArchiver.unload('x-pack/test/functional/es_archives/dashboard/session_in_space'); await PageObjects.security.forceLogout(); }); diff --git a/x-pack/test/search_sessions_integration/tests/apps/discover/async_search.ts b/x-pack/test/search_sessions_integration/tests/apps/discover/async_search.ts index 5d74338996e78..93dca78b34a82 100644 --- a/x-pack/test/search_sessions_integration/tests/apps/discover/async_search.ts +++ b/x-pack/test/search_sessions_integration/tests/apps/discover/async_search.ts @@ -28,8 +28,8 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { describe('discover async search', () => { before(async () => { - await esArchiver.loadIfNeeded('logstash_functional'); - await esArchiver.load('discover/default'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/logstash_functional'); + await esArchiver.load('x-pack/test/functional/es_archives/discover/default'); await PageObjects.common.navigateToApp('discover'); await PageObjects.timePicker.setDefaultAbsoluteRange(); await PageObjects.header.waitUntilLoadingHasFinished(); diff --git a/x-pack/test/search_sessions_integration/tests/apps/discover/index.ts b/x-pack/test/search_sessions_integration/tests/apps/discover/index.ts index f2bbdf9c9287b..31fcb61cf2278 100644 --- a/x-pack/test/search_sessions_integration/tests/apps/discover/index.ts +++ b/x-pack/test/search_sessions_integration/tests/apps/discover/index.ts @@ -17,7 +17,7 @@ export default function ({ loadTestFile, getService, getPageObjects }: FtrProvid this.tags('ciGroup3'); before(async () => { - await esArchiver.loadIfNeeded('logstash_functional'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/logstash_functional'); await kibanaServer.uiSettings.replace({ defaultIndex: 'logstash-*' }); await PageObjects.common.navigateToApp('discover'); }); diff --git a/x-pack/test/search_sessions_integration/tests/apps/discover/sessions_in_space.ts b/x-pack/test/search_sessions_integration/tests/apps/discover/sessions_in_space.ts index 24543ea14fab4..728ad056f4e6b 100644 --- a/x-pack/test/search_sessions_integration/tests/apps/discover/sessions_in_space.ts +++ b/x-pack/test/search_sessions_integration/tests/apps/discover/sessions_in_space.ts @@ -26,7 +26,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('discover in space', () => { describe('Storing search sessions in space', () => { before(async () => { - await esArchiver.load('dashboard/session_in_space'); + await esArchiver.load('x-pack/test/functional/es_archives/dashboard/session_in_space'); await security.role.create('data_analyst', { elasticsearch: { @@ -59,7 +59,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await security.role.delete('data_analyst'); await security.user.delete('analyst'); - await esArchiver.unload('dashboard/session_in_space'); + await esArchiver.unload('x-pack/test/functional/es_archives/dashboard/session_in_space'); await PageObjects.security.forceLogout(); }); @@ -99,7 +99,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); describe('Disabled storing search sessions in space', () => { before(async () => { - await esArchiver.load('dashboard/session_in_space'); + await esArchiver.load('x-pack/test/functional/es_archives/dashboard/session_in_space'); await security.role.create('data_analyst', { elasticsearch: { @@ -132,7 +132,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await security.role.delete('data_analyst'); await security.user.delete('analyst'); - await esArchiver.unload('dashboard/session_in_space'); + await esArchiver.unload('x-pack/test/functional/es_archives/dashboard/session_in_space'); await PageObjects.security.forceLogout(); }); diff --git a/x-pack/test/search_sessions_integration/tests/apps/lens/index.ts b/x-pack/test/search_sessions_integration/tests/apps/lens/index.ts index 04ada51cac0d6..c559af88fd9d9 100644 --- a/x-pack/test/search_sessions_integration/tests/apps/lens/index.ts +++ b/x-pack/test/search_sessions_integration/tests/apps/lens/index.ts @@ -15,7 +15,7 @@ export default function ({ loadTestFile, getService }: FtrProviderContext) { this.tags('ciGroup3'); before(async () => { - await esArchiver.loadIfNeeded('logstash_functional'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/logstash_functional'); await kibanaServer.uiSettings.replace({ defaultIndex: 'logstash-*' }); }); diff --git a/x-pack/test/search_sessions_integration/tests/apps/lens/search_sessions.ts b/x-pack/test/search_sessions_integration/tests/apps/lens/search_sessions.ts index 7a3ae0ebb1c66..d95e117d1b033 100644 --- a/x-pack/test/search_sessions_integration/tests/apps/lens/search_sessions.ts +++ b/x-pack/test/search_sessions_integration/tests/apps/lens/search_sessions.ts @@ -16,11 +16,11 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { describe('lens search sessions', () => { before(async () => { - await esArchiver.loadIfNeeded('logstash_functional'); - await esArchiver.loadIfNeeded('lens/basic'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/logstash_functional'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/lens/basic'); }); after(async () => { - await esArchiver.unload('lens/basic'); + await esArchiver.unload('x-pack/test/functional/es_archives/lens/basic'); }); it("doesn't shows search sessions indicator UI", async () => { diff --git a/x-pack/test/search_sessions_integration/tests/apps/management/search_sessions/index.ts b/x-pack/test/search_sessions_integration/tests/apps/management/search_sessions/index.ts index 0798a25a2e982..d1e3d9408c0ca 100644 --- a/x-pack/test/search_sessions_integration/tests/apps/management/search_sessions/index.ts +++ b/x-pack/test/search_sessions_integration/tests/apps/management/search_sessions/index.ts @@ -15,8 +15,8 @@ export default function ({ loadTestFile, getService }: FtrProviderContext) { this.tags('ciGroup3'); before(async () => { - await esArchiver.loadIfNeeded('logstash_functional'); - await esArchiver.load('dashboard/async_search'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/logstash_functional'); + await esArchiver.load('x-pack/test/functional/es_archives/dashboard/async_search'); await kibanaServer.uiSettings.replace({ defaultIndex: 'logstash-*' }); await kibanaServer.uiSettings.replace({ 'search:timeout': 10000 }); }); diff --git a/x-pack/test/search_sessions_integration/tests/apps/management/search_sessions/sessions_management.ts b/x-pack/test/search_sessions_integration/tests/apps/management/search_sessions/sessions_management.ts index 27b4a887075fb..78e4a4be9a0e3 100644 --- a/x-pack/test/search_sessions_integration/tests/apps/management/search_sessions/sessions_management.ts +++ b/x-pack/test/search_sessions_integration/tests/apps/management/search_sessions/sessions_management.ts @@ -109,7 +109,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('autorefreshes and shows items on the server', async () => { - await esArchiver.load('data/search_sessions'); + await esArchiver.load('x-pack/test/functional/es_archives/data/search_sessions'); const searchSessionList = await PageObjects.searchSessionsManagement.getList(); expect(searchSessionList.length).to.be(10); @@ -190,11 +190,11 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { ] `); - await esArchiver.unload('data/search_sessions'); + await esArchiver.unload('x-pack/test/functional/es_archives/data/search_sessions'); }); it('has working pagination controls', async () => { - await esArchiver.load('data/search_sessions'); + await esArchiver.load('x-pack/test/functional/es_archives/data/search_sessions'); log.debug(`loading first page of sessions`); const sessionListFirst = await PageObjects.searchSessionsManagement.getList(); @@ -223,7 +223,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { ] `); - await esArchiver.unload('data/search_sessions'); + await esArchiver.unload('x-pack/test/functional/es_archives/data/search_sessions'); }); }); }); diff --git a/x-pack/test/security_functional/login_selector.config.ts b/x-pack/test/security_functional/login_selector.config.ts index e2ddf8dacb79c..e30775af7e784 100644 --- a/x-pack/test/security_functional/login_selector.config.ts +++ b/x-pack/test/security_functional/login_selector.config.ts @@ -97,7 +97,6 @@ export default async function ({ readConfigFile }: FtrConfigProviderContext) { }, }, apps: kibanaFunctionalConfig.get('apps'), - esArchiver: { directory: resolve(__dirname, 'es_archives') }, screenshots: { directory: resolve(__dirname, 'screenshots') }, junit: { diff --git a/x-pack/test/security_functional/oidc.config.ts b/x-pack/test/security_functional/oidc.config.ts index db8799ba1acf7..9c00960671e03 100644 --- a/x-pack/test/security_functional/oidc.config.ts +++ b/x-pack/test/security_functional/oidc.config.ts @@ -79,7 +79,6 @@ export default async function ({ readConfigFile }: FtrConfigProviderContext) { }, }, apps: kibanaFunctionalConfig.get('apps'), - esArchiver: { directory: resolve(__dirname, 'es_archives') }, screenshots: { directory: resolve(__dirname, 'screenshots') }, junit: { diff --git a/x-pack/test/security_functional/saml.config.ts b/x-pack/test/security_functional/saml.config.ts index a983e2747239c..264197c961123 100644 --- a/x-pack/test/security_functional/saml.config.ts +++ b/x-pack/test/security_functional/saml.config.ts @@ -76,7 +76,6 @@ export default async function ({ readConfigFile }: FtrConfigProviderContext) { }, }, apps: kibanaFunctionalConfig.get('apps'), - esArchiver: { directory: resolve(__dirname, 'es_archives') }, screenshots: { directory: resolve(__dirname, 'screenshots') }, junit: { diff --git a/x-pack/test/security_functional/tests/login_selector/auth_provider_hint.ts b/x-pack/test/security_functional/tests/login_selector/auth_provider_hint.ts index 780edd38f4121..b94b93d920da4 100644 --- a/x-pack/test/security_functional/tests/login_selector/auth_provider_hint.ts +++ b/x-pack/test/security_functional/tests/login_selector/auth_provider_hint.ts @@ -31,13 +31,13 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { full_name: 'Guest', }); - await esArchiver.load('../../functional/es_archives/empty_kibana'); + await esArchiver.load('x-pack/test/functional/es_archives/empty_kibana'); await PageObjects.security.forceLogout(); }); after(async () => { await security.user.delete('anonymous_user'); - await esArchiver.unload('../../functional/es_archives/empty_kibana'); + await esArchiver.unload('x-pack/test/functional/es_archives/empty_kibana'); }); beforeEach(async () => { diff --git a/x-pack/test/security_functional/tests/login_selector/basic_functionality.ts b/x-pack/test/security_functional/tests/login_selector/basic_functionality.ts index e1b4396696acd..b535522d2955f 100644 --- a/x-pack/test/security_functional/tests/login_selector/basic_functionality.ts +++ b/x-pack/test/security_functional/tests/login_selector/basic_functionality.ts @@ -34,13 +34,13 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { full_name: 'Admin', }); - await esArchiver.load('../../functional/es_archives/empty_kibana'); + await esArchiver.load('x-pack/test/functional/es_archives/empty_kibana'); await PageObjects.security.forceLogout(); }); after(async () => { await security.user.delete(testCredentials.username); - await esArchiver.unload('../../functional/es_archives/empty_kibana'); + await esArchiver.unload('x-pack/test/functional/es_archives/empty_kibana'); }); beforeEach(async () => { diff --git a/x-pack/test/security_functional/tests/oidc/url_capture.ts b/x-pack/test/security_functional/tests/oidc/url_capture.ts index b72aab33034c5..4c6b68cc3757c 100644 --- a/x-pack/test/security_functional/tests/oidc/url_capture.ts +++ b/x-pack/test/security_functional/tests/oidc/url_capture.ts @@ -26,11 +26,11 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { .send({ roles: ['superuser'], enabled: true, rules: { field: { 'realm.name': 'oidc1' } } }) .expect(200); - await esArchiver.load('../../functional/es_archives/empty_kibana'); + await esArchiver.load('x-pack/test/functional/es_archives/empty_kibana'); }); after(async () => { - await esArchiver.unload('../../functional/es_archives/empty_kibana'); + await esArchiver.unload('x-pack/test/functional/es_archives/empty_kibana'); }); afterEach(async () => { diff --git a/x-pack/test/security_functional/tests/saml/url_capture.ts b/x-pack/test/security_functional/tests/saml/url_capture.ts index 09eee12813601..65d7688472539 100644 --- a/x-pack/test/security_functional/tests/saml/url_capture.ts +++ b/x-pack/test/security_functional/tests/saml/url_capture.ts @@ -26,11 +26,11 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { .send({ roles: ['superuser'], enabled: true, rules: { field: { 'realm.name': 'saml1' } } }) .expect(200); - await esArchiver.load('../../functional/es_archives/empty_kibana'); + await esArchiver.load('x-pack/test/functional/es_archives/empty_kibana'); }); after(async () => { - await esArchiver.unload('../../functional/es_archives/empty_kibana'); + await esArchiver.unload('x-pack/test/functional/es_archives/empty_kibana'); }); afterEach(async () => { diff --git a/x-pack/test/security_solution_cypress/config.firefox.ts b/x-pack/test/security_solution_cypress/config.firefox.ts index 9c9f2c2314a31..2a2ce410850ff 100644 --- a/x-pack/test/security_solution_cypress/config.firefox.ts +++ b/x-pack/test/security_solution_cypress/config.firefox.ts @@ -5,8 +5,6 @@ * 2.0. */ -import { resolve } from 'path'; - import { FtrConfigProviderContext } from '@kbn/test'; import { CA_CERT_PATH } from '@kbn/dev-utils'; @@ -24,10 +22,6 @@ export default async function ({ readConfigFile }: FtrConfigProviderContext) { return { ...kibanaCommonTestsConfig.getAll(), - esArchiver: { - directory: resolve(__dirname, 'es_archives'), - }, - browser: { type: 'firefox', acceptInsecureCerts: true, diff --git a/x-pack/test/security_solution_cypress/config.ts b/x-pack/test/security_solution_cypress/config.ts index 95743369de0d7..18b4605fb9d8b 100644 --- a/x-pack/test/security_solution_cypress/config.ts +++ b/x-pack/test/security_solution_cypress/config.ts @@ -5,8 +5,6 @@ * 2.0. */ -import { resolve } from 'path'; - import { FtrConfigProviderContext } from '@kbn/test'; import { CA_CERT_PATH } from '@kbn/dev-utils'; @@ -22,10 +20,6 @@ export default async function ({ readConfigFile }: FtrConfigProviderContext) { return { ...kibanaCommonTestsConfig.getAll(), - esArchiver: { - directory: resolve(__dirname, 'es_archives'), - }, - esTestCluster: { ...xpackFunctionalTestsConfig.get('esTestCluster'), serverArgs: [ diff --git a/x-pack/test/security_solution_cypress/runner.ts b/x-pack/test/security_solution_cypress/runner.ts index 0144228fd8d9d..b219c491ddf77 100644 --- a/x-pack/test/security_solution_cypress/runner.ts +++ b/x-pack/test/security_solution_cypress/runner.ts @@ -17,7 +17,7 @@ export async function SecuritySolutionCypressCliTestRunner({ getService }: FtrPr const config = getService('config'); const esArchiver = getService('esArchiver'); - await esArchiver.load('auditbeat'); + await esArchiver.load('x-pack/test/security_solution_cypress/es_archives/auditbeat'); await withProcRunner(log, async (procs) => { await procs.run('cypress', { @@ -56,7 +56,7 @@ export async function SecuritySolutionCypressCliFirefoxTestRunner({ const config = getService('config'); const esArchiver = getService('esArchiver'); - await esArchiver.load('auditbeat'); + await esArchiver.load('x-pack/test/security_solution_cypress/es_archives/auditbeat'); await withProcRunner(log, async (procs) => { await procs.run('cypress', { @@ -93,8 +93,8 @@ export async function SecuritySolutionCypressVisualTestRunner({ getService }: Ft const config = getService('config'); const esArchiver = getService('esArchiver'); - await esArchiver.load('empty_kibana'); - await esArchiver.load('auditbeat'); + await esArchiver.load('x-pack/test/security_solution_cypress/es_archives/empty_kibana'); + await esArchiver.load('x-pack/test/security_solution_cypress/es_archives/auditbeat'); await withProcRunner(log, async (procs) => { await procs.run('cypress', { diff --git a/x-pack/test/security_solution_endpoint/apps/endpoint/endpoint_list.ts b/x-pack/test/security_solution_endpoint/apps/endpoint/endpoint_list.ts index 8b07d6c0530cd..e55307ed5ef66 100644 --- a/x-pack/test/security_solution_endpoint/apps/endpoint/endpoint_list.ts +++ b/x-pack/test/security_solution_endpoint/apps/endpoint/endpoint_list.ts @@ -84,7 +84,10 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { }); it('finds data after load and polling', async () => { - await esArchiver.load('endpoint/metadata/destination_index', { useCreate: true }); + await esArchiver.load( + 'x-pack/test/functional/es_archives/endpoint/metadata/destination_index', + { useCreate: true } + ); await pageObjects.endpoint.waitForTableToHaveData('endpointListTable', 1100); const tableData = await pageObjects.endpointPageUtils.tableData('endpointListTable'); expect(tableData).to.eql(expectedData); @@ -93,7 +96,10 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { describe('when there is data,', () => { before(async () => { - await esArchiver.load('endpoint/metadata/destination_index', { useCreate: true }); + await esArchiver.load( + 'x-pack/test/functional/es_archives/endpoint/metadata/destination_index', + { useCreate: true } + ); await pageObjects.endpoint.navigateToEndpointList(); }); after(async () => { @@ -210,7 +216,10 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { describe('displays the correct table data for the kql queries', () => { before(async () => { - await esArchiver.load('endpoint/metadata/destination_index', { useCreate: true }); + await esArchiver.load( + 'x-pack/test/functional/es_archives/endpoint/metadata/destination_index', + { useCreate: true } + ); await pageObjects.endpoint.navigateToEndpointList(); }); after(async () => { diff --git a/x-pack/test/security_solution_endpoint/apps/endpoint/endpoint_telemetry.ts b/x-pack/test/security_solution_endpoint/apps/endpoint/endpoint_telemetry.ts index 57f03a197b389..efc87330eb822 100644 --- a/x-pack/test/security_solution_endpoint/apps/endpoint/endpoint_telemetry.ts +++ b/x-pack/test/security_solution_endpoint/apps/endpoint/endpoint_telemetry.ts @@ -16,12 +16,12 @@ export default function ({ getService }: FtrProviderContext) { // There are currently tests in the security_solution application being maintained describe.skip('security solution endpoint telemetry', () => { after(async () => { - await esArchiver.load('empty_kibana'); + await esArchiver.load('x-pack/test/functional/es_archives/empty_kibana'); }); describe('when no agents are connected', () => { before(async () => { - await esArchiver.load('empty_kibana'); + await esArchiver.load('x-pack/test/functional/es_archives/empty_kibana'); }); it('reports no endpoints or policies', async () => { @@ -42,7 +42,7 @@ export default function ({ getService }: FtrProviderContext) { }); describe('when agents are connected with endpoint integration disabled', () => { before(async () => { - await esArchiver.load('endpoint/telemetry/agent_only'); + await esArchiver.load('x-pack/test/functional/es_archives/endpoint/telemetry/agent_only'); }); it('reports no endpoints or policies', async () => { @@ -68,7 +68,7 @@ export default function ({ getService }: FtrProviderContext) { 'checkin_now', 0 ); - await esArchiver.load('endpoint/telemetry/checkin_now'); + await esArchiver.load('x-pack/test/functional/es_archives/endpoint/telemetry/checkin_now'); await telemetryTestResources.deleteArchive('checkin_now'); }); @@ -97,7 +97,9 @@ export default function ({ getService }: FtrProviderContext) { 'checkin_2_days_ago', 2 ); - await esArchiver.load('endpoint/telemetry/checkin_2_days_ago'); + await esArchiver.load( + 'x-pack/test/functional/es_archives/endpoint/telemetry/checkin_2_days_ago' + ); await telemetryTestResources.deleteArchive('checkin_2_days_ago'); }); @@ -121,7 +123,9 @@ export default function ({ getService }: FtrProviderContext) { }); describe('when agents are connected with endpoints integration malware enabled', () => { before(async () => { - await esArchiver.load('endpoint/telemetry/endpoint_malware_enabled'); + await esArchiver.load( + 'x-pack/test/functional/es_archives/endpoint/telemetry/endpoint_malware_enabled' + ); }); it('reports the correct number of windows and macos endpoints under policies malware', async () => { @@ -132,7 +136,9 @@ export default function ({ getService }: FtrProviderContext) { }); describe('when agents are connected with endpoints integration malware disabled', () => { before(async () => { - await esArchiver.load('endpoint/telemetry/endpoint_malware_disabled'); + await esArchiver.load( + 'x-pack/test/functional/es_archives/endpoint/telemetry/endpoint_malware_disabled' + ); }); it('reports the correct number of windows and macos endpoints under policies malware', async () => { const endpointTelemetry = await telemetryTestResources.getEndpointTelemetry(); @@ -142,7 +148,9 @@ export default function ({ getService }: FtrProviderContext) { }); describe('when agents are connected with endpoints integration uninstalled', () => { before(async () => { - await esArchiver.load('endpoint/telemetry/endpoint_uninstalled'); + await esArchiver.load( + 'x-pack/test/functional/es_archives/endpoint/telemetry/endpoint_uninstalled' + ); }); it('reports no endpoints or policies', async () => { const endpointTelemetry = await telemetryTestResources.getEndpointTelemetry(); @@ -168,7 +176,9 @@ export default function ({ getService }: FtrProviderContext) { 'cloned_endpoint_test', 0 ); - await esArchiver.load('endpoint/telemetry/cloned_endpoint_test'); + await esArchiver.load( + 'x-pack/test/functional/es_archives/endpoint/telemetry/cloned_endpoint_test' + ); await telemetryTestResources.deleteArchive('cloned_endpoint_test'); }); it('reports all endpoints and policies', async () => { @@ -213,7 +223,9 @@ export default function ({ getService }: FtrProviderContext) { 'cloned_endpoint_test', 0 ); - await esArchiver.load('endpoint/telemetry/cloned_endpoint_test'); + await esArchiver.load( + 'x-pack/test/functional/es_archives/endpoint/telemetry/cloned_endpoint_test' + ); await telemetryTestResources.deleteArchive('cloned_endpoint_test'); }); it('reports all endpoints and policies', async () => { @@ -258,7 +270,9 @@ export default function ({ getService }: FtrProviderContext) { 'cloned_endpoint_test', 0 ); - await esArchiver.load('endpoint/telemetry/cloned_endpoint_test'); + await esArchiver.load( + 'x-pack/test/functional/es_archives/endpoint/telemetry/cloned_endpoint_test' + ); await telemetryTestResources.deleteArchive('cloned_endpoint_test'); }); it('reports all endpoints and policies', async () => { diff --git a/x-pack/test/security_solution_endpoint_api_int/apis/metadata.ts b/x-pack/test/security_solution_endpoint_api_int/apis/metadata.ts index a1be11c4f696d..b5d98c115d194 100644 --- a/x-pack/test/security_solution_endpoint_api_int/apis/metadata.ts +++ b/x-pack/test/security_solution_endpoint_api_int/apis/metadata.ts @@ -44,7 +44,9 @@ export default function ({ getService }: FtrProviderContext) { describe(`POST ${HOST_METADATA_LIST_ROUTE} when index is not empty`, () => { before(async () => { - await esArchiver.load('endpoint/metadata/api_feature', { useCreate: true }); + await esArchiver.load('x-pack/test/functional/es_archives/endpoint/metadata/api_feature', { + useCreate: true, + }); // wait for transform await new Promise((r) => setTimeout(r, 120000)); }); diff --git a/x-pack/test/security_solution_endpoint_api_int/apis/metadata_v1.ts b/x-pack/test/security_solution_endpoint_api_int/apis/metadata_v1.ts index 6879184b9bc13..d8cf1a11fac0a 100644 --- a/x-pack/test/security_solution_endpoint_api_int/apis/metadata_v1.ts +++ b/x-pack/test/security_solution_endpoint_api_int/apis/metadata_v1.ts @@ -40,7 +40,11 @@ export default function ({ getService }: FtrProviderContext) { describe(`POST ${METADATA_REQUEST_V1_ROUTE} when index is not empty`, () => { before( - async () => await esArchiver.load('endpoint/metadata/api_feature', { useCreate: true }) + async () => + await esArchiver.load( + 'x-pack/test/functional/es_archives/endpoint/metadata/api_feature', + { useCreate: true } + ) ); // the endpoint uses data streams and es archiver does not support deleting them at the moment so we need // to do it manually diff --git a/x-pack/test/security_solution_endpoint_api_int/apis/package.ts b/x-pack/test/security_solution_endpoint_api_int/apis/package.ts index d46b7723fcafe..a8fd5a612b306 100644 --- a/x-pack/test/security_solution_endpoint_api_int/apis/package.ts +++ b/x-pack/test/security_solution_endpoint_api_int/apis/package.ts @@ -96,7 +96,9 @@ export default function ({ getService }: FtrProviderContext) { describe('dns processor', () => { before(async () => { - await esArchiver.load('endpoint/pipeline/dns', { useCreate: true }); + await esArchiver.load('x-pack/test/functional/es_archives/endpoint/pipeline/dns', { + useCreate: true, + }); }); after(async () => { diff --git a/x-pack/test/security_solution_endpoint_api_int/apis/policy.ts b/x-pack/test/security_solution_endpoint_api_int/apis/policy.ts index 73687784d15ea..8b72a6c21bfe5 100644 --- a/x-pack/test/security_solution_endpoint_api_int/apis/policy.ts +++ b/x-pack/test/security_solution_endpoint_api_int/apis/policy.ts @@ -14,7 +14,12 @@ export default function ({ getService }: FtrProviderContext) { const supertest = getService('supertest'); describe('Endpoint policy api', () => { describe('GET /api/endpoint/policy_response', () => { - before(async () => await esArchiver.load('endpoint/policy', { useCreate: true })); + before( + async () => + await esArchiver.load('x-pack/test/functional/es_archives/endpoint/policy', { + useCreate: true, + }) + ); // the endpoint uses data streams and es archiver does not support deleting them at the moment so we need // to do it manually diff --git a/x-pack/test/security_solution_endpoint_api_int/apis/resolver/entity.ts b/x-pack/test/security_solution_endpoint_api_int/apis/resolver/entity.ts index 3cca9213b4554..6a9f4caa84676 100644 --- a/x-pack/test/security_solution_endpoint_api_int/apis/resolver/entity.ts +++ b/x-pack/test/security_solution_endpoint_api_int/apis/resolver/entity.ts @@ -17,11 +17,11 @@ export default function ({ getService }: FtrProviderContext) { describe('Resolver tests for the entity route', () => { describe('winlogbeat tests', () => { before(async () => { - await esArchiver.load('endpoint/resolver/winlogbeat'); + await esArchiver.load('x-pack/test/functional/es_archives/endpoint/resolver/winlogbeat'); }); after(async () => { - await esArchiver.unload('endpoint/resolver/winlogbeat'); + await esArchiver.unload('x-pack/test/functional/es_archives/endpoint/resolver/winlogbeat'); }); it('returns a winlogbeat sysmon event when the event matches the schema correctly', async () => { @@ -56,11 +56,11 @@ export default function ({ getService }: FtrProviderContext) { describe('signals index mapping tests', () => { before(async () => { - await esArchiver.load('endpoint/resolver/signals'); + await esArchiver.load('x-pack/test/functional/es_archives/endpoint/resolver/signals'); }); after(async () => { - await esArchiver.unload('endpoint/resolver/signals'); + await esArchiver.unload('x-pack/test/functional/es_archives/endpoint/resolver/signals'); }); it('returns an event even if it does not have a mapping for entity_id', async () => { diff --git a/x-pack/test/spaces_api_integration/common/config.ts b/x-pack/test/spaces_api_integration/common/config.ts index d1e4dae76b636..7cceb945790d5 100644 --- a/x-pack/test/spaces_api_integration/common/config.ts +++ b/x-pack/test/spaces_api_integration/common/config.ts @@ -44,10 +44,6 @@ export function createTestConfig(name: string, options: CreateTestConfigOptions) reportName: 'X-Pack Spaces API Integration Tests -- ' + name, }, - esArchiver: { - directory: path.join(__dirname, 'fixtures', 'es_archiver'), - }, - esTestCluster: { ...config.xpack.api.get('esTestCluster'), license, diff --git a/x-pack/test/spaces_api_integration/common/suites/copy_to_space.ts b/x-pack/test/spaces_api_integration/common/suites/copy_to_space.ts index e264e574a3cea..ead34f6be8850 100644 --- a/x-pack/test/spaces_api_integration/common/suites/copy_to_space.ts +++ b/x-pack/test/spaces_api_integration/common/suites/copy_to_space.ts @@ -613,8 +613,16 @@ export function copyToSpaceTestSuiteFactory( }); describe('single-namespace types', () => { - beforeEach(() => esArchiver.load('saved_objects/spaces')); - afterEach(() => esArchiver.unload('saved_objects/spaces')); + beforeEach(() => + esArchiver.load( + 'x-pack/test/spaces_api_integration/common/fixtures/es_archiver/saved_objects/spaces' + ) + ); + afterEach(() => + esArchiver.unload( + 'x-pack/test/spaces_api_integration/common/fixtures/es_archiver/saved_objects/spaces' + ) + ); const dashboardObject = { type: 'dashboard', id: 'cts_dashboard' }; @@ -755,8 +763,16 @@ export function copyToSpaceTestSuiteFactory( const spaces = ['space_2']; const includeReferences = false; describe(`multi-namespace types with overwrite=${overwrite} and createNewCopies=${createNewCopies}`, () => { - before(() => esArchiver.load('saved_objects/spaces')); - after(() => esArchiver.unload('saved_objects/spaces')); + before(() => + esArchiver.load( + 'x-pack/test/spaces_api_integration/common/fixtures/es_archiver/saved_objects/spaces' + ) + ); + after(() => + esArchiver.unload( + 'x-pack/test/spaces_api_integration/common/fixtures/es_archiver/saved_objects/spaces' + ) + ); const testCases = tests.multiNamespaceTestCases(overwrite, createNewCopies); testCases.forEach(({ testTitle, objects, statusCode, response }) => { diff --git a/x-pack/test/spaces_api_integration/common/suites/create.ts b/x-pack/test/spaces_api_integration/common/suites/create.ts index 6839caf86e210..acc4524b38c36 100644 --- a/x-pack/test/spaces_api_integration/common/suites/create.ts +++ b/x-pack/test/spaces_api_integration/common/suites/create.ts @@ -68,8 +68,16 @@ export function createTestSuiteFactory(esArchiver: any, supertest: SuperTest { describeFn(description, () => { - beforeEach(() => esArchiver.load('saved_objects/spaces')); - afterEach(() => esArchiver.unload('saved_objects/spaces')); + beforeEach(() => + esArchiver.load( + 'x-pack/test/spaces_api_integration/common/fixtures/es_archiver/saved_objects/spaces' + ) + ); + afterEach(() => + esArchiver.unload( + 'x-pack/test/spaces_api_integration/common/fixtures/es_archiver/saved_objects/spaces' + ) + ); getTestScenariosForSpace(spaceId).forEach(({ urlPrefix, scenario }) => { it(`should return ${tests.newSpace.statusCode} ${scenario}`, async () => { diff --git a/x-pack/test/spaces_api_integration/common/suites/delete.ts b/x-pack/test/spaces_api_integration/common/suites/delete.ts index b4624d36a8192..ccd08fb2d93e9 100644 --- a/x-pack/test/spaces_api_integration/common/suites/delete.ts +++ b/x-pack/test/spaces_api_integration/common/suites/delete.ts @@ -187,7 +187,9 @@ export function deleteTestSuiteFactory( ) => { describeFn(description, () => { beforeEach(async () => { - await esArchiver.load('saved_objects/spaces'); + await esArchiver.load( + 'x-pack/test/spaces_api_integration/common/fixtures/es_archiver/saved_objects/spaces' + ); // since we want to verify that we only delete the right things // and can't include a config document with the correct id in the @@ -199,7 +201,11 @@ export function deleteTestSuiteFactory( .auth(user.username, user.password) .expect(200); }); - afterEach(() => esArchiver.unload('saved_objects/spaces')); + afterEach(() => + esArchiver.unload( + 'x-pack/test/spaces_api_integration/common/fixtures/es_archiver/saved_objects/spaces' + ) + ); getTestScenariosForSpace(spaceId).forEach(({ urlPrefix, scenario }) => { it(`should return ${tests.exists.statusCode} ${scenario}`, async () => { diff --git a/x-pack/test/spaces_api_integration/common/suites/get.ts b/x-pack/test/spaces_api_integration/common/suites/get.ts index c471c98fa75e6..0fc4334daa184 100644 --- a/x-pack/test/spaces_api_integration/common/suites/get.ts +++ b/x-pack/test/spaces_api_integration/common/suites/get.ts @@ -79,8 +79,16 @@ export function getTestSuiteFactory(esArchiver: any, supertest: SuperAgent) { user = {}, currentSpaceId, spaceId, tests }: GetTestDefinition ) => { describeFn(description, () => { - before(() => esArchiver.load('saved_objects/spaces')); - after(() => esArchiver.unload('saved_objects/spaces')); + before(() => + esArchiver.load( + 'x-pack/test/spaces_api_integration/common/fixtures/es_archiver/saved_objects/spaces' + ) + ); + after(() => + esArchiver.unload( + 'x-pack/test/spaces_api_integration/common/fixtures/es_archiver/saved_objects/spaces' + ) + ); getTestScenariosForSpace(currentSpaceId).forEach(({ urlPrefix, scenario }) => { it(`should return ${tests.default.statusCode} ${scenario}`, async () => { diff --git a/x-pack/test/spaces_api_integration/common/suites/get_all.ts b/x-pack/test/spaces_api_integration/common/suites/get_all.ts index e32bd6e8cd91d..63284fac1151b 100644 --- a/x-pack/test/spaces_api_integration/common/suites/get_all.ts +++ b/x-pack/test/spaces_api_integration/common/suites/get_all.ts @@ -90,8 +90,16 @@ export function getAllTestSuiteFactory(esArchiver: any, supertest: SuperTest { describeFn(description, () => { - before(() => esArchiver.load('saved_objects/spaces')); - after(() => esArchiver.unload('saved_objects/spaces')); + before(() => + esArchiver.load( + 'x-pack/test/spaces_api_integration/common/fixtures/es_archiver/saved_objects/spaces' + ) + ); + after(() => + esArchiver.unload( + 'x-pack/test/spaces_api_integration/common/fixtures/es_archiver/saved_objects/spaces' + ) + ); getTestScenariosForSpace(spaceId).forEach(({ scenario, urlPrefix }) => { describe('undefined purpose', () => { diff --git a/x-pack/test/spaces_api_integration/common/suites/get_shareable_references.ts b/x-pack/test/spaces_api_integration/common/suites/get_shareable_references.ts index a10e28d52924e..05d92c8ef33eb 100644 --- a/x-pack/test/spaces_api_integration/common/suites/get_shareable_references.ts +++ b/x-pack/test/spaces_api_integration/common/suites/get_shareable_references.ts @@ -242,8 +242,16 @@ export function getShareableReferencesTestSuiteFactory(esArchiver: any, supertes const { user, spaceId = SPACES.DEFAULT.spaceId, tests } = definition; describeFn(description, () => { - before(() => esArchiver.load('saved_objects/spaces')); - after(() => esArchiver.unload('saved_objects/spaces')); + before(() => + esArchiver.load( + 'x-pack/test/spaces_api_integration/common/fixtures/es_archiver/saved_objects/spaces' + ) + ); + after(() => + esArchiver.unload( + 'x-pack/test/spaces_api_integration/common/fixtures/es_archiver/saved_objects/spaces' + ) + ); for (const test of tests) { it(`should return ${test.responseStatusCode} ${test.title}`, async () => { diff --git a/x-pack/test/spaces_api_integration/common/suites/resolve_copy_to_space_conflicts.ts b/x-pack/test/spaces_api_integration/common/suites/resolve_copy_to_space_conflicts.ts index 66ec1febd7372..84ec05d043740 100644 --- a/x-pack/test/spaces_api_integration/common/suites/resolve_copy_to_space_conflicts.ts +++ b/x-pack/test/spaces_api_integration/common/suites/resolve_copy_to_space_conflicts.ts @@ -428,8 +428,16 @@ export function resolveCopyToSpaceConflictsSuite( }); describe('single-namespace types', () => { - beforeEach(() => esArchiver.load('saved_objects/spaces')); - afterEach(() => esArchiver.unload('saved_objects/spaces')); + beforeEach(() => + esArchiver.load( + 'x-pack/test/spaces_api_integration/common/fixtures/es_archiver/saved_objects/spaces' + ) + ); + afterEach(() => + esArchiver.unload( + 'x-pack/test/spaces_api_integration/common/fixtures/es_archiver/saved_objects/spaces' + ) + ); const dashboardObject = { type: 'dashboard', id: 'cts_dashboard' }; const visualizationObject = { type: 'visualization', id: 'cts_vis_3' }; @@ -518,8 +526,16 @@ export function resolveCopyToSpaceConflictsSuite( const includeReferences = false; const createNewCopies = false; describe(`multi-namespace types with "overwrite" retry`, () => { - before(() => esArchiver.load('saved_objects/spaces')); - after(() => esArchiver.unload('saved_objects/spaces')); + before(() => + esArchiver.load( + 'x-pack/test/spaces_api_integration/common/fixtures/es_archiver/saved_objects/spaces' + ) + ); + after(() => + esArchiver.unload( + 'x-pack/test/spaces_api_integration/common/fixtures/es_archiver/saved_objects/spaces' + ) + ); const testCases = tests.multiNamespaceTestCases(); testCases.forEach(({ testTitle, objects, retries, statusCode, response }) => { diff --git a/x-pack/test/spaces_api_integration/common/suites/update.ts b/x-pack/test/spaces_api_integration/common/suites/update.ts index 71606cccb3fd5..b3dfeb9f548de 100644 --- a/x-pack/test/spaces_api_integration/common/suites/update.ts +++ b/x-pack/test/spaces_api_integration/common/suites/update.ts @@ -70,8 +70,16 @@ export function updateTestSuiteFactory(esArchiver: any, supertest: SuperTest { describeFn(description, () => { - before(() => esArchiver.load('saved_objects/spaces')); - after(() => esArchiver.unload('saved_objects/spaces')); + before(() => + esArchiver.load( + 'x-pack/test/spaces_api_integration/common/fixtures/es_archiver/saved_objects/spaces' + ) + ); + after(() => + esArchiver.unload( + 'x-pack/test/spaces_api_integration/common/fixtures/es_archiver/saved_objects/spaces' + ) + ); describe('space_1', () => { it(`should return ${tests.alreadyExists.statusCode}`, async () => { diff --git a/x-pack/test/spaces_api_integration/common/suites/update_objects_spaces.ts b/x-pack/test/spaces_api_integration/common/suites/update_objects_spaces.ts index 7664deb6b0bdf..27bf8db5e042f 100644 --- a/x-pack/test/spaces_api_integration/common/suites/update_objects_spaces.ts +++ b/x-pack/test/spaces_api_integration/common/suites/update_objects_spaces.ts @@ -114,8 +114,16 @@ export function updateObjectsSpacesTestSuiteFactory(esArchiver: any, supertest: const { user, spaceId = SPACES.DEFAULT.spaceId, tests } = definition; describeFn(description, () => { - before(() => esArchiver.load('saved_objects/spaces')); - after(() => esArchiver.unload('saved_objects/spaces')); + before(() => + esArchiver.load( + 'x-pack/test/spaces_api_integration/common/fixtures/es_archiver/saved_objects/spaces' + ) + ); + after(() => + esArchiver.unload( + 'x-pack/test/spaces_api_integration/common/fixtures/es_archiver/saved_objects/spaces' + ) + ); for (const test of tests) { it(`should return ${test.responseStatusCode} ${test.title}`, async () => { diff --git a/x-pack/test/stack_functional_integration/apps/alerts/alerts_encryption_keys.js b/x-pack/test/stack_functional_integration/apps/alerts/alerts_encryption_keys.js index 208d768f5b218..f11aa7e09635b 100644 --- a/x-pack/test/stack_functional_integration/apps/alerts/alerts_encryption_keys.js +++ b/x-pack/test/stack_functional_integration/apps/alerts/alerts_encryption_keys.js @@ -7,7 +7,7 @@ import expect from '@kbn/expect'; -const ARCHIVE = 'email_connectors_with_encryption_rotation'; +const ARCHIVE = '../integration-test/test/es_archives/email_connectors_with_encryption_rotation'; export default ({ getPageObjects, getService }) => { const esArchiver = getService('esArchiver'); diff --git a/x-pack/test/stack_functional_integration/apps/ccs/ccs_discover.js b/x-pack/test/stack_functional_integration/apps/ccs/ccs_discover.js index 0713716ea6a77..83a759abe337d 100644 --- a/x-pack/test/stack_functional_integration/apps/ccs/ccs_discover.js +++ b/x-pack/test/stack_functional_integration/apps/ccs/ccs_discover.js @@ -234,7 +234,6 @@ export default ({ getService, getPageObjects }) => { log, client: esClient, kbnClient, - dataDir: config.get('esArchiver.directory'), }); let signalsId; @@ -263,7 +262,7 @@ export default ({ getService, getPageObjects }) => { before('Prepare data:metricbeat-*', async function () { log.info('Create index'); - await esArchiver.load('metricbeat'); + await esArchiver.load('../integration-test/test/es_archives/metricbeat'); log.info('Create index pattern'); dataId = await supertest @@ -323,7 +322,7 @@ export default ({ getService, getPageObjects }) => { } log.info('Delete index'); - await esArchiver.unload('metricbeat'); + await esArchiver.unload('../integration-test/test/es_archives/metricbeat'); }); after('Clean up .siem-signal-*', async function () { diff --git a/x-pack/test/stack_functional_integration/configs/config.stack_functional_integration_base.js b/x-pack/test/stack_functional_integration/configs/config.stack_functional_integration_base.js index 745b8b7e5da0a..7a65d01ba287a 100644 --- a/x-pack/test/stack_functional_integration/configs/config.stack_functional_integration_base.js +++ b/x-pack/test/stack_functional_integration/configs/config.stack_functional_integration_base.js @@ -11,6 +11,7 @@ import { ToolingLog, REPO_ROOT } from '@kbn/dev-utils'; import chalk from 'chalk'; import { esTestConfig, kbnTestConfig } from '@kbn/test'; import { TriggersActionsPageProvider } from '../../functional_with_es_ssl/page_objects/triggers_actions_ui_page'; +import { services } from '../services'; const log = new ToolingLog({ level: 'info', @@ -30,6 +31,7 @@ export default async ({ readConfigFile }) => { const settings = { ...xpackFunctionalConfig.getAll(), + services, pageObjects: { triggersActionsUI: TriggersActionsPageProvider, ...xpackFunctionalConfig.get('pageObjects'), @@ -57,10 +59,6 @@ export default async ({ readConfigFile }) => { screenshots: { directory: resolve(INTEGRATION_TEST_ROOT, 'test/screenshots'), }, - // choose where esArchiver should load archives from - esArchiver: { - directory: resolve(INTEGRATION_TEST_ROOT, 'test/es_archives'), - }, }; return settings; }; diff --git a/x-pack/test/stack_functional_integration/services/es_archiver.js b/x-pack/test/stack_functional_integration/services/es_archiver.js new file mode 100644 index 0000000000000..6da55f77ec776 --- /dev/null +++ b/x-pack/test/stack_functional_integration/services/es_archiver.js @@ -0,0 +1,40 @@ +/* + * 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 Path from 'path'; + +import { EsArchiver } from '@kbn/es-archiver'; +import { REPO_ROOT } from '@kbn/dev-utils'; + +import * as KibanaServer from '../../../../test/common/services/kibana_server'; + +const INTEGRATION_TEST_ROOT = + process.env.WORKSPACE || Path.resolve(REPO_ROOT, '../integration-test'); + +export function EsArchiverProvider({ getService }) { + const config = getService('config'); + const client = getService('es'); + const log = getService('log'); + const kibanaServer = getService('kibanaServer'); + const retry = getService('retry'); + + const esArchiver = new EsArchiver({ + baseDir: INTEGRATION_TEST_ROOT, + client, + log, + kbnClient: kibanaServer, + }); + + KibanaServer.extendEsArchiver({ + esArchiver, + kibanaServer, + retry, + defaults: config.get('uiSettings.defaults'), + }); + + return esArchiver; +} diff --git a/x-pack/test/stack_functional_integration/services/index.js b/x-pack/test/stack_functional_integration/services/index.js new file mode 100644 index 0000000000000..e311dd8b38f7e --- /dev/null +++ b/x-pack/test/stack_functional_integration/services/index.js @@ -0,0 +1,14 @@ +/* + * 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 { services as xpackFunctionalServices } from '../../functional/services'; +import { EsArchiverProvider } from './es_archiver'; + +export const services = { + ...xpackFunctionalServices, + esArchiver: EsArchiverProvider, +}; diff --git a/x-pack/test/ui_capabilities/common/config.ts b/x-pack/test/ui_capabilities/common/config.ts index 9c0ce92755e8e..1f695e562da05 100644 --- a/x-pack/test/ui_capabilities/common/config.ts +++ b/x-pack/test/ui_capabilities/common/config.ts @@ -30,7 +30,6 @@ export function createTestConfig(name: string, options: CreateTestConfigOptions) junit: { reportName: 'X-Pack UI Capabilities Functional Tests', }, - esArchiver: {}, esTestCluster: { ...xPackFunctionalTestsConfig.get('esTestCluster'), license, diff --git a/x-pack/test/upgrade_assistant_integration/config.js b/x-pack/test/upgrade_assistant_integration/config.js index e8424db699d12..1505697d771ca 100644 --- a/x-pack/test/upgrade_assistant_integration/config.js +++ b/x-pack/test/upgrade_assistant_integration/config.js @@ -26,7 +26,6 @@ export default async function ({ readConfigFile }) { ...kibanaCommonConfig.get('services'), supertest: kibanaAPITestsConfig.get('services.supertest'), }, - esArchiver: xPackFunctionalTestsConfig.get('esArchiver'), junit: { reportName: 'X-Pack Upgrade Assistant Integration Tests', }, diff --git a/x-pack/test/upgrade_assistant_integration/upgrade_assistant/reindexing.js b/x-pack/test/upgrade_assistant_integration/upgrade_assistant/reindexing.js index 052c72a46cc7b..2fe7254def272 100644 --- a/x-pack/test/upgrade_assistant_integration/upgrade_assistant/reindexing.js +++ b/x-pack/test/upgrade_assistant_integration/upgrade_assistant/reindexing.js @@ -52,7 +52,7 @@ export default function ({ getService }) { }); it('should create a new index with the same documents', async () => { - await esArchiver.load('upgrade_assistant/reindex'); + await esArchiver.load('x-pack/test/functional/es_archives/upgrade_assistant/reindex'); const { body } = await supertest .post(`/api/upgrade_assistant/reindex/dummydata`) .set('kbn-xsrf', 'xxx') @@ -84,7 +84,7 @@ export default function ({ getService }) { }); it('should update any aliases', async () => { - await esArchiver.load('upgrade_assistant/reindex'); + await esArchiver.load('x-pack/test/functional/es_archives/upgrade_assistant/reindex'); // Add aliases and ensure each returns the right number of docs await es.indices.updateAliases({ diff --git a/x-pack/test/visual_regression/tests/canvas/index.js b/x-pack/test/visual_regression/tests/canvas/index.js index 41f382bff284a..099c96e6eaf01 100644 --- a/x-pack/test/visual_regression/tests/canvas/index.js +++ b/x-pack/test/visual_regression/tests/canvas/index.js @@ -15,14 +15,14 @@ export default function ({ loadTestFile, getService }) { describe('canvas app visual regression', function () { before(async () => { - await esArchiver.loadIfNeeded('logstash_functional'); - await esArchiver.load('canvas/default'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/logstash_functional'); + await esArchiver.load('x-pack/test/functional/es_archives/canvas/default'); await browser.setWindowSize(SCREEN_WIDTH, 1000); }); after(async () => { - await esArchiver.unload('canvas/default'); + await esArchiver.unload('x-pack/test/functional/es_archives/canvas/default'); }); this.tags('ciGroup10'); diff --git a/x-pack/test/visual_regression/tests/infra/saved_views.js b/x-pack/test/visual_regression/tests/infra/saved_views.js index e251cf255c59e..a9e020b797df1 100644 --- a/x-pack/test/visual_regression/tests/infra/saved_views.js +++ b/x-pack/test/visual_regression/tests/infra/saved_views.js @@ -14,8 +14,8 @@ export default function ({ getPageObjects, getService }) { const esArchiver = getService('esArchiver'); describe('saved views', () => { - before(() => esArchiver.load('infra/metrics_and_logs')); - after(() => esArchiver.unload('infra/metrics_and_logs')); + before(() => esArchiver.load('x-pack/test/functional/es_archives/infra/metrics_and_logs')); + after(() => esArchiver.unload('x-pack/test/functional/es_archives/infra/metrics_and_logs')); describe('Inverntory Test save functionality', () => { it('should have save and load controls', async () => { await PageObjects.common.navigateToApp('infraOps'); diff --git a/x-pack/test/visual_regression/tests/infra/waffle_map.js b/x-pack/test/visual_regression/tests/infra/waffle_map.js index b691272ecf13d..70aaf89a059eb 100644 --- a/x-pack/test/visual_regression/tests/infra/waffle_map.js +++ b/x-pack/test/visual_regression/tests/infra/waffle_map.js @@ -14,8 +14,8 @@ export default function ({ getPageObjects, getService }) { const esArchiver = getService('esArchiver'); describe('waffle map', () => { - before(() => esArchiver.load('infra/metrics_and_logs')); - after(() => esArchiver.unload('infra/metrics_and_logs')); + before(() => esArchiver.load('x-pack/test/functional/es_archives/infra/metrics_and_logs')); + after(() => esArchiver.unload('x-pack/test/functional/es_archives/infra/metrics_and_logs')); it('should just work', async () => { await PageObjects.common.navigateToApp('infraOps'); diff --git a/x-pack/test/visual_regression/tests/login_page.ts b/x-pack/test/visual_regression/tests/login_page.ts index 3ee160cb3139f..65effd45d65df 100644 --- a/x-pack/test/visual_regression/tests/login_page.ts +++ b/x-pack/test/visual_regression/tests/login_page.ts @@ -17,12 +17,12 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe.skip('Security', () => { describe('Login Page', () => { before(async () => { - await esArchiver.load('empty_kibana'); + await esArchiver.load('x-pack/test/functional/es_archives/empty_kibana'); await PageObjects.security.forceLogout(); }); after(async () => { - await esArchiver.unload('empty_kibana'); + await esArchiver.unload('x-pack/test/functional/es_archives/empty_kibana'); }); afterEach(async () => { diff --git a/x-pack/test/visual_regression/tests/maps/index.js b/x-pack/test/visual_regression/tests/maps/index.js index b96fc71250427..f4bf0e046f17a 100644 --- a/x-pack/test/visual_regression/tests/maps/index.js +++ b/x-pack/test/visual_regression/tests/maps/index.js @@ -12,9 +12,9 @@ export default function ({ loadTestFile, getService }) { describe('maps app visual regression', function () { before(async () => { - await esArchiver.loadIfNeeded('logstash_functional'); - await esArchiver.load('maps/data'); - await esArchiver.load('maps/kibana'); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/logstash_functional'); + await esArchiver.load('x-pack/test/functional/es_archives/maps/data'); + await esArchiver.load('x-pack/test/functional/es_archives/maps/kibana'); await kibanaServer.uiSettings.replace({ defaultIndex: 'logstash-*', }); @@ -22,8 +22,8 @@ export default function ({ loadTestFile, getService }) { }); after(async () => { - await esArchiver.unload('maps/data'); - await esArchiver.unload('maps/kibana'); + await esArchiver.unload('x-pack/test/functional/es_archives/maps/data'); + await esArchiver.unload('x-pack/test/functional/es_archives/maps/kibana'); }); this.tags('ciGroup10'); From ff0349d048405045e5d037204c05163d88d197fd Mon Sep 17 00:00:00 2001 From: Oliver Gupte Date: Tue, 8 Jun 2021 18:52:49 -0400 Subject: [PATCH 07/19] [APM] Syncs agent config settings to APM Fleet policies (#100744) * [APM] Syncs agent config settings to APM Fleet policies (#95501) * fixes eslint issues * fixes malformed line comment * - consolidated logic that applies agent configurations to package policy objects - update package policy agent_configs to include etag, agent.name, and change settings -> config * Synchronizes agent configs whenever configuration is deleted. * PR feedback * nest agent_config within `apm-server` in the package policy input * nests agent_config under the requried 'value' property of config['apm-server'] in order to pass validation checks * - externalizes getApmPackagePolicies for reusability - parallelizes operations for improved performance Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> --- x-pack/plugins/apm/kibana.json | 3 +- .../lib/fleet/get_apm_package_policies.ts | 30 ++++ .../fleet/register_fleet_policy_callbacks.ts | 134 ++++++++++++++++++ ...c_agent_configs_to_apm_package_policies.ts | 59 ++++++++ x-pack/plugins/apm/server/plugin.ts | 34 +++-- .../routes/settings/agent_configuration.ts | 31 +++- x-pack/plugins/apm/server/types.ts | 9 ++ x-pack/plugins/apm/tsconfig.json | 3 +- 8 files changed, 286 insertions(+), 17 deletions(-) create mode 100644 x-pack/plugins/apm/server/lib/fleet/get_apm_package_policies.ts create mode 100644 x-pack/plugins/apm/server/lib/fleet/register_fleet_policy_callbacks.ts create mode 100644 x-pack/plugins/apm/server/lib/fleet/sync_agent_configs_to_apm_package_policies.ts diff --git a/x-pack/plugins/apm/kibana.json b/x-pack/plugins/apm/kibana.json index 76d544c3bc6f5..e33c410668c25 100644 --- a/x-pack/plugins/apm/kibana.json +++ b/x-pack/plugins/apm/kibana.json @@ -23,7 +23,8 @@ "security", "ml", "home", - "maps" + "maps", + "fleet" ], "server": true, "ui": true, diff --git a/x-pack/plugins/apm/server/lib/fleet/get_apm_package_policies.ts b/x-pack/plugins/apm/server/lib/fleet/get_apm_package_policies.ts new file mode 100644 index 0000000000000..363ed77d56c4d --- /dev/null +++ b/x-pack/plugins/apm/server/lib/fleet/get_apm_package_policies.ts @@ -0,0 +1,30 @@ +/* + * 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 { + CoreSetup, + CoreStart, + SavedObjectsClientContract, +} from 'kibana/server'; +import { APMPluginStartDependencies } from '../../types'; +import { getInternalSavedObjectsClient } from '../helpers/get_internal_saved_objects_client'; + +export async function getApmPackgePolicies({ + core, + fleetPluginStart, +}: { + core: { setup: CoreSetup; start: () => Promise }; + fleetPluginStart: NonNullable; +}) { + // @ts-ignore + const savedObjectsClient: SavedObjectsClientContract = await getInternalSavedObjectsClient( + core.setup + ); + return await fleetPluginStart.packagePolicyService.list(savedObjectsClient, { + kuery: 'ingest-package-policies.package.name:apm', + }); +} diff --git a/x-pack/plugins/apm/server/lib/fleet/register_fleet_policy_callbacks.ts b/x-pack/plugins/apm/server/lib/fleet/register_fleet_policy_callbacks.ts new file mode 100644 index 0000000000000..e4306b4c2ec98 --- /dev/null +++ b/x-pack/plugins/apm/server/lib/fleet/register_fleet_policy_callbacks.ts @@ -0,0 +1,134 @@ +/* + * 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 { APMPlugin, APMRouteHandlerResources } from '../..'; +import { listConfigurations } from '../settings/agent_configuration/list_configurations'; +import { setupRequest } from '../helpers/setup_request'; +import { APMPluginStartDependencies } from '../../types'; +import { ExternalCallback } from '../../../../fleet/server'; +import { AGENT_NAME } from '../../../common/elasticsearch_fieldnames'; +import { AgentConfiguration } from '../../../common/agent_configuration/configuration_types'; + +export async function registerFleetPolicyCallbacks({ + plugins, + ruleDataClient, + config, + logger, +}: { + plugins: APMRouteHandlerResources['plugins']; + ruleDataClient: APMRouteHandlerResources['ruleDataClient']; + config: NonNullable; + logger: NonNullable; +}) { + if (!plugins.fleet) { + return; + } + const fleetPluginStart = await plugins.fleet.start(); + + // Registers a callback invoked when a policy is created to populate the APM + // integration policy with pre-existing agent configurations + registerAgentConfigExternalCallback({ + fleetPluginStart, + callbackName: 'packagePolicyCreate', + plugins, + ruleDataClient, + config, + logger, + }); + + // Registers a callback invoked when a policy is updated to populate the APM + // integration policy with existing agent configurations + registerAgentConfigExternalCallback({ + fleetPluginStart, + callbackName: 'packagePolicyUpdate', + plugins, + ruleDataClient, + config, + logger, + }); +} + +type ExternalCallbackParams = Parameters; +type PackagePolicy = ExternalCallbackParams[0]; +type Context = ExternalCallbackParams[1]; +type Request = ExternalCallbackParams[2]; + +function registerAgentConfigExternalCallback({ + fleetPluginStart, + callbackName, + plugins, + ruleDataClient, + config, + logger, +}: { + fleetPluginStart: NonNullable; + callbackName: ExternalCallback[0]; + plugins: APMRouteHandlerResources['plugins']; + ruleDataClient: APMRouteHandlerResources['ruleDataClient']; + config: NonNullable; + logger: NonNullable; +}) { + const callbackFn: ExternalCallback[1] = async ( + packagePolicy: PackagePolicy, + context: Context, + request: Request + ) => { + if (packagePolicy.package?.name !== 'apm') { + return packagePolicy; + } + const setup = await setupRequest({ + context: context as any, + params: { query: { _inspect: false } }, + core: null as any, + plugins, + request, + config, + logger, + ruleDataClient, + }); + const agentConfigurations = await listConfigurations({ setup }); + return getPackagePolicyWithAgentConfigurations( + packagePolicy, + agentConfigurations + ); + }; + + fleetPluginStart.registerExternalCallback(callbackName, callbackFn); +} + +const APM_SERVER = 'apm-server'; + +// Immutable function applies the given package policy with a set of agent configurations +export function getPackagePolicyWithAgentConfigurations( + packagePolicy: PackagePolicy, + agentConfigurations: AgentConfiguration[] +) { + const [firstInput, ...restInputs] = packagePolicy.inputs; + const apmServerValue = firstInput?.config?.[APM_SERVER].value; + return { + ...packagePolicy, + inputs: [ + { + ...firstInput, + config: { + [APM_SERVER]: { + value: { + ...apmServerValue, + agent_config: agentConfigurations.map((configuration) => ({ + service: configuration.service, + config: configuration.settings, + etag: configuration.etag, + [AGENT_NAME]: configuration.agent_name, + })), + }, + }, + }, + }, + ...restInputs, + ], + }; +} diff --git a/x-pack/plugins/apm/server/lib/fleet/sync_agent_configs_to_apm_package_policies.ts b/x-pack/plugins/apm/server/lib/fleet/sync_agent_configs_to_apm_package_policies.ts new file mode 100644 index 0000000000000..4294c5b82cd63 --- /dev/null +++ b/x-pack/plugins/apm/server/lib/fleet/sync_agent_configs_to_apm_package_policies.ts @@ -0,0 +1,59 @@ +/* + * 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 { + CoreSetup, + CoreStart, + SavedObjectsClientContract, +} from 'kibana/server'; +import { APMPluginStartDependencies } from '../../types'; +import { getInternalSavedObjectsClient } from '../helpers/get_internal_saved_objects_client'; +import { Setup } from '../helpers/setup_request'; +import { listConfigurations } from '../settings/agent_configuration/list_configurations'; +import { getApmPackgePolicies } from './get_apm_package_policies'; +import { getPackagePolicyWithAgentConfigurations } from './register_fleet_policy_callbacks'; + +export async function syncAgentConfigsToApmPackagePolicies({ + core, + fleetPluginStart, + setup, +}: { + core: { setup: CoreSetup; start: () => Promise }; + fleetPluginStart: NonNullable; + setup: Setup; +}) { + const coreStart = await core.start(); + const esClient = coreStart.elasticsearch.client.asInternalUser; + const [ + savedObjectsClient, + agentConfigurations, + packagePolicies, + ] = await Promise.all([ + getInternalSavedObjectsClient(core.setup), + listConfigurations({ setup }), + getApmPackgePolicies({ + core, + fleetPluginStart, + }), + ]); + + return Promise.all( + packagePolicies.items.map(async (item) => { + const { id, revision, updated_at, updated_by, ...packagePolicy } = item; // eslint-disable-line @typescript-eslint/naming-convention + const updatedPackagePolicy = getPackagePolicyWithAgentConfigurations( + packagePolicy, + agentConfigurations + ); + return fleetPluginStart.packagePolicyService.update( + (savedObjectsClient as unknown) as SavedObjectsClientContract, + esClient, + id, + updatedPackagePolicy + ); + }) + ); +} diff --git a/x-pack/plugins/apm/server/plugin.ts b/x-pack/plugins/apm/server/plugin.ts index 824eba9bce0b0..c9391eba29f8d 100644 --- a/x-pack/plugins/apm/server/plugin.ts +++ b/x-pack/plugins/apm/server/plugin.ts @@ -24,6 +24,7 @@ import { mergeConfigs } from './index'; import { UI_SETTINGS } from '../../../../src/plugins/data/common'; import { APM_FEATURE, registerFeaturesUsage } from './feature'; import { registerApmAlerts } from './lib/alerts/register_apm_alerts'; +import { registerFleetPolicyCallbacks } from './lib/fleet/register_fleet_policy_callbacks'; import { createApmTelemetry } from './lib/apm_telemetry'; import { createApmEventClient } from './lib/helpers/create_es_client/create_apm_event_client'; import { getInternalSavedObjectsClient } from './lib/helpers/get_internal_saved_objects_client'; @@ -186,6 +187,19 @@ export class APMPlugin ready, }); + const resourcePlugins = mapValues(plugins, (value, key) => { + return { + setup: value, + start: () => + core.getStartServices().then((services) => { + const [, pluginsStartContracts] = services; + return pluginsStartContracts[ + key as keyof APMPluginStartDependencies + ]; + }), + }; + }) as APMRouteHandlerResources['plugins']; + registerRoutes({ core: { setup: core, @@ -195,18 +209,7 @@ export class APMPlugin config: currentConfig, repository: getGlobalApmServerRouteRepository(), ruleDataClient, - plugins: mapValues(plugins, (value, key) => { - return { - setup: value, - start: () => - core.getStartServices().then((services) => { - const [, pluginsStartContracts] = services; - return pluginsStartContracts[ - key as keyof APMPluginStartDependencies - ]; - }), - }; - }) as APMRouteHandlerResources['plugins'], + plugins: resourcePlugins, }); const boundGetApmIndices = async () => @@ -225,6 +228,13 @@ export class APMPlugin }); } + registerFleetPolicyCallbacks({ + plugins: resourcePlugins, + ruleDataClient, + config: this.currentConfig, + logger: this.logger, + }); + return { config$: mergedConfig$, getApmIndices: boundGetApmIndices, diff --git a/x-pack/plugins/apm/server/routes/settings/agent_configuration.ts b/x-pack/plugins/apm/server/routes/settings/agent_configuration.ts index ef1ade645cc44..b2461e381bd00 100644 --- a/x-pack/plugins/apm/server/routes/settings/agent_configuration.ts +++ b/x-pack/plugins/apm/server/routes/settings/agent_configuration.ts @@ -25,6 +25,7 @@ import { } from '../../../common/agent_configuration/runtime_types/agent_configuration_intake_rt'; import { getSearchAggregatedTransactions } from '../../lib/helpers/aggregated_transactions'; import { createApmServerRouteRepository } from '../create_apm_server_route_repository'; +import { syncAgentConfigsToApmPackagePolicies } from '../../lib/fleet/sync_agent_configs_to_apm_package_policies'; // get list of configurations const agentConfigurationRoute = createApmServerRoute({ @@ -78,7 +79,7 @@ const deleteAgentConfigurationRoute = createApmServerRoute({ }), handler: async (resources) => { const setup = await setupRequest(resources); - const { params, logger } = resources; + const { params, logger, core } = resources; const { service } = params.body; @@ -95,10 +96,23 @@ const deleteAgentConfigurationRoute = createApmServerRoute({ `Deleting config ${service.name}/${service.environment} (${config._id})` ); - return await deleteConfiguration({ + const deleteConfigurationResult = await deleteConfiguration({ configurationId: config._id, setup, }); + + if (resources.plugins.fleet) { + await syncAgentConfigsToApmPackagePolicies({ + core, + fleetPluginStart: await resources.plugins.fleet.start(), + setup, + }); + logger.info( + `Updated Fleet integration policy for APM to remove the deleted agent configuration.` + ); + } + + return deleteConfigurationResult; }, }); @@ -114,7 +128,7 @@ const createOrUpdateAgentConfigurationRoute = createApmServerRoute({ ]), handler: async (resources) => { const setup = await setupRequest(resources); - const { params, logger } = resources; + const { params, logger, core } = resources; const { body, query } = params; // if the config already exists, it is fetched and updated @@ -142,6 +156,17 @@ const createOrUpdateAgentConfigurationRoute = createApmServerRoute({ configurationIntake: body, setup, }); + + if (resources.plugins.fleet) { + await syncAgentConfigsToApmPackagePolicies({ + core, + fleetPluginStart: await resources.plugins.fleet.start(), + setup, + }); + logger.info( + `Saved latest agent settings to Fleet integration policy for APM.` + ); + } }, }); diff --git a/x-pack/plugins/apm/server/types.ts b/x-pack/plugins/apm/server/types.ts index a5ba4f39b32b3..325891d8c1d33 100644 --- a/x-pack/plugins/apm/server/types.ts +++ b/x-pack/plugins/apm/server/types.ts @@ -43,6 +43,10 @@ import { TaskManagerSetupContract, TaskManagerStartContract, } from '../../task_manager/server'; +import { + FleetSetupContract as FleetPluginSetup, + FleetStartContract as FleetPluginStart, +} from '../../fleet/server'; import { APMConfig } from '.'; import { getApmIndices } from './lib/settings/apm_indices/get_apm_indices'; import { createApmEventClient } from './lib/helpers/create_es_client/create_apm_event_client'; @@ -123,6 +127,10 @@ interface DependencyMap { setup: RuleRegistryPluginSetupContract; start: RuleRegistryPluginStartContract; }; + fleet: { + setup: FleetPluginSetup; + start: FleetPluginStart; + }; } const requiredDependencies = [ @@ -148,6 +156,7 @@ const optionalDependencies = [ 'ml', 'home', 'maps', + 'fleet', ] as const; type RequiredDependencies = Pick< diff --git a/x-pack/plugins/apm/tsconfig.json b/x-pack/plugins/apm/tsconfig.json index bb341059e2d43..192b7f4fe8c2e 100644 --- a/x-pack/plugins/apm/tsconfig.json +++ b/x-pack/plugins/apm/tsconfig.json @@ -41,6 +41,7 @@ { "path": "../rule_registry/tsconfig.json" }, { "path": "../security/tsconfig.json" }, { "path": "../task_manager/tsconfig.json" }, - { "path": "../triggers_actions_ui/tsconfig.json" } + { "path": "../triggers_actions_ui/tsconfig.json" }, + { "path": "../fleet/tsconfig.json" } ] } From 8c2c83cb7dccb74070eba7aa458cfaf2b830b271 Mon Sep 17 00:00:00 2001 From: Nicolas Chaulet Date: Tue, 8 Jun 2021 18:55:48 -0400 Subject: [PATCH 08/19] [Fleet] Add fleet server telemetry (#101400) --- .../server/collectors/agent_collectors.ts | 7 +- .../collectors/fleet_server_collector.ts | 87 ++++++++++++ .../fleet/server/collectors/register.ts | 55 ++++++++ .../schema/xpack_plugins.json | 52 +++++++ .../apis/fleet_telemetry.ts | 127 ++++++++++++++++++ .../test/fleet_api_integration/apis/index.js | 3 + 6 files changed, 329 insertions(+), 2 deletions(-) create mode 100644 x-pack/plugins/fleet/server/collectors/fleet_server_collector.ts create mode 100644 x-pack/test/fleet_api_integration/apis/fleet_telemetry.ts diff --git a/x-pack/plugins/fleet/server/collectors/agent_collectors.ts b/x-pack/plugins/fleet/server/collectors/agent_collectors.ts index 0eb392e784334..6a9a4cd9ba83c 100644 --- a/x-pack/plugins/fleet/server/collectors/agent_collectors.ts +++ b/x-pack/plugins/fleet/server/collectors/agent_collectors.ts @@ -5,8 +5,7 @@ * 2.0. */ -import type { SavedObjectsClient } from 'kibana/server'; -import type { ElasticsearchClient } from 'kibana/server'; +import type { SavedObjectsClient, ElasticsearchClient } from 'kibana/server'; import type { FleetConfigType } from '../../common/types'; import * as AgentService from '../services/agents'; @@ -18,6 +17,7 @@ export interface AgentUsage { unhealthy: number; offline: number; total_all_statuses: number; + updating: number; } export const getAgentUsage = async ( @@ -33,6 +33,7 @@ export const getAgentUsage = async ( unhealthy: 0, offline: 0, total_all_statuses: 0, + updating: 0, }; } @@ -42,6 +43,7 @@ export const getAgentUsage = async ( online, error, offline, + updating, } = await AgentService.getAgentStatusForAgentPolicy(soClient, esClient); return { total_enrolled: total, @@ -49,5 +51,6 @@ export const getAgentUsage = async ( unhealthy: error, offline, total_all_statuses: total + inactive, + updating, }; }; diff --git a/x-pack/plugins/fleet/server/collectors/fleet_server_collector.ts b/x-pack/plugins/fleet/server/collectors/fleet_server_collector.ts new file mode 100644 index 0000000000000..d861b211b8848 --- /dev/null +++ b/x-pack/plugins/fleet/server/collectors/fleet_server_collector.ts @@ -0,0 +1,87 @@ +/* + * 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 type { SavedObjectsClient, ElasticsearchClient } from 'kibana/server'; + +import { packagePolicyService, settingsService } from '../services'; +import { getAgentStatusForAgentPolicy } from '../services/agents'; +import { isFleetServerSetup } from '../services/fleet_server'; + +const DEFAULT_USAGE = { + total_all_statuses: 0, + total_enrolled: 0, + healthy: 0, + unhealthy: 0, + offline: 0, + updating: 0, + num_host_urls: 0, +}; + +export interface FleetServerUsage { + total_enrolled: number; + healthy: number; + unhealthy: number; + offline: number; + updating: number; + total_all_statuses: number; + num_host_urls: number; +} + +export const getFleetServerUsage = async ( + soClient?: SavedObjectsClient, + esClient?: ElasticsearchClient +): Promise => { + if (!soClient || !esClient || !(await isFleetServerSetup())) { + return DEFAULT_USAGE; + } + + const numHostsUrls = + (await settingsService.getSettings(soClient)).fleet_server_hosts?.length ?? 0; + + // Find all policies with Fleet server than query agent status + + let hasMore = true; + const policyIds = new Set(); + let page = 1; + while (hasMore) { + const res = await packagePolicyService.list(soClient, { + page: page++, + perPage: 20, + kuery: 'ingest-package-policies.package.name:fleet_server', + }); + + for (const item of res.items) { + policyIds.add(item.policy_id); + } + + if (res.items.length === 0) { + hasMore = false; + } + } + + if (policyIds.size === 0) { + return DEFAULT_USAGE; + } + + const { total, inactive, online, error, updating, offline } = await getAgentStatusForAgentPolicy( + soClient, + esClient, + undefined, + Array.from(policyIds) + .map((policyId) => `(policy_id:"${policyId}")`) + .join(' or ') + ); + + return { + total_enrolled: total, + healthy: online, + unhealthy: error, + offline, + updating, + total_all_statuses: total + inactive, + num_host_urls: numHostsUrls, + }; +}; diff --git a/x-pack/plugins/fleet/server/collectors/register.ts b/x-pack/plugins/fleet/server/collectors/register.ts index 842bb95fe813f..a097d423e7dd2 100644 --- a/x-pack/plugins/fleet/server/collectors/register.ts +++ b/x-pack/plugins/fleet/server/collectors/register.ts @@ -16,11 +16,14 @@ import type { AgentUsage } from './agent_collectors'; import { getInternalClients } from './helpers'; import { getPackageUsage } from './package_collectors'; import type { PackageUsage } from './package_collectors'; +import { getFleetServerUsage } from './fleet_server_collector'; +import type { FleetServerUsage } from './fleet_server_collector'; interface Usage { agents_enabled: boolean; agents: AgentUsage; packages: PackageUsage[]; + fleet_server: FleetServerUsage; } export function registerFleetUsageCollector( @@ -43,6 +46,7 @@ export function registerFleetUsageCollector( return { agents_enabled: getIsAgentsEnabled(config), agents: await getAgentUsage(config, soClient, esClient), + fleet_server: await getFleetServerUsage(soClient, esClient), packages: await getPackageUsage(soClient), }; }, @@ -67,6 +71,12 @@ export function registerFleetUsageCollector( description: 'The total number of enrolled agents in an unhealthy state', }, }, + updating: { + type: 'long', + _meta: { + description: 'The total number of enrolled agents in an updating state', + }, + }, offline: { type: 'long', _meta: { @@ -80,6 +90,51 @@ export function registerFleetUsageCollector( }, }, }, + fleet_server: { + total_enrolled: { + type: 'long', + _meta: { + description: 'The total number of enrolled Fleet Server agents, in any state', + }, + }, + total_all_statuses: { + type: 'long', + _meta: { + description: + 'The total number of Fleet Server agents in any state, both enrolled and inactive.', + }, + }, + healthy: { + type: 'long', + _meta: { + description: 'The total number of enrolled Fleet Server agents in a healthy state.', + }, + }, + unhealthy: { + type: 'long', + _meta: { + description: 'The total number of enrolled Fleet Server agents in an unhealthy state', + }, + }, + updating: { + type: 'long', + _meta: { + description: 'The total number of enrolled Fleet Server agents in an updating state', + }, + }, + offline: { + type: 'long', + _meta: { + description: 'The total number of enrolled Fleet Server agents currently offline', + }, + }, + num_host_urls: { + type: 'long', + _meta: { + description: 'The number of Fleet Server hosts configured in Fleet settings.', + }, + }, + }, packages: { type: 'array', items: { diff --git a/x-pack/plugins/telemetry_collection_xpack/schema/xpack_plugins.json b/x-pack/plugins/telemetry_collection_xpack/schema/xpack_plugins.json index 12e83008b2e5a..7c96dce3fac7f 100644 --- a/x-pack/plugins/telemetry_collection_xpack/schema/xpack_plugins.json +++ b/x-pack/plugins/telemetry_collection_xpack/schema/xpack_plugins.json @@ -2041,6 +2041,12 @@ "description": "The total number of enrolled agents in an unhealthy state" } }, + "updating": { + "type": "long", + "_meta": { + "description": "The total number of enrolled agents in an updating state" + } + }, "offline": { "type": "long", "_meta": { @@ -2055,6 +2061,52 @@ } } }, + "fleet_server": { + "properties": { + "total_enrolled": { + "type": "long", + "_meta": { + "description": "The total number of enrolled Fleet Server agents, in any state" + } + }, + "total_all_statuses": { + "type": "long", + "_meta": { + "description": "The total number of Fleet Server agents in any state, both enrolled and inactive." + } + }, + "healthy": { + "type": "long", + "_meta": { + "description": "The total number of enrolled Fleet Server agents in a healthy state." + } + }, + "unhealthy": { + "type": "long", + "_meta": { + "description": "The total number of enrolled Fleet Server agents in an unhealthy state" + } + }, + "updating": { + "type": "long", + "_meta": { + "description": "The total number of enrolled Fleet Server agents in an updating state" + } + }, + "offline": { + "type": "long", + "_meta": { + "description": "The total number of enrolled Fleet Server agents currently offline" + } + }, + "num_host_urls": { + "type": "long", + "_meta": { + "description": "The number of Fleet Server hosts configured in Fleet settings." + } + } + } + }, "packages": { "type": "array", "items": { diff --git a/x-pack/test/fleet_api_integration/apis/fleet_telemetry.ts b/x-pack/test/fleet_api_integration/apis/fleet_telemetry.ts new file mode 100644 index 0000000000000..5cf0db2a6d917 --- /dev/null +++ b/x-pack/test/fleet_api_integration/apis/fleet_telemetry.ts @@ -0,0 +1,127 @@ +/* + * 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 expect from '@kbn/expect'; +import { FtrProviderContext } from '../../api_integration/ftr_provider_context'; +import { skipIfNoDockerRegistry } from '../helpers'; +import { setupFleetAndAgents } from './agents/services'; + +export default function (providerContext: FtrProviderContext) { + const { getService } = providerContext; + const supertest = getService('supertest'); + const es = getService('es'); + const esArchiver = getService('esArchiver'); + + let agentCount = 0; + async function generateAgent(status: string, policyId: string) { + let data: any = {}; + + switch (status) { + case 'unhealthy': + data = { last_checkin_status: 'error' }; + break; + case 'offline': + data = { last_checkin: '2017-06-07T18:59:04.498Z' }; + break; + default: + data = { last_checkin: new Date().toISOString() }; + } + + await es.index({ + index: '.fleet-agents', + body: { + id: `agent-${++agentCount}`, + active: true, + last_checkin: new Date().toISOString(), + policy_id: policyId, + policy_revision: 1, + ...data, + }, + refresh: 'wait_for', + }); + } + + describe('fleet_telemetry', () => { + skipIfNoDockerRegistry(providerContext); + before(async () => { + await esArchiver.load('empty_kibana'); + await esArchiver.load('fleet/empty_fleet_server'); + }); + + setupFleetAndAgents(providerContext); + + after(async () => { + await esArchiver.unload('empty_kibana'); + await esArchiver.unload('fleet/empty_fleet_server'); + }); + + before(async () => { + // Get FleetServer policy id + const { body: apiResponse } = await supertest.get(`/api/fleet/agent_policies`).expect(200); + const defaultFleetServerPolicy = apiResponse.items.find( + (item: any) => item.is_default_fleet_server + ); + + const defaultServerPolicy = apiResponse.items.find((item: any) => item.is_default); + + if (!defaultFleetServerPolicy) { + throw new Error('No default Fleet server policy'); + } + + if (!defaultServerPolicy) { + throw new Error('No default policy'); + } + + await supertest + .put(`/api/fleet/settings`) + .set('kbn-xsrf', 'xxxx') + .send({ fleet_server_hosts: ['https://test1.fr', 'https://test2.fr'] }) + .expect(200); + + // Default Fleet Server + await generateAgent('healthy', defaultFleetServerPolicy.id); + await generateAgent('healthy', defaultFleetServerPolicy.id); + await generateAgent('unhealthy', defaultFleetServerPolicy.id); + + // Default policy + await generateAgent('healthy', defaultServerPolicy.id); + await generateAgent('offline', defaultServerPolicy.id); + await generateAgent('unhealthy', defaultServerPolicy.id); + }); + + it('should return the correct telemetry values for fleet', async () => { + const { + body: [apiResponse], + } = await supertest + .post(`/api/telemetry/v2/clusters/_stats`) + .set('kbn-xsrf', 'xxxx') + .send({ + unencrypted: true, + }) + .expect(200); + + expect(apiResponse.stack_stats.kibana.plugins.fleet.agents).eql({ + total_enrolled: 6, + healthy: 3, + unhealthy: 2, + offline: 1, + updating: 0, + total_all_statuses: 6, + }); + + expect(apiResponse.stack_stats.kibana.plugins.fleet.fleet_server).eql({ + total_all_statuses: 3, + total_enrolled: 3, + healthy: 2, + unhealthy: 1, + offline: 0, + updating: 0, + num_host_urls: 2, + }); + }); + }); +} diff --git a/x-pack/test/fleet_api_integration/apis/index.js b/x-pack/test/fleet_api_integration/apis/index.js index 2357f549c101c..ca6315e1934ab 100644 --- a/x-pack/test/fleet_api_integration/apis/index.js +++ b/x-pack/test/fleet_api_integration/apis/index.js @@ -48,5 +48,8 @@ export default function ({ loadTestFile }) { // Outputs loadTestFile(require.resolve('./outputs')); + + // Telemetry + loadTestFile(require.resolve('./fleet_telemetry')); }); } From e2d75c2b47b0010c2ea7c4c17722857e37b0a975 Mon Sep 17 00:00:00 2001 From: Brian Seeders Date: Tue, 8 Jun 2021 19:03:32 -0400 Subject: [PATCH 09/19] [CI] Restore old version_info behavior when .git directory is present (#101642) --- src/dev/build/lib/version_info.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/dev/build/lib/version_info.ts b/src/dev/build/lib/version_info.ts index 6be34a54e24f8..9ad20b4a6935b 100644 --- a/src/dev/build/lib/version_info.ts +++ b/src/dev/build/lib/version_info.ts @@ -7,6 +7,9 @@ */ import execa from 'execa'; +import fs from 'fs'; +import { join } from 'path'; +import { REPO_ROOT } from '@kbn/utils'; import { getBuildNumber } from './get_build_number'; interface Options { @@ -27,11 +30,12 @@ export async function getVersionInfo({ isRelease, versionQualifier, pkg }: Optio isRelease ? '' : '-SNAPSHOT' ); + const buildSha = fs.existsSync(join(REPO_ROOT, '.git')) + ? (await execa('git', ['rev-parse', 'HEAD'], { cwd: REPO_ROOT })).stdout + : process.env.GIT_COMMIT || process.env.BUILDKITE_COMMIT || ''; + return { - buildSha: - process.env.GIT_COMMIT || - process.env.BUILDKITE_COMMIT || - (await execa('git', ['rev-parse', 'HEAD'])).stdout, + buildSha, buildVersion, buildNumber: await getBuildNumber(), }; From 6c02081ed7a3b6b71ef4df3b5eada991305effe6 Mon Sep 17 00:00:00 2001 From: Alexander Wert Date: Wed, 9 Jun 2021 01:13:47 +0200 Subject: [PATCH 10/19] Added APM PHP agent to the list of agent names (#101062) * Added APM PHP agent to the list of agent names to include it into the agent telemetry collection * put php label into alphabetical order Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> --- x-pack/plugins/apm/common/agent_name.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/x-pack/plugins/apm/common/agent_name.ts b/x-pack/plugins/apm/common/agent_name.ts index 247b07b5e71bb..8e40b088dff26 100644 --- a/x-pack/plugins/apm/common/agent_name.ts +++ b/x-pack/plugins/apm/common/agent_name.ts @@ -35,6 +35,7 @@ export const AGENT_NAMES: AgentName[] = [ 'java', 'js-base', 'nodejs', + 'php', 'python', 'ruby', 'rum-js', From 4021576436c947e363dd8ceb4bbed87445da2a99 Mon Sep 17 00:00:00 2001 From: Frank Hassanabad Date: Tue, 8 Jun 2021 17:31:54 -0600 Subject: [PATCH 11/19] [Security Solution][Detection Engine] Adds runtime field tests (#101664) ## Summary Adds runtime field tests with skips around the tests that we do not support just yet. * Adds tests around corner cases involving ".", "..", ".foo", "foo.", etc... * Adds tests around overriding values from the runtime fields within the source document * Adds tests around ambiguity for when we override an array in a runtime field * Fixes minor wording around previous tests * Fixes one line string when we do testing in one area ### 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 --- .../security_and_spaces/tests/aliases.ts | 4 +- .../security_and_spaces/tests/index.ts | 1 + .../security_and_spaces/tests/runtime.ts | 110 +++++++++++++++++ .../detection_engine_api_integration/utils.ts | 2 +- .../security_solution/runtime/data.json | 59 +++++++++ .../security_solution/runtime/mappings.json | 36 ++++++ .../runtime_conflicting_fields/data.json | 67 ++++++++++ .../runtime_conflicting_fields/mappings.json | 114 ++++++++++++++++++ 8 files changed, 390 insertions(+), 3 deletions(-) create mode 100644 x-pack/test/detection_engine_api_integration/security_and_spaces/tests/runtime.ts create mode 100644 x-pack/test/functional/es_archives/security_solution/runtime/data.json create mode 100644 x-pack/test/functional/es_archives/security_solution/runtime/mappings.json create mode 100644 x-pack/test/functional/es_archives/security_solution/runtime_conflicting_fields/data.json create mode 100644 x-pack/test/functional/es_archives/security_solution/runtime_conflicting_fields/mappings.json diff --git a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/aliases.ts b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/aliases.ts index 3a6c9f96b7e88..ca1281e0d2da9 100644 --- a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/aliases.ts +++ b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/aliases.ts @@ -39,7 +39,7 @@ export default ({ getService }: FtrProviderContext) => { await esArchiver.unload('x-pack/test/functional/es_archives/security_solution/alias'); }); - it('Should keep the original alias value such as "host_alias" from a source index when the value is indexed', async () => { + it('should keep the original alias value such as "host_alias" from a source index when the value is indexed', async () => { const rule = getRuleForSignalTesting(['alias']); const { id } = await createRule(supertest, rule); await waitForRuleSuccessOrStatus(supertest, id); @@ -52,7 +52,7 @@ export default ({ getService }: FtrProviderContext) => { }); // TODO: Make aliases work to where we can have ECS fields such as host.name filled out - it.skip('Should copy alias data from a source index into the signals index in the same position when the target is ECS compatible', async () => { + it.skip('should copy alias data from a source index into the signals index in the same position when the target is ECS compatible', async () => { const rule = getRuleForSignalTesting(['alias']); const { id } = await createRule(supertest, rule); await waitForRuleSuccessOrStatus(supertest, id); diff --git a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/index.ts b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/index.ts index 01fa2765ba0f0..fd3675a2e47e6 100644 --- a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/index.ts +++ b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/index.ts @@ -44,6 +44,7 @@ export default ({ loadTestFile }: FtrProviderContext): void => { loadTestFile(require.resolve('./finalize_signals_migrations')); loadTestFile(require.resolve('./delete_signals_migrations')); loadTestFile(require.resolve('./timestamps')); + loadTestFile(require.resolve('./runtime')); }); // That split here enable us on using a different ciGroup to run the tests diff --git a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/runtime.ts b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/runtime.ts new file mode 100644 index 0000000000000..4132b63415fcc --- /dev/null +++ b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/runtime.ts @@ -0,0 +1,110 @@ +/* + * 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 expect from '@kbn/expect'; + +import { FtrProviderContext } from '../../common/ftr_provider_context'; +import { + createRule, + createSignalsIndex, + deleteAllAlerts, + deleteSignalsIndex, + getRuleForSignalTesting, + getSignalsById, + waitForRuleSuccessOrStatus, + waitForSignalsToBePresent, +} from '../../utils'; + +// eslint-disable-next-line import/no-default-export +export default ({ getService }: FtrProviderContext) => { + const supertest = getService('supertest'); + const esArchiver = getService('esArchiver'); + interface HostAlias { + name: string; + hostname: string; + } + + describe('Tests involving runtime fields of source indexes and the signals index', () => { + describe('Regular runtime field mappings', () => { + beforeEach(async () => { + await createSignalsIndex(supertest); + await esArchiver.load('security_solution/runtime'); + }); + + afterEach(async () => { + await deleteSignalsIndex(supertest); + await deleteAllAlerts(supertest); + await esArchiver.unload('security_solution/runtime'); + }); + + it('should copy normal non-runtime data set from the source index into the signals index in the same position when the target is ECS compatible', async () => { + const rule = getRuleForSignalTesting(['runtime']); + const { id } = await createRule(supertest, rule); + await waitForRuleSuccessOrStatus(supertest, id); + await waitForSignalsToBePresent(supertest, 4, [id]); + const signalsOpen = await getSignalsById(supertest, id); + const hits = signalsOpen.hits.hits.map((signal) => (signal._source.host as HostAlias).name); + expect(hits).to.eql(['host name 1', 'host name 2', 'host name 3', 'host name 4']); + }); + + // TODO: Make runtime fields able to be copied to where we can have ECS fields such as host.name filled out by them within the mapping directly + it.skip('should copy "runtime mapping" data from a source index into the signals index in the same position when the target is ECS compatible', async () => { + const rule = getRuleForSignalTesting(['runtime']); + const { id } = await createRule(supertest, rule); + await waitForRuleSuccessOrStatus(supertest, id); + await waitForSignalsToBePresent(supertest, 4, [id]); + const signalsOpen = await getSignalsById(supertest, id); + const hits = signalsOpen.hits.hits.map( + (signal) => (signal._source.host_alias as HostAlias).hostname + ); + expect(hits).to.eql(['host name 1', 'host name 2', 'host name 3', 'host name 4']); + }); + }); + + describe('Runtime field mappings that have conflicts within them', () => { + beforeEach(async () => { + await createSignalsIndex(supertest); + await esArchiver.load('security_solution/runtime_conflicting_fields'); + }); + + afterEach(async () => { + await deleteSignalsIndex(supertest); + await deleteAllAlerts(supertest); + await esArchiver.unload('security_solution/runtime_conflicting_fields'); + }); + + // TODO: Make the overrides of runtime fields override the host.name in this use case. + it.skip('should copy normal non-runtime data set from the source index into the signals index in the same position when the target is ECS compatible', async () => { + const rule = getRuleForSignalTesting(['runtime_conflicting_fields']); + const { id } = await createRule(supertest, rule); + await waitForRuleSuccessOrStatus(supertest, id); + await waitForSignalsToBePresent(supertest, 4, [id]); + const signalsOpen = await getSignalsById(supertest, id); + const hits = signalsOpen.hits.hits.map((signal) => (signal._source.host as HostAlias).name); + expect(hits).to.eql([ + 'I am the [host.name] field value which shadows the original host.name value', + 'I am the [host.name] field value which shadows the original host.name value', + 'I am the [host.name] field value which shadows the original host.name value', + 'I am the [host.name] field value which shadows the original host.name value', + ]); + }); + + // TODO: Make runtime fields able to be copied to where we can have ECS fields such as host.name filled out by them within the mapping directly + it.skip('should copy "runtime mapping" data from a source index into the signals index in the same position when the target is ECS compatible', async () => { + const rule = getRuleForSignalTesting(['runtime_conflicting_fields']); + const { id } = await createRule(supertest, rule); + await waitForRuleSuccessOrStatus(supertest, id); + await waitForSignalsToBePresent(supertest, 4, [id]); + const signalsOpen = await getSignalsById(supertest, id); + const hits = signalsOpen.hits.hits.map( + (signal) => (signal._source.host_alias as HostAlias).hostname + ); + expect(hits).to.eql(['host name 1', 'host name 2', 'host name 3', 'host name 4']); + }); + }); + }); +}; diff --git a/x-pack/test/detection_engine_api_integration/utils.ts b/x-pack/test/detection_engine_api_integration/utils.ts index 7456040a436a4..54252b19fc940 100644 --- a/x-pack/test/detection_engine_api_integration/utils.ts +++ b/x-pack/test/detection_engine_api_integration/utils.ts @@ -1007,7 +1007,7 @@ export const waitForRuleSuccessOrStatus = async ( .send({ ids: [id] }) .expect(200); return body[id]?.current_status?.status === status; - }, 'waitForRuleSuccess'); + }, 'waitForRuleSuccessOrStatus'); }; /** diff --git a/x-pack/test/functional/es_archives/security_solution/runtime/data.json b/x-pack/test/functional/es_archives/security_solution/runtime/data.json new file mode 100644 index 0000000000000..799d59e6fb1ee --- /dev/null +++ b/x-pack/test/functional/es_archives/security_solution/runtime/data.json @@ -0,0 +1,59 @@ +{ + "type": "doc", + "value": { + "id": "1", + "index": "runtime", + "source": { + "@timestamp": "2020-10-28T05:00:53.000Z", + "host": { + "name": "host name 1" + } + }, + "type": "_doc" + } +} + +{ + "type": "doc", + "value": { + "id": "2", + "index": "runtime", + "source": { + "@timestamp": "2020-10-28T05:01:53.000Z", + "host": { + "name": "host name 2" + } + }, + "type": "_doc" + } +} + +{ + "type": "doc", + "value": { + "id": "3", + "index": "runtime", + "source": { + "@timestamp": "2020-10-28T05:02:53.000Z", + "host": { + "name": "host name 3" + } + }, + "type": "_doc" + } +} + +{ + "type": "doc", + "value": { + "id": "4", + "index": "runtime", + "source": { + "@timestamp": "2020-10-28T05:03:53.000Z", + "host": { + "name": "host name 4" + } + }, + "type": "_doc" + } +} diff --git a/x-pack/test/functional/es_archives/security_solution/runtime/mappings.json b/x-pack/test/functional/es_archives/security_solution/runtime/mappings.json new file mode 100644 index 0000000000000..33235d0171837 --- /dev/null +++ b/x-pack/test/functional/es_archives/security_solution/runtime/mappings.json @@ -0,0 +1,36 @@ +{ + "type": "index", + "value": { + "index": "runtime", + "mappings": { + "dynamic": "strict", + "runtime": { + "host.hostname": { + "type": "keyword", + "script": { + "source": "emit(doc['host.name'].value)" + } + } + }, + "properties": { + "@timestamp": { + "type": "date" + }, + "host": { + "properties": { + "name": { + "type": "keyword" + } + } + } + } + }, + "settings": { + "index": { + "refresh_interval": "1s", + "number_of_replicas": "1", + "number_of_shards": "1" + } + } + } +} diff --git a/x-pack/test/functional/es_archives/security_solution/runtime_conflicting_fields/data.json b/x-pack/test/functional/es_archives/security_solution/runtime_conflicting_fields/data.json new file mode 100644 index 0000000000000..ea64cd215f478 --- /dev/null +++ b/x-pack/test/functional/es_archives/security_solution/runtime_conflicting_fields/data.json @@ -0,0 +1,67 @@ +{ + "type": "doc", + "value": { + "id": "1", + "index": "runtime_conflicting_fields", + "source": { + "@timestamp": "2020-10-28T05:00:53.000Z", + "host": [{ + "name": "host name 1_1" + }, { + "name": "host name 1_2" + }] + }, + "type": "_doc" + } +} + +{ + "type": "doc", + "value": { + "id": "2", + "index": "runtime_conflicting_fields", + "source": { + "@timestamp": "2020-10-28T05:01:53.000Z", + "host": [{ + "name": "host name 2_1" + }, { + "name": "host name 2_2" + }] + }, + "type": "_doc" + } +} + +{ + "type": "doc", + "value": { + "id": "3", + "index": "runtime_conflicting_fields", + "source": { + "@timestamp": "2020-10-28T05:02:53.000Z", + "host": [{ + "name": "host name 3_1" + }, { + "name": "host name 3_2" + }] + }, + "type": "_doc" + } +} + +{ + "type": "doc", + "value": { + "id": "4", + "index": "runtime_conflicting_fields", + "source": { + "@timestamp": "2020-10-28T05:03:53.000Z", + "host": [{ + "name": "host name 4_1" + }, { + "name": "host name 4_2" + }] + }, + "type": "_doc" + } +} diff --git a/x-pack/test/functional/es_archives/security_solution/runtime_conflicting_fields/mappings.json b/x-pack/test/functional/es_archives/security_solution/runtime_conflicting_fields/mappings.json new file mode 100644 index 0000000000000..04a538a332953 --- /dev/null +++ b/x-pack/test/functional/es_archives/security_solution/runtime_conflicting_fields/mappings.json @@ -0,0 +1,114 @@ +{ + "type": "index", + "value": { + "index": "runtime_conflicting_fields", + "mappings": { + "dynamic": "strict", + "runtime": { + "host_alias": { + "type": "keyword", + "script": { + "source": "emit(doc['host.name'].value)" + } + }, + ".": { + "type": "keyword", + "script": { + "source": "emit('I am the [.] field that runtime exposes')" + } + }, + "..": { + "type": "keyword", + "script": { + "source": "emit('I am the [..] field that runtime exposes')" + } + }, + "host.name.": { + "type": "keyword", + "script": { + "source": "emit('I am the [host.name] field that runtime exposes')" + } + }, + ".host.name": { + "type": "keyword", + "script": { + "source": "emit('I am the [.host.name] field that runtime exposes')" + } + }, + ".host.name.": { + "type": "keyword", + "script": { + "source": "emit('I am the [.host.name.] field that runtime exposes')" + } + }, + "..host.name.": { + "type": "keyword", + "script": { + "source": "emit('I am the [..host.name.] field that runtime exposes')" + } + }, + "..host.name": { + "type": "keyword", + "script": { + "source": "emit('I am the [..host.name] field that runtime exposes')" + } + }, + ".host.name..": { + "type": "keyword", + "script": { + "source": "emit('I am the [.host.name..] field that runtime exposes')" + } + }, + "host.name..": { + "type": "keyword", + "script": { + "source": "emit('I am the [host.name..] field that runtime exposes')" + } + }, + "host": { + "type": "keyword", + "script": { + "source": "emit('I am the [host] field which is now a keyword instead of object runtime exposes')" + } + }, + "host.name": { + "type": "keyword", + "script": { + "source": "emit('I am the [host.name] field value which shadows the original host.name value')" + } + }, + "host.field_1": { + "type": "keyword", + "script": { + "source": "emit('I am the [host.name.field_1] field value which now confuses which array element I should be in and am ambiguous')" + } + }, + "host.name.subobject": { + "type": "keyword", + "script": { + "source": "emit('I am the [host.name.subobject] field value which is now an object instead of keyword runtime exposes')" + } + } + }, + "properties": { + "@timestamp": { + "type": "date" + }, + "host": { + "properties": { + "name": { + "type": "keyword" + } + } + } + } + }, + "settings": { + "index": { + "refresh_interval": "1s", + "number_of_replicas": "1", + "number_of_shards": "1" + } + } + } +} From aa8f7f3af2abca03d29738573f13c21d96a5a1fb Mon Sep 17 00:00:00 2001 From: Tyler Smalley Date: Tue, 8 Jun 2021 21:06:50 -0700 Subject: [PATCH 12/19] [FTR] Updates esArchive paths PR's merged after #101345 Signed-off-by: Tyler Smalley --- .../security_and_spaces/tests/runtime.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/runtime.ts b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/runtime.ts index 4132b63415fcc..94cc390e0e6ef 100644 --- a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/runtime.ts +++ b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/runtime.ts @@ -32,13 +32,13 @@ export default ({ getService }: FtrProviderContext) => { describe('Regular runtime field mappings', () => { beforeEach(async () => { await createSignalsIndex(supertest); - await esArchiver.load('security_solution/runtime'); + await esArchiver.load('x-pack/test/functional/es_archives/security_solution/runtime'); }); afterEach(async () => { await deleteSignalsIndex(supertest); await deleteAllAlerts(supertest); - await esArchiver.unload('security_solution/runtime'); + await esArchiver.unload('x-pack/test/functional/es_archives/security_solution/runtime'); }); it('should copy normal non-runtime data set from the source index into the signals index in the same position when the target is ECS compatible', async () => { @@ -68,13 +68,17 @@ export default ({ getService }: FtrProviderContext) => { describe('Runtime field mappings that have conflicts within them', () => { beforeEach(async () => { await createSignalsIndex(supertest); - await esArchiver.load('security_solution/runtime_conflicting_fields'); + await esArchiver.load( + 'x-pack/test/functional/es_archives/security_solution/runtime_conflicting_fields' + ); }); afterEach(async () => { await deleteSignalsIndex(supertest); await deleteAllAlerts(supertest); - await esArchiver.unload('security_solution/runtime_conflicting_fields'); + await esArchiver.unload( + 'x-pack/test/functional/es_archives/security_solution/runtime_conflicting_fields' + ); }); // TODO: Make the overrides of runtime fields override the host.name in this use case. From c225aaaaa5fc9db8e4323f5121783e2b7b9f67f6 Mon Sep 17 00:00:00 2001 From: Tyler Smalley Date: Tue, 8 Jun 2021 21:10:36 -0700 Subject: [PATCH 13/19] [FTR] Updates esArchive paths PR's merged after #101345 Signed-off-by: Tyler Smalley --- x-pack/test/fleet_api_integration/apis/fleet_telemetry.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/x-pack/test/fleet_api_integration/apis/fleet_telemetry.ts b/x-pack/test/fleet_api_integration/apis/fleet_telemetry.ts index 5cf0db2a6d917..5e4a580473dd1 100644 --- a/x-pack/test/fleet_api_integration/apis/fleet_telemetry.ts +++ b/x-pack/test/fleet_api_integration/apis/fleet_telemetry.ts @@ -48,15 +48,15 @@ export default function (providerContext: FtrProviderContext) { describe('fleet_telemetry', () => { skipIfNoDockerRegistry(providerContext); before(async () => { - await esArchiver.load('empty_kibana'); - await esArchiver.load('fleet/empty_fleet_server'); + await esArchiver.load('x-pack/test/functional/es_archives/empty_kibana'); + await esArchiver.load('x-pack/test/functional/es_archives/fleet/empty_fleet_server'); }); setupFleetAndAgents(providerContext); after(async () => { - await esArchiver.unload('empty_kibana'); - await esArchiver.unload('fleet/empty_fleet_server'); + await esArchiver.unload('x-pack/test/functional/es_archives/empty_kibana'); + await esArchiver.unload('x-pack/test/functional/es_archives/fleet/empty_fleet_server'); }); before(async () => { From 12986fb8fc46a7adde34ae3052104b29c6f74c69 Mon Sep 17 00:00:00 2001 From: Constance Date: Tue, 8 Jun 2021 21:36:06 -0700 Subject: [PATCH 14/19] [Enterprise Search] Mocks/tests tech debt - avoid hungry mocking (#101107) * Move enzyme & misc test helpers out of __mocks__/ and into new test_helpers/ They're not technically mocks since nothing is being mocked, so we should move them into a test_helpers folder for specificity & organization * Move React Router mocks into its own separate folder/import This was part of the initial feedback, that it was unclear why importing something for Kea in __mocks__/index.ts was mocking react router along for the ride. Separating this out makes things clearer and imports more explicit + add some handy new mock useX jest.fn()s helpers, so we're not doing `useParams() as jest.Mock` errywhere * Move Kea & logic mocks/helpers into kea_logic subfolder - for organization NOTE: It can't be a plain kea/ folder because then Jest automatically mocks the `kea` module itself kea :facepalm: * Fix type failures - Caused by switch from any to unknown (changed back to any + added a .test_helper suffix exclusion for any) * Fix Enterprise Search tests/imports - I checked all application folders but this one, whoops * PR feedback: comment copy * Update tests/files added since PR open with new import locations * Fix misc react router typing - null not being type-able as a boolean - forgot to remove various useParam imports after adding mockUseParams + misc unused kea import, probably added while debugging kea mocks --- .eslintrc.js | 2 +- .../flash_messages_logic.mock.ts | 4 +- .../__mocks__/kea_logic/hooks.mock.ts | 65 +++++++++++++++++++ .../{ => kea_logic}/http_logic.mock.ts | 2 +- .../__mocks__/{ => kea_logic}/index.ts | 17 +---- .../{ => kea_logic}/kibana_logic.mock.ts | 6 +- .../{ => kea_logic}/licensing_logic.mock.ts | 4 +- .../logic_mounter.test_helper.ts} | 63 +----------------- .../{ => kea_logic}/telemetry_logic.mock.ts | 4 +- .../hooks.mock.ts} | 37 +++-------- .../__mocks__/react_router/index.ts | 13 ++++ .../__mocks__/react_router/state.mock.ts | 28 ++++++++ .../applications/app_search/app_logic.test.ts | 2 +- .../analytics/analytics_layout.test.tsx | 8 +-- .../analytics/analytics_logic.test.ts | 2 +- .../components/analytics_chart.test.tsx | 2 +- .../components/analytics_header.test.tsx | 2 +- .../components/analytics_search.test.tsx | 3 +- .../analytics_tables/analytics_table.test.tsx | 5 +- .../query_clicks_table.test.tsx | 5 +- .../recent_queries_table.test.tsx | 5 +- .../test_helpers/shared_columns_tests.tsx | 2 +- .../analytics/views/analytics.test.tsx | 2 +- .../analytics/views/query_detail.test.tsx | 9 ++- .../analytics/views/recent_queries.test.tsx | 2 +- .../analytics/views/top_queries.test.tsx | 2 +- .../views/top_queries_no_clicks.test.tsx | 2 +- .../views/top_queries_no_results.test.tsx | 2 +- .../views/top_queries_with_clicks.test.tsx | 2 +- .../api_logs/api_log/api_log_flyout.test.tsx | 2 +- .../api_logs/api_log/api_log_logic.test.tsx | 2 +- .../components/api_logs/api_logs.test.tsx | 3 +- .../api_logs/api_logs_logic.test.ts | 6 +- .../components/api_logs_table.test.tsx | 3 +- .../components/new_api_events_prompt.test.tsx | 2 +- .../crawler/crawler_landing.test.tsx | 2 +- .../crawler/crawler_overview.test.tsx | 3 +- .../crawler/crawler_overview_logic.test.ts | 6 +- .../crawler/crawler_router.test.tsx | 2 +- .../credentials/credentials.test.tsx | 2 +- .../credentials_flyout/body.test.tsx | 2 +- .../credentials_flyout/footer.test.tsx | 2 +- .../key_engine_access.test.tsx | 4 +- .../form_components/key_name.test.tsx | 2 +- .../key_read_write_access.test.tsx | 2 +- .../form_components/key_type.test.tsx | 2 +- .../credentials_flyout/header.test.tsx | 2 +- .../credentials_flyout/index.test.tsx | 2 +- .../credentials_list.test.tsx | 2 +- .../credentials/credentials_logic.test.ts | 6 +- .../curations/curation/curation.test.tsx | 12 ++-- .../curations/curation/curation_logic.test.ts | 2 +- .../documents/hidden_documents.test.tsx | 2 +- .../documents/organic_documents.test.tsx | 2 +- .../documents/promoted_documents.test.tsx | 2 +- .../queries/active_query_select.test.tsx | 2 +- .../queries/manage_queries_modal.test.tsx | 2 +- .../results/add_result_button.test.tsx | 2 +- .../results/add_result_flyout.test.tsx | 2 +- .../curation/results/add_result_logic.test.ts | 2 +- .../curation/results/curation_result.test.tsx | 2 +- .../curations/curations_logic.test.ts | 2 +- .../views/curation_creation.test.tsx | 2 +- .../curations/views/curations.test.tsx | 8 +-- .../api_code_example.test.tsx | 2 +- .../paste_json_text.test.tsx | 4 +- .../show_creation_modes.test.tsx | 2 +- .../upload_json_file.test.tsx | 4 +- .../errors.test.tsx | 2 +- .../summary.test.tsx | 2 +- .../summary_sections.test.tsx | 2 +- .../document_creation_buttons.test.tsx | 2 +- .../document_creation_flyout.test.tsx | 2 +- .../document_creation_logic.test.ts | 2 +- .../document_creation_button.test.tsx | 2 +- .../documents/document_detail.test.tsx | 7 +- .../documents/document_detail_logic.test.ts | 2 +- .../components/documents/documents.test.tsx | 2 +- .../documents/documents_logic.test.ts | 2 +- .../customization_modal.test.tsx | 2 +- .../search_experience.test.tsx | 2 +- .../search_experience_content.test.tsx | 2 +- .../components/engine/engine_logic.test.ts | 2 +- .../components/engine/engine_nav.test.tsx | 4 +- .../components/engine/engine_router.test.tsx | 14 ++-- .../engine_creation/engine_creation.test.tsx | 2 +- .../engine_creation_logic.test.ts | 2 +- .../components/recent_api_logs.test.tsx | 2 +- .../components/total_charts.test.tsx | 2 +- .../components/total_stats.test.tsx | 2 +- .../engine_overview/engine_overview.test.tsx | 2 +- .../engine_overview_logic.test.ts | 6 +- .../engines/components/empty_state.test.tsx | 3 +- .../engines/components/header.test.tsx | 2 +- .../tables/engine_link_helpers.test.tsx | 2 +- .../components/tables/engines_table.test.tsx | 4 +- .../tables/meta_engines_table.test.tsx | 4 +- .../meta_engines_table_expanded_row.test.tsx | 4 +- .../tables/meta_engines_table_logic.test.ts | 2 +- .../tables/test_helpers/shared_columns.tsx | 4 +- .../components/engines/engines_logic.test.ts | 6 +- .../engines/engines_overview.test.tsx | 4 +- .../layout/kibana_header_actions.test.tsx | 2 +- .../components/log_retention_callout.test.tsx | 6 +- .../components/log_retention_tooltip.test.tsx | 2 +- .../log_retention/log_retention_logic.test.ts | 6 +- .../messaging/log_retention_message.test.tsx | 4 +- .../meta_engine_creation.test.tsx | 2 +- .../meta_engine_creation_logic.test.ts | 2 +- .../multi_input_rows.test.tsx | 4 +- .../multi_input_rows_logic.test.ts | 2 +- .../query_tester/query_tester.test.tsx | 2 +- .../boost_item_content.test.tsx | 2 +- .../functional_boost_form.test.tsx | 2 +- .../proximity_boost_form.test.tsx | 2 +- .../value_boost_form.test.tsx | 2 +- .../relevance_tuning/boosts/boosts.test.tsx | 2 +- .../relevance_tuning.test.tsx | 2 +- .../relevance_tuning_callouts.test.tsx | 2 +- .../relevance_tuning_form.test.tsx | 2 +- .../text_search_toggle.test.tsx | 2 +- .../weight_slider.test.tsx | 2 +- .../relevance_tuning_layout.test.tsx | 2 +- .../relevance_tuning_logic.test.ts | 6 +- .../relevance_tuning_preview.test.tsx | 2 +- .../components/result/result.test.tsx | 2 +- .../query_performance.test.tsx | 2 +- .../result_settings/result_settings.test.tsx | 2 +- .../result_settings_logic.test.ts | 7 +- .../disabled_fields_body.test.tsx | 2 +- .../non_text_fields_body.test.tsx | 2 +- .../result_settings_table.test.tsx | 2 +- .../text_fields_body.test.tsx | 2 +- .../sample_response/sample_response.test.tsx | 2 +- .../sample_response_logic.test.ts | 2 +- .../role_mappings/role_mapping.test.tsx | 3 +- .../role_mappings/role_mappings.test.tsx | 2 +- .../role_mappings/role_mappings_logic.test.ts | 7 +- .../sample_engine_creation_cta.test.tsx | 2 +- .../sample_engine_creation_cta_logic.test.ts | 2 +- .../meta_engines_conflicts_table.test.tsx | 2 +- .../meta_engines_schema_table.test.tsx | 2 +- .../components/schema_callouts.test.tsx | 2 +- .../schema/components/schema_table.test.tsx | 2 +- .../schema/reindex_job/reindex_job.test.tsx | 7 +- .../reindex_job/reindex_job_logic.test.ts | 6 +- .../schema/schema_base_logic.test.ts | 6 +- .../components/schema/schema_logic.test.ts | 6 +- .../schema/schema_meta_engine_logic.test.ts | 2 +- .../components/schema/schema_router.test.tsx | 4 +- .../schema/views/meta_engine_schema.test.tsx | 2 +- .../components/schema/views/schema.test.tsx | 2 +- .../components/search/search_logic.test.ts | 7 +- .../components/search_ui_form.test.tsx | 2 +- .../components/search_ui_graphic.test.tsx | 2 +- .../components/search_ui/search_ui.test.tsx | 2 +- .../search_ui/search_ui_logic.test.ts | 7 +- .../log_retention_confirmation_modal.test.tsx | 2 +- .../log_retention_panel.test.tsx | 2 +- .../add_source_engines_button.test.tsx | 2 +- .../add_source_engines_modal.test.tsx | 2 +- .../components/source_engines_table.test.tsx | 4 +- .../source_engines/source_engines.test.tsx | 2 +- .../source_engines_logic.test.ts | 6 +- .../synonyms/components/synonym_card.test.tsx | 2 +- .../components/synonym_modal.test.tsx | 2 +- .../components/synonyms/synonyms.test.tsx | 3 +- .../synonyms/synonyms_logic.test.ts | 6 +- .../applications/app_search/index.test.tsx | 12 ++-- .../utils/encode_path_params/index.test.ts | 5 +- .../utils/formatted_date_time/index.test.tsx | 4 +- .../recursively_fetch_engines/index.test.ts | 2 +- .../license_callout/license_callout.test.tsx | 2 +- .../product_card/product_card.test.tsx | 2 +- .../product_selector.test.tsx | 2 +- .../trial_callout/trial_callout.test.tsx | 2 +- .../enterprise_search/index.test.tsx | 4 +- .../error_state/error_state_prompt.test.tsx | 2 +- .../flash_messages/flash_messages.test.tsx | 2 +- .../flash_messages_logic.test.ts | 2 +- .../flash_messages/handle_api_errors.test.ts | 2 +- .../set_message_helpers.test.ts | 2 +- .../shared/kibana/kibana_logic.test.ts | 2 +- .../generate_breadcrumbs.test.ts | 3 +- .../shared/kibana_chrome/set_chrome.test.tsx | 3 +- .../shared/layout/side_nav.test.tsx | 11 ++-- .../shared/not_found/not_found.test.tsx | 2 +- .../react_router_helpers/create_href.test.ts | 2 +- .../eui_components.test.tsx | 5 +- .../setup_guide/cloud/instructions.test.tsx | 4 +- .../shared/setup_guide/instructions.test.tsx | 4 +- .../shared/setup_guide/setup_guide.test.tsx | 4 +- .../shared/telemetry/send_telemetry.test.tsx | 2 +- .../shared/telemetry/telemetry_logic.test.ts | 2 +- .../enzyme_rerender.ts} | 0 .../expected_async_error.ts | 0 .../public/applications/test_helpers/index.ts | 15 +++++ .../mount_async.tsx} | 4 +- .../mount_with_i18n.tsx} | 0 .../shallow_with_i18n.tsx} | 0 .../workplace_search/app_logic.test.ts | 2 +- .../account_header/account_header.test.tsx | 2 +- .../product_button/product_button.test.tsx | 3 +- .../workplace_search/index.test.tsx | 3 +- .../components/add_source/add_source.test.tsx | 6 +- .../add_source/add_source_list.test.tsx | 2 +- .../add_source/add_source_logic.test.ts | 2 +- .../available_sources_list.test.tsx | 2 +- .../add_source/configure_custom.test.tsx | 2 +- .../add_source/configure_oauth.test.tsx | 2 +- .../add_source/connect_instance.test.tsx | 2 +- .../add_source/reauthenticate.test.tsx | 3 +- .../add_source/save_config.test.tsx | 2 +- .../add_source/source_features.test.tsx | 12 ++-- .../display_settings.test.tsx | 2 +- .../display_settings_logic.test.ts | 2 +- .../display_settings_router.test.tsx | 2 +- .../example_result_detail_card.test.tsx | 2 +- .../example_search_result_group.test.tsx | 2 +- .../example_standout_result.test.tsx | 2 +- .../field_editor_modal.test.tsx | 2 +- .../display_settings/result_detail.test.tsx | 2 +- .../display_settings/search_results.test.tsx | 2 +- .../components/overview.test.tsx | 2 +- .../components/schema/schema.test.tsx | 2 +- .../schema/schema_change_errors.test.tsx | 7 +- .../schema/schema_fields_table.test.tsx | 2 +- .../components/schema/schema_logic.test.ts | 6 +- .../components/source_added.test.tsx | 4 +- .../components/source_content.test.tsx | 2 +- .../components/source_settings.test.tsx | 2 +- .../components/source_sub_nav.test.tsx | 2 +- .../organization_sources.test.tsx | 3 +- .../content_sources/private_sources.test.tsx | 2 +- .../private_sources_layout.test.tsx | 2 +- .../content_sources/source_logic.test.ts | 4 +- .../content_sources/source_router.test.tsx | 7 +- .../content_sources/sources_logic.test.ts | 5 +- .../content_sources/sources_router.test.tsx | 4 +- .../content_sources/sources_view.test.tsx | 2 +- .../components/add_group_modal.test.tsx | 2 +- .../components/clear_filters_link.test.tsx | 2 +- .../filterable_users_popover.test.tsx | 2 +- .../components/group_manager_modal.test.tsx | 2 +- .../groups/components/group_overview.test.tsx | 2 +- .../groups/components/group_row.test.tsx | 2 +- .../group_row_users_dropdown.test.tsx | 2 +- .../group_source_prioritization.test.tsx | 2 +- .../groups/components/group_sub_nav.test.tsx | 2 +- .../components/group_users_table.test.tsx | 2 +- .../groups/components/groups_table.test.tsx | 2 +- .../components/manage_users_modal.test.tsx | 2 +- .../components/shared_sources_modal.test.tsx | 2 +- .../table_filter_sources_dropdown.test.tsx | 2 +- .../table_filter_users_dropdown.test.tsx | 2 +- .../groups/components/table_filters.test.tsx | 2 +- .../views/groups/group_logic.test.ts | 2 +- .../views/groups/group_router.test.tsx | 3 +- .../views/groups/groups.test.tsx | 2 +- .../views/groups/groups_logic.test.ts | 6 +- .../views/groups/groups_router.test.tsx | 2 +- .../overview/__mocks__/overview_logic.mock.ts | 2 +- .../views/overview/onboarding_card.test.tsx | 3 +- .../views/overview/onboarding_steps.test.tsx | 2 +- .../views/overview/overview.test.tsx | 1 - .../views/overview/overview_logic.test.ts | 2 +- .../views/overview/recent_activity.test.tsx | 2 +- .../views/role_mappings/role_mapping.test.tsx | 3 +- .../role_mappings/role_mappings.test.tsx | 2 +- .../role_mappings/role_mappings_logic.test.ts | 7 +- .../components/private_sources_table.test.tsx | 2 +- .../views/security/security.test.tsx | 2 +- .../views/security/security_logic.test.ts | 7 +- .../settings/components/connectors.test.tsx | 2 +- .../settings/components/customize.test.tsx | 2 +- .../components/oauth_application.test.tsx | 2 +- .../components/source_config.test.tsx | 2 +- .../views/settings/settings_logic.test.ts | 8 ++- .../views/settings/settings_router.test.tsx | 2 +- 279 files changed, 603 insertions(+), 448 deletions(-) rename x-pack/plugins/enterprise_search/public/applications/__mocks__/{ => kea_logic}/flash_messages_logic.mock.ts (89%) create mode 100644 x-pack/plugins/enterprise_search/public/applications/__mocks__/kea_logic/hooks.mock.ts rename x-pack/plugins/enterprise_search/public/applications/__mocks__/{ => kea_logic}/http_logic.mock.ts (92%) rename x-pack/plugins/enterprise_search/public/applications/__mocks__/{ => kea_logic}/index.ts (53%) rename x-pack/plugins/enterprise_search/public/applications/__mocks__/{ => kea_logic}/kibana_logic.mock.ts (79%) rename x-pack/plugins/enterprise_search/public/applications/__mocks__/{ => kea_logic}/licensing_logic.mock.ts (79%) rename x-pack/plugins/enterprise_search/public/applications/__mocks__/{kea.mock.ts => kea_logic/logic_mounter.test_helper.ts} (62%) rename x-pack/plugins/enterprise_search/public/applications/__mocks__/{ => kea_logic}/telemetry_logic.mock.ts (82%) rename x-pack/plugins/enterprise_search/public/applications/__mocks__/{react_router_history.mock.ts => react_router/hooks.mock.ts} (53%) create mode 100644 x-pack/plugins/enterprise_search/public/applications/__mocks__/react_router/index.ts create mode 100644 x-pack/plugins/enterprise_search/public/applications/__mocks__/react_router/state.mock.ts rename x-pack/plugins/enterprise_search/public/applications/{__mocks__/enzyme_rerender.mock.ts => test_helpers/enzyme_rerender.ts} (100%) rename x-pack/plugins/enterprise_search/public/applications/{__mocks__ => test_helpers}/expected_async_error.ts (100%) create mode 100644 x-pack/plugins/enterprise_search/public/applications/test_helpers/index.ts rename x-pack/plugins/enterprise_search/public/applications/{__mocks__/mount_async.mock.tsx => test_helpers/mount_async.tsx} (96%) rename x-pack/plugins/enterprise_search/public/applications/{__mocks__/mount_with_i18n.mock.tsx => test_helpers/mount_with_i18n.tsx} (100%) rename x-pack/plugins/enterprise_search/public/applications/{__mocks__/shallow_with_i18n.mock.tsx => test_helpers/shallow_with_i18n.tsx} (100%) diff --git a/.eslintrc.js b/.eslintrc.js index a4ce657d523d9..22d0270a5b066 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1370,7 +1370,7 @@ module.exports = { { // Source files only - allow `any` in test/mock files files: ['x-pack/plugins/enterprise_search/**/*.{ts,tsx}'], - excludedFiles: ['x-pack/plugins/enterprise_search/**/*.{test,mock}.{ts,tsx}'], + excludedFiles: ['x-pack/plugins/enterprise_search/**/*.{test,mock,test_helper}.{ts,tsx}'], rules: { '@typescript-eslint/no-explicit-any': 'error', }, diff --git a/x-pack/plugins/enterprise_search/public/applications/__mocks__/flash_messages_logic.mock.ts b/x-pack/plugins/enterprise_search/public/applications/__mocks__/kea_logic/flash_messages_logic.mock.ts similarity index 89% rename from x-pack/plugins/enterprise_search/public/applications/__mocks__/flash_messages_logic.mock.ts rename to x-pack/plugins/enterprise_search/public/applications/__mocks__/kea_logic/flash_messages_logic.mock.ts index 6c31927cd75b0..36a10fd234bfe 100644 --- a/x-pack/plugins/enterprise_search/public/applications/__mocks__/flash_messages_logic.mock.ts +++ b/x-pack/plugins/enterprise_search/public/applications/__mocks__/kea_logic/flash_messages_logic.mock.ts @@ -29,8 +29,8 @@ export const mockFlashMessageHelpers = { flashErrorToast: jest.fn(), }; -jest.mock('../shared/flash_messages', () => ({ - ...(jest.requireActual('../shared/flash_messages') as object), +jest.mock('../../shared/flash_messages', () => ({ + ...(jest.requireActual('../../shared/flash_messages') as object), ...mockFlashMessageHelpers, FlashMessagesLogic: { values: mockFlashMessagesValues, diff --git a/x-pack/plugins/enterprise_search/public/applications/__mocks__/kea_logic/hooks.mock.ts b/x-pack/plugins/enterprise_search/public/applications/__mocks__/kea_logic/hooks.mock.ts new file mode 100644 index 0000000000000..ce21fd08f180a --- /dev/null +++ b/x-pack/plugins/enterprise_search/public/applications/__mocks__/kea_logic/hooks.mock.ts @@ -0,0 +1,65 @@ +/* + * 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. + */ + +/** + * Combine all shared mock values/actions into a single obj + * + * NOTE: These variable names MUST start with 'mock*' in order for + * Jest to accept its use within a jest.mock() + */ +import { mockFlashMessagesValues, mockFlashMessagesActions } from './flash_messages_logic.mock'; +import { mockHttpValues } from './http_logic.mock'; +import { mockKibanaValues } from './kibana_logic.mock'; +import { mockLicensingValues } from './licensing_logic.mock'; +import { mockTelemetryActions } from './telemetry_logic.mock'; + +export const mockAllValues = { + ...mockKibanaValues, + ...mockLicensingValues, + ...mockHttpValues, + ...mockFlashMessagesValues, +}; +export const mockAllActions = { + ...mockTelemetryActions, + ...mockFlashMessagesActions, +}; + +/** + * Import this file directly to mock useValues with a set of default values for all shared logic files. + * Example usage: + * + * import '../../../__mocks__/kea_logic'; // Must come before kea's import, adjust relative path as needed + */ +jest.mock('kea', () => ({ + ...(jest.requireActual('kea') as object), + useValues: jest.fn(() => ({ ...mockAllValues })), + useActions: jest.fn(() => ({ ...mockAllActions })), +})); + +/** + * React component helpers + * + * Call this function to override a specific set of Kea values while retaining all other defaults + * + * Example usage: + * + * import { setMockValues } from '../../../__mocks__/kea_logic'; + * import { SomeComponent } from './'; + * + * it('some test', () => { + * setMockValues({ someValue: 'hello' }); + * shallow(); + * }); + */ +import { useValues, useActions } from 'kea'; + +export const setMockValues = (values: object) => { + (useValues as jest.Mock).mockImplementation(() => ({ ...mockAllValues, ...values })); +}; +export const setMockActions = (actions: object) => { + (useActions as jest.Mock).mockImplementation(() => ({ ...mockAllActions, ...actions })); +}; diff --git a/x-pack/plugins/enterprise_search/public/applications/__mocks__/http_logic.mock.ts b/x-pack/plugins/enterprise_search/public/applications/__mocks__/kea_logic/http_logic.mock.ts similarity index 92% rename from x-pack/plugins/enterprise_search/public/applications/__mocks__/http_logic.mock.ts rename to x-pack/plugins/enterprise_search/public/applications/__mocks__/kea_logic/http_logic.mock.ts index 5399646a7b414..e60f5a1a8ba12 100644 --- a/x-pack/plugins/enterprise_search/public/applications/__mocks__/http_logic.mock.ts +++ b/x-pack/plugins/enterprise_search/public/applications/__mocks__/kea_logic/http_logic.mock.ts @@ -13,6 +13,6 @@ export const mockHttpValues = { readOnlyMode: false, }; -jest.mock('../shared/http', () => ({ +jest.mock('../../shared/http', () => ({ HttpLogic: { values: mockHttpValues }, })); diff --git a/x-pack/plugins/enterprise_search/public/applications/__mocks__/index.ts b/x-pack/plugins/enterprise_search/public/applications/__mocks__/kea_logic/index.ts similarity index 53% rename from x-pack/plugins/enterprise_search/public/applications/__mocks__/index.ts rename to x-pack/plugins/enterprise_search/public/applications/__mocks__/kea_logic/index.ts index 4e3a344b52e46..81901e6d0e103 100644 --- a/x-pack/plugins/enterprise_search/public/applications/__mocks__/index.ts +++ b/x-pack/plugins/enterprise_search/public/applications/__mocks__/kea_logic/index.ts @@ -5,7 +5,6 @@ * 2.0. */ -export { mockHistory, mockLocation } from './react_router_history.mock'; export { mockKibanaValues } from './kibana_logic.mock'; export { mockLicensingValues } from './licensing_logic.mock'; export { mockHttpValues } from './http_logic.mock'; @@ -15,18 +14,6 @@ export { mockFlashMessagesActions, mockFlashMessageHelpers, } from './flash_messages_logic.mock'; -export { - mockAllValues, - mockAllActions, - setMockValues, - setMockActions, - LogicMounter, -} from './kea.mock'; - -export { mountAsync } from './mount_async.mock'; -export { mountWithIntl } from './mount_with_i18n.mock'; -export { shallowWithIntl } from './shallow_with_i18n.mock'; -export { rerender } from './enzyme_rerender.mock'; -// Note: shallow_useeffect must be imported directly as a file +export { mockAllValues, mockAllActions, setMockValues, setMockActions } from './hooks.mock'; -export { expectedAsyncError } from './expected_async_error'; +export { LogicMounter } from './logic_mounter.test_helper'; diff --git a/x-pack/plugins/enterprise_search/public/applications/__mocks__/kibana_logic.mock.ts b/x-pack/plugins/enterprise_search/public/applications/__mocks__/kea_logic/kibana_logic.mock.ts similarity index 79% rename from x-pack/plugins/enterprise_search/public/applications/__mocks__/kibana_logic.mock.ts rename to x-pack/plugins/enterprise_search/public/applications/__mocks__/kea_logic/kibana_logic.mock.ts index 1ebd61df388c5..ebb6f8c4fe5aa 100644 --- a/x-pack/plugins/enterprise_search/public/applications/__mocks__/kibana_logic.mock.ts +++ b/x-pack/plugins/enterprise_search/public/applications/__mocks__/kea_logic/kibana_logic.mock.ts @@ -5,9 +5,9 @@ * 2.0. */ -import { mockHistory } from './react_router_history.mock'; +import { chartPluginMock } from '../../../../../../../src/plugins/charts/public/mocks'; -import { chartPluginMock } from '../../../../../../src/plugins/charts/public/mocks'; +import { mockHistory } from '../react_router/state.mock'; export const mockKibanaValues = { config: { host: 'http://localhost:3002' }, @@ -24,6 +24,6 @@ export const mockKibanaValues = { renderHeaderActions: jest.fn(), }; -jest.mock('../shared/kibana', () => ({ +jest.mock('../../shared/kibana', () => ({ KibanaLogic: { values: mockKibanaValues }, })); diff --git a/x-pack/plugins/enterprise_search/public/applications/__mocks__/licensing_logic.mock.ts b/x-pack/plugins/enterprise_search/public/applications/__mocks__/kea_logic/licensing_logic.mock.ts similarity index 79% rename from x-pack/plugins/enterprise_search/public/applications/__mocks__/licensing_logic.mock.ts rename to x-pack/plugins/enterprise_search/public/applications/__mocks__/kea_logic/licensing_logic.mock.ts index d39ba56cdc1c1..2cea6061b63ab 100644 --- a/x-pack/plugins/enterprise_search/public/applications/__mocks__/licensing_logic.mock.ts +++ b/x-pack/plugins/enterprise_search/public/applications/__mocks__/kea_logic/licensing_logic.mock.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { licensingMock } from '../../../../licensing/public/mocks'; +import { licensingMock } from '../../../../../licensing/public/mocks'; export const mockLicensingValues = { license: licensingMock.createLicense(), @@ -13,6 +13,6 @@ export const mockLicensingValues = { hasGoldLicense: false, }; -jest.mock('../shared/licensing', () => ({ +jest.mock('../../shared/licensing', () => ({ LicensingLogic: { values: mockLicensingValues }, })); diff --git a/x-pack/plugins/enterprise_search/public/applications/__mocks__/kea.mock.ts b/x-pack/plugins/enterprise_search/public/applications/__mocks__/kea_logic/logic_mounter.test_helper.ts similarity index 62% rename from x-pack/plugins/enterprise_search/public/applications/__mocks__/kea.mock.ts rename to x-pack/plugins/enterprise_search/public/applications/__mocks__/kea_logic/logic_mounter.test_helper.ts index 4ebb9edd20c0e..08867fe944d15 100644 --- a/x-pack/plugins/enterprise_search/public/applications/__mocks__/kea.mock.ts +++ b/x-pack/plugins/enterprise_search/public/applications/__mocks__/kea_logic/logic_mounter.test_helper.ts @@ -6,67 +6,6 @@ */ /** - * Combine all shared mock values/actions into a single obj - * - * NOTE: These variable names MUST start with 'mock*' in order for - * Jest to accept its use within a jest.mock() - */ -import { mockFlashMessagesValues, mockFlashMessagesActions } from './flash_messages_logic.mock'; -import { mockHttpValues } from './http_logic.mock'; -import { mockKibanaValues } from './kibana_logic.mock'; -import { mockLicensingValues } from './licensing_logic.mock'; -import { mockTelemetryActions } from './telemetry_logic.mock'; - -export const mockAllValues = { - ...mockKibanaValues, - ...mockLicensingValues, - ...mockHttpValues, - ...mockFlashMessagesValues, -}; -export const mockAllActions = { - ...mockTelemetryActions, - ...mockFlashMessagesActions, -}; - -/** - * Import this file directly to mock useValues with a set of default values for all shared logic files. - * Example usage: - * - * import '../../../__mocks__/kea'; // Must come before kea's import, adjust relative path as needed - */ -jest.mock('kea', () => ({ - ...(jest.requireActual('kea') as object), - useValues: jest.fn(() => ({ ...mockAllValues })), - useActions: jest.fn(() => ({ ...mockAllActions })), -})); - -/** - * React component helpers - * - * Call this function to override a specific set of Kea values while retaining all other defaults - * - * Example usage: - * - * import { setMockValues } from '../../../__mocks__/kea.mock'; - * import { SomeComponent } from './'; - * - * it('some test', () => { - * setMockValues({ someValue: 'hello' }); - * shallow(); - * }); - */ -import { useValues, useActions } from 'kea'; - -export const setMockValues = (values: object) => { - (useValues as jest.Mock).mockImplementation(() => ({ ...mockAllValues, ...values })); -}; -export const setMockActions = (actions: object) => { - (useActions as jest.Mock).mockImplementation(() => ({ ...mockAllActions, ...actions })); -}; - -/** - * Kea logic helpers - * * Call this function to mount a logic file and optionally override default values. * Automatically DRYs out a lot of cruft for us, such as resetting context, creating the * nested defaults path obj (see https://kea.js.org/docs/api/context#resetcontext), and @@ -74,7 +13,7 @@ export const setMockActions = (actions: object) => { * * Example usage: * - * import { LogicMounter } from '../../../__mocks__/kea.mock'; + * import { LogicMounter } from '../../../__mocks__/kea_logic'; * import { SomeLogic } from './'; * * const { mount, unmount } = new LogicMounter(SomeLogic); diff --git a/x-pack/plugins/enterprise_search/public/applications/__mocks__/telemetry_logic.mock.ts b/x-pack/plugins/enterprise_search/public/applications/__mocks__/kea_logic/telemetry_logic.mock.ts similarity index 82% rename from x-pack/plugins/enterprise_search/public/applications/__mocks__/telemetry_logic.mock.ts rename to x-pack/plugins/enterprise_search/public/applications/__mocks__/kea_logic/telemetry_logic.mock.ts index 01b2e7cf103fb..fbc1537e733e7 100644 --- a/x-pack/plugins/enterprise_search/public/applications/__mocks__/telemetry_logic.mock.ts +++ b/x-pack/plugins/enterprise_search/public/applications/__mocks__/kea_logic/telemetry_logic.mock.ts @@ -12,7 +12,7 @@ export const mockTelemetryActions = { sendWorkplaceSearchTelemetry: jest.fn(), }; -jest.mock('../shared/telemetry', () => ({ - ...(jest.requireActual('../shared/telemetry') as object), +jest.mock('../../shared/telemetry', () => ({ + ...(jest.requireActual('../../shared/telemetry') as object), TelemetryLogic: { actions: mockTelemetryActions }, })); diff --git a/x-pack/plugins/enterprise_search/public/applications/__mocks__/react_router_history.mock.ts b/x-pack/plugins/enterprise_search/public/applications/__mocks__/react_router/hooks.mock.ts similarity index 53% rename from x-pack/plugins/enterprise_search/public/applications/__mocks__/react_router_history.mock.ts rename to x-pack/plugins/enterprise_search/public/applications/__mocks__/react_router/hooks.mock.ts index 8f0c63d46c8e7..5e867da7607fe 100644 --- a/x-pack/plugins/enterprise_search/public/applications/__mocks__/react_router_history.mock.ts +++ b/x-pack/plugins/enterprise_search/public/applications/__mocks__/react_router/hooks.mock.ts @@ -5,34 +5,21 @@ * 2.0. */ -/** - * NOTE: These variable names MUST start with 'mock*' in order for - * Jest to accept its use within a jest.mock() - */ -export const mockHistory = { - createHref: jest.fn(({ pathname }) => `/app/enterprise_search${pathname}`), - push: jest.fn(), - location: { - pathname: '/current-path', - }, - listen: jest.fn(() => jest.fn()), -} as any; -export const mockLocation = { - key: 'someKey', - pathname: '/current-path', - search: '?query=something', - hash: '#hash', - state: {}, -}; +import { mockHistory, mockLocation } from './state.mock'; + +export const mockUseHistory = jest.fn(() => mockHistory); +export const mockUseLocation = jest.fn(() => mockLocation); +export const mockUseParams = jest.fn(() => ({})); +export const mockUseRouteMatch = jest.fn(() => true); jest.mock('react-router-dom', () => { const originalModule = jest.requireActual('react-router-dom'); return { ...originalModule, - useHistory: jest.fn(() => mockHistory), - useLocation: jest.fn(() => mockLocation), - useParams: jest.fn(() => ({})), - useRouteMatch: jest.fn(() => null), + useHistory: mockUseHistory, + useLocation: mockUseLocation, + useParams: mockUseParams, + useRouteMatch: mockUseRouteMatch, // Note: RR's generatePath() opinionatedly encodeURI()s paths (although this doesn't actually // show up/affect the final browser URL). Since we already have a generateEncodedPath helper & // RR is removing this behavior in history 5.0+, I'm mocking tests to remove the extra encoding @@ -40,7 +27,3 @@ jest.mock('react-router-dom', () => { generatePath: jest.fn((path, params) => decodeURI(originalModule.generatePath(path, params))), }; }); - -/** - * For example usage, @see public/applications/shared/react_router_helpers/eui_link.test.tsx - */ diff --git a/x-pack/plugins/enterprise_search/public/applications/__mocks__/react_router/index.ts b/x-pack/plugins/enterprise_search/public/applications/__mocks__/react_router/index.ts new file mode 100644 index 0000000000000..0bf83135407b3 --- /dev/null +++ b/x-pack/plugins/enterprise_search/public/applications/__mocks__/react_router/index.ts @@ -0,0 +1,13 @@ +/* + * 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. + */ + +// State and hooks are stored in separate mock files for when a file needs to +// import a basic history mock without automatically jest.mock()ing all of React Router +export * from './state.mock'; +export * from './hooks.mock'; + +// For example usage, @see public/applications/shared/react_router_helpers/eui_link.test.tsx diff --git a/x-pack/plugins/enterprise_search/public/applications/__mocks__/react_router/state.mock.ts b/x-pack/plugins/enterprise_search/public/applications/__mocks__/react_router/state.mock.ts new file mode 100644 index 0000000000000..0ce8673530b00 --- /dev/null +++ b/x-pack/plugins/enterprise_search/public/applications/__mocks__/react_router/state.mock.ts @@ -0,0 +1,28 @@ +/* + * 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. + */ + +/** + * NOTE: These variable names MUST start with 'mock*' in order for + * Jest to accept its use within a jest.mock() + */ + +export const mockHistory = { + createHref: jest.fn(({ pathname }) => `/app/enterprise_search${pathname}`), + push: jest.fn(), + location: { + pathname: '/current-path', + }, + listen: jest.fn(() => jest.fn()), +} as any; + +export const mockLocation = { + key: 'someKey', + pathname: '/current-path', + search: '?query=something', + hash: '#hash', + state: {}, +}; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/app_logic.test.ts b/x-pack/plugins/enterprise_search/public/applications/app_search/app_logic.test.ts index f6497e5f5266b..7b08e82a4cf20 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/app_logic.test.ts +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/app_logic.test.ts @@ -6,7 +6,7 @@ */ import { DEFAULT_INITIAL_APP_DATA } from '../../../common/__mocks__'; -import { LogicMounter } from '../__mocks__'; +import { LogicMounter } from '../__mocks__/kea_logic'; import { AppLogic } from './app_logic'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/analytics/analytics_layout.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/analytics/analytics_layout.test.tsx index 291df04746418..9832915f19e9e 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/analytics/analytics_layout.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/analytics/analytics_layout.test.tsx @@ -6,16 +6,16 @@ */ import '../../../__mocks__/shallow_useeffect.mock'; -import '../../../__mocks__/react_router_history.mock'; -import { mockKibanaValues, setMockValues, setMockActions, rerender } from '../../../__mocks__'; +import { mockKibanaValues, setMockValues, setMockActions } from '../../../__mocks__/kea_logic'; +import { mockUseParams } from '../../../__mocks__/react_router'; import React from 'react'; -import { useParams } from 'react-router-dom'; import { shallow } from 'enzyme'; import { FlashMessages } from '../../../shared/flash_messages'; import { Loading } from '../../../shared/loading'; +import { rerender } from '../../../test_helpers'; import { LogRetentionCallout } from '../log_retention'; import { AnalyticsLayout } from './analytics_layout'; @@ -63,7 +63,7 @@ describe('AnalyticsLayout', () => { describe('data loading', () => { it('loads query data for query details pages', () => { - (useParams as jest.Mock).mockReturnValueOnce({ query: 'test' }); + mockUseParams.mockReturnValueOnce({ query: 'test' }); shallow(); expect(actions.loadQueryData).toHaveBeenCalledWith('test'); diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/analytics/analytics_logic.test.ts b/x-pack/plugins/enterprise_search/public/applications/app_search/components/analytics/analytics_logic.test.ts index 3359143ad3672..921a0892bb890 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/analytics/analytics_logic.test.ts +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/analytics/analytics_logic.test.ts @@ -10,7 +10,7 @@ import { mockKibanaValues, mockHttpValues, mockFlashMessageHelpers, -} from '../../../__mocks__'; +} from '../../../__mocks__/kea_logic'; jest.mock('../engine', () => ({ EngineLogic: { values: { engineName: 'test-engine' } }, diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/analytics/components/analytics_chart.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/analytics/components/analytics_chart.test.tsx index 51238d62bdac7..8a5d2cbf89c4a 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/analytics/components/analytics_chart.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/analytics/components/analytics_chart.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { mockKibanaValues } from '../../../../__mocks__'; +import { mockKibanaValues } from '../../../../__mocks__/kea_logic'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/analytics/components/analytics_header.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/analytics/components/analytics_header.test.tsx index 952c4c2517a0e..5269ea9110065 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/analytics/components/analytics_header.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/analytics/components/analytics_header.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { setMockValues, mockKibanaValues } from '../../../../__mocks__'; +import { setMockValues, mockKibanaValues } from '../../../../__mocks__/kea_logic'; import React, { ReactElement } from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/analytics/components/analytics_search.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/analytics/components/analytics_search.test.tsx index 89fa5b4cc4b73..de04a21d48a23 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/analytics/components/analytics_search.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/analytics/components/analytics_search.test.tsx @@ -5,7 +5,8 @@ * 2.0. */ -import { mockKibanaValues } from '../../../../__mocks__'; +import { mockKibanaValues } from '../../../../__mocks__/kea_logic'; +import '../../../../__mocks__/react_router'; import '../../../__mocks__/engine_logic.mock'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/analytics/components/analytics_tables/analytics_table.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/analytics/components/analytics_tables/analytics_table.test.tsx index 624cc57e1eb22..e25e4d8c16bb2 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/analytics/components/analytics_tables/analytics_table.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/analytics/components/analytics_tables/analytics_table.test.tsx @@ -5,13 +5,16 @@ * 2.0. */ -import { mountWithIntl } from '../../../../../__mocks__'; +import '../../../../../__mocks__/kea_logic'; +import '../../../../../__mocks__/react_router'; import '../../../../__mocks__/engine_logic.mock'; import React from 'react'; import { EuiBasicTable, EuiBadge, EuiEmptyPrompt } from '@elastic/eui'; +import { mountWithIntl } from '../../../../../test_helpers'; + import { runActionColumnTests } from './test_helpers/shared_columns_tests'; import { AnalyticsTable } from './'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/analytics/components/analytics_tables/query_clicks_table.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/analytics/components/analytics_tables/query_clicks_table.test.tsx index cc8f13299c57f..00cb12060822e 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/analytics/components/analytics_tables/query_clicks_table.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/analytics/components/analytics_tables/query_clicks_table.test.tsx @@ -5,13 +5,16 @@ * 2.0. */ -import { mountWithIntl } from '../../../../../__mocks__'; +import '../../../../../__mocks__/kea_logic'; +import '../../../../../__mocks__/react_router'; import '../../../../__mocks__/engine_logic.mock'; import React from 'react'; import { EuiBasicTable, EuiLink, EuiBadge, EuiEmptyPrompt } from '@elastic/eui'; +import { mountWithIntl } from '../../../../../test_helpers'; + import { QueryClicksTable } from './'; describe('QueryClicksTable', () => { diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/analytics/components/analytics_tables/recent_queries_table.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/analytics/components/analytics_tables/recent_queries_table.test.tsx index 6021363183098..6ec89751a62e9 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/analytics/components/analytics_tables/recent_queries_table.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/analytics/components/analytics_tables/recent_queries_table.test.tsx @@ -5,13 +5,16 @@ * 2.0. */ -import { mountWithIntl } from '../../../../../__mocks__'; +import '../../../../../__mocks__/kea_logic'; +import '../../../../../__mocks__/react_router'; import '../../../../__mocks__/engine_logic.mock'; import React from 'react'; import { EuiBasicTable, EuiBadge, EuiEmptyPrompt } from '@elastic/eui'; +import { mountWithIntl } from '../../../../../test_helpers'; + import { runActionColumnTests } from './test_helpers/shared_columns_tests'; import { RecentQueriesTable } from './'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/analytics/components/analytics_tables/test_helpers/shared_columns_tests.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/analytics/components/analytics_tables/test_helpers/shared_columns_tests.tsx index 95af7b52487d4..cb3d340debd04 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/analytics/components/analytics_tables/test_helpers/shared_columns_tests.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/analytics/components/analytics_tables/test_helpers/shared_columns_tests.tsx @@ -9,7 +9,7 @@ import { mockHttpValues, mockKibanaValues, mockFlashMessageHelpers, -} from '../../../../../../__mocks__'; +} from '../../../../../../__mocks__/kea_logic'; import '../../../../../__mocks__/engine_logic.mock'; import { ReactWrapper } from 'enzyme'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/analytics/views/analytics.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/analytics/views/analytics.test.tsx index 688d5dec1a958..8496be6223764 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/analytics/views/analytics.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/analytics/views/analytics.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { setMockValues } from '../../../../__mocks__'; +import { setMockValues } from '../../../../__mocks__/kea_logic'; import '../../../__mocks__/engine_logic.mock'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/analytics/views/query_detail.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/analytics/views/query_detail.test.tsx index 978f11ddfd5cd..a942918fa9c62 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/analytics/views/query_detail.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/analytics/views/query_detail.test.tsx @@ -5,11 +5,10 @@ * 2.0. */ -import '../../../../__mocks__/react_router_history.mock'; -import { setMockValues } from '../../../../__mocks__'; +import { setMockValues } from '../../../../__mocks__/kea_logic'; +import { mockUseParams } from '../../../../__mocks__/react_router'; import React from 'react'; -import { useParams } from 'react-router-dom'; import { shallow } from 'enzyme'; @@ -24,7 +23,7 @@ describe('QueryDetail', () => { const mockBreadcrumbs = ['Engines', 'some-engine', 'Analytics']; beforeEach(() => { - (useParams as jest.Mock).mockReturnValue({ query: 'some-query' }); + mockUseParams.mockReturnValue({ query: 'some-query' }); setMockValues({ totalQueriesForQuery: 100, @@ -50,7 +49,7 @@ describe('QueryDetail', () => { }); it('renders empty "" search titles correctly', () => { - (useParams as jest.Mock).mockReturnValue({ query: '""' }); + mockUseParams.mockReturnValue({ query: '""' }); const wrapper = shallow(); expect(wrapper.find(AnalyticsLayout).prop('title')).toEqual('""'); diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/analytics/views/recent_queries.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/analytics/views/recent_queries.test.tsx index 21d515a7b9795..20a25db3a7adf 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/analytics/views/recent_queries.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/analytics/views/recent_queries.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { setMockValues } from '../../../../__mocks__'; +import { setMockValues } from '../../../../__mocks__/kea_logic'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/analytics/views/top_queries.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/analytics/views/top_queries.test.tsx index 46b2b37958435..98362e42c5536 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/analytics/views/top_queries.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/analytics/views/top_queries.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { setMockValues } from '../../../../__mocks__'; +import { setMockValues } from '../../../../__mocks__/kea_logic'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/analytics/views/top_queries_no_clicks.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/analytics/views/top_queries_no_clicks.test.tsx index 83212160d1350..dfbda1c68ca84 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/analytics/views/top_queries_no_clicks.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/analytics/views/top_queries_no_clicks.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { setMockValues } from '../../../../__mocks__'; +import { setMockValues } from '../../../../__mocks__/kea_logic'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/analytics/views/top_queries_no_results.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/analytics/views/top_queries_no_results.test.tsx index dfc5b9c93ab64..60e33660f87d7 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/analytics/views/top_queries_no_results.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/analytics/views/top_queries_no_results.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { setMockValues } from '../../../../__mocks__'; +import { setMockValues } from '../../../../__mocks__/kea_logic'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/analytics/views/top_queries_with_clicks.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/analytics/views/top_queries_with_clicks.test.tsx index fb967ca06b387..b4c9f0fb40f71 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/analytics/views/top_queries_with_clicks.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/analytics/views/top_queries_with_clicks.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { setMockValues } from '../../../../__mocks__'; +import { setMockValues } from '../../../../__mocks__/kea_logic'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/api_logs/api_log/api_log_flyout.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/api_logs/api_log/api_log_flyout.test.tsx index 6bebeee80465c..3ff22479f4013 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/api_logs/api_log/api_log_flyout.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/api_logs/api_log/api_log_flyout.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { setMockValues, setMockActions } from '../../../../__mocks__'; +import { setMockValues, setMockActions } from '../../../../__mocks__/kea_logic'; import { mockApiLog } from '../__mocks__/api_log.mock'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/api_logs/api_log/api_log_logic.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/api_logs/api_log/api_log_logic.test.tsx index 2b7ca7510e8e1..e0d7c30bd0141 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/api_logs/api_log/api_log_logic.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/api_logs/api_log/api_log_logic.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { LogicMounter } from '../../../../__mocks__'; +import { LogicMounter } from '../../../../__mocks__/kea_logic'; import { mockApiLog } from '../__mocks__/api_log.mock'; import { ApiLogLogic } from './'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/api_logs/api_logs.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/api_logs/api_logs.test.tsx index cb29d92030ad7..c2a11ec06fa6a 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/api_logs/api_logs.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/api_logs/api_logs.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { setMockValues, setMockActions, rerender } from '../../../__mocks__'; +import { setMockValues, setMockActions } from '../../../__mocks__/kea_logic'; import '../../../__mocks__/shallow_useeffect.mock'; import '../../__mocks__/engine_logic.mock'; @@ -16,6 +16,7 @@ import { shallow } from 'enzyme'; import { EuiPageHeader } from '@elastic/eui'; import { Loading } from '../../../shared/loading'; +import { rerender } from '../../../test_helpers'; import { LogRetentionCallout, LogRetentionTooltip } from '../log_retention'; import { ApiLogsTable, NewApiEventsPrompt } from './components'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/api_logs/api_logs_logic.test.ts b/x-pack/plugins/enterprise_search/public/applications/app_search/components/api_logs/api_logs_logic.test.ts index 2eda4c6323fa5..5af5dca3e97dc 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/api_logs/api_logs_logic.test.ts +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/api_logs/api_logs_logic.test.ts @@ -5,7 +5,11 @@ * 2.0. */ -import { LogicMounter, mockHttpValues, mockFlashMessageHelpers } from '../../../__mocks__'; +import { + LogicMounter, + mockHttpValues, + mockFlashMessageHelpers, +} from '../../../__mocks__/kea_logic'; import { mockApiLog } from './__mocks__/api_log.mock'; import '../../__mocks__/engine_logic.mock'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/api_logs/components/api_logs_table.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/api_logs/components/api_logs_table.test.tsx index 780c198a9fac5..2a00cc6eb42bb 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/api_logs/components/api_logs_table.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/api_logs/components/api_logs_table.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { setMockValues, setMockActions, mountWithIntl } from '../../../../__mocks__'; +import { setMockValues, setMockActions } from '../../../../__mocks__/kea_logic'; // NOTE: We're mocking FormattedRelative here because it (currently) has // console warn issues, and it allows us to skip mocking dates @@ -21,6 +21,7 @@ import { shallow } from 'enzyme'; import { EuiBasicTable, EuiBadge, EuiHealth, EuiButtonEmpty, EuiEmptyPrompt } from '@elastic/eui'; import { DEFAULT_META } from '../../../../shared/constants'; +import { mountWithIntl } from '../../../../test_helpers'; import { ApiLogsTable } from './'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/api_logs/components/new_api_events_prompt.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/api_logs/components/new_api_events_prompt.test.tsx index 91d1962cd91db..5fd1d12f24842 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/api_logs/components/new_api_events_prompt.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/api_logs/components/new_api_events_prompt.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { setMockValues, setMockActions } from '../../../../__mocks__'; +import { setMockValues, setMockActions } from '../../../../__mocks__/kea_logic'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/crawler/crawler_landing.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/crawler/crawler_landing.test.tsx index 132579bad8bdc..045fd9ee7be1b 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/crawler/crawler_landing.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/crawler/crawler_landing.test.tsx @@ -4,7 +4,7 @@ * 2.0; you may not use this file except in compliance with the Elastic License * 2.0. */ -import { setMockValues } from '../../../__mocks__'; +import { setMockValues } from '../../../__mocks__/kea_logic'; import { mockEngineValues } from '../../__mocks__'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/crawler/crawler_overview.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/crawler/crawler_overview.test.tsx index eb30ae867b4b6..cc3fa21f73309 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/crawler/crawler_overview.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/crawler/crawler_overview.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { rerender, setMockActions, setMockValues } from '../../../__mocks__'; +import { setMockActions, setMockValues } from '../../../__mocks__/kea_logic'; import '../../../__mocks__/shallow_useeffect.mock'; import React from 'react'; @@ -15,6 +15,7 @@ import { shallow, ShallowWrapper } from 'enzyme'; import { EuiCode } from '@elastic/eui'; import { Loading } from '../../../shared/loading'; +import { rerender } from '../../../test_helpers'; import { CrawlerOverview } from './crawler_overview'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/crawler/crawler_overview_logic.test.ts b/x-pack/plugins/enterprise_search/public/applications/app_search/components/crawler/crawler_overview_logic.test.ts index 766f5dcfa02dc..f23322337766a 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/crawler/crawler_overview_logic.test.ts +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/crawler/crawler_overview_logic.test.ts @@ -5,7 +5,11 @@ * 2.0. */ -import { LogicMounter, mockHttpValues, mockFlashMessageHelpers } from '../../../__mocks__'; +import { + LogicMounter, + mockHttpValues, + mockFlashMessageHelpers, +} from '../../../__mocks__/kea_logic'; import '../../__mocks__/engine_logic.mock'; import { nextTick } from '@kbn/test/jest'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/crawler/crawler_router.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/crawler/crawler_router.test.tsx index 351f547447803..c11c656333010 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/crawler/crawler_router.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/crawler/crawler_router.test.tsx @@ -4,8 +4,8 @@ * 2.0; you may not use this file except in compliance with the Elastic License * 2.0. */ -import { setMockValues } from '../../../__mocks__'; +import { setMockValues } from '../../../__mocks__/kea_logic'; import { mockEngineValues } from '../../__mocks__'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/credentials/credentials.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/credentials/credentials.test.tsx index 3785873461f16..286658c011002 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/credentials/credentials.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/credentials/credentials.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { setMockValues, setMockActions } from '../../../__mocks__/kea.mock'; +import { setMockValues, setMockActions } from '../../../__mocks__/kea_logic'; import { unmountHandler } from '../../../__mocks__/shallow_useeffect.mock'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/credentials/credentials_flyout/body.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/credentials/credentials_flyout/body.test.tsx index 595bc1bcbb828..1ca6c0ce82855 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/credentials/credentials_flyout/body.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/credentials/credentials_flyout/body.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { setMockValues, setMockActions } from '../../../../__mocks__/kea.mock'; +import { setMockValues, setMockActions } from '../../../../__mocks__/kea_logic'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/credentials/credentials_flyout/footer.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/credentials/credentials_flyout/footer.test.tsx index 23e85b92bb8b4..d3312b5a1e369 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/credentials/credentials_flyout/footer.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/credentials/credentials_flyout/footer.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { setMockValues, setMockActions } from '../../../../__mocks__/kea.mock'; +import { setMockValues, setMockActions } from '../../../../__mocks__/kea_logic'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/credentials/credentials_flyout/form_components/key_engine_access.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/credentials/credentials_flyout/form_components/key_engine_access.test.tsx index 7247deb09f12b..d39ffb2bea206 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/credentials/credentials_flyout/form_components/key_engine_access.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/credentials/credentials_flyout/form_components/key_engine_access.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { setMockValues, setMockActions, rerender } from '../../../../../__mocks__'; +import { setMockValues, setMockActions } from '../../../../../__mocks__/kea_logic'; import React from 'react'; @@ -13,6 +13,8 @@ import { shallow } from 'enzyme'; import { EuiRadio, EuiCheckbox } from '@elastic/eui'; +import { rerender } from '../../../../../test_helpers'; + import { FormKeyEngineAccess, EngineSelection } from './key_engine_access'; describe('FormKeyEngineAccess', () => { diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/credentials/credentials_flyout/form_components/key_name.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/credentials/credentials_flyout/form_components/key_name.test.tsx index d54d0c89c90cb..a206cdef4a737 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/credentials/credentials_flyout/form_components/key_name.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/credentials/credentials_flyout/form_components/key_name.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { setMockValues, setMockActions } from '../../../../../__mocks__/kea.mock'; +import { setMockValues, setMockActions } from '../../../../../__mocks__/kea_logic'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/credentials/credentials_flyout/form_components/key_read_write_access.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/credentials/credentials_flyout/form_components/key_read_write_access.test.tsx index cf45576d691cf..6f52a27dd628d 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/credentials/credentials_flyout/form_components/key_read_write_access.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/credentials/credentials_flyout/form_components/key_read_write_access.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { setMockValues, setMockActions } from '../../../../../__mocks__/kea.mock'; +import { setMockValues, setMockActions } from '../../../../../__mocks__/kea_logic'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/credentials/credentials_flyout/form_components/key_type.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/credentials/credentials_flyout/form_components/key_type.test.tsx index 5de2c7fda53ca..9cd518be2aaa5 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/credentials/credentials_flyout/form_components/key_type.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/credentials/credentials_flyout/form_components/key_type.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { setMockValues, setMockActions } from '../../../../../__mocks__/kea.mock'; +import { setMockValues, setMockActions } from '../../../../../__mocks__/kea_logic'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/credentials/credentials_flyout/header.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/credentials/credentials_flyout/header.test.tsx index 8ee7f810c1fa5..019a6c7043fb0 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/credentials/credentials_flyout/header.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/credentials/credentials_flyout/header.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { setMockValues } from '../../../../__mocks__/kea.mock'; +import { setMockValues } from '../../../../__mocks__/kea_logic'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/credentials/credentials_flyout/index.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/credentials/credentials_flyout/index.test.tsx index 9932b8ca227b0..b86c1c592c4cd 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/credentials/credentials_flyout/index.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/credentials/credentials_flyout/index.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { setMockActions } from '../../../../__mocks__/kea.mock'; +import { setMockActions } from '../../../../__mocks__/kea_logic'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/credentials/credentials_list/credentials_list.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/credentials/credentials_list/credentials_list.test.tsx index 274bda56a2fc1..13dd77da40931 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/credentials/credentials_list/credentials_list.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/credentials/credentials_list/credentials_list.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { setMockValues, setMockActions } from '../../../../__mocks__/kea.mock'; +import { setMockValues, setMockActions } from '../../../../__mocks__/kea_logic'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/credentials/credentials_logic.test.ts b/x-pack/plugins/enterprise_search/public/applications/app_search/components/credentials/credentials_logic.test.ts index bf84b03e7603e..7192488e49746 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/credentials/credentials_logic.test.ts +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/credentials/credentials_logic.test.ts @@ -5,7 +5,11 @@ * 2.0. */ -import { LogicMounter, mockFlashMessageHelpers, mockHttpValues } from '../../../__mocks__'; +import { + LogicMounter, + mockFlashMessageHelpers, + mockHttpValues, +} from '../../../__mocks__/kea_logic'; import { nextTick } from '@kbn/test/jest'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/curations/curation/curation.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/curations/curation/curation.test.tsx index ad4ba100145d9..937acfd84ce83 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/curations/curation/curation.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/curations/curation/curation.test.tsx @@ -5,12 +5,11 @@ * 2.0. */ -import '../../../../__mocks__/react_router_history.mock'; import '../../../../__mocks__/shallow_useeffect.mock'; -import { setMockActions, setMockValues, rerender } from '../../../../__mocks__'; +import { setMockActions, setMockValues } from '../../../../__mocks__/kea_logic'; +import { mockUseParams } from '../../../../__mocks__/react_router'; import React from 'react'; -import { useParams } from 'react-router-dom'; import { shallow, ShallowWrapper } from 'enzyme'; @@ -18,6 +17,7 @@ import { EuiPageHeader } from '@elastic/eui'; import { SetAppSearchChrome as SetPageChrome } from '../../../../shared/kibana_chrome'; import { Loading } from '../../../../shared/loading'; +import { rerender } from '../../../../test_helpers'; jest.mock('./curation_logic', () => ({ CurationLogic: jest.fn() })); import { CurationLogic } from './curation_logic'; @@ -71,18 +71,18 @@ describe('Curation', () => { }); it('initializes CurationLogic with a curationId prop from URL param', () => { - (useParams as jest.Mock).mockReturnValueOnce({ curationId: 'hello-world' }); + mockUseParams.mockReturnValueOnce({ curationId: 'hello-world' }); shallow(); expect(CurationLogic).toHaveBeenCalledWith({ curationId: 'hello-world' }); }); it('calls loadCuration on page load & whenever the curationId URL param changes', () => { - (useParams as jest.Mock).mockReturnValueOnce({ curationId: 'cur-123456789' }); + mockUseParams.mockReturnValueOnce({ curationId: 'cur-123456789' }); const wrapper = shallow(); expect(actions.loadCuration).toHaveBeenCalledTimes(1); - (useParams as jest.Mock).mockReturnValueOnce({ curationId: 'cur-987654321' }); + mockUseParams.mockReturnValueOnce({ curationId: 'cur-987654321' }); rerender(wrapper); expect(actions.loadCuration).toHaveBeenCalledTimes(2); }); diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/curations/curation/curation_logic.test.ts b/x-pack/plugins/enterprise_search/public/applications/app_search/components/curations/curation/curation_logic.test.ts index 17f7cd7cd154e..db387f581b92e 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/curations/curation/curation_logic.test.ts +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/curations/curation/curation_logic.test.ts @@ -10,7 +10,7 @@ import { mockHttpValues, mockKibanaValues, mockFlashMessageHelpers, -} from '../../../../__mocks__'; +} from '../../../../__mocks__/kea_logic'; import '../../../__mocks__/engine_logic.mock'; import { nextTick } from '@kbn/test/jest'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/curations/curation/documents/hidden_documents.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/curations/curation/documents/hidden_documents.test.tsx index 7ffa45c285320..c2377d0109494 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/curations/curation/documents/hidden_documents.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/curations/curation/documents/hidden_documents.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { setMockValues, setMockActions } from '../../../../../__mocks__'; +import { setMockValues, setMockActions } from '../../../../../__mocks__/kea_logic'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/curations/curation/documents/organic_documents.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/curations/curation/documents/organic_documents.test.tsx index 2a83ecfcada44..0624d0063e57d 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/curations/curation/documents/organic_documents.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/curations/curation/documents/organic_documents.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { setMockValues, setMockActions } from '../../../../../__mocks__'; +import { setMockValues, setMockActions } from '../../../../../__mocks__/kea_logic'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/curations/curation/documents/promoted_documents.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/curations/curation/documents/promoted_documents.test.tsx index 7240a443b76e9..e0c6de973666c 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/curations/curation/documents/promoted_documents.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/curations/curation/documents/promoted_documents.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { setMockValues, setMockActions } from '../../../../../__mocks__'; +import { setMockValues, setMockActions } from '../../../../../__mocks__/kea_logic'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/curations/curation/queries/active_query_select.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/curations/curation/queries/active_query_select.test.tsx index 65e8dbc96b636..f27c7ef959b50 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/curations/curation/queries/active_query_select.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/curations/curation/queries/active_query_select.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { setMockValues, setMockActions } from '../../../../../__mocks__'; +import { setMockValues, setMockActions } from '../../../../../__mocks__/kea_logic'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/curations/curation/queries/manage_queries_modal.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/curations/curation/queries/manage_queries_modal.test.tsx index 7fe992cdd96e2..1ff34c5875a0c 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/curations/curation/queries/manage_queries_modal.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/curations/curation/queries/manage_queries_modal.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { setMockValues, setMockActions } from '../../../../../__mocks__'; +import { setMockValues, setMockActions } from '../../../../../__mocks__/kea_logic'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/curations/curation/results/add_result_button.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/curations/curation/results/add_result_button.test.tsx index 19fc7e1784d3d..53cefdd00c670 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/curations/curation/results/add_result_button.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/curations/curation/results/add_result_button.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { setMockActions } from '../../../../../__mocks__'; +import { setMockActions } from '../../../../../__mocks__/kea_logic'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/curations/curation/results/add_result_flyout.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/curations/curation/results/add_result_flyout.test.tsx index a0f178aca32b2..71469e4e3f8cb 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/curations/curation/results/add_result_flyout.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/curations/curation/results/add_result_flyout.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { setMockActions, setMockValues } from '../../../../../__mocks__'; +import { setMockActions, setMockValues } from '../../../../../__mocks__/kea_logic'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/curations/curation/results/add_result_logic.test.ts b/x-pack/plugins/enterprise_search/public/applications/app_search/components/curations/curation/results/add_result_logic.test.ts index e7007cdc093cb..f1013fa4a6dfb 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/curations/curation/results/add_result_logic.test.ts +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/curations/curation/results/add_result_logic.test.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { LogicMounter } from '../../../../../__mocks__'; +import { LogicMounter } from '../../../../../__mocks__/kea_logic'; import '../../../../__mocks__/engine_logic.mock'; import { AddResultLogic } from './'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/curations/curation/results/curation_result.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/curations/curation/results/curation_result.test.tsx index 460c0f4dfa44c..67a26f2ecd4b6 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/curations/curation/results/curation_result.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/curations/curation/results/curation_result.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { setMockValues } from '../../../../../__mocks__'; +import { setMockValues } from '../../../../../__mocks__/kea_logic'; import React from 'react'; import { DraggableProvidedDragHandleProps } from 'react-beautiful-dnd'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/curations/curations_logic.test.ts b/x-pack/plugins/enterprise_search/public/applications/app_search/components/curations/curations_logic.test.ts index c1031fc20bc15..f00f744f730ab 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/curations/curations_logic.test.ts +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/curations/curations_logic.test.ts @@ -10,7 +10,7 @@ import { mockHttpValues, mockKibanaValues, mockFlashMessageHelpers, -} from '../../../__mocks__'; +} from '../../../__mocks__/kea_logic'; import '../../__mocks__/engine_logic.mock'; import { nextTick } from '@kbn/test/jest'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/curations/views/curation_creation.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/curations/views/curation_creation.test.tsx index 258d0ec6231fc..ad306dfc73080 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/curations/views/curation_creation.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/curations/views/curation_creation.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { setMockActions } from '../../../../__mocks__'; +import { setMockActions } from '../../../../__mocks__/kea_logic'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/curations/views/curations.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/curations/views/curations.test.tsx index 1be21c97c623b..bcc402d6eea27 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/curations/views/curations.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/curations/views/curations.test.tsx @@ -5,12 +5,7 @@ * 2.0. */ -import { - mountWithIntl, - mockKibanaValues, - setMockActions, - setMockValues, -} from '../../../../__mocks__'; +import { mockKibanaValues, setMockActions, setMockValues } from '../../../../__mocks__/kea_logic'; import '../../../__mocks__/engine_logic.mock'; import React from 'react'; @@ -20,6 +15,7 @@ import { shallow, ReactWrapper } from 'enzyme'; import { EuiPageHeader, EuiBasicTable } from '@elastic/eui'; import { Loading } from '../../../../shared/loading'; +import { mountWithIntl } from '../../../../test_helpers'; import { EmptyState } from '../components'; import { Curations, CurationsTable } from './curations'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/document_creation/creation_mode_components/api_code_example.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/document_creation/creation_mode_components/api_code_example.test.tsx index 34afa9d1e39ed..b0cf40713142a 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/document_creation/creation_mode_components/api_code_example.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/document_creation/creation_mode_components/api_code_example.test.tsx @@ -6,7 +6,7 @@ */ import '../../../../__mocks__/enterprise_search_url.mock'; -import { setMockValues, setMockActions } from '../../../../__mocks__/kea.mock'; +import { setMockValues, setMockActions } from '../../../../__mocks__/kea_logic'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/document_creation/creation_mode_components/paste_json_text.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/document_creation/creation_mode_components/paste_json_text.test.tsx index 8b5b36094fbc6..863e87a28f40e 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/document_creation/creation_mode_components/paste_json_text.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/document_creation/creation_mode_components/paste_json_text.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { setMockValues, setMockActions, rerender } from '../../../../__mocks__'; +import { setMockValues, setMockActions } from '../../../../__mocks__/kea_logic'; import React from 'react'; @@ -13,6 +13,8 @@ import { shallow } from 'enzyme'; import { EuiTextArea, EuiButtonEmpty, EuiButton } from '@elastic/eui'; +import { rerender } from '../../../../test_helpers'; + import { Errors } from '../creation_response_components'; import { PasteJsonText, FlyoutHeader, FlyoutBody, FlyoutFooter } from './paste_json_text'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/document_creation/creation_mode_components/show_creation_modes.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/document_creation/creation_mode_components/show_creation_modes.test.tsx index 739580d039a36..1087e3d927559 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/document_creation/creation_mode_components/show_creation_modes.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/document_creation/creation_mode_components/show_creation_modes.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { setMockActions } from '../../../../__mocks__/kea.mock'; +import { setMockActions } from '../../../../__mocks__/kea_logic'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/document_creation/creation_mode_components/upload_json_file.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/document_creation/creation_mode_components/upload_json_file.test.tsx index 7dc8952a18688..9b8820434fad8 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/document_creation/creation_mode_components/upload_json_file.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/document_creation/creation_mode_components/upload_json_file.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { setMockValues, setMockActions, rerender } from '../../../../__mocks__'; +import { setMockValues, setMockActions } from '../../../../__mocks__/kea_logic'; import React from 'react'; @@ -13,6 +13,8 @@ import { shallow } from 'enzyme'; import { EuiFilePicker, EuiButtonEmpty, EuiButton } from '@elastic/eui'; +import { rerender } from '../../../../test_helpers'; + import { Errors } from '../creation_response_components'; import { UploadJsonFile, FlyoutHeader, FlyoutBody, FlyoutFooter } from './upload_json_file'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/document_creation/creation_response_components/errors.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/document_creation/creation_response_components/errors.test.tsx index f03989aeaf5a3..3a3e7fd66d314 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/document_creation/creation_response_components/errors.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/document_creation/creation_response_components/errors.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { setMockValues } from '../../../../__mocks__/kea.mock'; +import { setMockValues } from '../../../../__mocks__/kea_logic'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/document_creation/creation_response_components/summary.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/document_creation/creation_response_components/summary.test.tsx index f53f94322879c..39608c6e8f81d 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/document_creation/creation_response_components/summary.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/document_creation/creation_response_components/summary.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { setMockValues, setMockActions } from '../../../../__mocks__/kea.mock'; +import { setMockValues, setMockActions } from '../../../../__mocks__/kea_logic'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/document_creation/creation_response_components/summary_sections.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/document_creation/creation_response_components/summary_sections.test.tsx index 7eb9f3f46036d..7843b8bbf907b 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/document_creation/creation_response_components/summary_sections.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/document_creation/creation_response_components/summary_sections.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { setMockValues } from '../../../../__mocks__/kea.mock'; +import { setMockValues } from '../../../../__mocks__/kea_logic'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/document_creation/document_creation_buttons.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/document_creation/document_creation_buttons.test.tsx index 7cbcc6b17e047..f293a0050eac9 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/document_creation/document_creation_buttons.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/document_creation/document_creation_buttons.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { setMockActions } from '../../../__mocks__/kea.mock'; +import { setMockActions } from '../../../__mocks__/kea_logic'; import '../../__mocks__/engine_logic.mock'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/document_creation/document_creation_flyout.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/document_creation/document_creation_flyout.test.tsx index 66995b8d20dfe..3dc5d445930ba 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/document_creation/document_creation_flyout.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/document_creation/document_creation_flyout.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { setMockValues, setMockActions } from '../../../__mocks__/kea.mock'; +import { setMockValues, setMockActions } from '../../../__mocks__/kea_logic'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/document_creation/document_creation_logic.test.ts b/x-pack/plugins/enterprise_search/public/applications/app_search/components/document_creation/document_creation_logic.test.ts index 2c6cadf9a8ece..a75cb78536783 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/document_creation/document_creation_logic.test.ts +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/document_creation/document_creation_logic.test.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { LogicMounter, mockHttpValues } from '../../../__mocks__'; +import { LogicMounter, mockHttpValues } from '../../../__mocks__/kea_logic'; import dedent from 'dedent'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/documents/components/document_creation_button.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/documents/components/document_creation_button.test.tsx index a6ccdc180b415..e9b74a56d0e50 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/documents/components/document_creation_button.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/documents/components/document_creation_button.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { setMockActions } from '../../../../__mocks__/kea.mock'; +import { setMockActions } from '../../../../__mocks__/kea_logic'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/documents/document_detail.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/documents/document_detail.test.tsx index c4563b4357134..4aade8e61b085 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/documents/document_detail.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/documents/document_detail.test.tsx @@ -5,13 +5,12 @@ * 2.0. */ -import { setMockValues, setMockActions } from '../../../__mocks__/kea.mock'; +import { setMockValues, setMockActions } from '../../../__mocks__/kea_logic'; +import { mockUseParams } from '../../../__mocks__/react_router'; import { unmountHandler } from '../../../__mocks__/shallow_useeffect.mock'; -import '../../../__mocks__/react_router_history.mock'; import '../../__mocks__/engine_logic.mock'; import React from 'react'; -import { useParams } from 'react-router-dom'; import { shallow } from 'enzyme'; @@ -39,7 +38,7 @@ describe('DocumentDetail', () => { setMockValues(values); setMockActions(actions); - (useParams as jest.Mock).mockImplementationOnce(() => ({ + mockUseParams.mockImplementationOnce(() => ({ documentId: '1', })); }); diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/documents/document_detail_logic.test.ts b/x-pack/plugins/enterprise_search/public/applications/app_search/components/documents/document_detail_logic.test.ts index 565c3069788c0..a258dcd970c74 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/documents/document_detail_logic.test.ts +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/documents/document_detail_logic.test.ts @@ -10,7 +10,7 @@ import { mockHttpValues, mockKibanaValues, mockFlashMessageHelpers, -} from '../../../__mocks__'; +} from '../../../__mocks__/kea_logic'; import { mockEngineValues } from '../../__mocks__'; import { nextTick } from '@kbn/test/jest'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/documents/documents.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/documents/documents.test.tsx index 88f5b6a1c49e6..143ad3f55ff2f 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/documents/documents.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/documents/documents.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { setMockValues } from '../../../__mocks__/kea.mock'; +import { setMockValues } from '../../../__mocks__/kea_logic'; import '../../__mocks__/engine_logic.mock'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/documents/documents_logic.test.ts b/x-pack/plugins/enterprise_search/public/applications/app_search/components/documents/documents_logic.test.ts index c1d30a3cdd401..29b2c835f8260 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/documents/documents_logic.test.ts +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/documents/documents_logic.test.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { LogicMounter } from '../../../__mocks__/kea.mock'; +import { LogicMounter } from '../../../__mocks__/kea_logic'; import { DocumentsLogic } from './documents_logic'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/documents/search_experience/customization_modal.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/documents/search_experience/customization_modal.test.tsx index 332c5b822eb6d..536698ffe28f3 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/documents/search_experience/customization_modal.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/documents/search_experience/customization_modal.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { setMockValues, setMockActions } from '../../../../__mocks__'; +import { setMockValues, setMockActions } from '../../../../__mocks__/kea_logic'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/documents/search_experience/search_experience.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/documents/search_experience/search_experience.test.tsx index e5f2978e5ba92..a4d1a92ee45a4 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/documents/search_experience/search_experience.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/documents/search_experience/search_experience.test.tsx @@ -6,7 +6,7 @@ */ import '../../../../__mocks__/enterprise_search_url.mock'; -import { setMockValues } from '../../../../__mocks__'; +import { setMockValues } from '../../../../__mocks__/kea_logic'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/documents/search_experience/search_experience_content.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/documents/search_experience/search_experience_content.test.tsx index ea111402309b4..44a6da51ec8d6 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/documents/search_experience/search_experience_content.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/documents/search_experience/search_experience_content.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { setMockValues } from '../../../../__mocks__/kea.mock'; +import { setMockValues } from '../../../../__mocks__/kea_logic'; import { setMockSearchContextState } from './__mocks__/hooks.mock'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/engine/engine_logic.test.ts b/x-pack/plugins/enterprise_search/public/applications/app_search/components/engine/engine_logic.test.ts index 836265a037e16..2b60193d4f7d3 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/engine/engine_logic.test.ts +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/engine/engine_logic.test.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { LogicMounter, mockHttpValues } from '../../../__mocks__'; +import { LogicMounter, mockHttpValues } from '../../../__mocks__/kea_logic'; import { nextTick } from '@kbn/test/jest'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/engine/engine_nav.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/engine/engine_nav.test.tsx index d913e3921bf1b..c2b0a6a50fd06 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/engine/engine_nav.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/engine/engine_nav.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { setMockValues, rerender } from '../../../__mocks__'; +import { setMockValues } from '../../../__mocks__/kea_logic'; import { mockEngineValues } from '../../__mocks__'; import React from 'react'; @@ -14,6 +14,8 @@ import { shallow } from 'enzyme'; import { EuiBadge, EuiIcon } from '@elastic/eui'; +import { rerender } from '../../../test_helpers'; + import { EngineNav } from './engine_nav'; describe('EngineNav', () => { diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/engine/engine_router.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/engine/engine_router.test.tsx index 3eab209d706fa..b74c31adca438 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/engine/engine_router.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/engine/engine_router.test.tsx @@ -5,13 +5,17 @@ * 2.0. */ -import '../../../__mocks__/react_router_history.mock'; -import { mockFlashMessageHelpers, setMockValues, setMockActions } from '../../../__mocks__'; +import { + mockFlashMessageHelpers, + setMockValues, + setMockActions, +} from '../../../__mocks__/kea_logic'; +import { mockUseParams } from '../../../__mocks__/react_router'; import { unmountHandler } from '../../../__mocks__/shallow_useeffect.mock'; import { mockEngineValues } from '../../__mocks__'; import React from 'react'; -import { Switch, Redirect, useParams } from 'react-router-dom'; +import { Switch, Redirect } from 'react-router-dom'; import { shallow } from 'enzyme'; @@ -43,7 +47,7 @@ describe('EngineRouter', () => { beforeEach(() => { setMockValues(values); setMockActions(actions); - (useParams as jest.Mock).mockReturnValue({ engineName: 'some-engine' }); + mockUseParams.mockReturnValue({ engineName: 'some-engine' }); }); describe('useEffect', () => { @@ -87,7 +91,7 @@ describe('EngineRouter', () => { // any route views as they would be rendering with the wrong data. it('renders a loading component if the engine stored in state is stale', () => { setMockValues({ ...values, engineName: 'some-engine' }); - (useParams as jest.Mock).mockReturnValue({ engineName: 'some-new-engine' }); + mockUseParams.mockReturnValue({ engineName: 'some-new-engine' }); const wrapper = shallow(); expect(wrapper.find(Loading)).toHaveLength(1); }); diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/engine_creation/engine_creation.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/engine_creation/engine_creation.test.tsx index 9d1bbafc82662..b91e33d1c8a92 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/engine_creation/engine_creation.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/engine_creation/engine_creation.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { setMockActions, setMockValues } from '../../../__mocks__'; +import { setMockActions, setMockValues } from '../../../__mocks__/kea_logic'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/engine_creation/engine_creation_logic.test.ts b/x-pack/plugins/enterprise_search/public/applications/app_search/components/engine_creation/engine_creation_logic.test.ts index 6d5c4480e45f6..1e87b3ef21f03 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/engine_creation/engine_creation_logic.test.ts +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/engine_creation/engine_creation_logic.test.ts @@ -10,7 +10,7 @@ import { mockHttpValues, mockKibanaValues, mockFlashMessageHelpers, -} from '../../../__mocks__'; +} from '../../../__mocks__/kea_logic'; import { nextTick } from '@kbn/test/jest'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/engine_overview/components/recent_api_logs.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/engine_overview/components/recent_api_logs.test.tsx index 6f3ec806a438d..1281d8f23a7eb 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/engine_overview/components/recent_api_logs.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/engine_overview/components/recent_api_logs.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { setMockActions } from '../../../../__mocks__'; +import { setMockActions } from '../../../../__mocks__/kea_logic'; import '../../../../__mocks__/shallow_useeffect.mock'; import '../../../__mocks__/engine_logic.mock'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/engine_overview/components/total_charts.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/engine_overview/components/total_charts.test.tsx index 74ce770205ffe..b20b71487307d 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/engine_overview/components/total_charts.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/engine_overview/components/total_charts.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { setMockValues } from '../../../../__mocks__/kea.mock'; +import { setMockValues } from '../../../../__mocks__/kea_logic'; import '../../../__mocks__/engine_logic.mock'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/engine_overview/components/total_stats.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/engine_overview/components/total_stats.test.tsx index 7fcda61073c5b..28a63c5d36842 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/engine_overview/components/total_stats.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/engine_overview/components/total_stats.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { setMockValues } from '../../../../__mocks__/kea.mock'; +import { setMockValues } from '../../../../__mocks__/kea_logic'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/engine_overview/engine_overview.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/engine_overview/engine_overview.test.tsx index d2d69de72c110..a3b2f4cfd8b9f 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/engine_overview/engine_overview.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/engine_overview/engine_overview.test.tsx @@ -6,7 +6,7 @@ */ import '../../../__mocks__/shallow_useeffect.mock'; -import { setMockValues, setMockActions } from '../../../__mocks__/kea.mock'; +import { setMockValues, setMockActions } from '../../../__mocks__/kea_logic'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/engine_overview/engine_overview_logic.test.ts b/x-pack/plugins/enterprise_search/public/applications/app_search/components/engine_overview/engine_overview_logic.test.ts index b790edef43cc4..c9c1defd46032 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/engine_overview/engine_overview_logic.test.ts +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/engine_overview/engine_overview_logic.test.ts @@ -5,7 +5,11 @@ * 2.0. */ -import { LogicMounter, mockHttpValues, mockFlashMessageHelpers } from '../../../__mocks__'; +import { + LogicMounter, + mockHttpValues, + mockFlashMessageHelpers, +} from '../../../__mocks__/kea_logic'; jest.mock('../engine', () => ({ EngineLogic: { values: { engineName: 'some-engine' } }, diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/engines/components/empty_state.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/engines/components/empty_state.test.tsx index 222041c9f85a3..159a986096ae2 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/engines/components/empty_state.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/engines/components/empty_state.test.tsx @@ -5,8 +5,7 @@ * 2.0. */ -import '../../../../__mocks__/kea.mock'; -import { setMockValues, mockTelemetryActions } from '../../../../__mocks__'; +import { setMockValues, mockTelemetryActions } from '../../../../__mocks__/kea_logic'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/engines/components/header.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/engines/components/header.test.tsx index 8cb26713cb840..9b245a468b083 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/engines/components/header.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/engines/components/header.test.tsx @@ -6,7 +6,7 @@ */ import '../../../../__mocks__/enterprise_search_url.mock'; -import { mockTelemetryActions } from '../../../../__mocks__'; +import { mockTelemetryActions } from '../../../../__mocks__/kea_logic'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/engines/components/tables/engine_link_helpers.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/engines/components/tables/engine_link_helpers.test.tsx index 5d91c724068e7..1ddf6e40ce1ff 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/engines/components/tables/engine_link_helpers.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/engines/components/tables/engine_link_helpers.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { mockKibanaValues, mockTelemetryActions } from '../../../../../__mocks__'; +import { mockKibanaValues, mockTelemetryActions } from '../../../../../__mocks__/kea_logic'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/engines/components/tables/engines_table.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/engines/components/tables/engines_table.test.tsx index 8d3b4b2a5e6ca..b9369d019a2f8 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/engines/components/tables/engines_table.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/engines/components/tables/engines_table.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { mountWithIntl, setMockValues } from '../../../../../__mocks__'; +import { setMockValues } from '../../../../../__mocks__/kea_logic'; import '../../../../../__mocks__/enterprise_search_url.mock'; import './__mocks__/engines_logic.mock'; @@ -15,6 +15,8 @@ import { shallow } from 'enzyme'; import { EuiBasicTable } from '@elastic/eui'; +import { mountWithIntl } from '../../../../../test_helpers'; + import { EngineDetails } from '../../../engine/types'; import { EnginesTable } from './engines_table'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/engines/components/tables/meta_engines_table.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/engines/components/tables/meta_engines_table.test.tsx index 430539c10bbf3..fb258e1e3be8c 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/engines/components/tables/meta_engines_table.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/engines/components/tables/meta_engines_table.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { mountWithIntl, setMockValues } from '../../../../../__mocks__'; +import { setMockValues } from '../../../../../__mocks__/kea_logic'; import '../../../../../__mocks__/enterprise_search_url.mock'; import './__mocks__/engines_logic.mock'; @@ -15,6 +15,8 @@ import { shallow } from 'enzyme'; import { EuiBasicTable } from '@elastic/eui'; +import { mountWithIntl } from '../../../../../test_helpers'; + import { EngineDetails } from '../../../engine/types'; import { MetaEnginesTable } from './meta_engines_table'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/engines/components/tables/meta_engines_table_expanded_row.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/engines/components/tables/meta_engines_table_expanded_row.test.tsx index dcaa1a2b7c246..26c8c0fddcd11 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/engines/components/tables/meta_engines_table_expanded_row.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/engines/components/tables/meta_engines_table_expanded_row.test.tsx @@ -5,14 +5,14 @@ * 2.0. */ -import { mountWithIntl } from '../../../../../__mocks__'; - import React from 'react'; import { shallow } from 'enzyme'; import { EuiBasicTable, EuiHealth } from '@elastic/eui'; +import { mountWithIntl } from '../../../../../test_helpers'; + import { EngineDetails } from '../../../engine/types'; import { MetaEnginesTableExpandedRow } from './meta_engines_table_expanded_row'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/engines/components/tables/meta_engines_table_logic.test.ts b/x-pack/plugins/enterprise_search/public/applications/app_search/components/engines/components/tables/meta_engines_table_logic.test.ts index de1902c7cf748..3c0b9c4dc33f6 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/engines/components/tables/meta_engines_table_logic.test.ts +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/engines/components/tables/meta_engines_table_logic.test.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { LogicMounter } from '../../../../../__mocks__'; +import { LogicMounter } from '../../../../../__mocks__/kea_logic'; import { mockRecursivelyFetchEngines } from '../../../../__mocks__/recursively_fetch_engines.mock'; import { EngineDetails } from '../../../engine/types'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/engines/components/tables/test_helpers/shared_columns.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/engines/components/tables/test_helpers/shared_columns.tsx index 97e2057cea2d9..b46dfa7e19dd9 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/engines/components/tables/test_helpers/shared_columns.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/engines/components/tables/test_helpers/shared_columns.tsx @@ -5,13 +5,15 @@ * 2.0. */ -import { setMockValues, rerender } from '../../../../../../__mocks__'; +import { setMockValues } from '../../../../../../__mocks__/kea_logic'; import '../__mocks__/engines_logic.mock'; import { ShallowWrapper } from 'enzyme'; import { EuiBasicTable, EuiButtonIcon } from '@elastic/eui'; +import { rerender } from '../../../../../../test_helpers'; + import { EnginesLogic } from '../../../../engines'; import * as engineLinkHelpers from '../engine_link_helpers'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/engines/engines_logic.test.ts b/x-pack/plugins/enterprise_search/public/applications/app_search/components/engines/engines_logic.test.ts index a67e5bb9ae7dc..eb95d1ce148da 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/engines/engines_logic.test.ts +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/engines/engines_logic.test.ts @@ -5,7 +5,11 @@ * 2.0. */ -import { LogicMounter, mockHttpValues, mockFlashMessageHelpers } from '../../../__mocks__'; +import { + LogicMounter, + mockHttpValues, + mockFlashMessageHelpers, +} from '../../../__mocks__/kea_logic'; import { nextTick } from '@kbn/test/jest'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/engines/engines_overview.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/engines/engines_overview.test.tsx index b326a7d3ee075..27fe65fe518eb 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/engines/engines_overview.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/engines/engines_overview.test.tsx @@ -6,12 +6,14 @@ */ import '../../../__mocks__/shallow_useeffect.mock'; -import { setMockValues, setMockActions, rerender } from '../../../__mocks__'; +import { setMockValues, setMockActions } from '../../../__mocks__/kea_logic'; import React from 'react'; import { shallow, ShallowWrapper } from 'enzyme'; +import { rerender } from '../../../test_helpers'; + import { LoadingState, EmptyState } from './components'; import { EnginesTable } from './components/tables/engines_table'; import { MetaEnginesTable } from './components/tables/meta_engines_table'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/layout/kibana_header_actions.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/layout/kibana_header_actions.test.tsx index 096d858cd1191..d25e6ab27b099 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/layout/kibana_header_actions.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/layout/kibana_header_actions.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { setMockValues } from '../../../__mocks__'; +import { setMockValues } from '../../../__mocks__/kea_logic'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/log_retention/components/log_retention_callout.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/log_retention/components/log_retention_callout.test.tsx index fe022391d76b4..c6ccdc78b16f3 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/log_retention/components/log_retention_callout.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/log_retention/components/log_retention_callout.test.tsx @@ -6,7 +6,7 @@ */ import '../../../../__mocks__/shallow_useeffect.mock'; -import { setMockValues, setMockActions, mountWithIntl } from '../../../../__mocks__'; +import { setMockValues, setMockActions } from '../../../../__mocks__/kea_logic'; import React from 'react'; @@ -14,7 +14,9 @@ import { shallow } from 'enzyme'; import { EuiCallOut, EuiLink } from '@elastic/eui'; -import { LogRetentionOptions } from '../'; +import { mountWithIntl } from '../../../../test_helpers'; + +import { LogRetentionOptions } from '../index'; import { LogRetentionCallout } from './'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/log_retention/components/log_retention_tooltip.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/log_retention/components/log_retention_tooltip.test.tsx index 6b5693e4c301e..db5f058b28015 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/log_retention/components/log_retention_tooltip.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/log_retention/components/log_retention_tooltip.test.tsx @@ -6,7 +6,7 @@ */ import '../../../../__mocks__/shallow_useeffect.mock'; -import { setMockValues, setMockActions } from '../../../../__mocks__/kea.mock'; +import { setMockValues, setMockActions } from '../../../../__mocks__/kea_logic'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/log_retention/log_retention_logic.test.ts b/x-pack/plugins/enterprise_search/public/applications/app_search/components/log_retention/log_retention_logic.test.ts index 57f3f46fed92e..4e2382c23edbd 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/log_retention/log_retention_logic.test.ts +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/log_retention/log_retention_logic.test.ts @@ -5,7 +5,11 @@ * 2.0. */ -import { LogicMounter, mockHttpValues, mockFlashMessageHelpers } from '../../../__mocks__'; +import { + LogicMounter, + mockHttpValues, + mockFlashMessageHelpers, +} from '../../../__mocks__/kea_logic'; import { nextTick } from '@kbn/test/jest'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/log_retention/messaging/log_retention_message.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/log_retention/messaging/log_retention_message.test.tsx index cd71e37108927..ab221879367b3 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/log_retention/messaging/log_retention_message.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/log_retention/messaging/log_retention_message.test.tsx @@ -5,12 +5,14 @@ * 2.0. */ -import { setMockValues, mountWithIntl } from '../../../../__mocks__'; +import { setMockValues } from '../../../../__mocks__/kea_logic'; import React from 'react'; import { shallow } from 'enzyme'; +import { mountWithIntl } from '../../../../test_helpers'; + import { LogRetentionOptions } from '../types'; import { LogRetentionMessage } from './'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/meta_engine_creation/meta_engine_creation.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/meta_engine_creation/meta_engine_creation.test.tsx index a30f5bf77efad..fe7ea2d959289 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/meta_engine_creation/meta_engine_creation.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/meta_engine_creation/meta_engine_creation.test.tsx @@ -6,7 +6,7 @@ */ import '../../../__mocks__/shallow_useeffect.mock'; -import { setMockActions, setMockValues } from '../../../__mocks__'; +import { setMockActions, setMockValues } from '../../../__mocks__/kea_logic'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/meta_engine_creation/meta_engine_creation_logic.test.ts b/x-pack/plugins/enterprise_search/public/applications/app_search/components/meta_engine_creation/meta_engine_creation_logic.test.ts index d8968316d1b72..137a8afc5c4fe 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/meta_engine_creation/meta_engine_creation_logic.test.ts +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/meta_engine_creation/meta_engine_creation_logic.test.ts @@ -10,7 +10,7 @@ import { mockHttpValues, mockFlashMessageHelpers, mockKibanaValues, -} from '../../../__mocks__'; +} from '../../../__mocks__/kea_logic'; import { nextTick } from '@kbn/test/jest'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/multi_input_rows/multi_input_rows.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/multi_input_rows/multi_input_rows.test.tsx index 0b6f8b4a6d3d4..3b8e1c96ff504 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/multi_input_rows/multi_input_rows.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/multi_input_rows/multi_input_rows.test.tsx @@ -5,13 +5,15 @@ * 2.0. */ -import { setMockActions, setMockValues, rerender } from '../../../__mocks__'; +import { setMockActions, setMockValues } from '../../../__mocks__/kea_logic'; import '../../../__mocks__/shallow_useeffect.mock'; import React from 'react'; import { shallow } from 'enzyme'; +import { rerender } from '../../../test_helpers'; + import { InputRow } from './input_row'; jest.mock('./multi_input_rows_logic', () => ({ diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/multi_input_rows/multi_input_rows_logic.test.ts b/x-pack/plugins/enterprise_search/public/applications/app_search/components/multi_input_rows/multi_input_rows_logic.test.ts index 0e2d28a6fc3e1..de439349bd15f 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/multi_input_rows/multi_input_rows_logic.test.ts +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/multi_input_rows/multi_input_rows_logic.test.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { LogicMounter } from '../../../__mocks__'; +import { LogicMounter } from '../../../__mocks__/kea_logic'; import { Logic } from 'kea'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/query_tester/query_tester.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/query_tester/query_tester.test.tsx index 160be70cbbfc9..a9e2b7129c781 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/query_tester/query_tester.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/query_tester/query_tester.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { setMockValues, setMockActions } from '../../../__mocks__/kea.mock'; +import { setMockValues, setMockActions } from '../../../__mocks__/kea_logic'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/relevance_tuning/boosts/boost_item_content/boost_item_content.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/relevance_tuning/boosts/boost_item_content/boost_item_content.test.tsx index e21f46c6748dd..794c644f3d40b 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/relevance_tuning/boosts/boost_item_content/boost_item_content.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/relevance_tuning/boosts/boost_item_content/boost_item_content.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { setMockActions } from '../../../../../__mocks__/kea.mock'; +import { setMockActions } from '../../../../../__mocks__/kea_logic'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/relevance_tuning/boosts/boost_item_content/functional_boost_form.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/relevance_tuning/boosts/boost_item_content/functional_boost_form.test.tsx index feb4328e5adea..4a540e09287ed 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/relevance_tuning/boosts/boost_item_content/functional_boost_form.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/relevance_tuning/boosts/boost_item_content/functional_boost_form.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { setMockActions } from '../../../../../__mocks__/kea.mock'; +import { setMockActions } from '../../../../../__mocks__/kea_logic'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/relevance_tuning/boosts/boost_item_content/proximity_boost_form.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/relevance_tuning/boosts/boost_item_content/proximity_boost_form.test.tsx index 0ed914abb3ab5..776a21c5acb1b 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/relevance_tuning/boosts/boost_item_content/proximity_boost_form.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/relevance_tuning/boosts/boost_item_content/proximity_boost_form.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { setMockActions } from '../../../../../__mocks__/kea.mock'; +import { setMockActions } from '../../../../../__mocks__/kea_logic'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/relevance_tuning/boosts/boost_item_content/value_boost_form.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/relevance_tuning/boosts/boost_item_content/value_boost_form.test.tsx index 6f9284891e711..292be35055e37 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/relevance_tuning/boosts/boost_item_content/value_boost_form.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/relevance_tuning/boosts/boost_item_content/value_boost_form.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { setMockActions } from '../../../../../__mocks__/kea.mock'; +import { setMockActions } from '../../../../../__mocks__/kea_logic'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/relevance_tuning/boosts/boosts.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/relevance_tuning/boosts/boosts.test.tsx index c82efa906f676..a7c7002fbf273 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/relevance_tuning/boosts/boosts.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/relevance_tuning/boosts/boosts.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { setMockActions } from '../../../../__mocks__/kea.mock'; +import { setMockActions } from '../../../../__mocks__/kea_logic'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/relevance_tuning/relevance_tuning.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/relevance_tuning/relevance_tuning.test.tsx index 574d2ae02af99..092740ac5d3cc 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/relevance_tuning/relevance_tuning.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/relevance_tuning/relevance_tuning.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { setMockActions, setMockValues } from '../../../__mocks__/kea.mock'; +import { setMockActions, setMockValues } from '../../../__mocks__/kea_logic'; import '../../../__mocks__/shallow_useeffect.mock'; import '../../__mocks__/engine_logic.mock'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/relevance_tuning/relevance_tuning_callouts.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/relevance_tuning/relevance_tuning_callouts.test.tsx index 8ab706f5953fb..8384d07938678 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/relevance_tuning/relevance_tuning_callouts.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/relevance_tuning/relevance_tuning_callouts.test.tsx @@ -6,7 +6,7 @@ */ import '../../__mocks__/engine_logic.mock'; -import { setMockValues } from '../../../__mocks__/kea.mock'; +import { setMockValues } from '../../../__mocks__/kea_logic'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/relevance_tuning/relevance_tuning_form/relevance_tuning_form.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/relevance_tuning/relevance_tuning_form/relevance_tuning_form.test.tsx index a1a241b8856a5..d4052f23cfca4 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/relevance_tuning/relevance_tuning_form/relevance_tuning_form.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/relevance_tuning/relevance_tuning_form/relevance_tuning_form.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { setMockValues, setMockActions } from '../../../../__mocks__/kea.mock'; +import { setMockValues, setMockActions } from '../../../../__mocks__/kea_logic'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/relevance_tuning/relevance_tuning_form/relevance_tuning_item_content/text_search_toggle.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/relevance_tuning/relevance_tuning_form/relevance_tuning_item_content/text_search_toggle.test.tsx index f2d4f9c20a58d..85cf4af7a7b76 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/relevance_tuning/relevance_tuning_form/relevance_tuning_item_content/text_search_toggle.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/relevance_tuning/relevance_tuning_form/relevance_tuning_item_content/text_search_toggle.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { setMockActions } from '../../../../../__mocks__/kea.mock'; +import { setMockActions } from '../../../../../__mocks__/kea_logic'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/relevance_tuning/relevance_tuning_form/relevance_tuning_item_content/weight_slider.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/relevance_tuning/relevance_tuning_form/relevance_tuning_item_content/weight_slider.test.tsx index 21a112a4ea988..49c02ef8e94f2 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/relevance_tuning/relevance_tuning_form/relevance_tuning_item_content/weight_slider.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/relevance_tuning/relevance_tuning_form/relevance_tuning_item_content/weight_slider.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { setMockActions } from '../../../../../__mocks__/kea.mock'; +import { setMockActions } from '../../../../../__mocks__/kea_logic'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/relevance_tuning/relevance_tuning_layout.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/relevance_tuning/relevance_tuning_layout.test.tsx index 6f4333d94919b..20b1a16879234 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/relevance_tuning/relevance_tuning_layout.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/relevance_tuning/relevance_tuning_layout.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { setMockActions, setMockValues } from '../../../__mocks__/kea.mock'; +import { setMockActions, setMockValues } from '../../../__mocks__/kea_logic'; import '../../__mocks__/engine_logic.mock'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/relevance_tuning/relevance_tuning_logic.test.ts b/x-pack/plugins/enterprise_search/public/applications/app_search/components/relevance_tuning/relevance_tuning_logic.test.ts index 97030e08e2a9f..1d143ed0ca938 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/relevance_tuning/relevance_tuning_logic.test.ts +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/relevance_tuning/relevance_tuning_logic.test.ts @@ -5,7 +5,11 @@ * 2.0. */ -import { LogicMounter, mockFlashMessageHelpers, mockHttpValues } from '../../../__mocks__'; +import { + LogicMounter, + mockFlashMessageHelpers, + mockHttpValues, +} from '../../../__mocks__/kea_logic'; import { mockEngineValues, mockEngineActions } from '../../__mocks__'; import { nextTick } from '@kbn/test/jest'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/relevance_tuning/relevance_tuning_preview.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/relevance_tuning/relevance_tuning_preview.test.tsx index ec6458a14b346..b39faa6029436 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/relevance_tuning/relevance_tuning_preview.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/relevance_tuning/relevance_tuning_preview.test.tsx @@ -4,7 +4,7 @@ * 2.0; you may not use this file except in compliance with the Elastic License * 2.0. */ -import { setMockActions, setMockValues } from '../../../__mocks__/kea.mock'; +import { setMockActions, setMockValues } from '../../../__mocks__/kea_logic'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/result/result.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/result/result.test.tsx index 333cefecb99c8..1e361f113d883 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/result/result.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/result/result.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { mockKibanaValues } from '../../../__mocks__'; +import { mockKibanaValues } from '../../../__mocks__/kea_logic'; import React from 'react'; import { DraggableProvidedDragHandleProps } from 'react-beautiful-dnd'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/result_settings/query_performance/query_performance.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/result_settings/query_performance/query_performance.test.tsx index 0c62b783a47ff..604d94f915439 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/result_settings/query_performance/query_performance.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/result_settings/query_performance/query_performance.test.tsx @@ -4,7 +4,7 @@ * 2.0; you may not use this file except in compliance with the Elastic License * 2.0. */ -import { setMockValues } from '../../../../__mocks__/kea.mock'; +import { setMockValues } from '../../../../__mocks__/kea_logic'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/result_settings/result_settings.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/result_settings/result_settings.test.tsx index dd99dc6c505da..ec521b4959535 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/result_settings/result_settings.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/result_settings/result_settings.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { setMockValues, setMockActions } from '../../../__mocks__'; +import { setMockValues, setMockActions } from '../../../__mocks__/kea_logic'; import '../../../__mocks__/shallow_useeffect.mock'; import '../../__mocks__/engine_logic.mock'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/result_settings/result_settings_logic.test.ts b/x-pack/plugins/enterprise_search/public/applications/app_search/components/result_settings/result_settings_logic.test.ts index 6522d84aef156..5ce6fd9328917 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/result_settings/result_settings_logic.test.ts +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/result_settings/result_settings_logic.test.ts @@ -5,8 +5,11 @@ * 2.0. */ -import { LogicMounter, mockFlashMessageHelpers, mockHttpValues } from '../../../__mocks__'; - +import { + LogicMounter, + mockFlashMessageHelpers, + mockHttpValues, +} from '../../../__mocks__/kea_logic'; import { mockEngineValues } from '../../__mocks__'; import { omit } from 'lodash'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/result_settings/result_settings_table/disabled_fields_body.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/result_settings/result_settings_table/disabled_fields_body.test.tsx index db87ac20a4223..580bb4db76389 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/result_settings/result_settings_table/disabled_fields_body.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/result_settings/result_settings_table/disabled_fields_body.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { setMockValues } from '../../../../__mocks__'; +import { setMockValues } from '../../../../__mocks__/kea_logic'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/result_settings/result_settings_table/non_text_fields_body.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/result_settings/result_settings_table/non_text_fields_body.test.tsx index c99b8644812b9..8abb716183a9f 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/result_settings/result_settings_table/non_text_fields_body.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/result_settings/result_settings_table/non_text_fields_body.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { setMockValues, setMockActions } from '../../../../__mocks__/kea.mock'; +import { setMockValues, setMockActions } from '../../../../__mocks__/kea_logic'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/result_settings/result_settings_table/result_settings_table.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/result_settings/result_settings_table/result_settings_table.test.tsx index 151d436e59ea2..332b4a31895f4 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/result_settings/result_settings_table/result_settings_table.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/result_settings/result_settings_table/result_settings_table.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { setMockValues } from '../../../../__mocks__/kea.mock'; +import { setMockValues } from '../../../../__mocks__/kea_logic'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/result_settings/result_settings_table/text_fields_body.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/result_settings/result_settings_table/text_fields_body.test.tsx index 7be58a387fa69..6f2f4c9f9acbf 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/result_settings/result_settings_table/text_fields_body.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/result_settings/result_settings_table/text_fields_body.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { setMockValues, setMockActions } from '../../../../__mocks__/kea.mock'; +import { setMockValues, setMockActions } from '../../../../__mocks__/kea_logic'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/result_settings/sample_response/sample_response.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/result_settings/sample_response/sample_response.test.tsx index e324150a2d52a..964e466582d60 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/result_settings/sample_response/sample_response.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/result_settings/sample_response/sample_response.test.tsx @@ -6,7 +6,7 @@ */ import '../../../../__mocks__/shallow_useeffect.mock'; -import { setMockActions, setMockValues } from '../../../../__mocks__'; +import { setMockActions, setMockValues } from '../../../../__mocks__/kea_logic'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/result_settings/sample_response/sample_response_logic.test.ts b/x-pack/plugins/enterprise_search/public/applications/app_search/components/result_settings/sample_response/sample_response_logic.test.ts index 11f8a1089af9b..426934b95388e 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/result_settings/sample_response/sample_response_logic.test.ts +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/result_settings/sample_response/sample_response_logic.test.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { LogicMounter, mockHttpValues } from '../../../../__mocks__'; +import { LogicMounter, mockHttpValues } from '../../../../__mocks__/kea_logic'; import '../../../__mocks__/engine_logic.mock'; import { nextTick } from '@kbn/test/jest'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/role_mappings/role_mapping.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/role_mappings/role_mapping.test.tsx index b7ba254cc3d7d..0b7d4255fc323 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/role_mappings/role_mapping.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/role_mappings/role_mapping.test.tsx @@ -5,9 +5,10 @@ * 2.0. */ +import '../../../__mocks__/react_router'; import '../../../__mocks__/shallow_useeffect.mock'; import { DEFAULT_INITIAL_APP_DATA } from '../../../../../common/__mocks__'; -import { setMockActions, setMockValues } from '../../../__mocks__'; +import { setMockActions, setMockValues } from '../../../__mocks__/kea_logic'; import { engines } from '../../__mocks__/engines.mock'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/role_mappings/role_mappings.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/role_mappings/role_mappings.test.tsx index 9559df2c1f981..d7ce8053c71f0 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/role_mappings/role_mappings.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/role_mappings/role_mappings.test.tsx @@ -6,7 +6,7 @@ */ import '../../../__mocks__/shallow_useeffect.mock'; -import { setMockActions, setMockValues } from '../../../__mocks__'; +import { setMockActions, setMockValues } from '../../../__mocks__/kea_logic'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/role_mappings/role_mappings_logic.test.ts b/x-pack/plugins/enterprise_search/public/applications/app_search/components/role_mappings/role_mappings_logic.test.ts index 0faafcc7a299d..87e6ee62460fa 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/role_mappings/role_mappings_logic.test.ts +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/role_mappings/role_mappings_logic.test.ts @@ -5,8 +5,11 @@ * 2.0. */ -import { mockFlashMessageHelpers, mockHttpValues } from '../../../__mocks__'; -import { LogicMounter } from '../../../__mocks__/kea.mock'; +import { + LogicMounter, + mockFlashMessageHelpers, + mockHttpValues, +} from '../../../__mocks__/kea_logic'; import { engines } from '../../__mocks__/engines.mock'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/sample_engine_creation_cta/sample_engine_creation_cta.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/sample_engine_creation_cta/sample_engine_creation_cta.test.tsx index 992afe4356a07..ac25e887c2de0 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/sample_engine_creation_cta/sample_engine_creation_cta.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/sample_engine_creation_cta/sample_engine_creation_cta.test.tsx @@ -6,7 +6,7 @@ */ import '../../../__mocks__/enterprise_search_url.mock'; -import { setMockActions, setMockValues } from '../../../__mocks__'; +import { setMockActions, setMockValues } from '../../../__mocks__/kea_logic'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/sample_engine_creation_cta/sample_engine_creation_cta_logic.test.ts b/x-pack/plugins/enterprise_search/public/applications/app_search/components/sample_engine_creation_cta/sample_engine_creation_cta_logic.test.ts index 740c4df697d68..3400361144ca4 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/sample_engine_creation_cta/sample_engine_creation_cta_logic.test.ts +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/sample_engine_creation_cta/sample_engine_creation_cta_logic.test.ts @@ -10,7 +10,7 @@ import { mockHttpValues, mockKibanaValues, mockFlashMessageHelpers, -} from '../../../__mocks__'; +} from '../../../__mocks__/kea_logic'; import { nextTick } from '@kbn/test/jest'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/schema/components/meta_engines_conflicts_table.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/schema/components/meta_engines_conflicts_table.test.tsx index eb40d70e13ff8..5d2b5c8a8eacf 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/schema/components/meta_engines_conflicts_table.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/schema/components/meta_engines_conflicts_table.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { setMockValues } from '../../../../__mocks__'; +import { setMockValues } from '../../../../__mocks__/kea_logic'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/schema/components/meta_engines_schema_table.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/schema/components/meta_engines_schema_table.test.tsx index 7d377d5a92714..e4235336b1d4b 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/schema/components/meta_engines_schema_table.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/schema/components/meta_engines_schema_table.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { setMockValues } from '../../../../__mocks__'; +import { setMockValues } from '../../../../__mocks__/kea_logic'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/schema/components/schema_callouts.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/schema/components/schema_callouts.test.tsx index 5bb08a6c8859a..e259e67dd2e4e 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/schema/components/schema_callouts.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/schema/components/schema_callouts.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { setMockValues, setMockActions } from '../../../../__mocks__'; +import { setMockValues, setMockActions } from '../../../../__mocks__/kea_logic'; import '../../../__mocks__/engine_logic.mock'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/schema/components/schema_table.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/schema/components/schema_table.test.tsx index c8b0bb7ddbac5..366558556c6f9 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/schema/components/schema_table.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/schema/components/schema_table.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { setMockValues, setMockActions } from '../../../../__mocks__'; +import { setMockValues, setMockActions } from '../../../../__mocks__/kea_logic'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/schema/reindex_job/reindex_job.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/schema/reindex_job/reindex_job.test.tsx index 1755fbea5fb7b..e76ab60005231 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/schema/reindex_job/reindex_job.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/schema/reindex_job/reindex_job.test.tsx @@ -5,13 +5,12 @@ * 2.0. */ -import { setMockValues, setMockActions } from '../../../../__mocks__'; -import '../../../../__mocks__/react_router_history.mock'; +import { setMockValues, setMockActions } from '../../../../__mocks__/kea_logic'; +import { mockUseParams } from '../../../../__mocks__/react_router'; import '../../../../__mocks__/shallow_useeffect.mock'; import '../../../__mocks__/engine_logic.mock'; import React from 'react'; -import { useParams } from 'react-router-dom'; import { shallow } from 'enzyme'; @@ -38,7 +37,7 @@ describe('ReindexJob', () => { }; beforeEach(() => { - (useParams as jest.Mock).mockReturnValueOnce({ reindexJobId: 'abc1234567890' }); + mockUseParams.mockReturnValueOnce({ reindexJobId: 'abc1234567890' }); setMockValues(values); setMockActions(actions); }); diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/schema/reindex_job/reindex_job_logic.test.ts b/x-pack/plugins/enterprise_search/public/applications/app_search/components/schema/reindex_job/reindex_job_logic.test.ts index b872ad3c914c6..f01c735aeca8e 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/schema/reindex_job/reindex_job_logic.test.ts +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/schema/reindex_job/reindex_job_logic.test.ts @@ -5,7 +5,11 @@ * 2.0. */ -import { LogicMounter, mockFlashMessageHelpers, mockHttpValues } from '../../../../__mocks__'; +import { + LogicMounter, + mockFlashMessageHelpers, + mockHttpValues, +} from '../../../../__mocks__/kea_logic'; import '../../../__mocks__/engine_logic.mock'; import { nextTick } from '@kbn/test/jest'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/schema/schema_base_logic.test.ts b/x-pack/plugins/enterprise_search/public/applications/app_search/components/schema/schema_base_logic.test.ts index 2f5788278aa0b..684780d72a275 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/schema/schema_base_logic.test.ts +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/schema/schema_base_logic.test.ts @@ -5,7 +5,11 @@ * 2.0. */ -import { LogicMounter, mockFlashMessageHelpers, mockHttpValues } from '../../../__mocks__'; +import { + LogicMounter, + mockFlashMessageHelpers, + mockHttpValues, +} from '../../../__mocks__/kea_logic'; import '../../__mocks__/engine_logic.mock'; import { nextTick } from '@kbn/test/jest'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/schema/schema_logic.test.ts b/x-pack/plugins/enterprise_search/public/applications/app_search/components/schema/schema_logic.test.ts index 123f62af4eeba..7687296cf9f83 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/schema/schema_logic.test.ts +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/schema/schema_logic.test.ts @@ -5,7 +5,11 @@ * 2.0. */ -import { LogicMounter, mockFlashMessageHelpers, mockHttpValues } from '../../../__mocks__'; +import { + LogicMounter, + mockFlashMessageHelpers, + mockHttpValues, +} from '../../../__mocks__/kea_logic'; import { mockEngineActions } from '../../__mocks__/engine_logic.mock'; import { nextTick } from '@kbn/test/jest'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/schema/schema_meta_engine_logic.test.ts b/x-pack/plugins/enterprise_search/public/applications/app_search/components/schema/schema_meta_engine_logic.test.ts index f265fb2d74113..4e56b26902142 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/schema/schema_meta_engine_logic.test.ts +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/schema/schema_meta_engine_logic.test.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { LogicMounter } from '../../../__mocks__'; +import { LogicMounter } from '../../../__mocks__/kea_logic'; import { SchemaType } from '../../../shared/schema/types'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/schema/schema_router.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/schema/schema_router.test.tsx index 13a94c666509b..f1713c36045e9 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/schema/schema_router.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/schema/schema_router.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { setMockValues, rerender } from '../../../__mocks__'; +import { setMockValues } from '../../../__mocks__/kea_logic'; import '../../__mocks__/engine_logic.mock'; import React from 'react'; @@ -13,6 +13,8 @@ import { Route, Switch } from 'react-router-dom'; import { shallow } from 'enzyme'; +import { rerender } from '../../../test_helpers'; + import { ReindexJob } from './reindex_job'; import { Schema, MetaEngineSchema } from './views'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/schema/views/meta_engine_schema.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/schema/views/meta_engine_schema.test.tsx index b1322c148b577..1d677ad08db43 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/schema/views/meta_engine_schema.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/schema/views/meta_engine_schema.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { setMockValues, setMockActions } from '../../../../__mocks__'; +import { setMockValues, setMockActions } from '../../../../__mocks__/kea_logic'; import '../../../../__mocks__/shallow_useeffect.mock'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/schema/views/schema.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/schema/views/schema.test.tsx index 23d1480e5dca9..91ec8eda55fc3 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/schema/views/schema.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/schema/views/schema.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { setMockValues, setMockActions } from '../../../../__mocks__'; +import { setMockValues, setMockActions } from '../../../../__mocks__/kea_logic'; import '../../../../__mocks__/shallow_useeffect.mock'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/search/search_logic.test.ts b/x-pack/plugins/enterprise_search/public/applications/app_search/components/search/search_logic.test.ts index 784ebd0aad0cb..c0d81f87e3e02 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/search/search_logic.test.ts +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/search/search_logic.test.ts @@ -6,8 +6,11 @@ */ import '../../__mocks__/engine_logic.mock'; - -import { LogicMounter, mockHttpValues, mockFlashMessageHelpers } from '../../../__mocks__'; +import { + LogicMounter, + mockHttpValues, + mockFlashMessageHelpers, +} from '../../../__mocks__/kea_logic'; import { nextTick } from '@kbn/test/jest'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/search_ui/components/search_ui_form.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/search_ui/components/search_ui_form.test.tsx index 82b925f57f2df..944c99f7c61c2 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/search_ui/components/search_ui_form.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/search_ui/components/search_ui_form.test.tsx @@ -9,7 +9,7 @@ jest.mock('../utils', () => ({ generatePreviewUrl: jest.fn(), })); -import { setMockValues, setMockActions } from '../../../../__mocks__'; +import { setMockValues, setMockActions } from '../../../../__mocks__/kea_logic'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/search_ui/components/search_ui_graphic.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/search_ui/components/search_ui_graphic.test.tsx index 0326cef9a2455..056543fb5e748 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/search_ui/components/search_ui_graphic.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/search_ui/components/search_ui_graphic.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { setMockValues } from '../../../../__mocks__'; +import { setMockValues } from '../../../../__mocks__/kea_logic'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/search_ui/search_ui.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/search_ui/search_ui.test.tsx index 34c0669cc476e..edec376dd3edd 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/search_ui/search_ui.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/search_ui/search_ui.test.tsx @@ -8,7 +8,7 @@ import '../../../__mocks__/shallow_useeffect.mock'; import '../../__mocks__/engine_logic.mock'; -import { setMockActions } from '../../../__mocks__'; +import { setMockActions } from '../../../__mocks__/kea_logic'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/search_ui/search_ui_logic.test.ts b/x-pack/plugins/enterprise_search/public/applications/app_search/components/search_ui/search_ui_logic.test.ts index 2e29ac0d398a6..f615f9a4e2c72 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/search_ui/search_ui_logic.test.ts +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/search_ui/search_ui_logic.test.ts @@ -5,8 +5,11 @@ * 2.0. */ -import { LogicMounter, mockFlashMessageHelpers, mockHttpValues } from '../../../__mocks__'; - +import { + LogicMounter, + mockFlashMessageHelpers, + mockHttpValues, +} from '../../../__mocks__/kea_logic'; import { mockEngineValues } from '../../__mocks__'; import { nextTick } from '@kbn/test/jest'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/settings/log_retention/log_retention_confirmation_modal.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/settings/log_retention/log_retention_confirmation_modal.test.tsx index 494517a438372..fc20a9dbc5519 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/settings/log_retention/log_retention_confirmation_modal.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/settings/log_retention/log_retention_confirmation_modal.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { setMockActions, setMockValues } from '../../../../__mocks__'; +import { setMockActions, setMockValues } from '../../../../__mocks__/kea_logic'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/settings/log_retention/log_retention_panel.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/settings/log_retention/log_retention_panel.test.tsx index aee23e61e76fe..3f6bbe4307b57 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/settings/log_retention/log_retention_panel.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/settings/log_retention/log_retention_panel.test.tsx @@ -6,7 +6,7 @@ */ import '../../../../__mocks__/shallow_useeffect.mock'; -import { setMockActions, setMockValues } from '../../../../__mocks__'; +import { setMockActions, setMockValues } from '../../../../__mocks__/kea_logic'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/source_engines/components/add_source_engines_button.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/source_engines/components/add_source_engines_button.test.tsx index 43a4682849c78..fb214b267038f 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/source_engines/components/add_source_engines_button.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/source_engines/components/add_source_engines_button.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { setMockActions } from '../../../../__mocks__'; +import { setMockActions } from '../../../../__mocks__/kea_logic'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/source_engines/components/add_source_engines_modal.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/source_engines/components/add_source_engines_modal.test.tsx index 19c2f72ed6f52..b02a21ac45aed 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/source_engines/components/add_source_engines_modal.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/source_engines/components/add_source_engines_modal.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { setMockActions, setMockValues } from '../../../../__mocks__'; +import { setMockActions, setMockValues } from '../../../../__mocks__/kea_logic'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/source_engines/components/source_engines_table.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/source_engines/components/source_engines_table.test.tsx index 895c7ab35e86a..7638db403191a 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/source_engines/components/source_engines_table.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/source_engines/components/source_engines_table.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { mountWithIntl, setMockActions, setMockValues } from '../../../../__mocks__'; +import { setMockActions, setMockValues } from '../../../../__mocks__/kea_logic'; import React from 'react'; @@ -13,6 +13,8 @@ import { shallow } from 'enzyme'; import { EuiInMemoryTable, EuiButtonIcon } from '@elastic/eui'; +import { mountWithIntl } from '../../../../test_helpers'; + import { SourceEnginesTable } from './source_engines_table'; describe('SourceEnginesTable', () => { diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/source_engines/source_engines.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/source_engines/source_engines.test.tsx index 8cfcaeec97b87..9d2fe653150c3 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/source_engines/source_engines.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/source_engines/source_engines.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { setMockActions, setMockValues } from '../../../__mocks__'; +import { setMockActions, setMockValues } from '../../../__mocks__/kea_logic'; import '../../../__mocks__/shallow_useeffect.mock'; import '../../__mocks__/engine_logic.mock'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/source_engines/source_engines_logic.test.ts b/x-pack/plugins/enterprise_search/public/applications/app_search/components/source_engines/source_engines_logic.test.ts index 49886f1257a58..c39a25276a43c 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/source_engines/source_engines_logic.test.ts +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/source_engines/source_engines_logic.test.ts @@ -5,7 +5,11 @@ * 2.0. */ -import { LogicMounter, mockFlashMessageHelpers, mockHttpValues } from '../../../__mocks__'; +import { + LogicMounter, + mockFlashMessageHelpers, + mockHttpValues, +} from '../../../__mocks__/kea_logic'; import { mockRecursivelyFetchEngines } from '../../__mocks__'; import '../../__mocks__/engine_logic.mock'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/synonyms/components/synonym_card.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/synonyms/components/synonym_card.test.tsx index ccb28a86d67c9..7a1ba289865ee 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/synonyms/components/synonym_card.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/synonyms/components/synonym_card.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { setMockActions } from '../../../../__mocks__'; +import { setMockActions } from '../../../../__mocks__/kea_logic'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/synonyms/components/synonym_modal.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/synonyms/components/synonym_modal.test.tsx index dc2c6424bc2f9..15b74d1cdbca9 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/synonyms/components/synonym_modal.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/synonyms/components/synonym_modal.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { setMockValues, setMockActions } from '../../../../__mocks__'; +import { setMockValues, setMockActions } from '../../../../__mocks__/kea_logic'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/synonyms/synonyms.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/synonyms/synonyms.test.tsx index 7fb3745eb158e..c8f65c4bdbc6c 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/synonyms/synonyms.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/synonyms/synonyms.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { setMockValues, setMockActions, rerender } from '../../../__mocks__'; +import { setMockValues, setMockActions } from '../../../__mocks__/kea_logic'; import '../../../__mocks__/shallow_useeffect.mock'; import '../../__mocks__/engine_logic.mock'; @@ -16,6 +16,7 @@ import { shallow } from 'enzyme'; import { EuiPageHeader, EuiButton, EuiPagination } from '@elastic/eui'; import { Loading } from '../../../shared/loading'; +import { rerender } from '../../../test_helpers'; import { SynonymCard, SynonymModal, EmptyState } from './components'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/synonyms/synonyms_logic.test.ts b/x-pack/plugins/enterprise_search/public/applications/app_search/components/synonyms/synonyms_logic.test.ts index 037f3d1e6912a..630a069d0c5e8 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/synonyms/synonyms_logic.test.ts +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/synonyms/synonyms_logic.test.ts @@ -5,7 +5,11 @@ * 2.0. */ -import { LogicMounter, mockHttpValues, mockFlashMessageHelpers } from '../../../__mocks__'; +import { + LogicMounter, + mockHttpValues, + mockFlashMessageHelpers, +} from '../../../__mocks__/kea_logic'; import '../../__mocks__/engine_logic.mock'; import { nextTick } from '@kbn/test/jest'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/index.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/index.test.tsx index 08aab7af164e3..4d8ff80326715 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/index.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/index.test.tsx @@ -6,19 +6,21 @@ */ import { DEFAULT_INITIAL_APP_DATA } from '../../../common/__mocks__'; -import { setMockValues, rerender } from '../__mocks__'; +import { setMockValues } from '../__mocks__/kea_logic'; +import { mockUseRouteMatch } from '../__mocks__/react_router'; import '../__mocks__/shallow_useeffect.mock'; import '../__mocks__/enterprise_search_url.mock'; -import '../__mocks__/react_router_history.mock'; import React from 'react'; -import { Redirect, useRouteMatch } from 'react-router-dom'; +import { Redirect } from 'react-router-dom'; import { shallow, ShallowWrapper } from 'enzyme'; import { Layout, SideNav, SideNavLink } from '../shared/layout'; +import { rerender } from '../test_helpers'; + jest.mock('./app_logic', () => ({ AppLogic: jest.fn() })); import { AppLogic } from './app_logic'; @@ -184,14 +186,14 @@ describe('AppSearchNav', () => { const getEnginesLink = (wrapper: ShallowWrapper) => wrapper.find(SideNavLink).dive(); it('does not render the engine subnav on top-level routes', () => { - (useRouteMatch as jest.Mock).mockReturnValueOnce(false); + mockUseRouteMatch.mockReturnValueOnce(false); const wrapper = shallow(); expect(getEnginesLink(wrapper).find(EngineNav)).toHaveLength(0); }); it('renders the engine subnav if currently on an engine route', () => { - (useRouteMatch as jest.Mock).mockReturnValueOnce(true); + mockUseRouteMatch.mockReturnValueOnce(true); const wrapper = shallow(); expect(getEnginesLink(wrapper).find(EngineNav)).toHaveLength(1); diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/utils/encode_path_params/index.test.ts b/x-pack/plugins/enterprise_search/public/applications/app_search/utils/encode_path_params/index.test.ts index 88863e83f9b67..f7464d1861265 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/utils/encode_path_params/index.test.ts +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/utils/encode_path_params/index.test.ts @@ -5,8 +5,7 @@ * 2.0. */ -import '../../../__mocks__/react_router_history.mock'; -import { useParams } from 'react-router-dom'; +import { mockUseParams } from '../../../__mocks__/react_router'; import { encodePathParams, generateEncodedPath, useDecodedParams } from './'; @@ -38,7 +37,7 @@ describe('generateEncodedPath', () => { describe('useDecodedParams', () => { it('decodeURIComponent()s all object values from useParams()', () => { - (useParams as jest.Mock).mockReturnValue({ + mockUseParams.mockReturnValue({ someValue: 'hello%20world%3F%3F%3F', anotherValue: 'test!%40%23%24%25%5E%26*%5B%5D%2F%7C%3B%3A%22%3C%3E~%60', }); diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/utils/formatted_date_time/index.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/utils/formatted_date_time/index.test.tsx index 5137a60ffe59d..47d1fe6b69d56 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/utils/formatted_date_time/index.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/utils/formatted_date_time/index.test.tsx @@ -5,10 +5,10 @@ * 2.0. */ -import { mountWithIntl } from '../../../__mocks__'; - import React from 'react'; +import { mountWithIntl } from '../../../test_helpers'; + import { FormattedDateTime } from './'; describe('FormattedDateTime', () => { diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/utils/recursively_fetch_engines/index.test.ts b/x-pack/plugins/enterprise_search/public/applications/app_search/utils/recursively_fetch_engines/index.test.ts index 104f98e45a5f5..a73dd075115ee 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/utils/recursively_fetch_engines/index.test.ts +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/utils/recursively_fetch_engines/index.test.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { mockFlashMessageHelpers, mockHttpValues } from '../../../__mocks__'; +import { mockFlashMessageHelpers, mockHttpValues } from '../../../__mocks__/kea_logic'; import { nextTick } from '@kbn/test/jest'; diff --git a/x-pack/plugins/enterprise_search/public/applications/enterprise_search/components/license_callout/license_callout.test.tsx b/x-pack/plugins/enterprise_search/public/applications/enterprise_search/components/license_callout/license_callout.test.tsx index 26892f7cec7ae..0c77a0fbf6f5a 100644 --- a/x-pack/plugins/enterprise_search/public/applications/enterprise_search/components/license_callout/license_callout.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/enterprise_search/components/license_callout/license_callout.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { setMockValues } from '../../../__mocks__'; +import { setMockValues } from '../../../__mocks__/kea_logic'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/enterprise_search/components/product_card/product_card.test.tsx b/x-pack/plugins/enterprise_search/public/applications/enterprise_search/components/product_card/product_card.test.tsx index 8631e6e2a51d4..9d54a9f1725e9 100644 --- a/x-pack/plugins/enterprise_search/public/applications/enterprise_search/components/product_card/product_card.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/enterprise_search/components/product_card/product_card.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { setMockValues, mockTelemetryActions } from '../../../__mocks__'; +import { setMockValues, mockTelemetryActions } from '../../../__mocks__/kea_logic'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/enterprise_search/components/product_selector/product_selector.test.tsx b/x-pack/plugins/enterprise_search/public/applications/enterprise_search/components/product_selector/product_selector.test.tsx index 9c0f7c2bac94b..90e16fe2d22fa 100644 --- a/x-pack/plugins/enterprise_search/public/applications/enterprise_search/components/product_selector/product_selector.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/enterprise_search/components/product_selector/product_selector.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { setMockValues } from '../../../__mocks__/kea.mock'; +import { setMockValues } from '../../../__mocks__/kea_logic'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/enterprise_search/components/trial_callout/trial_callout.test.tsx b/x-pack/plugins/enterprise_search/public/applications/enterprise_search/components/trial_callout/trial_callout.test.tsx index 2ed2f9e43e9c4..72958acacb034 100644 --- a/x-pack/plugins/enterprise_search/public/applications/enterprise_search/components/trial_callout/trial_callout.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/enterprise_search/components/trial_callout/trial_callout.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { setMockValues } from '../../../__mocks__'; +import { setMockValues } from '../../../__mocks__/kea_logic'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/enterprise_search/index.test.tsx b/x-pack/plugins/enterprise_search/public/applications/enterprise_search/index.test.tsx index 2d8dbd55f4366..fbb3e58f198a7 100644 --- a/x-pack/plugins/enterprise_search/public/applications/enterprise_search/index.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/enterprise_search/index.test.tsx @@ -5,12 +5,14 @@ * 2.0. */ -import { setMockValues, rerender } from '../__mocks__'; +import { setMockValues } from '../__mocks__/kea_logic'; import React from 'react'; import { shallow } from 'enzyme'; +import { rerender } from '../test_helpers'; + import { ErrorConnecting } from './components/error_connecting'; import { ProductSelector } from './components/product_selector'; import { SetupGuide } from './components/setup_guide'; diff --git a/x-pack/plugins/enterprise_search/public/applications/shared/error_state/error_state_prompt.test.tsx b/x-pack/plugins/enterprise_search/public/applications/shared/error_state/error_state_prompt.test.tsx index d9d31f5a45d4b..e8f0816de5225 100644 --- a/x-pack/plugins/enterprise_search/public/applications/shared/error_state/error_state_prompt.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/shared/error_state/error_state_prompt.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import '../../__mocks__/kea.mock'; +import '../../__mocks__/kea_logic'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/shared/flash_messages/flash_messages.test.tsx b/x-pack/plugins/enterprise_search/public/applications/shared/flash_messages/flash_messages.test.tsx index 289dcc0137cb8..6f4f3853fa8c9 100644 --- a/x-pack/plugins/enterprise_search/public/applications/shared/flash_messages/flash_messages.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/shared/flash_messages/flash_messages.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { setMockValues, setMockActions } from '../../__mocks__/kea.mock'; +import { setMockValues, setMockActions } from '../../__mocks__/kea_logic'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/shared/flash_messages/flash_messages_logic.test.ts b/x-pack/plugins/enterprise_search/public/applications/shared/flash_messages/flash_messages_logic.test.ts index c7dc658dada74..19e236ac122f0 100644 --- a/x-pack/plugins/enterprise_search/public/applications/shared/flash_messages/flash_messages_logic.test.ts +++ b/x-pack/plugins/enterprise_search/public/applications/shared/flash_messages/flash_messages_logic.test.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { mockKibanaValues } from '../../__mocks__/kibana_logic.mock'; +import { mockKibanaValues } from '../../__mocks__/kea_logic/kibana_logic.mock'; import { resetContext } from 'kea'; diff --git a/x-pack/plugins/enterprise_search/public/applications/shared/flash_messages/handle_api_errors.test.ts b/x-pack/plugins/enterprise_search/public/applications/shared/flash_messages/handle_api_errors.test.ts index b6b0e23ce7d6a..b361e796b4f43 100644 --- a/x-pack/plugins/enterprise_search/public/applications/shared/flash_messages/handle_api_errors.test.ts +++ b/x-pack/plugins/enterprise_search/public/applications/shared/flash_messages/handle_api_errors.test.ts @@ -5,7 +5,7 @@ * 2.0. */ -import '../../__mocks__/kibana_logic.mock'; +import '../../__mocks__/kea_logic/kibana_logic.mock'; import { FlashMessagesLogic } from './flash_messages_logic'; diff --git a/x-pack/plugins/enterprise_search/public/applications/shared/flash_messages/set_message_helpers.test.ts b/x-pack/plugins/enterprise_search/public/applications/shared/flash_messages/set_message_helpers.test.ts index d22be32e038cb..6d56c7b202797 100644 --- a/x-pack/plugins/enterprise_search/public/applications/shared/flash_messages/set_message_helpers.test.ts +++ b/x-pack/plugins/enterprise_search/public/applications/shared/flash_messages/set_message_helpers.test.ts @@ -5,7 +5,7 @@ * 2.0. */ -import '../../__mocks__/kibana_logic.mock'; +import '../../__mocks__/kea_logic/kibana_logic.mock'; import { FlashMessagesLogic } from './flash_messages_logic'; import { diff --git a/x-pack/plugins/enterprise_search/public/applications/shared/kibana/kibana_logic.test.ts b/x-pack/plugins/enterprise_search/public/applications/shared/kibana/kibana_logic.test.ts index a5f54d16b2fad..4cc907c3de9e4 100644 --- a/x-pack/plugins/enterprise_search/public/applications/shared/kibana/kibana_logic.test.ts +++ b/x-pack/plugins/enterprise_search/public/applications/shared/kibana/kibana_logic.test.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { mockKibanaValues } from '../../__mocks__'; +import { mockKibanaValues } from '../../__mocks__/kea_logic'; import { resetContext } from 'kea'; diff --git a/x-pack/plugins/enterprise_search/public/applications/shared/kibana_chrome/generate_breadcrumbs.test.ts b/x-pack/plugins/enterprise_search/public/applications/shared/kibana_chrome/generate_breadcrumbs.test.ts index c05c4dcbdddc0..f5d10ba4bc00f 100644 --- a/x-pack/plugins/enterprise_search/public/applications/shared/kibana_chrome/generate_breadcrumbs.test.ts +++ b/x-pack/plugins/enterprise_search/public/applications/shared/kibana_chrome/generate_breadcrumbs.test.ts @@ -5,7 +5,8 @@ * 2.0. */ -import { setMockValues, mockKibanaValues, mockHistory } from '../../__mocks__'; +import { setMockValues, mockKibanaValues } from '../../__mocks__/kea_logic'; +import { mockHistory } from '../../__mocks__/react_router'; jest.mock('../react_router_helpers', () => ({ letBrowserHandleEvent: jest.fn(() => false), diff --git a/x-pack/plugins/enterprise_search/public/applications/shared/kibana_chrome/set_chrome.test.tsx b/x-pack/plugins/enterprise_search/public/applications/shared/kibana_chrome/set_chrome.test.tsx index c9743e6824018..d396aba895587 100644 --- a/x-pack/plugins/enterprise_search/public/applications/shared/kibana_chrome/set_chrome.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/shared/kibana_chrome/set_chrome.test.tsx @@ -6,7 +6,8 @@ */ import '../../__mocks__/shallow_useeffect.mock'; -import { setMockValues, mockKibanaValues, mockHistory } from '../../__mocks__'; +import { setMockValues, mockKibanaValues } from '../../__mocks__/kea_logic'; +import { mockHistory } from '../../__mocks__/react_router'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/shared/layout/side_nav.test.tsx b/x-pack/plugins/enterprise_search/public/applications/shared/layout/side_nav.test.tsx index 451b49738029d..244037d6e1382 100644 --- a/x-pack/plugins/enterprise_search/public/applications/shared/layout/side_nav.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/shared/layout/side_nav.test.tsx @@ -5,10 +5,9 @@ * 2.0. */ -import '../../__mocks__/react_router_history.mock'; +import { mockLocation } from '../../__mocks__/react_router'; import React from 'react'; -import { useLocation } from 'react-router-dom'; import { shallow } from 'enzyme'; @@ -63,7 +62,7 @@ describe('SideNavLink', () => { }); it('sets an active class if the current path matches the nav link', () => { - (useLocation as jest.Mock).mockImplementationOnce(() => ({ pathname: '/test/' })); + mockLocation.pathname = '/test/'; const wrapper = shallow(Link); @@ -71,7 +70,7 @@ describe('SideNavLink', () => { }); it('sets an active class if the current path is / and the link isRoot', () => { - (useLocation as jest.Mock).mockImplementationOnce(() => ({ pathname: '/' })); + mockLocation.pathname = '/'; const wrapper = shallow( @@ -111,7 +110,7 @@ describe('SideNavLink', () => { describe('shouldShowActiveForSubroutes', () => { it("won't set an active class when route is a subroute of 'to'", () => { - (useLocation as jest.Mock).mockImplementationOnce(() => ({ pathname: '/documents/1234' })); + mockLocation.pathname = '/documents/1234'; const wrapper = shallow( @@ -123,7 +122,7 @@ describe('SideNavLink', () => { }); it('sets an active class if the current path is a subRoute of "to", and shouldShowActiveForSubroutes is true', () => { - (useLocation as jest.Mock).mockImplementationOnce(() => ({ pathname: '/documents/1234' })); + mockLocation.pathname = '/documents/1234'; const wrapper = shallow( diff --git a/x-pack/plugins/enterprise_search/public/applications/shared/not_found/not_found.test.tsx b/x-pack/plugins/enterprise_search/public/applications/shared/not_found/not_found.test.tsx index 7e75b2b47bb7a..1561224a26e42 100644 --- a/x-pack/plugins/enterprise_search/public/applications/shared/not_found/not_found.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/shared/not_found/not_found.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { setMockValues } from '../../__mocks__/kea.mock'; +import { setMockValues } from '../../__mocks__/kea_logic'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/shared/react_router_helpers/create_href.test.ts b/x-pack/plugins/enterprise_search/public/applications/shared/react_router_helpers/create_href.test.ts index fe2973cfdee32..2ffe87279d44f 100644 --- a/x-pack/plugins/enterprise_search/public/applications/shared/react_router_helpers/create_href.test.ts +++ b/x-pack/plugins/enterprise_search/public/applications/shared/react_router_helpers/create_href.test.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { mockHistory } from '../../__mocks__'; +import { mockHistory } from '../../__mocks__/react_router'; import { httpServiceMock } from 'src/core/public/mocks'; diff --git a/x-pack/plugins/enterprise_search/public/applications/shared/react_router_helpers/eui_components.test.tsx b/x-pack/plugins/enterprise_search/public/applications/shared/react_router_helpers/eui_components.test.tsx index 75639ffeb9d6b..7fded20cdd87e 100644 --- a/x-pack/plugins/enterprise_search/public/applications/shared/react_router_helpers/eui_components.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/shared/react_router_helpers/eui_components.test.tsx @@ -5,9 +5,8 @@ * 2.0. */ -import '../../__mocks__/kea.mock'; - -import { mockKibanaValues, mockHistory } from '../../__mocks__'; +import { mockKibanaValues } from '../../__mocks__/kea_logic'; +import { mockHistory } from '../../__mocks__/react_router'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/shared/setup_guide/cloud/instructions.test.tsx b/x-pack/plugins/enterprise_search/public/applications/shared/setup_guide/cloud/instructions.test.tsx index 0136f9745c322..58b6bc8a6c485 100644 --- a/x-pack/plugins/enterprise_search/public/applications/shared/setup_guide/cloud/instructions.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/shared/setup_guide/cloud/instructions.test.tsx @@ -5,14 +5,14 @@ * 2.0. */ -import { mountWithIntl } from '../../../__mocks__'; - import React from 'react'; import { shallow } from 'enzyme'; import { EuiSteps, EuiLink } from '@elastic/eui'; +import { mountWithIntl } from '../../../test_helpers'; + import { CloudSetupInstructions } from './instructions'; describe('CloudSetupInstructions', () => { diff --git a/x-pack/plugins/enterprise_search/public/applications/shared/setup_guide/instructions.test.tsx b/x-pack/plugins/enterprise_search/public/applications/shared/setup_guide/instructions.test.tsx index fd31ca720b82b..9f65e6b599a98 100644 --- a/x-pack/plugins/enterprise_search/public/applications/shared/setup_guide/instructions.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/shared/setup_guide/instructions.test.tsx @@ -5,14 +5,14 @@ * 2.0. */ -import { mountWithIntl } from '../../__mocks__'; - import React from 'react'; import { shallow } from 'enzyme'; import { EuiSteps, EuiLink } from '@elastic/eui'; +import { mountWithIntl } from '../../test_helpers'; + import { SetupInstructions } from './instructions'; describe('SetupInstructions', () => { diff --git a/x-pack/plugins/enterprise_search/public/applications/shared/setup_guide/setup_guide.test.tsx b/x-pack/plugins/enterprise_search/public/applications/shared/setup_guide/setup_guide.test.tsx index 90ddddd7d20aa..e33b9d29689c4 100644 --- a/x-pack/plugins/enterprise_search/public/applications/shared/setup_guide/setup_guide.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/shared/setup_guide/setup_guide.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { setMockValues, rerender } from '../../__mocks__'; +import { setMockValues } from '../../__mocks__/kea_logic'; import React from 'react'; @@ -13,6 +13,8 @@ import { shallow, ShallowWrapper } from 'enzyme'; import { EuiIcon } from '@elastic/eui'; +import { rerender } from '../../test_helpers'; + import { CloudSetupInstructions } from './cloud/instructions'; import { SetupInstructions } from './instructions'; diff --git a/x-pack/plugins/enterprise_search/public/applications/shared/telemetry/send_telemetry.test.tsx b/x-pack/plugins/enterprise_search/public/applications/shared/telemetry/send_telemetry.test.tsx index 5fc8074d0a4d7..bd9b7fb5bfbe3 100644 --- a/x-pack/plugins/enterprise_search/public/applications/shared/telemetry/send_telemetry.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/shared/telemetry/send_telemetry.test.tsx @@ -6,7 +6,7 @@ */ import '../../__mocks__/shallow_useeffect.mock'; -import { mockTelemetryActions } from '../../__mocks__'; +import { mockTelemetryActions } from '../../__mocks__/kea_logic'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/shared/telemetry/telemetry_logic.test.ts b/x-pack/plugins/enterprise_search/public/applications/shared/telemetry/telemetry_logic.test.ts index e516daedc1ba6..d80750d068f2b 100644 --- a/x-pack/plugins/enterprise_search/public/applications/shared/telemetry/telemetry_logic.test.ts +++ b/x-pack/plugins/enterprise_search/public/applications/shared/telemetry/telemetry_logic.test.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { LogicMounter, mockHttpValues } from '../../__mocks__'; +import { LogicMounter, mockHttpValues } from '../../__mocks__/kea_logic'; import { JSON_HEADER as headers } from '../../../../common/constants'; diff --git a/x-pack/plugins/enterprise_search/public/applications/__mocks__/enzyme_rerender.mock.ts b/x-pack/plugins/enterprise_search/public/applications/test_helpers/enzyme_rerender.ts similarity index 100% rename from x-pack/plugins/enterprise_search/public/applications/__mocks__/enzyme_rerender.mock.ts rename to x-pack/plugins/enterprise_search/public/applications/test_helpers/enzyme_rerender.ts diff --git a/x-pack/plugins/enterprise_search/public/applications/__mocks__/expected_async_error.ts b/x-pack/plugins/enterprise_search/public/applications/test_helpers/expected_async_error.ts similarity index 100% rename from x-pack/plugins/enterprise_search/public/applications/__mocks__/expected_async_error.ts rename to x-pack/plugins/enterprise_search/public/applications/test_helpers/expected_async_error.ts diff --git a/x-pack/plugins/enterprise_search/public/applications/test_helpers/index.ts b/x-pack/plugins/enterprise_search/public/applications/test_helpers/index.ts new file mode 100644 index 0000000000000..e34ff763637b5 --- /dev/null +++ b/x-pack/plugins/enterprise_search/public/applications/test_helpers/index.ts @@ -0,0 +1,15 @@ +/* + * 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. + */ + +// Enzyme helpers +export { mountAsync } from './mount_async'; +export { mountWithIntl } from './mount_with_i18n'; +export { shallowWithIntl } from './shallow_with_i18n'; +export { rerender } from './enzyme_rerender'; + +// Misc +export { expectedAsyncError } from './expected_async_error'; diff --git a/x-pack/plugins/enterprise_search/public/applications/__mocks__/mount_async.mock.tsx b/x-pack/plugins/enterprise_search/public/applications/test_helpers/mount_async.tsx similarity index 96% rename from x-pack/plugins/enterprise_search/public/applications/__mocks__/mount_async.mock.tsx rename to x-pack/plugins/enterprise_search/public/applications/test_helpers/mount_async.tsx index 886effcd54057..cd66c0ae85a91 100644 --- a/x-pack/plugins/enterprise_search/public/applications/__mocks__/mount_async.mock.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/test_helpers/mount_async.tsx @@ -5,13 +5,13 @@ * 2.0. */ -import { mountWithIntl } from './mount_with_i18n.mock'; - import React from 'react'; import { mount, ReactWrapper } from 'enzyme'; import { act } from 'react-dom/test-utils'; +import { mountWithIntl } from './mount_with_i18n'; + /** * This helper is intended for components that have async effects * (e.g. http fetches) on mount. It mostly adds act/update boilerplate diff --git a/x-pack/plugins/enterprise_search/public/applications/__mocks__/mount_with_i18n.mock.tsx b/x-pack/plugins/enterprise_search/public/applications/test_helpers/mount_with_i18n.tsx similarity index 100% rename from x-pack/plugins/enterprise_search/public/applications/__mocks__/mount_with_i18n.mock.tsx rename to x-pack/plugins/enterprise_search/public/applications/test_helpers/mount_with_i18n.tsx diff --git a/x-pack/plugins/enterprise_search/public/applications/__mocks__/shallow_with_i18n.mock.tsx b/x-pack/plugins/enterprise_search/public/applications/test_helpers/shallow_with_i18n.tsx similarity index 100% rename from x-pack/plugins/enterprise_search/public/applications/__mocks__/shallow_with_i18n.mock.tsx rename to x-pack/plugins/enterprise_search/public/applications/test_helpers/shallow_with_i18n.tsx diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/app_logic.test.ts b/x-pack/plugins/enterprise_search/public/applications/workplace_search/app_logic.test.ts index 34e67acc870ee..b2cc835da4ecd 100644 --- a/x-pack/plugins/enterprise_search/public/applications/workplace_search/app_logic.test.ts +++ b/x-pack/plugins/enterprise_search/public/applications/workplace_search/app_logic.test.ts @@ -6,7 +6,7 @@ */ import { DEFAULT_INITIAL_APP_DATA } from '../../../common/__mocks__'; -import { LogicMounter } from '../__mocks__'; +import { LogicMounter } from '../__mocks__/kea_logic'; import { AppLogic } from './app_logic'; diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/components/layout/account_header/account_header.test.tsx b/x-pack/plugins/enterprise_search/public/applications/workplace_search/components/layout/account_header/account_header.test.tsx index e8035f01a9405..9df11ab2308da 100644 --- a/x-pack/plugins/enterprise_search/public/applications/workplace_search/components/layout/account_header/account_header.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/workplace_search/components/layout/account_header/account_header.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { setMockValues } from '../../../../__mocks__'; +import { setMockValues } from '../../../../__mocks__/kea_logic'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/components/shared/product_button/product_button.test.tsx b/x-pack/plugins/enterprise_search/public/applications/workplace_search/components/shared/product_button/product_button.test.tsx index 0bced6a7fc4e0..e605e914df061 100644 --- a/x-pack/plugins/enterprise_search/public/applications/workplace_search/components/shared/product_button/product_button.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/workplace_search/components/shared/product_button/product_button.test.tsx @@ -5,8 +5,7 @@ * 2.0. */ -import '../../../../__mocks__/kea.mock'; -import { mockTelemetryActions } from '../../../../__mocks__'; +import { mockTelemetryActions } from '../../../../__mocks__/kea_logic'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/index.test.tsx b/x-pack/plugins/enterprise_search/public/applications/workplace_search/index.test.tsx index 2c2859e8f4427..fb0ea82220640 100644 --- a/x-pack/plugins/enterprise_search/public/applications/workplace_search/index.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/workplace_search/index.test.tsx @@ -5,8 +5,9 @@ * 2.0. */ +import '../__mocks__/react_router'; import '../__mocks__/shallow_useeffect.mock'; -import { setMockValues, setMockActions, mockKibanaValues } from '../__mocks__'; +import { setMockValues, setMockActions, mockKibanaValues } from '../__mocks__/kea_logic'; import React from 'react'; import { Redirect } from 'react-router-dom'; diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/add_source/add_source.test.tsx b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/add_source/add_source.test.tsx index 0ee872f7cfe8a..92cbfcf6eeafe 100644 --- a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/add_source/add_source.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/add_source/add_source.test.tsx @@ -6,7 +6,11 @@ */ import '../../../../../__mocks__/shallow_useeffect.mock'; -import { mockKibanaValues, setMockActions, setMockValues } from '../../../../../__mocks__'; +import { + mockKibanaValues, + setMockActions, + setMockValues, +} from '../../../../../__mocks__/kea_logic'; import { sourceConfigData } from '../../../../__mocks__/content_sources.mock'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/add_source/add_source_list.test.tsx b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/add_source/add_source_list.test.tsx index 90da349ea4f27..6bf71cd73ec35 100644 --- a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/add_source/add_source_list.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/add_source/add_source_list.test.tsx @@ -6,7 +6,7 @@ */ import '../../../../../__mocks__/shallow_useeffect.mock'; -import { setMockActions, setMockValues } from '../../../../../__mocks__'; +import { setMockActions, setMockValues } from '../../../../../__mocks__/kea_logic'; import { contentSources, configuredSources, diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/add_source/add_source_logic.test.ts b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/add_source/add_source_logic.test.ts index b52b354a6b115..fcaa847c47f3e 100644 --- a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/add_source/add_source_logic.test.ts +++ b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/add_source/add_source_logic.test.ts @@ -10,7 +10,7 @@ import { mockFlashMessageHelpers, mockHttpValues, mockKibanaValues, -} from '../../../../../__mocks__'; +} from '../../../../../__mocks__/kea_logic'; import { sourceConfigData } from '../../../../__mocks__/content_sources.mock'; import { nextTick } from '@kbn/test/jest'; diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/add_source/available_sources_list.test.tsx b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/add_source/available_sources_list.test.tsx index fcb55f24ddb03..26a3d38f247ea 100644 --- a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/add_source/available_sources_list.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/add_source/available_sources_list.test.tsx @@ -6,7 +6,7 @@ */ import '../../../../../__mocks__/shallow_useeffect.mock'; -import { setMockValues } from '../../../../../__mocks__'; +import { setMockValues } from '../../../../../__mocks__/kea_logic'; import { mergedAvailableSources } from '../../../../__mocks__/content_sources.mock'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/add_source/configure_custom.test.tsx b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/add_source/configure_custom.test.tsx index 099989255bf47..6c0d87b7696ec 100644 --- a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/add_source/configure_custom.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/add_source/configure_custom.test.tsx @@ -6,7 +6,7 @@ */ import '../../../../../__mocks__/shallow_useeffect.mock'; -import { setMockActions, setMockValues } from '../../../../../__mocks__'; +import { setMockActions, setMockValues } from '../../../../../__mocks__/kea_logic'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/add_source/configure_oauth.test.tsx b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/add_source/configure_oauth.test.tsx index 533dfcda70db1..332456cae99ad 100644 --- a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/add_source/configure_oauth.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/add_source/configure_oauth.test.tsx @@ -6,7 +6,7 @@ */ import '../../../../../__mocks__/shallow_useeffect.mock'; -import { setMockActions, setMockValues } from '../../../../../__mocks__'; +import { setMockActions, setMockValues } from '../../../../../__mocks__/kea_logic'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/add_source/connect_instance.test.tsx b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/add_source/connect_instance.test.tsx index d6b427630e48e..d8696118d7f4e 100644 --- a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/add_source/connect_instance.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/add_source/connect_instance.test.tsx @@ -6,7 +6,7 @@ */ import '../../../../../__mocks__/shallow_useeffect.mock'; -import { setMockActions, setMockValues } from '../../../../../__mocks__'; +import { setMockActions, setMockValues } from '../../../../../__mocks__/kea_logic'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/add_source/reauthenticate.test.tsx b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/add_source/reauthenticate.test.tsx index c38ab167b18de..b826b8b42232e 100644 --- a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/add_source/reauthenticate.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/add_source/reauthenticate.test.tsx @@ -5,8 +5,9 @@ * 2.0. */ +import '../../../../../__mocks__/react_router'; import '../../../../../__mocks__/shallow_useeffect.mock'; -import { setMockActions, setMockValues } from '../../../../../__mocks__'; +import { setMockActions, setMockValues } from '../../../../../__mocks__/kea_logic'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/add_source/save_config.test.tsx b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/add_source/save_config.test.tsx index c0f7f1139cb73..32e1c59c56293 100644 --- a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/add_source/save_config.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/add_source/save_config.test.tsx @@ -6,7 +6,7 @@ */ import '../../../../../__mocks__/shallow_useeffect.mock'; -import { setMockActions, setMockValues } from '../../../../../__mocks__'; +import { setMockActions, setMockValues } from '../../../../../__mocks__/kea_logic'; import { sourceConfigData } from '../../../../__mocks__/content_sources.mock'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/add_source/source_features.test.tsx b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/add_source/source_features.test.tsx index cd8ba37695ac6..6afac428f2866 100644 --- a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/add_source/source_features.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/add_source/source_features.test.tsx @@ -5,12 +5,14 @@ * 2.0. */ -import { mountAsync, setMockValues } from '../../../../../__mocks__'; +import { setMockValues } from '../../../../../__mocks__/kea_logic'; import React from 'react'; import { EuiPanel } from '@elastic/eui'; +import { mountWithIntl } from '../../../../../test_helpers'; + import { staticSourceData } from '../../source_data'; import { SourceFeatures } from './source_features'; @@ -26,7 +28,7 @@ describe('SourceFeatures', () => { it('renders hasPlatinumLicense & isOrganization', async () => { setMockValues({ hasPlatinumLicense: true, isOrganization: true }); - const wrapper = await mountAsync(, { i18n: true }); + const wrapper = await mountWithIntl(); expect(wrapper.find('FeaturesRouter[featureId="SyncFrequency"]')).toHaveLength(1); expect(wrapper.find('FeaturesRouter[featureId="SyncedItems"]')).toHaveLength(1); @@ -34,7 +36,7 @@ describe('SourceFeatures', () => { it('renders !hasPlatinumLicense & isOrganization', async () => { setMockValues({ hasPlatinumLicense: false, isOrganization: true }); - const wrapper = await mountAsync(, { i18n: true }); + const wrapper = await mountWithIntl(); expect(wrapper.find('FeaturesRouter[featureId="SyncFrequency"]')).toHaveLength(1); expect(wrapper.find('FeaturesRouter[featureId="SyncedItems"]')).toHaveLength(1); @@ -43,7 +45,7 @@ describe('SourceFeatures', () => { it('renders hasPlatinumLicense & !isOrganization', async () => { setMockValues({ hasPlatinumLicense: true, isOrganization: false }); - const wrapper = await mountAsync(, { i18n: true }); + const wrapper = await mountWithIntl(); expect(wrapper.find('FeaturesRouter[featureId="Private"]')).toHaveLength(1); expect(wrapper.find('FeaturesRouter[featureId="SyncedItems"]')).toHaveLength(1); @@ -52,7 +54,7 @@ describe('SourceFeatures', () => { it('renders !hasPlatinumLicense & !isOrganization', async () => { setMockValues({ hasPlatinumLicense: false, isOrganization: false }); - const wrapper = await mountAsync(, { i18n: true }); + const wrapper = await mountWithIntl(); expect(wrapper.find('IncludedFeatures').find(EuiPanel)).toHaveLength(0); }); diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/display_settings/display_settings.test.tsx b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/display_settings/display_settings.test.tsx index 54be43596a431..aa5cec385738d 100644 --- a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/display_settings/display_settings.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/display_settings/display_settings.test.tsx @@ -7,7 +7,7 @@ import '../../../../../__mocks__/shallow_useeffect.mock'; -import { setMockValues, setMockActions } from '../../../../../__mocks__'; +import { setMockValues, setMockActions } from '../../../../../__mocks__/kea_logic'; import { exampleResult } from '../../../../__mocks__/content_sources.mock'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/display_settings/display_settings_logic.test.ts b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/display_settings/display_settings_logic.test.ts index 5a6ef5ba5990f..10c715c80b3d6 100644 --- a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/display_settings/display_settings_logic.test.ts +++ b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/display_settings/display_settings_logic.test.ts @@ -10,7 +10,7 @@ import { mockFlashMessageHelpers, mockHttpValues, mockKibanaValues, -} from '../../../../../__mocks__'; +} from '../../../../../__mocks__/kea_logic'; import { exampleResult } from '../../../../__mocks__/content_sources.mock'; import { nextTick } from '@kbn/test/jest'; diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/display_settings/display_settings_router.test.tsx b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/display_settings/display_settings_router.test.tsx index f04afe60aa49d..7f4e566022ab4 100644 --- a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/display_settings/display_settings_router.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/display_settings/display_settings_router.test.tsx @@ -7,7 +7,7 @@ import '../../../../../__mocks__/shallow_useeffect.mock'; -import { setMockValues } from '../../../../../__mocks__'; +import { setMockValues } from '../../../../../__mocks__/kea_logic'; import React from 'react'; import { Route, Switch } from 'react-router-dom'; diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/display_settings/example_result_detail_card.test.tsx b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/display_settings/example_result_detail_card.test.tsx index 15e1fe0ed417c..82a421d85df01 100644 --- a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/display_settings/example_result_detail_card.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/display_settings/example_result_detail_card.test.tsx @@ -7,7 +7,7 @@ import '../../../../../__mocks__/shallow_useeffect.mock'; -import { setMockValues } from '../../../../../__mocks__'; +import { setMockValues } from '../../../../../__mocks__/kea_logic'; import { exampleResult } from '../../../../__mocks__/content_sources.mock'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/display_settings/example_search_result_group.test.tsx b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/display_settings/example_search_result_group.test.tsx index 6f90c1045ae31..7139ea30be137 100644 --- a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/display_settings/example_search_result_group.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/display_settings/example_search_result_group.test.tsx @@ -7,7 +7,7 @@ import '../../../../../__mocks__/shallow_useeffect.mock'; -import { setMockValues } from '../../../../../__mocks__'; +import { setMockValues } from '../../../../../__mocks__/kea_logic'; import { exampleResult } from '../../../../__mocks__/content_sources.mock'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/display_settings/example_standout_result.test.tsx b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/display_settings/example_standout_result.test.tsx index 49845e79d86aa..a38e0ce82490d 100644 --- a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/display_settings/example_standout_result.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/display_settings/example_standout_result.test.tsx @@ -7,7 +7,7 @@ import '../../../../../__mocks__/shallow_useeffect.mock'; -import { setMockValues } from '../../../../../__mocks__'; +import { setMockValues } from '../../../../../__mocks__/kea_logic'; import { exampleResult } from '../../../../__mocks__/content_sources.mock'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/display_settings/field_editor_modal.test.tsx b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/display_settings/field_editor_modal.test.tsx index fe7bced843841..7d828549178e0 100644 --- a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/display_settings/field_editor_modal.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/display_settings/field_editor_modal.test.tsx @@ -7,7 +7,7 @@ import '../../../../../__mocks__/shallow_useeffect.mock'; -import { setMockValues, setMockActions } from '../../../../../__mocks__'; +import { setMockValues, setMockActions } from '../../../../../__mocks__/kea_logic'; import { exampleResult } from '../../../../__mocks__/content_sources.mock'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/display_settings/result_detail.test.tsx b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/display_settings/result_detail.test.tsx index 768573ce80fee..f400527c6c003 100644 --- a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/display_settings/result_detail.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/display_settings/result_detail.test.tsx @@ -6,7 +6,7 @@ */ import '../../../../../__mocks__/shallow_useeffect.mock'; -import { setMockValues, setMockActions } from '../../../../../__mocks__'; +import { setMockValues, setMockActions } from '../../../../../__mocks__/kea_logic'; import { exampleResult } from '../../../../__mocks__/content_sources.mock'; /** diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/display_settings/search_results.test.tsx b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/display_settings/search_results.test.tsx index 28de0006f162f..cc0378b4b70db 100644 --- a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/display_settings/search_results.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/display_settings/search_results.test.tsx @@ -7,7 +7,7 @@ import '../../../../../__mocks__/shallow_useeffect.mock'; -import { setMockValues, setMockActions } from '../../../../../__mocks__'; +import { setMockValues, setMockActions } from '../../../../../__mocks__/kea_logic'; import { exampleResult } from '../../../../__mocks__/content_sources.mock'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/overview.test.tsx b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/overview.test.tsx index a30f1bfbd596a..f2cf5f50b813b 100644 --- a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/overview.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/overview.test.tsx @@ -7,7 +7,7 @@ import '../../../../__mocks__/shallow_useeffect.mock'; -import { setMockValues } from '../../../../__mocks__'; +import { setMockValues } from '../../../../__mocks__/kea_logic'; import { fullContentSources } from '../../../__mocks__/content_sources.mock'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/schema/schema.test.tsx b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/schema/schema.test.tsx index 6b656fbdc6ddb..178c9125ee437 100644 --- a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/schema/schema.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/schema/schema.test.tsx @@ -7,7 +7,7 @@ import '../../../../../__mocks__/shallow_useeffect.mock'; -import { setMockValues, setMockActions } from '../../../../../__mocks__'; +import { setMockValues, setMockActions } from '../../../../../__mocks__/kea_logic'; import { mostRecentIndexJob } from '../../../../__mocks__/content_sources.mock'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/schema/schema_change_errors.test.tsx b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/schema/schema_change_errors.test.tsx index f600d089c6e06..fdb729b59b097 100644 --- a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/schema/schema_change_errors.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/schema/schema_change_errors.test.tsx @@ -5,12 +5,11 @@ * 2.0. */ +import { setMockValues, setMockActions } from '../../../../../__mocks__/kea_logic'; +import { mockUseParams } from '../../../../../__mocks__/react_router'; import '../../../../../__mocks__/shallow_useeffect.mock'; -import { setMockValues, setMockActions } from '../../../../../__mocks__'; - import React from 'react'; -import { useParams } from 'react-router-dom'; import { shallow } from 'enzyme'; @@ -27,7 +26,7 @@ describe('SchemaChangeErrors', () => { setMockValues({ fieldCoercionErrors, serverSchema }); setMockActions({ initializeSchemaFieldErrors: jest.fn() }); - (useParams as jest.Mock).mockImplementationOnce(() => ({ + mockUseParams.mockImplementationOnce(() => ({ activeReindexJobId: '1', sourceId: '123', })); diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/schema/schema_fields_table.test.tsx b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/schema/schema_fields_table.test.tsx index 9996e58e819b2..c2c364763e2eb 100644 --- a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/schema/schema_fields_table.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/schema/schema_fields_table.test.tsx @@ -7,7 +7,7 @@ import '../../../../../__mocks__/shallow_useeffect.mock'; -import { setMockValues, setMockActions } from '../../../../../__mocks__'; +import { setMockValues, setMockActions } from '../../../../../__mocks__/kea_logic'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/schema/schema_logic.test.ts b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/schema/schema_logic.test.ts index 650909c0b5a82..fd1a574b3438f 100644 --- a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/schema/schema_logic.test.ts +++ b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/schema/schema_logic.test.ts @@ -5,7 +5,11 @@ * 2.0. */ -import { LogicMounter, mockFlashMessageHelpers, mockHttpValues } from '../../../../../__mocks__'; +import { + LogicMounter, + mockFlashMessageHelpers, + mockHttpValues, +} from '../../../../../__mocks__/kea_logic'; import { mostRecentIndexJob } from '../../../../__mocks__/content_sources.mock'; import { nextTick } from '@kbn/test/jest'; diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/source_added.test.tsx b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/source_added.test.tsx index 9eecc41aa1778..a182c2697fe90 100644 --- a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/source_added.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/source_added.test.tsx @@ -5,9 +5,9 @@ * 2.0. */ +import '../../../../__mocks__/react_router'; import '../../../../__mocks__/shallow_useeffect.mock'; - -import { setMockActions, setMockValues } from '../../../../__mocks__'; +import { setMockActions, setMockValues } from '../../../../__mocks__/kea_logic'; import React from 'react'; import { useLocation } from 'react-router-dom'; diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/source_content.test.tsx b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/source_content.test.tsx index 8aa644827709a..4bcc4b16166d1 100644 --- a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/source_content.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/source_content.test.tsx @@ -7,7 +7,7 @@ import '../../../../__mocks__/shallow_useeffect.mock'; -import { setMockValues, setMockActions } from '../../../../__mocks__'; +import { setMockValues, setMockActions } from '../../../../__mocks__/kea_logic'; import { fullContentSources, contentItems } from '../../../__mocks__/content_sources.mock'; import { meta } from '../../../__mocks__/meta.mock'; diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/source_settings.test.tsx b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/source_settings.test.tsx index b2a4488b04107..74f32cc22c2a8 100644 --- a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/source_settings.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/source_settings.test.tsx @@ -7,7 +7,7 @@ import '../../../../__mocks__/shallow_useeffect.mock'; -import { setMockValues, setMockActions } from '../../../../__mocks__'; +import { setMockValues, setMockActions } from '../../../../__mocks__/kea_logic'; import { fullContentSources, sourceConfigData } from '../../../__mocks__/content_sources.mock'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/source_sub_nav.test.tsx b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/source_sub_nav.test.tsx index 59f3bfb0a5611..25c389419d731 100644 --- a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/source_sub_nav.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/source_sub_nav.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { setMockValues } from '../../../../__mocks__'; +import { setMockValues } from '../../../../__mocks__/kea_logic'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/organization_sources.test.tsx b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/organization_sources.test.tsx index b986658f19fb3..9df91406c4b7b 100644 --- a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/organization_sources.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/organization_sources.test.tsx @@ -6,8 +6,7 @@ */ import '../../../__mocks__/shallow_useeffect.mock'; - -import { setMockValues, setMockActions } from '../../../__mocks__'; +import { setMockValues, setMockActions } from '../../../__mocks__/kea_logic'; import { contentSources } from '../../__mocks__/content_sources.mock'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/private_sources.test.tsx b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/private_sources.test.tsx index e6f19ff13b3cc..08f560c984344 100644 --- a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/private_sources.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/private_sources.test.tsx @@ -7,7 +7,7 @@ import '../../../__mocks__/shallow_useeffect.mock'; -import { setMockValues, setMockActions } from '../../../__mocks__'; +import { setMockValues, setMockActions } from '../../../__mocks__/kea_logic'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/private_sources_layout.test.tsx b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/private_sources_layout.test.tsx index 7558eb1e4e662..6af439814b891 100644 --- a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/private_sources_layout.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/private_sources_layout.test.tsx @@ -7,7 +7,7 @@ import '../../../__mocks__/shallow_useeffect.mock'; -import { setMockValues } from '../../../__mocks__'; +import { setMockValues } from '../../../__mocks__/kea_logic'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/source_logic.test.ts b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/source_logic.test.ts index 2cf867446b7fb..03f46830fafc3 100644 --- a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/source_logic.test.ts +++ b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/source_logic.test.ts @@ -10,12 +10,12 @@ import { mockFlashMessageHelpers, mockHttpValues, mockKibanaValues, - expectedAsyncError, -} from '../../../__mocks__'; +} from '../../../__mocks__/kea_logic'; import { fullContentSources, contentItems } from '../../__mocks__/content_sources.mock'; import { meta } from '../../__mocks__/meta.mock'; import { DEFAULT_META } from '../../../shared/constants'; +import { expectedAsyncError } from '../../../test_helpers'; jest.mock('../../app_logic', () => ({ AppLogic: { values: { isOrganization: true } }, diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/source_router.test.tsx b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/source_router.test.tsx index dda3eeea54926..783fc434fe8e5 100644 --- a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/source_router.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/source_router.test.tsx @@ -7,13 +7,12 @@ import '../../../__mocks__/shallow_useeffect.mock'; -import { setMockValues, setMockActions } from '../../../__mocks__'; -import { mockLocation } from '../../../__mocks__/react_router_history.mock'; +import { setMockValues, setMockActions } from '../../../__mocks__/kea_logic'; +import { mockLocation, mockUseParams } from '../../../__mocks__/react_router'; import { unmountHandler } from '../../../__mocks__/shallow_useeffect.mock'; import { contentSources } from '../../__mocks__/content_sources.mock'; import React from 'react'; -import { useParams } from 'react-router-dom'; import { Route, Switch } from 'react-router-dom'; import { shallow } from 'enzyme'; @@ -46,7 +45,7 @@ describe('SourceRouter', () => { resetSourceState, }); setMockValues({ ...mockValues }); - (useParams as jest.Mock).mockImplementationOnce(() => ({ + mockUseParams.mockImplementationOnce(() => ({ sourceId: contentSource.id, })); }); diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/sources_logic.test.ts b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/sources_logic.test.ts index 13844f51b2319..74d3faca5994b 100644 --- a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/sources_logic.test.ts +++ b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/sources_logic.test.ts @@ -9,10 +9,11 @@ import { LogicMounter, mockFlashMessageHelpers, mockHttpValues, - expectedAsyncError, -} from '../../../__mocks__'; +} from '../../../__mocks__/kea_logic'; import { configuredSources, contentSources } from '../../__mocks__/content_sources.mock'; +import { expectedAsyncError } from '../../../test_helpers'; + jest.mock('../../app_logic', () => ({ AppLogic: { values: { isOrganization: true } }, })); diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/sources_router.test.tsx b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/sources_router.test.tsx index eac1bd7d3ea27..3ba5161e5a3e3 100644 --- a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/sources_router.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/sources_router.test.tsx @@ -5,9 +5,9 @@ * 2.0. */ +import '../../../__mocks__/react_router'; import '../../../__mocks__/shallow_useeffect.mock'; - -import { setMockValues, setMockActions } from '../../../__mocks__'; +import { setMockValues, setMockActions } from '../../../__mocks__/kea_logic'; import React from 'react'; import { Route, Switch, Redirect } from 'react-router-dom'; diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/sources_view.test.tsx b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/sources_view.test.tsx index 06d7ecff50299..507e66bdf0332 100644 --- a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/sources_view.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/sources_view.test.tsx @@ -7,7 +7,7 @@ import '../../../__mocks__/shallow_useeffect.mock'; -import { setMockValues, setMockActions } from '../../../__mocks__'; +import { setMockValues, setMockActions } from '../../../__mocks__/kea_logic'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/groups/components/add_group_modal.test.tsx b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/groups/components/add_group_modal.test.tsx index 784544b0001fa..7468f9c937943 100644 --- a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/groups/components/add_group_modal.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/groups/components/add_group_modal.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { setMockValues, setMockActions } from '../../../../__mocks__'; +import { setMockValues, setMockActions } from '../../../../__mocks__/kea_logic'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/groups/components/clear_filters_link.test.tsx b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/groups/components/clear_filters_link.test.tsx index 9118bc5e7adf3..dd4b22c6ca62c 100644 --- a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/groups/components/clear_filters_link.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/groups/components/clear_filters_link.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { setMockActions } from '../../../../__mocks__'; +import { setMockActions } from '../../../../__mocks__/kea_logic'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/groups/components/filterable_users_popover.test.tsx b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/groups/components/filterable_users_popover.test.tsx index 1813b766b9875..dc7e635d8fa6b 100644 --- a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/groups/components/filterable_users_popover.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/groups/components/filterable_users_popover.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { setMockActions } from '../../../../__mocks__'; +import { setMockActions } from '../../../../__mocks__/kea_logic'; import { users } from '../../../__mocks__/users.mock'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/groups/components/group_manager_modal.test.tsx b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/groups/components/group_manager_modal.test.tsx index 7c39414f158ef..5619698335b30 100644 --- a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/groups/components/group_manager_modal.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/groups/components/group_manager_modal.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { setMockValues } from '../../../../__mocks__'; +import { setMockValues } from '../../../../__mocks__/kea_logic'; import { contentSources } from '../../../__mocks__/content_sources.mock'; import { groups } from '../../../__mocks__/groups.mock'; diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/groups/components/group_overview.test.tsx b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/groups/components/group_overview.test.tsx index 8d5714fd05792..7f60b8d8584ba 100644 --- a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/groups/components/group_overview.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/groups/components/group_overview.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { setMockActions, setMockValues } from '../../../../__mocks__'; +import { setMockActions, setMockValues } from '../../../../__mocks__/kea_logic'; import { groups } from '../../../__mocks__/groups.mock'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/groups/components/group_row.test.tsx b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/groups/components/group_row.test.tsx index 205eafd69cd10..7915482a45b2a 100644 --- a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/groups/components/group_row.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/groups/components/group_row.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { setMockValues } from '../../../../__mocks__'; +import { setMockValues } from '../../../../__mocks__/kea_logic'; import { groups } from '../../../__mocks__/groups.mock'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/groups/components/group_row_users_dropdown.test.tsx b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/groups/components/group_row_users_dropdown.test.tsx index e75b325a4eae9..1116c625be07a 100644 --- a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/groups/components/group_row_users_dropdown.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/groups/components/group_row_users_dropdown.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { setMockActions, setMockValues } from '../../../../__mocks__'; +import { setMockActions, setMockValues } from '../../../../__mocks__/kea_logic'; import { users } from '../../../__mocks__/users.mock'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/groups/components/group_source_prioritization.test.tsx b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/groups/components/group_source_prioritization.test.tsx index 4a9244486bf30..0faeb1df5398c 100644 --- a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/groups/components/group_source_prioritization.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/groups/components/group_source_prioritization.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { setMockActions, setMockValues } from '../../../../__mocks__'; +import { setMockActions, setMockValues } from '../../../../__mocks__/kea_logic'; import { groups } from '../../../__mocks__/groups.mock'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/groups/components/group_sub_nav.test.tsx b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/groups/components/group_sub_nav.test.tsx index e4dde81949bfa..263ec5f1b27c0 100644 --- a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/groups/components/group_sub_nav.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/groups/components/group_sub_nav.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { setMockValues } from '../../../../__mocks__'; +import { setMockValues } from '../../../../__mocks__/kea_logic'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/groups/components/group_users_table.test.tsx b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/groups/components/group_users_table.test.tsx index a6376d7653627..0dde2f5eaf7f7 100644 --- a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/groups/components/group_users_table.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/groups/components/group_users_table.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { setMockValues } from '../../../../__mocks__'; +import { setMockValues } from '../../../../__mocks__/kea_logic'; import { groups } from '../../../__mocks__/groups.mock'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/groups/components/groups_table.test.tsx b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/groups/components/groups_table.test.tsx index f60a13ec296d5..d11b830a8fc4b 100644 --- a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/groups/components/groups_table.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/groups/components/groups_table.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { setMockActions, setMockValues } from '../../../../__mocks__'; +import { setMockActions, setMockValues } from '../../../../__mocks__/kea_logic'; import { groups } from '../../../__mocks__/groups.mock'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/groups/components/manage_users_modal.test.tsx b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/groups/components/manage_users_modal.test.tsx index 49d51dfc7254c..5256155979e4d 100644 --- a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/groups/components/manage_users_modal.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/groups/components/manage_users_modal.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { setMockActions, setMockValues } from '../../../../__mocks__'; +import { setMockActions, setMockValues } from '../../../../__mocks__/kea_logic'; import { users } from '../../../__mocks__/users.mock'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/groups/components/shared_sources_modal.test.tsx b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/groups/components/shared_sources_modal.test.tsx index dd72850a06ad9..02f0b53af97cc 100644 --- a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/groups/components/shared_sources_modal.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/groups/components/shared_sources_modal.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { setMockActions, setMockValues } from '../../../../__mocks__'; +import { setMockActions, setMockValues } from '../../../../__mocks__/kea_logic'; import { groups } from '../../../__mocks__/groups.mock'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/groups/components/table_filter_sources_dropdown.test.tsx b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/groups/components/table_filter_sources_dropdown.test.tsx index 1e2a57da9ad2e..4150604fb8079 100644 --- a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/groups/components/table_filter_sources_dropdown.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/groups/components/table_filter_sources_dropdown.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { setMockActions, setMockValues } from '../../../../__mocks__'; +import { setMockActions, setMockValues } from '../../../../__mocks__/kea_logic'; import { contentSources } from '../../../__mocks__/content_sources.mock'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/groups/components/table_filter_users_dropdown.test.tsx b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/groups/components/table_filter_users_dropdown.test.tsx index e472563862015..93e5ad69964ca 100644 --- a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/groups/components/table_filter_users_dropdown.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/groups/components/table_filter_users_dropdown.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { setMockActions, setMockValues } from '../../../../__mocks__'; +import { setMockActions, setMockValues } from '../../../../__mocks__/kea_logic'; import { users } from '../../../__mocks__/users.mock'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/groups/components/table_filters.test.tsx b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/groups/components/table_filters.test.tsx index bcc58c394b516..83a20efe5257e 100644 --- a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/groups/components/table_filters.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/groups/components/table_filters.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { setMockActions, setMockValues } from '../../../../__mocks__'; +import { setMockActions, setMockValues } from '../../../../__mocks__/kea_logic'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/groups/group_logic.test.ts b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/groups/group_logic.test.ts index 9f12e8f202d50..2c9ca642f2283 100644 --- a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/groups/group_logic.test.ts +++ b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/groups/group_logic.test.ts @@ -10,7 +10,7 @@ import { mockKibanaValues, mockFlashMessageHelpers, mockHttpValues, -} from '../../../__mocks__'; +} from '../../../__mocks__/kea_logic'; import { groups } from '../../__mocks__/groups.mock'; import { mockGroupValues } from './__mocks__/group_logic.mock'; diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/groups/group_router.test.tsx b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/groups/group_router.test.tsx index 0b218f2496154..4c13dbce3ef1e 100644 --- a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/groups/group_router.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/groups/group_router.test.tsx @@ -5,8 +5,9 @@ * 2.0. */ +import '../../../__mocks__/react_router'; import '../../../__mocks__/shallow_useeffect.mock'; -import { setMockValues, setMockActions } from '../../../__mocks__'; +import { setMockValues, setMockActions } from '../../../__mocks__/kea_logic'; import { groups } from '../../__mocks__/groups.mock'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/groups/groups.test.tsx b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/groups/groups.test.tsx index 54f8580a8eab9..2929fa0ff1d61 100644 --- a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/groups/groups.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/groups/groups.test.tsx @@ -6,7 +6,7 @@ */ import '../../../__mocks__/shallow_useeffect.mock'; -import { setMockActions, setMockValues } from '../../../__mocks__'; +import { setMockActions, setMockValues } from '../../../__mocks__/kea_logic'; import { groups } from '../../__mocks__/groups.mock'; import { meta } from '../../__mocks__/meta.mock'; diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/groups/groups_logic.test.ts b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/groups/groups_logic.test.ts index bb6e7c0c76faf..c4a860368ff8b 100644 --- a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/groups/groups_logic.test.ts +++ b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/groups/groups_logic.test.ts @@ -5,7 +5,11 @@ * 2.0. */ -import { LogicMounter, mockFlashMessageHelpers, mockHttpValues } from '../../../__mocks__'; +import { + LogicMounter, + mockFlashMessageHelpers, + mockHttpValues, +} from '../../../__mocks__/kea_logic'; import { contentSources } from '../../__mocks__/content_sources.mock'; import { groups } from '../../__mocks__/groups.mock'; import { users } from '../../__mocks__/users.mock'; diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/groups/groups_router.test.tsx b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/groups/groups_router.test.tsx index 0295605eddd4d..66204f74f51f1 100644 --- a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/groups/groups_router.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/groups/groups_router.test.tsx @@ -6,7 +6,7 @@ */ import '../../../__mocks__/shallow_useeffect.mock'; -import { setMockActions } from '../../../__mocks__'; +import { setMockActions } from '../../../__mocks__/kea_logic'; import React from 'react'; import { Route, Switch } from 'react-router-dom'; diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/overview/__mocks__/overview_logic.mock.ts b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/overview/__mocks__/overview_logic.mock.ts index 787354974cb31..9aaa6253ea0ab 100644 --- a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/overview/__mocks__/overview_logic.mock.ts +++ b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/overview/__mocks__/overview_logic.mock.ts @@ -6,7 +6,7 @@ */ import { DEFAULT_INITIAL_APP_DATA } from '../../../../../../common/__mocks__'; -import { setMockValues as setMockKeaValues, setMockActions } from '../../../../__mocks__/kea.mock'; +import { setMockValues as setMockKeaValues, setMockActions } from '../../../../__mocks__/kea_logic'; const { workplaceSearch: mockAppValues } = DEFAULT_INITIAL_APP_DATA; diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/overview/onboarding_card.test.tsx b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/overview/onboarding_card.test.tsx index 2b9dc98b03567..382eb676f8708 100644 --- a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/overview/onboarding_card.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/overview/onboarding_card.test.tsx @@ -5,9 +5,8 @@ * 2.0. */ -import '../../../__mocks__/kea.mock'; import '../../../__mocks__/enterprise_search_url.mock'; -import { mockTelemetryActions } from '../../../__mocks__'; +import { mockTelemetryActions } from '../../../__mocks__/kea_logic'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/overview/onboarding_steps.test.tsx b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/overview/onboarding_steps.test.tsx index 5059533519a6f..01e5245c597eb 100644 --- a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/overview/onboarding_steps.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/overview/onboarding_steps.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { mockTelemetryActions } from '../../../__mocks__'; +import { mockTelemetryActions } from '../../../__mocks__/kea_logic'; import { setMockValues } from './__mocks__'; import './__mocks__/overview_logic.mock'; diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/overview/overview.test.tsx b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/overview/overview.test.tsx index 19c893bec81ea..f4fa1dab89810 100644 --- a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/overview/overview.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/overview/overview.test.tsx @@ -5,7 +5,6 @@ * 2.0. */ -import '../../../__mocks__/react_router_history.mock'; import './__mocks__/overview_logic.mock'; import { mockActions, setMockValues } from './__mocks__'; diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/overview/overview_logic.test.ts b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/overview/overview_logic.test.ts index 75a41216ffbb7..090715e14309a 100644 --- a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/overview/overview_logic.test.ts +++ b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/overview/overview_logic.test.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { LogicMounter, mockHttpValues } from '../../../__mocks__'; +import { LogicMounter, mockHttpValues } from '../../../__mocks__/kea_logic'; import { mockOverviewValues } from './__mocks__'; import { OverviewLogic } from './overview_logic'; diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/overview/recent_activity.test.tsx b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/overview/recent_activity.test.tsx index 3a925f011cc18..0cb3f77c681a1 100644 --- a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/overview/recent_activity.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/overview/recent_activity.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { mockTelemetryActions } from '../../../__mocks__'; +import { mockTelemetryActions } from '../../../__mocks__/kea_logic'; import { setMockValues } from './__mocks__'; import './__mocks__/overview_logic.mock'; diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/role_mappings/role_mapping.test.tsx b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/role_mappings/role_mapping.test.tsx index 01981b1c3894e..619a931864500 100644 --- a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/role_mappings/role_mapping.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/role_mappings/role_mapping.test.tsx @@ -5,8 +5,9 @@ * 2.0. */ +import '../../../__mocks__/react_router'; import '../../../__mocks__/shallow_useeffect.mock'; -import { setMockActions, setMockValues } from '../../../__mocks__'; +import { setMockActions, setMockValues } from '../../../__mocks__/kea_logic'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/role_mappings/role_mappings.test.tsx b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/role_mappings/role_mappings.test.tsx index 9559df2c1f981..d7ce8053c71f0 100644 --- a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/role_mappings/role_mappings.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/role_mappings/role_mappings.test.tsx @@ -6,7 +6,7 @@ */ import '../../../__mocks__/shallow_useeffect.mock'; -import { setMockActions, setMockValues } from '../../../__mocks__'; +import { setMockActions, setMockValues } from '../../../__mocks__/kea_logic'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/role_mappings/role_mappings_logic.test.ts b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/role_mappings/role_mappings_logic.test.ts index 281e3cfdff1c1..716cb8ebb6d47 100644 --- a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/role_mappings/role_mappings_logic.test.ts +++ b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/role_mappings/role_mappings_logic.test.ts @@ -5,8 +5,11 @@ * 2.0. */ -import { mockFlashMessageHelpers, mockHttpValues } from '../../../__mocks__'; -import { LogicMounter } from '../../../__mocks__/kea.mock'; +import { + LogicMounter, + mockFlashMessageHelpers, + mockHttpValues, +} from '../../../__mocks__/kea_logic'; import { groups } from '../../__mocks__/groups.mock'; diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/security/components/private_sources_table.test.tsx b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/security/components/private_sources_table.test.tsx index 4f7160ba631f1..65f9ac9cbb0f9 100644 --- a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/security/components/private_sources_table.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/security/components/private_sources_table.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { setMockValues } from '../../../../__mocks__'; +import { setMockValues } from '../../../../__mocks__/kea_logic'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/security/security.test.tsx b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/security/security.test.tsx index 346994ac557f9..c9720eb6c1c04 100644 --- a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/security/security.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/security/security.test.tsx @@ -6,7 +6,7 @@ */ import '../../../__mocks__/shallow_useeffect.mock'; -import { setMockValues, setMockActions } from '../../../__mocks__'; +import { setMockValues, setMockActions } from '../../../__mocks__/kea_logic'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/security/security_logic.test.ts b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/security/security_logic.test.ts index 02d8fdd3c30e4..ecb97cea528b9 100644 --- a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/security/security_logic.test.ts +++ b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/security/security_logic.test.ts @@ -5,8 +5,11 @@ * 2.0. */ -import { mockHttpValues, mockFlashMessageHelpers } from '../../../__mocks__'; -import { LogicMounter } from '../../../__mocks__/kea.mock'; +import { + LogicMounter, + mockHttpValues, + mockFlashMessageHelpers, +} from '../../../__mocks__/kea_logic'; import { nextTick } from '@kbn/test/jest'; diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/settings/components/connectors.test.tsx b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/settings/components/connectors.test.tsx index 13ef86a21a208..e95dd60ae6089 100644 --- a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/settings/components/connectors.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/settings/components/connectors.test.tsx @@ -7,7 +7,7 @@ import '../../../../__mocks__/shallow_useeffect.mock'; -import { setMockValues, setMockActions } from '../../../../__mocks__'; +import { setMockValues, setMockActions } from '../../../../__mocks__/kea_logic'; import { configuredSources } from '../../../__mocks__/content_sources.mock'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/settings/components/customize.test.tsx b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/settings/components/customize.test.tsx index ed05829d9e082..15d0db4c415d0 100644 --- a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/settings/components/customize.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/settings/components/customize.test.tsx @@ -7,7 +7,7 @@ import '../../../../__mocks__/shallow_useeffect.mock'; -import { setMockValues, setMockActions } from '../../../../__mocks__'; +import { setMockValues, setMockActions } from '../../../../__mocks__/kea_logic'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/settings/components/oauth_application.test.tsx b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/settings/components/oauth_application.test.tsx index 55a58610e0ed6..3c0cae212caa4 100644 --- a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/settings/components/oauth_application.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/settings/components/oauth_application.test.tsx @@ -7,7 +7,7 @@ import '../../../../__mocks__/shallow_useeffect.mock'; -import { setMockValues, setMockActions } from '../../../../__mocks__'; +import { setMockValues, setMockActions } from '../../../../__mocks__/kea_logic'; import { oauthApplication } from '../../../__mocks__/content_sources.mock'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/settings/components/source_config.test.tsx b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/settings/components/source_config.test.tsx index ed9f715fd6916..c9b458e8d3535 100644 --- a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/settings/components/source_config.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/settings/components/source_config.test.tsx @@ -7,7 +7,7 @@ import '../../../../__mocks__/shallow_useeffect.mock'; -import { setMockValues, setMockActions } from '../../../../__mocks__'; +import { setMockValues, setMockActions } from '../../../../__mocks__/kea_logic'; import { sourceConfigData } from '../../../__mocks__/content_sources.mock'; import React from 'react'; diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/settings/settings_logic.test.ts b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/settings/settings_logic.test.ts index a57c2c1f9ad44..0aef84ccf20e2 100644 --- a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/settings/settings_logic.test.ts +++ b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/settings/settings_logic.test.ts @@ -5,8 +5,12 @@ * 2.0. */ -import { mockFlashMessageHelpers, mockHttpValues, mockKibanaValues } from '../../../__mocks__'; -import { LogicMounter } from '../../../__mocks__/kea.mock'; +import { + LogicMounter, + mockFlashMessageHelpers, + mockHttpValues, + mockKibanaValues, +} from '../../../__mocks__/kea_logic'; import { configuredSources, oauthApplication } from '../../__mocks__/content_sources.mock'; import { nextTick } from '@kbn/test/jest'; diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/settings/settings_router.test.tsx b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/settings/settings_router.test.tsx index 3c0dee2a874ae..6a9104ceefde0 100644 --- a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/settings/settings_router.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/settings/settings_router.test.tsx @@ -7,7 +7,7 @@ import '../../../__mocks__/shallow_useeffect.mock'; -import { setMockActions } from '../../../__mocks__'; +import { setMockActions } from '../../../__mocks__/kea_logic'; import React from 'react'; import { Route, Redirect, Switch } from 'react-router-dom'; From abaac4c6c7106155e39cd68beca84e37ceba1051 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20S=C3=A1nchez?= Date: Wed, 9 Jun 2021 10:13:55 +0200 Subject: [PATCH 15/19] [Security solutions][Endpoint] Update event filtering texts (#101563) * Changes multilang for add endpoint event filter action on events tab * Changes more multilangs and display name error only when needed * Changes variable names and aria labels to be consistent with namings * Fixes unit test due multilang changes --- .../timeline_actions/alert_context_menu.tsx | 36 +++++++++---------- .../components/alerts_table/translations.ts | 6 ++-- .../view/components/flyout/index.test.tsx | 8 ++--- .../view/components/flyout/index.tsx | 2 +- .../view/components/form/index.test.tsx | 11 +++++- .../view/components/form/index.tsx | 15 +++++--- .../view/components/form/translations.ts | 4 +-- .../view/components/modal/translations.ts | 2 +- 8 files changed, 50 insertions(+), 34 deletions(-) diff --git a/x-pack/plugins/security_solution/public/detections/components/alerts_table/timeline_actions/alert_context_menu.tsx b/x-pack/plugins/security_solution/public/detections/components/alerts_table/timeline_actions/alert_context_menu.tsx index 3152c08fab323..9f59e3763ffbc 100644 --- a/x-pack/plugins/security_solution/public/detections/components/alerts_table/timeline_actions/alert_context_menu.tsx +++ b/x-pack/plugins/security_solution/public/detections/components/alerts_table/timeline_actions/alert_context_menu.tsx @@ -111,7 +111,7 @@ const AlertContextMenuComponent: React.FC = ({ setPopover(false); }, []); const [exceptionModalType, setOpenAddExceptionModal] = useState(null); - const [isAddEventExceptionModalOpen, setIsAddEventExceptionModalOpen] = useState(false); + const [isAddEventFilterModalOpen, setIsAddEventFilterModalOpen] = useState(false); const [{ canUserCRUD, hasIndexWrite, hasIndexMaintenance, hasIndexUpdateDelete }] = useUserData(); const isEndpointAlert = useMemo((): boolean => { @@ -129,8 +129,8 @@ const AlertContextMenuComponent: React.FC = ({ setOpenAddExceptionModal(null); }, []); - const closeAddEventExceptionModal = useCallback((): void => { - setIsAddEventExceptionModalOpen(false); + const closeAddEventFilterModal = useCallback((): void => { + setIsAddEventFilterModalOpen(false); }, []); const onAddExceptionCancel = useCallback(() => { @@ -364,26 +364,26 @@ const AlertContextMenuComponent: React.FC = ({ ); }, [handleAddExceptionClick, canUserCRUD, hasIndexWrite]); - const handleAddEventExceptionClick = useCallback((): void => { + const handleAddEventFilterClick = useCallback((): void => { closePopover(); - setIsAddEventExceptionModalOpen(true); + setIsAddEventFilterModalOpen(true); }, [closePopover]); - const addEventExceptionComponent = useMemo( + const addEventFilterComponent = useMemo( () => ( - - {i18n.ACTION_ADD_EVENT_EXCEPTION} + + {i18n.ACTION_ADD_EVENT_FILTER} ), - [handleAddEventExceptionClick] + [handleAddEventFilterClick] ); const statusFilters = useMemo(() => { @@ -412,11 +412,11 @@ const AlertContextMenuComponent: React.FC = ({ () => !isEvent && ruleId ? [...statusFilters, addEndpointExceptionComponent, addExceptionComponent] - : [addEventExceptionComponent], + : [addEventFilterComponent], [ addEndpointExceptionComponent, addExceptionComponent, - addEventExceptionComponent, + addEventFilterComponent, statusFilters, ruleId, isEvent, @@ -453,8 +453,8 @@ const AlertContextMenuComponent: React.FC = ({ onRuleChange={onRuleChange} /> )} - {isAddEventExceptionModalOpen && ecsRowData != null && ( - + {isAddEventFilterModalOpen && ecsRowData != null && ( + )} ); diff --git a/x-pack/plugins/security_solution/public/detections/components/alerts_table/translations.ts b/x-pack/plugins/security_solution/public/detections/components/alerts_table/translations.ts index 2d9f947dcea67..c43c4547a17ec 100644 --- a/x-pack/plugins/security_solution/public/detections/components/alerts_table/translations.ts +++ b/x-pack/plugins/security_solution/public/detections/components/alerts_table/translations.ts @@ -165,10 +165,10 @@ export const ACTION_ADD_EXCEPTION = i18n.translate( } ); -export const ACTION_ADD_EVENT_EXCEPTION = i18n.translate( - 'xpack.securitySolution.detectionEngine.alerts.actions.addEventException', +export const ACTION_ADD_EVENT_FILTER = i18n.translate( + 'xpack.securitySolution.detectionEngine.alerts.actions.addEventFilter', { - defaultMessage: 'Add Endpoint event exception', + defaultMessage: 'Add Endpoint event filter', } ); diff --git a/x-pack/plugins/security_solution/public/management/pages/event_filters/view/components/flyout/index.test.tsx b/x-pack/plugins/security_solution/public/management/pages/event_filters/view/components/flyout/index.test.tsx index 5ee4c4eb0aacb..6a106b1488677 100644 --- a/x-pack/plugins/security_solution/public/management/pages/event_filters/view/components/flyout/index.test.tsx +++ b/x-pack/plugins/security_solution/public/management/pages/event_filters/view/components/flyout/index.test.tsx @@ -70,7 +70,7 @@ describe('Event filter flyout', () => { it('should renders correctly', () => { const component = render(); expect(component.getAllByText('Add Endpoint Event Filter')).not.toBeNull(); - expect(component.getByText('cancel')).not.toBeNull(); + expect(component.getByText('Cancel')).not.toBeNull(); expect(component.getByText('Endpoint Security')).not.toBeNull(); }); @@ -136,7 +136,7 @@ describe('Event filter flyout', () => { it('should close when click on cancel button', () => { const component = render(); - const cancelButton = component.getByText('cancel'); + const cancelButton = component.getByText('Cancel'); expect(onCancelMock).toHaveBeenCalledTimes(0); act(() => { @@ -170,7 +170,7 @@ describe('Event filter flyout', () => { }); }); - const cancelButton = component.getByText('cancel'); + const cancelButton = component.getByText('Cancel'); expect(onCancelMock).toHaveBeenCalledTimes(0); act(() => { @@ -184,7 +184,7 @@ describe('Event filter flyout', () => { const component = render({ id: 'fakeId', type: 'edit' }); expect(component.getAllByText('Update Endpoint Event Filter')).not.toBeNull(); - expect(component.getByText('cancel')).not.toBeNull(); + expect(component.getByText('Cancel')).not.toBeNull(); expect(component.getByText('Endpoint Security')).not.toBeNull(); }); diff --git a/x-pack/plugins/security_solution/public/management/pages/event_filters/view/components/flyout/index.tsx b/x-pack/plugins/security_solution/public/management/pages/event_filters/view/components/flyout/index.tsx index c36e711879b8e..1217488a75ea6 100644 --- a/x-pack/plugins/security_solution/public/management/pages/event_filters/view/components/flyout/index.tsx +++ b/x-pack/plugins/security_solution/public/management/pages/event_filters/view/components/flyout/index.tsx @@ -141,7 +141,7 @@ export const EventFiltersFlyout: React.FC = memo( diff --git a/x-pack/plugins/security_solution/public/management/pages/event_filters/view/components/form/index.test.tsx b/x-pack/plugins/security_solution/public/management/pages/event_filters/view/components/form/index.test.tsx index 0867d0542e4c1..048bd97664f2e 100644 --- a/x-pack/plugins/security_solution/public/management/pages/event_filters/view/components/form/index.test.tsx +++ b/x-pack/plugins/security_solution/public/management/pages/event_filters/view/components/form/index.test.tsx @@ -82,7 +82,16 @@ describe('Event filter form', () => { component = renderComponentWithdata(); expect(component.getByTestId('alert-exception-builder')).not.toBeNull(); - expect(component.getByText(NAME_ERROR)).not.toBeNull(); + }); + + it('should display name error only when on blur and empty name', () => { + component = renderComponentWithdata(); + expect(component.queryByText(NAME_ERROR)).toBeNull(); + const nameInput = component.getByPlaceholderText(NAME_PLACEHOLDER); + act(() => { + fireEvent.blur(nameInput); + }); + expect(component.queryByText(NAME_ERROR)).not.toBeNull(); }); it('should change name', async () => { diff --git a/x-pack/plugins/security_solution/public/management/pages/event_filters/view/components/form/index.tsx b/x-pack/plugins/security_solution/public/management/pages/event_filters/view/components/form/index.tsx index 83fd6ff1a366d..93658d4efa737 100644 --- a/x-pack/plugins/security_solution/public/management/pages/event_filters/view/components/form/index.tsx +++ b/x-pack/plugins/security_solution/public/management/pages/event_filters/view/components/form/index.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import React, { memo, useMemo, useCallback } from 'react'; +import React, { memo, useMemo, useCallback, useState } from 'react'; import { useDispatch } from 'react-redux'; import { Dispatch } from 'redux'; import { @@ -58,6 +58,7 @@ export const EventFiltersForm: React.FC = memo( const exception = useEventFiltersSelector(getFormEntryStateMutable); const hasNameError = useEventFiltersSelector(getHasNameError); const newComment = useEventFiltersSelector(getNewComment); + const [hasBeenInputNameVisited, setHasBeenInputNameVisited] = useState(false); // This value has to be memoized to avoid infinite useEffect loop on useFetchIndex const indexNames = useMemo(() => ['logs-endpoint.events.*'], []); @@ -140,7 +141,12 @@ export const EventFiltersForm: React.FC = memo( const nameInputMemo = useMemo( () => ( - + = memo( onChange={handleOnChangeName} fullWidth aria-label={NAME_PLACEHOLDER} - required + required={hasBeenInputNameVisited} maxLength={256} + onBlur={() => !hasBeenInputNameVisited && setHasBeenInputNameVisited(true)} /> ), - [hasNameError, exception?.name, handleOnChangeName] + [hasNameError, exception?.name, handleOnChangeName, hasBeenInputNameVisited] ); const osInputMemo = useMemo( diff --git a/x-pack/plugins/security_solution/public/management/pages/event_filters/view/components/form/translations.ts b/x-pack/plugins/security_solution/public/management/pages/event_filters/view/components/form/translations.ts index 086f2298d2c1a..7391251a936e6 100644 --- a/x-pack/plugins/security_solution/public/management/pages/event_filters/view/components/form/translations.ts +++ b/x-pack/plugins/security_solution/public/management/pages/event_filters/view/components/form/translations.ts @@ -17,12 +17,12 @@ export const FORM_DESCRIPTION = i18n.translate( export const NAME_PLACEHOLDER = i18n.translate( 'xpack.securitySolution.eventFilter.form.name.placeholder', { - defaultMessage: 'Event exception name', + defaultMessage: 'Event filter name', } ); export const NAME_LABEL = i18n.translate('xpack.securitySolution.eventFilter.form.name.label', { - defaultMessage: 'Name your event exception', + defaultMessage: 'Name your event filter', }); export const NAME_ERROR = i18n.translate('xpack.securitySolution.eventFilter.form.name.error', { diff --git a/x-pack/plugins/security_solution/public/management/pages/event_filters/view/components/modal/translations.ts b/x-pack/plugins/security_solution/public/management/pages/event_filters/view/components/modal/translations.ts index 982d9b3bb12b3..66e0dfde298b8 100644 --- a/x-pack/plugins/security_solution/public/management/pages/event_filters/view/components/modal/translations.ts +++ b/x-pack/plugins/security_solution/public/management/pages/event_filters/view/components/modal/translations.ts @@ -25,6 +25,6 @@ export const ACTIONS_CONFIRM = i18n.translate( export const ACTIONS_CANCEL = i18n.translate( 'xpack.securitySolution.eventFilter.modal.actions.cancel', { - defaultMessage: 'cancel', + defaultMessage: 'Cancel', } ); From 52d62ceec55ce645113c9ea2d711eb2118982437 Mon Sep 17 00:00:00 2001 From: Dima Arnautov Date: Wed, 9 Jun 2021 11:00:05 +0200 Subject: [PATCH 16/19] [ML] Remove script fields from the Anomaly detection alerting rule executor (#101607) * [ML] remove script fields * [ML] fix initial score --- .../ml/server/lib/alerts/alerting_service.ts | 138 +++++------------- 1 file changed, 39 insertions(+), 99 deletions(-) diff --git a/x-pack/plugins/ml/server/lib/alerts/alerting_service.ts b/x-pack/plugins/ml/server/lib/alerts/alerting_service.ts index 0d4d117b69bf3..e7d3ef97a301b 100644 --- a/x-pack/plugins/ml/server/lib/alerts/alerting_service.ts +++ b/x-pack/plugins/ml/server/lib/alerts/alerting_service.ts @@ -41,6 +41,8 @@ type AggResultsResponse = { key?: number } & { }; }; +const TIME_RANGE_PADDING = 10; + /** * Mapping for result types and corresponding score fields. */ @@ -63,43 +65,6 @@ export function alertingServiceProvider(mlClient: MlClient, datafeedsService: Da }; }; - const getCommonScriptedFields = () => { - return { - start: { - script: { - lang: 'painless', - source: `LocalDateTime.ofEpochSecond((doc["timestamp"].value.getMillis()-((doc["bucket_span"].value * 1000) - * params.padding)) / 1000, 0, ZoneOffset.UTC).toString()+\":00.000Z\"`, - params: { - padding: 10, - }, - }, - }, - end: { - script: { - lang: 'painless', - source: `LocalDateTime.ofEpochSecond((doc["timestamp"].value.getMillis()+((doc["bucket_span"].value * 1000) - * params.padding)) / 1000, 0, ZoneOffset.UTC).toString()+\":00.000Z\"`, - params: { - padding: 10, - }, - }, - }, - timestamp_epoch: { - script: { - lang: 'painless', - source: 'doc["timestamp"].value.getMillis()/1000', - }, - }, - timestamp_iso8601: { - script: { - lang: 'painless', - source: 'doc["timestamp"].value', - }, - }, - }; - }; - /** * Builds an agg query based on the requested result type. * @param resultType @@ -110,9 +75,9 @@ export function alertingServiceProvider(mlClient: MlClient, datafeedsService: Da severity: number, useInitialScore?: boolean ) => { - const influencerScoreField = `${useInitialScore ? 'initial_' : ''}influencer_score`; - const recordScoreField = `${useInitialScore ? 'initial_' : ''}record_score`; - const bucketScoreField = `${useInitialScore ? 'initial_' : ''}anomaly_score`; + const influencerScoreField = getScoreFields(ANOMALY_RESULT_TYPE.INFLUENCER, useInitialScore); + const recordScoreField = getScoreFields(ANOMALY_RESULT_TYPE.RECORD, useInitialScore); + const bucketScoreField = getScoreFields(ANOMALY_RESULT_TYPE.BUCKET, useInitialScore); return { influencer_results: { @@ -140,27 +105,13 @@ export function alertingServiceProvider(mlClient: MlClient, datafeedsService: Da 'influencer_field_name', 'influencer_field_value', 'influencer_score', + 'initial_influencer_score', 'is_interim', 'job_id', + 'bucket_span', ], }, size: 3, - script_fields: { - ...getCommonScriptedFields(), - score: { - script: { - lang: 'painless', - source: `Math.floor(doc["${influencerScoreField}"].value)`, - }, - }, - unique_key: { - script: { - lang: 'painless', - source: - 'doc["timestamp"].value + "_" + doc["influencer_field_name"].value + "_" + doc["influencer_field_value"].value', - }, - }, - }, }, }, }, @@ -188,6 +139,7 @@ export function alertingServiceProvider(mlClient: MlClient, datafeedsService: Da 'result_type', 'timestamp', 'record_score', + 'initial_record_score', 'is_interim', 'function', 'field_name', @@ -199,24 +151,10 @@ export function alertingServiceProvider(mlClient: MlClient, datafeedsService: Da 'partition_field_value', 'job_id', 'detector_index', + 'bucket_span', ], }, size: 3, - script_fields: { - ...getCommonScriptedFields(), - score: { - script: { - lang: 'painless', - source: `Math.floor(doc["${recordScoreField}"].value)`, - }, - }, - unique_key: { - script: { - lang: 'painless', - source: 'doc["timestamp"].value + "_" + doc["function"].value', - }, - }, - }, }, }, }, @@ -247,25 +185,12 @@ export function alertingServiceProvider(mlClient: MlClient, datafeedsService: Da 'result_type', 'timestamp', 'anomaly_score', + 'initial_anomaly_score', 'is_interim', + 'bucket_span', ], }, size: 1, - script_fields: { - ...getCommonScriptedFields(), - score: { - script: { - lang: 'painless', - source: `Math.floor(doc["${bucketScoreField}"].value)`, - }, - }, - unique_key: { - script: { - lang: 'painless', - source: 'doc["timestamp"].value', - }, - }, - }, }, }, }, @@ -282,6 +207,10 @@ export function alertingServiceProvider(mlClient: MlClient, datafeedsService: Da return source.job_id; }; + const getScoreFields = (resultType: AnomalyResultType, useInitialScore?: boolean) => { + return `${useInitialScore ? 'initial_' : ''}${resultTypeScoreMapping[resultType]}`; + }; + const getRecordKey = (source: AnomalyRecordDoc): string => { let alertInstanceKey = `${source.job_id}_${source.timestamp}`; @@ -294,18 +223,23 @@ export function alertingServiceProvider(mlClient: MlClient, datafeedsService: Da return alertInstanceKey; }; - const getResultsFormatter = (resultType: AnomalyResultType) => { + /** + * Returns a callback for formatting elasticsearch aggregation response + * to the alert context. + * @param resultType + */ + const getResultsFormatter = (resultType: AnomalyResultType, useInitialScore: boolean = false) => { const resultsLabel = getAggResultsLabel(resultType); return (v: AggResultsResponse): AlertExecutionResult | undefined => { const aggTypeResults = v[resultsLabel.aggGroupLabel]; if (aggTypeResults.doc_count === 0) { return; } - const requestedAnomalies = aggTypeResults[resultsLabel.topHitsLabel].hits.hits; - const topAnomaly = requestedAnomalies[0]; const alertInstanceKey = getAlertInstanceKey(topAnomaly._source); + const timestamp = topAnomaly._source.timestamp; + const bucketSpanInSeconds = topAnomaly._source.bucket_span; return { count: aggTypeResults.doc_count, @@ -315,26 +249,32 @@ export function alertingServiceProvider(mlClient: MlClient, datafeedsService: Da alertInstanceKey, jobIds: [...new Set(requestedAnomalies.map((h) => h._source.job_id))], isInterim: requestedAnomalies.some((h) => h._source.is_interim), - timestamp: topAnomaly._source.timestamp, - timestampIso8601: topAnomaly.fields.timestamp_iso8601[0], - timestampEpoch: topAnomaly.fields.timestamp_epoch[0], - score: topAnomaly.fields.score[0], + timestamp, + timestampIso8601: new Date(timestamp).toISOString(), + timestampEpoch: timestamp / 1000, + score: Math.floor(topAnomaly._source[getScoreFields(resultType, useInitialScore)]), bucketRange: { - start: topAnomaly.fields.start[0], - end: topAnomaly.fields.end[0], + start: new Date( + timestamp - bucketSpanInSeconds * 1000 * TIME_RANGE_PADDING + ).toISOString(), + end: new Date(timestamp + bucketSpanInSeconds * 1000 * TIME_RANGE_PADDING).toISOString(), }, topRecords: v.record_results.top_record_hits.hits.hits.map((h) => { return { ...h._source, - score: h.fields.score[0], + score: Math.floor( + h._source[getScoreFields(ANOMALY_RESULT_TYPE.RECORD, useInitialScore)] + ), unique_key: getRecordKey(h._source), }; }) as RecordAnomalyAlertDoc[], topInfluencers: v.influencer_results.top_influencer_hits.hits.hits.map((h) => { return { ...h._source, - score: h.fields.score[0], - unique_key: h.fields.unique_key[0], + score: Math.floor( + h._source[getScoreFields(ANOMALY_RESULT_TYPE.INFLUENCER, useInitialScore)] + ), + unique_key: `${h._source.timestamp}_${h._source.influencer_field_name}_${h._source.influencer_field_value}`, }; }) as InfluencerAnomalyAlertDoc[], }; @@ -447,7 +387,7 @@ export function alertingServiceProvider(mlClient: MlClient, datafeedsService: Da const resultsLabel = getAggResultsLabel(params.resultType); - const formatter = getResultsFormatter(params.resultType); + const formatter = getResultsFormatter(params.resultType, !!previewTimeInterval); return (previewTimeInterval ? (result as { From 16e66b82b00b01af534643b7fbda2c7209a144d6 Mon Sep 17 00:00:00 2001 From: Dmitry Shevchenko Date: Wed, 9 Jun 2021 11:32:45 +0200 Subject: [PATCH 17/19] Implement "select all" rules feature (#100554) --- .../security_solution/common/constants.ts | 1 + .../schemas/common/schemas.ts | 12 + .../detection_engine/schemas/request/index.ts | 1 + .../perform_bulk_action_schema.mock.ts} | 13 +- .../perform_bulk_action_schema.test.ts | 68 ++++++ .../request/perform_bulk_action_schema.ts | 18 ++ .../detection_rules/custom_query_rule.spec.ts | 4 +- .../event_correlation_rule.spec.ts | 6 +- .../indicator_match_rule.spec.ts | 4 +- .../machine_learning_rule.spec.ts | 4 +- .../detection_rules/override.spec.ts | 4 +- .../detection_rules/prebuilt_rules.spec.ts | 64 +++-- .../detection_rules/sorting.spec.ts | 6 +- .../detection_rules/threshold_rule.spec.ts | 4 +- .../cypress/screens/alerts_detection_rules.ts | 14 ++ .../cypress/tasks/alerts_detection_rules.ts | 49 +++- .../__snapshots__/index.test.tsx.snap | 3 - .../generic_downloader/index.test.tsx | 41 ---- .../components/generic_downloader/index.tsx | 112 --------- .../public/common/hooks/use_bool_state.ts | 33 +++ .../public/common/hooks/use_value_changed.ts | 28 +++ .../public/common/utils/download_blob.ts | 23 ++ .../rules/all_rules_tables/index.test.tsx | 6 +- .../rules/all_rules_tables/index.tsx | 10 +- .../load_empty_prompt.test.tsx | 2 +- .../pre_packaged_rules/load_empty_prompt.tsx | 11 +- .../__snapshots__/index.test.tsx.snap | 7 - .../rule_actions_overflow/index.test.tsx | 109 +++------ .../rules/rule_actions_overflow/index.tsx | 67 +++--- .../containers/detection_engine/rules/api.ts | 43 ++-- .../rules_table/rules_table_reducer.test.ts | 159 +++++++----- .../rules/rules_table/rules_table_reducer.ts | 227 +++++++++--------- .../rules_table/use_async_confirmation.ts | 46 ++++ .../rules/rules_table/use_rules_table.ts | 15 +- .../detection_engine/rules/types.ts | 21 +- .../detection_engine/rules/utils.test.ts | 64 +++++ .../detection_engine/rules/utils.ts | 41 ++++ .../detection_engine/rules/all/actions.tsx | 89 +++++-- .../rules/all/batch_actions.tsx | 202 +++++++++++----- .../detection_engine/rules/all/columns.tsx | 10 +- .../all/exceptions/exceptions_table.test.tsx | 2 +- .../rules/all/exceptions/exceptions_table.tsx | 8 +- .../detection_engine/rules/all/helpers.ts | 16 ++ .../detection_engine/rules/all/index.test.tsx | 14 +- .../detection_engine/rules/all/index.tsx | 8 +- .../rules/all/rules_tables.tsx | 123 +++++++--- .../rules/all/utility_bar.test.tsx | 12 +- .../rules/all/utility_bar.tsx | 40 ++- .../detection_engine/rules/create/index.tsx | 4 +- .../detection_engine/rules/details/index.tsx | 10 +- .../detection_engine/rules/edit/index.tsx | 4 +- .../detection_engine/rules/helpers.test.tsx | 28 +-- .../pages/detection_engine/rules/helpers.tsx | 4 +- .../pages/detection_engine/rules/index.tsx | 12 +- .../detection_engine/rules/translations.ts | 57 ++++- .../export_timeline/export_timeline.test.tsx | 26 +- .../export_timeline/export_timeline.tsx | 47 ++-- .../open_timeline/export_timeline/index.tsx | 3 - .../open_timeline/open_timeline.tsx | 4 +- .../public/timelines/containers/api.ts | 6 +- .../routes/__mocks__/request_responses.ts | 9 + .../routes/rules/delete_rules_bulk_route.ts | 38 ++- .../routes/rules/delete_rules_route.ts | 48 ++-- .../rules/perform_bulk_action_route.test.ts | 148 ++++++++++++ .../routes/rules/perform_bulk_action_route.ts | 172 +++++++++++++ .../detection_engine/rules/add_tags.test.ts | 2 +- .../lib/detection_engine/rules/add_tags.ts | 2 +- .../rules/delete_rules.test.ts | 164 ++++--------- .../detection_engine/rules/delete_rules.ts | 37 +-- .../rules/duplicate_rule.test.ts | 133 ++++++++++ .../detection_engine/rules/duplicate_rule.ts | 40 +++ .../lib/detection_engine/rules/enable_rule.ts | 47 ++++ .../lib/detection_engine/rules/find_rules.ts | 2 +- .../lib/detection_engine/rules/patch_rules.ts | 32 +-- .../lib/detection_engine/rules/types.ts | 8 +- .../detection_engine/rules/update_rules.ts | 22 +- .../security_solution/server/routes/index.ts | 2 + .../translations/translations/ja-JP.json | 1 - .../translations/translations/zh-CN.json | 2 - .../security_and_spaces/tests/index.ts | 1 + .../tests/perform_bulk_action.ts | 152 ++++++++++++ 81 files changed, 2100 insertions(+), 1031 deletions(-) rename x-pack/plugins/security_solution/{public/common/components/generic_downloader/translations.ts => common/detection_engine/schemas/request/perform_bulk_action_schema.mock.ts} (50%) create mode 100644 x-pack/plugins/security_solution/common/detection_engine/schemas/request/perform_bulk_action_schema.test.ts create mode 100644 x-pack/plugins/security_solution/common/detection_engine/schemas/request/perform_bulk_action_schema.ts delete mode 100644 x-pack/plugins/security_solution/public/common/components/generic_downloader/__snapshots__/index.test.tsx.snap delete mode 100644 x-pack/plugins/security_solution/public/common/components/generic_downloader/index.test.tsx delete mode 100644 x-pack/plugins/security_solution/public/common/components/generic_downloader/index.tsx create mode 100644 x-pack/plugins/security_solution/public/common/hooks/use_bool_state.ts create mode 100644 x-pack/plugins/security_solution/public/common/hooks/use_value_changed.ts create mode 100644 x-pack/plugins/security_solution/public/common/utils/download_blob.ts create mode 100644 x-pack/plugins/security_solution/public/detections/containers/detection_engine/rules/rules_table/use_async_confirmation.ts create mode 100644 x-pack/plugins/security_solution/public/detections/containers/detection_engine/rules/utils.test.ts create mode 100644 x-pack/plugins/security_solution/public/detections/containers/detection_engine/rules/utils.ts create mode 100644 x-pack/plugins/security_solution/server/lib/detection_engine/routes/rules/perform_bulk_action_route.test.ts create mode 100644 x-pack/plugins/security_solution/server/lib/detection_engine/routes/rules/perform_bulk_action_route.ts create mode 100644 x-pack/plugins/security_solution/server/lib/detection_engine/rules/duplicate_rule.test.ts create mode 100644 x-pack/plugins/security_solution/server/lib/detection_engine/rules/duplicate_rule.ts create mode 100644 x-pack/plugins/security_solution/server/lib/detection_engine/rules/enable_rule.ts create mode 100644 x-pack/test/detection_engine_api_integration/security_and_spaces/tests/perform_bulk_action.ts diff --git a/x-pack/plugins/security_solution/common/constants.ts b/x-pack/plugins/security_solution/common/constants.ts index 91b48afdc4ed1..87e99a4b472e7 100644 --- a/x-pack/plugins/security_solution/common/constants.ts +++ b/x-pack/plugins/security_solution/common/constants.ts @@ -186,6 +186,7 @@ export const DETECTION_ENGINE_INDEX_URL = `${DETECTION_ENGINE_URL}/index`; export const DETECTION_ENGINE_TAGS_URL = `${DETECTION_ENGINE_URL}/tags`; export const DETECTION_ENGINE_RULES_STATUS_URL = `${DETECTION_ENGINE_RULES_URL}/_find_statuses`; export const DETECTION_ENGINE_PREPACKAGED_RULES_STATUS_URL = `${DETECTION_ENGINE_RULES_URL}/prepackaged/_status`; +export const DETECTION_ENGINE_RULES_BULK_ACTION = `${DETECTION_ENGINE_RULES_URL}/_bulk_action`; export const TIMELINE_URL = '/api/timeline'; export const TIMELINES_URL = '/api/timelines'; diff --git a/x-pack/plugins/security_solution/common/detection_engine/schemas/common/schemas.ts b/x-pack/plugins/security_solution/common/detection_engine/schemas/common/schemas.ts index 7b49b68ab79a1..c9a9d3bdcb24c 100644 --- a/x-pack/plugins/security_solution/common/detection_engine/schemas/common/schemas.ts +++ b/x-pack/plugins/security_solution/common/detection_engine/schemas/common/schemas.ts @@ -82,6 +82,8 @@ export const ruleIdOrUndefined = t.union([rule_id, t.undefined]); export type RuleIdOrUndefined = t.TypeOf; export const id = UUID; +export type Id = t.TypeOf; + export const idOrUndefined = t.union([id, t.undefined]); export type IdOrUndefined = t.TypeOf; @@ -408,3 +410,13 @@ export const privilege = t.type({ }); export type Privilege = t.TypeOf; + +export enum BulkAction { + 'enable' = 'enable', + 'disable' = 'disable', + 'export' = 'export', + 'delete' = 'delete', + 'duplicate' = 'duplicate', +} + +export const bulkAction = t.keyof(BulkAction); diff --git a/x-pack/plugins/security_solution/common/detection_engine/schemas/request/index.ts b/x-pack/plugins/security_solution/common/detection_engine/schemas/request/index.ts index 1035e9128305c..7722feb5f080d 100644 --- a/x-pack/plugins/security_solution/common/detection_engine/schemas/request/index.ts +++ b/x-pack/plugins/security_solution/common/detection_engine/schemas/request/index.ts @@ -17,3 +17,4 @@ export * from './query_signals_index_schema'; export * from './set_signal_status_schema'; export * from './update_rules_bulk_schema'; export * from './rule_schemas'; +export * from './perform_bulk_action_schema'; diff --git a/x-pack/plugins/security_solution/public/common/components/generic_downloader/translations.ts b/x-pack/plugins/security_solution/common/detection_engine/schemas/request/perform_bulk_action_schema.mock.ts similarity index 50% rename from x-pack/plugins/security_solution/public/common/components/generic_downloader/translations.ts rename to x-pack/plugins/security_solution/common/detection_engine/schemas/request/perform_bulk_action_schema.mock.ts index 9104d4e7c0b45..cb78168fbec6e 100644 --- a/x-pack/plugins/security_solution/public/common/components/generic_downloader/translations.ts +++ b/x-pack/plugins/security_solution/common/detection_engine/schemas/request/perform_bulk_action_schema.mock.ts @@ -5,11 +5,10 @@ * 2.0. */ -import { i18n } from '@kbn/i18n'; +import { BulkAction } from '../common/schemas'; +import { PerformBulkActionSchema } from './perform_bulk_action_schema'; -export const EXPORT_FAILURE = i18n.translate( - 'xpack.securitySolution.detectionEngine.rules.components.genericDownloader.exportFailureTitle', - { - defaultMessage: 'Failed to export data…', - } -); +export const getPerformBulkActionSchemaMock = (): PerformBulkActionSchema => ({ + query: '', + action: BulkAction.disable, +}); diff --git a/x-pack/plugins/security_solution/common/detection_engine/schemas/request/perform_bulk_action_schema.test.ts b/x-pack/plugins/security_solution/common/detection_engine/schemas/request/perform_bulk_action_schema.test.ts new file mode 100644 index 0000000000000..a9707b88f5240 --- /dev/null +++ b/x-pack/plugins/security_solution/common/detection_engine/schemas/request/perform_bulk_action_schema.test.ts @@ -0,0 +1,68 @@ +/* + * 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 { performBulkActionSchema, PerformBulkActionSchema } from './perform_bulk_action_schema'; +import { exactCheck, foldLeftRight, getPaths } from '@kbn/securitysolution-io-ts-utils'; +import { left } from 'fp-ts/lib/Either'; +import { BulkAction } from '../common/schemas'; + +describe('perform_bulk_action_schema', () => { + test('query and action is valid', () => { + const payload: PerformBulkActionSchema = { + query: 'name: test', + action: BulkAction.enable, + }; + + const decoded = performBulkActionSchema.decode(payload); + const checked = exactCheck(payload, decoded); + const message = foldLeftRight(checked); + expect(getPaths(left(message.errors))).toEqual([]); + expect(message.schema).toEqual(payload); + }); + + test('missing query is valid', () => { + const payload: PerformBulkActionSchema = { + query: undefined, + action: BulkAction.enable, + }; + + const decoded = performBulkActionSchema.decode(payload); + const checked = exactCheck(payload, decoded); + const message = foldLeftRight(checked); + expect(getPaths(left(message.errors))).toEqual([]); + expect(message.schema).toEqual(payload); + }); + + test('missing action is invalid', () => { + const payload: Omit = { + query: 'name: test', + }; + + const decoded = performBulkActionSchema.decode(payload); + const checked = exactCheck(payload, decoded); + const message = foldLeftRight(checked); + expect(getPaths(left(message.errors))).toEqual([ + 'Invalid value "undefined" supplied to "action"', + ]); + expect(message.schema).toEqual({}); + }); + + test('unknown action is invalid', () => { + const payload: Omit & { action: 'unknown' } = { + query: 'name: test', + action: 'unknown', + }; + + const decoded = performBulkActionSchema.decode(payload); + const checked = exactCheck(payload, decoded); + const message = foldLeftRight(checked); + expect(getPaths(left(message.errors))).toEqual([ + 'Invalid value "unknown" supplied to "action"', + ]); + expect(message.schema).toEqual({}); + }); +}); diff --git a/x-pack/plugins/security_solution/common/detection_engine/schemas/request/perform_bulk_action_schema.ts b/x-pack/plugins/security_solution/common/detection_engine/schemas/request/perform_bulk_action_schema.ts new file mode 100644 index 0000000000000..adb26f107c8cd --- /dev/null +++ b/x-pack/plugins/security_solution/common/detection_engine/schemas/request/perform_bulk_action_schema.ts @@ -0,0 +1,18 @@ +/* + * 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 * as t from 'io-ts'; +import { bulkAction, queryOrUndefined } from '../common/schemas'; + +export const performBulkActionSchema = t.exact( + t.type({ + query: queryOrUndefined, + action: bulkAction, + }) +); + +export type PerformBulkActionSchema = t.TypeOf; diff --git a/x-pack/plugins/security_solution/cypress/integration/detection_rules/custom_query_rule.spec.ts b/x-pack/plugins/security_solution/cypress/integration/detection_rules/custom_query_rule.spec.ts index 2f98cb15287d6..8210c7c6d8b20 100644 --- a/x-pack/plugins/security_solution/cypress/integration/detection_rules/custom_query_rule.spec.ts +++ b/x-pack/plugins/security_solution/cypress/integration/detection_rules/custom_query_rule.spec.ts @@ -80,7 +80,7 @@ import { waitForAlertsPanelToBeLoaded, } from '../../tasks/alerts'; import { - changeRowsPerPageTo300, + changeRowsPerPageTo100, deleteFirstRule, deleteSelectedRules, editFirstRule, @@ -159,7 +159,7 @@ describe('Custom detection rules creation', () => { cy.get(CUSTOM_RULES_BTN).should('have.text', 'Custom rules (1)'); - changeRowsPerPageTo300(); + changeRowsPerPageTo100(); cy.get(RULES_TABLE).then(($table) => { cy.wrap($table.find(RULES_ROW).length).should('eql', expectedNumberOfRules); diff --git a/x-pack/plugins/security_solution/cypress/integration/detection_rules/event_correlation_rule.spec.ts b/x-pack/plugins/security_solution/cypress/integration/detection_rules/event_correlation_rule.spec.ts index 0dbecde3d4d3f..b38796cca373d 100644 --- a/x-pack/plugins/security_solution/cypress/integration/detection_rules/event_correlation_rule.spec.ts +++ b/x-pack/plugins/security_solution/cypress/integration/detection_rules/event_correlation_rule.spec.ts @@ -56,7 +56,7 @@ import { waitForAlertsPanelToBeLoaded, } from '../../tasks/alerts'; import { - changeRowsPerPageTo300, + changeRowsPerPageTo100, filterByCustomRules, goToCreateNewRule, goToRuleDetails, @@ -113,7 +113,7 @@ describe('Detection rules, EQL', () => { cy.get(CUSTOM_RULES_BTN).should('have.text', 'Custom rules (1)'); - changeRowsPerPageTo300(); + changeRowsPerPageTo100(); cy.get(RULES_TABLE).then(($table) => { cy.wrap($table.find(RULES_ROW).length).should('eql', expectedNumberOfRules); @@ -208,7 +208,7 @@ describe('Detection rules, sequence EQL', () => { cy.get(CUSTOM_RULES_BTN).should('have.text', 'Custom rules (1)'); - changeRowsPerPageTo300(); + changeRowsPerPageTo100(); cy.get(RULES_TABLE).then(($table) => { cy.wrap($table.find(RULES_ROW).length).should('eql', expectedNumberOfRules); diff --git a/x-pack/plugins/security_solution/cypress/integration/detection_rules/indicator_match_rule.spec.ts b/x-pack/plugins/security_solution/cypress/integration/detection_rules/indicator_match_rule.spec.ts index d0f2cd9f45743..bc8cf0137fa83 100644 --- a/x-pack/plugins/security_solution/cypress/integration/detection_rules/indicator_match_rule.spec.ts +++ b/x-pack/plugins/security_solution/cypress/integration/detection_rules/indicator_match_rule.spec.ts @@ -78,7 +78,7 @@ import { scrollJsonViewToBottom, } from '../../tasks/alerts_details'; import { - changeRowsPerPageTo300, + changeRowsPerPageTo100, duplicateFirstRule, duplicateSelectedRules, duplicateRuleFromMenu, @@ -424,7 +424,7 @@ describe('indicator match', () => { cy.get(CUSTOM_RULES_BTN).should('have.text', 'Custom rules (1)'); - changeRowsPerPageTo300(); + changeRowsPerPageTo100(); cy.get(RULES_TABLE).then(($table) => { cy.wrap($table.find(RULES_ROW).length).should('eql', expectedNumberOfRules); diff --git a/x-pack/plugins/security_solution/cypress/integration/detection_rules/machine_learning_rule.spec.ts b/x-pack/plugins/security_solution/cypress/integration/detection_rules/machine_learning_rule.spec.ts index 0fe1326947a12..65dde40bbd76b 100644 --- a/x-pack/plugins/security_solution/cypress/integration/detection_rules/machine_learning_rule.spec.ts +++ b/x-pack/plugins/security_solution/cypress/integration/detection_rules/machine_learning_rule.spec.ts @@ -46,7 +46,7 @@ import { waitForAlertsPanelToBeLoaded, } from '../../tasks/alerts'; import { - changeRowsPerPageTo300, + changeRowsPerPageTo100, filterByCustomRules, goToCreateNewRule, goToRuleDetails, @@ -90,7 +90,7 @@ describe('Detection rules, machine learning', () => { cy.get(CUSTOM_RULES_BTN).should('have.text', 'Custom rules (1)'); - changeRowsPerPageTo300(); + changeRowsPerPageTo100(); cy.get(RULES_TABLE).then(($table) => { cy.wrap($table.find(RULES_ROW).length).should('eql', expectedNumberOfRules); diff --git a/x-pack/plugins/security_solution/cypress/integration/detection_rules/override.spec.ts b/x-pack/plugins/security_solution/cypress/integration/detection_rules/override.spec.ts index eb10f32bb8989..f9f1ca14c8164 100644 --- a/x-pack/plugins/security_solution/cypress/integration/detection_rules/override.spec.ts +++ b/x-pack/plugins/security_solution/cypress/integration/detection_rules/override.spec.ts @@ -68,7 +68,7 @@ import { waitForAlertsPanelToBeLoaded, } from '../../tasks/alerts'; import { - changeRowsPerPageTo300, + changeRowsPerPageTo100, filterByCustomRules, goToCreateNewRule, goToRuleDetails, @@ -121,7 +121,7 @@ describe('Detection rules, override', () => { cy.get(CUSTOM_RULES_BTN).should('have.text', 'Custom rules (1)'); - changeRowsPerPageTo300(); + changeRowsPerPageTo100(); const expectedNumberOfRules = 1; cy.get(RULES_TABLE).then(($table) => { diff --git a/x-pack/plugins/security_solution/cypress/integration/detection_rules/prebuilt_rules.spec.ts b/x-pack/plugins/security_solution/cypress/integration/detection_rules/prebuilt_rules.spec.ts index fb0a01bd1c7d3..74e1d082ae410 100644 --- a/x-pack/plugins/security_solution/cypress/integration/detection_rules/prebuilt_rules.spec.ts +++ b/x-pack/plugins/security_solution/cypress/integration/detection_rules/prebuilt_rules.spec.ts @@ -8,23 +8,29 @@ import { COLLAPSED_ACTION_BTN, ELASTIC_RULES_BTN, + pageSelector, RELOAD_PREBUILT_RULES_BTN, - RULES_ROW, - RULES_TABLE, + RULES_EMPTY_PROMPT, + RULE_SWITCH, SHOWING_RULES_TEXT, } from '../../screens/alerts_detection_rules'; import { goToManageAlertsDetectionRules, waitForAlertsIndexToBeCreated } from '../../tasks/alerts'; import { - changeRowsPerPageTo300, + changeRowsPerPageTo100, deleteFirstRule, deleteSelectedRules, loadPrebuiltDetectionRules, - goToNextPage, reloadDeletedRules, selectNumberOfRules, waitForRulesTableToBeLoaded, waitForPrebuiltDetectionRulesToBeLoaded, + selectAllRules, + confirmRulesDelete, + activateSelectedRules, + waitForRuleToChangeStatus, + deactivateSelectedRules, + changeRowsPerPageTo, } from '../../tasks/alerts_detection_rules'; import { loginAndWaitForPageWithoutDateRange } from '../../tasks/login'; @@ -39,7 +45,9 @@ describe('Alerts rules, prebuilt rules', () => { }); it('Loads prebuilt rules', () => { + const rowsPerPage = 100; const expectedNumberOfRules = totalNumberOfPrebuiltRules; + const expectedNumberOfPages = Math.ceil(totalNumberOfPrebuiltRules / rowsPerPage); const expectedElasticRulesBtnText = `Elastic rules (${expectedNumberOfRules})`; loginAndWaitForPageWithoutDateRange(DETECTIONS_URL); @@ -51,23 +59,14 @@ describe('Alerts rules, prebuilt rules', () => { cy.get(ELASTIC_RULES_BTN).should('have.text', expectedElasticRulesBtnText); - changeRowsPerPageTo300(); + changeRowsPerPageTo(rowsPerPage); cy.get(SHOWING_RULES_TEXT).should('have.text', `Showing ${expectedNumberOfRules} rules`); - cy.get(RULES_TABLE).then(($table1) => { - const firstScreenRules = $table1.find(RULES_ROW).length; - goToNextPage(); - cy.get(RULES_TABLE).then(($table2) => { - const secondScreenRules = $table2.find(RULES_ROW).length; - const totalNumberOfRules = firstScreenRules + secondScreenRules; - - expect(totalNumberOfRules).to.eql(expectedNumberOfRules); - }); - }); + cy.get(pageSelector(expectedNumberOfPages)).should('exist'); }); }); -describe('Deleting prebuilt rules', () => { +describe('Actions with prebuilt rules', () => { beforeEach(() => { const expectedNumberOfRules = totalNumberOfPrebuiltRules; const expectedElasticRulesBtnText = `Elastic rules (${expectedNumberOfRules})`; @@ -81,11 +80,30 @@ describe('Deleting prebuilt rules', () => { waitForPrebuiltDetectionRulesToBeLoaded(); cy.get(ELASTIC_RULES_BTN).should('have.text', expectedElasticRulesBtnText); + }); + + it('Allows to activate/deactivate all rules at once', () => { + selectAllRules(); + activateSelectedRules(); + waitForRuleToChangeStatus(); + cy.get(RULE_SWITCH).should('have.attr', 'aria-checked', 'true'); - changeRowsPerPageTo300(); + selectAllRules(); + deactivateSelectedRules(); + waitForRuleToChangeStatus(); + cy.get(RULE_SWITCH).should('have.attr', 'aria-checked', 'false'); + }); + + it('Allows to delete all rules at once', () => { + selectAllRules(); + deleteSelectedRules(); + confirmRulesDelete(); + cy.get(RULES_EMPTY_PROMPT).should('be.visible'); }); it('Does not allow to delete one rule when more than one is selected', () => { + changeRowsPerPageTo100(); + const numberOfRulesToBeSelected = 2; selectNumberOfRules(numberOfRulesToBeSelected); @@ -95,12 +113,14 @@ describe('Deleting prebuilt rules', () => { }); it('Deletes and recovers one rule', () => { + changeRowsPerPageTo100(); + const expectedNumberOfRulesAfterDeletion = totalNumberOfPrebuiltRules - 1; const expectedNumberOfRulesAfterRecovering = totalNumberOfPrebuiltRules; deleteFirstRule(); cy.reload(); - changeRowsPerPageTo300(); + changeRowsPerPageTo100(); cy.get(ELASTIC_RULES_BTN).should( 'have.text', @@ -114,7 +134,7 @@ describe('Deleting prebuilt rules', () => { cy.get(RELOAD_PREBUILT_RULES_BTN).should('not.exist'); cy.reload(); - changeRowsPerPageTo300(); + changeRowsPerPageTo100(); cy.get(ELASTIC_RULES_BTN).should( 'have.text', @@ -123,6 +143,8 @@ describe('Deleting prebuilt rules', () => { }); it('Deletes and recovers more than one rule', () => { + changeRowsPerPageTo100(); + const numberOfRulesToBeSelected = 2; const expectedNumberOfRulesAfterDeletion = totalNumberOfPrebuiltRules - 2; const expectedNumberOfRulesAfterRecovering = totalNumberOfPrebuiltRules; @@ -130,7 +152,7 @@ describe('Deleting prebuilt rules', () => { selectNumberOfRules(numberOfRulesToBeSelected); deleteSelectedRules(); cy.reload(); - changeRowsPerPageTo300(); + changeRowsPerPageTo100(); cy.get(RELOAD_PREBUILT_RULES_BTN).should('exist'); cy.get(RELOAD_PREBUILT_RULES_BTN).should( @@ -147,7 +169,7 @@ describe('Deleting prebuilt rules', () => { cy.get(RELOAD_PREBUILT_RULES_BTN).should('not.exist'); cy.reload(); - changeRowsPerPageTo300(); + changeRowsPerPageTo100(); cy.get(ELASTIC_RULES_BTN).should( 'have.text', diff --git a/x-pack/plugins/security_solution/cypress/integration/detection_rules/sorting.spec.ts b/x-pack/plugins/security_solution/cypress/integration/detection_rules/sorting.spec.ts index 0cf3caa09814c..f1ee0d39f545f 100644 --- a/x-pack/plugins/security_solution/cypress/integration/detection_rules/sorting.spec.ts +++ b/x-pack/plugins/security_solution/cypress/integration/detection_rules/sorting.spec.ts @@ -31,7 +31,7 @@ import { resetAllRulesIdleModalTimeout, sortByActivatedRules, waitForRulesTableToBeLoaded, - waitForRuleToBeActivated, + waitForRuleToChangeStatus, } from '../../tasks/alerts_detection_rules'; import { loginAndWaitForPageWithoutDateRange } from '../../tasks/login'; import { DEFAULT_RULE_REFRESH_INTERVAL_VALUE } from '../../../common/constants'; @@ -62,13 +62,13 @@ describe('Alerts detection rules', () => { .invoke('text') .then((secondInitialRuleName) => { activateRule(SECOND_RULE); - waitForRuleToBeActivated(); + waitForRuleToChangeStatus(); cy.get(RULE_NAME) .eq(FOURTH_RULE) .invoke('text') .then((fourthInitialRuleName) => { activateRule(FOURTH_RULE); - waitForRuleToBeActivated(); + waitForRuleToChangeStatus(); sortByActivatedRules(); cy.get(RULE_NAME) .eq(FIRST_RULE) diff --git a/x-pack/plugins/security_solution/cypress/integration/detection_rules/threshold_rule.spec.ts b/x-pack/plugins/security_solution/cypress/integration/detection_rules/threshold_rule.spec.ts index 7c09b311807be..0f4095372f92a 100644 --- a/x-pack/plugins/security_solution/cypress/integration/detection_rules/threshold_rule.spec.ts +++ b/x-pack/plugins/security_solution/cypress/integration/detection_rules/threshold_rule.spec.ts @@ -59,7 +59,7 @@ import { waitForAlertsPanelToBeLoaded, } from '../../tasks/alerts'; import { - changeRowsPerPageTo300, + changeRowsPerPageTo100, filterByCustomRules, goToCreateNewRule, goToRuleDetails, @@ -113,7 +113,7 @@ describe('Detection rules, threshold', () => { cy.get(CUSTOM_RULES_BTN).should('have.text', 'Custom rules (1)'); - changeRowsPerPageTo300(); + changeRowsPerPageTo100(); const expectedNumberOfRules = 1; cy.get(RULES_TABLE).then(($table) => { diff --git a/x-pack/plugins/security_solution/cypress/screens/alerts_detection_rules.ts b/x-pack/plugins/security_solution/cypress/screens/alerts_detection_rules.ts index 70dde344c88b6..ba071184d98eb 100644 --- a/x-pack/plugins/security_solution/cypress/screens/alerts_detection_rules.ts +++ b/x-pack/plugins/security_solution/cypress/screens/alerts_detection_rules.ts @@ -25,6 +25,12 @@ export const DUPLICATE_RULE_MENU_PANEL_BTN = '[data-test-subj="rules-details-dup export const REFRESH_BTN = '[data-test-subj="refreshRulesAction"] button'; +export const ACTIVATE_RULE_BULK_BTN = '[data-test-subj="activateRuleBulk"]'; + +export const DEACTIVATE_RULE_BULK_BTN = '[data-test-subj="deactivateRuleBulk"]'; + +export const EXPORT_RULE_BULK_BTN = '[data-test-subj="exportRuleBulk"]'; + export const DELETE_RULE_BULK_BTN = '[data-test-subj="deleteRuleBulk"]'; export const DUPLICATE_RULE_BULK_BTN = '[data-test-subj="duplicateRuleBulk"]'; @@ -87,3 +93,11 @@ export const pageSelector = (pageNumber: number) => `[data-test-subj="pagination-button-${pageNumber - 1}"]`; export const NEXT_BTN = '[data-test-subj="pagination-button-next"]'; + +export const SELECT_ALL_RULES_BTN = '[data-test-subj="selectAllRules"]'; + +export const RULES_EMPTY_PROMPT = '[data-test-subj="rulesEmptyPrompt"]'; + +export const RULES_DELETE_CONFIRMATION_MODAL = '[data-test-subj="allRulesDeleteConfirmationModal"]'; + +export const MODAL_CONFIRMATION_BTN = '[data-test-subj="confirmModalConfirmButton"]'; diff --git a/x-pack/plugins/security_solution/cypress/tasks/alerts_detection_rules.ts b/x-pack/plugins/security_solution/cypress/tasks/alerts_detection_rules.ts index cc14c54a4d84e..78298c9881077 100644 --- a/x-pack/plugins/security_solution/cypress/tasks/alerts_detection_rules.ts +++ b/x-pack/plugins/security_solution/cypress/tasks/alerts_detection_rules.ts @@ -36,6 +36,12 @@ import { DUPLICATE_RULE_MENU_PANEL_BTN, DUPLICATE_RULE_BULK_BTN, RULES_ROW, + SELECT_ALL_RULES_BTN, + MODAL_CONFIRMATION_BTN, + RULES_DELETE_CONFIRMATION_MODAL, + ACTIVATE_RULE_BULK_BTN, + DEACTIVATE_RULE_BULK_BTN, + EXPORT_RULE_BULK_BTN, } from '../screens/alerts_detection_rules'; import { ALL_ACTIONS, DELETE_RULE } from '../screens/rule_details'; @@ -57,11 +63,6 @@ export const duplicateFirstRule = () => { cy.get(DUPLICATE_RULE_ACTION_BTN).click(); }; -export const duplicateSelectedRules = () => { - cy.get(BULK_ACTIONS_BTN).click({ force: true }); - cy.get(DUPLICATE_RULE_BULK_BTN).click(); -}; - /** * Duplicates the rule from the menu and does additional * pipes and checking that the elements are present on the @@ -106,6 +107,26 @@ export const deleteSelectedRules = () => { cy.get(DELETE_RULE_BULK_BTN).click(); }; +export const duplicateSelectedRules = () => { + cy.get(BULK_ACTIONS_BTN).click({ force: true }); + cy.get(DUPLICATE_RULE_BULK_BTN).click(); +}; + +export const activateSelectedRules = () => { + cy.get(BULK_ACTIONS_BTN).click({ force: true }); + cy.get(ACTIVATE_RULE_BULK_BTN).click(); +}; + +export const deactivateSelectedRules = () => { + cy.get(BULK_ACTIONS_BTN).click({ force: true }); + cy.get(DEACTIVATE_RULE_BULK_BTN).click(); +}; + +export const exportSelectedRules = () => { + cy.get(BULK_ACTIONS_BTN).click({ force: true }); + cy.get(EXPORT_RULE_BULK_BTN).click(); +}; + export const exportFirstRule = () => { cy.get(COLLAPSED_ACTION_BTN).first().click({ force: true }); cy.get(EXPORT_ACTION_BTN).click(); @@ -149,6 +170,17 @@ export const selectNumberOfRules = (numberOfRules: number) => { } }; +export const selectAllRules = () => { + cy.get(SELECT_ALL_RULES_BTN).contains('Select all').click(); + cy.get(SELECT_ALL_RULES_BTN).contains('Clear'); +}; + +export const confirmRulesDelete = () => { + cy.get(RULES_DELETE_CONFIRMATION_MODAL).should('be.visible'); + cy.get(MODAL_CONFIRMATION_BTN).click(); + cy.get(RULES_DELETE_CONFIRMATION_MODAL).should('not.exist'); +}; + export const sortByActivatedRules = () => { cy.get(SORT_RULES_BTN).contains('Activated').click({ force: true }); waitForRulesTableToBeRefreshed(); @@ -174,9 +206,10 @@ export const waitForRulesTableToBeAutoRefreshed = () => { export const waitForPrebuiltDetectionRulesToBeLoaded = () => { cy.get(LOAD_PREBUILT_RULES_BTN).should('not.exist'); cy.get(RULES_TABLE).should('exist'); + cy.get(RULES_TABLE_REFRESH_INDICATOR).should('not.exist'); }; -export const waitForRuleToBeActivated = () => { +export const waitForRuleToChangeStatus = () => { cy.get(RULE_SWITCH_LOADER).should('exist'); cy.get(RULE_SWITCH_LOADER).should('not.exist'); }; @@ -215,8 +248,8 @@ export const changeRowsPerPageTo = (rowsCount: number) => { waitForRulesTableToBeRefreshed(); }; -export const changeRowsPerPageTo300 = () => { - changeRowsPerPageTo(300); +export const changeRowsPerPageTo100 = () => { + changeRowsPerPageTo(100); }; export const goToPage = (pageNumber: number) => { diff --git a/x-pack/plugins/security_solution/public/common/components/generic_downloader/__snapshots__/index.test.tsx.snap b/x-pack/plugins/security_solution/public/common/components/generic_downloader/__snapshots__/index.test.tsx.snap deleted file mode 100644 index 219be8cbda311..0000000000000 --- a/x-pack/plugins/security_solution/public/common/components/generic_downloader/__snapshots__/index.test.tsx.snap +++ /dev/null @@ -1,3 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`GenericDownloader renders correctly against snapshot 1`] = ``; diff --git a/x-pack/plugins/security_solution/public/common/components/generic_downloader/index.test.tsx b/x-pack/plugins/security_solution/public/common/components/generic_downloader/index.test.tsx deleted file mode 100644 index b8066c836de72..0000000000000 --- a/x-pack/plugins/security_solution/public/common/components/generic_downloader/index.test.tsx +++ /dev/null @@ -1,41 +0,0 @@ -/* - * 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 { shallow, mount } from 'enzyme'; -import React from 'react'; -import { GenericDownloaderComponent, ExportSelectedData } from './index'; -import { errorToToaster } from '../toasters'; - -jest.mock('../toasters', () => ({ - useStateToaster: jest.fn(() => [jest.fn(), jest.fn()]), - errorToToaster: jest.fn(), -})); - -describe('GenericDownloader', () => { - test('renders correctly against snapshot', () => { - const wrapper = shallow( - - ); - expect(wrapper).toMatchSnapshot(); - }); - - test('show toaster with correct error message if error occurrs', () => { - mount( - - ); - expect((errorToToaster as jest.Mock).mock.calls[0][0].title).toEqual('Failed to export data…'); - }); -}); diff --git a/x-pack/plugins/security_solution/public/common/components/generic_downloader/index.tsx b/x-pack/plugins/security_solution/public/common/components/generic_downloader/index.tsx deleted file mode 100644 index 2a2e425702755..0000000000000 --- a/x-pack/plugins/security_solution/public/common/components/generic_downloader/index.tsx +++ /dev/null @@ -1,112 +0,0 @@ -/* - * 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, { useEffect, useRef } from 'react'; -import styled from 'styled-components'; -import { isFunction } from 'lodash/fp'; -import * as i18n from './translations'; - -import { ExportDocumentsProps } from '../../../detections/containers/detection_engine/rules'; -import { useStateToaster, errorToToaster } from '../toasters'; -import { TimelineErrorResponse } from '../../../../common/types/timeline'; - -const InvisibleAnchor = styled.a` - display: none; -`; - -export type ExportSelectedData = ({ - excludeExportDetails, - filename, - ids, - signal, -}: ExportDocumentsProps) => Promise; - -export interface GenericDownloaderProps { - filename: string; - ids?: string[]; - exportSelectedData: ExportSelectedData; - onExportSuccess?: (exportCount: number) => void; - onExportFailure?: () => void; -} - -/** - * Component for downloading Rules as an exported .ndjson file. Download will occur on each update to `rules` param - * - * @param filename of file to be downloaded - * @param payload Rule[] - * - */ - -export const GenericDownloaderComponent = ({ - exportSelectedData, - filename, - ids, - onExportSuccess, - onExportFailure, -}: GenericDownloaderProps) => { - const anchorRef = useRef(null); - const [, dispatchToaster] = useStateToaster(); - - useEffect(() => { - let isSubscribed = true; - const abortCtrl = new AbortController(); - - const exportData = async () => { - if (anchorRef && anchorRef.current && ids != null && ids.length > 0) { - try { - const exportResponse = await exportSelectedData({ - ids, - signal: abortCtrl.signal, - }); - - if (isSubscribed) { - // this is for supporting IE - if (isFunction(window.navigator.msSaveOrOpenBlob)) { - window.navigator.msSaveBlob(exportResponse); - } else { - const objectURL = window.URL.createObjectURL(exportResponse); - // These are safe-assignments as writes to anchorRef are isolated to exportData - anchorRef.current.href = objectURL; // eslint-disable-line require-atomic-updates - anchorRef.current.download = filename; // eslint-disable-line require-atomic-updates - anchorRef.current.click(); - - if (typeof window.URL.revokeObjectURL === 'function') { - window.URL.revokeObjectURL(objectURL); - } - } - if (onExportSuccess != null) { - onExportSuccess(ids.length); - } - } - } catch (error) { - if (isSubscribed) { - if (onExportFailure != null) { - onExportFailure(); - } - errorToToaster({ title: i18n.EXPORT_FAILURE, error, dispatchToaster }); - } - } - } - }; - - exportData(); - - return () => { - isSubscribed = false; - abortCtrl.abort(); - }; - // eslint-disable-next-line react-hooks/exhaustive-deps - }, [ids]); - - return ; -}; - -GenericDownloaderComponent.displayName = 'GenericDownloaderComponent'; - -export const GenericDownloader = React.memo(GenericDownloaderComponent); - -GenericDownloader.displayName = 'GenericDownloader'; diff --git a/x-pack/plugins/security_solution/public/common/hooks/use_bool_state.ts b/x-pack/plugins/security_solution/public/common/hooks/use_bool_state.ts new file mode 100644 index 0000000000000..f9204de38d680 --- /dev/null +++ b/x-pack/plugins/security_solution/public/common/hooks/use_bool_state.ts @@ -0,0 +1,33 @@ +/* + * 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 { useCallback, useState } from 'react'; + +type UseBoolStateReturn = [ + state: boolean, + setTrue: () => void, + setFalse: () => void, + toggle: () => void +]; + +export const useBoolState = (initial = false): UseBoolStateReturn => { + const [state, setState] = useState(initial); + + const setTrue = useCallback(() => { + setState(true); + }, []); + + const setFalse = useCallback(() => { + setState(false); + }, []); + + const toggle = useCallback(() => { + setState((val) => !val); + }, []); + + return [state, setTrue, setFalse, toggle]; +}; diff --git a/x-pack/plugins/security_solution/public/common/hooks/use_value_changed.ts b/x-pack/plugins/security_solution/public/common/hooks/use_value_changed.ts new file mode 100644 index 0000000000000..ef054d0539757 --- /dev/null +++ b/x-pack/plugins/security_solution/public/common/hooks/use_value_changed.ts @@ -0,0 +1,28 @@ +/* + * 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 { useEffect, useRef } from 'react'; + +/** + * Use this method to watch value for changes. + * + * CAUTION: you probably don't need this hook. Try to use useEffect first. + * It is only useful in rare cases when a value differs by reference but not by content between renders. + * + * @param callback A callback to call when the value changes + * @param nextValue A value to observe for changes + */ +export const useValueChanged = (callback: (value: T) => void, nextValue: T) => { + const prevValue = useRef(nextValue); + + useEffect(() => { + if (JSON.stringify(prevValue.current) !== JSON.stringify(nextValue)) { + prevValue.current = nextValue; + callback(nextValue); + } + }, [callback, nextValue]); +}; diff --git a/x-pack/plugins/security_solution/public/common/utils/download_blob.ts b/x-pack/plugins/security_solution/public/common/utils/download_blob.ts new file mode 100644 index 0000000000000..80f32a8bdaa0c --- /dev/null +++ b/x-pack/plugins/security_solution/public/common/utils/download_blob.ts @@ -0,0 +1,23 @@ +/* + * 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. + */ + +/** + * Method for downloading any file + * + * @param blob raw data + * @param filename of file to be downloaded + * + */ +export const downloadBlob = (blob: Blob, filename: string) => { + const objectURL = window.URL.createObjectURL(blob); + const anchor = document.createElement('a'); + anchor.href = objectURL; + anchor.download = filename; + anchor.click(); + window.URL.revokeObjectURL(objectURL); + anchor.remove(); +}; diff --git a/x-pack/plugins/security_solution/public/detections/components/rules/all_rules_tables/index.test.tsx b/x-pack/plugins/security_solution/public/detections/components/rules/all_rules_tables/index.test.tsx index 3400a960bbc60..d1dfd6ccfd565 100644 --- a/x-pack/plugins/security_solution/public/detections/components/rules/all_rules_tables/index.test.tsx +++ b/x-pack/plugins/security_solution/public/detections/components/rules/all_rules_tables/index.test.tsx @@ -21,7 +21,7 @@ describe('AllRulesTables', () => { { { ; - hasNoPermissions: boolean; + hasPermissions: boolean; monitoringColumns: Array>; pagination: { pageIndex: number; @@ -55,7 +55,7 @@ const emptyPrompt = ( export const AllRulesTablesComponent: React.FC = ({ euiBasicTableSelectionProps, - hasNoPermissions, + hasPermissions, monitoringColumns, pagination, rules, @@ -72,7 +72,7 @@ export const AllRulesTablesComponent: React.FC = ({ = ({ pagination={pagination} ref={tableRef} sorting={sorting} - selection={hasNoPermissions ? undefined : euiBasicTableSelectionProps} + selection={hasPermissions ? euiBasicTableSelectionProps : undefined} /> )} {selectedTab === AllRulesTabs.monitoring && ( void; loading: boolean; - userHasNoPermissions: boolean; + userHasPermissions: boolean; } const PrePackagedRulesPromptComponent: React.FC = ({ createPrePackagedRules, loading = false, - userHasNoPermissions = true, + userHasPermissions = false, }) => { const history = useHistory(); const handlePreBuiltCreation = useCallback(() => { @@ -64,16 +64,17 @@ const PrePackagedRulesPromptComponent: React.FC = ( const loadPrebuiltRulesAndTemplatesButton = useMemo( () => getLoadPrebuiltRulesAndTemplatesButton({ - isDisabled: userHasNoPermissions, + isDisabled: !userHasPermissions, onClick: handlePreBuiltCreation, fill: true, 'data-test-subj': 'load-prebuilt-rules', }), - [getLoadPrebuiltRulesAndTemplatesButton, handlePreBuiltCreation, userHasNoPermissions] + [getLoadPrebuiltRulesAndTemplatesButton, handlePreBuiltCreation, userHasPermissions] ); return ( {i18n.PRE_BUILT_TITLE}} body={

{i18n.PRE_BUILT_MSG}

} actions={ @@ -81,7 +82,7 @@ const PrePackagedRulesPromptComponent: React.FC = ( {loadPrebuiltRulesAndTemplatesButton} - `; diff --git a/x-pack/plugins/security_solution/public/detections/components/rules/rule_actions_overflow/index.test.tsx b/x-pack/plugins/security_solution/public/detections/components/rules/rule_actions_overflow/index.test.tsx index 53f478da28055..3a27469ba2539 100644 --- a/x-pack/plugins/security_solution/public/detections/components/rules/rule_actions_overflow/index.test.tsx +++ b/x-pack/plugins/security_solution/public/detections/components/rules/rule_actions_overflow/index.test.tsx @@ -28,6 +28,16 @@ jest.mock('../../../pages/detection_engine/rules/all/actions', () => ({ editRuleAction: jest.fn(), })); +jest.mock('../../../../common/lib/kibana', () => { + return { + KibanaServices: { + get: () => ({ + http: { fetch: jest.fn() }, + }), + }, + }; +}); + const duplicateRulesActionMock = duplicateRulesAction as jest.Mock; const flushPromises = () => new Promise(setImmediate); @@ -41,7 +51,7 @@ describe('RuleActionsOverflow', () => { const wrapper = shallow( ); @@ -54,7 +64,7 @@ describe('RuleActionsOverflow', () => { const wrapper = mount( ); @@ -70,11 +80,7 @@ describe('RuleActionsOverflow', () => { test('items are empty when there is a null rule within the rules-details-menu-panel', () => { const wrapper = mount( - + ); wrapper.find('[data-test-subj="rules-details-popover-button-icon"] button').simulate('click'); wrapper.update(); @@ -85,11 +91,7 @@ describe('RuleActionsOverflow', () => { test('items are empty when there is an undefined rule within the rules-details-menu-panel', () => { const wrapper = mount( - + ); wrapper.find('[data-test-subj="rules-details-popover-button-icon"] button').simulate('click'); wrapper.update(); @@ -102,7 +104,7 @@ describe('RuleActionsOverflow', () => { const wrapper = mount( ); @@ -119,7 +121,7 @@ describe('RuleActionsOverflow', () => { const wrapper = mount( ); @@ -137,7 +139,7 @@ describe('RuleActionsOverflow', () => { const wrapper = mount( ); @@ -152,7 +154,7 @@ describe('RuleActionsOverflow', () => { const wrapper = mount( ); @@ -167,7 +169,7 @@ describe('RuleActionsOverflow', () => { const wrapper = mount( ); @@ -184,7 +186,7 @@ describe('RuleActionsOverflow', () => { const wrapper = mount( ); @@ -198,11 +200,7 @@ describe('RuleActionsOverflow', () => { test('it calls duplicateRulesAction with the rule and rule.id when rules-details-duplicate-rule is clicked', () => { const rule = mockRule('id'); const wrapper = mount( - + ); wrapper.find('[data-test-subj="rules-details-popover-button-icon"] button').simulate('click'); wrapper.update(); @@ -222,11 +220,7 @@ describe('RuleActionsOverflow', () => { const ruleDuplicate = mockRule('newRule'); duplicateRulesActionMock.mockImplementation(() => Promise.resolve([ruleDuplicate])); const wrapper = mount( - + ); wrapper.find('[data-test-subj="rules-details-popover-button-icon"] button').simulate('click'); wrapper.update(); @@ -244,7 +238,7 @@ describe('RuleActionsOverflow', () => { const wrapper = mount( ); @@ -259,7 +253,7 @@ describe('RuleActionsOverflow', () => { const wrapper = mount( ); @@ -272,33 +266,11 @@ describe('RuleActionsOverflow', () => { ).toEqual(false); }); - test('it sets the rule.rule_id on the generic downloader when rules-details-export-rule is clicked', () => { - const rule = mockRule('id'); - const wrapper = mount( - - ); - wrapper.find('[data-test-subj="rules-details-popover-button-icon"] button').simulate('click'); - wrapper.update(); - wrapper.find('[data-test-subj="rules-details-export-rule"] button').simulate('click'); - wrapper.update(); - expect( - wrapper.find('[data-test-subj="rules-details-generic-downloader"]').prop('ids') - ).toEqual([rule.rule_id]); - }); - test('it does not close the pop over on rules-details-export-rule when the rule is an immutable rule and the user does a click', () => { const rule = mockRule('id'); rule.immutable = true; const wrapper = mount( - + ); wrapper.find('[data-test-subj="rules-details-popover-button-icon"] button').simulate('click'); wrapper.update(); @@ -308,25 +280,6 @@ describe('RuleActionsOverflow', () => { wrapper.find('[data-test-subj="rules-details-popover"]').first().prop('isOpen') ).toEqual(true); }); - - test('it does not set the rule.rule_id on rules-details-export-rule when the rule is an immutable rule', () => { - const rule = mockRule('id'); - rule.immutable = true; - const wrapper = mount( - - ); - wrapper.find('[data-test-subj="rules-details-popover-button-icon"] button').simulate('click'); - wrapper.update(); - wrapper.find('[data-test-subj="rules-details-export-rule"] button').simulate('click'); - wrapper.update(); - expect( - wrapper.find('[data-test-subj="rules-details-generic-downloader"]').prop('ids') - ).toEqual([]); - }); }); describe('rules details delete rule', () => { @@ -335,7 +288,7 @@ describe('RuleActionsOverflow', () => { const wrapper = mount( ); @@ -350,7 +303,7 @@ describe('RuleActionsOverflow', () => { const wrapper = mount( ); @@ -367,7 +320,7 @@ describe('RuleActionsOverflow', () => { const wrapper = mount( ); @@ -381,11 +334,7 @@ describe('RuleActionsOverflow', () => { test('it calls deleteRulesAction with the rule.id when rules-details-delete-rule is clicked', () => { const rule = mockRule('id'); const wrapper = mount( - + ); wrapper.find('[data-test-subj="rules-details-popover-button-icon"] button').simulate('click'); wrapper.update(); diff --git a/x-pack/plugins/security_solution/public/detections/components/rules/rule_actions_overflow/index.tsx b/x-pack/plugins/security_solution/public/detections/components/rules/rule_actions_overflow/index.tsx index 0482e1997c9d1..e0841824d512f 100644 --- a/x-pack/plugins/security_solution/public/detections/components/rules/rule_actions_overflow/index.tsx +++ b/x-pack/plugins/security_solution/public/detections/components/rules/rule_actions_overflow/index.tsx @@ -12,23 +12,24 @@ import { EuiPopover, EuiToolTip, } from '@elastic/eui'; -import React, { useCallback, useMemo, useState } from 'react'; +import React, { useCallback, useMemo } from 'react'; import styled from 'styled-components'; import { noop } from 'lodash/fp'; import { useHistory } from 'react-router-dom'; -import { Rule, exportRules } from '../../../containers/detection_engine/rules'; +import { Rule } from '../../../containers/detection_engine/rules'; import * as i18n from './translations'; import * as i18nActions from '../../../pages/detection_engine/rules/translations'; -import { displaySuccessToast, useStateToaster } from '../../../../common/components/toasters'; +import { useStateToaster } from '../../../../common/components/toasters'; import { deleteRulesAction, duplicateRulesAction, editRuleAction, + exportRulesAction, } from '../../../pages/detection_engine/rules/all/actions'; -import { GenericDownloader } from '../../../../common/components/generic_downloader'; import { getRulesUrl } from '../../../../common/components/link_to/redirect_to_detection_engine'; import { getToolTipContent } from '../../../../common/utils/privileges'; +import { useBoolState } from '../../../../common/hooks/use_bool_state'; const MyEuiButtonIcon = styled(EuiButtonIcon)` &.euiButtonIcon { @@ -43,7 +44,7 @@ const MyEuiButtonIcon = styled(EuiButtonIcon)` interface RuleActionsOverflowComponentProps { rule: Rule | null; - userHasNoPermissions: boolean; + userHasPermissions: boolean; canDuplicateRuleWithActions: boolean; } @@ -52,11 +53,10 @@ interface RuleActionsOverflowComponentProps { */ const RuleActionsOverflowComponent = ({ rule, - userHasNoPermissions, + userHasPermissions, canDuplicateRuleWithActions, }: RuleActionsOverflowComponentProps) => { - const [isPopoverOpen, setIsPopoverOpen] = useState(false); - const [rulesToExport, setRulesToExport] = useState([]); + const [isPopoverOpen, , closePopover, togglePopover] = useBoolState(); const history = useHistory(); const [, dispatchToaster] = useStateToaster(); @@ -71,10 +71,10 @@ const RuleActionsOverflowComponent = ({ { - setIsPopoverOpen(false); + closePopover(); const createdRules = await duplicateRulesAction( [rule], [rule.id], @@ -96,11 +96,11 @@ const RuleActionsOverflowComponent = ({ { - setIsPopoverOpen(false); - setRulesToExport([rule.rule_id]); + onClick={async () => { + closePopover(); + await exportRulesAction([rule.rule_id], noop, dispatchToaster); }} > {i18nActions.EXPORT_RULE} @@ -108,10 +108,10 @@ const RuleActionsOverflowComponent = ({ { - setIsPopoverOpen(false); + closePopover(); await deleteRulesAction([rule.id], noop, dispatchToaster, onRuleDeletedCallback); }} > @@ -119,27 +119,30 @@ const RuleActionsOverflowComponent = ({ , ] : [], - // eslint-disable-next-line react-hooks/exhaustive-deps - [rule, userHasNoPermissions] + [ + canDuplicateRuleWithActions, + closePopover, + dispatchToaster, + history, + onRuleDeletedCallback, + rule, + userHasPermissions, + ] ); - const handlePopoverOpen = useCallback(() => { - setIsPopoverOpen(!isPopoverOpen); - }, [setIsPopoverOpen, isPopoverOpen]); - const button = useMemo( () => ( ), - [handlePopoverOpen, userHasNoPermissions] + [togglePopover, userHasPermissions] ); return ( @@ -147,7 +150,7 @@ const RuleActionsOverflowComponent = ({ setIsPopoverOpen(false)} + closePopover={closePopover} id="ruleActionsOverflow" isOpen={isPopoverOpen} data-test-subj="rules-details-popover" @@ -157,18 +160,6 @@ const RuleActionsOverflowComponent = ({ > - { - displaySuccessToast( - i18nActions.SUCCESSFULLY_EXPORTED_RULES(exportCount), - dispatchToaster - ); - }} - /> ); }; diff --git a/x-pack/plugins/security_solution/public/detections/containers/detection_engine/rules/api.ts b/x-pack/plugins/security_solution/public/detections/containers/detection_engine/rules/api.ts index d4c4e10813172..7de91a07a68a0 100644 --- a/x-pack/plugins/security_solution/public/detections/containers/detection_engine/rules/api.ts +++ b/x-pack/plugins/security_solution/public/detections/containers/detection_engine/rules/api.ts @@ -13,6 +13,7 @@ import { DETECTION_ENGINE_RULES_STATUS_URL, DETECTION_ENGINE_PREPACKAGED_RULES_STATUS_URL, DETECTION_ENGINE_TAGS_URL, + DETECTION_ENGINE_RULES_BULK_ACTION, } from '../../../../../common/constants'; import { UpdateRulesProps, @@ -32,10 +33,14 @@ import { PrePackagedRulesStatusResponse, BulkRuleResponse, PatchRuleProps, + BulkActionProps, + BulkActionResponse, } from './types'; import { KibanaServices } from '../../../../common/lib/kibana'; import * as i18n from '../../../pages/detection_engine/rules/translations'; import { RulesSchema } from '../../../../../common/detection_engine/schemas/response'; +import { convertRulesFilterToKQL } from './utils'; +import { BulkAction } from '../../../../../common/detection_engine/schemas/common/schemas'; /** * Create provided Rule @@ -110,26 +115,7 @@ export const fetchRules = async ({ }, signal, }: FetchRulesProps): Promise => { - const showCustomRuleFilter = filterOptions.showCustomRules - ? [`alert.attributes.tags: "__internal_immutable:false"`] - : []; - const showElasticRuleFilter = filterOptions.showElasticRules - ? [`alert.attributes.tags: "__internal_immutable:true"`] - : []; - const filtersWithoutTags = [ - ...(filterOptions.filter.length ? [`alert.attributes.name: ${filterOptions.filter}`] : []), - ...showCustomRuleFilter, - ...showElasticRuleFilter, - ].join(' AND '); - - const tags = filterOptions.tags - .map((t) => `alert.attributes.tags: "${t.replace(/"/g, '\\"')}"`) - .join(' AND '); - - const filterString = - filtersWithoutTags !== '' && tags !== '' - ? `${filtersWithoutTags} AND (${tags})` - : filtersWithoutTags + tags; + const filterString = convertRulesFilterToKQL(filterOptions); const getFieldNameForSortField = (field: string) => { return field === 'name' ? `${field}.keyword` : field; @@ -243,6 +229,23 @@ export const duplicateRules = async ({ rules }: DuplicateRulesProps): Promise({ + action, + query, +}: BulkActionProps): Promise> => + KibanaServices.get().http.fetch>(DETECTION_ENGINE_RULES_BULK_ACTION, { + method: 'POST', + body: JSON.stringify({ action, query }), + }); + /** * Create Prepackaged Rules * diff --git a/x-pack/plugins/security_solution/public/detections/containers/detection_engine/rules/rules_table/rules_table_reducer.test.ts b/x-pack/plugins/security_solution/public/detections/containers/detection_engine/rules/rules_table/rules_table_reducer.test.ts index 60edeaf0de983..2a983117db524 100644 --- a/x-pack/plugins/security_solution/public/detections/containers/detection_engine/rules/rules_table/rules_table_reducer.test.ts +++ b/x-pack/plugins/security_solution/public/detections/containers/detection_engine/rules/rules_table/rules_table_reducer.test.ts @@ -7,7 +7,7 @@ import { mockRule } from '../../../../pages/detection_engine/rules/all/__mocks__/mock'; import { FilterOptions, PaginationOptions } from '../types'; -import { RulesTableAction, RulesTableState, createRulesTableReducer } from './rules_table_reducer'; +import { RulesTableState, rulesTableReducer } from './rules_table_reducer'; const initialState: RulesTableState = { rules: [], @@ -24,10 +24,10 @@ const initialState: RulesTableState = { showCustomRules: false, showElasticRules: false, }, + isAllSelected: false, loadingRulesAction: null, loadingRuleIds: [], selectedRuleIds: [], - exportRuleIds: [], lastUpdated: 0, isRefreshOn: false, isRefreshing: false, @@ -35,36 +35,20 @@ const initialState: RulesTableState = { }; describe('allRulesReducer', () => { - let reducer: (state: RulesTableState, action: RulesTableAction) => RulesTableState; - beforeEach(() => { jest.useFakeTimers(); jest .spyOn(global.Date, 'now') .mockImplementationOnce(() => new Date('2020-10-31T11:01:58.135Z').valueOf()); - reducer = createRulesTableReducer({ current: null }); }); afterEach(() => { jest.clearAllMocks(); }); - describe('#exportRuleIds', () => { - test('should update state with rules to be exported', () => { - const { loadingRuleIds, loadingRulesAction, exportRuleIds } = reducer(initialState, { - type: 'exportRuleIds', - ids: ['123', '456'], - }); - - expect(loadingRuleIds).toEqual(['123', '456']); - expect(exportRuleIds).toEqual(['123', '456']); - expect(loadingRulesAction).toEqual('export'); - }); - }); - describe('#loadingRuleIds', () => { - test('should update state with rule ids with a pending action', () => { - const { loadingRuleIds, loadingRulesAction } = reducer(initialState, { + it('should update state with rule ids with a pending action', () => { + const { loadingRuleIds, loadingRulesAction } = rulesTableReducer(initialState, { type: 'loadingRuleIds', ids: ['123', '456'], actionType: 'enable', @@ -74,8 +58,8 @@ describe('allRulesReducer', () => { expect(loadingRulesAction).toEqual('enable'); }); - test('should update loadingIds to empty array if action is null', () => { - const { loadingRuleIds, loadingRulesAction } = reducer(initialState, { + it('should update loadingIds to empty array if action is null', () => { + const { loadingRuleIds, loadingRulesAction } = rulesTableReducer(initialState, { type: 'loadingRuleIds', ids: ['123', '456'], actionType: null, @@ -85,8 +69,8 @@ describe('allRulesReducer', () => { expect(loadingRulesAction).toBeNull(); }); - test('should append rule ids to any existing loading ids', () => { - const { loadingRuleIds, loadingRulesAction } = reducer( + it('should append rule ids to any existing loading ids', () => { + const { loadingRuleIds, loadingRulesAction } = rulesTableReducer( { ...initialState, loadingRuleIds: ['abc'] }, { type: 'loadingRuleIds', @@ -101,8 +85,8 @@ describe('allRulesReducer', () => { }); describe('#selectedRuleIds', () => { - test('should update state with selected rule ids', () => { - const { selectedRuleIds } = reducer(initialState, { + it('should update state with selected rule ids', () => { + const { selectedRuleIds } = rulesTableReducer(initialState, { type: 'selectedRuleIds', ids: ['123', '456'], }); @@ -112,19 +96,22 @@ describe('allRulesReducer', () => { }); describe('#setRules', () => { - test('should update rules and reset loading/selected rule ids', () => { - const { selectedRuleIds, loadingRuleIds, loadingRulesAction, pagination, rules } = reducer( - initialState, - { - type: 'setRules', - rules: [mockRule('someRuleId')], - pagination: { - page: 1, - perPage: 20, - total: 0, - }, - } - ); + it('should update rules and reset loading/selected rule ids', () => { + const { + selectedRuleIds, + loadingRuleIds, + loadingRulesAction, + pagination, + rules, + } = rulesTableReducer(initialState, { + type: 'setRules', + rules: [mockRule('someRuleId')], + pagination: { + page: 1, + perPage: 20, + total: 0, + }, + }); expect(rules).toEqual([mockRule('someRuleId')]); expect(selectedRuleIds).toEqual([]); @@ -139,9 +126,9 @@ describe('allRulesReducer', () => { }); describe('#updateRules', () => { - test('should return existing and new rules', () => { + it('should return existing and new rules', () => { const existingRule = { ...mockRule('123'), rule_id: 'rule-123' }; - const { rules, loadingRulesAction } = reducer( + const { rules, loadingRulesAction } = rulesTableReducer( { ...initialState, rules: [existingRule] }, { type: 'updateRules', @@ -153,9 +140,9 @@ describe('allRulesReducer', () => { expect(loadingRulesAction).toBeNull(); }); - test('should return updated rule', () => { + it('should return updated rule', () => { const updatedRule = { ...mockRule('someRuleId'), description: 'updated rule' }; - const { rules, loadingRulesAction } = reducer( + const { rules, loadingRulesAction } = rulesTableReducer( { ...initialState, rules: [mockRule('someRuleId')] }, { type: 'updateRules', @@ -167,9 +154,9 @@ describe('allRulesReducer', () => { expect(loadingRulesAction).toBeNull(); }); - test('should return updated existing loading rule ids', () => { + it('should return updated existing loading rule ids', () => { const existingRule = { ...mockRule('someRuleId'), id: '123', rule_id: 'rule-123' }; - const { loadingRuleIds, loadingRulesAction } = reducer( + const { loadingRuleIds, loadingRulesAction } = rulesTableReducer( { ...initialState, rules: [existingRule], @@ -188,7 +175,7 @@ describe('allRulesReducer', () => { }); describe('#updateFilterOptions', () => { - test('should return existing and new rules', () => { + it('should return existing and new rules', () => { const paginationMock: PaginationOptions = { page: 1, perPage: 20, @@ -202,7 +189,7 @@ describe('allRulesReducer', () => { showCustomRules: false, showElasticRules: false, }; - const { filterOptions, pagination } = reducer(initialState, { + const { filterOptions, pagination } = rulesTableReducer(initialState, { type: 'updateFilterOptions', filterOptions: filterMock, pagination: paginationMock, @@ -214,8 +201,8 @@ describe('allRulesReducer', () => { }); describe('#failure', () => { - test('should reset rules value to empty array', () => { - const { rules } = reducer(initialState, { + it('should reset rules value to empty array', () => { + const { rules } = rulesTableReducer(initialState, { type: 'failure', }); @@ -224,8 +211,8 @@ describe('allRulesReducer', () => { }); describe('#setLastRefreshDate', () => { - test('should update last refresh date with current date', () => { - const { lastUpdated } = reducer(initialState, { + it('should update last refresh date with current date', () => { + const { lastUpdated } = rulesTableReducer(initialState, { type: 'setLastRefreshDate', }); @@ -234,8 +221,8 @@ describe('allRulesReducer', () => { }); describe('#setShowIdleModal', () => { - test('should hide idle modal and restart refresh if "show" is false', () => { - const { showIdleModal, isRefreshOn } = reducer(initialState, { + it('should hide idle modal and restart refresh if "show" is false', () => { + const { showIdleModal, isRefreshOn } = rulesTableReducer(initialState, { type: 'setShowIdleModal', show: false, }); @@ -244,8 +231,8 @@ describe('allRulesReducer', () => { expect(isRefreshOn).toBeTruthy(); }); - test('should show idle modal and pause refresh if "show" is true', () => { - const { showIdleModal, isRefreshOn } = reducer(initialState, { + it('should show idle modal and pause refresh if "show" is true', () => { + const { showIdleModal, isRefreshOn } = rulesTableReducer(initialState, { type: 'setShowIdleModal', show: true, }); @@ -256,8 +243,8 @@ describe('allRulesReducer', () => { }); describe('#setAutoRefreshOn', () => { - test('should pause auto refresh if "paused" is true', () => { - const { isRefreshOn } = reducer(initialState, { + it('should pause auto refresh if "paused" is true', () => { + const { isRefreshOn } = rulesTableReducer(initialState, { type: 'setAutoRefreshOn', on: true, }); @@ -265,8 +252,8 @@ describe('allRulesReducer', () => { expect(isRefreshOn).toBeTruthy(); }); - test('should resume auto refresh if "paused" is false', () => { - const { isRefreshOn } = reducer(initialState, { + it('should resume auto refresh if "paused" is false', () => { + const { isRefreshOn } = rulesTableReducer(initialState, { type: 'setAutoRefreshOn', on: false, }); @@ -274,4 +261,58 @@ describe('allRulesReducer', () => { expect(isRefreshOn).toBeFalsy(); }); }); + + describe('#selectAllRules', () => { + it('should select all rules', () => { + const state = rulesTableReducer( + { + ...initialState, + rules: [mockRule('1'), mockRule('2'), mockRule('3')], + }, + { + type: 'setIsAllSelected', + isAllSelected: true, + } + ); + + expect(state.isAllSelected).toBe(true); + expect(state.selectedRuleIds).toEqual(['1', '2', '3']); + }); + + it('should deselect all rules', () => { + const state = rulesTableReducer( + { + ...initialState, + rules: [mockRule('1'), mockRule('2'), mockRule('3')], + isAllSelected: true, + selectedRuleIds: ['1', '2', '3'], + }, + { + type: 'setIsAllSelected', + isAllSelected: false, + } + ); + + expect(state.isAllSelected).toBe(false); + expect(state.selectedRuleIds).toEqual([]); + }); + + it('should unset "isAllSelected" on selected rules modification', () => { + const state = rulesTableReducer( + { + ...initialState, + rules: [mockRule('1'), mockRule('2'), mockRule('3')], + isAllSelected: true, + selectedRuleIds: ['1', '2', '3'], + }, + { + type: 'selectedRuleIds', + ids: ['1', '2'], + } + ); + + expect(state.isAllSelected).toBe(false); + expect(state.selectedRuleIds).toEqual(['1', '2']); + }); + }); }); diff --git a/x-pack/plugins/security_solution/public/detections/containers/detection_engine/rules/rules_table/rules_table_reducer.ts b/x-pack/plugins/security_solution/public/detections/containers/detection_engine/rules/rules_table/rules_table_reducer.ts index 01a87fef2b723..7d32785222fed 100644 --- a/x-pack/plugins/security_solution/public/detections/containers/detection_engine/rules/rules_table/rules_table_reducer.ts +++ b/x-pack/plugins/security_solution/public/detections/containers/detection_engine/rules/rules_table/rules_table_reducer.ts @@ -5,8 +5,6 @@ * 2.0. */ -import type React from 'react'; -import { EuiBasicTable } from '@elastic/eui'; import { FilterOptions, PaginationOptions, Rule } from '../types'; export type LoadingRuleAction = @@ -25,11 +23,11 @@ export interface RulesTableState { loadingRulesAction: LoadingRuleAction; loadingRuleIds: string[]; selectedRuleIds: string[]; - exportRuleIds: string[]; lastUpdated: number; isRefreshOn: boolean; isRefreshing: boolean; showIdleModal: boolean; + isAllSelected: boolean; } export type RulesTableAction = @@ -42,128 +40,119 @@ export type RulesTableAction = } | { type: 'loadingRuleIds'; ids: string[]; actionType: LoadingRuleAction } | { type: 'selectedRuleIds'; ids: string[] } - | { type: 'exportRuleIds'; ids: string[] } | { type: 'setLastRefreshDate' } | { type: 'setAutoRefreshOn'; on: boolean } | { type: 'setIsRefreshing'; isRefreshing: boolean } + | { type: 'setIsAllSelected'; isAllSelected: boolean } | { type: 'setShowIdleModal'; show: boolean } | { type: 'failure' }; -export const createRulesTableReducer = ( - tableRef: React.MutableRefObject | null> -) => { - const rulesTableReducer = (state: RulesTableState, action: RulesTableAction): RulesTableState => { - switch (action.type) { - case 'setRules': { - if (tableRef?.current?.changeSelection != null) { - // for future devs: eui basic table is not giving us a prop to set the value, so - // we are using the ref in setTimeout to reset on the next loop so that we - // do not get a warning telling us we are trying to update during a render - window.setTimeout(() => tableRef?.current?.changeSelection([]), 0); +export const rulesTableReducer = ( + state: RulesTableState, + action: RulesTableAction +): RulesTableState => { + switch (action.type) { + case 'setRules': { + return { + ...state, + rules: action.rules, + selectedRuleIds: state.isAllSelected ? action.rules.map(({ id }) => id) : [], + loadingRuleIds: [], + loadingRulesAction: null, + pagination: { + ...state.pagination, + ...action.pagination, + }, + }; + } + case 'updateRules': { + const ruleIds = state.rules.map((r) => r.id); + const updatedRules = action.rules.reduce((rules, updatedRule) => { + let newRules = rules; + if (ruleIds.includes(updatedRule.id)) { + newRules = newRules.map((r) => (updatedRule.id === r.id ? updatedRule : r)); + } else { + newRules = [...newRules, updatedRule]; } - - return { - ...state, - rules: action.rules, - selectedRuleIds: [], - loadingRuleIds: [], - loadingRulesAction: null, - pagination: { - ...state.pagination, - ...action.pagination, - }, - }; - } - case 'updateRules': { - const ruleIds = state.rules.map((r) => r.id); - const updatedRules = action.rules.reduce((rules, updatedRule) => { - let newRules = rules; - if (ruleIds.includes(updatedRule.id)) { - newRules = newRules.map((r) => (updatedRule.id === r.id ? updatedRule : r)); - } else { - newRules = [...newRules, updatedRule]; - } - return newRules; - }, state.rules); - const updatedRuleIds = action.rules.map((r) => r.id); - const newLoadingRuleIds = state.loadingRuleIds.filter((id) => !updatedRuleIds.includes(id)); - return { - ...state, - rules: updatedRules, - loadingRuleIds: newLoadingRuleIds, - loadingRulesAction: newLoadingRuleIds.length === 0 ? null : state.loadingRulesAction, - }; - } - case 'updateFilterOptions': { - return { - ...state, - filterOptions: { - ...state.filterOptions, - ...action.filterOptions, - }, - pagination: { - ...state.pagination, - ...action.pagination, - }, - }; - } - case 'loadingRuleIds': { - return { - ...state, - loadingRuleIds: action.actionType == null ? [] : [...state.loadingRuleIds, ...action.ids], - loadingRulesAction: action.actionType, - }; - } - case 'selectedRuleIds': { - return { - ...state, - selectedRuleIds: action.ids, - }; - } - case 'exportRuleIds': { - return { - ...state, - loadingRuleIds: action.ids, - loadingRulesAction: 'export', - exportRuleIds: action.ids, - }; - } - case 'setLastRefreshDate': { - return { - ...state, - lastUpdated: Date.now(), - }; - } - case 'setAutoRefreshOn': { - return { - ...state, - isRefreshOn: action.on, - }; - } - case 'setIsRefreshing': { - return { - ...state, - isRefreshing: action.isRefreshing, - }; - } - case 'setShowIdleModal': { - return { - ...state, - showIdleModal: action.show, - isRefreshOn: !action.show, - }; - } - case 'failure': { - return { - ...state, - rules: [], - }; - } - default: { - return state; - } + return newRules; + }, state.rules); + const updatedRuleIds = action.rules.map((r) => r.id); + const newLoadingRuleIds = state.loadingRuleIds.filter((id) => !updatedRuleIds.includes(id)); + return { + ...state, + rules: updatedRules, + loadingRuleIds: newLoadingRuleIds, + loadingRulesAction: newLoadingRuleIds.length === 0 ? null : state.loadingRulesAction, + }; } - }; - - return rulesTableReducer; + case 'updateFilterOptions': { + return { + ...state, + filterOptions: { + ...state.filterOptions, + ...action.filterOptions, + }, + pagination: { + ...state.pagination, + ...action.pagination, + }, + }; + } + case 'loadingRuleIds': { + return { + ...state, + loadingRuleIds: action.actionType == null ? [] : [...state.loadingRuleIds, ...action.ids], + loadingRulesAction: action.actionType, + }; + } + case 'selectedRuleIds': { + return { + ...state, + isAllSelected: false, + selectedRuleIds: action.ids, + }; + } + case 'setLastRefreshDate': { + return { + ...state, + lastUpdated: Date.now(), + }; + } + case 'setAutoRefreshOn': { + return { + ...state, + isRefreshOn: action.on, + }; + } + case 'setIsRefreshing': { + return { + ...state, + isRefreshing: action.isRefreshing, + }; + } + case 'setIsAllSelected': { + const { isAllSelected } = action; + return { + ...state, + isAllSelected, + selectedRuleIds: isAllSelected ? state.rules.map(({ id }) => id) : [], + }; + } + case 'setShowIdleModal': { + return { + ...state, + showIdleModal: action.show, + isRefreshOn: !action.show, + }; + } + case 'failure': { + return { + ...state, + rules: [], + }; + } + default: { + return state; + } + } }; diff --git a/x-pack/plugins/security_solution/public/detections/containers/detection_engine/rules/rules_table/use_async_confirmation.ts b/x-pack/plugins/security_solution/public/detections/containers/detection_engine/rules/rules_table/use_async_confirmation.ts new file mode 100644 index 0000000000000..cce45f87d8ce3 --- /dev/null +++ b/x-pack/plugins/security_solution/public/detections/containers/detection_engine/rules/rules_table/use_async_confirmation.ts @@ -0,0 +1,46 @@ +/* + * 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 { useCallback, useRef } from 'react'; + +type UseAsyncConfirmationReturn = [ + initConfirmation: () => Promise, + confirm: () => void, + cancel: () => void +]; + +interface UseAsyncConfirmationArgs { + onInit: () => void; + onFinish: () => void; +} + +export const useAsyncConfirmation = ({ + onInit, + onFinish, +}: UseAsyncConfirmationArgs): UseAsyncConfirmationReturn => { + const confirmationPromiseRef = useRef<(result: boolean) => void>(); + + const confirm = useCallback(() => { + confirmationPromiseRef.current?.(true); + }, []); + + const cancel = useCallback(() => { + confirmationPromiseRef.current?.(false); + }, []); + + const initConfirmation = useCallback(() => { + onInit(); + + return new Promise((resolve) => { + confirmationPromiseRef.current = resolve; + }).finally(() => { + onFinish(); + }); + }, [onInit, onFinish]); + + return [initConfirmation, confirm, cancel]; +}; diff --git a/x-pack/plugins/security_solution/public/detections/containers/detection_engine/rules/rules_table/use_rules_table.ts b/x-pack/plugins/security_solution/public/detections/containers/detection_engine/rules/rules_table/use_rules_table.ts index 8969843f61a1c..cb41401ee2f40 100644 --- a/x-pack/plugins/security_solution/public/detections/containers/detection_engine/rules/rules_table/use_rules_table.ts +++ b/x-pack/plugins/security_solution/public/detections/containers/detection_engine/rules/rules_table/use_rules_table.ts @@ -5,14 +5,11 @@ * 2.0. */ -import { Dispatch, useMemo, useReducer, useEffect, useRef } from 'react'; -import { EuiBasicTable } from '@elastic/eui'; - +import { Dispatch, useReducer, useEffect, useRef } from 'react'; import { useAppToasts } from '../../../../../common/hooks/use_app_toasts'; import * as i18n from '../translations'; - import { fetchRules } from '../api'; -import { createRulesTableReducer, RulesTableState, RulesTableAction } from './rules_table_reducer'; +import { rulesTableReducer, RulesTableState, RulesTableAction } from './rules_table_reducer'; import { createRulesTableFacade, RulesTableFacade } from './rules_table_facade'; const INITIAL_SORT_FIELD = 'enabled'; @@ -35,15 +32,14 @@ const initialStateDefaults: RulesTableState = { loadingRulesAction: null, loadingRuleIds: [], selectedRuleIds: [], - exportRuleIds: [], lastUpdated: 0, isRefreshOn: true, isRefreshing: false, + isAllSelected: false, showIdleModal: false, }; export interface UseRulesTableParams { - tableRef: React.MutableRefObject | null>; initialStateOverride?: Partial; } @@ -54,7 +50,7 @@ export interface UseRulesTableReturn extends RulesTableFacade { } export const useRulesTable = (params: UseRulesTableParams): UseRulesTableReturn => { - const { tableRef, initialStateOverride } = params; + const { initialStateOverride } = params; const initialState: RulesTableState = { ...initialStateDefaults, @@ -62,8 +58,7 @@ export const useRulesTable = (params: UseRulesTableParams): UseRulesTableReturn ...initialStateOverride, }; - const reducer = useMemo(() => createRulesTableReducer(tableRef), [tableRef]); - const [state, dispatch] = useReducer(reducer, initialState); + const [state, dispatch] = useReducer(rulesTableReducer, initialState); const facade = useRef(createRulesTableFacade(dispatch)); const { addError } = useAppToasts(); diff --git a/x-pack/plugins/security_solution/public/detections/containers/detection_engine/rules/types.ts b/x-pack/plugins/security_solution/public/detections/containers/detection_engine/rules/types.ts index 85ff0f9ac1457..20bdeaf7e6378 100644 --- a/x-pack/plugins/security_solution/public/detections/containers/detection_engine/rules/types.ts +++ b/x-pack/plugins/security_solution/public/detections/containers/detection_engine/rules/types.ts @@ -28,6 +28,7 @@ import { rule_name_override, timestamp_override, threshold, + BulkAction, } from '../../../../../common/detection_engine/schemas/common/schemas'; import { CreateRulesSchema, @@ -212,6 +213,24 @@ export interface DuplicateRulesProps { rules: Rule[]; } +export interface BulkActionProps { + action: Action; + query: string; +} + +export interface BulkActionResult { + success: boolean; + rules_count: number; +} + +export type BulkActionResponse = { + [BulkAction.delete]: BulkActionResult; + [BulkAction.disable]: BulkActionResult; + [BulkAction.enable]: BulkActionResult; + [BulkAction.duplicate]: BulkActionResult; + [BulkAction.export]: Blob; +}[Action]; + export interface BasicFetchProps { signal: AbortSignal; } @@ -248,7 +267,7 @@ export interface ExportDocumentsProps { ids: string[]; filename?: string; excludeExportDetails?: boolean; - signal: AbortSignal; + signal?: AbortSignal; } export interface RuleStatus { diff --git a/x-pack/plugins/security_solution/public/detections/containers/detection_engine/rules/utils.test.ts b/x-pack/plugins/security_solution/public/detections/containers/detection_engine/rules/utils.test.ts new file mode 100644 index 0000000000000..c293e26f1740c --- /dev/null +++ b/x-pack/plugins/security_solution/public/detections/containers/detection_engine/rules/utils.test.ts @@ -0,0 +1,64 @@ +/* + * 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 { INTERNAL_IMMUTABLE_KEY } from '../../../../../common/constants'; +import { FilterOptions } from './types'; +import { convertRulesFilterToKQL } from './utils'; + +describe('convertRulesFilterToKQL', () => { + const filterOptions: FilterOptions = { + filter: '', + sortField: 'name', + sortOrder: 'asc', + showCustomRules: false, + showElasticRules: false, + tags: [], + }; + + it('returns empty string if filter options are empty', () => { + const kql = convertRulesFilterToKQL(filterOptions); + + expect(kql).toBe(''); + }); + + it('handles presence of "filter" properly', () => { + const kql = convertRulesFilterToKQL({ ...filterOptions, filter: 'foo' }); + + expect(kql).toBe('alert.attributes.name: foo'); + }); + + it('handles presence of "showCustomRules" properly', () => { + const kql = convertRulesFilterToKQL({ ...filterOptions, showCustomRules: true }); + + expect(kql).toBe(`alert.attributes.tags: "${INTERNAL_IMMUTABLE_KEY}:false"`); + }); + + it('handles presence of "showElasticRules" properly', () => { + const kql = convertRulesFilterToKQL({ ...filterOptions, showElasticRules: true }); + + expect(kql).toBe(`alert.attributes.tags: "${INTERNAL_IMMUTABLE_KEY}:true"`); + }); + + it('handles presence of "tags" properly', () => { + const kql = convertRulesFilterToKQL({ ...filterOptions, tags: ['tag1', 'tag2'] }); + + expect(kql).toBe('alert.attributes.tags: "tag1" AND alert.attributes.tags: "tag2"'); + }); + + it('handles combination of different properties properly', () => { + const kql = convertRulesFilterToKQL({ + ...filterOptions, + filter: 'foo', + showElasticRules: true, + tags: ['tag1', 'tag2'], + }); + + expect(kql).toBe( + `alert.attributes.name: foo AND alert.attributes.tags: "${INTERNAL_IMMUTABLE_KEY}:true" AND (alert.attributes.tags: "tag1" AND alert.attributes.tags: "tag2")` + ); + }); +}); diff --git a/x-pack/plugins/security_solution/public/detections/containers/detection_engine/rules/utils.ts b/x-pack/plugins/security_solution/public/detections/containers/detection_engine/rules/utils.ts new file mode 100644 index 0000000000000..841b2adca09e0 --- /dev/null +++ b/x-pack/plugins/security_solution/public/detections/containers/detection_engine/rules/utils.ts @@ -0,0 +1,41 @@ +/* + * 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 { INTERNAL_IMMUTABLE_KEY } from '../../../../../common/constants'; +import { FilterOptions } from './types'; + +/** + * Convert rules filter options object to KQL query + * + * @param filterOptions desired filters (e.g. filter/sortField/sortOrder) + * + * @returns KQL string + */ +export const convertRulesFilterToKQL = (filterOptions: FilterOptions): string => { + const showCustomRuleFilter = filterOptions.showCustomRules + ? [`alert.attributes.tags: "${INTERNAL_IMMUTABLE_KEY}:false"`] + : []; + const showElasticRuleFilter = filterOptions.showElasticRules + ? [`alert.attributes.tags: "${INTERNAL_IMMUTABLE_KEY}:true"`] + : []; + const filtersWithoutTags = [ + ...(filterOptions.filter.length ? [`alert.attributes.name: ${filterOptions.filter}`] : []), + ...showCustomRuleFilter, + ...showElasticRuleFilter, + ].join(' AND '); + + const tags = filterOptions.tags + .map((t) => `alert.attributes.tags: "${t.replace(/"/g, '\\"')}"`) + .join(' AND '); + + const filterString = + filtersWithoutTags !== '' && tags !== '' + ? `${filtersWithoutTags} AND (${tags})` + : filtersWithoutTags + tags; + + return filterString; +}; diff --git a/x-pack/plugins/security_solution/public/detections/pages/detection_engine/rules/all/actions.tsx b/x-pack/plugins/security_solution/public/detections/pages/detection_engine/rules/all/actions.tsx index de33d414398a8..78fac10815d45 100644 --- a/x-pack/plugins/security_solution/public/detections/pages/detection_engine/rules/all/actions.tsx +++ b/x-pack/plugins/security_solution/public/detections/pages/detection_engine/rules/all/actions.tsx @@ -7,29 +7,29 @@ import * as H from 'history'; import React, { Dispatch } from 'react'; - +import { BulkAction } from '../../../../../../common/detection_engine/schemas/common/schemas'; import { CreateRulesSchema } from '../../../../../../common/detection_engine/schemas/request'; -import { - deleteRules, - duplicateRules, - enableRules, - Rule, - RulesTableAction, -} from '../../../../containers/detection_engine/rules'; - import { getEditRuleUrl } from '../../../../../common/components/link_to/redirect_to_detection_engine'; - import { ActionToaster, displayErrorToast, displaySuccessToast, errorToToaster, } from '../../../../../common/components/toasters'; -import { track, METRIC_TYPE, TELEMETRY_EVENT } from '../../../../../common/lib/telemetry'; - -import * as i18n from '../translations'; -import { bucketRulesResponse } from './helpers'; +import { METRIC_TYPE, TELEMETRY_EVENT, track } from '../../../../../common/lib/telemetry'; +import { downloadBlob } from '../../../../../common/utils/download_blob'; +import { + deleteRules, + duplicateRules, + enableRules, + exportRules, + performBulkAction, + Rule, + RulesTableAction, +} from '../../../../containers/detection_engine/rules'; import { transformOutput } from '../../../../containers/detection_engine/rules/transforms'; +import * as i18n from '../translations'; +import { bucketRulesResponse, getExportedRulesCount } from './helpers'; export const editRuleAction = (rule: Rule, history: H.History) => { history.push(getEditRuleUrl(rule.id)); @@ -58,20 +58,34 @@ export const duplicateRulesAction = async ( } else { displaySuccessToast(i18n.SUCCESSFULLY_DUPLICATED_RULES(ruleIds.length), dispatchToaster); } - dispatch({ type: 'loadingRuleIds', ids: [], actionType: null }); - return createdRules; } catch (error) { - dispatch({ type: 'loadingRuleIds', ids: [], actionType: null }); errorToToaster({ title: i18n.DUPLICATE_RULE_ERROR, error, dispatchToaster }); + } finally { + dispatch({ type: 'loadingRuleIds', ids: [], actionType: null }); } }; -export const exportRulesAction = ( +export const exportRulesAction = async ( exportRuleId: string[], - dispatch: React.Dispatch + dispatch: React.Dispatch, + dispatchToaster: Dispatch ) => { - dispatch({ type: 'exportRuleIds', ids: exportRuleId }); + try { + dispatch({ type: 'loadingRuleIds', ids: exportRuleId, actionType: 'export' }); + const blob = await exportRules({ ids: exportRuleId }); + downloadBlob(blob, `${i18n.EXPORT_FILENAME}.ndjson`); + + const exportedRulesCount = await getExportedRulesCount(blob); + displaySuccessToast( + i18n.SUCCESSFULLY_EXPORTED_RULES(exportedRulesCount, exportRuleId.length), + dispatchToaster + ); + } catch (e) { + displayErrorToast(i18n.BULK_ACTION_FAILED, [e.message], dispatchToaster); + } finally { + dispatch({ type: 'loadingRuleIds', ids: [], actionType: null }); + } }; export const deleteRulesAction = async ( @@ -84,7 +98,6 @@ export const deleteRulesAction = async ( dispatch({ type: 'loadingRuleIds', ids: ruleIds, actionType: 'delete' }); const response = await deleteRules({ ids: ruleIds }); const { errors } = bucketRulesResponse(response); - dispatch({ type: 'loadingRuleIds', ids: [], actionType: null }); if (errors.length > 0) { displayErrorToast( i18n.BATCH_ACTION_DELETE_SELECTED_ERROR(ruleIds.length), @@ -95,12 +108,13 @@ export const deleteRulesAction = async ( onRuleDeleted(); } } catch (error) { - dispatch({ type: 'loadingRuleIds', ids: [], actionType: null }); errorToToaster({ title: i18n.BATCH_ACTION_DELETE_SELECTED_ERROR(ruleIds.length), error, dispatchToaster, }); + } finally { + dispatch({ type: 'loadingRuleIds', ids: [], actionType: null }); } }; @@ -144,6 +158,37 @@ export const enableRulesAction = async ( } } catch (e) { displayErrorToast(errorTitle, [e.message], dispatchToaster); + } finally { + dispatch({ type: 'loadingRuleIds', ids: [], actionType: null }); + } +}; + +export const rulesBulkActionByQuery = async ( + visibleRuleIds: string[], + selectedItemsCount: number, + query: string, + action: BulkAction, + dispatch: React.Dispatch, + dispatchToaster: Dispatch +) => { + try { + dispatch({ type: 'loadingRuleIds', ids: visibleRuleIds, actionType: action }); + + if (action === BulkAction.export) { + const blob = await performBulkAction({ query, action }); + downloadBlob(blob, `${i18n.EXPORT_FILENAME}.ndjson`); + + const exportedRulesCount = await getExportedRulesCount(blob); + displaySuccessToast( + i18n.SUCCESSFULLY_EXPORTED_RULES(exportedRulesCount, selectedItemsCount), + dispatchToaster + ); + } else { + await performBulkAction({ query, action }); + } + } catch (e) { + displayErrorToast(i18n.BULK_ACTION_FAILED, [e.message], dispatchToaster); + } finally { dispatch({ type: 'loadingRuleIds', ids: [], actionType: null }); } }; diff --git a/x-pack/plugins/security_solution/public/detections/pages/detection_engine/rules/all/batch_actions.tsx b/x-pack/plugins/security_solution/public/detections/pages/detection_engine/rules/all/batch_actions.tsx index 648d653d6a3c8..5b558824b4659 100644 --- a/x-pack/plugins/security_solution/public/detections/pages/detection_engine/rules/all/batch_actions.tsx +++ b/x-pack/plugins/security_solution/public/detections/pages/detection_engine/rules/all/batch_actions.tsx @@ -10,6 +10,7 @@ import React, { Dispatch } from 'react'; import * as i18n from '../translations'; import { RulesTableAction } from '../../../../containers/detection_engine/rules/rules_table'; import { + rulesBulkActionByQuery, deleteRulesAction, duplicateRulesAction, enableRulesAction, @@ -20,6 +21,7 @@ import { Rule } from '../../../../containers/detection_engine/rules'; import * as detectionI18n from '../../translations'; import { isMlRule } from '../../../../../../common/machine_learning/helpers'; import { canEditRuleWithActions } from '../../../../../common/utils/privileges'; +import { BulkAction } from '../../../../../../common/detection_engine/schemas/common/schemas'; interface GetBatchItems { closePopover: () => void; @@ -32,6 +34,10 @@ interface GetBatchItems { refetchPrePackagedRulesStatus: () => Promise; rules: Rule[]; selectedRuleIds: string[]; + isAllSelected: boolean; + filterQuery: string; + confirmDeletion: () => Promise; + selectedItemsCount: number; } export const getBatchItems = ({ @@ -45,51 +51,138 @@ export const getBatchItems = ({ rules, selectedRuleIds, hasActionsPrivileges, + isAllSelected, + filterQuery, + confirmDeletion, + selectedItemsCount, }: GetBatchItems) => { - const selectedRules = selectedRuleIds.reduce>((acc, id) => { - const found = rules.find((r) => r.id === id); - if (found != null) { - return { [id]: found, ...acc }; - } - return acc; - }, {}); + const selectedRules = rules.filter(({ id }) => selectedRuleIds.includes(id)); - const containsEnabled = selectedRuleIds.some((id) => selectedRules[id]?.enabled ?? false); - const containsDisabled = selectedRuleIds.some((id) => !selectedRules[id]?.enabled ?? false); + const containsEnabled = selectedRules.some(({ enabled }) => enabled); + const containsDisabled = selectedRules.some(({ enabled }) => !enabled); const containsLoading = selectedRuleIds.some((id) => loadingRuleIds.includes(id)); - const containsImmutable = selectedRuleIds.some((id) => selectedRules[id]?.immutable ?? false); + const containsImmutable = selectedRules.some(({ immutable }) => immutable); const missingActionPrivileges = !hasActionsPrivileges && - selectedRuleIds.some((id) => { - return !canEditRuleWithActions(selectedRules[id], hasActionsPrivileges); - }); + selectedRules.some((rule) => !canEditRuleWithActions(rule, hasActionsPrivileges)); + + const handleActivateAction = async () => { + closePopover(); + const deactivatedRules = selectedRules.filter(({ enabled }) => !enabled); + const deactivatedRulesNoML = deactivatedRules.filter(({ type }) => !isMlRule(type)); + + const mlRuleCount = deactivatedRules.length - deactivatedRulesNoML.length; + if (!hasMlPermissions && mlRuleCount > 0) { + displayWarningToast(detectionI18n.ML_RULES_UNAVAILABLE(mlRuleCount), dispatchToaster); + } + + const ruleIds = hasMlPermissions + ? deactivatedRules.map(({ id }) => id) + : deactivatedRulesNoML.map(({ id }) => id); + + if (isAllSelected) { + await rulesBulkActionByQuery( + ruleIds, + selectedItemsCount, + filterQuery, + BulkAction.enable, + dispatch, + dispatchToaster + ); + await reFetchRules(); + } else { + await enableRulesAction(ruleIds, true, dispatch, dispatchToaster); + } + }; + + const handleDeactivateActions = async () => { + closePopover(); + const activatedIds = selectedRules.filter(({ enabled }) => enabled).map(({ id }) => id); + if (isAllSelected) { + await rulesBulkActionByQuery( + activatedIds, + selectedItemsCount, + filterQuery, + BulkAction.disable, + dispatch, + dispatchToaster + ); + await reFetchRules(); + } else { + await enableRulesAction(activatedIds, false, dispatch, dispatchToaster); + } + }; + + const handleDuplicateAction = async () => { + closePopover(); + if (isAllSelected) { + await rulesBulkActionByQuery( + selectedRuleIds, + selectedItemsCount, + filterQuery, + BulkAction.duplicate, + dispatch, + dispatchToaster + ); + await reFetchRules(); + } else { + await duplicateRulesAction(selectedRules, selectedRuleIds, dispatch, dispatchToaster); + } + await reFetchRules(); + await refetchPrePackagedRulesStatus(); + }; + + const handleDeleteAction = async () => { + closePopover(); + if (isAllSelected) { + if ((await confirmDeletion()) === false) { + // User has cancelled deletion + return; + } + + await rulesBulkActionByQuery( + selectedRuleIds, + selectedItemsCount, + filterQuery, + BulkAction.delete, + dispatch, + dispatchToaster + ); + } else { + await deleteRulesAction(selectedRuleIds, dispatch, dispatchToaster); + } + await reFetchRules(); + await refetchPrePackagedRulesStatus(); + }; + + const handleExportAction = async () => { + closePopover(); + if (isAllSelected) { + await rulesBulkActionByQuery( + selectedRuleIds, + selectedItemsCount, + filterQuery, + BulkAction.export, + dispatch, + dispatchToaster + ); + } else { + await exportRulesAction( + selectedRules.map((r) => r.rule_id), + dispatch, + dispatchToaster + ); + } + }; return [ { - closePopover(); - const deactivatedIds = selectedRuleIds.filter((id) => !selectedRules[id]?.enabled ?? false); - - const deactivatedIdsNoML = deactivatedIds.filter( - (id) => !isMlRule(selectedRules[id]?.type) - ); - - const mlRuleCount = deactivatedIds.length - deactivatedIdsNoML.length; - if (!hasMlPermissions && mlRuleCount > 0) { - displayWarningToast(detectionI18n.ML_RULES_UNAVAILABLE(mlRuleCount), dispatchToaster); - } - - await enableRulesAction( - hasMlPermissions ? deactivatedIds : deactivatedIdsNoML, - true, - dispatch, - dispatchToaster - ); - }} + disabled={missingActionPrivileges || containsLoading || (!containsDisabled && !isAllSelected)} + onClick={handleActivateAction} > , { - closePopover(); - const activatedIds = selectedRuleIds.filter((id) => selectedRules[id]?.enabled ?? false); - await enableRulesAction(activatedIds, false, dispatch, dispatchToaster); - }} + disabled={missingActionPrivileges || containsLoading || (!containsEnabled && !isAllSelected)} + onClick={handleDeactivateActions} > , { - closePopover(); - exportRulesAction( - rules.filter((r) => selectedRuleIds.includes(r.id)).map((r) => r.rule_id), - dispatch - ); - }} + disabled={ + (containsImmutable && !isAllSelected) || containsLoading || selectedRuleIds.length === 0 + } + onClick={handleExportAction} > {i18n.BATCH_ACTION_EXPORT_SELECTED} , @@ -135,17 +222,7 @@ export const getBatchItems = ({ data-test-subj="duplicateRuleBulk" icon="copy" disabled={missingActionPrivileges || containsLoading || selectedRuleIds.length === 0} - onClick={async () => { - closePopover(); - await duplicateRulesAction( - rules.filter((r) => selectedRuleIds.includes(r.id)), - selectedRuleIds, - dispatch, - dispatchToaster - ); - await reFetchRules(); - await refetchPrePackagedRulesStatus(); - }} + onClick={handleDuplicateAction} > { - closePopover(); - await deleteRulesAction(selectedRuleIds, dispatch, dispatchToaster); - await reFetchRules(); - await refetchPrePackagedRulesStatus(); - }} + onClick={handleDeleteAction} > {i18n.BATCH_ACTION_DELETE_SELECTED} , diff --git a/x-pack/plugins/security_solution/public/detections/pages/detection_engine/rules/all/columns.tsx b/x-pack/plugins/security_solution/public/detections/pages/detection_engine/rules/all/columns.tsx index 83bb530827fa2..28a65c3e64e1f 100644 --- a/x-pack/plugins/security_solution/public/detections/pages/detection_engine/rules/all/columns.tsx +++ b/x-pack/plugins/security_solution/public/detections/pages/detection_engine/rules/all/columns.tsx @@ -96,7 +96,7 @@ export const getActions = ( description: i18n.EXPORT_RULE, icon: 'exportAction', name: i18n.EXPORT_RULE, - onClick: (rowItem: Rule) => exportRulesAction([rowItem.rule_id], dispatch), + onClick: (rowItem: Rule) => exportRulesAction([rowItem.rule_id], dispatch, dispatchToaster), enabled: (rowItem: Rule) => !rowItem.immutable, }, { @@ -125,7 +125,7 @@ interface GetColumns { formatUrl: FormatUrl; history: H.History; hasMlPermissions: boolean; - hasNoPermissions: boolean; + hasPermissions: boolean; loadingRuleIds: string[]; reFetchRules: () => Promise; refetchPrePackagedRulesStatus: () => Promise; @@ -142,7 +142,7 @@ export const getColumns = ({ formatUrl, history, hasMlPermissions, - hasNoPermissions, + hasPermissions, loadingRuleIds, reFetchRules, refetchPrePackagedRulesStatus, @@ -275,7 +275,7 @@ export const getColumns = ({ enabled={item.enabled} isDisabled={ !canEditRuleWithActions(item, hasReadActionsPrivileges) || - hasNoPermissions || + !hasPermissions || (isMlRule(item.type) && !hasMlPermissions && !item.enabled) } isLoading={loadingRuleIds.includes(item.id)} @@ -300,7 +300,7 @@ export const getColumns = ({ } as EuiTableActionsColumnType, ]; - return hasNoPermissions ? cols : [...cols, ...actions]; + return hasPermissions ? [...cols, ...actions] : cols; }; export const getMonitoringColumns = ( diff --git a/x-pack/plugins/security_solution/public/detections/pages/detection_engine/rules/all/exceptions/exceptions_table.test.tsx b/x-pack/plugins/security_solution/public/detections/pages/detection_engine/rules/all/exceptions/exceptions_table.test.tsx index 6a0f4dc4e2dea..dd3549ea20d36 100644 --- a/x-pack/plugins/security_solution/public/detections/pages/detection_engine/rules/all/exceptions/exceptions_table.test.tsx +++ b/x-pack/plugins/security_solution/public/detections/pages/detection_engine/rules/all/exceptions/exceptions_table.test.tsx @@ -79,7 +79,7 @@ describe('ExceptionListsTable', () => { diff --git a/x-pack/plugins/security_solution/public/detections/pages/detection_engine/rules/all/exceptions/exceptions_table.tsx b/x-pack/plugins/security_solution/public/detections/pages/detection_engine/rules/all/exceptions/exceptions_table.tsx index 1dfa83da1637a..7f734b10fd020 100644 --- a/x-pack/plugins/security_solution/public/detections/pages/detection_engine/rules/all/exceptions/exceptions_table.tsx +++ b/x-pack/plugins/security_solution/public/detections/pages/detection_engine/rules/all/exceptions/exceptions_table.tsx @@ -38,7 +38,7 @@ export type Func = () => Promise; interface ExceptionListsTableProps { history: History; - hasNoPermissions: boolean; + hasPermissions: boolean; loading: boolean; formatUrl: FormatUrl; } @@ -60,7 +60,7 @@ const exceptionReferenceModalInitialState: ReferenceModalState = { }; export const ExceptionListsTable = React.memo( - ({ formatUrl, history, hasNoPermissions, loading }) => { + ({ formatUrl, history, hasPermissions, loading }) => { const { services: { http, notifications }, } = useKibana(); @@ -359,7 +359,7 @@ export const ExceptionListsTable = React.memo( <> ( => { + const blobContent = await blob.text(); + // The Blob content is an NDJSON file, the last line of which contains export details. + const exportDetailsJson = blobContent.split('\n').filter(Boolean).slice(-1)[0]; + const exportDetails = JSON.parse(exportDetailsJson); + + return exportDetails.exported_count; +}; diff --git a/x-pack/plugins/security_solution/public/detections/pages/detection_engine/rules/all/index.test.tsx b/x-pack/plugins/security_solution/public/detections/pages/detection_engine/rules/all/index.test.tsx index 1f4586754cb33..9597c221843be 100644 --- a/x-pack/plugins/security_solution/public/detections/pages/detection_engine/rules/all/index.test.tsx +++ b/x-pack/plugins/security_solution/public/detections/pages/detection_engine/rules/all/index.test.tsx @@ -124,10 +124,10 @@ describe('AllRules', () => { loadingRulesAction: null, loadingRuleIds: [], selectedRuleIds: [], - exportRuleIds: [], lastUpdated: 0, isRefreshOn: true, isRefreshing: false, + isAllSelected: false, showIdleModal: false, }; @@ -189,7 +189,7 @@ describe('AllRules', () => { const wrapper = shallow( { { { { { Promise; @@ -64,7 +64,7 @@ const allRulesTabs = [ export const AllRules = React.memo( ({ createPrePackagedRules, - hasNoPermissions, + hasPermissions, loading, loadingCreatePrePackagedRules, refetchPrePackagedRulesStatus, @@ -110,7 +110,7 @@ export const AllRules = React.memo( formatUrl={formatUrl} selectedTab={allRulesTab} createPrePackagedRules={createPrePackagedRules} - hasNoPermissions={hasNoPermissions} + hasPermissions={hasPermissions} loading={loading} loadingCreatePrePackagedRules={loadingCreatePrePackagedRules} refetchPrePackagedRulesStatus={refetchPrePackagedRulesStatus} @@ -125,7 +125,7 @@ export const AllRules = React.memo( )} diff --git a/x-pack/plugins/security_solution/public/detections/pages/detection_engine/rules/all/rules_tables.tsx b/x-pack/plugins/security_solution/public/detections/pages/detection_engine/rules/all/rules_tables.tsx index 353cc657f2116..8fd82a495e52f 100644 --- a/x-pack/plugins/security_solution/public/detections/pages/detection_engine/rules/all/rules_tables.tsx +++ b/x-pack/plugins/security_solution/public/detections/pages/detection_engine/rules/all/rules_tables.tsx @@ -15,7 +15,6 @@ import { EuiWindowEvent, } from '@elastic/eui'; import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'; -import uuid from 'uuid'; import { debounce } from 'lodash/fp'; import { History } from 'history'; @@ -25,7 +24,6 @@ import { CreatePreBuiltRules, FilterOptions, Rule, - exportRules, RulesSortingFields, } from '../../../../containers/detection_engine/rules'; @@ -36,7 +34,6 @@ import { useStateToaster } from '../../../../../common/components/toasters'; import { Loader } from '../../../../../common/components/loader'; import { Panel } from '../../../../../common/components/panel'; import { PrePackagedRulesPrompt } from '../../../../components/rules/pre_packaged_rules/load_empty_prompt'; -import { GenericDownloader } from '../../../../../common/components/generic_downloader'; import { AllRulesTables, SortingType } from '../../../../components/rules/all_rules_tables'; import { getPrePackagedRuleStatus } from '../helpers'; import * as i18n from '../translations'; @@ -53,6 +50,10 @@ import { AllRulesUtilityBar } from './utility_bar'; import { LastUpdatedAt } from '../../../../../common/components/last_updated'; import { DEFAULT_RULES_TABLE_REFRESH_SETTING } from '../../../../../../common/constants'; import { AllRulesTabs } from '.'; +import { useValueChanged } from '../../../../../common/hooks/use_value_changed'; +import { convertRulesFilterToKQL } from '../../../../containers/detection_engine/rules/utils'; +import { useBoolState } from '../../../../../common/hooks/use_bool_state'; +import { useAsyncConfirmation } from '../../../../containers/detection_engine/rules/rules_table/use_async_confirmation'; const INITIAL_SORT_FIELD = 'enabled'; @@ -60,7 +61,7 @@ interface RulesTableProps { history: History; formatUrl: FormatUrl; createPrePackagedRules: CreatePreBuiltRules | null; - hasNoPermissions: boolean; + hasPermissions: boolean; loading: boolean; loadingCreatePrePackagedRules: boolean; refetchPrePackagedRulesStatus: () => Promise; @@ -85,7 +86,7 @@ export const RulesTables = React.memo( history, formatUrl, createPrePackagedRules, - hasNoPermissions, + hasPermissions, loading, loadingCreatePrePackagedRules, refetchPrePackagedRulesStatus, @@ -115,14 +116,12 @@ export const RulesTables = React.memo( }>(DEFAULT_RULES_TABLE_REFRESH_SETTING); const rulesTable = useRulesTable({ - tableRef, initialStateOverride: { isRefreshOn: defaultAutoRefreshSetting.on, }, }); const { - exportRuleIds, filterOptions, loadingRuleIds, loadingRulesAction, @@ -133,12 +132,12 @@ export const RulesTables = React.memo( showIdleModal, isRefreshOn, isRefreshing, + isAllSelected, } = rulesTable.state; const { dispatch, updateOptions, - actionStopped, setShowIdleModal, setLastRefreshDate, setAutoRefreshOn, @@ -186,9 +185,24 @@ export const RulesTables = React.memo( actions, ]); + const [ + isDeleteConfirmationVisible, + showDeleteConfirmation, + hideDeleteConfirmation, + ] = useBoolState(); + + const [confirmDeletion, handleDeletionConfirm, handleDeletionCancel] = useAsyncConfirmation({ + onInit: showDeleteConfirmation, + onFinish: hideDeleteConfirmation, + }); + + const selectedItemsCount = isAllSelected ? pagination.total : selectedRuleIds.length; + const hasPagination = pagination.total > pagination.perPage; + const getBatchItemsPopoverContent = useCallback( (closePopover: () => void): JSX.Element[] => { return getBatchItems({ + isAllSelected, closePopover, dispatch, dispatchToaster, @@ -199,9 +213,13 @@ export const RulesTables = React.memo( reFetchRules, refetchPrePackagedRulesStatus, rules, + filterQuery: convertRulesFilterToKQL(filterOptions), + confirmDeletion, + selectedItemsCount, }); }, [ + isAllSelected, dispatch, dispatchToaster, hasMlPermissions, @@ -211,6 +229,9 @@ export const RulesTables = React.memo( rules, selectedRuleIds, hasActionsPrivileges, + filterOptions, + confirmDeletion, + selectedItemsCount, ] ); @@ -219,7 +240,7 @@ export const RulesTables = React.memo( pageIndex: pagination.page - 1, pageSize: pagination.perPage, totalItemCount: pagination.total, - pageSizeOptions: [5, 10, 20, 50, 100, 200, 300, 400, 500, 600], + pageSizeOptions: [5, 10, 20, 50, 100], }), [pagination] ); @@ -252,7 +273,7 @@ export const RulesTables = React.memo( formatUrl, history, hasMlPermissions, - hasNoPermissions, + hasPermissions, loadingRuleIds: loadingRulesAction != null && (loadingRulesAction === 'enable' || loadingRulesAction === 'disable') @@ -268,7 +289,7 @@ export const RulesTables = React.memo( formatUrl, refetchPrePackagedRulesStatus, hasActionsPrivileges, - hasNoPermissions, + hasPermissions, hasMlPermissions, history, loadingRuleIds, @@ -299,15 +320,43 @@ export const RulesTables = React.memo( } }, [createPrePackagedRules, reFetchRules, refetchPrePackagedRulesStatus]); + const isSelectAllCalled = useRef(false); + + // Synchronize selectedRuleIds with EuiBasicTable's selected rows + useValueChanged((ruleIds) => { + if (tableRef.current?.changeSelection != null) { + tableRef.current.setSelection(rules.filter((rule) => ruleIds.includes(rule.id))); + } + }, selectedRuleIds); + const euiBasicTableSelectionProps = useMemo( () => ({ selectable: (item: Rule) => !loadingRuleIds.includes(item.id), - onSelectionChange: (selected: Rule[]) => - dispatch({ type: 'selectedRuleIds', ids: selected.map((r) => r.id) }), + onSelectionChange: (selected: Rule[]) => { + /** + * EuiBasicTable doesn't provide declarative API to control selected rows. + * This limitation requires us to synchronize selection state manually using setSelection(). + * But it creates a chain reaction when the user clicks Select All: + * selectAll() -> setSelection() -> onSelectionChange() -> setSelection(). + * To break the chain we should check whether the onSelectionChange was triggered + * by the Select All action or not. + * + */ + if (isSelectAllCalled.current) { + isSelectAllCalled.current = false; + } else { + dispatch({ type: 'selectedRuleIds', ids: selected.map(({ id }) => id) }); + } + }, }), [loadingRuleIds, dispatch] ); + const toggleSelectAll = useCallback(() => { + isSelectAllCalled.current = true; + dispatch({ type: 'setIsAllSelected', isAllSelected: !isAllSelected }); + }, [dispatch, isAllSelected]); + const refreshTable = useCallback( async (mode: 'auto' | 'manual' = 'manual'): Promise => { if (isLoadingAnActionOnRule) { @@ -397,22 +446,6 @@ export const RulesTables = React.memo( [initLoading, prePackagedRuleStatus, rulesCustomInstalled] ); - const handleGenericDownloaderSuccess = useCallback( - (exportCount) => { - actionStopped(); - dispatchToaster({ - type: 'addToaster', - toast: { - id: uuid.v4(), - title: i18n.SUCCESSFULLY_EXPORTED_RULES(exportCount), - color: 'success', - iconType: 'check', - }, - }); - }, - [actionStopped, dispatchToaster] - ); - return ( <> @@ -421,13 +454,6 @@ export const RulesTables = React.memo( - - ( )} {initLoading && ( @@ -492,22 +518,39 @@ export const RulesTables = React.memo(

{i18n.REFRESH_PROMPT_BODY}

)} + {isDeleteConfirmationVisible && ( + +

{i18n.DELETE_CONFIRMATION_BODY}

+
+ )} {shouldShowRulesTable && ( <> { const wrapper = mount( { const wrapper = mount( { const wrapper = mount( { const wrapper = mount( { const wrapper = mount( { const wrapper = mount( void; + numberSelectedItems: number; onGetBatchItemsPopoverContent?: (closePopover: () => void) => JSX.Element[]; + onRefresh?: (refreshRule: boolean) => void; onRefreshSwitch?: (checked: boolean) => void; + onToggleSelectAll?: () => void; + paginationTotal: number; + showBulkActions: boolean; + hasPagination?: boolean; } export const AllRulesUtilityBar = React.memo( ({ - userHasNoPermissions, - onRefresh, - paginationTotal, + canBulkEdit, + isAllSelected, + isAutoRefreshOn, numberSelectedItems, onGetBatchItemsPopoverContent, - isAutoRefreshOn, - showBulkActions = true, + onRefresh, onRefreshSwitch, + onToggleSelectAll, + paginationTotal, + showBulkActions = true, + hasPagination, }) => { const handleGetBatchItemsPopoverContent = useCallback( (closePopover: () => void): JSX.Element | null => { @@ -99,7 +105,19 @@ export const AllRulesUtilityBar = React.memo( {i18n.SELECTED_RULES(numberSelectedItems)} - {!userHasNoPermissions && ( + + {canBulkEdit && onToggleSelectAll && hasPagination && ( + + {isAllSelected ? i18n.CLEAR_SELECTION : i18n.SELECT_ALL_RULES(paginationTotal)} + + )} + + {canBulkEdit && ( { ) { history.replace(getDetectionEngineUrl()); return null; - } else if (userHasNoPermissions(canUserCRUD)) { + } else if (!userHasPermissions(canUserCRUD)) { history.replace(getRulesUrl()); return null; } diff --git a/x-pack/plugins/security_solution/public/detections/pages/detection_engine/rules/details/index.tsx b/x-pack/plugins/security_solution/public/detections/pages/detection_engine/rules/details/index.tsx index 8dac9e03514d1..6727db8aba3b4 100644 --- a/x-pack/plugins/security_solution/public/detections/pages/detection_engine/rules/details/index.tsx +++ b/x-pack/plugins/security_solution/public/detections/pages/detection_engine/rules/details/index.tsx @@ -70,7 +70,7 @@ import { } from '../../../../components/alerts_table/default_config'; import { RuleSwitch } from '../../../../components/rules/rule_switch'; import { StepPanel } from '../../../../components/rules/step_panel'; -import { getStepsData, redirectToDetections, userHasNoPermissions } from '../helpers'; +import { getStepsData, redirectToDetections, userHasPermissions } from '../helpers'; import { useGlobalTime } from '../../../../../common/containers/use_global_time'; import { alertsHistogramOptions } from '../../../../components/alerts_histogram_panel/config'; import { inputsSelectors } from '../../../../../common/store/inputs'; @@ -461,7 +461,7 @@ const RuleDetailsPageComponent = () => { {ruleI18n.EDIT_RULE_SETTINGS} @@ -608,7 +608,7 @@ const RuleDetailsPageComponent = () => { isDisabled={ !isExistingRule || !canEditRuleWithActions(rule, hasActionsPrivileges) || - userHasNoPermissions(canUserCRUD) || + !userHasPermissions(canUserCRUD) || (!hasMlPermissions && !rule?.enabled) } enabled={isExistingRule && (rule?.enabled ?? false)} @@ -625,9 +625,7 @@ const RuleDetailsPageComponent = () => { { ) { history.replace(getDetectionEngineUrl()); return null; - } else if (userHasNoPermissions(canUserCRUD)) { + } else if (!userHasPermissions(canUserCRUD)) { history.replace(getRuleDetailsUrl(ruleId ?? '')); return null; } diff --git a/x-pack/plugins/security_solution/public/detections/pages/detection_engine/rules/helpers.test.tsx b/x-pack/plugins/security_solution/public/detections/pages/detection_engine/rules/helpers.test.tsx index 4c3e5b18d4c1b..fa600d9ce4a0e 100644 --- a/x-pack/plugins/security_solution/public/detections/pages/detection_engine/rules/helpers.test.tsx +++ b/x-pack/plugins/security_solution/public/detections/pages/detection_engine/rules/helpers.test.tsx @@ -18,7 +18,7 @@ import { getPrePackagedRuleStatus, getPrePackagedTimelineStatus, determineDetailsValue, - userHasNoPermissions, + userHasPermissions, fillEmptySeverityMappings, } from './helpers'; import { mockRuleWithEverything, mockRule } from './all/__mocks__/mock'; @@ -403,26 +403,26 @@ describe('rule helpers', () => { }); }); - describe('userHasNoPermissions', () => { - test("returns false when user's CRUD operations are null", () => { - const result: boolean = userHasNoPermissions(null); - const userHasNoPermissionsExpectedResult = false; + describe('userHasPermissions', () => { + test("returns true when user's CRUD operations are null", () => { + const result: boolean = userHasPermissions(null); + const userHasPermissionsExpectedResult = true; - expect(result).toEqual(userHasNoPermissionsExpectedResult); + expect(result).toEqual(userHasPermissionsExpectedResult); }); - test('returns true when user cannot CRUD', () => { - const result: boolean = userHasNoPermissions(false); - const userHasNoPermissionsExpectedResult = true; + test('returns false when user cannot CRUD', () => { + const result: boolean = userHasPermissions(false); + const userHasPermissionsExpectedResult = false; - expect(result).toEqual(userHasNoPermissionsExpectedResult); + expect(result).toEqual(userHasPermissionsExpectedResult); }); - test('returns false when user can CRUD', () => { - const result: boolean = userHasNoPermissions(true); - const userHasNoPermissionsExpectedResult = false; + test('returns true when user can CRUD', () => { + const result: boolean = userHasPermissions(true); + const userHasPermissionsExpectedResult = true; - expect(result).toEqual(userHasNoPermissionsExpectedResult); + expect(result).toEqual(userHasPermissionsExpectedResult); }); }); diff --git a/x-pack/plugins/security_solution/public/detections/pages/detection_engine/rules/helpers.tsx b/x-pack/plugins/security_solution/public/detections/pages/detection_engine/rules/helpers.tsx index a88ff9bb2c921..f20ace09ed2b6 100644 --- a/x-pack/plugins/security_solution/public/detections/pages/detection_engine/rules/helpers.tsx +++ b/x-pack/plugins/security_solution/public/detections/pages/detection_engine/rules/helpers.tsx @@ -405,8 +405,8 @@ export const getActionMessageParams = memoizeOne( ); // typed as null not undefined as the initial state for this value is null. -export const userHasNoPermissions = (canUserCRUD: boolean | null): boolean => - canUserCRUD != null ? !canUserCRUD : false; +export const userHasPermissions = (canUserCRUD: boolean | null): boolean => + canUserCRUD != null ? canUserCRUD : true; export const MaxWidthEuiFlexItem = styled(EuiFlexItem)` max-width: 1000px; diff --git a/x-pack/plugins/security_solution/public/detections/pages/detection_engine/rules/index.tsx b/x-pack/plugins/security_solution/public/detections/pages/detection_engine/rules/index.tsx index 8aca1cb960c1d..8bacb10444a7d 100644 --- a/x-pack/plugins/security_solution/public/detections/pages/detection_engine/rules/index.tsx +++ b/x-pack/plugins/security_solution/public/detections/pages/detection_engine/rules/index.tsx @@ -28,7 +28,7 @@ import { getPrePackagedRuleStatus, getPrePackagedTimelineStatus, redirectToDetections, - userHasNoPermissions, + userHasPermissions, } from './helpers'; import * as i18n from './translations'; import { SecurityPageName } from '../../../../app/types'; @@ -131,7 +131,7 @@ const RulesPageComponent: React.FC = () => { const loadPrebuiltRulesAndTemplatesButton = useMemo( () => getLoadPrebuiltRulesAndTemplatesButton({ - isDisabled: userHasNoPermissions(canUserCRUD) || loading, + isDisabled: !userHasPermissions(canUserCRUD) || loading, onClick: handleCreatePrePackagedRules, }), [canUserCRUD, getLoadPrebuiltRulesAndTemplatesButton, handleCreatePrePackagedRules, loading] @@ -140,7 +140,7 @@ const RulesPageComponent: React.FC = () => { const reloadPrebuiltRulesAndTemplatesButton = useMemo( () => getReloadPrebuiltRulesAndTemplatesButton({ - isDisabled: userHasNoPermissions(canUserCRUD) || loading, + isDisabled: !userHasPermissions(canUserCRUD) || loading, onClick: handleCreatePrePackagedRules, }), [canUserCRUD, getReloadPrebuiltRulesAndTemplatesButton, handleCreatePrePackagedRules, loading] @@ -213,7 +213,7 @@ const RulesPageComponent: React.FC = () => { { setShowImportModal(true); }} @@ -228,7 +228,7 @@ const RulesPageComponent: React.FC = () => { onClick={goToNewRule} href={formatUrl(getCreateRuleUrl())} iconType="plusInCircle" - isDisabled={userHasNoPermissions(canUserCRUD) || loading} + isDisabled={!userHasPermissions(canUserCRUD) || loading} > {i18n.ADD_NEW_RULE} @@ -250,7 +250,7 @@ const RulesPageComponent: React.FC = () => { data-test-subj="all-rules" loading={loading || prePackagedRuleLoading} loadingCreatePrePackagedRules={loadingCreatePrePackagedRules} - hasNoPermissions={userHasNoPermissions(canUserCRUD)} + hasPermissions={userHasPermissions(canUserCRUD)} refetchPrePackagedRulesStatus={handleRefetchPrePackagedRulesStatus} rulesCustomInstalled={rulesCustomInstalled} rulesInstalled={rulesInstalled} diff --git a/x-pack/plugins/security_solution/public/detections/pages/detection_engine/rules/translations.ts b/x-pack/plugins/security_solution/public/detections/pages/detection_engine/rules/translations.ts index 1bfa62e9b77c0..defd976a04c4b 100644 --- a/x-pack/plugins/security_solution/public/detections/pages/detection_engine/rules/translations.ts +++ b/x-pack/plugins/security_solution/public/detections/pages/detection_engine/rules/translations.ts @@ -165,13 +165,13 @@ export const EXPORT_FILENAME = i18n.translate( } ); -export const SUCCESSFULLY_EXPORTED_RULES = (totalRules: number) => +export const SUCCESSFULLY_EXPORTED_RULES = (exportedRules: number, totalRules: number) => i18n.translate( - 'xpack.securitySolution.detectionEngine.rules.allRules.successfullyExportedRulesTitle', + 'xpack.securitySolution.detectionEngine.rules.allRules.successfullyExportedXofYRulesTitle', { - values: { totalRules }, + values: { totalRules, exportedRules }, defaultMessage: - 'Successfully exported {totalRules, plural, =0 {all rules} =1 {{totalRules} rule} other {{totalRules} rules}}', + 'Successfully exported {exportedRules} of {totalRules} {totalRules, plural, =1 {rule} other {rules}}. Prebuilt rules were excluded from the resulting file.', } ); @@ -202,6 +202,19 @@ export const SHOWING_RULES = (totalRules: number) => defaultMessage: 'Showing {totalRules} {totalRules, plural, =1 {rule} other {rules}}', }); +export const SELECT_ALL_RULES = (totalRules: number) => + i18n.translate('xpack.securitySolution.detectionEngine.rules.allRules.selectAllRulesTitle', { + values: { totalRules }, + defaultMessage: 'Select all {totalRules} {totalRules, plural, =1 {rule} other {rules}}', + }); + +export const CLEAR_SELECTION = i18n.translate( + 'xpack.securitySolution.detectionEngine.rules.allRules.clearSelectionTitle', + { + defaultMessage: 'Clear selection', + } +); + export const SELECTED_RULES = (selectedRules: number) => i18n.translate('xpack.securitySolution.detectionEngine.rules.allRules.selectedRulesTitle', { values: { selectedRules }, @@ -253,6 +266,13 @@ export const DUPLICATE_RULE_ERROR = i18n.translate( } ); +export const BULK_ACTION_FAILED = i18n.translate( + 'xpack.securitySolution.detectionEngine.rules.allRules.actions.bulkActionFailedDescription', + { + defaultMessage: 'Failed to execte bulk action', + } +); + export const EXPORT_RULE = i18n.translate( 'xpack.securitySolution.detectionEngine.rules.allRules.actions.exportRuleDescription', { @@ -577,6 +597,35 @@ export const REFRESH_PROMPT_BODY = i18n.translate( } ); +export const DELETE_CONFIRMATION_TITLE = i18n.translate( + 'xpack.securitySolution.detectionEngine.components.allRules.deleteConfirmationTitle', + { + defaultMessage: 'Confirm bulk deletion', + } +); + +export const DELETE_CONFIRMATION_CONFIRM = i18n.translate( + 'xpack.securitySolution.detectionEngine.components.allRules.deleteConfirmationConfirm', + { + defaultMessage: 'Confirm', + } +); + +export const DELETE_CONFIRMATION_CANCEL = i18n.translate( + 'xpack.securitySolution.detectionEngine.components.allRules.deleteConfirmationCancel', + { + defaultMessage: 'Cancel', + } +); + +export const DELETE_CONFIRMATION_BODY = i18n.translate( + 'xpack.securitySolution.detectionEngine.components.allRules.deleteConfirmationBody', + { + defaultMessage: + 'This action will delete all rules that match current filter query. Click "Confirm" to continue.', + } +); + export const REFRESH_RULE_POPOVER_DESCRIPTION = i18n.translate( 'xpack.securitySolution.detectionEngine.rules.refreshRulePopoverDescription', { diff --git a/x-pack/plugins/security_solution/public/timelines/components/open_timeline/export_timeline/export_timeline.test.tsx b/x-pack/plugins/security_solution/public/timelines/components/open_timeline/export_timeline/export_timeline.test.tsx index a273ef1df9788..738d166fcb9a4 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/open_timeline/export_timeline/export_timeline.test.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/open_timeline/export_timeline/export_timeline.test.tsx @@ -10,14 +10,20 @@ import React from 'react'; import { TimelineDownloader } from './export_timeline'; import { mockSelectedTimeline } from './mocks'; import * as i18n from '../translations'; +import { downloadBlob } from '../../../../common/utils/download_blob'; import { ReactWrapper, mount } from 'enzyme'; import { waitFor } from '@testing-library/react'; import { useParams } from 'react-router-dom'; import { useAppToasts } from '../../../../common/hooks/use_app_toasts'; +import { exportSelectedTimeline } from '../../../containers/api'; jest.mock('../../../../common/hooks/use_app_toasts'); +jest.mock('../../../../common/utils/download_blob'); +jest.mock('../../../containers/api', () => ({ + exportSelectedTimeline: jest.fn(), +})); jest.mock('.', () => { return { @@ -37,6 +43,7 @@ jest.mock('react-router-dom', () => { describe('TimelineDownloader', () => { const mockAddSuccess = jest.fn(); (useAppToasts as jest.Mock).mockReturnValue({ addSuccess: mockAddSuccess }); + (exportSelectedTimeline as jest.Mock).mockReturnValue(new Blob()); let wrapper: ReactWrapper; const exportedIds = ['baa20980-6301-11ea-9223-95b6d4dd806c']; @@ -56,14 +63,14 @@ describe('TimelineDownloader', () => { mockAddSuccess.mockClear(); }); - describe('should not render a downloader', () => { - test('Without exportedIds', () => { + describe('ExportTimeline', () => { + it('should not start download without exportedIds', () => { const testProps = { ...defaultTestProps, exportedIds: undefined, }; wrapper = mount(); - expect(wrapper.find('[data-test-subj="export-timeline-downloader"]').exists()).toBeFalsy(); + expect(downloadBlob).toHaveBeenCalledTimes(0); }); test('With isEnableDownloader is false', () => { @@ -72,18 +79,23 @@ describe('TimelineDownloader', () => { isEnableDownloader: false, }; wrapper = mount(); - expect(wrapper.find('[data-test-subj="export-timeline-downloader"]').exists()).toBeFalsy(); + expect(downloadBlob).toHaveBeenCalledTimes(0); }); }); - describe('should render a downloader', () => { - test('With selectedItems and exportedIds is given and isEnableDownloader is true', () => { + describe('should start download', () => { + test('With selectedItems and exportedIds is given and isEnableDownloader is true', async () => { const testProps = { ...defaultTestProps, selectedItems: mockSelectedTimeline, }; wrapper = mount(); - expect(wrapper.find('[data-test-subj="export-timeline-downloader"]').exists()).toBeTruthy(); + + await waitFor(() => { + wrapper.update(); + + expect(downloadBlob).toHaveBeenCalledTimes(1); + }); }); test('With correct toast message on success for exported timelines', async () => { diff --git a/x-pack/plugins/security_solution/public/timelines/components/open_timeline/export_timeline/export_timeline.tsx b/x-pack/plugins/security_solution/public/timelines/components/open_timeline/export_timeline/export_timeline.tsx index b8b1c76ffd6d7..10e6ea9ee085c 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/open_timeline/export_timeline/export_timeline.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/open_timeline/export_timeline/export_timeline.tsx @@ -5,23 +5,20 @@ * 2.0. */ -import React, { useCallback } from 'react'; +import React, { useCallback, useEffect } from 'react'; import { useParams } from 'react-router-dom'; -import { - GenericDownloader, - ExportSelectedData, -} from '../../../../common/components/generic_downloader'; import * as i18n from '../translations'; import { TimelineType } from '../../../../../common/types/timeline'; import { useAppToasts } from '../../../../common/hooks/use_app_toasts'; +import { exportSelectedTimeline } from '../../../containers/api'; +import { downloadBlob } from '../../../../common/utils/download_blob'; const ExportTimeline: React.FC<{ exportedIds: string[] | undefined; - getExportedData: ExportSelectedData; isEnableDownloader: boolean; onComplete?: () => void; -}> = ({ onComplete, isEnableDownloader, exportedIds, getExportedData }) => { +}> = ({ onComplete, isEnableDownloader, exportedIds }) => { const { tabName: timelineType } = useParams<{ tabName: TimelineType }>(); const { addSuccess } = useAppToasts(); @@ -47,20 +44,28 @@ const ExportTimeline: React.FC<{ } }, [onComplete]); - return ( - <> - {exportedIds != null && isEnableDownloader && ( - - )} - - ); + useEffect(() => { + const downloadTimeline = async () => { + if (exportedIds?.length && isEnableDownloader) { + const result = await exportSelectedTimeline({ ids: exportedIds }); + if (result instanceof Blob) { + downloadBlob(result, `${i18n.EXPORT_FILENAME}.ndjson`); + onExportSuccess(exportedIds.length); + } else { + onExportFailure(); + } + } + }; + + downloadTimeline(); + // We probably don't need to have ExportTimeline in the form of a React component. + // See https://github.com/elastic/kibana/issues/101571 for more detail. + // But for now, it uses isEnableDownloader as a signal to start downloading. + // Other variables are excluded from the deps array to avoid false positives + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [exportedIds, isEnableDownloader]); + + return null; }; ExportTimeline.displayName = 'ExportTimeline'; export const TimelineDownloader = React.memo(ExportTimeline); diff --git a/x-pack/plugins/security_solution/public/timelines/components/open_timeline/export_timeline/index.tsx b/x-pack/plugins/security_solution/public/timelines/components/open_timeline/export_timeline/index.tsx index 250e7847edb5c..aa447c9e84f97 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/open_timeline/export_timeline/index.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/open_timeline/export_timeline/index.tsx @@ -10,7 +10,6 @@ import { DeleteTimelines } from '../types'; import { TimelineDownloader } from './export_timeline'; import { DeleteTimelineModalOverlay } from '../delete_timeline_modal'; -import { exportSelectedTimeline } from '../../../containers/api'; export interface ExportTimeline { disableExportTimelineDownloader: () => void; @@ -37,7 +36,6 @@ export const EditTimelineActionsComponent: React.FC<{ @@ -55,4 +53,3 @@ export const EditTimelineActionsComponent: React.FC<{ ); export const EditTimelineActions = React.memo(EditTimelineActionsComponent); -export const EditOneTimelineAction = React.memo(EditTimelineActionsComponent); diff --git a/x-pack/plugins/security_solution/public/timelines/components/open_timeline/open_timeline.tsx b/x-pack/plugins/security_solution/public/timelines/components/open_timeline/open_timeline.tsx index 316b6cff766ea..922e40d6d860e 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/open_timeline/open_timeline.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/open_timeline/open_timeline.tsx @@ -24,7 +24,7 @@ import { importTimelines } from '../../containers/api'; import { useEditTimelineBatchActions } from './edit_timeline_batch_actions'; import { useEditTimelineActions } from './edit_timeline_actions'; -import { EditOneTimelineAction } from './export_timeline'; +import { EditTimelineActions } from './export_timeline'; import { SearchRow } from './search_row'; import { TimelinesTable } from './timelines_table'; import * as i18n from './translations'; @@ -170,7 +170,7 @@ export const OpenTimeline = React.memo( return ( <> - => { +}: ExportDocumentsProps): Promise => { let requestBody; try { requestBody = ids.length > 0 ? JSON.stringify({ ids }) : undefined; diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/routes/__mocks__/request_responses.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/routes/__mocks__/request_responses.ts index 857762dec45e9..3942d1637fedd 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/routes/__mocks__/request_responses.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/routes/__mocks__/request_responses.ts @@ -18,6 +18,7 @@ import { DETECTION_ENGINE_PREPACKAGED_URL, DETECTION_ENGINE_SIGNALS_FINALIZE_MIGRATION_URL, DETECTION_ENGINE_SIGNALS_MIGRATION_STATUS_URL, + DETECTION_ENGINE_RULES_BULK_ACTION, } from '../../../../../common/constants'; import { ShardsResponse } from '../../../types'; import { @@ -36,6 +37,7 @@ import { getSignalsMigrationStatusSchemaMock } from '../../../../../common/detec import { RuleParams } from '../../schemas/rule_schemas'; import { Alert } from '../../../../../../alerting/common'; import { getQueryRuleParams } from '../../schemas/rule_schemas.mock'; +import { getPerformBulkActionSchemaMock } from '../../../../../common/detection_engine/schemas/request/perform_bulk_action_schema.mock'; export const typicalSetStatusSignalByIdsPayload = (): SetSignalsStatusSchemaDecoded => ({ signal_ids: ['somefakeid1', 'somefakeid2'], @@ -107,6 +109,13 @@ export const getPatchBulkRequest = () => body: [getCreateRulesSchemaMock()], }); +export const getBulkActionRequest = () => + requestMock.create({ + method: 'patch', + path: DETECTION_ENGINE_RULES_BULK_ACTION, + body: getPerformBulkActionSchemaMock(), + }); + export const getDeleteBulkRequest = () => requestMock.create({ method: 'delete', diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/routes/rules/delete_rules_bulk_route.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/routes/rules/delete_rules_bulk_route.ts index 1e7ba976d6915..3068521682f8f 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/routes/rules/delete_rules_bulk_route.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/routes/rules/delete_rules_bulk_route.ts @@ -23,9 +23,8 @@ import { getIdBulkError } from './utils'; import { transformValidateBulkError } from './validate'; import { transformBulkError, buildSiemResponse, createBulkErrorObject } from '../utils'; import { deleteRules } from '../../rules/delete_rules'; -import { deleteNotifications } from '../../notifications/delete_notifications'; -import { deleteRuleActionsSavedObject } from '../../rule_actions/delete_rule_actions_saved_object'; import { ruleStatusSavedObjectsClientFactory } from '../../signals/rule_status_saved_objects_client'; +import { readRules } from '../../rules/read_rules'; type Config = RouteConfig; type Handler = RequestHandler< @@ -74,27 +73,24 @@ export const deleteRulesBulkRoute = (router: SecuritySolutionPluginRouter) => { } try { - const rule = await deleteRules({ - alertsClient, - id, - ruleId, - }); - if (rule != null) { - await deleteNotifications({ alertsClient, ruleAlertId: rule.id }); - await deleteRuleActionsSavedObject({ - ruleAlertId: rule.id, - savedObjectsClient, - }); - const ruleStatuses = await ruleStatusClient.find({ - perPage: 6, - search: rule.id, - searchFields: ['alertId'], - }); - ruleStatuses.saved_objects.forEach(async (obj) => ruleStatusClient.delete(obj.id)); - return transformValidateBulkError(idOrRuleIdOrUnknown, rule, undefined, ruleStatuses); - } else { + const rule = await readRules({ alertsClient, id, ruleId }); + if (!rule) { return getIdBulkError({ id, ruleId }); } + + const ruleStatuses = await ruleStatusClient.find({ + perPage: 6, + search: rule.id, + searchFields: ['alertId'], + }); + await deleteRules({ + alertsClient, + savedObjectsClient, + ruleStatusClient, + ruleStatuses, + id: rule.id, + }); + return transformValidateBulkError(idOrRuleIdOrUnknown, rule, undefined, ruleStatuses); } catch (err) { return transformBulkError(idOrRuleIdOrUnknown, err); } diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/routes/rules/delete_rules_route.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/routes/rules/delete_rules_route.ts index 4b05f603b85b7..4a6b41230f799 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/routes/rules/delete_rules_route.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/routes/rules/delete_rules_route.ts @@ -19,9 +19,8 @@ import { deleteRules } from '../../rules/delete_rules'; import { getIdError, transform } from './utils'; import { buildSiemResponse } from '../utils'; -import { deleteNotifications } from '../../notifications/delete_notifications'; -import { deleteRuleActionsSavedObject } from '../../rule_actions/delete_rule_actions_saved_object'; import { ruleStatusSavedObjectsClientFactory } from '../../signals/rule_status_saved_objects_client'; +import { readRules } from '../../rules/read_rules'; export const deleteRulesRoute = ( router: SecuritySolutionPluginRouter, @@ -57,36 +56,33 @@ export const deleteRulesRoute = ( } const ruleStatusClient = ruleStatusSavedObjectsClientFactory(savedObjectsClient); - const rule = await deleteRules({ - alertsClient, - id, - ruleId, - }); - if (rule != null) { - await deleteNotifications({ alertsClient, ruleAlertId: rule.id }); - await deleteRuleActionsSavedObject({ - ruleAlertId: rule.id, - savedObjectsClient, - }); - const ruleStatuses = await ruleStatusClient.find({ - perPage: 6, - search: rule.id, - searchFields: ['alertId'], - }); - ruleStatuses.saved_objects.forEach(async (obj) => ruleStatusClient.delete(obj.id)); - const transformed = transform(rule, undefined, ruleStatuses.saved_objects[0]); - if (transformed == null) { - return siemResponse.error({ statusCode: 500, body: 'failed to transform alert' }); - } else { - return response.ok({ body: transformed ?? {} }); - } - } else { + const rule = await readRules({ alertsClient, id, ruleId }); + if (!rule) { const error = getIdError({ id, ruleId }); return siemResponse.error({ body: error.message, statusCode: error.statusCode, }); } + + const ruleStatuses = await ruleStatusClient.find({ + perPage: 6, + search: rule.id, + searchFields: ['alertId'], + }); + await deleteRules({ + alertsClient, + savedObjectsClient, + ruleStatusClient, + ruleStatuses, + id: rule.id, + }); + const transformed = transform(rule, undefined, ruleStatuses.saved_objects[0]); + if (transformed == null) { + return siemResponse.error({ statusCode: 500, body: 'failed to transform alert' }); + } else { + return response.ok({ body: transformed ?? {} }); + } } catch (err) { const error = transformError(err); return siemResponse.error({ diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/routes/rules/perform_bulk_action_route.test.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/routes/rules/perform_bulk_action_route.test.ts new file mode 100644 index 0000000000000..60677fd8eda90 --- /dev/null +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/routes/rules/perform_bulk_action_route.test.ts @@ -0,0 +1,148 @@ +/* + * 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 { DETECTION_ENGINE_RULES_BULK_ACTION } from '../../../../../common/constants'; +import { mlServicesMock, mlAuthzMock as mockMlAuthzFactory } from '../../../machine_learning/mocks'; +import { buildMlAuthz } from '../../../machine_learning/authz'; +import { + getEmptyFindResult, + getFindResultStatus, + getBulkActionRequest, + getFindResultWithSingleHit, + getFindResultWithMultiHits, +} from '../__mocks__/request_responses'; +import { requestContextMock, serverMock, requestMock } from '../__mocks__'; +import { performBulkActionRoute } from './perform_bulk_action_route'; +import { getPerformBulkActionSchemaMock } from '../../../../../common/detection_engine/schemas/request/perform_bulk_action_schema.mock'; + +jest.mock('../../../machine_learning/authz', () => mockMlAuthzFactory.create()); + +describe('perform_bulk_action', () => { + let server: ReturnType; + let { clients, context } = requestContextMock.createTools(); + let ml: ReturnType; + + beforeEach(() => { + server = serverMock.create(); + ({ clients, context } = requestContextMock.createTools()); + ml = mlServicesMock.createSetupContract(); + + clients.alertsClient.find.mockResolvedValue(getFindResultWithSingleHit()); + clients.savedObjectsClient.find.mockResolvedValue(getFindResultStatus()); + + performBulkActionRoute(server.router, ml); + }); + + describe('status codes', () => { + it('returns 200 when performing bulk action with all dependencies present', async () => { + const response = await server.inject(getBulkActionRequest(), context); + expect(response.status).toEqual(200); + expect(response.body).toEqual({ success: true, rules_count: 1 }); + }); + + it("returns 200 when provided filter query doesn't match any rules", async () => { + clients.alertsClient.find.mockResolvedValue(getEmptyFindResult()); + const response = await server.inject(getBulkActionRequest(), context); + expect(response.status).toEqual(200); + expect(response.body).toEqual({ success: true, rules_count: 0 }); + }); + + it('returns 400 when provided filter query matches too many rules', async () => { + clients.alertsClient.find.mockResolvedValue( + getFindResultWithMultiHits({ data: [], total: Infinity }) + ); + const response = await server.inject(getBulkActionRequest(), context); + expect(response.status).toEqual(400); + expect(response.body).toEqual({ + message: 'More than 10000 rules matched the filter query. Try to narrow it down.', + status_code: 400, + }); + }); + + it('returns 404 if alertClient is not available on the route', async () => { + context.alerting!.getAlertsClient = jest.fn(); + const response = await server.inject(getBulkActionRequest(), context); + expect(response.status).toEqual(404); + expect(response.body).toEqual({ message: 'Not Found', status_code: 404 }); + }); + + it('catches error if disable throws error', async () => { + clients.alertsClient.disable.mockImplementation(async () => { + throw new Error('Test error'); + }); + const response = await server.inject(getBulkActionRequest(), context); + expect(response.status).toEqual(500); + expect(response.body).toEqual({ + message: 'Test error', + status_code: 500, + }); + }); + + it('rejects patching a rule if mlAuthz fails', async () => { + (buildMlAuthz as jest.Mock).mockReturnValueOnce({ + validateRuleType: jest + .fn() + .mockResolvedValue({ valid: false, message: 'mocked validation message' }), + }); + const response = await server.inject(getBulkActionRequest(), context); + + expect(response.status).toEqual(403); + expect(response.body).toEqual({ + message: 'mocked validation message', + status_code: 403, + }); + }); + }); + + describe('request validation', () => { + it('rejects payloads with no action', async () => { + const request = requestMock.create({ + method: 'patch', + path: DETECTION_ENGINE_RULES_BULK_ACTION, + body: { ...getPerformBulkActionSchemaMock(), action: undefined }, + }); + const result = server.validate(request); + expect(result.badRequest).toHaveBeenCalledWith( + 'Invalid value "undefined" supplied to "action"' + ); + }); + + it('rejects payloads with unknown action', async () => { + const request = requestMock.create({ + method: 'patch', + path: DETECTION_ENGINE_RULES_BULK_ACTION, + body: { ...getPerformBulkActionSchemaMock(), action: 'unknown' }, + }); + const result = server.validate(request); + expect(result.badRequest).toHaveBeenCalledWith( + 'Invalid value "unknown" supplied to "action"' + ); + }); + + it('accepts payloads with no query', async () => { + const request = requestMock.create({ + method: 'patch', + path: DETECTION_ENGINE_RULES_BULK_ACTION, + body: { ...getPerformBulkActionSchemaMock(), query: undefined }, + }); + const result = server.validate(request); + + expect(result.ok).toHaveBeenCalled(); + }); + + it('accepts payloads with query and action', async () => { + const request = requestMock.create({ + method: 'patch', + path: DETECTION_ENGINE_RULES_BULK_ACTION, + body: getPerformBulkActionSchemaMock(), + }); + const result = server.validate(request); + + expect(result.ok).toHaveBeenCalled(); + }); + }); +}); diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/routes/rules/perform_bulk_action_route.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/routes/rules/perform_bulk_action_route.ts new file mode 100644 index 0000000000000..9d569acf3782a --- /dev/null +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/routes/rules/perform_bulk_action_route.ts @@ -0,0 +1,172 @@ +/* + * 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 { transformError } from '@kbn/securitysolution-es-utils'; +import { DETECTION_ENGINE_RULES_BULK_ACTION } from '../../../../../common/constants'; +import { BulkAction } from '../../../../../common/detection_engine/schemas/common/schemas'; +import { performBulkActionSchema } from '../../../../../common/detection_engine/schemas/request/perform_bulk_action_schema'; +import { SetupPlugins } from '../../../../plugin'; +import type { SecuritySolutionPluginRouter } from '../../../../types'; +import { buildRouteValidation } from '../../../../utils/build_validation/route_validation'; +import { buildMlAuthz } from '../../../machine_learning/authz'; +import { throwHttpError } from '../../../machine_learning/validation'; +import { deleteRules } from '../../rules/delete_rules'; +import { duplicateRule } from '../../rules/duplicate_rule'; +import { enableRule } from '../../rules/enable_rule'; +import { findRules } from '../../rules/find_rules'; +import { getExportByObjectIds } from '../../rules/get_export_by_object_ids'; +import { updateRulesNotifications } from '../../rules/update_rules_notifications'; +import { getRuleActionsSavedObject } from '../../rule_actions/get_rule_actions_saved_object'; +import { ruleStatusSavedObjectsClientFactory } from '../../signals/rule_status_saved_objects_client'; +import { buildSiemResponse } from '../utils'; + +const BULK_ACTION_RULES_LIMIT = 10000; + +export const performBulkActionRoute = ( + router: SecuritySolutionPluginRouter, + ml: SetupPlugins['ml'] +) => { + router.post( + { + path: DETECTION_ENGINE_RULES_BULK_ACTION, + validate: { + body: buildRouteValidation(performBulkActionSchema), + }, + options: { + tags: ['access:securitySolution'], + }, + }, + async (context, request, response) => { + const { body } = request; + const siemResponse = buildSiemResponse(response); + + try { + const alertsClient = context.alerting?.getAlertsClient(); + const savedObjectsClient = context.core.savedObjects.client; + const ruleStatusClient = ruleStatusSavedObjectsClientFactory(savedObjectsClient); + + const mlAuthz = buildMlAuthz({ + license: context.licensing.license, + ml, + request, + savedObjectsClient, + }); + + if (!alertsClient) { + return siemResponse.error({ statusCode: 404 }); + } + + const rules = await findRules({ + alertsClient, + perPage: BULK_ACTION_RULES_LIMIT, + filter: body.query !== '' ? body.query : undefined, + page: undefined, + sortField: undefined, + sortOrder: undefined, + fields: undefined, + }); + + if (rules.total > BULK_ACTION_RULES_LIMIT) { + return siemResponse.error({ + body: `More than ${BULK_ACTION_RULES_LIMIT} rules matched the filter query. Try to narrow it down.`, + statusCode: 400, + }); + } + + switch (body.action) { + case BulkAction.enable: + await Promise.all( + rules.data.map(async (rule) => { + if (!rule.enabled) { + throwHttpError(await mlAuthz.validateRuleType(rule.params.type)); + await enableRule({ rule, alertsClient, savedObjectsClient }); + } + }) + ); + break; + case BulkAction.disable: + await Promise.all( + rules.data.map(async (rule) => { + if (rule.enabled) { + throwHttpError(await mlAuthz.validateRuleType(rule.params.type)); + await alertsClient.disable({ id: rule.id }); + } + }) + ); + break; + case BulkAction.delete: + await Promise.all( + rules.data.map(async (rule) => { + const ruleStatuses = await ruleStatusClient.find({ + perPage: 6, + search: rule.id, + searchFields: ['alertId'], + }); + await deleteRules({ + alertsClient, + savedObjectsClient, + ruleStatusClient, + ruleStatuses, + id: rule.id, + }); + }) + ); + break; + case BulkAction.duplicate: + await Promise.all( + rules.data.map(async (rule) => { + throwHttpError(await mlAuthz.validateRuleType(rule.params.type)); + + const createdRule = await alertsClient.create({ + data: duplicateRule(rule), + }); + + const ruleActions = await getRuleActionsSavedObject({ + savedObjectsClient, + ruleAlertId: rule.id, + }); + + await updateRulesNotifications({ + ruleAlertId: createdRule.id, + alertsClient, + savedObjectsClient, + enabled: createdRule.enabled, + actions: ruleActions?.actions || [], + throttle: ruleActions?.alertThrottle, + name: createdRule.name, + }); + }) + ); + break; + case BulkAction.export: + const exported = await getExportByObjectIds( + alertsClient, + rules.data.map(({ params }) => ({ rule_id: params.ruleId })) + ); + + const responseBody = `${exported.rulesNdjson}${exported.exportDetails}`; + + return response.ok({ + headers: { + 'Content-Disposition': `attachment; filename="rules_export.ndjson"`, + 'Content-Type': 'application/ndjson', + }, + body: responseBody, + }); + } + + return response.ok({ body: { success: true, rules_count: rules.data.length } }); + } catch (err) { + const error = transformError(err); + return siemResponse.error({ + body: error.message, + statusCode: error.statusCode, + }); + } + } + ); +}; diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/rules/add_tags.test.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/rules/add_tags.test.ts index 972e44c718f94..a871c7157d5e8 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/rules/add_tags.test.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/rules/add_tags.test.ts @@ -33,8 +33,8 @@ describe('add_tags', () => { const tags2 = addTags(tags1, 'rule-1', false); expect(tags2).toEqual([ 'tag-1', - `${INTERNAL_RULE_ID_KEY}:rule-1`, `${INTERNAL_IMMUTABLE_KEY}:false`, + `${INTERNAL_RULE_ID_KEY}:rule-1`, ]); }); }); diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/rules/add_tags.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/rules/add_tags.ts index 84a2483938421..6ff4a54ad8e54 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/rules/add_tags.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/rules/add_tags.ts @@ -10,7 +10,7 @@ import { INTERNAL_RULE_ID_KEY, INTERNAL_IMMUTABLE_KEY } from '../../../../common export const addTags = (tags: string[], ruleId: string, immutable: boolean): string[] => { return Array.from( new Set([ - ...tags, + ...tags.filter((tag) => !tag.startsWith(INTERNAL_RULE_ID_KEY)), `${INTERNAL_RULE_ID_KEY}:${ruleId}`, `${INTERNAL_IMMUTABLE_KEY}:${immutable}`, ]) diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/rules/delete_rules.test.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/rules/delete_rules.test.ts index e7a4df790d62d..f581be9e1f62b 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/rules/delete_rules.test.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/rules/delete_rules.test.ts @@ -5,138 +5,74 @@ * 2.0. */ +import { savedObjectsClientMock } from '../../../../../../../src/core/server/mocks'; import { alertsClientMock } from '../../../../../alerting/server/mocks'; +import { ruleStatusSavedObjectsClientMock } from '../signals/__mocks__/rule_status_saved_objects_client.mock'; import { deleteRules } from './delete_rules'; -import { readRules } from './read_rules'; -jest.mock('./read_rules'); +import { deleteNotifications } from '../notifications/delete_notifications'; +import { deleteRuleActionsSavedObject } from '../rule_actions/delete_rule_actions_saved_object'; +import { SavedObjectsFindResult } from '../../../../../../../src/core/server'; +import { IRuleStatusSOAttributes } from './types'; + +jest.mock('../notifications/delete_notifications'); +jest.mock('../rule_actions/delete_rule_actions_saved_object'); describe('deleteRules', () => { let alertsClient: ReturnType; - const notificationId = 'notification-52128c15-0d1b-4716-a4c5-46997ac7f3bd'; - const ruleId = 'rule-04128c15-0d1b-4716-a4c5-46997ac7f3bd'; + let ruleStatusClient: ReturnType; + let savedObjectsClient: ReturnType; beforeEach(() => { alertsClient = alertsClientMock.create(); + savedObjectsClient = savedObjectsClientMock.create(); + ruleStatusClient = ruleStatusSavedObjectsClientMock.create(); }); - it('should return null if notification was not found', async () => { - (readRules as jest.Mock).mockResolvedValue(null); - - const result = await deleteRules({ - alertsClient, - id: notificationId, - ruleId, - }); - - expect(result).toBe(null); - }); - - it('should call alertsClient.delete if notification was found', async () => { - (readRules as jest.Mock).mockResolvedValue({ - id: notificationId, - }); - - const result = await deleteRules({ - alertsClient, - id: notificationId, - ruleId, - }); - - expect(alertsClient.delete).toHaveBeenCalledWith( - expect.objectContaining({ - id: notificationId, - }) - ); - expect(result).toEqual({ id: notificationId }); - }); - - it('should call alertsClient.delete if ruleId was undefined', async () => { - (readRules as jest.Mock).mockResolvedValue({ - id: null, - }); - - const result = await deleteRules({ - alertsClient, - id: notificationId, - ruleId: undefined, - }); - - expect(alertsClient.delete).toHaveBeenCalledWith( - expect.objectContaining({ - id: notificationId, - }) - ); - expect(result).toEqual({ id: null }); - }); - - it('should return null if alertsClient.delete rejects with 404 if ruleId was undefined', async () => { - (readRules as jest.Mock).mockResolvedValue({ - id: null, - }); - - alertsClient.delete.mockRejectedValue({ - output: { - statusCode: 404, + it('should delete the rule along with its notifications, actions, and statuses', async () => { + const ruleStatus: SavedObjectsFindResult = { + id: 'statusId', + type: '', + references: [], + attributes: { + alertId: 'alertId', + statusDate: '', + lastFailureAt: null, + lastFailureMessage: null, + lastSuccessAt: null, + lastSuccessMessage: null, + status: null, + lastLookBackDate: null, + gap: null, + bulkCreateTimeDurations: null, + searchAfterTimeDurations: null, }, - }); + score: 0, + }; - const result = await deleteRules({ + const rule = { alertsClient, - id: notificationId, - ruleId: undefined, - }); - - expect(alertsClient.delete).toHaveBeenCalledWith( - expect.objectContaining({ - id: notificationId, - }) - ); - expect(result).toEqual(null); - }); - - it('should return error object if alertsClient.delete rejects with status different than 404 and if ruleId was undefined', async () => { - (readRules as jest.Mock).mockResolvedValue({ - id: null, - }); - - const errorObject = { - output: { - statusCode: 500, + savedObjectsClient, + ruleStatusClient, + id: 'ruleId', + ruleStatuses: { + total: 0, + per_page: 0, + page: 0, + saved_objects: [ruleStatus], }, }; - alertsClient.delete.mockRejectedValue(errorObject); + await deleteRules(rule); - let errorResult; - try { - await deleteRules({ - alertsClient, - id: notificationId, - ruleId: undefined, - }); - } catch (error) { - errorResult = error; - } - - expect(alertsClient.delete).toHaveBeenCalledWith( - expect.objectContaining({ - id: notificationId, - }) - ); - expect(errorResult).toEqual(errorObject); - }); - - it('should return null if ruleId and id was undefined', async () => { - (readRules as jest.Mock).mockResolvedValue({ - id: null, + expect(alertsClient.delete).toHaveBeenCalledWith({ id: rule.id }); + expect(deleteNotifications).toHaveBeenCalledWith({ + ruleAlertId: rule.id, + alertsClient: expect.any(Object), }); - - const result = await deleteRules({ - alertsClient, - id: undefined, - ruleId: undefined, + expect(deleteRuleActionsSavedObject).toHaveBeenCalledWith({ + ruleAlertId: rule.id, + savedObjectsClient: expect.any(Object), }); - - expect(result).toEqual(null); + expect(ruleStatusClient.delete).toHaveBeenCalledWith(ruleStatus.id); }); }); diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/rules/delete_rules.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/rules/delete_rules.ts index 3947103e7625d..ed5477599253b 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/rules/delete_rules.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/rules/delete_rules.ts @@ -5,30 +5,19 @@ * 2.0. */ -import { readRules } from './read_rules'; +import { deleteNotifications } from '../notifications/delete_notifications'; +import { deleteRuleActionsSavedObject } from '../rule_actions/delete_rule_actions_saved_object'; import { DeleteRuleOptions } from './types'; -export const deleteRules = async ({ alertsClient, id, ruleId }: DeleteRuleOptions) => { - const rule = await readRules({ alertsClient, id, ruleId }); - if (rule == null) { - return null; - } - - if (ruleId != null) { - await alertsClient.delete({ id: rule.id }); - return rule; - } else if (id != null) { - try { - await alertsClient.delete({ id }); - return rule; - } catch (err) { - if (err.output.statusCode === 404) { - return null; - } else { - throw err; - } - } - } else { - return null; - } +export const deleteRules = async ({ + alertsClient, + savedObjectsClient, + ruleStatusClient, + ruleStatuses, + id, +}: DeleteRuleOptions) => { + await alertsClient.delete({ id }); + await deleteNotifications({ alertsClient, ruleAlertId: id }); + await deleteRuleActionsSavedObject({ ruleAlertId: id, savedObjectsClient }); + ruleStatuses.saved_objects.forEach(async (obj) => ruleStatusClient.delete(obj.id)); }; diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/rules/duplicate_rule.test.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/rules/duplicate_rule.test.ts new file mode 100644 index 0000000000000..3046999a632c6 --- /dev/null +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/rules/duplicate_rule.test.ts @@ -0,0 +1,133 @@ +/* + * 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 uuid from 'uuid'; +import { INTERNAL_IMMUTABLE_KEY } from '../../../../common/constants'; +import { duplicateRule } from './duplicate_rule'; + +jest.mock('uuid', () => ({ + v4: jest.fn(), +})); + +describe('duplicateRule', () => { + it('should return a copy of rule with new ruleId', () => { + (uuid.v4 as jest.Mock).mockReturnValue('newId'); + + expect( + duplicateRule({ + id: 'oldTestRuleId', + notifyWhen: 'onActiveAlert', + name: 'test', + tags: ['test', '__internal_rule_id:oldTestRuleId', `${INTERNAL_IMMUTABLE_KEY}:false`], + alertTypeId: 'siem.signals', + consumer: 'siem', + params: { + savedId: undefined, + author: [], + description: 'test', + ruleId: 'oldTestRuleId', + falsePositives: [], + from: 'now-360s', + immutable: false, + license: '', + outputIndex: '.siem-signals-default', + meta: undefined, + maxSignals: 100, + riskScore: 42, + riskScoreMapping: [], + severity: 'low', + severityMapping: [], + threat: [], + to: 'now', + references: [], + version: 1, + exceptionsList: [], + type: 'query', + language: 'kuery', + index: [], + query: 'process.args : "chmod"', + filters: [], + buildingBlockType: undefined, + note: undefined, + timelineId: undefined, + timelineTitle: undefined, + ruleNameOverride: undefined, + timestampOverride: undefined, + }, + schedule: { + interval: '5m', + }, + enabled: false, + actions: [], + throttle: null, + apiKeyOwner: 'kibana', + createdBy: 'kibana', + updatedBy: 'kibana', + muteAll: false, + mutedInstanceIds: [], + updatedAt: new Date(2021, 0), + createdAt: new Date(2021, 0), + scheduledTaskId: undefined, + executionStatus: { + lastExecutionDate: new Date(2021, 0), + status: 'ok', + }, + }) + ).toMatchInlineSnapshot(` + Object { + "actions": Array [], + "alertTypeId": "siem.signals", + "consumer": "siem", + "enabled": false, + "name": "test [Duplicate]", + "notifyWhen": null, + "params": Object { + "author": Array [], + "buildingBlockType": undefined, + "description": "test", + "exceptionsList": Array [], + "falsePositives": Array [], + "filters": Array [], + "from": "now-360s", + "immutable": false, + "index": Array [], + "language": "kuery", + "license": "", + "maxSignals": 100, + "meta": undefined, + "note": undefined, + "outputIndex": ".siem-signals-default", + "query": "process.args : \\"chmod\\"", + "references": Array [], + "riskScore": 42, + "riskScoreMapping": Array [], + "ruleId": "newId", + "ruleNameOverride": undefined, + "savedId": undefined, + "severity": "low", + "severityMapping": Array [], + "threat": Array [], + "timelineId": undefined, + "timelineTitle": undefined, + "timestampOverride": undefined, + "to": "now", + "type": "query", + "version": 1, + }, + "schedule": Object { + "interval": "5m", + }, + "tags": Array [ + "test", + "__internal_immutable:false", + "__internal_rule_id:newId", + ], + "throttle": null, + } + `); + }); +}); diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/rules/duplicate_rule.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/rules/duplicate_rule.ts new file mode 100644 index 0000000000000..2f12e33507422 --- /dev/null +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/rules/duplicate_rule.ts @@ -0,0 +1,40 @@ +/* + * 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 uuid from 'uuid'; +import { i18n } from '@kbn/i18n'; +import { SanitizedAlert } from '../../../../../alerting/common'; +import { SERVER_APP_ID, SIGNALS_ID } from '../../../../common/constants'; +import { InternalRuleCreate, RuleParams } from '../schemas/rule_schemas'; +import { addTags } from './add_tags'; + +const DUPLICATE_TITLE = i18n.translate( + 'xpack.securitySolution.detectionEngine.rules.cloneRule.duplicateTitle', + { + defaultMessage: 'Duplicate', + } +); + +export const duplicateRule = (rule: SanitizedAlert): InternalRuleCreate => { + const newRuleId = uuid.v4(); + return { + name: `${rule.name} [${DUPLICATE_TITLE}]`, + tags: addTags(rule.tags, newRuleId, false), + alertTypeId: SIGNALS_ID, + consumer: SERVER_APP_ID, + params: { + ...rule.params, + immutable: false, + ruleId: newRuleId, + }, + schedule: rule.schedule, + enabled: false, + actions: rule.actions, + throttle: null, + notifyWhen: null, + }; +}; diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/rules/enable_rule.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/rules/enable_rule.ts new file mode 100644 index 0000000000000..dc4cca2059b3e --- /dev/null +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/rules/enable_rule.ts @@ -0,0 +1,47 @@ +/* + * 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 { SavedObjectsClientContract } from 'kibana/server'; +import { SanitizedAlert } from '../../../../../alerting/common'; +import { AlertsClient } from '../../../../../alerting/server'; +import { RuleParams } from '../schemas/rule_schemas'; +import { ruleStatusSavedObjectsClientFactory } from '../signals/rule_status_saved_objects_client'; + +interface EnableRuleArgs { + rule: SanitizedAlert; + alertsClient: AlertsClient; + savedObjectsClient: SavedObjectsClientContract; +} + +/** + * Enables the rule and updates its status to 'going to run' + * + * @param rule - rule to enable + * @param alertsClient - Alerts client + * @param savedObjectsClient - Saved Objects client + */ +export const enableRule = async ({ rule, alertsClient, savedObjectsClient }: EnableRuleArgs) => { + await alertsClient.enable({ id: rule.id }); + + const ruleStatusClient = ruleStatusSavedObjectsClientFactory(savedObjectsClient); + const ruleCurrentStatus = await ruleStatusClient.find({ + perPage: 1, + sortField: 'statusDate', + sortOrder: 'desc', + search: rule.id, + searchFields: ['alertId'], + }); + + // set current status for this rule to be 'going to run' + if (ruleCurrentStatus && ruleCurrentStatus.saved_objects.length > 0) { + const currentStatusToDisable = ruleCurrentStatus.saved_objects[0]; + await ruleStatusClient.update(currentStatusToDisable.id, { + ...currentStatusToDisable.attributes, + status: 'going to run', + }); + } +}; diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/rules/find_rules.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/rules/find_rules.ts index 754aaf67c3224..eae5ccd2f6ffd 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/rules/find_rules.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/rules/find_rules.ts @@ -18,7 +18,7 @@ export const getFilter = (filter: string | null | undefined) => { } }; -export const findRules = async ({ +export const findRules = ({ alertsClient, perPage, page, diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/rules/patch_rules.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/rules/patch_rules.ts index b9a88bc36a812..72af7ebc340cd 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/rules/patch_rules.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/rules/patch_rules.ts @@ -5,19 +5,19 @@ * 2.0. */ -import { defaults } from 'lodash/fp'; import { validate } from '@kbn/securitysolution-io-ts-utils'; +import { defaults } from 'lodash/fp'; import { PartialAlert } from '../../../../../alerting/server'; import { transformRuleToAlertAction } from '../../../../common/detection_engine/transform_actions'; -import { PatchRulesOptions } from './types'; -import { addTags } from './add_tags'; -import { calculateVersion, calculateName, calculateInterval, removeUndefined } from './utils'; -import { ruleStatusSavedObjectsClientFactory } from '../signals/rule_status_saved_objects_client'; -import { internalRuleUpdate, RuleParams } from '../schemas/rule_schemas'; import { normalizeMachineLearningJobIds, normalizeThresholdObject, } from '../../../../common/detection_engine/utils'; +import { internalRuleUpdate, RuleParams } from '../schemas/rule_schemas'; +import { addTags } from './add_tags'; +import { enableRule } from './enable_rule'; +import { PatchRulesOptions } from './types'; +import { calculateInterval, calculateName, calculateVersion, removeUndefined } from './utils'; class PatchError extends Error { public readonly statusCode: number; @@ -200,25 +200,7 @@ export const patchRules = async ({ if (rule.enabled && enabled === false) { await alertsClient.disable({ id: rule.id }); } else if (!rule.enabled && enabled === true) { - await alertsClient.enable({ id: rule.id }); - - const ruleStatusClient = ruleStatusSavedObjectsClientFactory(savedObjectsClient); - const ruleCurrentStatus = await ruleStatusClient.find({ - perPage: 1, - sortField: 'statusDate', - sortOrder: 'desc', - search: rule.id, - searchFields: ['alertId'], - }); - - // set current status for this rule to be 'going to run' - if (ruleCurrentStatus && ruleCurrentStatus.saved_objects.length > 0) { - const currentStatusToDisable = ruleCurrentStatus.saved_objects[0]; - await ruleStatusClient.update(currentStatusToDisable.id, { - ...currentStatusToDisable.attributes, - status: 'going to run', - }); - } + await enableRule({ rule, alertsClient, savedObjectsClient }); } else { // enabled is null or undefined and we do not touch the rule } diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/rules/types.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/rules/types.ts index 601f3ebaa0f9e..d029393ce781e 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/rules/types.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/rules/types.ts @@ -68,6 +68,7 @@ import { MetaOrUndefined, Description, Enabled, + Id, IdOrUndefined, RuleIdOrUndefined, EnabledOrUndefined, @@ -105,6 +106,7 @@ import { Alert, SanitizedAlert } from '../../../../../alerting/common'; import { SIGNALS_ID } from '../../../../common/constants'; import { PartialFilter } from '../types'; import { RuleParams } from '../schemas/rule_schemas'; +import { RuleStatusSavedObjectsClient } from '../signals/rule_status_saved_objects_client'; export type RuleAlertType = Alert; @@ -329,8 +331,10 @@ export interface ReadRuleOptions { export interface DeleteRuleOptions { alertsClient: AlertsClient; - id: IdOrUndefined; - ruleId: RuleIdOrUndefined; + savedObjectsClient: SavedObjectsClientContract; + ruleStatusClient: RuleStatusSavedObjectsClient; + ruleStatuses: SavedObjectsFindResponse; + id: Id; } export interface FindRuleOptions { diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/rules/update_rules.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/rules/update_rules.ts index 38cae8d1cf50f..0fac804163afa 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/rules/update_rules.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/rules/update_rules.ts @@ -13,9 +13,9 @@ import { PartialAlert } from '../../../../../alerting/server'; import { readRules } from './read_rules'; import { UpdateRulesOptions } from './types'; import { addTags } from './add_tags'; -import { ruleStatusSavedObjectsClientFactory } from '../signals/rule_status_saved_objects_client'; import { typeSpecificSnakeToCamel } from '../schemas/rule_converters'; import { InternalRuleUpdate, RuleParams } from '../schemas/rule_schemas'; +import { enableRule } from './enable_rule'; export const updateRules = async ({ alertsClient, @@ -88,25 +88,7 @@ export const updateRules = async ({ if (existingRule.enabled && enabled === false) { await alertsClient.disable({ id: existingRule.id }); } else if (!existingRule.enabled && enabled === true) { - await alertsClient.enable({ id: existingRule.id }); - - const ruleStatusClient = ruleStatusSavedObjectsClientFactory(savedObjectsClient); - const ruleCurrentStatus = await ruleStatusClient.find({ - perPage: 1, - sortField: 'statusDate', - sortOrder: 'desc', - search: existingRule.id, - searchFields: ['alertId'], - }); - - // set current status for this rule to be 'going to run' - if (ruleCurrentStatus && ruleCurrentStatus.saved_objects.length > 0) { - const currentStatusToDisable = ruleCurrentStatus.saved_objects[0]; - await ruleStatusClient.update(currentStatusToDisable.id, { - ...currentStatusToDisable.attributes, - status: 'going to run', - }); - } + await enableRule({ rule: existingRule, alertsClient, savedObjectsClient }); } return { ...update, enabled }; }; diff --git a/x-pack/plugins/security_solution/server/routes/index.ts b/x-pack/plugins/security_solution/server/routes/index.ts index 0245d4cb99cc0..00de66c0dec28 100644 --- a/x-pack/plugins/security_solution/server/routes/index.ts +++ b/x-pack/plugins/security_solution/server/routes/index.ts @@ -31,6 +31,7 @@ import { createRulesBulkRoute } from '../lib/detection_engine/routes/rules/creat import { updateRulesBulkRoute } from '../lib/detection_engine/routes/rules/update_rules_bulk_route'; import { patchRulesBulkRoute } from '../lib/detection_engine/routes/rules/patch_rules_bulk_route'; import { deleteRulesBulkRoute } from '../lib/detection_engine/routes/rules/delete_rules_bulk_route'; +import { performBulkActionRoute } from '../lib/detection_engine/routes/rules/perform_bulk_action_route'; import { importRulesRoute } from '../lib/detection_engine/routes/rules/import_rules_route'; import { exportRulesRoute } from '../lib/detection_engine/routes/rules/export_rules_route'; import { findRulesStatusesRoute } from '../lib/detection_engine/routes/rules/find_rules_status_route'; @@ -81,6 +82,7 @@ export const initRoutes = ( updateRulesBulkRoute(router, ml); patchRulesBulkRoute(router, ml); deleteRulesBulkRoute(router); + performBulkActionRoute(router, ml); createTimelinesRoute(router, config, security); patchTimelinesRoute(router, config, security); diff --git a/x-pack/plugins/translations/translations/ja-JP.json b/x-pack/plugins/translations/translations/ja-JP.json index 7f82d9f32a868..879c666cff672 100644 --- a/x-pack/plugins/translations/translations/ja-JP.json +++ b/x-pack/plugins/translations/translations/ja-JP.json @@ -20103,7 +20103,6 @@ "xpack.securitySolution.detectionEngine.rules.allRules.tabs.monitoring": "ルール監視", "xpack.securitySolution.detectionEngine.rules.allRules.tabs.rules": "ルール", "xpack.securitySolution.detectionEngine.rules.backOptionsHeader": "検出に戻る", - "xpack.securitySolution.detectionEngine.rules.components.genericDownloader.exportFailureTitle": "データをエクスポートできませんでした…", "xpack.securitySolution.detectionEngine.rules.components.ruleActionsOverflow.allActionsTitle": "すべてのアクション", "xpack.securitySolution.detectionEngine.rules.continueButtonTitle": "続行", "xpack.securitySolution.detectionEngine.rules.create.successfullyCreatedRuleTitle": "{ruleName}が作成されました", diff --git a/x-pack/plugins/translations/translations/zh-CN.json b/x-pack/plugins/translations/translations/zh-CN.json index c3c0402ef27ab..ac1a8d69796a2 100644 --- a/x-pack/plugins/translations/translations/zh-CN.json +++ b/x-pack/plugins/translations/translations/zh-CN.json @@ -20388,13 +20388,11 @@ "xpack.securitySolution.detectionEngine.rules.allRules.showingExceptionLists": "正在显示 {totalLists} 个{totalLists, plural, other {列表}}", "xpack.securitySolution.detectionEngine.rules.allRules.showingRulesTitle": "正在显示 {totalRules} 个{totalRules, plural, other {规则}}", "xpack.securitySolution.detectionEngine.rules.allRules.successfullyDuplicatedRulesTitle": "已成功复制 {totalRules, plural, other {{totalRules} 个规则}}", - "xpack.securitySolution.detectionEngine.rules.allRules.successfullyExportedRulesTitle": "已成功导出{totalRules, plural, =0 {所有规则} other { {totalRules} 个规则}}", "xpack.securitySolution.detectionEngine.rules.allRules.tableTitle": "所有规则", "xpack.securitySolution.detectionEngine.rules.allRules.tabs.exceptions": "例外列表", "xpack.securitySolution.detectionEngine.rules.allRules.tabs.monitoring": "规则监测", "xpack.securitySolution.detectionEngine.rules.allRules.tabs.rules": "规则", "xpack.securitySolution.detectionEngine.rules.backOptionsHeader": "返回到检测", - "xpack.securitySolution.detectionEngine.rules.components.genericDownloader.exportFailureTitle": "无法导出数据……", "xpack.securitySolution.detectionEngine.rules.components.ruleActionsOverflow.allActionsTitle": "所有操作", "xpack.securitySolution.detectionEngine.rules.continueButtonTitle": "继续", "xpack.securitySolution.detectionEngine.rules.create.successfullyCreatedRuleTitle": "{ruleName} 已创建", diff --git a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/index.ts b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/index.ts index fd3675a2e47e6..3c5e04ee1f64e 100644 --- a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/index.ts +++ b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/index.ts @@ -35,6 +35,7 @@ export default ({ loadTestFile }: FtrProviderContext): void => { loadTestFile(require.resolve('./update_rules')); loadTestFile(require.resolve('./update_rules_bulk')); loadTestFile(require.resolve('./patch_rules_bulk')); + loadTestFile(require.resolve('./perform_bulk_action')); loadTestFile(require.resolve('./patch_rules')); loadTestFile(require.resolve('./read_privileges')); loadTestFile(require.resolve('./query_signals')); diff --git a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/perform_bulk_action.ts b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/perform_bulk_action.ts new file mode 100644 index 0000000000000..53613624067e1 --- /dev/null +++ b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/perform_bulk_action.ts @@ -0,0 +1,152 @@ +/* + * 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 expect from '@kbn/expect'; + +import { + DETECTION_ENGINE_RULES_BULK_ACTION, + DETECTION_ENGINE_RULES_URL, +} from '../../../../plugins/security_solution/common/constants'; +import { BulkAction } from '../../../../plugins/security_solution/common/detection_engine/schemas/common/schemas'; +import { FtrProviderContext } from '../../common/ftr_provider_context'; +import { + binaryToString, + createRule, + createSignalsIndex, + deleteAllAlerts, + deleteSignalsIndex, + getSimpleRule, + getSimpleRuleOutput, + removeServerGeneratedProperties, +} from '../../utils'; + +// eslint-disable-next-line import/no-default-export +export default ({ getService }: FtrProviderContext): void => { + const supertest = getService('supertest'); + + describe('perform_bulk_action', () => { + beforeEach(async () => { + await createSignalsIndex(supertest); + }); + + afterEach(async () => { + await deleteSignalsIndex(supertest); + await deleteAllAlerts(supertest); + }); + + it('should export rules', async () => { + await createRule(supertest, getSimpleRule()); + + const { body } = await supertest + .post(DETECTION_ENGINE_RULES_BULK_ACTION) + .set('kbn-xsrf', 'true') + .send({ query: '', action: BulkAction.export }) + .expect(200) + .expect('Content-Type', 'application/ndjson') + .expect('Content-Disposition', 'attachment; filename="rules_export.ndjson"') + .parse(binaryToString); + + const [ruleJson, exportDetailsJson] = body.toString().split(/\n/); + + const rule = removeServerGeneratedProperties(JSON.parse(ruleJson)); + expect(rule).to.eql(getSimpleRuleOutput()); + + const exportDetails = JSON.parse(exportDetailsJson); + expect(exportDetails).to.eql({ + exported_count: 1, + missing_rules: [], + missing_rules_count: 0, + }); + }); + + it('should delete rules', async () => { + const ruleId = 'ruleId'; + await createRule(supertest, getSimpleRule(ruleId)); + + const { body } = await supertest + .post(DETECTION_ENGINE_RULES_BULK_ACTION) + .set('kbn-xsrf', 'true') + .send({ query: '', action: BulkAction.delete }) + .expect(200); + + expect(body).to.eql({ success: true, rules_count: 1 }); + + await supertest + .get(`${DETECTION_ENGINE_RULES_URL}?rule_id=${ruleId}`) + .set('kbn-xsrf', 'true') + .expect(404); + }); + + it('should enable rules', async () => { + const ruleId = 'ruleId'; + await createRule(supertest, getSimpleRule(ruleId)); + + const { body } = await supertest + .post(DETECTION_ENGINE_RULES_BULK_ACTION) + .set('kbn-xsrf', 'true') + .send({ query: '', action: BulkAction.enable }) + .expect(200); + + expect(body).to.eql({ success: true, rules_count: 1 }); + + const { body: ruleBody } = await supertest + .get(`${DETECTION_ENGINE_RULES_URL}?rule_id=${ruleId}`) + .set('kbn-xsrf', 'true') + .expect(200); + + const referenceRule = getSimpleRuleOutput(ruleId); + referenceRule.enabled = true; + + const storedRule = removeServerGeneratedProperties(ruleBody); + + expect(storedRule).to.eql(referenceRule); + }); + + it('should disable rules', async () => { + const ruleId = 'ruleId'; + await createRule(supertest, getSimpleRule(ruleId, true)); + + const { body } = await supertest + .post(DETECTION_ENGINE_RULES_BULK_ACTION) + .set('kbn-xsrf', 'true') + .send({ query: '', action: BulkAction.disable }) + .expect(200); + + expect(body).to.eql({ success: true, rules_count: 1 }); + + const { body: ruleBody } = await supertest + .get(`${DETECTION_ENGINE_RULES_URL}?rule_id=${ruleId}`) + .set('kbn-xsrf', 'true') + .expect(200); + + const referenceRule = getSimpleRuleOutput(ruleId); + const storedRule = removeServerGeneratedProperties(ruleBody); + + expect(storedRule).to.eql(referenceRule); + }); + + it('should duplicate rules', async () => { + const ruleId = 'ruleId'; + await createRule(supertest, getSimpleRule(ruleId)); + + const { body } = await supertest + .post(DETECTION_ENGINE_RULES_BULK_ACTION) + .set('kbn-xsrf', 'true') + .send({ query: '', action: BulkAction.duplicate }) + .expect(200); + + expect(body).to.eql({ success: true, rules_count: 1 }); + + const { body: rulesResponse } = await supertest + .get(`${DETECTION_ENGINE_RULES_URL}/_find`) + .set('kbn-xsrf', 'true') + .expect(200); + + expect(rulesResponse.total).to.eql(2); + }); + }); +}; From e94a34df305bc6e72399f377cad1f46721e8ad5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20S=C3=A1nchez?= Date: Wed, 9 Jun 2021 12:11:56 +0200 Subject: [PATCH 18/19] [Security solution][Endpoint] Add back button when to the event filters list (#101280) * Add back button when to the event filters list. Isolated back to external app button to be used as generic component * Adds unit tests for back button Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> --- .../common/endpoint/types/index.ts | 12 +++++ .../common/endpoint/types/trusted_apps.ts | 13 ----- .../back_to_external_app_button.tsx | 52 +++++++++++++++++++ .../back_to_external_app_button/index.ts | 8 +++ .../view/event_filters_list_page.test.tsx | 26 ++++++++++ .../view/event_filters_list_page.tsx | 16 ++++-- .../components/fleet_event_filters_card.tsx | 7 ++- .../components/fleet_trusted_apps_card.tsx | 4 +- .../view/trusted_apps_page.test.tsx | 30 +++++++++++ .../trusted_apps/view/trusted_apps_page.tsx | 48 ++--------------- .../translations/translations/ja-JP.json | 1 - .../translations/translations/zh-CN.json | 1 - 12 files changed, 151 insertions(+), 67 deletions(-) create mode 100644 x-pack/plugins/security_solution/public/management/components/back_to_external_app_button/back_to_external_app_button.tsx create mode 100644 x-pack/plugins/security_solution/public/management/components/back_to_external_app_button/index.ts diff --git a/x-pack/plugins/security_solution/common/endpoint/types/index.ts b/x-pack/plugins/security_solution/common/endpoint/types/index.ts index e006944eb914f..1e0d798cf7f07 100644 --- a/x-pack/plugins/security_solution/common/endpoint/types/index.ts +++ b/x-pack/plugins/security_solution/common/endpoint/types/index.ts @@ -1114,3 +1114,15 @@ export interface GetExceptionSummaryResponse { macos: number; linux: number; } + +/** + * Supported React-Router state for the Generic List page + */ +export interface ListPageRouteState { + /** Where the user should be redirected to when the `Back` button is clicked */ + onBackButtonNavigateTo: Parameters; + /** The URL for the `Back` button */ + backButtonUrl?: string; + /** The label for the button */ + backButtonLabel?: string; +} diff --git a/x-pack/plugins/security_solution/common/endpoint/types/trusted_apps.ts b/x-pack/plugins/security_solution/common/endpoint/types/trusted_apps.ts index 8d66370fea4d3..94a2e7f236beb 100644 --- a/x-pack/plugins/security_solution/common/endpoint/types/trusted_apps.ts +++ b/x-pack/plugins/security_solution/common/endpoint/types/trusted_apps.ts @@ -6,7 +6,6 @@ */ import { TypeOf } from '@kbn/config-schema'; -import { ApplicationStart } from 'kibana/public'; import { DeleteTrustedAppsRequestSchema, @@ -133,15 +132,3 @@ export type TrustedApp = NewTrustedApp & { updated_at: string; updated_by: string; }; - -/** - * Supported React-Router state for the Trusted Apps List page - */ -export interface TrustedAppsListPageRouteState { - /** Where the user should be redirected to when the `Back` button is clicked */ - onBackButtonNavigateTo: Parameters; - /** The URL for the `Back` button */ - backButtonUrl?: string; - /** The label for the button */ - backButtonLabel?: string; -} diff --git a/x-pack/plugins/security_solution/public/management/components/back_to_external_app_button/back_to_external_app_button.tsx b/x-pack/plugins/security_solution/public/management/components/back_to_external_app_button/back_to_external_app_button.tsx new file mode 100644 index 0000000000000..78c854d933584 --- /dev/null +++ b/x-pack/plugins/security_solution/public/management/components/back_to_external_app_button/back_to_external_app_button.tsx @@ -0,0 +1,52 @@ +/* + * 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, { memo } from 'react'; + +import { FormattedMessage } from '@kbn/i18n/react'; +import { EuiButtonEmpty } from '@elastic/eui'; +import styled from 'styled-components'; + +import { ListPageRouteState } from '../../../../common/endpoint/types'; + +import { useNavigateToAppEventHandler } from '../../../common/hooks/endpoint/use_navigate_to_app_event_handler'; + +const EuiButtonEmptyStyled = styled(EuiButtonEmpty)` + margin-bottom: ${({ theme }) => theme.eui.euiSizeS}; + + .euiIcon { + width: ${({ theme }) => theme.eui.euiIconSizes.small}; + height: ${({ theme }) => theme.eui.euiIconSizes.small}; + } + + .text { + font-size: ${({ theme }) => theme.eui.euiFontSizeXS}; + } +`; + +export const BackToExternalAppButton = memo( + ({ backButtonLabel, backButtonUrl, onBackButtonNavigateTo }) => { + const handleBackOnClick = useNavigateToAppEventHandler(...onBackButtonNavigateTo!); + + return ( + + {backButtonLabel || ( + + )} + + ); + } +); + +BackToExternalAppButton.displayName = 'BackToExternalAppButton'; diff --git a/x-pack/plugins/security_solution/public/management/components/back_to_external_app_button/index.ts b/x-pack/plugins/security_solution/public/management/components/back_to_external_app_button/index.ts new file mode 100644 index 0000000000000..d4a2f8de13546 --- /dev/null +++ b/x-pack/plugins/security_solution/public/management/components/back_to_external_app_button/index.ts @@ -0,0 +1,8 @@ +/* + * 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. + */ + +export { BackToExternalAppButton } from './back_to_external_app_button'; diff --git a/x-pack/plugins/security_solution/public/management/pages/event_filters/view/event_filters_list_page.test.tsx b/x-pack/plugins/security_solution/public/management/pages/event_filters/view/event_filters_list_page.test.tsx index 465f92dfda767..59d409874c561 100644 --- a/x-pack/plugins/security_solution/public/management/pages/event_filters/view/event_filters_list_page.test.tsx +++ b/x-pack/plugins/security_solution/public/management/pages/event_filters/view/event_filters_list_page.test.tsx @@ -175,4 +175,30 @@ describe('When on the Event Filters List Page', () => { }); }); }); + + describe('and the back button is present', () => { + beforeEach(async () => { + renderResult = render(); + act(() => { + history.push('/event_filters', { + onBackButtonNavigateTo: [{ appId: 'appId' }], + backButtonLabel: 'back to fleet', + backButtonUrl: '/fleet', + }); + }); + }); + + it('back button is present', () => { + const button = renderResult.queryByTestId('backToOrigin'); + expect(button).not.toBeNull(); + expect(button).toHaveAttribute('href', '/fleet'); + }); + + it('back button is not present', () => { + act(() => { + history.push('/event_filters'); + }); + expect(renderResult.queryByTestId('backToOrigin')).toBeNull(); + }); + }); }); diff --git a/x-pack/plugins/security_solution/public/management/pages/event_filters/view/event_filters_list_page.tsx b/x-pack/plugins/security_solution/public/management/pages/event_filters/view/event_filters_list_page.tsx index 32fc018210418..00ee80c5d7022 100644 --- a/x-pack/plugins/security_solution/public/management/pages/event_filters/view/event_filters_list_page.tsx +++ b/x-pack/plugins/security_solution/public/management/pages/event_filters/view/event_filters_list_page.tsx @@ -5,10 +5,10 @@ * 2.0. */ -import React, { memo, useCallback, useEffect } from 'react'; +import React, { memo, useCallback, useMemo, useEffect } from 'react'; import { useDispatch } from 'react-redux'; import { Dispatch } from 'redux'; -import { useHistory } from 'react-router-dom'; +import { useHistory, useLocation } from 'react-router-dom'; import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; import { EuiButton, EuiSpacer, EuiHorizontalRule, EuiText } from '@elastic/eui'; @@ -34,7 +34,7 @@ import { showDeleteModal, } from '../store/selector'; import { PaginatedContent, PaginatedContentProps } from '../../../components/paginated_content'; -import { Immutable } from '../../../../../common/endpoint/types'; +import { Immutable, ListPageRouteState } from '../../../../../common/endpoint/types'; import { ExceptionItem, ExceptionItemProps, @@ -42,6 +42,7 @@ import { import { EventFilterDeleteModal } from './components/event_filter_delete_modal'; import { SearchBar } from '../../../components/search_bar'; +import { BackToExternalAppButton } from '../../../components/back_to_external_app_button'; type EventListPaginatedContent = PaginatedContentProps< Immutable, @@ -59,6 +60,7 @@ const AdministrationListPage = styled(_AdministrationListPage)` `; export const EventFiltersListPage = memo(() => { + const { state: routeState } = useLocation(); const history = useHistory(); const dispatch = useDispatch>(); const isActionError = useEventFiltersSelector(getActionError); @@ -103,6 +105,13 @@ export const EventFiltersListPage = memo(() => { } }, [dispatch, formEntry, history, isActionError, location, navigateCallback]); + const backButton = useMemo(() => { + if (routeState && routeState.onBackButtonNavigateTo) { + return ; + } + return null; + }, [routeState]); + const handleAddButtonClick = useCallback( () => navigateCallback({ @@ -173,6 +182,7 @@ export const EventFiltersListPage = memo(() => { return ( ( }; }, [eventFiltersApi, toasts]); - const eventFiltersRouteState = useMemo(() => { + const eventFiltersRouteState = useMemo(() => { const fleetPackageCustomUrlPath = `#${pagePathGetters.integration_details_custom({ pkgkey })}`; return { backButtonLabel: i18n.translate( diff --git a/x-pack/plugins/security_solution/public/management/pages/policy/view/ingest_manager_integration/endpoint_package_custom_extension/components/fleet_trusted_apps_card.tsx b/x-pack/plugins/security_solution/public/management/pages/policy/view/ingest_manager_integration/endpoint_package_custom_extension/components/fleet_trusted_apps_card.tsx index b1464d23e00fb..ed3ba10c1e62b 100644 --- a/x-pack/plugins/security_solution/public/management/pages/policy/view/ingest_manager_integration/endpoint_package_custom_extension/components/fleet_trusted_apps_card.tsx +++ b/x-pack/plugins/security_solution/public/management/pages/policy/view/ingest_manager_integration/endpoint_package_custom_extension/components/fleet_trusted_apps_card.tsx @@ -17,7 +17,7 @@ import { import { useKibana } from '../../../../../../../../../../../src/plugins/kibana_react/public'; import { getTrustedAppsListPath } from '../../../../../../common/routing'; import { - TrustedAppsListPageRouteState, + ListPageRouteState, GetExceptionSummaryResponse, } from '../../../../../../../../common/endpoint/types'; import { PLUGIN_ID as FLEET_PLUGIN_ID } from '../../../../../../../../../fleet/common'; @@ -67,7 +67,7 @@ export const FleetTrustedAppsCard = memo(( }, [toasts, trustedAppsApi]); const trustedAppsListUrlPath = getTrustedAppsListPath(); - const trustedAppRouteState = useMemo(() => { + const trustedAppRouteState = useMemo(() => { const fleetPackageCustomUrlPath = `#${pagePathGetters.integration_details_custom({ pkgkey })}`; return { backButtonLabel: i18n.translate( diff --git a/x-pack/plugins/security_solution/public/management/pages/trusted_apps/view/trusted_apps_page.test.tsx b/x-pack/plugins/security_solution/public/management/pages/trusted_apps/view/trusted_apps_page.test.tsx index fac9fb1e5bf6e..691601b69e3cd 100644 --- a/x-pack/plugins/security_solution/public/management/pages/trusted_apps/view/trusted_apps_page.test.tsx +++ b/x-pack/plugins/security_solution/public/management/pages/trusted_apps/view/trusted_apps_page.test.tsx @@ -900,4 +900,34 @@ describe('When on the Trusted Apps Page', () => { }); }); }); + + describe('and the back button is present', () => { + let renderResult: ReturnType; + beforeEach(async () => { + renderResult = render(); + await act(async () => { + await waitForAction('trustedAppsListResourceStateChanged'); + }); + reactTestingLibrary.act(() => { + history.push('/trusted_apps', { + onBackButtonNavigateTo: [{ appId: 'appId' }], + backButtonLabel: 'back to fleet', + backButtonUrl: '/fleet', + }); + }); + }); + + it('back button is present', () => { + const button = renderResult.queryByTestId('backToOrigin'); + expect(button).not.toBeNull(); + expect(button).toHaveAttribute('href', '/fleet'); + }); + + it('back button is not present', () => { + reactTestingLibrary.act(() => { + history.push('/trusted_apps'); + }); + expect(renderResult.queryByTestId('backToOrigin')).toBeNull(); + }); + }); }); diff --git a/x-pack/plugins/security_solution/public/management/pages/trusted_apps/view/trusted_apps_page.tsx b/x-pack/plugins/security_solution/public/management/pages/trusted_apps/view/trusted_apps_page.tsx index 5603b8e2d61c9..4cd6ad62f3a35 100644 --- a/x-pack/plugins/security_solution/public/management/pages/trusted_apps/view/trusted_apps_page.tsx +++ b/x-pack/plugins/security_solution/public/management/pages/trusted_apps/view/trusted_apps_page.tsx @@ -7,11 +7,9 @@ import React, { memo, useMemo } from 'react'; import { useLocation } from 'react-router-dom'; -import styled from 'styled-components'; import { FormattedMessage } from '@kbn/i18n/react'; import { EuiButton, - EuiButtonEmpty, EuiEmptyPrompt, EuiFlexGroup, EuiFlexItem, @@ -35,14 +33,14 @@ import { TrustedAppsGrid } from './components/trusted_apps_grid'; import { TrustedAppsList } from './components/trusted_apps_list'; import { TrustedAppDeletionDialog } from './trusted_app_deletion_dialog'; import { TrustedAppsNotifications } from './trusted_apps_notifications'; -import { TrustedAppsListPageRouteState } from '../../../../../common/endpoint/types'; -import { useNavigateToAppEventHandler } from '../../../../common/hooks/endpoint/use_navigate_to_app_event_handler'; import { ABOUT_TRUSTED_APPS, SEARCH_TRUSTED_APP_PLACEHOLDER } from './translations'; import { EmptyState } from './components/empty_state'; import { SearchBar } from '../../../components/search_bar'; +import { BackToExternalAppButton } from '../../../components/back_to_external_app_button'; +import { ListPageRouteState } from '../../../../../common/endpoint/types'; export const TrustedAppsPage = memo(() => { - const { state: routeState } = useLocation(); + const { state: routeState } = useLocation(); const location = useTrustedAppsSelector(getCurrentLocation); const totalItemsCount = useTrustedAppsSelector(getListTotalItemsCount); const isCheckingIfEntriesExists = useTrustedAppsSelector(checkingIfEntriesExist); @@ -161,43 +159,3 @@ export const TrustedAppsPage = memo(() => { }); TrustedAppsPage.displayName = 'TrustedAppsPage'; - -const EuiButtonEmptyStyled = styled(EuiButtonEmpty)` - margin-bottom: ${({ theme }) => theme.eui.euiSizeS}; - - .euiIcon { - width: ${({ theme }) => theme.eui.euiIconSizes.small}; - height: ${({ theme }) => theme.eui.euiIconSizes.small}; - } - - .text { - font-size: ${({ theme }) => theme.eui.euiFontSizeXS}; - } -`; - -const BackToExternalAppButton = memo( - ({ backButtonLabel, backButtonUrl, onBackButtonNavigateTo }) => { - const handleBackOnClick = useNavigateToAppEventHandler(...onBackButtonNavigateTo!); - - return ( - - {backButtonLabel || ( - - )} - - ); - } -); - -BackToExternalAppButton.displayName = 'BackToExternalAppButton'; diff --git a/x-pack/plugins/translations/translations/ja-JP.json b/x-pack/plugins/translations/translations/ja-JP.json index 879c666cff672..a909207d7848a 100644 --- a/x-pack/plugins/translations/translations/ja-JP.json +++ b/x-pack/plugins/translations/translations/ja-JP.json @@ -21393,7 +21393,6 @@ "xpack.securitySolution.trustedapps.list.actions.delete": "削除", "xpack.securitySolution.trustedapps.list.actions.delete.description": "このエントリを削除", "xpack.securitySolution.trustedapps.list.addButton": "信頼できるアプリケーションを追加", - "xpack.securitySolution.trustedapps.list.backButton": "戻る", "xpack.securitySolution.trustedapps.list.columns.actions": "アクション", "xpack.securitySolution.trustedapps.list.pageTitle": "信頼できるアプリケーション", "xpack.securitySolution.trustedapps.listEmptyState.message": "現在、エンドポイントには信頼できるアプリケーションがありません。", diff --git a/x-pack/plugins/translations/translations/zh-CN.json b/x-pack/plugins/translations/translations/zh-CN.json index ac1a8d69796a2..b4f27d2677efa 100644 --- a/x-pack/plugins/translations/translations/zh-CN.json +++ b/x-pack/plugins/translations/translations/zh-CN.json @@ -21728,7 +21728,6 @@ "xpack.securitySolution.trustedapps.list.actions.delete": "移除", "xpack.securitySolution.trustedapps.list.actions.delete.description": "移除此条目", "xpack.securitySolution.trustedapps.list.addButton": "添加受信任的应用程序", - "xpack.securitySolution.trustedapps.list.backButton": "返回", "xpack.securitySolution.trustedapps.list.columns.actions": "操作", "xpack.securitySolution.trustedapps.list.pageTitle": "受信任的应用程序", "xpack.securitySolution.trustedapps.list.totalCount": "{totalItemCount, plural, other {# 个受信任的应用程序}}", From d3ce128556319e2d65be4d38c6c8e264e376bafa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B8ren=20Louv-Jansen?= Date: Wed, 9 Jun 2021 12:27:53 +0200 Subject: [PATCH 19/19] [APM] Only register items in side nav if user has permissions to see app (#101707) --- x-pack/plugins/apm/public/plugin.ts | 109 +++++++++--------- .../translations/translations/ja-JP.json | 3 - .../translations/translations/zh-CN.json | 3 - 3 files changed, 54 insertions(+), 61 deletions(-) diff --git a/x-pack/plugins/apm/public/plugin.ts b/x-pack/plugins/apm/public/plugin.ts index 24db9e0cd8504..bfc0a3daf6f0e 100644 --- a/x-pack/plugins/apm/public/plugin.ts +++ b/x-pack/plugins/apm/public/plugin.ts @@ -6,7 +6,8 @@ */ import { i18n } from '@kbn/i18n'; -import { of } from 'rxjs'; +import { from } from 'rxjs'; +import { map } from 'rxjs/operators'; import type { ConfigSchema } from '.'; import { AppMountParameters, @@ -86,19 +87,56 @@ export class ApmPlugin implements Plugin { pluginSetupDeps.home.featureCatalogue.register(featureCatalogueEntry); } - // register observability nav + const servicesTitle = i18n.translate('xpack.apm.navigation.servicesTitle', { + defaultMessage: 'Services', + }); + const tracesTitle = i18n.translate('xpack.apm.navigation.tracesTitle', { + defaultMessage: 'Traces', + }); + const serviceMapTitle = i18n.translate( + 'xpack.apm.navigation.serviceMapTitle', + { defaultMessage: 'Service Map' } + ); + + // register observability nav if user has access to plugin plugins.observability.navigation.registerSections( - of([ - { - label: 'APM', - sortKey: 200, - entries: [ - { label: 'Services', app: 'apm', path: '/services' }, - { label: 'Traces', app: 'apm', path: '/traces' }, - { label: 'Service Map', app: 'apm', path: '/service-map' }, - ], - }, - ]) + from(core.getStartServices()).pipe( + map(([coreStart]) => { + if (coreStart.application.capabilities.apm.show) { + return [ + // APM navigation + { + label: 'APM', + sortKey: 200, + entries: [ + { label: servicesTitle, app: 'apm', path: '/services' }, + { label: tracesTitle, app: 'apm', path: '/traces' }, + { label: serviceMapTitle, app: 'apm', path: '/service-map' }, + ], + }, + + // UX navigation + { + label: 'User Experience', + sortKey: 201, + entries: [ + { + label: i18n.translate('xpack.apm.ux.overview.heading', { + defaultMessage: 'Overview', + }), + app: 'ux', + path: '/', + matchFullPath: true, + ignoreTrailingSlash: true, + }, + ], + }, + ]; + } + + return []; + }) + ) ); const getApmDataHelper = async () => { @@ -150,26 +188,6 @@ export class ApmPlugin implements Plugin { }, }); - plugins.observability.navigation.registerSections( - of([ - { - label: 'User Experience', - sortKey: 201, - entries: [ - { - label: i18n.translate('xpack.apm.ux.overview.heading', { - defaultMessage: 'Overview', - }), - app: 'ux', - path: '/', - matchFullPath: true, - ignoreTrailingSlash: true, - }, - ], - }, - ]) - ); - core.application.register({ id: 'apm', title: 'APM', @@ -178,29 +196,10 @@ export class ApmPlugin implements Plugin { appRoute: '/app/apm', icon: 'plugins/apm/public/icon.svg', category: DEFAULT_APP_CATEGORIES.observability, - // !! Need to be kept in sync with the routes in x-pack/plugins/apm/public/components/app/Main/route_config/index.tsx deepLinks: [ - { - id: 'services', - title: i18n.translate('xpack.apm.breadcrumb.servicesTitle', { - defaultMessage: 'Services', - }), - path: '/services', - }, - { - id: 'traces', - title: i18n.translate('xpack.apm.breadcrumb.tracesTitle', { - defaultMessage: 'Traces', - }), - path: '/traces', - }, - { - id: 'service-map', - title: i18n.translate('xpack.apm.breadcrumb.serviceMapTitle', { - defaultMessage: 'Service Map', - }), - path: '/service-map', - }, + { id: 'services', title: servicesTitle, path: '/services' }, + { id: 'traces', title: tracesTitle, path: '/traces' }, + { id: 'service-map', title: serviceMapTitle, path: '/service-map' }, ], async mount(appMountParameters: AppMountParameters) { diff --git a/x-pack/plugins/translations/translations/ja-JP.json b/x-pack/plugins/translations/translations/ja-JP.json index a909207d7848a..0e4855503c88b 100644 --- a/x-pack/plugins/translations/translations/ja-JP.json +++ b/x-pack/plugins/translations/translations/ja-JP.json @@ -5390,9 +5390,6 @@ "xpack.apm.apply.label": "適用", "xpack.apm.applyFilter": "{title} フィルターを適用", "xpack.apm.applyOptions": "オプションを適用", - "xpack.apm.breadcrumb.serviceMapTitle": "サービスマップ", - "xpack.apm.breadcrumb.servicesTitle": "サービス", - "xpack.apm.breadcrumb.tracesTitle": "トレース", "xpack.apm.chart.annotation.version": "バージョン", "xpack.apm.chart.cpuSeries.processAverageLabel": "プロセス平均", "xpack.apm.chart.cpuSeries.processMaxLabel": "プロセス最大", diff --git a/x-pack/plugins/translations/translations/zh-CN.json b/x-pack/plugins/translations/translations/zh-CN.json index b4f27d2677efa..562fc1b426252 100644 --- a/x-pack/plugins/translations/translations/zh-CN.json +++ b/x-pack/plugins/translations/translations/zh-CN.json @@ -5419,9 +5419,6 @@ "xpack.apm.apply.label": "应用", "xpack.apm.applyFilter": "应用 {title} 筛选", "xpack.apm.applyOptions": "应用选项", - "xpack.apm.breadcrumb.serviceMapTitle": "服务地图", - "xpack.apm.breadcrumb.servicesTitle": "服务", - "xpack.apm.breadcrumb.tracesTitle": "追溯", "xpack.apm.chart.annotation.version": "版本", "xpack.apm.chart.cpuSeries.processAverageLabel": "进程平均值", "xpack.apm.chart.cpuSeries.processMaxLabel": "进程最大值",

New to Kibana?