From 686ade7808624869855cde49af01fa8ab705d876 Mon Sep 17 00:00:00 2001 From: spalger Date: Tue, 8 Jun 2021 14:26:26 -0700 Subject: [PATCH 01/25] 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 02/25] [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 03/25] [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 04/25] [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 05/25] [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 06/25] 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 07/25] [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 08/25] [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 09/25] [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 10/25] [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 11/25] [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 12/25] [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 13/25] 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 14/25] [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 15/25] [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": "进程最大值", From 8b555c7f121abd16f4febdfb3111288aa13152d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B8ren=20Louv-Jansen?= Date: Wed, 9 Jun 2021 13:57:42 +0200 Subject: [PATCH 16/25] [APM] Replace side nav with tabs on Settings page (#101460) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Casper Hübertz --- .../ServicePage/ServicePage.tsx | 23 +-- .../SettingsPage/SettingsPage.tsx | 113 +++++------- .../AgentConfigurationCreateEdit/index.tsx | 16 +- .../Settings/AgentConfigurations/index.tsx | 53 +++--- .../app/Settings/ApmIndices/index.test.tsx | 2 +- .../app/Settings/ApmIndices/index.tsx | 166 ++++++++--------- .../Settings/CustomizeUI/CustomLink/index.tsx | 92 +++++----- .../app/Settings/CustomizeUI/index.tsx | 22 +-- .../anomaly_detection/add_environments.tsx | 23 ++- .../app/Settings/anomaly_detection/index.tsx | 16 -- .../Settings/anomaly_detection/jobs_list.tsx | 48 ++--- .../components/routing/apm_route_config.tsx | 58 +++--- .../routing/templates/apm_main_template.tsx | 1 + .../templates/apm_service_template.tsx | 22 ++- .../templates/settings_template.test.tsx | 21 ++- .../routing/templates/settings_template.tsx | 168 ++++++++++-------- .../translations/translations/ja-JP.json | 9 - .../translations/translations/zh-CN.json | 9 - 18 files changed, 384 insertions(+), 478 deletions(-) diff --git a/x-pack/plugins/apm/public/components/app/Settings/AgentConfigurations/AgentConfigurationCreateEdit/ServicePage/ServicePage.tsx b/x-pack/plugins/apm/public/components/app/Settings/AgentConfigurations/AgentConfigurationCreateEdit/ServicePage/ServicePage.tsx index 71355a84d28d4..d71751805ce41 100644 --- a/x-pack/plugins/apm/public/components/app/Settings/AgentConfigurations/AgentConfigurationCreateEdit/ServicePage/ServicePage.tsx +++ b/x-pack/plugins/apm/public/components/app/Settings/AgentConfigurations/AgentConfigurationCreateEdit/ServicePage/ServicePage.tsx @@ -5,14 +5,7 @@ * 2.0. */ -import { - EuiTitle, - EuiSpacer, - EuiPanel, - EuiFlexGroup, - EuiFlexItem, - EuiButton, -} from '@elastic/eui'; +import { EuiSpacer, EuiFlexGroup, EuiFlexItem, EuiButton } from '@elastic/eui'; import React from 'react'; import { i18n } from '@kbn/i18n'; import { isString } from 'lodash'; @@ -100,17 +93,7 @@ export function ServicePage({ newConfig, setNewConfig, onClickNext }: Props) { ); return ( - - -

- {i18n.translate('xpack.apm.agentConfig.servicePage.title', { - defaultMessage: 'Choose service', - })} -

-
- - - + <> {/* Service name options */}
- + ); } diff --git a/x-pack/plugins/apm/public/components/app/Settings/AgentConfigurations/AgentConfigurationCreateEdit/SettingsPage/SettingsPage.tsx b/x-pack/plugins/apm/public/components/app/Settings/AgentConfigurations/AgentConfigurationCreateEdit/SettingsPage/SettingsPage.tsx index b26779c5fe949..7623e467aaa2d 100644 --- a/x-pack/plugins/apm/public/components/app/Settings/AgentConfigurations/AgentConfigurationCreateEdit/SettingsPage/SettingsPage.tsx +++ b/x-pack/plugins/apm/public/components/app/Settings/AgentConfigurations/AgentConfigurationCreateEdit/SettingsPage/SettingsPage.tsx @@ -15,11 +15,10 @@ import { EuiForm, EuiHealth, EuiLoadingSpinner, - EuiPanel, EuiSpacer, EuiStat, EuiText, - EuiTitle, + EuiHorizontalRule, } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import React, { useMemo, useState } from 'react'; @@ -136,79 +135,55 @@ export function SettingsPage({ }} > {/* Selected Service panel */} - - -

- {i18n.translate('xpack.apm.agentConfig.chooseService.title', { - defaultMessage: 'Choose service', - })} -

-
- - - - - - - - - - - {!isEditMode && ( - - {i18n.translate( - 'xpack.apm.agentConfig.chooseService.editButton', - { defaultMessage: 'Edit' } - )} - + + + + + + - -
+ /> + + + {!isEditMode && ( + + {i18n.translate( + 'xpack.apm.agentConfig.chooseService.editButton', + { defaultMessage: 'Edit' } + )} + + )} + + - + {/* Settings panel */} - - -

- {i18n.translate('xpack.apm.agentConfig.settings.title', { - defaultMessage: 'Configuration options', - })} -

-
- - - {isLoading ? ( -
- -
- ) : ( - renderSettings({ unsavedChanges, newConfig, setNewConfig }) - )} -
+ {isLoading ? ( +
+ +
+ ) : ( + renderSettings({ unsavedChanges, newConfig, setNewConfig }) + )} diff --git a/x-pack/plugins/apm/public/components/app/Settings/AgentConfigurations/AgentConfigurationCreateEdit/index.tsx b/x-pack/plugins/apm/public/components/app/Settings/AgentConfigurations/AgentConfigurationCreateEdit/index.tsx index 07afb2fece283..a0ca7daf82610 100644 --- a/x-pack/plugins/apm/public/components/app/Settings/AgentConfigurations/AgentConfigurationCreateEdit/index.tsx +++ b/x-pack/plugins/apm/public/components/app/Settings/AgentConfigurations/AgentConfigurationCreateEdit/index.tsx @@ -109,7 +109,15 @@ export function AgentConfigurationCreateEdit({ return ( <> - + + {i18n.translate('xpack.apm.agentConfig.newConfig.description', { + defaultMessage: `Fine-tune your agent configuration from within the APM app. Changes are automatically propagated to your APM agents, so there’s no need to redeploy.`, + })} + + + + +

{isEditMode ? i18n.translate('xpack.apm.agentConfig.editConfigTitle', { @@ -121,12 +129,6 @@ export function AgentConfigurationCreateEdit({

- - {i18n.translate('xpack.apm.agentConfig.newConfig.description', { - defaultMessage: `Fine-tune your agent configuration from within the APM app. Changes are automatically propagated to your APM agents, so there’s no need to redeploy.`, - })} - - {pageStep === 'choose-service-step' && ( diff --git a/x-pack/plugins/apm/public/components/app/Settings/AgentConfigurations/index.tsx b/x-pack/plugins/apm/public/components/app/Settings/AgentConfigurations/index.tsx index b781a6569cc35..1ca7f46a0b26f 100644 --- a/x-pack/plugins/apm/public/components/app/Settings/AgentConfigurations/index.tsx +++ b/x-pack/plugins/apm/public/components/app/Settings/AgentConfigurations/index.tsx @@ -10,7 +10,6 @@ import { EuiButton, EuiFlexGroup, EuiFlexItem, - EuiPanel, EuiSpacer, EuiTitle, EuiText, @@ -42,44 +41,36 @@ export function AgentConfigurations() { return ( <> - -

- {i18n.translate('xpack.apm.agentConfig.titleText', { - defaultMessage: 'Agent central configuration', - })} -

-
- {i18n.translate('xpack.apm.settings.agentConfig.descriptionText', { defaultMessage: `Fine-tune your agent configuration from within the APM app. Changes are automatically propagated to your APM agents, so there’s no need to redeploy.`, })} - - - - - -

- {i18n.translate( - 'xpack.apm.agentConfig.configurationsPanelTitle', - { defaultMessage: 'Configurations' } - )} -

-
-
- {hasConfigurations ? : null} -
+ - + + + +

+ {i18n.translate( + 'xpack.apm.agentConfig.configurationsPanelTitle', + { defaultMessage: 'Configurations' } + )} +

+
+
+ + {hasConfigurations ? : null} +
+ + - -
+ ); } diff --git a/x-pack/plugins/apm/public/components/app/Settings/ApmIndices/index.test.tsx b/x-pack/plugins/apm/public/components/app/Settings/ApmIndices/index.test.tsx index 28cb4ebd51cdd..1b19bb5860b2c 100644 --- a/x-pack/plugins/apm/public/components/app/Settings/ApmIndices/index.test.tsx +++ b/x-pack/plugins/apm/public/components/app/Settings/ApmIndices/index.test.tsx @@ -26,7 +26,7 @@ describe('ApmIndices', () => { expect(getByText('Indices')).toMatchInlineSnapshot(`

Indices

diff --git a/x-pack/plugins/apm/public/components/app/Settings/ApmIndices/index.tsx b/x-pack/plugins/apm/public/components/app/Settings/ApmIndices/index.tsx index 44a3c4655417c..2d74187f9d83b 100644 --- a/x-pack/plugins/apm/public/components/app/Settings/ApmIndices/index.tsx +++ b/x-pack/plugins/apm/public/components/app/Settings/ApmIndices/index.tsx @@ -13,7 +13,6 @@ import { EuiFlexItem, EuiForm, EuiFormRow, - EuiPanel, EuiSpacer, EuiText, EuiTitle, @@ -176,100 +175,101 @@ export function ApmIndices() { return ( <> - + + {i18n.translate('xpack.apm.settings.apmIndices.description', { + defaultMessage: `The APM UI uses index patterns to query your APM indices. If you've customized the index names that APM Server writes events to, you may need to update these patterns for the APM UI to work. Settings here take precedence over those set in kibana.yml.`, + })} + + + + +

{i18n.translate('xpack.apm.settings.apmIndices.title', { defaultMessage: 'Indices', })}

- - - {i18n.translate('xpack.apm.settings.apmIndices.description', { - defaultMessage: `The APM UI uses index patterns to query your APM indices. If you've customized the index names that APM Server writes events to, you may need to update these patterns for the APM UI to work. Settings here take precedence over those set in kibana.yml.`, - })} - - - - - - - {APM_INDEX_LABELS.map(({ configurationName, label }) => { - const matchedConfiguration = data.apmIndexSettings.find( - ({ configurationName: configName }) => - configName === configurationName - ); - const defaultValue = matchedConfiguration - ? matchedConfiguration.defaultValue - : ''; - const savedUiIndexValue = apmIndices[configurationName] || ''; - return ( - + + + + + {APM_INDEX_LABELS.map(({ configurationName, label }) => { + const matchedConfiguration = data.apmIndexSettings.find( + ({ configurationName: configName }) => + configName === configurationName + ); + const defaultValue = matchedConfiguration + ? matchedConfiguration.defaultValue + : ''; + const savedUiIndexValue = apmIndices[configurationName] || ''; + return ( + + + + ); + })} + + + + + {i18n.translate( + 'xpack.apm.settings.apmIndices.cancelButton', + { defaultMessage: 'Cancel' } + )} + + + + + - - - ); - })} - - - - {i18n.translate( - 'xpack.apm.settings.apmIndices.cancelButton', - { defaultMessage: 'Cancel' } + 'xpack.apm.settings.apmIndices.applyButton', + { defaultMessage: 'Apply changes' } )} - - - - - - {i18n.translate( - 'xpack.apm.settings.apmIndices.applyButton', - { defaultMessage: 'Apply changes' } - )} - - - - - - - - - + + + + + + + ); } diff --git a/x-pack/plugins/apm/public/components/app/Settings/CustomizeUI/CustomLink/index.tsx b/x-pack/plugins/apm/public/components/app/Settings/CustomizeUI/CustomLink/index.tsx index ab18a31e76917..c1315f165abdb 100644 --- a/x-pack/plugins/apm/public/components/app/Settings/CustomizeUI/CustomLink/index.tsx +++ b/x-pack/plugins/apm/public/components/app/Settings/CustomizeUI/CustomLink/index.tsx @@ -8,7 +8,6 @@ import { EuiFlexGroup, EuiFlexItem, - EuiPanel, EuiTitle, EuiText, EuiSpacer, @@ -83,62 +82,51 @@ export function CustomLinkOverview() { }} /> )} - - - - + + + {i18n.translate('xpack.apm.settings.customizeUI.customLink.info', { + defaultMessage: + 'These links will be shown in the Actions context menu in selected areas of the app, e.g. by the transactions detail.', + })} + + + + + + + +

+ {i18n.translate('xpack.apm.settings.customizeUI.customLink', { + defaultMessage: 'Custom Links', + })} +

+
+
+ {hasValidLicense && !showEmptyPrompt && ( + + - - - -

- {i18n.translate( - 'xpack.apm.settings.customizeUI.customLink', - { - defaultMessage: 'Custom Links', - } - )} -

-
-
-
+
- {hasValidLicense && !showEmptyPrompt && ( - - - - - - - - )} -
- - - {i18n.translate('xpack.apm.settings.customizeUI.customLink.info', { - defaultMessage: - 'These links will be shown in the Actions context menu in selected areas of the app, e.g. by the transactions detail.', - })} - - {hasValidLicense ? ( - showEmptyPrompt ? ( - - ) : ( - - ) - ) : ( - )} -
+ + + + + {hasValidLicense ? ( + showEmptyPrompt ? ( + + ) : ( + + ) + ) : ( + + )} ); } diff --git a/x-pack/plugins/apm/public/components/app/Settings/CustomizeUI/index.tsx b/x-pack/plugins/apm/public/components/app/Settings/CustomizeUI/index.tsx index c4b3c39248ffb..9ce1f1325bb2c 100644 --- a/x-pack/plugins/apm/public/components/app/Settings/CustomizeUI/index.tsx +++ b/x-pack/plugins/apm/public/components/app/Settings/CustomizeUI/index.tsx @@ -6,28 +6,8 @@ */ import React from 'react'; -import { EuiTitle, EuiSpacer, EuiText } from '@elastic/eui'; -import { i18n } from '@kbn/i18n'; import { CustomLinkOverview } from './CustomLink'; export function CustomizeUI() { - return ( - <> - -

- {i18n.translate('xpack.apm.settings.customizeApp.title', { - defaultMessage: 'Customize app', - })} -

-
- - - {i18n.translate('xpack.apm.settings.customizeApp.description', { - defaultMessage: `Extend the APM app experience with the following settings.`, - })} - - - - - ); + return ; } diff --git a/x-pack/plugins/apm/public/components/app/Settings/anomaly_detection/add_environments.tsx b/x-pack/plugins/apm/public/components/app/Settings/anomaly_detection/add_environments.tsx index bf9062418313a..89e5dfcbdadfb 100644 --- a/x-pack/plugins/apm/public/components/app/Settings/anomaly_detection/add_environments.tsx +++ b/x-pack/plugins/apm/public/components/app/Settings/anomaly_detection/add_environments.tsx @@ -7,7 +7,6 @@ import React, { useState } from 'react'; import { - EuiPanel, EuiTitle, EuiText, EuiSpacer, @@ -70,29 +69,27 @@ export function AddEnvironments({ if (!canCreateJob) { return ( - - {ML_ERRORS.MISSING_WRITE_PRIVILEGES}} - /> - + {ML_ERRORS.MISSING_WRITE_PRIVILEGES}} + /> ); } const isLoading = status === FETCH_STATUS.LOADING; return ( - - + <> +

{i18n.translate( 'xpack.apm.settings.anomalyDetection.addEnvironments.titleText', - { - defaultMessage: 'Select environments', - } + { defaultMessage: 'Select environments' } )}

+ + {i18n.translate( 'xpack.apm.settings.anomalyDetection.addEnvironments.descriptionText', @@ -181,6 +178,6 @@ export function AddEnvironments({ -
+ ); } diff --git a/x-pack/plugins/apm/public/components/app/Settings/anomaly_detection/index.tsx b/x-pack/plugins/apm/public/components/app/Settings/anomaly_detection/index.tsx index 38b9970f64d32..57d141d763909 100644 --- a/x-pack/plugins/apm/public/components/app/Settings/anomaly_detection/index.tsx +++ b/x-pack/plugins/apm/public/components/app/Settings/anomaly_detection/index.tsx @@ -6,8 +6,6 @@ */ import React, { useState } from 'react'; -import { EuiTitle, EuiSpacer, EuiText } from '@elastic/eui'; -import { i18n } from '@kbn/i18n'; import { EuiPanel, EuiEmptyPrompt } from '@elastic/eui'; import { ML_ERRORS } from '../../../../../common/anomaly_detection'; import { useApmPluginContext } from '../../../../context/apm_plugin/use_apm_plugin_context'; @@ -66,20 +64,6 @@ export function AnomalyDetection() { return ( <> - -

- {i18n.translate('xpack.apm.settings.anomalyDetection.titleText', { - defaultMessage: 'Anomaly detection', - })} -

-
- - - {i18n.translate('xpack.apm.settings.anomalyDetection.descriptionText', { - defaultMessage: `Machine Learning's anomaly detection integration enables application health status indicators for services in each configured environment by identifying anomalies in latency.`, - })} - - {viewAddEnvironments ? ( environment)} diff --git a/x-pack/plugins/apm/public/components/app/Settings/anomaly_detection/jobs_list.tsx b/x-pack/plugins/apm/public/components/app/Settings/anomaly_detection/jobs_list.tsx index 9c69d692876b0..6df2ed73afe76 100644 --- a/x-pack/plugins/apm/public/components/app/Settings/anomaly_detection/jobs_list.tsx +++ b/x-pack/plugins/apm/public/components/app/Settings/anomaly_detection/jobs_list.tsx @@ -9,7 +9,6 @@ import { EuiButton, EuiFlexGroup, EuiFlexItem, - EuiPanel, EuiSpacer, EuiText, EuiTitle, @@ -66,7 +65,28 @@ export function JobsList({ data, status, onAddEnvironments }: Props) { const { jobs, hasLegacyJobs } = data; return ( - + <> + + + {i18n.translate( + 'xpack.apm.settings.anomalyDetection.jobList.mlDescriptionText.mlJobsLinkText', + { + defaultMessage: 'Machine Learning', + } + )} + + ), + }} + /> + + + + @@ -91,25 +111,9 @@ export function JobsList({ data, status, onAddEnvironments }: Props) { - - - {i18n.translate( - 'xpack.apm.settings.anomalyDetection.jobList.mlDescriptionText.mlJobsLinkText', - { - defaultMessage: 'Machine Learning', - } - )} - - ), - }} - /> - - + + + {hasLegacyJobs && } - + ); } diff --git a/x-pack/plugins/apm/public/components/routing/apm_route_config.tsx b/x-pack/plugins/apm/public/components/routing/apm_route_config.tsx index 09c25ee4557c5..3d530f4614d82 100644 --- a/x-pack/plugins/apm/public/components/routing/apm_route_config.tsx +++ b/x-pack/plugins/apm/public/components/routing/apm_route_config.tsx @@ -219,41 +219,33 @@ function TransactionDetailsRouteView( function SettingsAgentConfigurationRouteView() { return ( - - - - - + + + ); } function SettingsAnomalyDetectionRouteView() { return ( - - - - - + + + ); } function SettingsApmIndicesRouteView() { return ( - - - - - + + + ); } function SettingsCustomizeUI() { return ( - - - - - + + + ); } @@ -276,14 +268,12 @@ export function EditAgentConfigurationRouteView(props: RouteComponentProps) { ); return ( - - - - - + + + ); } @@ -295,13 +285,11 @@ export function CreateAgentConfigurationRouteView(props: RouteComponentProps) { const { pageStep } = toQuery(search); return ( - - - - - + + + ); } diff --git a/x-pack/plugins/apm/public/components/routing/templates/apm_main_template.tsx b/x-pack/plugins/apm/public/components/routing/templates/apm_main_template.tsx index e917350f6024b..357ba4c3d9f38 100644 --- a/x-pack/plugins/apm/public/components/routing/templates/apm_main_template.tsx +++ b/x-pack/plugins/apm/public/components/routing/templates/apm_main_template.tsx @@ -31,6 +31,7 @@ export function ApmMainTemplate({ children: React.ReactNode; } & EuiPageTemplateProps) { const { services } = useKibana(); + const ObservabilityPageTemplate = services.observability.navigation.PageTemplate; diff --git a/x-pack/plugins/apm/public/components/routing/templates/apm_service_template.tsx b/x-pack/plugins/apm/public/components/routing/templates/apm_service_template.tsx index ab53052780ea9..bbaffbd3374c6 100644 --- a/x-pack/plugins/apm/public/components/routing/templates/apm_service_template.tsx +++ b/x-pack/plugins/apm/public/components/routing/templates/apm_service_template.tsx @@ -33,23 +33,21 @@ import { Correlations } from '../../app/correlations'; import { SearchBar } from '../../shared/search_bar'; type Tab = NonNullable[0] & { - key: string; + key: + | 'errors' + | 'metrics' + | 'nodes' + | 'overview' + | 'service-map' + | 'profiling' + | 'transactions'; hidden?: boolean; }; -type TabKey = - | 'errors' - | 'metrics' - | 'nodes' - | 'overview' - | 'service-map' - | 'profiling' - | 'transactions'; - interface Props { children: React.ReactNode; serviceName: string; - selectedTab: TabKey; + selectedTab: Tab['key']; searchBarOptions?: React.ComponentProps; } @@ -107,7 +105,7 @@ function useTabs({ selectedTab, }: { serviceName: string; - selectedTab: TabKey; + selectedTab: Tab['key']; }) { const { agentName, transactionType } = useApmServiceContext(); const { core, config } = useApmPluginContext(); diff --git a/x-pack/plugins/apm/public/components/routing/templates/settings_template.test.tsx b/x-pack/plugins/apm/public/components/routing/templates/settings_template.test.tsx index 36d54525d2537..d3efef4c88380 100644 --- a/x-pack/plugins/apm/public/components/routing/templates/settings_template.test.tsx +++ b/x-pack/plugins/apm/public/components/routing/templates/settings_template.test.tsx @@ -11,13 +11,28 @@ import React, { ReactNode } from 'react'; import { SettingsTemplate } from './settings_template'; import { createMemoryHistory } from 'history'; import { MemoryRouter, RouteComponentProps } from 'react-router-dom'; +import { CoreStart } from 'kibana/public'; +import { createKibanaReactContext } from 'src/plugins/kibana_react/public'; const { location } = createMemoryHistory(); +const KibanaReactContext = createKibanaReactContext({ + usageCollection: { reportUiCounter: () => {} }, + observability: { + navigation: { + PageTemplate: () => { + return <>hello world; + }, + }, + }, +} as Partial); + function Wrapper({ children }: { children?: ReactNode }) { return ( - {children} + + {children} + ); } @@ -29,8 +44,8 @@ describe('Settings', () => { } as unknown) as RouteComponentProps<{}>; expect(() => render( - -
+ +
hello world
, { wrapper: Wrapper } ) diff --git a/x-pack/plugins/apm/public/components/routing/templates/settings_template.tsx b/x-pack/plugins/apm/public/components/routing/templates/settings_template.tsx index 66958c01a7fea..0e610722a76e7 100644 --- a/x-pack/plugins/apm/public/components/routing/templates/settings_template.tsx +++ b/x-pack/plugins/apm/public/components/routing/templates/settings_template.tsx @@ -5,90 +5,108 @@ * 2.0. */ -import { EuiPage, EuiPageBody, EuiPageSideBar, EuiSideNav } from '@elastic/eui'; +import { EuiPageHeaderProps } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; -import React, { ReactNode, useState } from 'react'; +import React from 'react'; +import { History } from 'history'; import { useHistory } from 'react-router-dom'; +import { CoreStart } from 'kibana/public'; +import { ApmMainTemplate } from './apm_main_template'; import { useApmPluginContext } from '../../../context/apm_plugin/use_apm_plugin_context'; import { getAPMHref } from '../../shared/Links/apm/APMLink'; -export function SettingsTemplate({ children }: { children: ReactNode }) { +type Tab = NonNullable[0] & { + key: + | 'agent-configurations' + | 'anomaly-detection' + | 'apm-indices' + | 'customize-ui'; + hidden?: boolean; +}; + +interface Props { + children: React.ReactNode; + selectedTab: Tab['key']; +} + +export function SettingsTemplate({ children, selectedTab }: Props) { const { core } = useApmPluginContext(); const history = useHistory(); - const { basePath } = core.http; - const canAccessML = !!core.application.capabilities.ml?.canAccessML; - const { search, pathname } = history.location; + const tabs = getTabs({ history, core, selectedTab }); - const [isSideNavOpenOnMobile, setisSideNavOpenOnMobile] = useState(false); + return ( + + {children} + + ); +} - const toggleOpenOnMobile = () => { - setisSideNavOpenOnMobile((prevState) => !prevState); - }; +function getTabs({ + history, + core, + selectedTab, +}: { + history: History; + core: CoreStart; + selectedTab: Tab['key']; +}) { + const { basePath } = core.http; + const canAccessML = !!core.application.capabilities.ml?.canAccessML; + const { search } = history.location; - function getSettingsHref(path: string) { - return getAPMHref({ basePath, path: `/settings${path}`, search }); - } + const tabs: Tab[] = [ + { + key: 'agent-configurations', + label: i18n.translate('xpack.apm.settings.agentConfig', { + defaultMessage: 'Agent Configuration', + }), + href: getAPMHref({ + basePath, + path: `/settings/agent-configuration`, + search, + }), + }, + { + key: 'anomaly-detection', + label: i18n.translate('xpack.apm.settings.anomalyDetection', { + defaultMessage: 'Anomaly detection', + }), + href: getAPMHref({ + basePath, + path: `/settings/anomaly-detection`, + search, + }), + hidden: !canAccessML, + }, + { + key: 'customize-ui', + label: i18n.translate('xpack.apm.settings.customizeApp', { + defaultMessage: 'Customize app', + }), + href: getAPMHref({ basePath, path: `/settings/customize-ui`, search }), + }, + { + key: 'apm-indices', + label: i18n.translate('xpack.apm.settings.indices', { + defaultMessage: 'Indices', + }), + href: getAPMHref({ basePath, path: `/settings/apm-indices`, search }), + }, + ]; - return ( - - - toggleOpenOnMobile()} - isOpenOnMobile={isSideNavOpenOnMobile} - items={[ - { - name: i18n.translate('xpack.apm.settings.pageTitle', { - defaultMessage: 'Settings', - }), - id: 0, - items: [ - { - name: i18n.translate('xpack.apm.settings.agentConfig', { - defaultMessage: 'Agent Configuration', - }), - id: '1', - href: getSettingsHref('/agent-configuration'), - isSelected: pathname.startsWith( - '/settings/agent-configuration' - ), - }, - ...(canAccessML - ? [ - { - name: i18n.translate( - 'xpack.apm.settings.anomalyDetection', - { - defaultMessage: 'Anomaly detection', - } - ), - id: '4', - href: getSettingsHref('/anomaly-detection'), - isSelected: pathname === '/settings/anomaly-detection', - }, - ] - : []), - { - name: i18n.translate('xpack.apm.settings.customizeApp', { - defaultMessage: 'Customize app', - }), - id: '3', - href: getSettingsHref('/customize-ui'), - isSelected: pathname === '/settings/customize-ui', - }, - { - name: i18n.translate('xpack.apm.settings.indices', { - defaultMessage: 'Indices', - }), - id: '2', - href: getSettingsHref('/apm-indices'), - isSelected: pathname === '/settings/apm-indices', - }, - ], - }, - ]} - /> - - {children} - - ); + return tabs + .filter((t) => !t.hidden) + .map(({ href, key, label }) => ({ + href, + label, + isSelected: key === selectedTab, + })); } diff --git a/x-pack/plugins/translations/translations/ja-JP.json b/x-pack/plugins/translations/translations/ja-JP.json index 0e4855503c88b..460bbe2255a1e 100644 --- a/x-pack/plugins/translations/translations/ja-JP.json +++ b/x-pack/plugins/translations/translations/ja-JP.json @@ -5245,7 +5245,6 @@ "xpack.apm.agentConfig.chooseService.editButton": "編集", "xpack.apm.agentConfig.chooseService.service.environment.label": "環境", "xpack.apm.agentConfig.chooseService.service.name.label": "サービス名", - "xpack.apm.agentConfig.chooseService.title": "サービスを選択", "xpack.apm.agentConfig.circuitBreakerEnabled.description": "Circuit Breaker を有効にすべきかどうかを指定するブール値。 有効にすると、エージェントは定期的にストレス監視をポーリングして、システム/プロセス/JVMのストレス状態を検出します。監視のいずれかがストレスの兆候を検出した場合、`recording`構成オプションの設定が「false」であるかのようにエージェントは一時停止し、リソース消費を最小限に抑えられます。一時停止した場合、エージェントはストレス状態が緩和されたかどうかを検出するために同じ監視のポーリングを継続します。すべての監視でシステム/プロセス/JVMにストレスがないことが認められると、エージェントは再開して完全に機能します。", "xpack.apm.agentConfig.circuitBreakerEnabled.label": "Cirtcuit Breaker が有効", "xpack.apm.agentConfig.configTable.appliedTooltipMessage": "1 つ以上のエージェントにより適用されました", @@ -5304,8 +5303,6 @@ "xpack.apm.agentConfig.servicePage.service.description": "構成するサービスを選択してください。", "xpack.apm.agentConfig.servicePage.service.fieldLabel": "サービス名", "xpack.apm.agentConfig.servicePage.service.title": "サービス", - "xpack.apm.agentConfig.servicePage.title": "サービスを選択", - "xpack.apm.agentConfig.settings.title": "構成オプション", "xpack.apm.agentConfig.settingsPage.discardChangesButton": "変更を破棄", "xpack.apm.agentConfig.settingsPage.notFound.message": "リクエストされた構成が存在しません", "xpack.apm.agentConfig.settingsPage.notFound.title": "申し訳ございません、エラーが発生しました", @@ -5324,7 +5321,6 @@ "xpack.apm.agentConfig.stressMonitorSystemCpuReliefThreshold.label": "ストレス監視システム CPU 緩和しきい値", "xpack.apm.agentConfig.stressMonitorSystemCpuStressThreshold.description": "システムCPU監視でシステムCPUストレスの検出に使用するしきい値。システムCPUが少なくとも「stress_monitor_cpu_duration_threshold」と同じ長さ以上の期間にわたってこのしきい値を超えると、監視機能はこれをストレス状態と見なします。", "xpack.apm.agentConfig.stressMonitorSystemCpuStressThreshold.label": "ストレス監視システム CPU ストレスしきい値", - "xpack.apm.agentConfig.titleText": "エージェント中央構成", "xpack.apm.agentConfig.transactionIgnoreUrl.description": "特定の URL への要求が命令されないように制限するために使用します。この構成では、無視される URL パスのワイルドカードパターンのカンマ区切りのリストを使用できます。受信 HTTP 要求が検出されると、要求パスが、リストの各要素に対してテストされます。たとえば、このリストに「/home/index」を追加すると、一致して、「http://localhost/home/index」と「http://whatever.com/home/index?value1=123」から命令が削除されます。", "xpack.apm.agentConfig.transactionIgnoreUrl.label": "URL に基づくトランザクションを無視", "xpack.apm.agentConfig.transactionMaxSpans.description": "トランザクションごとに記録される範囲を制限します。", @@ -5782,7 +5778,6 @@ "xpack.apm.settings.anomalyDetection.addEnvironments.selectorLabel": "環境", "xpack.apm.settings.anomalyDetection.addEnvironments.selectorPlaceholder": "環境を選択または追加", "xpack.apm.settings.anomalyDetection.addEnvironments.titleText": "環境を選択", - "xpack.apm.settings.anomalyDetection.descriptionText": "機械学習異常検知統合により、レイテンシの異常を特定することで、各構成された環境で、サービスのアプリケーション正常性ステータスインジケーターが有効になります。", "xpack.apm.settings.anomalyDetection.jobList.actionColumnLabel": "アクション", "xpack.apm.settings.anomalyDetection.jobList.addEnvironments": "MLジョブを作成", "xpack.apm.settings.anomalyDetection.jobList.emptyListText": "異常検知ジョブがありません。", @@ -5792,7 +5787,6 @@ "xpack.apm.settings.anomalyDetection.jobList.mlDescriptionText": "異常検知を新しい環境に追加するには、機械学習ジョブを作成します。既存の機械学習ジョブは、{mlJobsLink}で管理できます。", "xpack.apm.settings.anomalyDetection.jobList.mlDescriptionText.mlJobsLinkText": "機械学習", "xpack.apm.settings.anomalyDetection.jobList.mlJobLinkText": "MLでジョブを表示", - "xpack.apm.settings.anomalyDetection.titleText": "異常検知", "xpack.apm.settings.apmIndices.applyButton": "変更を適用", "xpack.apm.settings.apmIndices.applyChanges.failed.text": "インデックスの適用時に何か問題が発生しました。エラー:{errorMessage}", "xpack.apm.settings.apmIndices.applyChanges.failed.title": "インデックスが適用できませんでした。", @@ -5810,8 +5804,6 @@ "xpack.apm.settings.apmIndices.title": "インデックス", "xpack.apm.settings.apmIndices.transactionIndicesLabel": "トランザクションインデックス", "xpack.apm.settings.customizeApp": "アプリをカスタマイズ", - "xpack.apm.settings.customizeApp.description": "次の設定でAPMアプリ経験を拡張します。", - "xpack.apm.settings.customizeApp.title": "アプリをカスタマイズ", "xpack.apm.settings.customizeUI.customLink": "カスタムリンク", "xpack.apm.settings.customizeUI.customLink.create.failed": "リンクを保存できませんでした!", "xpack.apm.settings.customizeUI.customLink.create.failed.message": "リンクを保存するときに問題が発生しました。エラー:「{errorMessage}」", @@ -5860,7 +5852,6 @@ "xpack.apm.settings.customizeUI.customLink.table.noResultFound": "\"{value}\"に対する結果が見つかりませんでした。", "xpack.apm.settings.customizeUI.customLink.table.url": "URL", "xpack.apm.settings.indices": "インデックス", - "xpack.apm.settings.pageTitle": "設定", "xpack.apm.settingsLinkLabel": "設定", "xpack.apm.setupInstructionsButtonLabel": "セットアップの手順", "xpack.apm.significanTerms.license.text": "相関関係APIを使用するには、Elastic Platinumライセンスのサブスクリプションが必要です。", diff --git a/x-pack/plugins/translations/translations/zh-CN.json b/x-pack/plugins/translations/translations/zh-CN.json index 562fc1b426252..f80ef442cbde0 100644 --- a/x-pack/plugins/translations/translations/zh-CN.json +++ b/x-pack/plugins/translations/translations/zh-CN.json @@ -5274,7 +5274,6 @@ "xpack.apm.agentConfig.chooseService.editButton": "编辑", "xpack.apm.agentConfig.chooseService.service.environment.label": "环境", "xpack.apm.agentConfig.chooseService.service.name.label": "服务名称", - "xpack.apm.agentConfig.chooseService.title": "选择服务", "xpack.apm.agentConfig.circuitBreakerEnabled.description": "指定是否应启用断路器的布尔值。 启用时,代理定期轮询压力监测以检测系统/进程/JVM 压力状态。如果任意监测检测到压力迹象,代理将会暂停,就如 `recording` 配置选项已设置为 `false` 一样,从而使资源消耗降低至最小程度。暂停时,代理继续轮询相同的监测,以便检测压力状态是否已缓解。如果所有监测认为系统/进程/JVM 不再承受压力时,代理将完全恢复正常运行。", "xpack.apm.agentConfig.circuitBreakerEnabled.label": "断路器已启用", "xpack.apm.agentConfig.configTable.appliedTooltipMessage": "已至少由一个代理应用", @@ -5333,8 +5332,6 @@ "xpack.apm.agentConfig.servicePage.service.description": "选择要配置的服务。", "xpack.apm.agentConfig.servicePage.service.fieldLabel": "服务名称", "xpack.apm.agentConfig.servicePage.service.title": "服务", - "xpack.apm.agentConfig.servicePage.title": "选择服务", - "xpack.apm.agentConfig.settings.title": "配置选项", "xpack.apm.agentConfig.settingsPage.discardChangesButton": "放弃更改", "xpack.apm.agentConfig.settingsPage.notFound.message": "请求的配置不存在", "xpack.apm.agentConfig.settingsPage.notFound.title": "抱歉,有错误", @@ -5353,7 +5350,6 @@ "xpack.apm.agentConfig.stressMonitorSystemCpuReliefThreshold.label": "压力监测系统 cpu 缓解阈值", "xpack.apm.agentConfig.stressMonitorSystemCpuStressThreshold.description": "系统 CPU 监测用于检测系统 CPU 压力的阈值。如果系统 CPU 超过此阈值的持续时间至少有 `stress_monitor_cpu_duration_threshold`,监测会将其视为压力状态。", "xpack.apm.agentConfig.stressMonitorSystemCpuStressThreshold.label": "压力监测系统 cpu 压力阈值", - "xpack.apm.agentConfig.titleText": "代理中央配置", "xpack.apm.agentConfig.transactionIgnoreUrl.description": "用于限制对某些 URL 的请求不被检测。此配置接受应忽略的 URL 路径的通配符模式逗号分隔列表。当监测到传入 HTTP 请求时,会根据此列表中的每个元素测试其请求路径。例如,将 `/home/index` 添加到此列表中后,该元素将匹配并删除 `http://localhost/home/index` 和 `http://whatever.com/home/index?value1=123` 的检测", "xpack.apm.agentConfig.transactionIgnoreUrl.label": "基于 URL 忽略事务", "xpack.apm.agentConfig.transactionMaxSpans.description": "限制每个事务记录的跨度数量。", @@ -5816,7 +5812,6 @@ "xpack.apm.settings.anomalyDetection.addEnvironments.selectorLabel": "环境", "xpack.apm.settings.anomalyDetection.addEnvironments.selectorPlaceholder": "选择或添加环境", "xpack.apm.settings.anomalyDetection.addEnvironments.titleText": "选择环境", - "xpack.apm.settings.anomalyDetection.descriptionText": "Machine Learning 异常检测集成通过识别延迟异常来为每个已配置环境中的服务启用应用程序运行状态指标。", "xpack.apm.settings.anomalyDetection.jobList.actionColumnLabel": "操作", "xpack.apm.settings.anomalyDetection.jobList.addEnvironments": "创建 ML 作业", "xpack.apm.settings.anomalyDetection.jobList.emptyListText": "无异常检测作业。", @@ -5826,7 +5821,6 @@ "xpack.apm.settings.anomalyDetection.jobList.mlDescriptionText": "要将异常检测添加到新环境,请创建 Machine Learning 作业。现有 Machine Learning 作业可在 {mlJobsLink} 中进行管理。", "xpack.apm.settings.anomalyDetection.jobList.mlDescriptionText.mlJobsLinkText": "Machine Learning", "xpack.apm.settings.anomalyDetection.jobList.mlJobLinkText": "在 ML 中查看作业", - "xpack.apm.settings.anomalyDetection.titleText": "异常检测", "xpack.apm.settings.apmIndices.applyButton": "应用更改", "xpack.apm.settings.apmIndices.applyChanges.failed.text": "应用索引时出现问题。错误:{errorMessage}", "xpack.apm.settings.apmIndices.applyChanges.failed.title": "无法应用索引。", @@ -5844,8 +5838,6 @@ "xpack.apm.settings.apmIndices.title": "索引", "xpack.apm.settings.apmIndices.transactionIndicesLabel": "事务索引", "xpack.apm.settings.customizeApp": "定制应用", - "xpack.apm.settings.customizeApp.description": "使用以下设置扩展 APM 应用体验。", - "xpack.apm.settings.customizeApp.title": "定制应用", "xpack.apm.settings.customizeUI.customLink": "定制链接", "xpack.apm.settings.customizeUI.customLink.create.failed": "链接无法保存!", "xpack.apm.settings.customizeUI.customLink.create.failed.message": "保存链接时出现了问题。错误:“{errorMessage}”", @@ -5894,7 +5886,6 @@ "xpack.apm.settings.customizeUI.customLink.table.noResultFound": "没有“{value}”的结果。", "xpack.apm.settings.customizeUI.customLink.table.url": "URL", "xpack.apm.settings.indices": "索引", - "xpack.apm.settings.pageTitle": "设置", "xpack.apm.settingsLinkLabel": "设置", "xpack.apm.setupInstructionsButtonLabel": "设置说明", "xpack.apm.significanTerms.license.text": "要使用相关性 API,必须订阅 Elastic 白金级许可证。", From 7604fd7c8034012436161127f8091cf228bbcc63 Mon Sep 17 00:00:00 2001 From: Stacey Gammon Date: Wed, 9 Jun 2021 08:01:48 -0400 Subject: [PATCH 17/25] Improve security server types (#101661) * Remove RecursiveReadonly wrapper on public API items * Remove Pick and export some types that are part of the public API * Udpate api docs * Export API items that are part of the public API * Add extra comments * update api docs --- api_docs/cases.json | 162 ++- api_docs/licensing.json | 2 +- api_docs/security.json | 1054 ++++++++++++----- api_docs/security.mdx | 6 + api_docs/spaces.json | 10 +- x-pack/plugins/security/common/index.ts | 1 + .../authentication_service.mock.ts | 4 +- .../authentication/authentication_service.ts | 19 +- .../security/server/authentication/index.ts | 6 +- .../authorization/authorization_service.tsx | 19 +- .../security/server/authorization/index.ts | 6 +- x-pack/plugins/security/server/index.ts | 2 + x-pack/plugins/security/server/plugin.ts | 42 +- .../server/routes/api_keys/create.test.ts | 4 +- .../server/routes/api_keys/enabled.test.ts | 4 +- .../routes/authentication/common.test.ts | 4 +- .../server/routes/authentication/saml.test.ts | 4 +- .../plugins/security/server/routes/index.ts | 8 +- .../routes/users/change_password.test.ts | 4 +- .../security/server/saved_objects/index.ts | 4 +- .../secure_spaces_client_wrapper.test.ts | 9 +- 21 files changed, 911 insertions(+), 463 deletions(-) diff --git a/api_docs/cases.json b/api_docs/cases.json index 55ec344cb0bcb..bc92995dff6e9 100644 --- a/api_docs/cases.json +++ b/api_docs/cases.json @@ -1035,7 +1035,7 @@ ], "source": { "path": "x-pack/plugins/cases/common/api/runtime_types.ts", - "lineNumber": 53 + "lineNumber": 49 }, "deprecated": false, "children": [ @@ -1051,7 +1051,7 @@ ], "source": { "path": "x-pack/plugins/cases/common/api/runtime_types.ts", - "lineNumber": 53 + "lineNumber": 49 }, "deprecated": false, "isRequired": true @@ -1074,7 +1074,7 @@ ], "source": { "path": "x-pack/plugins/cases/common/api/runtime_types.ts", - "lineNumber": 59 + "lineNumber": 55 }, "deprecated": false, "children": [ @@ -1091,7 +1091,7 @@ ], "source": { "path": "x-pack/plugins/cases/common/api/runtime_types.ts", - "lineNumber": 60 + "lineNumber": 56 }, "deprecated": false, "isRequired": true @@ -1108,7 +1108,7 @@ ], "source": { "path": "x-pack/plugins/cases/common/api/runtime_types.ts", - "lineNumber": 61 + "lineNumber": 57 }, "deprecated": false, "isRequired": true @@ -1129,7 +1129,7 @@ ], "source": { "path": "x-pack/plugins/cases/common/api/runtime_types.ts", - "lineNumber": 75 + "lineNumber": 71 }, "deprecated": false, "children": [ @@ -1145,7 +1145,7 @@ ], "source": { "path": "x-pack/plugins/cases/common/api/runtime_types.ts", - "lineNumber": 76 + "lineNumber": 72 }, "deprecated": false, "isRequired": true @@ -1170,7 +1170,7 @@ ], "source": { "path": "x-pack/plugins/cases/common/api/runtime_types.ts", - "lineNumber": 24 + "lineNumber": 20 }, "deprecated": true, "references": [], @@ -1187,7 +1187,7 @@ ], "source": { "path": "x-pack/plugins/cases/common/api/runtime_types.ts", - "lineNumber": 24 + "lineNumber": 20 }, "deprecated": false, "isRequired": true @@ -1634,62 +1634,6 @@ "returnComment": [], "initialIsOpen": false }, - { - "parentPluginId": "cases", - "id": "def-common.OmitProp", - "type": "Function", - "tags": [], - "label": "OmitProp", - "description": [], - "signature": [ - "(o: O, k: K) => Pick>" - ], - "source": { - "path": "x-pack/plugins/cases/common/api/runtime_types.ts", - "lineNumber": 17 - }, - "deprecated": false, - "children": [ - { - "parentPluginId": "cases", - "id": "def-common.OmitProp.$1", - "type": "Uncategorized", - "tags": [], - "label": "o", - "description": [], - "signature": [ - "O" - ], - "source": { - "path": "x-pack/plugins/cases/common/api/runtime_types.ts", - "lineNumber": 17 - }, - "deprecated": false, - "isRequired": true - }, - { - "parentPluginId": "cases", - "id": "def-common.OmitProp.$2", - "type": "Uncategorized", - "tags": [], - "label": "k", - "description": [], - "signature": [ - "K" - ], - "source": { - "path": "x-pack/plugins/cases/common/api/runtime_types.ts", - "lineNumber": 17 - }, - "deprecated": false, - "isRequired": true - } - ], - "returnComment": [], - "initialIsOpen": false - }, { "parentPluginId": "cases", "id": "def-common.throwErrors", @@ -1704,7 +1648,7 @@ ], "source": { "path": "x-pack/plugins/cases/common/api/runtime_types.ts", - "lineNumber": 55 + "lineNumber": 51 }, "deprecated": false, "children": [ @@ -1720,7 +1664,7 @@ ], "source": { "path": "x-pack/plugins/cases/common/api/runtime_types.ts", - "lineNumber": 55 + "lineNumber": 51 }, "deprecated": false, "isRequired": true @@ -5278,7 +5222,7 @@ "section": "def-common.ConnectorTypes", "text": "ConnectorTypes" }, - ".none; fields: null; }); closure_type: \"close-by-user\" | \"close-by-pushing\"; owner: string; } & { created_at: string; created_by: { email: string | null | undefined; full_name: string | null | undefined; username: string | null | undefined; }; updated_at: string | null; updated_by: { email: string | null | undefined; full_name: string | null | undefined; username: string | null | undefined; } | null; } & { mappings: { action_type: \"append\" | \"overwrite\" | \"nothing\"; source: \"description\" | \"title\" | \"comments\"; target: string; }[]; owner: string; } & { id: string; version: string; error: string | null; owner: string; })[]" + ".none; fields: null; }); closure_type: \"close-by-user\" | \"close-by-pushing\"; } & { owner: string; } & { created_at: string; created_by: { email: string | null | undefined; full_name: string | null | undefined; username: string | null | undefined; }; updated_at: string | null; updated_by: { email: string | null | undefined; full_name: string | null | undefined; username: string | null | undefined; } | null; } & { mappings: { action_type: \"append\" | \"overwrite\" | \"nothing\"; source: \"description\" | \"title\" | \"comments\"; target: string; }[]; owner: string; } & { id: string; version: string; error: string | null; owner: string; })[]" ], "source": { "path": "x-pack/plugins/cases/common/api/cases/configure.ts", @@ -5335,7 +5279,7 @@ "section": "def-common.ConnectorTypes", "text": "ConnectorTypes" }, - ".none; fields: null; }); closure_type: \"close-by-user\" | \"close-by-pushing\"; owner: string; }" + ".none; fields: null; }); closure_type: \"close-by-user\" | \"close-by-pushing\"; } & { owner: string; }" ], "source": { "path": "x-pack/plugins/cases/common/api/cases/configure.ts", @@ -5392,7 +5336,7 @@ "section": "def-common.ConnectorTypes", "text": "ConnectorTypes" }, - ".none; fields: null; }); closure_type: \"close-by-user\" | \"close-by-pushing\"; owner: string; } & { created_at: string; created_by: { email: string | null | undefined; full_name: string | null | undefined; username: string | null | undefined; }; updated_at: string | null; updated_by: { email: string | null | undefined; full_name: string | null | undefined; username: string | null | undefined; } | null; }" + ".none; fields: null; }); closure_type: \"close-by-user\" | \"close-by-pushing\"; } & { owner: string; } & { created_at: string; created_by: { email: string | null | undefined; full_name: string | null | undefined; username: string | null | undefined; }; updated_at: string | null; updated_by: { email: string | null | undefined; full_name: string | null | undefined; username: string | null | undefined; } | null; }" ], "source": { "path": "x-pack/plugins/cases/common/api/cases/configure.ts", @@ -5506,7 +5450,7 @@ "section": "def-common.ConnectorTypes", "text": "ConnectorTypes" }, - ".none; fields: null; }); closure_type: \"close-by-user\" | \"close-by-pushing\"; owner: string; }" + ".none; fields: null; }); closure_type: \"close-by-user\" | \"close-by-pushing\"; } & { owner: string; }" ], "source": { "path": "x-pack/plugins/cases/common/api/cases/configure.ts", @@ -5563,7 +5507,7 @@ "section": "def-common.ConnectorTypes", "text": "ConnectorTypes" }, - ".none; fields: null; }); closure_type: \"close-by-user\" | \"close-by-pushing\"; owner: string; } & { created_at: string; created_by: { email: string | null | undefined; full_name: string | null | undefined; username: string | null | undefined; }; updated_at: string | null; updated_by: { email: string | null | undefined; full_name: string | null | undefined; username: string | null | undefined; } | null; } & { mappings: { action_type: \"append\" | \"overwrite\" | \"nothing\"; source: \"description\" | \"title\" | \"comments\"; target: string; }[]; owner: string; } & { id: string; version: string; error: string | null; owner: string; }" + ".none; fields: null; }); closure_type: \"close-by-user\" | \"close-by-pushing\"; } & { owner: string; } & { created_at: string; created_by: { email: string | null | undefined; full_name: string | null | undefined; username: string | null | undefined; }; updated_at: string | null; updated_by: { email: string | null | undefined; full_name: string | null | undefined; username: string | null | undefined; } | null; } & { mappings: { action_type: \"append\" | \"overwrite\" | \"nothing\"; source: \"description\" | \"title\" | \"comments\"; target: string; }[]; owner: string; } & { id: string; version: string; error: string | null; owner: string; }" ], "source": { "path": "x-pack/plugins/cases/common/api/cases/configure.ts", @@ -7187,7 +7131,7 @@ "section": "def-common.ConnectorTypes", "text": "ConnectorTypes" }, - ".none; fields: null; }); closure_type: \"close-by-user\" | \"close-by-pushing\"; owner: string; } & { created_at: string; created_by: { email: string | null | undefined; full_name: string | null | undefined; username: string | null | undefined; }; updated_at: string | null; updated_by: { email: string | null | undefined; full_name: string | null | undefined; username: string | null | undefined; } | null; }, \"updated_at\" | \"owner\" | \"created_at\" | \"created_by\" | \"updated_by\" | \"closure_type\"> & { connector: ", + ".none; fields: null; }); closure_type: \"close-by-user\" | \"close-by-pushing\"; } & { owner: string; } & { created_at: string; created_by: { email: string | null | undefined; full_name: string | null | undefined; username: string | null | undefined; }; updated_at: string | null; updated_by: { email: string | null | undefined; full_name: string | null | undefined; username: string | null | undefined; } | null; }, \"updated_at\" | \"owner\" | \"created_at\" | \"created_by\" | \"updated_by\" | \"closure_type\"> & { connector: ", { "pluginId": "cases", "scope": "common", @@ -7359,6 +7303,40 @@ "deprecated": false, "initialIsOpen": false }, + { + "parentPluginId": "cases", + "id": "def-common.MAX_CONCURRENT_SEARCHES", + "type": "number", + "tags": [], + "label": "MAX_CONCURRENT_SEARCHES", + "description": [], + "signature": [ + "10" + ], + "source": { + "path": "x-pack/plugins/cases/common/constants.ts", + "lineNumber": 97 + }, + "deprecated": false, + "initialIsOpen": false + }, + { + "parentPluginId": "cases", + "id": "def-common.MAX_DOCS_PER_PAGE", + "type": "number", + "tags": [], + "label": "MAX_DOCS_PER_PAGE", + "description": [], + "signature": [ + "10000" + ], + "source": { + "path": "x-pack/plugins/cases/common/constants.ts", + "lineNumber": 96 + }, + "deprecated": false, + "initialIsOpen": false + }, { "parentPluginId": "cases", "id": "def-common.MAX_GENERATED_ALERTS_PER_SUB_CASE", @@ -9365,6 +9343,8 @@ "<[", "IntersectionC", "<[", + "IntersectionC", + "<[", "TypeC", "<{ connector: ", "IntersectionC", @@ -9572,9 +9552,11 @@ "LiteralC", "<\"close-by-user\">, ", "LiteralC", - "<\"close-by-pushing\">]>; owner: ", + "<\"close-by-pushing\">]>; }>, ", + "TypeC", + "<{ owner: ", "StringC", - "; }>, ", + "; }>]>, ", "TypeC", "<{ created_at: ", "StringC", @@ -9701,6 +9683,8 @@ "label": "CaseConfigureAttributesRt", "description": [], "signature": [ + "IntersectionC", + "<[", "IntersectionC", "<[", "TypeC", @@ -9910,9 +9894,11 @@ "LiteralC", "<\"close-by-user\">, ", "LiteralC", - "<\"close-by-pushing\">]>; owner: ", + "<\"close-by-pushing\">]>; }>, ", + "TypeC", + "<{ owner: ", "StringC", - "; }>, ", + "; }>]>, ", "TypeC", "<{ created_at: ", "StringC", @@ -10019,6 +10005,8 @@ "<[", "IntersectionC", "<[", + "IntersectionC", + "<[", "TypeC", "<{ connector: ", "IntersectionC", @@ -10226,9 +10214,11 @@ "LiteralC", "<\"close-by-user\">, ", "LiteralC", - "<\"close-by-pushing\">]>; owner: ", + "<\"close-by-pushing\">]>; }>, ", + "TypeC", + "<{ owner: ", "StringC", - "; }>, ", + "; }>]>, ", "TypeC", "<{ created_at: ", "StringC", @@ -12728,7 +12718,7 @@ "IntersectionC", "<[", "PartialC", - ", ", "LiteralC", - "<\"close-by-pushing\">]>; owner: ", - "StringC", - "; }, \"connector\" | \"closure_type\">>, ", + "<\"close-by-pushing\">]>; }>, ", "TypeC", "<{ version: ", "StringC", @@ -12957,6 +12945,8 @@ "label": "CasesConfigureRequestRt", "description": [], "signature": [ + "IntersectionC", + "<[", "TypeC", "<{ connector: ", "IntersectionC", @@ -13164,9 +13154,11 @@ "LiteralC", "<\"close-by-user\">, ", "LiteralC", - "<\"close-by-pushing\">]>; owner: ", + "<\"close-by-pushing\">]>; }>, ", + "TypeC", + "<{ owner: ", "StringC", - "; }>" + "; }>]>" ], "source": { "path": "x-pack/plugins/cases/common/api/cases/configure.ts", diff --git a/api_docs/licensing.json b/api_docs/licensing.json index 6959c5fc0e511..862a00e65215f 100644 --- a/api_docs/licensing.json +++ b/api_docs/licensing.json @@ -3074,7 +3074,7 @@ "plugin": "security", "link": { "path": "x-pack/plugins/security/server/plugin.ts", - "lineNumber": 225 + "lineNumber": 229 } }, { diff --git a/api_docs/security.json b/api_docs/security.json index e0fd2a6bb33f2..f7547221cec66 100644 --- a/api_docs/security.json +++ b/api_docs/security.json @@ -14,7 +14,13 @@ "\nRepresents the currently authenticated user." ], "signature": [ - "AuthenticatedUser", + { + "pluginId": "security", + "scope": "common", + "docId": "kibSecurityPluginApi", + "section": "def-common.AuthenticatedUser", + "text": "AuthenticatedUser" + }, " extends ", "User" ], @@ -120,7 +126,13 @@ ], "signature": [ "() => Promise<", - "AuthenticatedUser", + { + "pluginId": "security", + "scope": "common", + "docId": "kibSecurityPluginApi", + "section": "def-common.AuthenticatedUser", + "text": "AuthenticatedUser" + }, ">" ], "source": { @@ -943,6 +955,121 @@ ], "initialIsOpen": false }, + { + "parentPluginId": "security", + "id": "def-server.AuditServiceSetup", + "type": "Interface", + "tags": [], + "label": "AuditServiceSetup", + "description": [], + "source": { + "path": "x-pack/plugins/security/server/audit/audit_service.ts", + "lineNumber": 40 + }, + "deprecated": false, + "children": [ + { + "parentPluginId": "security", + "id": "def-server.AuditServiceSetup.asScoped", + "type": "Function", + "tags": [], + "label": "asScoped", + "description": [], + "signature": [ + "(request: ", + { + "pluginId": "core", + "scope": "server", + "docId": "kibCoreHttpPluginApi", + "section": "def-server.KibanaRequest", + "text": "KibanaRequest" + }, + ") => ", + { + "pluginId": "security", + "scope": "server", + "docId": "kibSecurityPluginApi", + "section": "def-server.AuditLogger", + "text": "AuditLogger" + } + ], + "source": { + "path": "x-pack/plugins/security/server/audit/audit_service.ts", + "lineNumber": 41 + }, + "deprecated": false, + "returnComment": [], + "children": [ + { + "parentPluginId": "security", + "id": "def-server.request", + "type": "Object", + "tags": [], + "label": "request", + "description": [], + "signature": [ + { + "pluginId": "core", + "scope": "server", + "docId": "kibCoreHttpPluginApi", + "section": "def-server.KibanaRequest", + "text": "KibanaRequest" + }, + "" + ], + "source": { + "path": "x-pack/plugins/security/server/audit/audit_service.ts", + "lineNumber": 41 + }, + "deprecated": false + } + ] + }, + { + "parentPluginId": "security", + "id": "def-server.AuditServiceSetup.getLogger", + "type": "Function", + "tags": [], + "label": "getLogger", + "description": [], + "signature": [ + "(id?: string | undefined) => ", + { + "pluginId": "security", + "scope": "server", + "docId": "kibSecurityPluginApi", + "section": "def-server.LegacyAuditLogger", + "text": "LegacyAuditLogger" + } + ], + "source": { + "path": "x-pack/plugins/security/server/audit/audit_service.ts", + "lineNumber": 42 + }, + "deprecated": false, + "returnComment": [], + "children": [ + { + "parentPluginId": "security", + "id": "def-server.id", + "type": "string", + "tags": [], + "label": "id", + "description": [], + "signature": [ + "string | undefined" + ], + "source": { + "path": "x-pack/plugins/security/server/audit/audit_service.ts", + "lineNumber": 42 + }, + "deprecated": false + } + ] + } + ], + "initialIsOpen": false + }, { "parentPluginId": "security", "id": "def-server.AuthenticatedUser", @@ -953,7 +1080,13 @@ "\nRepresents the currently authenticated user." ], "signature": [ - "AuthenticatedUser", + { + "pluginId": "security", + "scope": "common", + "docId": "kibSecurityPluginApi", + "section": "def-common.AuthenticatedUser", + "text": "AuthenticatedUser" + }, " extends ", "User" ], @@ -1035,6 +1168,174 @@ ], "initialIsOpen": false }, + { + "parentPluginId": "security", + "id": "def-server.AuthenticationServiceStart", + "type": "Interface", + "tags": [], + "label": "AuthenticationServiceStart", + "description": [ + "\nAuthentication services available on the security plugin's start contract." + ], + "source": { + "path": "x-pack/plugins/security/server/authentication/authentication_service.ts", + "lineNumber": 72 + }, + "deprecated": false, + "children": [ + { + "parentPluginId": "security", + "id": "def-server.AuthenticationServiceStart.apiKeys", + "type": "Object", + "tags": [], + "label": "apiKeys", + "description": [], + "signature": [ + "{ create: (request: ", + { + "pluginId": "core", + "scope": "server", + "docId": "kibCoreHttpPluginApi", + "section": "def-server.KibanaRequest", + "text": "KibanaRequest" + }, + ", params: ", + "CreateAPIKeyParams", + ") => Promise<", + { + "pluginId": "security", + "scope": "server", + "docId": "kibSecurityPluginApi", + "section": "def-server.CreateAPIKeyResult", + "text": "CreateAPIKeyResult" + }, + " | null>; areAPIKeysEnabled: () => Promise; invalidate: (request: ", + { + "pluginId": "core", + "scope": "server", + "docId": "kibCoreHttpPluginApi", + "section": "def-server.KibanaRequest", + "text": "KibanaRequest" + }, + ", params: ", + { + "pluginId": "security", + "scope": "server", + "docId": "kibSecurityPluginApi", + "section": "def-server.InvalidateAPIKeysParams", + "text": "InvalidateAPIKeysParams" + }, + ") => Promise<", + { + "pluginId": "security", + "scope": "server", + "docId": "kibSecurityPluginApi", + "section": "def-server.InvalidateAPIKeyResult", + "text": "InvalidateAPIKeyResult" + }, + " | null>; grantAsInternalUser: (request: ", + { + "pluginId": "core", + "scope": "server", + "docId": "kibCoreHttpPluginApi", + "section": "def-server.KibanaRequest", + "text": "KibanaRequest" + }, + ", createParams: ", + "CreateAPIKeyParams", + ") => Promise<", + { + "pluginId": "security", + "scope": "server", + "docId": "kibSecurityPluginApi", + "section": "def-server.GrantAPIKeyResult", + "text": "GrantAPIKeyResult" + }, + " | null>; invalidateAsInternalUser: (params: ", + { + "pluginId": "security", + "scope": "server", + "docId": "kibSecurityPluginApi", + "section": "def-server.InvalidateAPIKeysParams", + "text": "InvalidateAPIKeysParams" + }, + ") => Promise<", + { + "pluginId": "security", + "scope": "server", + "docId": "kibSecurityPluginApi", + "section": "def-server.InvalidateAPIKeyResult", + "text": "InvalidateAPIKeyResult" + }, + " | null>; }" + ], + "source": { + "path": "x-pack/plugins/security/server/authentication/authentication_service.ts", + "lineNumber": 73 + }, + "deprecated": false + }, + { + "parentPluginId": "security", + "id": "def-server.AuthenticationServiceStart.getCurrentUser", + "type": "Function", + "tags": [], + "label": "getCurrentUser", + "description": [], + "signature": [ + "(request: ", + { + "pluginId": "core", + "scope": "server", + "docId": "kibCoreHttpPluginApi", + "section": "def-server.KibanaRequest", + "text": "KibanaRequest" + }, + ") => ", + { + "pluginId": "security", + "scope": "common", + "docId": "kibSecurityPluginApi", + "section": "def-common.AuthenticatedUser", + "text": "AuthenticatedUser" + }, + " | null" + ], + "source": { + "path": "x-pack/plugins/security/server/authentication/authentication_service.ts", + "lineNumber": 81 + }, + "deprecated": false, + "returnComment": [], + "children": [ + { + "parentPluginId": "security", + "id": "def-server.request", + "type": "Object", + "tags": [], + "label": "request", + "description": [], + "signature": [ + { + "pluginId": "core", + "scope": "server", + "docId": "kibCoreHttpPluginApi", + "section": "def-server.KibanaRequest", + "text": "KibanaRequest" + }, + "" + ], + "source": { + "path": "x-pack/plugins/security/server/authentication/authentication_service.ts", + "lineNumber": 81 + }, + "deprecated": false + } + ] + } + ], + "initialIsOpen": false + }, { "parentPluginId": "security", "id": "def-server.CheckPrivilegesPayload", @@ -1496,385 +1797,484 @@ } ], "initialIsOpen": false + } + ], + "enums": [], + "misc": [ + { + "parentPluginId": "security", + "id": "def-server.AuthorizationServiceSetup", + "type": "Type", + "tags": [], + "label": "AuthorizationServiceSetup", + "description": [], + "source": { + "path": "x-pack/plugins/security/server/index.ts", + "lineNumber": 31 + }, + "deprecated": false, + "initialIsOpen": false }, { "parentPluginId": "security", - "id": "def-server.SecurityPluginSetup", - "type": "Interface", + "id": "def-server.ROUTE_TAG_CAN_REDIRECT", + "type": "string", "tags": [], - "label": "SecurityPluginSetup", + "label": "ROUTE_TAG_CAN_REDIRECT", "description": [ - "\nDescribes public Security plugin contract returned at the `setup` stage." + "\nIf the route is marked with this tag Security can safely assume that the calling party that sends\nrequest to this route can handle redirect responses. It's particularly important if we want the\nspecific route to be able to initiate or participate in the authentication handshake that may\ninvolve redirects and will eventually redirect authenticated user to this route." + ], + "signature": [ + "\"security:canRedirect\"" ], "source": { - "path": "x-pack/plugins/security/server/plugin.ts", - "lineNumber": 69 + "path": "x-pack/plugins/security/server/routes/tags.ts", + "lineNumber": 21 }, "deprecated": false, - "children": [ - { - "parentPluginId": "security", - "id": "def-server.SecurityPluginSetup.authc", - "type": "Object", - "tags": [ - "deprecated" - ], - "label": "authc", - "description": [], - "signature": [ - "{ getCurrentUser: (request: ", - { - "pluginId": "core", - "scope": "server", - "docId": "kibCoreHttpPluginApi", - "section": "def-server.KibanaRequest", - "text": "KibanaRequest" - }, - ") => ", - "AuthenticatedUser", - " | null; }" - ], - "source": { - "path": "x-pack/plugins/security/server/plugin.ts", - "lineNumber": 73 + "initialIsOpen": false + } + ], + "objects": [], + "setup": { + "parentPluginId": "security", + "id": "def-server.SecurityPluginSetup", + "type": "Interface", + "tags": [], + "label": "SecurityPluginSetup", + "description": [ + "\nDescribes public Security plugin contract returned at the `setup` stage." + ], + "source": { + "path": "x-pack/plugins/security/server/plugin.ts", + "lineNumber": 72 + }, + "deprecated": false, + "children": [ + { + "parentPluginId": "security", + "id": "def-server.SecurityPluginSetup.authc", + "type": "Object", + "tags": [ + "deprecated" + ], + "label": "authc", + "description": [], + "signature": [ + "{ getCurrentUser: (request: ", + { + "pluginId": "core", + "scope": "server", + "docId": "kibCoreHttpPluginApi", + "section": "def-server.KibanaRequest", + "text": "KibanaRequest" }, - "deprecated": true, - "references": [ - { - "plugin": "reporting", - "link": { - "path": "x-pack/plugins/reporting/server/routes/lib/get_user.ts", - "lineNumber": 13 - } - }, - { - "plugin": "encryptedSavedObjects", - "link": { - "path": "x-pack/plugins/encrypted_saved_objects/server/crypto/encryption_key_rotation_service.ts", - "lineNumber": 107 - } - }, - { - "plugin": "encryptedSavedObjects", - "link": { - "path": "x-pack/plugins/encrypted_saved_objects/server/saved_objects/index.ts", - "lineNumber": 67 - } - }, - { - "plugin": "actions", - "link": { - "path": "x-pack/plugins/actions/server/plugin.ts", - "lineNumber": 444 - } - }, - { - "plugin": "ml", - "link": { - "path": "x-pack/plugins/ml/server/routes/annotations.ts", - "lineNumber": 105 - } - }, - { - "plugin": "dashboardMode", - "link": { - "path": "x-pack/plugins/dashboard_mode/server/interceptors/dashboard_mode_request_interceptor.ts", - "lineNumber": 33 - } - }, - { - "plugin": "dataEnhanced", - "link": { - "path": "x-pack/plugins/data_enhanced/server/search/session/session_service.ts", - "lineNumber": 448 - } - }, - { - "plugin": "logstash", - "link": { - "path": "x-pack/plugins/logstash/server/routes/pipeline/save.ts", - "lineNumber": 41 - } - }, - { - "plugin": "securitySolution", - "link": { - "path": "x-pack/plugins/security_solution/server/lib/detection_engine/routes/signals/create_signals_migration_route.ts", - "lineNumber": 48 - } - }, - { - "plugin": "securitySolution", - "link": { - "path": "x-pack/plugins/security_solution/server/lib/detection_engine/routes/signals/delete_signals_migration_route.ts", - "lineNumber": 45 - } - }, - { - "plugin": "securitySolution", - "link": { - "path": "x-pack/plugins/security_solution/server/lib/detection_engine/routes/signals/finalize_signals_migration_route.ts", - "lineNumber": 45 - } - }, - { - "plugin": "securitySolution", - "link": { - "path": "x-pack/plugins/security_solution/server/lib/timeline/utils/common.ts", - "lineNumber": 28 - } + ") => ", + { + "pluginId": "security", + "scope": "common", + "docId": "kibSecurityPluginApi", + "section": "def-common.AuthenticatedUser", + "text": "AuthenticatedUser" + }, + " | null; }" + ], + "source": { + "path": "x-pack/plugins/security/server/plugin.ts", + "lineNumber": 76 + }, + "deprecated": true, + "references": [ + { + "plugin": "reporting", + "link": { + "path": "x-pack/plugins/reporting/server/routes/lib/get_user.ts", + "lineNumber": 13 } - ] + }, + { + "plugin": "encryptedSavedObjects", + "link": { + "path": "x-pack/plugins/encrypted_saved_objects/server/crypto/encryption_key_rotation_service.ts", + "lineNumber": 107 + } + }, + { + "plugin": "encryptedSavedObjects", + "link": { + "path": "x-pack/plugins/encrypted_saved_objects/server/saved_objects/index.ts", + "lineNumber": 67 + } + }, + { + "plugin": "actions", + "link": { + "path": "x-pack/plugins/actions/server/plugin.ts", + "lineNumber": 444 + } + }, + { + "plugin": "ml", + "link": { + "path": "x-pack/plugins/ml/server/routes/annotations.ts", + "lineNumber": 105 + } + }, + { + "plugin": "dashboardMode", + "link": { + "path": "x-pack/plugins/dashboard_mode/server/interceptors/dashboard_mode_request_interceptor.ts", + "lineNumber": 33 + } + }, + { + "plugin": "dataEnhanced", + "link": { + "path": "x-pack/plugins/data_enhanced/server/search/session/session_service.ts", + "lineNumber": 448 + } + }, + { + "plugin": "logstash", + "link": { + "path": "x-pack/plugins/logstash/server/routes/pipeline/save.ts", + "lineNumber": 41 + } + }, + { + "plugin": "securitySolution", + "link": { + "path": "x-pack/plugins/security_solution/server/lib/detection_engine/routes/signals/create_signals_migration_route.ts", + "lineNumber": 48 + } + }, + { + "plugin": "securitySolution", + "link": { + "path": "x-pack/plugins/security_solution/server/lib/detection_engine/routes/signals/delete_signals_migration_route.ts", + "lineNumber": 45 + } + }, + { + "plugin": "securitySolution", + "link": { + "path": "x-pack/plugins/security_solution/server/lib/detection_engine/routes/signals/finalize_signals_migration_route.ts", + "lineNumber": 45 + } + }, + { + "plugin": "securitySolution", + "link": { + "path": "x-pack/plugins/security_solution/server/lib/timeline/utils/common.ts", + "lineNumber": 28 + } + } + ] + }, + { + "parentPluginId": "security", + "id": "def-server.SecurityPluginSetup.authz", + "type": "Object", + "tags": [ + "deprecated" + ], + "label": "authz", + "description": [], + "signature": [ + { + "pluginId": "security", + "scope": "server", + "docId": "kibSecurityPluginApi", + "section": "def-server.AuthorizationServiceSetup", + "text": "AuthorizationServiceSetup" + } + ], + "source": { + "path": "x-pack/plugins/security/server/plugin.ts", + "lineNumber": 80 }, - { - "parentPluginId": "security", - "id": "def-server.SecurityPluginSetup.authz", - "type": "Object", - "tags": [ - "deprecated" - ], - "label": "authz", - "description": [], - "signature": [ - "{ mode: ", - "AuthorizationMode", - "; actions: ", - "Actions", - "; checkPrivilegesDynamicallyWithRequest: ", - "CheckPrivilegesDynamicallyWithRequest", - "; checkPrivilegesWithRequest: ", - "CheckPrivilegesWithRequest", - "; }" - ], - "source": { - "path": "x-pack/plugins/security/server/plugin.ts", - "lineNumber": 77 + "deprecated": true, + "references": [ + { + "plugin": "actions", + "link": { + "path": "x-pack/plugins/actions/server/plugin.ts", + "lineNumber": 443 + } }, - "deprecated": true, - "references": [ - { - "plugin": "actions", - "link": { - "path": "x-pack/plugins/actions/server/plugin.ts", - "lineNumber": 443 - } - }, - { - "plugin": "ml", - "link": { - "path": "x-pack/plugins/ml/server/saved_objects/initialization/initialization.ts", - "lineNumber": 54 - } - }, - { - "plugin": "ml", - "link": { - "path": "x-pack/plugins/ml/server/plugin.ts", - "lineNumber": 153 - } - }, - { - "plugin": "ml", - "link": { - "path": "x-pack/plugins/ml/server/plugin.ts", - "lineNumber": 203 - } - }, - { - "plugin": "enterpriseSearch", - "link": { - "path": "x-pack/plugins/enterprise_search/server/lib/check_access.ts", - "lineNumber": 46 - } - }, - { - "plugin": "enterpriseSearch", - "link": { - "path": "x-pack/plugins/enterprise_search/server/lib/check_access.ts", - "lineNumber": 86 - } - }, - { - "plugin": "enterpriseSearch", - "link": { - "path": "x-pack/plugins/enterprise_search/server/lib/check_access.ts", - "lineNumber": 88 - } - }, - { - "plugin": "savedObjectsTagging", - "link": { - "path": "x-pack/plugins/saved_objects_tagging/server/request_handler_context.ts", - "lineNumber": 37 - } + { + "plugin": "ml", + "link": { + "path": "x-pack/plugins/ml/server/saved_objects/initialization/initialization.ts", + "lineNumber": 54 } - ] + }, + { + "plugin": "ml", + "link": { + "path": "x-pack/plugins/ml/server/plugin.ts", + "lineNumber": 153 + } + }, + { + "plugin": "ml", + "link": { + "path": "x-pack/plugins/ml/server/plugin.ts", + "lineNumber": 203 + } + }, + { + "plugin": "enterpriseSearch", + "link": { + "path": "x-pack/plugins/enterprise_search/server/lib/check_access.ts", + "lineNumber": 46 + } + }, + { + "plugin": "enterpriseSearch", + "link": { + "path": "x-pack/plugins/enterprise_search/server/lib/check_access.ts", + "lineNumber": 86 + } + }, + { + "plugin": "enterpriseSearch", + "link": { + "path": "x-pack/plugins/enterprise_search/server/lib/check_access.ts", + "lineNumber": 88 + } + }, + { + "plugin": "savedObjectsTagging", + "link": { + "path": "x-pack/plugins/saved_objects_tagging/server/request_handler_context.ts", + "lineNumber": 37 + } + } + ] + }, + { + "parentPluginId": "security", + "id": "def-server.SecurityPluginSetup.license", + "type": "Object", + "tags": [], + "label": "license", + "description": [ + "\nExposes information about the available security features under the current license." + ], + "signature": [ + { + "pluginId": "security", + "scope": "common", + "docId": "kibSecurityPluginApi", + "section": "def-common.SecurityLicense", + "text": "SecurityLicense" + } + ], + "source": { + "path": "x-pack/plugins/security/server/plugin.ts", + "lineNumber": 84 }, + "deprecated": false + }, + { + "parentPluginId": "security", + "id": "def-server.SecurityPluginSetup.audit", + "type": "Object", + "tags": [], + "label": "audit", + "description": [ + "\nExposes services for audit logging." + ], + "signature": [ + { + "pluginId": "security", + "scope": "server", + "docId": "kibSecurityPluginApi", + "section": "def-server.AuditServiceSetup", + "text": "AuditServiceSetup" + } + ], + "source": { + "path": "x-pack/plugins/security/server/plugin.ts", + "lineNumber": 88 + }, + "deprecated": false + } + ], + "lifecycle": "setup", + "initialIsOpen": true + }, + "start": { + "parentPluginId": "security", + "id": "def-server.SecurityPluginStart", + "type": "Interface", + "tags": [], + "label": "SecurityPluginStart", + "description": [ + "\nDescribes public Security plugin contract returned at the `start` stage." + ], + "source": { + "path": "x-pack/plugins/security/server/plugin.ts", + "lineNumber": 94 + }, + "deprecated": false, + "children": [ + { + "parentPluginId": "security", + "id": "def-server.SecurityPluginStart.authc", + "type": "Object", + "tags": [], + "label": "authc", + "description": [ + "\nAuthentication services to confirm the user is who they say they are." + ], + "signature": [ + { + "pluginId": "security", + "scope": "server", + "docId": "kibSecurityPluginApi", + "section": "def-server.AuthenticationServiceStart", + "text": "AuthenticationServiceStart" + } + ], + "source": { + "path": "x-pack/plugins/security/server/plugin.ts", + "lineNumber": 98 + }, + "deprecated": false + }, + { + "parentPluginId": "security", + "id": "def-server.SecurityPluginStart.authz", + "type": "Object", + "tags": [], + "label": "authz", + "description": [ + "\nAuthorization services to manage and access the permissions a particular user has." + ], + "signature": [ + { + "pluginId": "security", + "scope": "server", + "docId": "kibSecurityPluginApi", + "section": "def-server.AuthorizationServiceSetup", + "text": "AuthorizationServiceSetup" + } + ], + "source": { + "path": "x-pack/plugins/security/server/plugin.ts", + "lineNumber": 102 + }, + "deprecated": false + } + ], + "lifecycle": "start", + "initialIsOpen": true + } + }, + "common": { + "classes": [], + "functions": [], + "interfaces": [ + { + "parentPluginId": "security", + "id": "def-common.AuthenticatedUser", + "type": "Interface", + "tags": [], + "label": "AuthenticatedUser", + "description": [ + "\nRepresents the currently authenticated user." + ], + "signature": [ + { + "pluginId": "security", + "scope": "common", + "docId": "kibSecurityPluginApi", + "section": "def-common.AuthenticatedUser", + "text": "AuthenticatedUser" + }, + " extends ", + "User" + ], + "source": { + "path": "x-pack/plugins/security/common/model/authenticated_user.ts", + "lineNumber": 21 + }, + "deprecated": false, + "children": [ { "parentPluginId": "security", - "id": "def-server.SecurityPluginSetup.license", + "id": "def-common.AuthenticatedUser.authentication_realm", "type": "Object", "tags": [], - "label": "license", - "description": [], + "label": "authentication_realm", + "description": [ + "\nThe name and type of the Realm that has authenticated the user." + ], "signature": [ - { - "pluginId": "security", - "scope": "common", - "docId": "kibSecurityPluginApi", - "section": "def-common.SecurityLicense", - "text": "SecurityLicense" - } + "UserRealm" ], "source": { - "path": "x-pack/plugins/security/server/plugin.ts", - "lineNumber": 81 + "path": "x-pack/plugins/security/common/model/authenticated_user.ts", + "lineNumber": 25 }, "deprecated": false }, { "parentPluginId": "security", - "id": "def-server.SecurityPluginSetup.audit", + "id": "def-common.AuthenticatedUser.lookup_realm", "type": "Object", "tags": [], - "label": "audit", - "description": [], + "label": "lookup_realm", + "description": [ + "\nThe name and type of the Realm where the user information were retrieved from." + ], "signature": [ - "AuditServiceSetup" + "UserRealm" ], "source": { - "path": "x-pack/plugins/security/server/plugin.ts", - "lineNumber": 82 + "path": "x-pack/plugins/security/common/model/authenticated_user.ts", + "lineNumber": 30 }, "deprecated": false - } - ], - "initialIsOpen": false - }, - { - "parentPluginId": "security", - "id": "def-server.SecurityPluginStart", - "type": "Interface", - "tags": [], - "label": "SecurityPluginStart", - "description": [ - "\nDescribes public Security plugin contract returned at the `start` stage." - ], - "source": { - "path": "x-pack/plugins/security/server/plugin.ts", - "lineNumber": 88 - }, - "deprecated": false, - "children": [ + }, { "parentPluginId": "security", - "id": "def-server.SecurityPluginStart.authc", + "id": "def-common.AuthenticatedUser.authentication_provider", "type": "Object", "tags": [], - "label": "authc", - "description": [], + "label": "authentication_provider", + "description": [ + "\nThe authentication provider that used to authenticate user." + ], "signature": [ - "{ getCurrentUser: (request: ", - { - "pluginId": "core", - "scope": "server", - "docId": "kibCoreHttpPluginApi", - "section": "def-server.KibanaRequest", - "text": "KibanaRequest" - }, - ") => ", - "AuthenticatedUser", - " | null; apiKeys: Pick<", - "APIKeys", - ", \"create\" | \"areAPIKeysEnabled\" | \"invalidate\" | \"grantAsInternalUser\" | \"invalidateAsInternalUser\">; }" + "AuthenticationProvider" ], "source": { - "path": "x-pack/plugins/security/server/plugin.ts", - "lineNumber": 89 + "path": "x-pack/plugins/security/common/model/authenticated_user.ts", + "lineNumber": 35 }, "deprecated": false }, { "parentPluginId": "security", - "id": "def-server.SecurityPluginStart.authz", - "type": "Object", + "id": "def-common.AuthenticatedUser.authentication_type", + "type": "string", "tags": [], - "label": "authz", - "description": [], - "signature": [ - "{ mode: ", - "AuthorizationMode", - "; actions: ", - "Actions", - "; checkPrivilegesDynamicallyWithRequest: ", - "CheckPrivilegesDynamicallyWithRequest", - "; checkPrivilegesWithRequest: ", - "CheckPrivilegesWithRequest", - "; }" + "label": "authentication_type", + "description": [ + "\nThe AuthenticationType used by ES to authenticate the user.\n" ], "source": { - "path": "x-pack/plugins/security/server/plugin.ts", - "lineNumber": 90 + "path": "x-pack/plugins/security/common/model/authenticated_user.ts", + "lineNumber": 42 }, "deprecated": false } ], "initialIsOpen": false - } - ], - "enums": [], - "misc": [ - { - "parentPluginId": "security", - "id": "def-server.AuthorizationServiceSetup", - "type": "Type", - "tags": [], - "label": "AuthorizationServiceSetup", - "description": [], - "signature": [ - "{ mode: ", - "AuthorizationMode", - "; actions: ", - "Actions", - "; checkPrivilegesDynamicallyWithRequest: ", - "CheckPrivilegesDynamicallyWithRequest", - "; checkPrivilegesWithRequest: ", - "CheckPrivilegesWithRequest", - "; }" - ], - "source": { - "path": "x-pack/plugins/security/server/index.ts", - "lineNumber": 30 - }, - "deprecated": false, - "initialIsOpen": false }, - { - "parentPluginId": "security", - "id": "def-server.ROUTE_TAG_CAN_REDIRECT", - "type": "string", - "tags": [], - "label": "ROUTE_TAG_CAN_REDIRECT", - "description": [ - "\nIf the route is marked with this tag Security can safely assume that the calling party that sends\nrequest to this route can handle redirect responses. It's particularly important if we want the\nspecific route to be able to initiate or participate in the authentication handshake that may\ninvolve redirects and will eventually redirect authenticated user to this route." - ], - "signature": [ - "\"security:canRedirect\"" - ], - "source": { - "path": "x-pack/plugins/security/server/routes/tags.ts", - "lineNumber": 21 - }, - "deprecated": false, - "initialIsOpen": false - } - ], - "objects": [] - }, - "common": { - "classes": [], - "functions": [], - "interfaces": [ { "parentPluginId": "security", "id": "def-common.SecurityLicense", diff --git a/api_docs/security.mdx b/api_docs/security.mdx index 07f219ce6e771..250ceff429207 100644 --- a/api_docs/security.mdx +++ b/api_docs/security.mdx @@ -27,6 +27,12 @@ import securityObj from './security.json'; ## Server +### Setup + + +### Start + + ### Interfaces diff --git a/api_docs/spaces.json b/api_docs/spaces.json index d24b3884ffac6..002145f3b48db 100644 --- a/api_docs/spaces.json +++ b/api_docs/spaces.json @@ -1203,7 +1203,7 @@ "plugin": "security", "link": { "path": "x-pack/plugins/security/server/plugin.ts", - "lineNumber": 263 + "lineNumber": 267 } }, { @@ -2002,28 +2002,28 @@ "plugin": "security", "link": { "path": "x-pack/plugins/security/server/plugin.ts", - "lineNumber": 57 + "lineNumber": 60 } }, { "plugin": "security", "link": { "path": "x-pack/plugins/security/server/plugin.ts", - "lineNumber": 263 + "lineNumber": 267 } }, { "plugin": "security", "link": { "path": "x-pack/plugins/security/server/plugin.ts", - "lineNumber": 281 + "lineNumber": 285 } }, { "plugin": "security", "link": { "path": "x-pack/plugins/security/server/plugin.ts", - "lineNumber": 297 + "lineNumber": 301 } }, { diff --git a/x-pack/plugins/security/common/index.ts b/x-pack/plugins/security/common/index.ts index 8b99ac3c5761b..034c25758a1f0 100644 --- a/x-pack/plugins/security/common/index.ts +++ b/x-pack/plugins/security/common/index.ts @@ -6,3 +6,4 @@ */ export { SecurityLicense } from './licensing'; +export { AuthenticatedUser } from './model'; diff --git a/x-pack/plugins/security/server/authentication/authentication_service.mock.ts b/x-pack/plugins/security/server/authentication/authentication_service.mock.ts index ba3297aeb5493..ba73d3b196d2f 100644 --- a/x-pack/plugins/security/server/authentication/authentication_service.mock.ts +++ b/x-pack/plugins/security/server/authentication/authentication_service.mock.ts @@ -8,10 +8,10 @@ import type { DeeplyMockedKeys } from '@kbn/utility-types/jest'; import { apiKeysMock } from './api_keys/api_keys.mock'; -import type { AuthenticationServiceStart } from './authentication_service'; +import type { AuthenticationServiceStartInternal } from './authentication_service'; export const authenticationServiceMock = { - createStart: (): DeeplyMockedKeys => ({ + createStart: (): DeeplyMockedKeys => ({ apiKeys: apiKeysMock.create(), login: jest.fn(), logout: jest.fn(), diff --git a/x-pack/plugins/security/server/authentication/authentication_service.ts b/x-pack/plugins/security/server/authentication/authentication_service.ts index e5895422e7a74..946fedbeee04f 100644 --- a/x-pack/plugins/security/server/authentication/authentication_service.ts +++ b/x-pack/plugins/security/server/authentication/authentication_service.ts @@ -51,7 +51,7 @@ interface AuthenticationServiceStartParams { loggers: LoggerFactory; } -export interface AuthenticationServiceStart { +export interface AuthenticationServiceStartInternal extends AuthenticationServiceStart { apiKeys: Pick< APIKeys, | 'areAPIKeysEnabled' @@ -66,6 +66,21 @@ export interface AuthenticationServiceStart { getCurrentUser: (request: KibanaRequest) => AuthenticatedUser | null; } +/** + * Authentication services available on the security plugin's start contract. + */ +export interface AuthenticationServiceStart { + apiKeys: Pick< + APIKeys, + | 'areAPIKeysEnabled' + | 'create' + | 'invalidate' + | 'grantAsInternalUser' + | 'invalidateAsInternalUser' + >; + getCurrentUser: (request: KibanaRequest) => AuthenticatedUser | null; +} + export class AuthenticationService { private license!: SecurityLicense; private authenticator?: Authenticator; @@ -212,7 +227,7 @@ export class AuthenticationService { legacyAuditLogger, loggers, session, - }: AuthenticationServiceStartParams): AuthenticationServiceStart { + }: AuthenticationServiceStartParams): AuthenticationServiceStartInternal { const apiKeys = new APIKeys({ clusterClient, logger: this.logger.get('api-key'), diff --git a/x-pack/plugins/security/server/authentication/index.ts b/x-pack/plugins/security/server/authentication/index.ts index f7f5f82d2858b..4f82c5653baa9 100644 --- a/x-pack/plugins/security/server/authentication/index.ts +++ b/x-pack/plugins/security/server/authentication/index.ts @@ -6,7 +6,11 @@ */ export { canRedirectRequest } from './can_redirect_request'; -export { AuthenticationService, AuthenticationServiceStart } from './authentication_service'; +export { + AuthenticationService, + AuthenticationServiceStart, + AuthenticationServiceStartInternal, +} from './authentication_service'; export { AuthenticationResult } from './authentication_result'; export { DeauthenticationResult } from './deauthentication_result'; export { diff --git a/x-pack/plugins/security/server/authorization/authorization_service.tsx b/x-pack/plugins/security/server/authorization/authorization_service.tsx index 1e2588dafe233..c5adb3aff670e 100644 --- a/x-pack/plugins/security/server/authorization/authorization_service.tsx +++ b/x-pack/plugins/security/server/authorization/authorization_service.tsx @@ -72,7 +72,7 @@ interface AuthorizationServiceStartParams { online$: Observable; } -export interface AuthorizationServiceSetup { +export interface AuthorizationServiceSetupInternal extends AuthorizationServiceSetup { actions: Actions; checkPrivilegesWithRequest: CheckPrivilegesWithRequest; checkPrivilegesDynamicallyWithRequest: CheckPrivilegesDynamicallyWithRequest; @@ -82,6 +82,21 @@ export interface AuthorizationServiceSetup { privileges: PrivilegesService; } +/** + * Authorization services available on the setup contract of the security plugin. + */ +export interface AuthorizationServiceSetup { + /** + * Actions are used to create the "actions" that are associated with Elasticsearch's + * application privileges, and are used to perform the authorization checks implemented + * by the various `checkPrivilegesWithRequest` derivatives + */ + actions: Actions; + checkPrivilegesWithRequest: CheckPrivilegesWithRequest; + checkPrivilegesDynamicallyWithRequest: CheckPrivilegesDynamicallyWithRequest; + mode: AuthorizationMode; +} + export class AuthorizationService { private logger!: Logger; private applicationName!: string; @@ -101,7 +116,7 @@ export class AuthorizationService { kibanaIndexName, getSpacesService, getCurrentUser, - }: AuthorizationServiceSetupParams): AuthorizationServiceSetup { + }: AuthorizationServiceSetupParams): AuthorizationServiceSetupInternal { this.logger = loggers.get('authorization'); this.applicationName = `${APPLICATION_PREFIX}${kibanaIndexName}`; diff --git a/x-pack/plugins/security/server/authorization/index.ts b/x-pack/plugins/security/server/authorization/index.ts index 16a3c2ae50058..4d67f3435e7da 100644 --- a/x-pack/plugins/security/server/authorization/index.ts +++ b/x-pack/plugins/security/server/authorization/index.ts @@ -6,6 +6,10 @@ */ export { Actions } from './actions'; -export { AuthorizationService, AuthorizationServiceSetup } from './authorization_service'; +export { + AuthorizationService, + AuthorizationServiceSetup, + AuthorizationServiceSetupInternal, +} from './authorization_service'; export { CheckSavedObjectsPrivileges } from './check_saved_objects_privileges'; export { CheckPrivilegesPayload } from './types'; diff --git a/x-pack/plugins/security/server/index.ts b/x-pack/plugins/security/server/index.ts index e50ab66a92547..a48c6833096cc 100644 --- a/x-pack/plugins/security/server/index.ts +++ b/x-pack/plugins/security/server/index.ts @@ -25,6 +25,7 @@ export type { InvalidateAPIKeysParams, InvalidateAPIKeyResult, GrantAPIKeyResult, + AuthenticationServiceStart, } from './authentication'; export type { CheckPrivilegesPayload } from './authorization'; export type AuthorizationServiceSetup = SecurityPluginStart['authz']; @@ -32,6 +33,7 @@ export { LegacyAuditLogger, AuditLogger, AuditEvent } from './audit'; export type { SecurityPluginSetup, SecurityPluginStart }; export type { AuthenticatedUser } from '../common/model'; export { ROUTE_TAG_CAN_REDIRECT } from './routes/tags'; +export { AuditServiceSetup } from './audit'; export const config: PluginConfigDescriptor> = { schema: ConfigSchema, diff --git a/x-pack/plugins/security/server/plugin.ts b/x-pack/plugins/security/server/plugin.ts index 57be308525fdd..98f1335b53450 100644 --- a/x-pack/plugins/security/server/plugin.ts +++ b/x-pack/plugins/security/server/plugin.ts @@ -10,7 +10,6 @@ import { combineLatest } from 'rxjs'; import { map } from 'rxjs/operators'; import type { TypeOf } from '@kbn/config-schema'; -import type { RecursiveReadonly } from '@kbn/utility-types'; import type { CoreSetup, CoreStart, @@ -36,10 +35,14 @@ import type { AnonymousAccessServiceStart } from './anonymous_access'; import { AnonymousAccessService } from './anonymous_access'; import type { AuditServiceSetup } from './audit'; import { AuditService, SecurityAuditLogger } from './audit'; -import type { AuthenticationServiceStart } from './authentication'; +import type { + AuthenticationServiceStart, + AuthenticationServiceStartInternal, +} from './authentication'; import { AuthenticationService } from './authentication'; import type { AuthorizationServiceSetup } from './authorization'; import { AuthorizationService } from './authorization'; +import type { AuthorizationServiceSetupInternal } from './authorization/authorization_service'; import type { ConfigSchema, ConfigType } from './config'; import { createConfig } from './config'; import { ElasticsearchService } from './elasticsearch'; @@ -74,11 +77,14 @@ export interface SecurityPluginSetup { /** * @deprecated Use `authz` methods from the `SecurityServiceStart` contract instead. */ - authz: Pick< - AuthorizationServiceSetup, - 'actions' | 'checkPrivilegesDynamicallyWithRequest' | 'checkPrivilegesWithRequest' | 'mode' - >; + authz: AuthorizationServiceSetup; + /** + * Exposes information about the available security features under the current license. + */ license: SecurityLicense; + /** + * Exposes services for audit logging. + */ audit: AuditServiceSetup; } @@ -86,11 +92,14 @@ export interface SecurityPluginSetup { * Describes public Security plugin contract returned at the `start` stage. */ export interface SecurityPluginStart { - authc: Pick; - authz: Pick< - AuthorizationServiceSetup, - 'actions' | 'checkPrivilegesDynamicallyWithRequest' | 'checkPrivilegesWithRequest' | 'mode' - >; + /** + * Authentication services to confirm the user is who they say they are. + */ + authc: AuthenticationServiceStart; + /** + * Authorization services to manage and access the permissions a particular user has. + */ + authz: AuthorizationServiceSetup; } export interface PluginSetupDependencies { @@ -113,14 +122,9 @@ export interface PluginStartDependencies { * Represents Security Plugin instance that will be managed by the Kibana plugin system. */ export class SecurityPlugin - implements - Plugin< - RecursiveReadonly, - RecursiveReadonly, - PluginSetupDependencies - > { + implements Plugin { private readonly logger: Logger; - private authorizationSetup?: AuthorizationServiceSetup; + private authorizationSetup?: AuthorizationServiceSetupInternal; private auditSetup?: AuditServiceSetup; private anonymousAccessStart?: AnonymousAccessServiceStart; private configSubscription?: Subscription; @@ -152,7 +156,7 @@ export class SecurityPlugin private readonly authenticationService = new AuthenticationService( this.initializerContext.logger.get('authentication') ); - private authenticationStart?: AuthenticationServiceStart; + private authenticationStart?: AuthenticationServiceStartInternal; private readonly getAuthentication = () => { if (!this.authenticationStart) { throw new Error(`authenticationStart is not registered!`); diff --git a/x-pack/plugins/security/server/routes/api_keys/create.test.ts b/x-pack/plugins/security/server/routes/api_keys/create.test.ts index 502a7cb1246c4..ee28681adbd5f 100644 --- a/x-pack/plugins/security/server/routes/api_keys/create.test.ts +++ b/x-pack/plugins/security/server/routes/api_keys/create.test.ts @@ -12,7 +12,7 @@ import type { RequestHandler } from 'src/core/server'; import { kibanaResponseFactory } from 'src/core/server'; import { httpServerMock } from 'src/core/server/mocks'; -import type { AuthenticationServiceStart } from '../../authentication'; +import type { AuthenticationServiceStartInternal } from '../../authentication'; import { authenticationServiceMock } from '../../authentication/authentication_service.mock'; import type { SecurityRequestHandlerContext } from '../../types'; import { routeDefinitionParamsMock } from '../index.mock'; @@ -28,7 +28,7 @@ describe('Create API Key route', () => { } let routeHandler: RequestHandler; - let authc: DeeplyMockedKeys; + let authc: DeeplyMockedKeys; beforeEach(() => { authc = authenticationServiceMock.createStart(); const mockRouteDefinitionParams = routeDefinitionParamsMock.create(); diff --git a/x-pack/plugins/security/server/routes/api_keys/enabled.test.ts b/x-pack/plugins/security/server/routes/api_keys/enabled.test.ts index da097faf8c6b2..1000e79563b57 100644 --- a/x-pack/plugins/security/server/routes/api_keys/enabled.test.ts +++ b/x-pack/plugins/security/server/routes/api_keys/enabled.test.ts @@ -12,7 +12,7 @@ import type { RequestHandler } from 'src/core/server'; import { kibanaResponseFactory } from 'src/core/server'; import { httpServerMock } from 'src/core/server/mocks'; -import type { AuthenticationServiceStart } from '../../authentication'; +import type { AuthenticationServiceStartInternal } from '../../authentication'; import { authenticationServiceMock } from '../../authentication/authentication_service.mock'; import type { SecurityRequestHandlerContext } from '../../types'; import { routeDefinitionParamsMock } from '../index.mock'; @@ -28,7 +28,7 @@ describe('API keys enabled', () => { } let routeHandler: RequestHandler; - let authc: DeeplyMockedKeys; + let authc: DeeplyMockedKeys; beforeEach(() => { authc = authenticationServiceMock.createStart(); const mockRouteDefinitionParams = routeDefinitionParamsMock.create(); diff --git a/x-pack/plugins/security/server/routes/authentication/common.test.ts b/x-pack/plugins/security/server/routes/authentication/common.test.ts index 1e0b6784a45c8..5acc5817bfb3e 100644 --- a/x-pack/plugins/security/server/routes/authentication/common.test.ts +++ b/x-pack/plugins/security/server/routes/authentication/common.test.ts @@ -13,7 +13,7 @@ import { httpServerMock } from 'src/core/server/mocks'; import type { SecurityLicense, SecurityLicenseFeatures } from '../../../common/licensing'; import { mockAuthenticatedUser } from '../../../common/model/authenticated_user.mock'; -import type { AuthenticationServiceStart } from '../../authentication'; +import type { AuthenticationServiceStartInternal } from '../../authentication'; import { AuthenticationResult, DeauthenticationResult, @@ -28,7 +28,7 @@ import { defineCommonRoutes } from './common'; describe('Common authentication routes', () => { let router: jest.Mocked; - let authc: DeeplyMockedKeys; + let authc: DeeplyMockedKeys; let license: jest.Mocked; let mockContext: SecurityRequestHandlerContext; beforeEach(() => { diff --git a/x-pack/plugins/security/server/routes/authentication/saml.test.ts b/x-pack/plugins/security/server/routes/authentication/saml.test.ts index 3b2497ed9f30b..c28c435217ef3 100644 --- a/x-pack/plugins/security/server/routes/authentication/saml.test.ts +++ b/x-pack/plugins/security/server/routes/authentication/saml.test.ts @@ -11,7 +11,7 @@ import type { RequestHandler, RouteConfig } from 'src/core/server'; import { httpServerMock } from 'src/core/server/mocks'; import { mockAuthenticatedUser } from '../../../common/model/authenticated_user.mock'; -import type { AuthenticationServiceStart } from '../../authentication'; +import type { AuthenticationServiceStartInternal } from '../../authentication'; import { AuthenticationResult, SAMLLogin } from '../../authentication'; import { authenticationServiceMock } from '../../authentication/authentication_service.mock'; import type { SecurityRouter } from '../../types'; @@ -21,7 +21,7 @@ import { defineSAMLRoutes } from './saml'; describe('SAML authentication routes', () => { let router: jest.Mocked; - let authc: DeeplyMockedKeys; + let authc: DeeplyMockedKeys; beforeEach(() => { const routeParamsMock = routeDefinitionParamsMock.create(); router = routeParamsMock.router; diff --git a/x-pack/plugins/security/server/routes/index.ts b/x-pack/plugins/security/server/routes/index.ts index cdb3a2fa289fd..e36ca1b9ab72e 100644 --- a/x-pack/plugins/security/server/routes/index.ts +++ b/x-pack/plugins/security/server/routes/index.ts @@ -10,8 +10,8 @@ import type { HttpResources, IBasePath, Logger } from 'src/core/server'; import type { KibanaFeature } from '../../../features/server'; import type { SecurityLicense } from '../../common/licensing'; -import type { AuthenticationServiceStart } from '../authentication'; -import type { AuthorizationServiceSetup } from '../authorization'; +import type { AuthenticationServiceStartInternal } from '../authentication'; +import type { AuthorizationServiceSetupInternal } from '../authorization'; import type { ConfigType } from '../config'; import type { SecurityFeatureUsageServiceStart } from '../feature_usage'; import type { Session } from '../session_management'; @@ -34,12 +34,12 @@ export interface RouteDefinitionParams { httpResources: HttpResources; logger: Logger; config: ConfigType; - authz: AuthorizationServiceSetup; + authz: AuthorizationServiceSetupInternal; getSession: () => PublicMethodsOf; license: SecurityLicense; getFeatures: () => Promise; getFeatureUsageService: () => SecurityFeatureUsageServiceStart; - getAuthenticationService: () => AuthenticationServiceStart; + getAuthenticationService: () => AuthenticationServiceStartInternal; } export function defineRoutes(params: RouteDefinitionParams) { diff --git a/x-pack/plugins/security/server/routes/users/change_password.test.ts b/x-pack/plugins/security/server/routes/users/change_password.test.ts index a97fce7ea4b19..e5f4381a20421 100644 --- a/x-pack/plugins/security/server/routes/users/change_password.test.ts +++ b/x-pack/plugins/security/server/routes/users/change_password.test.ts @@ -15,8 +15,8 @@ import { kibanaResponseFactory } from 'src/core/server'; import { coreMock, httpServerMock } from 'src/core/server/mocks'; import { mockAuthenticatedUser } from '../../../common/model/authenticated_user.mock'; -import type { AuthenticationServiceStart } from '../../authentication'; import { AuthenticationResult } from '../../authentication'; +import type { AuthenticationServiceStartInternal } from '../../authentication/authentication_service'; import { authenticationServiceMock } from '../../authentication/authentication_service.mock'; import type { Session } from '../../session_management'; import { sessionMock } from '../../session_management/session.mock'; @@ -26,7 +26,7 @@ import { defineChangeUserPasswordRoutes } from './change_password'; describe('Change password', () => { let router: jest.Mocked; - let authc: DeeplyMockedKeys; + let authc: DeeplyMockedKeys; let session: jest.Mocked>; let routeHandler: RequestHandler; let routeConfig: RouteConfig; diff --git a/x-pack/plugins/security/server/saved_objects/index.ts b/x-pack/plugins/security/server/saved_objects/index.ts index e052fd1c7ab6a..837b3c594d396 100644 --- a/x-pack/plugins/security/server/saved_objects/index.ts +++ b/x-pack/plugins/security/server/saved_objects/index.ts @@ -9,7 +9,7 @@ import type { CoreSetup, LegacyRequest } from 'src/core/server'; import { KibanaRequest, SavedObjectsClient } from '../../../../../src/core/server'; import type { AuditServiceSetup, SecurityAuditLogger } from '../audit'; -import type { AuthorizationServiceSetup } from '../authorization'; +import type { AuthorizationServiceSetupInternal } from '../authorization/authorization_service'; import type { SpacesService } from '../plugin'; import { SecureSavedObjectsClientWrapper } from './secure_saved_objects_client_wrapper'; @@ -17,7 +17,7 @@ interface SetupSavedObjectsParams { legacyAuditLogger: SecurityAuditLogger; audit: AuditServiceSetup; authz: Pick< - AuthorizationServiceSetup, + AuthorizationServiceSetupInternal, 'mode' | 'actions' | 'checkSavedObjectsPrivilegesWithRequest' >; savedObjects: CoreSetup['savedObjects']; diff --git a/x-pack/plugins/security/server/spaces/secure_spaces_client_wrapper.test.ts b/x-pack/plugins/security/server/spaces/secure_spaces_client_wrapper.test.ts index 0b8a7abab2382..bc7cb727edd80 100644 --- a/x-pack/plugins/security/server/spaces/secure_spaces_client_wrapper.test.ts +++ b/x-pack/plugins/security/server/spaces/secure_spaces_client_wrapper.test.ts @@ -15,7 +15,10 @@ import { spacesClientMock } from '../../../spaces/server/mocks'; import type { AuditEvent, AuditLogger } from '../audit'; import { SpaceAuditAction } from '../audit'; import { auditServiceMock } from '../audit/index.mock'; -import type { AuthorizationServiceSetup } from '../authorization'; +import type { + AuthorizationServiceSetup, + AuthorizationServiceSetupInternal, +} from '../authorization'; import { authorizationMock } from '../authorization/index.mock'; import type { CheckPrivilegesResponse } from '../authorization/types'; import type { LegacySpacesAuditLogger } from './legacy_audit_logger'; @@ -85,7 +88,9 @@ const setup = ({ securityEnabled = false }: Opts = {}) => { }; }; -const expectNoAuthorizationCheck = (authorization: jest.Mocked) => { +const expectNoAuthorizationCheck = ( + authorization: jest.Mocked +) => { expect(authorization.checkPrivilegesDynamicallyWithRequest).not.toHaveBeenCalled(); expect(authorization.checkPrivilegesWithRequest).not.toHaveBeenCalled(); expect(authorization.checkSavedObjectsPrivilegesWithRequest).not.toHaveBeenCalled(); From d90285f718395fa051b50caa8ec77e29ffa06636 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20S=C3=A1nchez?= Date: Wed, 9 Jun 2021 14:20:43 +0200 Subject: [PATCH 18/25] Blocks save event filter with a white space name (#101599) --- .../view/components/form/index.test.tsx | 17 +++++++++++++++++ .../view/components/form/index.tsx | 5 +++-- 2 files changed, 20 insertions(+), 2 deletions(-) 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 048bd97664f2e..4171441e7de25 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 @@ -111,6 +111,23 @@ describe('Event filter form', () => { expect(store.getState()!.management!.eventFilters!.form!.hasNameError).toBeFalsy(); }); + it('should change name with a white space still shows an error', async () => { + component = renderComponentWithdata(); + + const nameInput = component.getByPlaceholderText(NAME_PLACEHOLDER); + + act(() => { + fireEvent.change(nameInput, { + target: { + value: ' ', + }, + }); + }); + + expect(store.getState()!.management!.eventFilters!.form!.entry!.name).toBe(''); + expect(store.getState()!.management!.eventFilters!.form!.hasNameError).toBeTruthy(); + }); + it('should change comments', async () => { component = renderComponentWithdata(); 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 93658d4efa737..121808b62f570 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 @@ -91,11 +91,12 @@ export const EventFiltersForm: React.FC = memo( const handleOnChangeName = useCallback( (e: React.ChangeEvent) => { if (!exception) return; + const name = e.target.value.toString().trim(); dispatch({ type: 'eventFiltersChangeForm', payload: { - entry: { ...exception, name: e.target.value.toString() }, - hasNameError: !e.target.value, + entry: { ...exception, name }, + hasNameError: !name, }, }); }, From e3c3b6f3347235b45eb4b6175a387bcd9d9ce13c Mon Sep 17 00:00:00 2001 From: Marco Liberati Date: Wed, 9 Jun 2021 14:27:49 +0200 Subject: [PATCH 19/25] [Lens] New summary row feature for datatable (#101075) * :sparkles: New summary row feature for datatable * :sparkles: Allow empty strings behind flag + tests * :bug: Address the transition problem + refactor * :white_check_mark: Add some unit tests * :white_check_mark: Add first functional tests * :ok_hand: first feedback addressed * :sparkles: Make it handle numeric array values * :memo: Improved message * :white_check_mark: Fix functional test * :fire: Remove warning message for last value * :rotating_light: Remove unused import * :bug: Fix a bug with last value * :ok_hand: Integrated feedback * :lipstick: Migrated to combobox * :white_check_mark: Fix unit tests + restore right data-test-id * :label: Fix type issue * :ok_hand: Address all issues reported Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> --- .../components/dimension_editor.test.tsx | 62 ++++++++- .../components/dimension_editor.tsx | 101 ++++++++++++-- .../components/table_basic.test.tsx | 102 ++++++++++++++ .../components/table_basic.tsx | 36 +++++ .../datatable_visualization/expression.tsx | 14 ++ .../datatable_visualization/summary.test.ts | 125 +++++++++++++++++ .../public/datatable_visualization/summary.ts | 127 ++++++++++++++++++ .../public/datatable_visualization/utils.ts | 27 ++++ .../datatable_visualization/visualization.tsx | 9 ++ .../shared_components/debounced_value.test.ts | 55 ++++++++ .../shared_components/debounced_value.ts | 23 ++-- x-pack/test/functional/apps/lens/table.ts | 10 ++ .../test/functional/page_objects/lens_page.ts | 18 +++ 13 files changed, 692 insertions(+), 17 deletions(-) create mode 100644 x-pack/plugins/lens/public/datatable_visualization/summary.test.ts create mode 100644 x-pack/plugins/lens/public/datatable_visualization/summary.ts create mode 100644 x-pack/plugins/lens/public/datatable_visualization/utils.ts create mode 100644 x-pack/plugins/lens/public/shared_components/debounced_value.test.ts diff --git a/x-pack/plugins/lens/public/datatable_visualization/components/dimension_editor.test.tsx b/x-pack/plugins/lens/public/datatable_visualization/components/dimension_editor.test.tsx index 88948e9a7615b..49003af28f3f1 100644 --- a/x-pack/plugins/lens/public/datatable_visualization/components/dimension_editor.test.tsx +++ b/x-pack/plugins/lens/public/datatable_visualization/components/dimension_editor.test.tsx @@ -6,7 +6,7 @@ */ import React from 'react'; -import { EuiButtonGroup } from '@elastic/eui'; +import { EuiButtonGroup, EuiComboBox, EuiFieldText } from '@elastic/eui'; import { FramePublicAPI, VisualizationDimensionEditorProps } from '../../types'; import { DatatableVisualizationState } from '../visualization'; import { createMockDatasource, createMockFramePublicAPI } from '../../editor_frame_service/mocks'; @@ -212,4 +212,64 @@ describe('data table dimension editor', () => { expect(instance.find(PalettePanelContainer).exists()).toBe(true); }); + + it('should show the summary field for non numeric columns', () => { + const instance = mountWithIntl(); + expect(instance.find('[data-test-subj="lnsDatatable_summaryrow_function"]').exists()).toBe( + false + ); + expect(instance.find('[data-test-subj="lnsDatatable_summaryrow_label"]').exists()).toBe(false); + }); + + it('should set the summary row function default to "none"', () => { + frame.activeData!.first.columns[0].meta.type = 'number'; + const instance = mountWithIntl(); + expect( + instance + .find('[data-test-subj="lnsDatatable_summaryrow_function"]') + .find(EuiComboBox) + .prop('selectedOptions') + ).toEqual([{ value: 'none', label: 'None' }]); + + expect(instance.find('[data-test-subj="lnsDatatable_summaryrow_label"]').exists()).toBe(false); + }); + + it('should show the summary row label input ony when summary row is different from "none"', () => { + frame.activeData!.first.columns[0].meta.type = 'number'; + state.columns[0].summaryRow = 'sum'; + const instance = mountWithIntl(); + expect( + instance + .find('[data-test-subj="lnsDatatable_summaryrow_function"]') + .find(EuiComboBox) + .prop('selectedOptions') + ).toEqual([{ value: 'sum', label: 'Sum' }]); + + expect( + instance + .find('[data-test-subj="lnsDatatable_summaryrow_label"]') + .find(EuiFieldText) + .prop('value') + ).toBe('Sum'); + }); + + it("should show the correct summary row name when user's changes summary label", () => { + frame.activeData!.first.columns[0].meta.type = 'number'; + state.columns[0].summaryRow = 'sum'; + state.columns[0].summaryLabel = 'MySum'; + const instance = mountWithIntl(); + expect( + instance + .find('[data-test-subj="lnsDatatable_summaryrow_function"]') + .find(EuiComboBox) + .prop('selectedOptions') + ).toEqual([{ value: 'sum', label: 'Sum' }]); + + expect( + instance + .find('[data-test-subj="lnsDatatable_summaryrow_label"]') + .find(EuiFieldText) + .prop('value') + ).toBe('MySum'); + }); }); diff --git a/x-pack/plugins/lens/public/datatable_visualization/components/dimension_editor.tsx b/x-pack/plugins/lens/public/datatable_visualization/components/dimension_editor.tsx index 76c47a9c743c5..6c39a04ae1504 100644 --- a/x-pack/plugins/lens/public/datatable_visualization/components/dimension_editor.tsx +++ b/x-pack/plugins/lens/public/datatable_visualization/components/dimension_editor.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import React, { useState } from 'react'; +import React, { useCallback, useState } from 'react'; import { i18n } from '@kbn/i18n'; import { EuiFormRow, @@ -16,10 +16,12 @@ import { EuiFlexItem, EuiFlexGroup, EuiButtonEmpty, + EuiFieldText, + EuiComboBox, } from '@elastic/eui'; import { PaletteRegistry } from 'src/plugins/charts/public'; import { VisualizationDimensionEditorProps } from '../../types'; -import { DatatableVisualizationState } from '../visualization'; +import { ColumnState, DatatableVisualizationState } from '../visualization'; import { getOriginalId } from '../transpose_helpers'; import { CustomizablePalette, @@ -27,14 +29,22 @@ import { defaultPaletteParams, FIXED_PROGRESSION, getStopsForFixedMode, + useDebouncedValue, } from '../../shared_components/'; import { PalettePanelContainer } from './palette_panel_container'; import { findMinMaxByColumnId } from './shared_utils'; import './dimension_editor.scss'; +import { + getDefaultSummaryLabel, + getFinalSummaryConfiguration, + getSummaryRowOptions, +} from '../summary'; +import { isNumericField } from '../utils'; const idPrefix = htmlIdGenerator()(); type ColumnType = DatatableVisualizationState['columns'][number]; +type SummaryRowType = Extract; function updateColumnWith( state: DatatableVisualizationState, @@ -58,6 +68,24 @@ export function TableDimensionEditor( const { state, setState, frame, accessor } = props; const column = state.columns.find(({ columnId }) => accessor === columnId); const [isPaletteOpen, setIsPaletteOpen] = useState(false); + const onSummaryLabelChangeToDebounce = useCallback( + (newSummaryLabel: string | undefined) => { + setState({ + ...state, + columns: updateColumnWith(state, accessor, { summaryLabel: newSummaryLabel }), + }); + }, + [accessor, setState, state] + ); + const { inputValue: summaryLabel, handleInputChange: onSummaryLabelChange } = useDebouncedValue< + string | undefined + >( + { + onChange: onSummaryLabelChangeToDebounce, + value: column?.summaryLabel, + }, + { allowEmptyString: true } // empty string is a valid label for this feature + ); if (!column) return null; if (column.isTransposed) return null; @@ -65,13 +93,16 @@ export function TableDimensionEditor( const currentData = frame.activeData?.[state.layerId]; // either read config state or use same logic as chart itself - const isNumericField = - currentData?.columns.find((col) => col.id === accessor || getOriginalId(col.id) === accessor) - ?.meta.type === 'number'; - - const currentAlignment = column?.alignment || (isNumericField ? 'right' : 'left'); + const isNumeric = isNumericField(currentData, accessor); + const currentAlignment = column?.alignment || (isNumeric ? 'right' : 'left'); const currentColorMode = column?.colorMode || 'none'; const hasDynamicColoring = currentColorMode !== 'none'; + // when switching from one operation to another, make sure to keep the configuration consistent + const { summaryRow, summaryLabel: fallbackSummaryLabel } = getFinalSummaryConfiguration( + accessor, + column, + currentData + ); const visibleColumnsCount = state.columns.filter((c) => !c.hidden).length; @@ -175,7 +206,61 @@ export function TableDimensionEditor( /> )} - {isNumericField && ( + {isNumeric && ( + <> + + { + const newValue = choices[0].value as SummaryRowType; + setState({ + ...state, + columns: updateColumnWith(state, accessor, { summaryRow: newValue }), + }); + }} + /> + + {summaryRow !== 'none' && ( + + { + onSummaryLabelChange(e.target.value); + }} + /> + + )} + + )} + {isNumeric && ( <> { c: { min: 3, max: 3 }, }); }); + + test('it does render a summary footer if at least one column has it configured', () => { + const { data, args } = sampleArgs(); + + const wrapper = mountWithIntl( + ({ convert: (x) => x } as IFieldFormat)} + dispatchEvent={onDispatchEvent} + getType={jest.fn()} + renderMode="display" + paletteService={chartPluginMock.createPaletteRegistry()} + uiSettings={({ get: jest.fn() } as unknown) as IUiSettingsClient} + /> + ); + expect(wrapper.find('[data-test-subj="lnsDataTable-footer-a"]').exists()).toEqual(false); + expect(wrapper.find('[data-test-subj="lnsDataTable-footer-c"]').first().text()).toEqual( + 'Sum: 3' + ); + }); + + test('it does render a summary footer with just the raw value for empty label', () => { + const { data, args } = sampleArgs(); + + const wrapper = mountWithIntl( + ({ convert: (x) => x } as IFieldFormat)} + dispatchEvent={onDispatchEvent} + getType={jest.fn()} + renderMode="display" + paletteService={chartPluginMock.createPaletteRegistry()} + uiSettings={({ get: jest.fn() } as unknown) as IUiSettingsClient} + /> + ); + + expect(wrapper.find('[data-test-subj="lnsDataTable-footer-c"]').first().text()).toEqual('3'); + }); + + test('it does not render the summary row if the only column with summary is hidden', () => { + const { data, args } = sampleArgs(); + + const wrapper = mountWithIntl( + ({ convert: (x) => x } as IFieldFormat)} + dispatchEvent={onDispatchEvent} + getType={jest.fn()} + renderMode="display" + paletteService={chartPluginMock.createPaletteRegistry()} + uiSettings={({ get: jest.fn() } as unknown) as IUiSettingsClient} + /> + ); + + expect(wrapper.find('[data-test-subj="lnsDataTable-footer-c"]').exists()).toBe(false); + }); }); diff --git a/x-pack/plugins/lens/public/datatable_visualization/components/table_basic.tsx b/x-pack/plugins/lens/public/datatable_visualization/components/table_basic.tsx index e6fcf3f321f7f..cd990149fdaf5 100644 --- a/x-pack/plugins/lens/public/datatable_visualization/components/table_basic.tsx +++ b/x-pack/plugins/lens/public/datatable_visualization/components/table_basic.tsx @@ -43,6 +43,7 @@ import { } from './table_actions'; import { findMinMaxByColumnId } from './shared_utils'; import { CUSTOM_PALETTE } from '../../shared_components/coloring/constants'; +import { getFinalSummaryConfiguration } from '../summary'; export const DataContext = React.createContext({}); @@ -286,6 +287,40 @@ export const DatatableComponent = (props: DatatableRenderProps) => { [onEditAction, sortBy, sortDirection] ); + const renderSummaryRow = useMemo(() => { + const columnsWithSummary = columnConfig.columns + .filter((col) => !!col.columnId && !col.hidden) + .map((config) => ({ + columnId: config.columnId, + summaryRowValue: config.summaryRowValue, + ...getFinalSummaryConfiguration(config.columnId, config, firstTable), + })) + .filter(({ summaryRow }) => summaryRow !== 'none'); + + if (columnsWithSummary.length) { + const summaryLookup = Object.fromEntries( + columnsWithSummary.map(({ summaryRowValue, summaryLabel, columnId }) => [ + columnId, + summaryLabel === '' ? `${summaryRowValue}` : `${summaryLabel}: ${summaryRowValue}`, + ]) + ); + return ({ columnId }: { columnId: string }) => { + const currentAlignment = alignments && alignments[columnId]; + const alignmentClassName = `lnsTableCell--${currentAlignment}`; + const columnName = + columns.find(({ id }) => id === columnId)?.displayAsText?.replace(/ /g, '-') || columnId; + return summaryLookup[columnId] != null ? ( +
+ {summaryLookup[columnId]} +
+ ) : null; + }; + } + }, [columnConfig.columns, alignments, firstTable, columns]); + if (isEmpty) { return ; } @@ -323,6 +358,7 @@ export const DatatableComponent = (props: DatatableRenderProps) => { sorting={sorting} onColumnResize={onColumnResize} toolbarVisibility={false} + renderFooterCellValue={renderSummaryRow} /> diff --git a/x-pack/plugins/lens/public/datatable_visualization/expression.tsx b/x-pack/plugins/lens/public/datatable_visualization/expression.tsx index 2d5f4aea98856..79a541b0288ab 100644 --- a/x-pack/plugins/lens/public/datatable_visualization/expression.tsx +++ b/x-pack/plugins/lens/public/datatable_visualization/expression.tsx @@ -28,10 +28,12 @@ import { ColumnState } from './visualization'; import type { FormatFactory, ILensInterpreterRenderHandlers, LensMultiTable } from '../types'; import type { DatatableRender } from './components/types'; import { transposeTable } from './transpose_helpers'; +import { computeSummaryRowForColumn } from './summary'; export type ColumnConfigArg = Omit & { type: 'lens_datatable_column'; palette?: PaletteOutput; + summaryRowValue?: unknown; }; export interface Args { @@ -116,6 +118,16 @@ export const getDatatable = ({ return memo; }, {}); + const columnsWithSummary = args.columns.filter((c) => c.summaryRow); + for (const column of columnsWithSummary) { + column.summaryRowValue = computeSummaryRowForColumn( + column, + firstTable, + formatters, + formatFactory({ id: 'number' }) + ); + } + if (sortBy && columnsReverseLookup[sortBy] && sortDirection !== 'none') { // Sort on raw values for these types, while use the formatted value for the rest const sortingCriteria = getSortingCriteria( @@ -173,6 +185,8 @@ export const datatableColumn: ExpressionFunctionDefinition< types: ['palette'], help: '', }, + summaryRow: { types: ['string'], help: '' }, + summaryLabel: { types: ['string'], help: '' }, }, fn: function fn(input: unknown, args: ColumnState) { return { diff --git a/x-pack/plugins/lens/public/datatable_visualization/summary.test.ts b/x-pack/plugins/lens/public/datatable_visualization/summary.test.ts new file mode 100644 index 0000000000000..f92c83fbbfdc8 --- /dev/null +++ b/x-pack/plugins/lens/public/datatable_visualization/summary.test.ts @@ -0,0 +1,125 @@ +/* + * 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 { IFieldFormat } from 'src/plugins/data/public'; +import { Datatable } from 'src/plugins/expressions'; +import { computeSummaryRowForColumn, getFinalSummaryConfiguration } from './summary'; + +describe('Summary row helpers', () => { + const mockNumericTable: Datatable = { + type: 'datatable', + columns: [{ id: 'myColumn', name: 'My Column', meta: { type: 'number' } }], + rows: [{ myColumn: 45 }], + }; + + const mockNumericTableWithArray: Datatable = { + type: 'datatable', + columns: [{ id: 'myColumn', name: 'My Column', meta: { type: 'number' } }], + rows: [{ myColumn: [45, 90] }], + }; + + const mockNonNumericTable: Datatable = { + type: 'datatable', + columns: [{ id: 'myColumn', name: 'My Column', meta: { type: 'string' } }], + rows: [{ myColumn: 'myString' }], + }; + + const defaultFormatter = { convert: (x) => x } as IFieldFormat; + const customNumericFormatter = { convert: (x: number) => x.toFixed(2) } as IFieldFormat; + + describe('getFinalSummaryConfiguration', () => { + it('should return the base configuration for an unconfigured column', () => { + expect(getFinalSummaryConfiguration('myColumn', {}, mockNumericTable)).toEqual({ + summaryRow: 'none', + summaryLabel: 'None', + }); + }); + + it('should return the right configuration for a partially configured column', () => { + expect( + getFinalSummaryConfiguration('myColumn', { summaryRow: 'sum' }, mockNumericTable) + ).toEqual({ + summaryRow: 'sum', + summaryLabel: 'Sum', + }); + }); + + it('should return the base configuration for a transitioned invalid column', () => { + expect( + getFinalSummaryConfiguration('myColumn', { summaryRow: 'sum' }, mockNumericTableWithArray) + ).toEqual({ + summaryRow: 'sum', + summaryLabel: 'Sum', + }); + }); + + it('should return the base configuration for a non numeric column', () => { + expect( + getFinalSummaryConfiguration('myColumn', { summaryRow: 'sum' }, mockNonNumericTable) + ).toEqual({ + summaryRow: 'none', + summaryLabel: 'None', + }); + }); + }); + + describe('computeSummaryRowForColumn', () => { + for (const op of ['avg', 'sum', 'min', 'max'] as const) { + it(`should return formatted value for a ${op} summary function`, () => { + expect( + computeSummaryRowForColumn( + { summaryRow: op, columnId: 'myColumn', type: 'lens_datatable_column' }, + mockNumericTable, + { + myColumn: customNumericFormatter, + }, + defaultFormatter + ) + ).toBe('45.00'); + }); + } + + it('should ignore the column formatter, rather return the raw value for count operation', () => { + expect( + computeSummaryRowForColumn( + { summaryRow: 'count', columnId: 'myColumn', type: 'lens_datatable_column' }, + mockNumericTable, + { + myColumn: customNumericFormatter, + }, + defaultFormatter + ) + ).toBe(1); + }); + + it('should only count non-null/empty values', () => { + expect( + computeSummaryRowForColumn( + { summaryRow: 'count', columnId: 'myColumn', type: 'lens_datatable_column' }, + { ...mockNumericTable, rows: [...mockNumericTable.rows, { myColumn: null }] }, + { + myColumn: customNumericFormatter, + }, + defaultFormatter + ) + ).toBe(1); + }); + + it('should count numeric arrays as valid and distinct values', () => { + expect( + computeSummaryRowForColumn( + { summaryRow: 'count', columnId: 'myColumn', type: 'lens_datatable_column' }, + mockNumericTableWithArray, + { + myColumn: defaultFormatter, + }, + defaultFormatter + ) + ).toBe(2); + }); + }); +}); diff --git a/x-pack/plugins/lens/public/datatable_visualization/summary.ts b/x-pack/plugins/lens/public/datatable_visualization/summary.ts new file mode 100644 index 0000000000000..6c267445aab76 --- /dev/null +++ b/x-pack/plugins/lens/public/datatable_visualization/summary.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 { i18n } from '@kbn/i18n'; +import { FieldFormat } from 'src/plugins/data/public'; +import { Datatable } from 'src/plugins/expressions/public'; +import { ColumnConfigArg } from './datatable_visualization'; +import { getOriginalId } from './transpose_helpers'; +import { isNumericField } from './utils'; + +type SummaryRowType = Extract; + +export function getFinalSummaryConfiguration( + columnId: string, + columnArgs: Pick | undefined, + table: Datatable | undefined +) { + const isNumeric = isNumericField(table, columnId); + + const summaryRow = isNumeric ? columnArgs?.summaryRow || 'none' : 'none'; + const summaryLabel = columnArgs?.summaryLabel ?? getDefaultSummaryLabel(summaryRow); + + return { + summaryRow, + summaryLabel, + }; +} + +export function getDefaultSummaryLabel(type: SummaryRowType) { + return getSummaryRowOptions().find(({ value }) => type === value)!.label!; +} + +export function getSummaryRowOptions(): Array<{ + value: SummaryRowType; + label: string; + 'data-test-subj': string; +}> { + return [ + { + value: 'none', + label: i18n.translate('xpack.lens.table.summaryRow.none', { + defaultMessage: 'None', + }), + 'data-test-subj': 'lns-datatable-summary-none', + }, + { + value: 'count', + label: i18n.translate('xpack.lens.table.summaryRow.count', { + defaultMessage: 'Value count', + }), + 'data-test-subj': 'lns-datatable-summary-count', + }, + { + value: 'sum', + label: i18n.translate('xpack.lens.table.summaryRow.sum', { + defaultMessage: 'Sum', + }), + 'data-test-subj': 'lns-datatable-summary-sum', + }, + { + value: 'avg', + label: i18n.translate('xpack.lens.table.summaryRow.average', { + defaultMessage: 'Average', + }), + 'data-test-subj': 'lns-datatable-summary-avg', + }, + { + value: 'min', + label: i18n.translate('xpack.lens.table.summaryRow.minimum', { + defaultMessage: 'Minimum', + }), + 'data-test-subj': 'lns-datatable-summary-min', + }, + { + value: 'max', + label: i18n.translate('xpack.lens.table.summaryRow.maximum', { + defaultMessage: 'Maximum', + }), + 'data-test-subj': 'lns-datatable-summary-max', + }, + ]; +} + +export function computeSummaryRowForColumn( + columnArgs: ColumnConfigArg, + table: Datatable, + formatters: Record, + defaultFormatter: FieldFormat +) { + const summaryValue = computeFinalValue(columnArgs.summaryRow, columnArgs.columnId, table.rows); + // ignore the coluymn formatter for the count case + if (columnArgs.summaryRow === 'count') { + return defaultFormatter.convert(summaryValue); + } + return formatters[getOriginalId(columnArgs.columnId)].convert(summaryValue); +} + +function computeFinalValue( + type: ColumnConfigArg['summaryRow'], + columnId: string, + rows: Datatable['rows'] +) { + // flatten the row structure, to easier handle numeric arrays + const validRows = rows.filter((v) => v[columnId] != null).flatMap((v) => v[columnId]); + const count = validRows.length; + const sum = validRows.reduce((partialSum: number, value: number) => { + return partialSum + value; + }, 0); + switch (type) { + case 'sum': + return sum; + case 'count': + return count; + case 'avg': + return sum / count; + case 'min': + return Math.min(...validRows); + case 'max': + return Math.max(...validRows); + default: + throw Error('No summary function found'); + } +} diff --git a/x-pack/plugins/lens/public/datatable_visualization/utils.ts b/x-pack/plugins/lens/public/datatable_visualization/utils.ts new file mode 100644 index 0000000000000..64fdee233e830 --- /dev/null +++ b/x-pack/plugins/lens/public/datatable_visualization/utils.ts @@ -0,0 +1,27 @@ +/* + * 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 { Datatable } from 'src/plugins/expressions/public'; +import { getOriginalId } from './transpose_helpers'; + +function isValidNumber(value: unknown): boolean { + return typeof value === 'number' || value == null; +} + +export function isNumericField(currentData: Datatable | undefined, accessor: string) { + const isNumeric = + currentData?.columns.find((col) => col.id === accessor || getOriginalId(col.id) === accessor) + ?.meta.type === 'number'; + + return ( + isNumeric && + currentData?.rows.every((row) => { + const val = row[accessor]; + return isValidNumber(val) || (Array.isArray(val) && val.every(isValidNumber)); + }) + ); +} diff --git a/x-pack/plugins/lens/public/datatable_visualization/visualization.tsx b/x-pack/plugins/lens/public/datatable_visualization/visualization.tsx index efde4160019e7..e48cb1b28c084 100644 --- a/x-pack/plugins/lens/public/datatable_visualization/visualization.tsx +++ b/x-pack/plugins/lens/public/datatable_visualization/visualization.tsx @@ -23,6 +23,7 @@ import { TableDimensionEditor } from './components/dimension_editor'; import { CUSTOM_PALETTE } from '../shared_components/coloring/constants'; import { CustomPaletteParams } from '../shared_components/coloring/types'; import { getStopsForFixedMode } from '../shared_components'; +import { getDefaultSummaryLabel } from './summary'; export interface ColumnState { columnId: string; @@ -38,6 +39,8 @@ export interface ColumnState { alignment?: 'left' | 'right' | 'center'; palette?: PaletteOutput; colorMode?: 'none' | 'cell' | 'text'; + summaryRow?: 'none' | 'sum' | 'avg' | 'count' | 'min' | 'max'; + summaryLabel?: string; } export interface SortingState { @@ -358,6 +361,8 @@ export const getDatatableVisualization = ({ reverse: false, // managed at UI level }; + const hasNoSummaryRow = column.summaryRow == null || column.summaryRow === 'none'; + return { type: 'expression', chain: [ @@ -376,6 +381,10 @@ export const getDatatableVisualization = ({ alignment: typeof column.alignment === 'undefined' ? [] : [column.alignment], colorMode: [column.colorMode ?? 'none'], palette: [paletteService.get(CUSTOM_PALETTE).toExpression(paletteParams)], + summaryRow: hasNoSummaryRow ? [] : [column.summaryRow!], + summaryLabel: hasNoSummaryRow + ? [] + : [column.summaryLabel ?? getDefaultSummaryLabel(column.summaryRow!)], }, }, ], diff --git a/x-pack/plugins/lens/public/shared_components/debounced_value.test.ts b/x-pack/plugins/lens/public/shared_components/debounced_value.test.ts new file mode 100644 index 0000000000000..7aa93fcad95e9 --- /dev/null +++ b/x-pack/plugins/lens/public/shared_components/debounced_value.test.ts @@ -0,0 +1,55 @@ +/* + * 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 { act, renderHook } from '@testing-library/react-hooks'; +import { useDebouncedValue } from './debounced_value'; + +jest.mock('lodash', () => { + const original = jest.requireActual('lodash'); + + return { + ...original, + debounce: (fn: unknown) => fn, + }; +}); + +describe('useDebouncedValue', () => { + it('should update upstream value changes', () => { + const onChangeMock = jest.fn(); + const { result } = renderHook(() => useDebouncedValue({ value: 'a', onChange: onChangeMock })); + + act(() => { + result.current.handleInputChange('b'); + }); + + expect(onChangeMock).toHaveBeenCalledWith('b'); + }); + + it('should fallback to initial value with empty string (by default)', () => { + const onChangeMock = jest.fn(); + const { result } = renderHook(() => useDebouncedValue({ value: 'a', onChange: onChangeMock })); + + act(() => { + result.current.handleInputChange(''); + }); + + expect(onChangeMock).toHaveBeenCalledWith('a'); + }); + + it('should allow empty input to be updated', () => { + const onChangeMock = jest.fn(); + const { result } = renderHook(() => + useDebouncedValue({ value: 'a', onChange: onChangeMock }, { allowEmptyString: true }) + ); + + act(() => { + result.current.handleInputChange(''); + }); + + expect(onChangeMock).toHaveBeenCalledWith(''); + }); +}); diff --git a/x-pack/plugins/lens/public/shared_components/debounced_value.ts b/x-pack/plugins/lens/public/shared_components/debounced_value.ts index 1f8ba0fa765b2..5525f6b16b316 100644 --- a/x-pack/plugins/lens/public/shared_components/debounced_value.ts +++ b/x-pack/plugins/lens/public/shared_components/debounced_value.ts @@ -13,15 +13,19 @@ import { debounce } from 'lodash'; * are in flight because the user is currently modifying the value. */ -export const useDebouncedValue = ({ - onChange, - value, -}: { - onChange: (val: T) => void; - value: T; -}) => { +export const useDebouncedValue = ( + { + onChange, + value, + }: { + onChange: (val: T) => void; + value: T; + }, + { allowEmptyString }: { allowEmptyString?: boolean } = {} +) => { const [inputValue, setInputValue] = useState(value); const unflushedChanges = useRef(false); + const shouldUpdateWithEmptyString = Boolean(allowEmptyString); // Save the initial value const initialValue = useRef(value); @@ -45,7 +49,10 @@ export const useDebouncedValue = ({ const handleInputChange = (val: T) => { setInputValue(val); - onChangeDebounced(val || initialValue.current); + const valueToUpload = shouldUpdateWithEmptyString + ? val ?? initialValue.current + : val || initialValue.current; + onChangeDebounced(valueToUpload); }; return { inputValue, handleInputChange, initialValue: initialValue.current }; diff --git a/x-pack/test/functional/apps/lens/table.ts b/x-pack/test/functional/apps/lens/table.ts index f048bf47991f2..f499c5bf0cfe8 100644 --- a/x-pack/test/functional/apps/lens/table.ts +++ b/x-pack/test/functional/apps/lens/table.ts @@ -143,6 +143,16 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { expect(styleObj['background-color']).to.be('rgb(168, 191, 218)'); // should also set text color when in cell mode expect(styleObj.color).to.be('rgb(0, 0, 0)'); + await PageObjects.lens.closeTablePalettePanel(); + }); + + it('should allow to show a summary table for metric columns', async () => { + await PageObjects.lens.setTableSummaryRowFunction('sum'); + await PageObjects.header.waitUntilLoadingHasFinished(); + await PageObjects.lens.assertExactText( + '[data-test-subj="lnsDataTable-footer-169.228.188.120-›-Average-of-bytes"]', + 'Sum: 18,994' + ); }); }); } diff --git a/x-pack/test/functional/page_objects/lens_page.ts b/x-pack/test/functional/page_objects/lens_page.ts index b8f1e6b3dd236..c0111afad2893 100644 --- a/x-pack/test/functional/page_objects/lens_page.ts +++ b/x-pack/test/functional/page_objects/lens_page.ts @@ -761,6 +761,20 @@ export function LensPageProvider({ getService, getPageObjects }: FtrProviderCont return buttonEl.click(); }, + async setTableSummaryRowFunction( + summaryFunction: 'none' | 'sum' | 'avg' | 'count' | 'min' | 'max' + ) { + await testSubjects.click('lnsDatatable_summaryrow_function'); + await testSubjects.click('lns-datatable-summary-' + summaryFunction); + }, + + async setTableSummaryRowLabel(newLabel: string) { + await testSubjects.setValue('lnsDatatable_summaryrow_label', newLabel, { + clearWithKeyboard: true, + typeCharByChar: true, + }); + }, + async setTableDynamicColoring(coloringType: 'none' | 'cell' | 'text') { await testSubjects.click('lnsDatatable_dynamicColoring_groups_' + coloringType); }, @@ -769,6 +783,10 @@ export function LensPageProvider({ getService, getPageObjects }: FtrProviderCont await testSubjects.click('lnsDatatable_dynamicColoring_trigger'); }, + async closeTablePalettePanel() { + await testSubjects.click('lns-indexPattern-PalettePanelContainerBack'); + }, + // different picker from the next one async changePaletteTo(paletteName: string) { await testSubjects.click('lnsDatatable_dynamicColoring_palette_picker'); From fb88c99524efb2a20d98b5c1ea1de8e27af25a70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yulia=20=C4=8Cech?= <6585477+yuliacech@users.noreply.github.com> Date: Wed, 9 Jun 2021 14:42:56 +0200 Subject: [PATCH 20/25] [ILM] Refactor types and fix missing aria labels (#101518) * Refactor phase types (mostly moving imports) * Refactor phase types (mostly moving imports) * Renamed a type for consistency and replaced more hard coded strings with types * Fixed remaining references to the deleted MinAgePhase --- .../client_integration/app/app.helpers.tsx | 2 +- .../client_integration/app/app.test.ts | 8 ++++--- .../edit_policy/edit_policy.helpers.tsx | 4 ++-- .../edit_policy/features/delete_phase.test.ts | 8 +++---- .../edit_policy/features/frozen_phase.test.ts | 2 +- .../cloud_aware_behavior.test.ts | 2 +- .../node_allocation/cold_phase.test.ts | 2 +- .../node_allocation/general_behavior.test.ts | 2 +- .../node_allocation/warm_phase.test.ts | 2 +- .../features/request_flyout.test.ts | 2 +- .../edit_policy/features/rollover.test.ts | 2 +- .../features/searchable_snapshots.test.ts | 2 +- .../edit_policy/features/timeline.test.ts | 2 +- .../edit_policy/features/warm_phase.test.ts | 2 +- .../cold_phase_validation.test.ts | 2 +- .../form_validation/error_indicators.test.ts | 2 +- .../hot_phase_validation.test.ts | 2 +- .../policy_name_validation.test.ts | 2 +- .../form_validation/timing.test.ts | 9 ++++---- .../warm_phase_validation.test.ts | 2 +- .../policy_serialization.test.ts | 4 ++-- .../helpers/actions/errors_actions.ts | 2 +- .../helpers/actions/forcemerge_actions.ts | 2 +- .../helpers/actions/freeze_actions.ts | 2 +- .../helpers/actions/index_priority_actions.ts | 2 +- .../helpers/actions/min_age_actions.ts | 2 +- .../actions/node_allocation_actions.ts | 2 +- .../helpers/actions/readonly_actions.ts | 2 +- .../actions/searchable_snapshot_actions.ts | 2 +- .../helpers/actions/set_replicas_action.ts | 2 +- .../helpers/actions/shrink_actions.ts | 2 +- .../helpers/actions/toggle_phase_action.ts | 4 ++-- .../client_integration/helpers/index.ts | 4 ++-- .../client_integration/helpers/types.ts | 10 -------- .../common/types/policies.ts | 8 +++++-- .../components/phase_footer/phase_footer.tsx | 4 ++-- .../components/phases/phase/phase.tsx | 4 ++-- .../shared_fields/index_priority_field.tsx | 7 +++--- .../min_age_field/min_age_field.tsx | 5 ++-- .../shared_fields/min_age_field/util.ts | 23 +++++++++++++------ .../components/timeline/timeline.tsx | 4 ++-- .../sections/edit_policy/form/schema.ts | 8 +++---- .../sections/edit_policy/form/validations.ts | 8 +++---- .../lib/absolute_timing_to_relative_timing.ts | 9 ++++---- .../application/sections/edit_policy/types.ts | 2 -- 45 files changed, 94 insertions(+), 91 deletions(-) delete mode 100644 x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/types.ts diff --git a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/app/app.helpers.tsx b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/app/app.helpers.tsx index 77b0372e24994..b99d828b8bbd0 100644 --- a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/app/app.helpers.tsx +++ b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/app/app.helpers.tsx @@ -8,7 +8,7 @@ import React from 'react'; import { act } from 'react-dom/test-utils'; import { registerTestBed, TestBed, TestBedConfig } from '@kbn/test/jest'; -import { KibanaContextProvider } from '../../../../../../src/plugins/kibana_react/public/context'; +import { KibanaContextProvider } from '../../../../../../src/plugins/kibana_react/public'; import { createBreadcrumbsMock } from '../../../public/application/services/breadcrumbs.mock'; import { licensingMock } from '../../../../licensing/public/mocks'; import { App } from '../../../public/application/app'; diff --git a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/app/app.test.ts b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/app/app.test.ts index 36f04be3b30b1..18af96dd2804b 100644 --- a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/app/app.test.ts +++ b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/app/app.test.ts @@ -5,15 +5,17 @@ * 2.0. */ +import { act } from 'react-dom/test-utils'; + +import { getDefaultHotPhasePolicy, POLICY_NAME } from '../edit_policy/constants'; +import { setupEnvironment } from '../helpers'; + import { AppTestBed, getDoubleEncodedPolicyEditPath, getEncodedPolicyEditPath, setup, } from './app.helpers'; -import { setupEnvironment } from '../helpers/setup_environment'; -import { getDefaultHotPhasePolicy, POLICY_NAME } from '../edit_policy/constants'; -import { act } from 'react-dom/test-utils'; const SPECIAL_CHARS_NAME = 'test?#$+=&@:'; const PERCENT_SIGN_NAME = 'test%'; diff --git a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/edit_policy.helpers.tsx b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/edit_policy.helpers.tsx index 58da73942000d..6f1c58b2e9b18 100644 --- a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/edit_policy.helpers.tsx +++ b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/edit_policy.helpers.tsx @@ -8,8 +8,9 @@ import { TestBedConfig } from '@kbn/test/jest'; import { AppServicesContext } from '../../../public/types'; +import { Phase } from '../../../common/types'; + import { - Phase, createNodeAllocationActions, createFormToggleAction, createFormSetValueAction, @@ -27,7 +28,6 @@ import { createReadonlyActions, createIndexPriorityActions, } from '../helpers'; - import { initTestBed } from './init_test_bed'; type SetupReturn = ReturnType; diff --git a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/features/delete_phase.test.ts b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/features/delete_phase.test.ts index 6403cfead8bd0..0c24101461f24 100644 --- a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/features/delete_phase.test.ts +++ b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/features/delete_phase.test.ts @@ -5,16 +5,16 @@ * 2.0. */ +import { act } from 'react-dom/test-utils'; +import { API_BASE_PATH } from '../../../../common/constants'; +import { setupEnvironment } from '../../helpers'; +import { EditPolicyTestBed, setup } from '../edit_policy.helpers'; import { DELETE_PHASE_POLICY, getDefaultHotPhasePolicy, NEW_SNAPSHOT_POLICY_NAME, SNAPSHOT_POLICY_NAME, } from '../constants'; -import { act } from 'react-dom/test-utils'; -import { EditPolicyTestBed, setup } from '../edit_policy.helpers'; -import { API_BASE_PATH } from '../../../../common/constants'; -import { setupEnvironment } from '../../helpers/setup_environment'; describe(' delete phase', () => { let testBed: EditPolicyTestBed; diff --git a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/features/frozen_phase.test.ts b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/features/frozen_phase.test.ts index 3736e9c43e269..982377e2a0365 100644 --- a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/features/frozen_phase.test.ts +++ b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/features/frozen_phase.test.ts @@ -8,7 +8,7 @@ import { act } from 'react-dom/test-utils'; import { licensingMock } from '../../../../../licensing/public/mocks'; -import { setupEnvironment } from '../../helpers/setup_environment'; +import { setupEnvironment } from '../../helpers'; import { EditPolicyTestBed, setup } from '../edit_policy.helpers'; describe(' frozen phase', () => { diff --git a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/features/node_allocation/cloud_aware_behavior.test.ts b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/features/node_allocation/cloud_aware_behavior.test.ts index 7ca68bd76759e..136865329eb50 100644 --- a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/features/node_allocation/cloud_aware_behavior.test.ts +++ b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/features/node_allocation/cloud_aware_behavior.test.ts @@ -6,7 +6,7 @@ */ import { act } from 'react-dom/test-utils'; -import { setupEnvironment } from '../../../helpers/setup_environment'; +import { setupEnvironment } from '../../../helpers'; import { CloudNodeAllocationTestBed, setupCloudNodeAllocation, diff --git a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/features/node_allocation/cold_phase.test.ts b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/features/node_allocation/cold_phase.test.ts index 3b968c1dca4ab..e2093e04b7779 100644 --- a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/features/node_allocation/cold_phase.test.ts +++ b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/features/node_allocation/cold_phase.test.ts @@ -6,7 +6,7 @@ */ import { act } from 'react-dom/test-utils'; -import { setupEnvironment } from '../../../helpers/setup_environment'; +import { setupEnvironment } from '../../../helpers'; import { NodeAllocationTestBed, setupColdPhaseNodeAllocation } from './cold_phase.helpers'; describe(' node allocation in the cold phase', () => { diff --git a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/features/node_allocation/general_behavior.test.ts b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/features/node_allocation/general_behavior.test.ts index d45e1cfe9567b..cac6c174b769e 100644 --- a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/features/node_allocation/general_behavior.test.ts +++ b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/features/node_allocation/general_behavior.test.ts @@ -6,7 +6,7 @@ */ import { act } from 'react-dom/test-utils'; -import { setupEnvironment } from '../../../helpers/setup_environment'; +import { setupEnvironment } from '../../../helpers'; import { GeneralNodeAllocationTestBed, setupGeneralNodeAllocation, diff --git a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/features/node_allocation/warm_phase.test.ts b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/features/node_allocation/warm_phase.test.ts index 1a1ed988d266e..8d4d0afcf052d 100644 --- a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/features/node_allocation/warm_phase.test.ts +++ b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/features/node_allocation/warm_phase.test.ts @@ -6,7 +6,7 @@ */ import { act } from 'react-dom/test-utils'; -import { setupEnvironment } from '../../../helpers/setup_environment'; +import { setupEnvironment } from '../../../helpers'; import { NodeAllocationTestBed, setupWarmPhaseNodeAllocation } from './warm_phase.helpers'; describe(' node allocation in the warm phase', () => { diff --git a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/features/request_flyout.test.ts b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/features/request_flyout.test.ts index de9a1b403ad33..1cb895e9ac86a 100644 --- a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/features/request_flyout.test.ts +++ b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/features/request_flyout.test.ts @@ -6,8 +6,8 @@ */ import { act } from 'react-dom/test-utils'; +import { setupEnvironment } from '../../helpers'; import { EditPolicyTestBed, setup } from '../edit_policy.helpers'; -import { setupEnvironment } from '../../helpers/setup_environment'; describe(' request flyout', () => { let testBed: EditPolicyTestBed; diff --git a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/features/rollover.test.ts b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/features/rollover.test.ts index b58fe4086c7f0..8e9586e52577b 100644 --- a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/features/rollover.test.ts +++ b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/features/rollover.test.ts @@ -7,7 +7,7 @@ import { act } from 'react-dom/test-utils'; import { licensingMock } from '../../../../../licensing/public/mocks'; -import { setupEnvironment } from '../../helpers/setup_environment'; +import { setupEnvironment } from '../../helpers'; import { EditPolicyTestBed, setup } from '../edit_policy.helpers'; describe(' rollover', () => { diff --git a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/features/searchable_snapshots.test.ts b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/features/searchable_snapshots.test.ts index 21a76b16c17ef..d400966cdae38 100644 --- a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/features/searchable_snapshots.test.ts +++ b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/features/searchable_snapshots.test.ts @@ -7,7 +7,7 @@ import { act } from 'react-dom/test-utils'; import { licensingMock } from '../../../../../licensing/public/mocks'; -import { setupEnvironment } from '../../helpers/setup_environment'; +import { setupEnvironment } from '../../helpers'; import { getDefaultHotPhasePolicy } from '../constants'; import { EditPolicyTestBed, setup } from '../edit_policy.helpers'; diff --git a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/features/timeline.test.ts b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/features/timeline.test.ts index 5a117caa99378..a4f2a24bcee8b 100644 --- a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/features/timeline.test.ts +++ b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/features/timeline.test.ts @@ -6,7 +6,7 @@ */ import { act } from 'react-dom/test-utils'; -import { setupEnvironment } from '../../helpers/setup_environment'; +import { setupEnvironment } from '../../helpers'; import { EditPolicyTestBed, setup } from '../edit_policy.helpers'; describe(' timeline', () => { diff --git a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/features/warm_phase.test.ts b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/features/warm_phase.test.ts index 8ec2f2e1b4598..ae9f306483820 100644 --- a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/features/warm_phase.test.ts +++ b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/features/warm_phase.test.ts @@ -6,7 +6,7 @@ */ import { act } from 'react-dom/test-utils'; -import { setupEnvironment } from '../../helpers/setup_environment'; +import { setupEnvironment } from '../../helpers'; import { EditPolicyTestBed, setup } from '../edit_policy.helpers'; describe(' warm phase', () => { diff --git a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/form_validation/cold_phase_validation.test.ts b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/form_validation/cold_phase_validation.test.ts index 669bcfdd34f63..9a14571c6ec3b 100644 --- a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/form_validation/cold_phase_validation.test.ts +++ b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/form_validation/cold_phase_validation.test.ts @@ -7,7 +7,7 @@ import { act } from 'react-dom/test-utils'; import { i18nTexts } from '../../../../public/application/sections/edit_policy/i18n_texts'; -import { setupEnvironment } from '../../helpers/setup_environment'; +import { setupEnvironment } from '../../helpers'; import { EditPolicyTestBed, setup } from '../edit_policy.helpers'; describe(' cold phase validation', () => { diff --git a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/form_validation/error_indicators.test.ts b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/form_validation/error_indicators.test.ts index 5c70a9025df67..0a047714bd345 100644 --- a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/form_validation/error_indicators.test.ts +++ b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/form_validation/error_indicators.test.ts @@ -6,7 +6,7 @@ */ import { act } from 'react-dom/test-utils'; -import { setupEnvironment } from '../../helpers/setup_environment'; +import { setupEnvironment } from '../../helpers'; import { EditPolicyTestBed, setup } from '../edit_policy.helpers'; describe(' error indicators', () => { diff --git a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/form_validation/hot_phase_validation.test.ts b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/form_validation/hot_phase_validation.test.ts index 879aab872b19b..296b128eb8f52 100644 --- a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/form_validation/hot_phase_validation.test.ts +++ b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/form_validation/hot_phase_validation.test.ts @@ -7,7 +7,7 @@ import { act } from 'react-dom/test-utils'; import { i18nTexts } from '../../../../public/application/sections/edit_policy/i18n_texts'; -import { setupEnvironment } from '../../helpers/setup_environment'; +import { setupEnvironment } from '../../helpers'; import { EditPolicyTestBed, setup } from '../edit_policy.helpers'; describe(' hot phase validation', () => { diff --git a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/form_validation/policy_name_validation.test.ts b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/form_validation/policy_name_validation.test.ts index 41d2b6d166dce..08b794466da49 100644 --- a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/form_validation/policy_name_validation.test.ts +++ b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/form_validation/policy_name_validation.test.ts @@ -7,7 +7,7 @@ import { act } from 'react-dom/test-utils'; import { i18nTexts } from '../../../../public/application/sections/edit_policy/i18n_texts'; -import { setupEnvironment } from '../../helpers/setup_environment'; +import { setupEnvironment } from '../../helpers'; import { EditPolicyTestBed, setup } from '../edit_policy.helpers'; import { getGeneratedPolicies } from '../constants'; diff --git a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/form_validation/timing.test.ts b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/form_validation/timing.test.ts index c164605e5cd4b..ac11e8a162e02 100644 --- a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/form_validation/timing.test.ts +++ b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/form_validation/timing.test.ts @@ -8,8 +8,9 @@ import { act } from 'react-dom/test-utils'; import { i18nTexts } from '../../../../public/application/sections/edit_policy/i18n_texts'; +import { PhaseWithTiming } from '../../../../common/types'; +import { setupEnvironment } from '../../helpers'; import { EditPolicyTestBed, setup } from '../edit_policy.helpers'; -import { setupEnvironment } from '../../helpers/setup_environment'; describe(' timing validation', () => { let testBed: EditPolicyTestBed; @@ -69,12 +70,12 @@ describe(' timing validation', () => { ['warm', 'cold', 'delete', 'frozen'].forEach((phase: string) => { const { name, value, error } = testConfig; test(`${phase}: ${name}`, async () => { - await actions.togglePhase(phase as 'warm' | 'cold' | 'delete' | 'frozen'); + await actions.togglePhase(phase as PhaseWithTiming); // 1. We first set as dummy value to have a starting min_age value - await actions[phase as 'warm' | 'cold' | 'delete' | 'frozen'].setMinAgeValue('111'); + await actions[phase as PhaseWithTiming].setMinAgeValue('111'); // 2. At this point we are sure there will be a change of value and that any validation // will be displayed under the field. - await actions[phase as 'warm' | 'cold' | 'delete' | 'frozen'].setMinAgeValue(value); + await actions[phase as PhaseWithTiming].setMinAgeValue(value); actions.errors.waitForValidation(); diff --git a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/form_validation/warm_phase_validation.test.ts b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/form_validation/warm_phase_validation.test.ts index 70794491d4edd..bef99ea8cb891 100644 --- a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/form_validation/warm_phase_validation.test.ts +++ b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/form_validation/warm_phase_validation.test.ts @@ -7,7 +7,7 @@ import { act } from 'react-dom/test-utils'; import { i18nTexts } from '../../../../public/application/sections/edit_policy/i18n_texts'; -import { setupEnvironment } from '../../helpers/setup_environment'; +import { setupEnvironment } from '../../helpers'; import { EditPolicyTestBed, setup } from '../edit_policy.helpers'; describe(' warm phase validation', () => { diff --git a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/serialization/policy_serialization.test.ts b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/serialization/policy_serialization.test.ts index dfc81e9e0d9d7..8c345cf784f9f 100644 --- a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/serialization/policy_serialization.test.ts +++ b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/serialization/policy_serialization.test.ts @@ -6,14 +6,14 @@ */ import { act } from 'react-dom/test-utils'; -import { setupEnvironment } from '../../helpers/setup_environment'; +import { licensingMock } from '../../../../../licensing/public/mocks'; +import { setupEnvironment } from '../../helpers'; import { getDefaultHotPhasePolicy, POLICY_WITH_INCLUDE_EXCLUDE, POLICY_WITH_KNOWN_AND_UNKNOWN_FIELDS, } from '../constants'; import { EditPolicyTestBed, setup } from '../edit_policy.helpers'; -import { licensingMock } from '../../../../../licensing/public/mocks'; describe(' serialization', () => { let testBed: EditPolicyTestBed; diff --git a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/errors_actions.ts b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/errors_actions.ts index 8d5708950a75f..a92747a95a2ca 100644 --- a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/errors_actions.ts +++ b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/errors_actions.ts @@ -7,7 +7,7 @@ import { act } from 'react-dom/test-utils'; import { TestBed } from '@kbn/test/jest'; -import { Phase } from '../types'; +import { Phase } from '../../../../common/types'; const createWaitForValidationAction = (testBed: TestBed) => () => { const { component } = testBed; diff --git a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/forcemerge_actions.ts b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/forcemerge_actions.ts index 61b16d18648f5..a7e4983165bac 100644 --- a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/forcemerge_actions.ts +++ b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/forcemerge_actions.ts @@ -7,9 +7,9 @@ import { act } from 'react-dom/test-utils'; import { TestBed } from '@kbn/test/jest'; +import { Phase } from '../../../../common/types'; import { createFormToggleAction } from './form_toggle_action'; import { createFormSetValueAction } from './form_set_value_action'; -import { Phase } from '../types'; const createFormCheckboxAction = (testBed: TestBed, dataTestSubject: string) => async ( checked: boolean diff --git a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/freeze_actions.ts b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/freeze_actions.ts index 87b03ff4e1deb..ad3d9d3bfbcb8 100644 --- a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/freeze_actions.ts +++ b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/freeze_actions.ts @@ -6,8 +6,8 @@ */ import { TestBed } from '@kbn/test/jest'; +import { Phase } from '../../../../common/types'; import { createFormToggleAction } from './form_toggle_action'; -import { Phase } from '../types'; export const createFreezeActions = (testBed: TestBed, phase: Phase) => { const { exists } = testBed; diff --git a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/index_priority_actions.ts b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/index_priority_actions.ts index a0423c12be5c3..3b48da2a0c69f 100644 --- a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/index_priority_actions.ts +++ b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/index_priority_actions.ts @@ -6,9 +6,9 @@ */ import { TestBed } from '@kbn/test/jest'; +import { Phase } from '../../../../common/types'; import { createFormToggleAction } from './form_toggle_action'; import { createFormSetValueAction } from './form_set_value_action'; -import { Phase } from '../types'; export const createIndexPriorityActions = (testBed: TestBed, phase: Phase) => { const { exists } = testBed; diff --git a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/min_age_actions.ts b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/min_age_actions.ts index 4a2491f3561ee..551474c8b16e6 100644 --- a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/min_age_actions.ts +++ b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/min_age_actions.ts @@ -6,8 +6,8 @@ */ import { TestBed } from '@kbn/test/jest'; +import { Phase } from '../../../../common/types'; import { createFormSetValueAction } from './form_set_value_action'; -import { Phase } from '../types'; export const createMinAgeActions = (testBed: TestBed, phase: Phase) => { const { exists } = testBed; diff --git a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/node_allocation_actions.ts b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/node_allocation_actions.ts index b4b97b7c88a5e..7c0f8fea7299d 100644 --- a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/node_allocation_actions.ts +++ b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/node_allocation_actions.ts @@ -9,7 +9,7 @@ import { act } from 'react-dom/test-utils'; import { TestBed } from '@kbn/test/jest'; import { DataTierAllocationType } from '../../../../public/application/sections/edit_policy/types'; -import { Phase } from '../types'; +import { Phase } from '../../../../common/types'; import { createFormSetValueAction } from './form_set_value_action'; export const createNodeAllocationActions = (testBed: TestBed, phase: Phase) => { diff --git a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/readonly_actions.ts b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/readonly_actions.ts index ee9161c91209e..b76143eccf1f2 100644 --- a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/readonly_actions.ts +++ b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/readonly_actions.ts @@ -6,8 +6,8 @@ */ import { TestBed } from '@kbn/test/jest'; +import { Phase } from '../../../../common/types'; import { createFormToggleAction } from './form_toggle_action'; -import { Phase } from '../types'; export const createReadonlyActions = (testBed: TestBed, phase: Phase) => { const { exists } = testBed; diff --git a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/searchable_snapshot_actions.ts b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/searchable_snapshot_actions.ts index d7ccd32694759..f1a64c3943511 100644 --- a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/searchable_snapshot_actions.ts +++ b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/searchable_snapshot_actions.ts @@ -7,7 +7,7 @@ import { act } from 'react-dom/test-utils'; import { TestBed } from '@kbn/test/jest'; -import { Phase } from '../types'; +import { Phase } from '../../../../common/types'; import { createFormToggleAction } from './form_toggle_action'; export const createSearchableSnapshotActions = (testBed: TestBed, phase: Phase) => { diff --git a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/set_replicas_action.ts b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/set_replicas_action.ts index cabd3012001b7..b07d7783379fb 100644 --- a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/set_replicas_action.ts +++ b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/set_replicas_action.ts @@ -7,7 +7,7 @@ import { TestBed } from '@kbn/test/jest'; -import { Phase } from '../types'; +import { Phase } from '../../../../common/types'; import { createFormToggleAction } from './form_toggle_action'; import { createFormSetValueAction } from './form_set_value_action'; diff --git a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/shrink_actions.ts b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/shrink_actions.ts index 9d227ef2624a4..0531850384124 100644 --- a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/shrink_actions.ts +++ b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/shrink_actions.ts @@ -6,9 +6,9 @@ */ import { TestBed } from '@kbn/test/jest'; +import { Phase } from '../../../../common/types'; import { createFormToggleAction } from './form_toggle_action'; import { createFormSetValueAction } from './form_set_value_action'; -import { Phase } from '../types'; export const createShrinkActions = (testBed: TestBed, phase: Phase) => { const { exists } = testBed; diff --git a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/toggle_phase_action.ts b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/toggle_phase_action.ts index fb1575d05bdef..a0bed0e1644e6 100644 --- a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/toggle_phase_action.ts +++ b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/toggle_phase_action.ts @@ -6,9 +6,9 @@ */ import { TestBed } from '@kbn/test/jest'; - import { act } from 'react-dom/test-utils'; -import { Phase } from '../types'; + +import { Phase } from '../../../../common/types'; const toggleDeletePhase = async (testBed: TestBed) => { const { find, component } = testBed; diff --git a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/index.ts b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/index.ts index 5b2e1827cd6e8..f9cd1f27b72be 100644 --- a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/index.ts +++ b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/index.ts @@ -5,6 +5,6 @@ * 2.0. */ -export { Phase } from './types'; - export * from './actions'; + +export { setupEnvironment } from './setup_environment'; diff --git a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/types.ts b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/types.ts deleted file mode 100644 index 644ada96a9f05..0000000000000 --- a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/types.ts +++ /dev/null @@ -1,10 +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 { Phases } from '../../../common/types'; - -export type Phase = keyof Phases; diff --git a/x-pack/plugins/index_lifecycle_management/common/types/policies.ts b/x-pack/plugins/index_lifecycle_management/common/types/policies.ts index 385751f31d5bc..b08f87e5a172b 100644 --- a/x-pack/plugins/index_lifecycle_management/common/types/policies.ts +++ b/x-pack/plugins/index_lifecycle_management/common/types/policies.ts @@ -7,8 +7,14 @@ import { Index as IndexInterface } from '../../../index_management/common/types'; +export type Phase = keyof Phases; + export type PhaseWithAllocation = 'warm' | 'cold'; +export type PhaseWithTiming = keyof Omit; + +export type PhaseExceptDelete = keyof Omit; + export interface SerializedPolicy { name: string; phases: Phases; @@ -22,8 +28,6 @@ export interface Phases { delete?: SerializedDeletePhase; } -export type PhasesExceptDelete = keyof Omit; - export interface PolicyFromES { modified_date: string; name: string; diff --git a/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/phase_footer/phase_footer.tsx b/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/phase_footer/phase_footer.tsx index 22422ceab8a04..0428c2939050d 100644 --- a/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/phase_footer/phase_footer.tsx +++ b/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/phase_footer/phase_footer.tsx @@ -11,7 +11,7 @@ import { i18n } from '@kbn/i18n'; import { EuiText, EuiButtonGroup, EuiFlexGroup, EuiFlexItem } from '@elastic/eui'; -import { PhasesExceptDelete } from '../../../../../../common/types'; +import { PhaseExceptDelete } from '../../../../../../common/types'; import { usePhaseTimings } from '../../form'; @@ -32,7 +32,7 @@ const keepDataLabel = i18n.translate( ); interface Props { - phase: PhasesExceptDelete; + phase: PhaseExceptDelete; } export const PhaseFooter: FunctionComponent = ({ phase }) => { diff --git a/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/phases/phase/phase.tsx b/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/phases/phase/phase.tsx index 040baf3625eb8..f5ab67c0b3ee7 100644 --- a/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/phases/phase/phase.tsx +++ b/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/phases/phase/phase.tsx @@ -20,7 +20,7 @@ import { import { get } from 'lodash'; import { FormattedMessage } from '@kbn/i18n/react'; -import { PhasesExceptDelete } from '../../../../../../../common/types'; +import { PhaseExceptDelete } from '../../../../../../../common/types'; import { ToggleField, useFormData } from '../../../../../../shared_imports'; import { i18nTexts } from '../../../i18n_texts'; import { FormInternal } from '../../../types'; @@ -33,7 +33,7 @@ import { PhaseErrorIndicator } from './phase_error_indicator'; import './phase.scss'; interface Props { - phase: PhasesExceptDelete; + phase: PhaseExceptDelete; /** * Settings that should always be visible on the phase when it is enabled. */ diff --git a/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/phases/shared_fields/index_priority_field.tsx b/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/phases/shared_fields/index_priority_field.tsx index 47d2aa6ba92df..0f5288df36119 100644 --- a/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/phases/shared_fields/index_priority_field.tsx +++ b/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/phases/shared_fields/index_priority_field.tsx @@ -10,15 +10,16 @@ import React, { FunctionComponent, useMemo } from 'react'; import { FormattedMessage } from '@kbn/i18n/react'; import { EuiSpacer, EuiTextColor } from '@elastic/eui'; -import { NumericField } from '../../../../../../shared_imports'; +import { PhaseExceptDelete } from '../../../../../../../common/types'; +import { NumericField } from '../../../../../../shared_imports'; import { useEditPolicyContext } from '../../../edit_policy_context'; -import { UseField } from '../../../form'; +import { UseField } from '../../../form'; import { LearnMoreLink, DescribedFormRow } from '../..'; interface Props { - phase: 'hot' | 'warm' | 'cold' | 'frozen'; + phase: PhaseExceptDelete; } export const IndexPriorityField: FunctionComponent = ({ phase }) => { diff --git a/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/phases/shared_fields/min_age_field/min_age_field.tsx b/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/phases/shared_fields/min_age_field/min_age_field.tsx index 136a37140cca7..ad92ef2d44479 100644 --- a/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/phases/shared_fields/min_age_field/min_age_field.tsx +++ b/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/phases/shared_fields/min_age_field/min_age_field.tsx @@ -21,13 +21,12 @@ import { EuiIconTip, } from '@elastic/eui'; +import { PhaseWithTiming } from '../../../../../../../../common/types'; import { getFieldValidityAndErrorMessage, useFormData } from '../../../../../../../shared_imports'; import { UseField, useConfiguration, useGlobalFields } from '../../../../form'; import { getPhaseMinAgeInMilliseconds } from '../../../../lib'; import { getUnitsAriaLabelForPhase, getTimingLabelForPhase } from './util'; -type PhaseWithMinAgeAction = 'warm' | 'cold' | 'delete'; - const i18nTexts = { daysOptionLabel: i18n.translate('xpack.indexLifecycleMgmt.editPolicy.daysOptionLabel', { defaultMessage: 'days', @@ -77,7 +76,7 @@ const i18nTexts = { }; interface Props { - phase: PhaseWithMinAgeAction; + phase: PhaseWithTiming; } export const MinAgeField: FunctionComponent = ({ phase }): React.ReactElement => { diff --git a/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/phases/shared_fields/min_age_field/util.ts b/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/phases/shared_fields/min_age_field/util.ts index a626a0a62f551..5f1b98c6dbda2 100644 --- a/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/phases/shared_fields/min_age_field/util.ts +++ b/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/phases/shared_fields/min_age_field/util.ts @@ -6,12 +6,9 @@ */ import { i18n } from '@kbn/i18n'; -import { Phases } from '../../../../../../../../common/types'; +import { PhaseWithTiming } from '../../../../../../../../common/types'; -type PhaseWithMinAgeAction = 'warm' | 'cold' | 'delete'; - -export function getUnitsAriaLabelForPhase(phase: keyof Phases) { - // NOTE: Hot phase isn't necessary, because indices begin in the hot phase. +export function getUnitsAriaLabelForPhase(phase: PhaseWithTiming) { switch (phase) { case 'warm': return i18n.translate( @@ -29,6 +26,14 @@ export function getUnitsAriaLabelForPhase(phase: keyof Phases) { } ); + case 'frozen': + return i18n.translate( + 'xpack.indexLifecycleMgmt.editPolicy.phaseFrozen.minimumAgeUnitsAriaLabel', + { + defaultMessage: 'Units for timing of frozen phase', + } + ); + case 'delete': return i18n.translate( 'xpack.indexLifecycleMgmt.editPolicy.phaseDelete.minimumAgeUnitsAriaLabel', @@ -38,8 +43,7 @@ export function getUnitsAriaLabelForPhase(phase: keyof Phases) { ); } } -export function getTimingLabelForPhase(phase: PhaseWithMinAgeAction) { - // NOTE: Hot phase isn't necessary, because indices begin in the hot phase. +export function getTimingLabelForPhase(phase: PhaseWithTiming) { switch (phase) { case 'warm': return i18n.translate('xpack.indexLifecycleMgmt.editPolicy.phaseWarm.minimumAgeLabel', { @@ -51,6 +55,11 @@ export function getTimingLabelForPhase(phase: PhaseWithMinAgeAction) { defaultMessage: 'Timing for cold phase', }); + case 'frozen': + return i18n.translate('xpack.indexLifecycleMgmt.editPolicy.phaseFrozen.minimumAgeLabel', { + defaultMessage: 'Timing for frozen phase', + }); + case 'delete': return i18n.translate('xpack.indexLifecycleMgmt.editPolicy.phaseDelete.minimumAgeLabel', { defaultMessage: 'Timing for delete phase', diff --git a/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/timeline/timeline.tsx b/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/timeline/timeline.tsx index 6edc6568ef766..de5c258ab82fa 100644 --- a/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/timeline/timeline.tsx +++ b/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/timeline/timeline.tsx @@ -11,7 +11,7 @@ import { FormattedMessage } from '@kbn/i18n/react'; import React, { FunctionComponent, memo } from 'react'; import { EuiFlexGroup, EuiFlexItem, EuiTitle, EuiText, EuiIconTip } from '@elastic/eui'; -import { PhasesExceptDelete } from '../../../../../../common/types'; +import { PhaseExceptDelete } from '../../../../../../common/types'; import { calculateRelativeFromAbsoluteMilliseconds, @@ -136,7 +136,7 @@ export const Timeline: FunctionComponent = memo( const widths = calculateWidths(phaseAgeInMilliseconds); - const getDurationInPhaseContent = (phase: PhasesExceptDelete): string | React.ReactNode => + const getDurationInPhaseContent = (phase: PhaseExceptDelete): string | React.ReactNode => phaseAgeInMilliseconds.phases[phase] === Infinity ? ( ) : null; diff --git a/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/form/schema.ts b/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/form/schema.ts index f24d350432d80..c26f54cbb6f5a 100644 --- a/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/form/schema.ts +++ b/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/form/schema.ts @@ -7,10 +7,10 @@ import { i18n } from '@kbn/i18n'; +import { PhaseExceptDelete, PhaseWithTiming } from '../../../../../common/types'; import { FormSchema, fieldValidators } from '../../../../shared_imports'; import { defaultIndexPriority } from '../../../constants'; import { ROLLOVER_FORM_PATHS, CLOUD_DEFAULT_REPO } from '../constants'; -import { MinAgePhase } from '../types'; import { i18nTexts } from '../i18n_texts'; import { ifExistsNumberGreaterThanZero, @@ -107,8 +107,8 @@ const numberOfShardsField = { serializer: serializers.stringToNumber, }; -const getPriorityField = (phase: 'hot' | 'warm' | 'cold' | 'frozen') => ({ - defaultValue: defaultIndexPriority[phase] as any, +const getPriorityField = (phase: PhaseExceptDelete) => ({ + defaultValue: defaultIndexPriority[phase], label: i18nTexts.editPolicy.indexPriorityFieldLabel, validations: [ { @@ -119,7 +119,7 @@ const getPriorityField = (phase: 'hot' | 'warm' | 'cold' | 'frozen') => ({ serializer: serializers.stringToNumber, }); -const getMinAgeField = (phase: MinAgePhase, defaultValue?: string) => ({ +const getMinAgeField = (phase: PhaseWithTiming, defaultValue?: string) => ({ defaultValue, // By passing an empty array we make sure to *not* trigger the validation when the field value changes. // The validation will be triggered when the millisecond variant (in the _meta) is updated (in sync) diff --git a/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/form/validations.ts b/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/form/validations.ts index b39b3f3cd4226..892e40f80f4b8 100644 --- a/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/form/validations.ts +++ b/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/form/validations.ts @@ -16,8 +16,8 @@ import { import { ROLLOVER_FORM_PATHS } from '../constants'; import { i18nTexts } from '../i18n_texts'; -import { PolicyFromES } from '../../../../../common/types'; -import { FormInternal, MinAgePhase } from '../types'; +import { PhaseWithTiming, PolicyFromES } from '../../../../../common/types'; +import { FormInternal } from '../types'; const { numberGreaterThanField, containsCharsField, emptyField, startsWithField } = fieldValidators; @@ -164,7 +164,7 @@ export const createPolicyNameValidations = ({ * For example, the user can't define '5 days' for cold phase if the * warm phase is set to '10 days'. */ -export const minAgeGreaterThanPreviousPhase = (phase: MinAgePhase) => ({ +export const minAgeGreaterThanPreviousPhase = (phase: PhaseWithTiming) => ({ formData, }: { formData: Record; @@ -173,7 +173,7 @@ export const minAgeGreaterThanPreviousPhase = (phase: MinAgePhase) => ({ return; } - const getValueFor = (_phase: MinAgePhase) => { + const getValueFor = (_phase: PhaseWithTiming) => { const milli = formData[`_meta.${_phase}.minAgeToMilliSeconds`]; const esFormat = diff --git a/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/lib/absolute_timing_to_relative_timing.ts b/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/lib/absolute_timing_to_relative_timing.ts index 9d55f542db4c4..71e2741c27cdc 100644 --- a/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/lib/absolute_timing_to_relative_timing.ts +++ b/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/lib/absolute_timing_to_relative_timing.ts @@ -22,17 +22,16 @@ import moment from 'moment'; -import { splitSizeAndUnits } from '../../../lib/policies'; +import { Phase, PhaseWithTiming } from '../../../../../common/types'; -import { FormInternal, MinAgePhase } from '../types'; +import { splitSizeAndUnits } from '../../../lib/policies'; +import { FormInternal } from '../types'; /* -===- Private functions and types -===- */ -type Phase = 'hot' | MinAgePhase; - const phaseOrder: Phase[] = ['hot', 'warm', 'cold', 'frozen', 'delete']; -const getMinAge = (phase: MinAgePhase, formData: FormInternal) => ({ +const getMinAge = (phase: PhaseWithTiming, formData: FormInternal) => ({ min_age: formData.phases?.[phase]?.min_age ? formData.phases[phase]!.min_age! + formData._meta[phase].minAgeUnit : '0ms', diff --git a/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/types.ts b/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/types.ts index 987cbbcfde45b..ba7d31cf6da49 100644 --- a/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/types.ts +++ b/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/types.ts @@ -18,8 +18,6 @@ export interface MinAgeField { minAgeToMilliSeconds: number; } -export type MinAgePhase = 'warm' | 'cold' | 'frozen' | 'delete'; - export interface ForcemergeFields { bestCompression: boolean; } From edc5251433f8505d4266326567ea11702ee9b236 Mon Sep 17 00:00:00 2001 From: Anton Dosov Date: Wed, 9 Jun 2021 15:00:39 +0200 Subject: [PATCH 21/25] [Index Patterns] Runtime fields CRUD REST API (#101164) Part of index pattern REST API --- docs/api/index-patterns.asciidoc | 12 ++ docs/api/index-patterns/create.asciidoc | 1 + docs/api/index-patterns/get.asciidoc | 1 + .../runtime-fields/create.asciidoc | 61 +++++++++ .../runtime-fields/delete.asciidoc | 37 ++++++ .../runtime-fields/get.asciidoc | 52 ++++++++ .../runtime-fields/update.asciidoc | 66 ++++++++++ .../runtime-fields/upsert.asciidoc | 61 +++++++++ docs/api/index-patterns/update.asciidoc | 3 +- ...ata-public.indexpattern.getruntimefield.md | 24 ++++ ...ata-public.indexpattern.hasruntimefield.md | 24 ++++ ...plugin-plugins-data-public.indexpattern.md | 5 +- ...-public.indexpattern.removeruntimefield.md | 4 +- ...ic.indexpattern.replaceallruntimefields.md | 24 ++++ ...ata-server.indexpattern.getruntimefield.md | 24 ++++ ...ata-server.indexpattern.hasruntimefield.md | 24 ++++ ...plugin-plugins-data-server.indexpattern.md | 5 +- ...-server.indexpattern.removeruntimefield.md | 4 +- ...er.indexpattern.replaceallruntimefields.md | 24 ++++ .../index_patterns/index_pattern.ts | 40 +++++- src/plugins/data/public/public.api.md | 3 + .../data/server/index_patterns/routes.ts | 12 ++ .../routes/create_index_pattern.ts | 8 +- .../runtime_fields/create_runtime_field.ts | 74 +++++++++++ .../runtime_fields/delete_runtime_field.ts | 64 +++++++++ .../runtime_fields/get_runtime_field.ts | 67 ++++++++++ .../runtime_fields/put_runtime_field.ts | 76 +++++++++++ .../runtime_fields/update_runtime_field.ts | 84 ++++++++++++ .../routes/update_index_pattern.ts | 13 +- .../index_patterns/routes/util/schemas.ts | 25 +++- src/plugins/data/server/server.api.md | 3 + .../fields_api/update_fields/main.ts | 1 + .../apis/index_patterns/index.js | 2 + .../create_index_pattern/main.ts | 28 +++- .../create_index_pattern/validation.ts | 20 +++ .../update_index_pattern/main.ts | 48 +++++++ .../apis/index_patterns/integration/index.ts | 18 +++ .../index_patterns/integration/integration.ts | 119 +++++++++++++++++ .../create_runtime_field/errors.ts | 35 +++++ .../create_runtime_field/index.ts | 16 +++ .../create_runtime_field/main.ts | 95 ++++++++++++++ .../delete_runtime_field/errors.ts | 81 ++++++++++++ .../delete_runtime_field/index.ts | 16 +++ .../delete_runtime_field/main.ts | 66 ++++++++++ .../get_runtime_field/errors.ts | 81 ++++++++++++ .../get_runtime_field/index.ts | 16 +++ .../get_runtime_field/main.ts | 71 ++++++++++ .../runtime_fields_crud/index.ts | 19 +++ .../put_runtime_field/errors.ts | 69 ++++++++++ .../put_runtime_field/index.ts | 16 +++ .../put_runtime_field/main.ts | 122 ++++++++++++++++++ .../update_runtime_field/errors.ts | 51 ++++++++ .../update_runtime_field/index.ts | 16 +++ .../update_runtime_field/main.ts | 76 +++++++++++ .../create_scripted_field/main.ts | 1 + .../delete_scripted_field/main.ts | 1 + .../get_scripted_field/main.ts | 1 + .../put_scripted_field/main.ts | 1 + .../update_scripted_field/main.ts | 1 + 59 files changed, 1993 insertions(+), 19 deletions(-) create mode 100644 docs/api/index-patterns/runtime-fields/create.asciidoc create mode 100644 docs/api/index-patterns/runtime-fields/delete.asciidoc create mode 100644 docs/api/index-patterns/runtime-fields/get.asciidoc create mode 100644 docs/api/index-patterns/runtime-fields/update.asciidoc create mode 100644 docs/api/index-patterns/runtime-fields/upsert.asciidoc create mode 100644 docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpattern.getruntimefield.md create mode 100644 docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpattern.hasruntimefield.md create mode 100644 docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpattern.replaceallruntimefields.md create mode 100644 docs/development/plugins/data/server/kibana-plugin-plugins-data-server.indexpattern.getruntimefield.md create mode 100644 docs/development/plugins/data/server/kibana-plugin-plugins-data-server.indexpattern.hasruntimefield.md create mode 100644 docs/development/plugins/data/server/kibana-plugin-plugins-data-server.indexpattern.replaceallruntimefields.md create mode 100644 src/plugins/data/server/index_patterns/routes/runtime_fields/create_runtime_field.ts create mode 100644 src/plugins/data/server/index_patterns/routes/runtime_fields/delete_runtime_field.ts create mode 100644 src/plugins/data/server/index_patterns/routes/runtime_fields/get_runtime_field.ts create mode 100644 src/plugins/data/server/index_patterns/routes/runtime_fields/put_runtime_field.ts create mode 100644 src/plugins/data/server/index_patterns/routes/runtime_fields/update_runtime_field.ts create mode 100644 test/api_integration/apis/index_patterns/integration/index.ts create mode 100644 test/api_integration/apis/index_patterns/integration/integration.ts create mode 100644 test/api_integration/apis/index_patterns/runtime_fields_crud/create_runtime_field/errors.ts create mode 100644 test/api_integration/apis/index_patterns/runtime_fields_crud/create_runtime_field/index.ts create mode 100644 test/api_integration/apis/index_patterns/runtime_fields_crud/create_runtime_field/main.ts create mode 100644 test/api_integration/apis/index_patterns/runtime_fields_crud/delete_runtime_field/errors.ts create mode 100644 test/api_integration/apis/index_patterns/runtime_fields_crud/delete_runtime_field/index.ts create mode 100644 test/api_integration/apis/index_patterns/runtime_fields_crud/delete_runtime_field/main.ts create mode 100644 test/api_integration/apis/index_patterns/runtime_fields_crud/get_runtime_field/errors.ts create mode 100644 test/api_integration/apis/index_patterns/runtime_fields_crud/get_runtime_field/index.ts create mode 100644 test/api_integration/apis/index_patterns/runtime_fields_crud/get_runtime_field/main.ts create mode 100644 test/api_integration/apis/index_patterns/runtime_fields_crud/index.ts create mode 100644 test/api_integration/apis/index_patterns/runtime_fields_crud/put_runtime_field/errors.ts create mode 100644 test/api_integration/apis/index_patterns/runtime_fields_crud/put_runtime_field/index.ts create mode 100644 test/api_integration/apis/index_patterns/runtime_fields_crud/put_runtime_field/main.ts create mode 100644 test/api_integration/apis/index_patterns/runtime_fields_crud/update_runtime_field/errors.ts create mode 100644 test/api_integration/apis/index_patterns/runtime_fields_crud/update_runtime_field/index.ts create mode 100644 test/api_integration/apis/index_patterns/runtime_fields_crud/update_runtime_field/main.ts diff --git a/docs/api/index-patterns.asciidoc b/docs/api/index-patterns.asciidoc index 79d2f164fb8c3..b343d80b4fc15 100644 --- a/docs/api/index-patterns.asciidoc +++ b/docs/api/index-patterns.asciidoc @@ -20,6 +20,12 @@ The following index patterns APIs are available: ** <> to set a default index pattern * Fields ** <> to change field metadata, such as `count`, `customLabel` and `format` +* Runtime fields + ** <> to retrieve a runtime field + ** <> to create a runtime field + ** <> to create or update a runtime field + ** <> to partially update an existing runtime field + ** <> to delete a runtime field include::index-patterns/get.asciidoc[] include::index-patterns/create.asciidoc[] @@ -28,3 +34,9 @@ include::index-patterns/delete.asciidoc[] include::index-patterns/default-get.asciidoc[] include::index-patterns/default-set.asciidoc[] include::index-patterns/update-fields.asciidoc[] +include::index-patterns/runtime-fields/get.asciidoc[] +include::index-patterns/runtime-fields/create.asciidoc[] +include::index-patterns/runtime-fields/upsert.asciidoc[] +include::index-patterns/runtime-fields/update.asciidoc[] +include::index-patterns/runtime-fields/delete.asciidoc[] + diff --git a/docs/api/index-patterns/create.asciidoc b/docs/api/index-patterns/create.asciidoc index 771292d6f934d..521e25931ad49 100644 --- a/docs/api/index-patterns/create.asciidoc +++ b/docs/api/index-patterns/create.asciidoc @@ -84,6 +84,7 @@ $ curl -X POST api/index_patterns/index_pattern "typeMeta": {}, "fieldFormats": {}, "fieldAttrs": {}, + "runtimeFieldMap": {} "allowNoIndex": "..." } } diff --git a/docs/api/index-patterns/get.asciidoc b/docs/api/index-patterns/get.asciidoc index 3f53bf0726bf1..64588e63f62ae 100644 --- a/docs/api/index-patterns/get.asciidoc +++ b/docs/api/index-patterns/get.asciidoc @@ -58,6 +58,7 @@ The API returns an index pattern object: "typeMeta": {}, "fieldFormats": {}, "fieldAttrs": {}, + "runtimeFieldMap" {}, "allowNoIndex: "..." } } diff --git a/docs/api/index-patterns/runtime-fields/create.asciidoc b/docs/api/index-patterns/runtime-fields/create.asciidoc new file mode 100644 index 0000000000000..b0773c29e5309 --- /dev/null +++ b/docs/api/index-patterns/runtime-fields/create.asciidoc @@ -0,0 +1,61 @@ +[[index-patterns-runtime-field-api-create]] +=== Create runtime field API +++++ +Create runtime field +++++ + +experimental[] Create a runtime field + +[[index-patterns-runtime-field-create-request]] +==== Request + +`POST :/api/index_patterns/index_pattern//runtime_field` + +`POST :/s//api/index_patterns/index_pattern//runtime_field` + +[[index-patterns-runtime-field-create-params]] +==== Path parameters + +`space_id`:: +(Optional, string) An identifier for the space. If `space_id` is not provided in the URL, the default space is used. + +`index_pattern_id`:: +(Required, string) The ID of the index pattern. + +[[index-patterns-runtime-field-create-body]] +==== Request body + +`name`:: (Required, string) The name for a runtime field. + +`runtimeField`:: (Required, object) The runtime field definition object. + + +[[index-patterns-runtime-field-create-example]] +==== Examples + +Create a runtime field on an index pattern: + +[source,sh] +-------------------------------------------------- +$ curl -X POST api/index_patterns/index_pattern//runtime_field +{ + "name": "runtimeFoo", + "runtimeField": { + "type": "long", + "script": { + "source": "emit(doc["foo"].value)" + } + } +} +-------------------------------------------------- +// KIBANA + +The API returns created runtime field object and update index pattern object: + +[source,sh] +-------------------------------------------------- +{ + "index_pattern": {...}, + "field": {...} +} +-------------------------------------------------- diff --git a/docs/api/index-patterns/runtime-fields/delete.asciidoc b/docs/api/index-patterns/runtime-fields/delete.asciidoc new file mode 100644 index 0000000000000..840789fe1ec23 --- /dev/null +++ b/docs/api/index-patterns/runtime-fields/delete.asciidoc @@ -0,0 +1,37 @@ +[[index-patterns-runtime-field-api-delete]] +=== Delete runtime field API +++++ +Delete runtime field +++++ + +experimental[] Delete a runtime field from an index pattern. + +[[index-patterns-runtime-field-api-delete-request]] +==== Request + +`DELETE :/api/index_patterns/index_pattern//runtime_field/` + +`DELETE :/s//api/index_patterns/index_pattern//runtime_field/` + +[[index-patterns-runtime-field-api-delete-path-params]] +==== Path parameters + +`space_id`:: +(Optional, string) An identifier for the space. If `space_id` is not provided in the URL, the default space is used. + +`index_pattern_id`:: +(Required, string) The ID of the index pattern your want to delete a runtime field from. + +`name`:: +(Required, string) The name of the runtime field you want to delete. + + +==== Example + +Delete a runtime field from an index pattern: + +[source,sh] +-------------------------------------------------- +$ curl -X DELETE api/index_patterns/index_pattern//runtime_field/ +-------------------------------------------------- +// KIBANA diff --git a/docs/api/index-patterns/runtime-fields/get.asciidoc b/docs/api/index-patterns/runtime-fields/get.asciidoc new file mode 100644 index 0000000000000..42bd209c708bc --- /dev/null +++ b/docs/api/index-patterns/runtime-fields/get.asciidoc @@ -0,0 +1,52 @@ +[[index-patterns-runtime-field-api-get]] +=== Get runtime field API +++++ +Get runtime field +++++ + +experimental[] Get a runtime field + +[[index-patterns-runtime-field-get-request]] +==== Request + +`GET :/api/index_patterns/index_pattern//runtime_field/` + +`GET :/s//api/index_patterns/index_pattern//runtime_field/` + +[[index-patterns-runtime-field-get-params]] +==== Path parameters + +`space_id`:: +(Optional, string) An identifier for the space. If `space_id` is not provided in the URL, the default space is used. + +`index_pattern_id`:: +(Required, string) The ID of the index pattern. + +`name`:: +(Required, string) The name of the runtime field you want to retrieve. + + +[[index-patterns-runtime-field-get-example]] +==== Example + +Retrieve a runtime field named `foo` of index pattern with the `my-pattern` ID: + +[source,sh] +-------------------------------------------------- +$ curl -X GET api/index_patterns/index_pattern/my-pattern/runtime_field/foo +-------------------------------------------------- +// KIBANA + +The API returns a runtime `field` object, and a `runtimeField` definition object: + +[source,sh] +-------------------------------------------------- +{ + "field": { + ... + }, + "runtimeField": { + ... + } +} +-------------------------------------------------- diff --git a/docs/api/index-patterns/runtime-fields/update.asciidoc b/docs/api/index-patterns/runtime-fields/update.asciidoc new file mode 100644 index 0000000000000..f34460896f7bc --- /dev/null +++ b/docs/api/index-patterns/runtime-fields/update.asciidoc @@ -0,0 +1,66 @@ +[[index-patterns-runtime-field-api-update]] +=== Update runtime field API +++++ +Update runtime field +++++ + +experimental[] Update an existing runtime field + +[[index-patterns-runtime-field-update-request]] +==== Request + +`POST :/api/index_patterns/index_pattern//runtime_field/` + +`POST :/s//api/index_patterns/index_pattern//runtime_field/` + +[[index-patterns-runtime-field-update-params]] +==== Path parameters + +`space_id`:: +(Optional, string) An identifier for the space. If `space_id` is not provided in the URL, the default space is used. + +`index_pattern_id`:: +(Required, string) The ID of the index pattern. + +`name`:: +(Required, string) The name of the runtime field you want to update. + +[[index-patterns-runtime-field-update-body]] +==== Request body + +`runtimeField`:: (Required, object) The runtime field definition object. + +You can update following fields: + +* `type` +* `script` + + + +[[index-patterns-runtime-field-update-example]] +==== Examples + +Update an existing runtime field on an index pattern: + +[source,sh] +-------------------------------------------------- +$ curl -X POST api/index_patterns/index_pattern//runtime_field/ +{ + "runtimeField": { + "script": { + "source": "emit(doc["bar"].value)" + } + } +} +-------------------------------------------------- +// KIBANA + +The API returns updated runtime field object and updated index pattern object: + +[source,sh] +-------------------------------------------------- +{ + "index_pattern": {...}, + "field": {...} +} +-------------------------------------------------- diff --git a/docs/api/index-patterns/runtime-fields/upsert.asciidoc b/docs/api/index-patterns/runtime-fields/upsert.asciidoc new file mode 100644 index 0000000000000..1b436db19c62e --- /dev/null +++ b/docs/api/index-patterns/runtime-fields/upsert.asciidoc @@ -0,0 +1,61 @@ +[[index-patterns-runtime-field-api-upsert]] +=== Upsert runtime field API +++++ +Upsert runtime field +++++ + +experimental[] Create or update an existing runtime field + +[[index-patterns-runtime-field-upsert-request]] +==== Request + +`PUT :/api/index_patterns/index_pattern//runtime_field` + +`PUT :/s//api/index_patterns/index_pattern//runtime_field` + +[[index-patterns-runtime-field-upsert-params]] +==== Path parameters + +`space_id`:: +(Optional, string) An identifier for the space. If `space_id` is not provided in the URL, the default space is used. + +`index_pattern_id`:: +(Required, string) The ID of the index pattern. + +[[index-patterns-runtime-field-upsert-body]] +==== Request body + +`name`:: (Required, string) The name for a new runtime field or a name of an existing runtime field. + +`runtimeField`:: (Required, object) The runtime field definition object. + + +[[index-patterns-runtime-field-upsert-example]] +==== Examples + +Create or update an existing runtime field on an index pattern: + +[source,sh] +-------------------------------------------------- +$ curl -X PUT api/index_patterns/index_pattern//runtime_field +{ + "name": "runtimeFoo", + "runtimeField": { + "type": "long", + "script": { + "source": "emit(doc["foo"].value)" + } + } +} +-------------------------------------------------- +// KIBANA + +The API returns created or updated runtime field object and updated index pattern object: + +[source,sh] +-------------------------------------------------- +{ + "index_pattern": {...}, + "field": {...} +} +-------------------------------------------------- diff --git a/docs/api/index-patterns/update.asciidoc b/docs/api/index-patterns/update.asciidoc index 8ed0ff89fb928..2d5fe882d448d 100644 --- a/docs/api/index-patterns/update.asciidoc +++ b/docs/api/index-patterns/update.asciidoc @@ -93,7 +93,8 @@ $ curl -X POST api/saved_objects/index-pattern/my-pattern "fieldFormats": {}, "type": "...", "typeMeta": {}, - "fields": {} + "fields": {}, + "runtimeFieldMap": {} } } -------------------------------------------------- diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpattern.getruntimefield.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpattern.getruntimefield.md new file mode 100644 index 0000000000000..c0aca53255b8f --- /dev/null +++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpattern.getruntimefield.md @@ -0,0 +1,24 @@ + + +[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [IndexPattern](./kibana-plugin-plugins-data-public.indexpattern.md) > [getRuntimeField](./kibana-plugin-plugins-data-public.indexpattern.getruntimefield.md) + +## IndexPattern.getRuntimeField() method + +Returns runtime field if exists + +Signature: + +```typescript +getRuntimeField(name: string): RuntimeField | null; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| name | string | | + +Returns: + +`RuntimeField | null` + diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpattern.hasruntimefield.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpattern.hasruntimefield.md new file mode 100644 index 0000000000000..96dbe13a7f197 --- /dev/null +++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpattern.hasruntimefield.md @@ -0,0 +1,24 @@ + + +[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [IndexPattern](./kibana-plugin-plugins-data-public.indexpattern.md) > [hasRuntimeField](./kibana-plugin-plugins-data-public.indexpattern.hasruntimefield.md) + +## IndexPattern.hasRuntimeField() method + +Checks if runtime field exists + +Signature: + +```typescript +hasRuntimeField(name: string): boolean; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| name | string | | + +Returns: + +`boolean` + diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpattern.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpattern.md index 53d173d39f50d..51ca42fdce70a 100644 --- a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpattern.md +++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpattern.md @@ -54,13 +54,16 @@ export declare class IndexPattern implements IIndexPattern | [getFormatterForField(field)](./kibana-plugin-plugins-data-public.indexpattern.getformatterforfield.md) | | Provide a field, get its formatter | | [getFormatterForFieldNoDefault(fieldname)](./kibana-plugin-plugins-data-public.indexpattern.getformatterforfieldnodefault.md) | | Get formatter for a given field name. Return undefined if none exists | | [getNonScriptedFields()](./kibana-plugin-plugins-data-public.indexpattern.getnonscriptedfields.md) | | | +| [getRuntimeField(name)](./kibana-plugin-plugins-data-public.indexpattern.getruntimefield.md) | | Returns runtime field if exists | | [getScriptedFields()](./kibana-plugin-plugins-data-public.indexpattern.getscriptedfields.md) | | | | [getSourceFiltering()](./kibana-plugin-plugins-data-public.indexpattern.getsourcefiltering.md) | | Get the source filtering configuration for that index. | | [getTimeField()](./kibana-plugin-plugins-data-public.indexpattern.gettimefield.md) | | | +| [hasRuntimeField(name)](./kibana-plugin-plugins-data-public.indexpattern.hasruntimefield.md) | | Checks if runtime field exists | | [isTimeBased()](./kibana-plugin-plugins-data-public.indexpattern.istimebased.md) | | | | [isTimeNanosBased()](./kibana-plugin-plugins-data-public.indexpattern.istimenanosbased.md) | | | -| [removeRuntimeField(name)](./kibana-plugin-plugins-data-public.indexpattern.removeruntimefield.md) | | Remove a runtime field - removed from mapped field or removed unmapped field as appropriate | +| [removeRuntimeField(name)](./kibana-plugin-plugins-data-public.indexpattern.removeruntimefield.md) | | Remove a runtime field - removed from mapped field or removed unmapped field as appropriate. Doesn't clear associated field attributes. | | [removeScriptedField(fieldName)](./kibana-plugin-plugins-data-public.indexpattern.removescriptedfield.md) | | Remove scripted field from field list | +| [replaceAllRuntimeFields(newFields)](./kibana-plugin-plugins-data-public.indexpattern.replaceallruntimefields.md) | | Replaces all existing runtime fields with new fields | | [setFieldAttrs(fieldName, attrName, value)](./kibana-plugin-plugins-data-public.indexpattern.setfieldattrs.md) | | | | [setFieldCount(fieldName, count)](./kibana-plugin-plugins-data-public.indexpattern.setfieldcount.md) | | | | [setFieldCustomLabel(fieldName, customLabel)](./kibana-plugin-plugins-data-public.indexpattern.setfieldcustomlabel.md) | | | diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpattern.removeruntimefield.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpattern.removeruntimefield.md index 7a5228fece782..f2774924fc73c 100644 --- a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpattern.removeruntimefield.md +++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpattern.removeruntimefield.md @@ -4,7 +4,7 @@ ## IndexPattern.removeRuntimeField() method -Remove a runtime field - removed from mapped field or removed unmapped field as appropriate +Remove a runtime field - removed from mapped field or removed unmapped field as appropriate. Doesn't clear associated field attributes. Signature: @@ -16,7 +16,7 @@ removeRuntimeField(name: string): void; | Parameter | Type | Description | | --- | --- | --- | -| name | string | | +| name | string | Field name to remove | Returns: diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpattern.replaceallruntimefields.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpattern.replaceallruntimefields.md new file mode 100644 index 0000000000000..076b2b38cf474 --- /dev/null +++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpattern.replaceallruntimefields.md @@ -0,0 +1,24 @@ + + +[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [IndexPattern](./kibana-plugin-plugins-data-public.indexpattern.md) > [replaceAllRuntimeFields](./kibana-plugin-plugins-data-public.indexpattern.replaceallruntimefields.md) + +## IndexPattern.replaceAllRuntimeFields() method + +Replaces all existing runtime fields with new fields + +Signature: + +```typescript +replaceAllRuntimeFields(newFields: Record): void; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| newFields | Record<string, RuntimeField> | | + +Returns: + +`void` + diff --git a/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.indexpattern.getruntimefield.md b/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.indexpattern.getruntimefield.md new file mode 100644 index 0000000000000..d5dc8f966316b --- /dev/null +++ b/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.indexpattern.getruntimefield.md @@ -0,0 +1,24 @@ + + +[Home](./index.md) > [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) > [IndexPattern](./kibana-plugin-plugins-data-server.indexpattern.md) > [getRuntimeField](./kibana-plugin-plugins-data-server.indexpattern.getruntimefield.md) + +## IndexPattern.getRuntimeField() method + +Returns runtime field if exists + +Signature: + +```typescript +getRuntimeField(name: string): RuntimeField | null; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| name | string | | + +Returns: + +`RuntimeField | null` + diff --git a/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.indexpattern.hasruntimefield.md b/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.indexpattern.hasruntimefield.md new file mode 100644 index 0000000000000..5000d5e645cbb --- /dev/null +++ b/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.indexpattern.hasruntimefield.md @@ -0,0 +1,24 @@ + + +[Home](./index.md) > [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) > [IndexPattern](./kibana-plugin-plugins-data-server.indexpattern.md) > [hasRuntimeField](./kibana-plugin-plugins-data-server.indexpattern.hasruntimefield.md) + +## IndexPattern.hasRuntimeField() method + +Checks if runtime field exists + +Signature: + +```typescript +hasRuntimeField(name: string): boolean; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| name | string | | + +Returns: + +`boolean` + diff --git a/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.indexpattern.md b/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.indexpattern.md index 97d1cd9115262..27b8a31a2582b 100644 --- a/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.indexpattern.md +++ b/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.indexpattern.md @@ -54,13 +54,16 @@ export declare class IndexPattern implements IIndexPattern | [getFormatterForField(field)](./kibana-plugin-plugins-data-server.indexpattern.getformatterforfield.md) | | Provide a field, get its formatter | | [getFormatterForFieldNoDefault(fieldname)](./kibana-plugin-plugins-data-server.indexpattern.getformatterforfieldnodefault.md) | | Get formatter for a given field name. Return undefined if none exists | | [getNonScriptedFields()](./kibana-plugin-plugins-data-server.indexpattern.getnonscriptedfields.md) | | | +| [getRuntimeField(name)](./kibana-plugin-plugins-data-server.indexpattern.getruntimefield.md) | | Returns runtime field if exists | | [getScriptedFields()](./kibana-plugin-plugins-data-server.indexpattern.getscriptedfields.md) | | | | [getSourceFiltering()](./kibana-plugin-plugins-data-server.indexpattern.getsourcefiltering.md) | | Get the source filtering configuration for that index. | | [getTimeField()](./kibana-plugin-plugins-data-server.indexpattern.gettimefield.md) | | | +| [hasRuntimeField(name)](./kibana-plugin-plugins-data-server.indexpattern.hasruntimefield.md) | | Checks if runtime field exists | | [isTimeBased()](./kibana-plugin-plugins-data-server.indexpattern.istimebased.md) | | | | [isTimeNanosBased()](./kibana-plugin-plugins-data-server.indexpattern.istimenanosbased.md) | | | -| [removeRuntimeField(name)](./kibana-plugin-plugins-data-server.indexpattern.removeruntimefield.md) | | Remove a runtime field - removed from mapped field or removed unmapped field as appropriate | +| [removeRuntimeField(name)](./kibana-plugin-plugins-data-server.indexpattern.removeruntimefield.md) | | Remove a runtime field - removed from mapped field or removed unmapped field as appropriate. Doesn't clear associated field attributes. | | [removeScriptedField(fieldName)](./kibana-plugin-plugins-data-server.indexpattern.removescriptedfield.md) | | Remove scripted field from field list | +| [replaceAllRuntimeFields(newFields)](./kibana-plugin-plugins-data-server.indexpattern.replaceallruntimefields.md) | | Replaces all existing runtime fields with new fields | | [setFieldAttrs(fieldName, attrName, value)](./kibana-plugin-plugins-data-server.indexpattern.setfieldattrs.md) | | | | [setFieldCount(fieldName, count)](./kibana-plugin-plugins-data-server.indexpattern.setfieldcount.md) | | | | [setFieldCustomLabel(fieldName, customLabel)](./kibana-plugin-plugins-data-server.indexpattern.setfieldcustomlabel.md) | | | diff --git a/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.indexpattern.removeruntimefield.md b/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.indexpattern.removeruntimefield.md index da8e7e40a7fac..ef32b80ba8502 100644 --- a/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.indexpattern.removeruntimefield.md +++ b/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.indexpattern.removeruntimefield.md @@ -4,7 +4,7 @@ ## IndexPattern.removeRuntimeField() method -Remove a runtime field - removed from mapped field or removed unmapped field as appropriate +Remove a runtime field - removed from mapped field or removed unmapped field as appropriate. Doesn't clear associated field attributes. Signature: @@ -16,7 +16,7 @@ removeRuntimeField(name: string): void; | Parameter | Type | Description | | --- | --- | --- | -| name | string | | +| name | string | Field name to remove | Returns: diff --git a/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.indexpattern.replaceallruntimefields.md b/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.indexpattern.replaceallruntimefields.md new file mode 100644 index 0000000000000..35df871763f8a --- /dev/null +++ b/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.indexpattern.replaceallruntimefields.md @@ -0,0 +1,24 @@ + + +[Home](./index.md) > [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) > [IndexPattern](./kibana-plugin-plugins-data-server.indexpattern.md) > [replaceAllRuntimeFields](./kibana-plugin-plugins-data-server.indexpattern.replaceallruntimefields.md) + +## IndexPattern.replaceAllRuntimeFields() method + +Replaces all existing runtime fields with new fields + +Signature: + +```typescript +replaceAllRuntimeFields(newFields: Record): void; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| newFields | Record<string, RuntimeField> | | + +Returns: + +`void` + diff --git a/src/plugins/data/common/index_patterns/index_patterns/index_pattern.ts b/src/plugins/data/common/index_patterns/index_patterns/index_pattern.ts index c897cdbce2309..0c3a9901f8c8c 100644 --- a/src/plugins/data/common/index_patterns/index_patterns/index_pattern.ts +++ b/src/plugins/data/common/index_patterns/index_patterns/index_pattern.ts @@ -364,7 +364,6 @@ export class IndexPattern implements IIndexPattern { * @param name Field name * @param runtimeField Runtime field definition */ - addRuntimeField(name: string, runtimeField: RuntimeField) { const existingField = this.getFieldByName(name); if (existingField) { @@ -384,11 +383,41 @@ export class IndexPattern implements IIndexPattern { } /** - * Remove a runtime field - removed from mapped field or removed unmapped - * field as appropriate - * @param name Field name + * Checks if runtime field exists + * @param name + */ + hasRuntimeField(name: string): boolean { + return !!this.runtimeFieldMap[name]; + } + + /** + * Returns runtime field if exists + * @param name + */ + getRuntimeField(name: string): RuntimeField | null { + return this.runtimeFieldMap[name] ?? null; + } + + /** + * Replaces all existing runtime fields with new fields + * @param newFields */ + replaceAllRuntimeFields(newFields: Record) { + const oldRuntimeFieldNames = Object.keys(this.runtimeFieldMap); + oldRuntimeFieldNames.forEach((name) => { + this.removeRuntimeField(name); + }); + Object.entries(newFields).forEach(([name, field]) => { + this.addRuntimeField(name, field); + }); + } + + /** + * Remove a runtime field - removed from mapped field or removed unmapped + * field as appropriate. Doesn't clear associated field attributes. + * @param name - Field name to remove + */ removeRuntimeField(name: string) { const existingField = this.getFieldByName(name); if (existingField) { @@ -396,9 +425,6 @@ export class IndexPattern implements IIndexPattern { // mapped field, remove runtimeField def existingField.runtimeField = undefined; } else { - // runtimeField only - this.setFieldCustomLabel(name, null); - this.deleteFieldFormat(name); this.fields.remove(existingField); } } diff --git a/src/plugins/data/public/public.api.md b/src/plugins/data/public/public.api.md index 5ef499840fa6d..67534577d99fc 100644 --- a/src/plugins/data/public/public.api.md +++ b/src/plugins/data/public/public.api.md @@ -1413,6 +1413,7 @@ export class IndexPattern implements IIndexPattern { typeMeta?: string | undefined; type?: string | undefined; }; + getRuntimeField(name: string): RuntimeField | null; // @deprecated (undocumented) getScriptedFields(): IndexPatternField[]; getSourceFiltering(): { @@ -1420,6 +1421,7 @@ export class IndexPattern implements IIndexPattern { }; // (undocumented) getTimeField(): IndexPatternField | undefined; + hasRuntimeField(name: string): boolean; // (undocumented) id?: string; // @deprecated (undocumented) @@ -1433,6 +1435,7 @@ export class IndexPattern implements IIndexPattern { removeRuntimeField(name: string): void; // @deprecated removeScriptedField(fieldName: string): void; + replaceAllRuntimeFields(newFields: Record): void; resetOriginalSavedObjectBody: () => void; // (undocumented) protected setFieldAttrs(fieldName: string, attrName: K, value: FieldAttrSet[K]): void; diff --git a/src/plugins/data/server/index_patterns/routes.ts b/src/plugins/data/server/index_patterns/routes.ts index 9bff590b54f1c..d2d8cb82cf646 100644 --- a/src/plugins/data/server/index_patterns/routes.ts +++ b/src/plugins/data/server/index_patterns/routes.ts @@ -21,6 +21,11 @@ import { registerDeleteScriptedFieldRoute } from './routes/scripted_fields/delet import { registerUpdateScriptedFieldRoute } from './routes/scripted_fields/update_scripted_field'; import type { DataPluginStart, DataPluginStartDependencies } from '../plugin'; import { registerManageDefaultIndexPatternRoutes } from './routes/default_index_pattern'; +import { registerCreateRuntimeFieldRoute } from './routes/runtime_fields/create_runtime_field'; +import { registerGetRuntimeFieldRoute } from './routes/runtime_fields/get_runtime_field'; +import { registerDeleteRuntimeFieldRoute } from './routes/runtime_fields/delete_runtime_field'; +import { registerPutRuntimeFieldRoute } from './routes/runtime_fields/put_runtime_field'; +import { registerUpdateRuntimeFieldRoute } from './routes/runtime_fields/update_runtime_field'; export function registerRoutes( http: HttpServiceSetup, @@ -55,6 +60,13 @@ export function registerRoutes( registerDeleteScriptedFieldRoute(router, getStartServices); registerUpdateScriptedFieldRoute(router, getStartServices); + // Runtime Fields API + registerCreateRuntimeFieldRoute(router, getStartServices); + registerGetRuntimeFieldRoute(router, getStartServices); + registerDeleteRuntimeFieldRoute(router, getStartServices); + registerPutRuntimeFieldRoute(router, getStartServices); + registerUpdateRuntimeFieldRoute(router, getStartServices); + router.get( { path: '/api/index_patterns/_fields_for_wildcard', diff --git a/src/plugins/data/server/index_patterns/routes/create_index_pattern.ts b/src/plugins/data/server/index_patterns/routes/create_index_pattern.ts index d076733462622..7049903f84e8c 100644 --- a/src/plugins/data/server/index_patterns/routes/create_index_pattern.ts +++ b/src/plugins/data/server/index_patterns/routes/create_index_pattern.ts @@ -9,7 +9,11 @@ import { schema } from '@kbn/config-schema'; import { IndexPatternSpec } from 'src/plugins/data/common'; import { handleErrors } from './util/handle_errors'; -import { fieldSpecSchema, serializedFieldFormatSchema } from './util/schemas'; +import { + fieldSpecSchema, + runtimeFieldSpecSchema, + serializedFieldFormatSchema, +} from './util/schemas'; import { IRouter, StartServicesAccessor } from '../../../../../core/server'; import type { DataPluginStart, DataPluginStartDependencies } from '../../plugin'; @@ -39,6 +43,7 @@ const indexPatternSpecSchema = schema.object({ ) ), allowNoIndex: schema.maybe(schema.boolean()), + runtimeFieldMap: schema.maybe(schema.recordOf(schema.string(), runtimeFieldSpecSchema)), }); export const registerCreateIndexPatternRoute = ( @@ -66,6 +71,7 @@ export const registerCreateIndexPatternRoute = ( elasticsearchClient ); const body = req.body; + const indexPattern = await indexPatternsService.createAndSave( body.index_pattern as IndexPatternSpec, body.override, diff --git a/src/plugins/data/server/index_patterns/routes/runtime_fields/create_runtime_field.ts b/src/plugins/data/server/index_patterns/routes/runtime_fields/create_runtime_field.ts new file mode 100644 index 0000000000000..faf6d87b6d10b --- /dev/null +++ b/src/plugins/data/server/index_patterns/routes/runtime_fields/create_runtime_field.ts @@ -0,0 +1,74 @@ +/* + * 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 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import { schema } from '@kbn/config-schema'; +import { handleErrors } from '../util/handle_errors'; +import { runtimeFieldSpecSchema } from '../util/schemas'; +import { IRouter, StartServicesAccessor } from '../../../../../../core/server'; +import type { DataPluginStart, DataPluginStartDependencies } from '../../../plugin'; + +export const registerCreateRuntimeFieldRoute = ( + router: IRouter, + getStartServices: StartServicesAccessor +) => { + router.post( + { + path: '/api/index_patterns/index_pattern/{id}/runtime_field', + validate: { + params: schema.object({ + id: schema.string({ + minLength: 1, + maxLength: 1_000, + }), + }), + body: schema.object({ + name: schema.string({ + minLength: 1, + maxLength: 1_000, + }), + runtimeField: runtimeFieldSpecSchema, + }), + }, + }, + + handleErrors(async (ctx, req, res) => { + const savedObjectsClient = ctx.core.savedObjects.client; + const elasticsearchClient = ctx.core.elasticsearch.client.asCurrentUser; + const [, , { indexPatterns }] = await getStartServices(); + const indexPatternsService = await indexPatterns.indexPatternsServiceFactory( + savedObjectsClient, + elasticsearchClient + ); + const id = req.params.id; + const { name, runtimeField } = req.body; + + const indexPattern = await indexPatternsService.get(id); + + if (indexPattern.fields.getByName(name)) { + throw new Error(`Field [name = ${name}] already exists.`); + } + + indexPattern.addRuntimeField(name, runtimeField); + + const addedField = indexPattern.fields.getByName(name); + if (!addedField) throw new Error(`Could not create a field [name = ${name}].`); + + await indexPatternsService.updateSavedObject(indexPattern); + + const savedField = indexPattern.fields.getByName(name); + if (!savedField) throw new Error(`Could not create a field [name = ${name}].`); + + return res.ok({ + body: { + field: savedField.toSpec(), + index_pattern: indexPattern.toSpec(), + }, + }); + }) + ); +}; diff --git a/src/plugins/data/server/index_patterns/routes/runtime_fields/delete_runtime_field.ts b/src/plugins/data/server/index_patterns/routes/runtime_fields/delete_runtime_field.ts new file mode 100644 index 0000000000000..58b8529d7cf5a --- /dev/null +++ b/src/plugins/data/server/index_patterns/routes/runtime_fields/delete_runtime_field.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 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import { schema } from '@kbn/config-schema'; +import { ErrorIndexPatternFieldNotFound } from '../../error'; +import { handleErrors } from '../util/handle_errors'; +import { IRouter, StartServicesAccessor } from '../../../../../../core/server'; +import type { DataPluginStart, DataPluginStartDependencies } from '../../../plugin'; + +export const registerDeleteRuntimeFieldRoute = ( + router: IRouter, + getStartServices: StartServicesAccessor +) => { + router.delete( + { + path: '/api/index_patterns/index_pattern/{id}/runtime_field/{name}', + validate: { + params: schema.object({ + id: schema.string({ + minLength: 1, + maxLength: 1_000, + }), + name: schema.string({ + minLength: 1, + maxLength: 1_000, + }), + }), + }, + }, + handleErrors(async (ctx, req, res) => { + const savedObjectsClient = ctx.core.savedObjects.client; + const elasticsearchClient = ctx.core.elasticsearch.client.asCurrentUser; + const [, , { indexPatterns }] = await getStartServices(); + const indexPatternsService = await indexPatterns.indexPatternsServiceFactory( + savedObjectsClient, + elasticsearchClient + ); + const id = req.params.id; + const name = req.params.name; + + const indexPattern = await indexPatternsService.get(id); + const field = indexPattern.fields.getByName(name); + + if (!field) { + throw new ErrorIndexPatternFieldNotFound(id, name); + } + + if (!field.runtimeField) { + throw new Error('Only runtime fields can be deleted.'); + } + + indexPattern.removeRuntimeField(name); + + await indexPatternsService.updateSavedObject(indexPattern); + + return res.ok(); + }) + ); +}; diff --git a/src/plugins/data/server/index_patterns/routes/runtime_fields/get_runtime_field.ts b/src/plugins/data/server/index_patterns/routes/runtime_fields/get_runtime_field.ts new file mode 100644 index 0000000000000..6bc2bf396c0b4 --- /dev/null +++ b/src/plugins/data/server/index_patterns/routes/runtime_fields/get_runtime_field.ts @@ -0,0 +1,67 @@ +/* + * 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 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import { schema } from '@kbn/config-schema'; +import { ErrorIndexPatternFieldNotFound } from '../../error'; +import { handleErrors } from '../util/handle_errors'; +import { IRouter, StartServicesAccessor } from '../../../../../../core/server'; +import type { DataPluginStart, DataPluginStartDependencies } from '../../../plugin'; + +export const registerGetRuntimeFieldRoute = ( + router: IRouter, + getStartServices: StartServicesAccessor +) => { + router.get( + { + path: '/api/index_patterns/index_pattern/{id}/runtime_field/{name}', + validate: { + params: schema.object({ + id: schema.string({ + minLength: 1, + maxLength: 1_000, + }), + name: schema.string({ + minLength: 1, + maxLength: 1_000, + }), + }), + }, + }, + + handleErrors(async (ctx, req, res) => { + const savedObjectsClient = ctx.core.savedObjects.client; + const elasticsearchClient = ctx.core.elasticsearch.client.asCurrentUser; + const [, , { indexPatterns }] = await getStartServices(); + const indexPatternsService = await indexPatterns.indexPatternsServiceFactory( + savedObjectsClient, + elasticsearchClient + ); + const id = req.params.id; + const name = req.params.name; + + const indexPattern = await indexPatternsService.get(id); + + const field = indexPattern.fields.getByName(name); + + if (!field) { + throw new ErrorIndexPatternFieldNotFound(id, name); + } + + if (!field.runtimeField) { + throw new Error('Only runtime fields can be retrieved.'); + } + + return res.ok({ + body: { + field: field.toSpec(), + runtimeField: indexPattern.getRuntimeField(name), + }, + }); + }) + ); +}; diff --git a/src/plugins/data/server/index_patterns/routes/runtime_fields/put_runtime_field.ts b/src/plugins/data/server/index_patterns/routes/runtime_fields/put_runtime_field.ts new file mode 100644 index 0000000000000..a5e92fa5a36ec --- /dev/null +++ b/src/plugins/data/server/index_patterns/routes/runtime_fields/put_runtime_field.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 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import { schema } from '@kbn/config-schema'; +import { handleErrors } from '../util/handle_errors'; +import { runtimeFieldSpecSchema } from '../util/schemas'; +import { IRouter, StartServicesAccessor } from '../../../../../../core/server'; +import type { DataPluginStart, DataPluginStartDependencies } from '../../../plugin'; + +export const registerPutRuntimeFieldRoute = ( + router: IRouter, + getStartServices: StartServicesAccessor +) => { + router.put( + { + path: '/api/index_patterns/index_pattern/{id}/runtime_field', + validate: { + params: schema.object({ + id: schema.string({ + minLength: 1, + maxLength: 1_000, + }), + }), + body: schema.object({ + name: schema.string({ + minLength: 1, + maxLength: 1_000, + }), + runtimeField: runtimeFieldSpecSchema, + }), + }, + }, + handleErrors(async (ctx, req, res) => { + const savedObjectsClient = ctx.core.savedObjects.client; + const elasticsearchClient = ctx.core.elasticsearch.client.asCurrentUser; + const [, , { indexPatterns }] = await getStartServices(); + const indexPatternsService = await indexPatterns.indexPatternsServiceFactory( + savedObjectsClient, + elasticsearchClient + ); + const id = req.params.id; + const { name, runtimeField } = req.body; + + const indexPattern = await indexPatternsService.get(id); + + const oldFieldObject = indexPattern.fields.getByName(name); + + if (oldFieldObject && !oldFieldObject.runtimeField) { + throw new Error('Only runtime fields can be updated'); + } + + if (oldFieldObject) { + indexPattern.removeRuntimeField(name); + } + + indexPattern.addRuntimeField(name, runtimeField); + + await indexPatternsService.updateSavedObject(indexPattern); + + const fieldObject = indexPattern.fields.getByName(name); + if (!fieldObject) throw new Error(`Could not create a field [name = ${name}].`); + + return res.ok({ + body: { + field: fieldObject.toSpec(), + index_pattern: indexPattern.toSpec(), + }, + }); + }) + ); +}; diff --git a/src/plugins/data/server/index_patterns/routes/runtime_fields/update_runtime_field.ts b/src/plugins/data/server/index_patterns/routes/runtime_fields/update_runtime_field.ts new file mode 100644 index 0000000000000..3f3aae46c4388 --- /dev/null +++ b/src/plugins/data/server/index_patterns/routes/runtime_fields/update_runtime_field.ts @@ -0,0 +1,84 @@ +/* + * 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 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import { schema } from '@kbn/config-schema'; +import { RuntimeField } from 'src/plugins/data/common'; +import { ErrorIndexPatternFieldNotFound } from '../../error'; +import { handleErrors } from '../util/handle_errors'; +import { runtimeFieldSpec, runtimeFieldSpecTypeSchema } from '../util/schemas'; +import { IRouter, StartServicesAccessor } from '../../../../../../core/server'; +import type { DataPluginStart, DataPluginStartDependencies } from '../../../plugin'; + +export const registerUpdateRuntimeFieldRoute = ( + router: IRouter, + getStartServices: StartServicesAccessor +) => { + router.post( + { + path: '/api/index_patterns/index_pattern/{id}/runtime_field/{name}', + validate: { + params: schema.object({ + id: schema.string({ + minLength: 1, + maxLength: 1_000, + }), + name: schema.string({ + minLength: 1, + maxLength: 1_000, + }), + }), + body: schema.object({ + name: schema.never(), + runtimeField: schema.object({ + ...runtimeFieldSpec, + // We need to overwrite the below fields on top of `runtimeFieldSpec`, + // because some fields would be optional + type: schema.maybe(runtimeFieldSpecTypeSchema), + }), + }), + }, + }, + handleErrors(async (ctx, req, res) => { + const savedObjectsClient = ctx.core.savedObjects.client; + const elasticsearchClient = ctx.core.elasticsearch.client.asCurrentUser; + const [, , { indexPatterns }] = await getStartServices(); + const indexPatternsService = await indexPatterns.indexPatternsServiceFactory( + savedObjectsClient, + elasticsearchClient + ); + const id = req.params.id; + const name = req.params.name; + const runtimeField = req.body.runtimeField as Partial; + + const indexPattern = await indexPatternsService.get(id); + const existingRuntimeField = indexPattern.getRuntimeField(name); + + if (!existingRuntimeField) { + throw new ErrorIndexPatternFieldNotFound(id, name); + } + + indexPattern.removeRuntimeField(name); + indexPattern.addRuntimeField(name, { + ...existingRuntimeField, + ...runtimeField, + }); + + await indexPatternsService.updateSavedObject(indexPattern); + + const fieldObject = indexPattern.fields.getByName(name); + if (!fieldObject) throw new Error(`Could not create a field [name = ${name}].`); + + return res.ok({ + body: { + field: fieldObject.toSpec(), + index_pattern: indexPattern.toSpec(), + }, + }); + }) + ); +}; diff --git a/src/plugins/data/server/index_patterns/routes/update_index_pattern.ts b/src/plugins/data/server/index_patterns/routes/update_index_pattern.ts index c1509b9b848be..1c88550c154c5 100644 --- a/src/plugins/data/server/index_patterns/routes/update_index_pattern.ts +++ b/src/plugins/data/server/index_patterns/routes/update_index_pattern.ts @@ -8,7 +8,11 @@ import { schema } from '@kbn/config-schema'; import { handleErrors } from './util/handle_errors'; -import { fieldSpecSchema, serializedFieldFormatSchema } from './util/schemas'; +import { + fieldSpecSchema, + runtimeFieldSpecSchema, + serializedFieldFormatSchema, +} from './util/schemas'; import { IRouter, StartServicesAccessor } from '../../../../../core/server'; import type { DataPluginStart, DataPluginStartDependencies } from '../../plugin'; @@ -28,6 +32,7 @@ const indexPatternUpdateSchema = schema.object({ fieldFormats: schema.maybe(schema.recordOf(schema.string(), serializedFieldFormatSchema)), fields: schema.maybe(schema.recordOf(schema.string(), fieldSpecSchema)), allowNoIndex: schema.maybe(schema.boolean()), + runtimeFieldMap: schema.maybe(schema.recordOf(schema.string(), runtimeFieldSpecSchema)), }); export const registerUpdateIndexPatternRoute = ( @@ -78,6 +83,7 @@ export const registerUpdateIndexPatternRoute = ( type, typeMeta, fields, + runtimeFieldMap, }, } = req.body; @@ -131,6 +137,11 @@ export const registerUpdateIndexPatternRoute = ( ); } + if (runtimeFieldMap !== undefined) { + changeCount++; + indexPattern.replaceAllRuntimeFields(runtimeFieldMap); + } + if (changeCount < 1) { throw new Error('Index pattern change set is empty.'); } diff --git a/src/plugins/data/server/index_patterns/routes/util/schemas.ts b/src/plugins/data/server/index_patterns/routes/util/schemas.ts index d916423c4fc69..79ee1ffa1ab97 100644 --- a/src/plugins/data/server/index_patterns/routes/util/schemas.ts +++ b/src/plugins/data/server/index_patterns/routes/util/schemas.ts @@ -6,7 +6,8 @@ * Side Public License, v 1. */ -import { schema } from '@kbn/config-schema'; +import { schema, Type } from '@kbn/config-schema'; +import { RUNTIME_FIELD_TYPES, RuntimeType } from '../../../../common'; export const serializedFieldFormatSchema = schema.object({ id: schema.maybe(schema.string()), @@ -52,4 +53,24 @@ export const fieldSpecSchemaFields = { shortDotsEnable: schema.maybe(schema.boolean()), }; -export const fieldSpecSchema = schema.object(fieldSpecSchemaFields); +export const fieldSpecSchema = schema.object(fieldSpecSchemaFields, { + // Allow and ignore unknowns to make fields transient. + // Because `fields` have a bunch of calculated fields + // this allows to retrieve an index pattern and then to re-create by using the retrieved payload + unknowns: 'ignore', +}); + +export const runtimeFieldSpecTypeSchema = schema.oneOf( + RUNTIME_FIELD_TYPES.map((runtimeFieldType) => schema.literal(runtimeFieldType)) as [ + Type + ] +); +export const runtimeFieldSpec = { + type: runtimeFieldSpecTypeSchema, + script: schema.maybe( + schema.object({ + source: schema.string(), + }) + ), +}; +export const runtimeFieldSpecSchema = schema.object(runtimeFieldSpec); diff --git a/src/plugins/data/server/server.api.md b/src/plugins/data/server/server.api.md index ff265ccf53301..783bd8d2fcd0e 100644 --- a/src/plugins/data/server/server.api.md +++ b/src/plugins/data/server/server.api.md @@ -816,6 +816,7 @@ export class IndexPattern implements IIndexPattern { typeMeta?: string | undefined; type?: string | undefined; }; + getRuntimeField(name: string): RuntimeField | null; // @deprecated (undocumented) getScriptedFields(): IndexPatternField[]; getSourceFiltering(): { @@ -823,6 +824,7 @@ export class IndexPattern implements IIndexPattern { }; // (undocumented) getTimeField(): IndexPatternField | undefined; + hasRuntimeField(name: string): boolean; // (undocumented) id?: string; // @deprecated (undocumented) @@ -836,6 +838,7 @@ export class IndexPattern implements IIndexPattern { removeRuntimeField(name: string): void; // @deprecated removeScriptedField(fieldName: string): void; + replaceAllRuntimeFields(newFields: Record): void; resetOriginalSavedObjectBody: () => void; // (undocumented) protected setFieldAttrs(fieldName: string, attrName: K, value: FieldAttrSet[K]): void; 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 3bec22de48ee6..16861f3c28051 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 @@ -22,6 +22,7 @@ export default function ({ getService }: FtrProviderContext) { indexPattern = ( await supertest.post('/api/index_patterns/index_pattern').send({ + override: true, index_pattern: { title: basicIndex, }, diff --git a/test/api_integration/apis/index_patterns/index.js b/test/api_integration/apis/index_patterns/index.js index 9c1e1bba0ab9a..656b4e506fa23 100644 --- a/test/api_integration/apis/index_patterns/index.js +++ b/test/api_integration/apis/index_patterns/index.js @@ -15,5 +15,7 @@ export default function ({ loadTestFile }) { loadTestFile(require.resolve('./scripted_fields_crud')); loadTestFile(require.resolve('./fields_api')); loadTestFile(require.resolve('./default_index_pattern')); + loadTestFile(require.resolve('./runtime_fields_crud')); + loadTestFile(require.resolve('./integration')); }); } 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 31c3f13a6e05f..500a642f60850 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 @@ -117,7 +117,7 @@ export default function ({ getService }: FtrProviderContext) { expect(response.body.index_pattern.fields.bar.type).to.be('boolean'); }); - it('Can add scripted fields, other fields created from es index', async () => { + it('can add scripted fields, other fields created from es index', async () => { const title = `basic_index*`; const response = await supertest.post('/api/index_patterns/index_pattern').send({ override: true, @@ -159,6 +159,32 @@ export default function ({ getService }: FtrProviderContext) { expect(response.body.index_pattern.fields.bar.esTypes[0]).to.be('test-type'); expect(response.body.index_pattern.fields.bar.scripted).to.be(true); }); + + it('can add runtime fields', async () => { + const title = `basic_index*`; + const response = await supertest.post('/api/index_patterns/index_pattern').send({ + override: true, + index_pattern: { + title, + runtimeFieldMap: { + runtimeFoo: { + type: 'keyword', + script: { + source: 'emit(doc["foo"].value)', + }, + }, + }, + }, + }); + + expect(response.status).to.be(200); + expect(response.body.index_pattern.title).to.be(title); + + expect(response.body.index_pattern.runtimeFieldMap.runtimeFoo.type).to.be('keyword'); + expect(response.body.index_pattern.runtimeFieldMap.runtimeFoo.script.source).to.be( + 'emit(doc["foo"].value)' + ); + }); }); it('can specify optional typeMeta attribute when creating an index pattern', async () => { diff --git a/test/api_integration/apis/index_patterns/index_pattern_crud/create_index_pattern/validation.ts b/test/api_integration/apis/index_patterns/index_pattern_crud/create_index_pattern/validation.ts index 2f62ea231b722..598001644eedb 100644 --- a/test/api_integration/apis/index_patterns/index_pattern_crud/create_index_pattern/validation.ts +++ b/test/api_integration/apis/index_patterns/index_pattern_crud/create_index_pattern/validation.ts @@ -64,5 +64,25 @@ export default function ({ getService }: FtrProviderContext) { '[request body.refresh_fields]: expected value of type [boolean] but got [number]' ); }); + + it('returns an error when unknown runtime field type', async () => { + const title = `basic_index*`; + const response = await supertest.post('/api/index_patterns/index_pattern').send({ + override: true, + index_pattern: { + title, + runtimeFieldMap: { + runtimeFoo: { + type: 'wrong-type', + script: { + source: 'emit(doc["foo"].value)', + }, + }, + }, + }, + }); + + expect(response.status).to.be(400); + }); }); } diff --git a/test/api_integration/apis/index_patterns/index_pattern_crud/update_index_pattern/main.ts b/test/api_integration/apis/index_patterns/index_pattern_crud/update_index_pattern/main.ts index cd34724e6cda3..7532278d7eb12 100644 --- a/test/api_integration/apis/index_patterns/index_pattern_crud/update_index_pattern/main.ts +++ b/test/api_integration/apis/index_patterns/index_pattern_crud/update_index_pattern/main.ts @@ -284,5 +284,53 @@ export default function ({ getService }: FtrProviderContext) { expect(response3.body.index_pattern.intervalName).to.be('intervalName2'); expect(response3.body.index_pattern.typeMeta.baz).to.be('qux'); }); + + it('can update runtime fields', async () => { + const title = `basic_index*`; + const response1 = await supertest.post('/api/index_patterns/index_pattern').send({ + override: true, + index_pattern: { + title, + runtimeFieldMap: { + runtimeFoo: { + type: 'keyword', + script: { + source: 'emit(doc["foo"].value)', + }, + }, + }, + }, + }); + + expect(response1.status).to.be(200); + expect(response1.body.index_pattern.title).to.be(title); + + expect(response1.body.index_pattern.runtimeFieldMap.runtimeFoo.type).to.be('keyword'); + expect(response1.body.index_pattern.runtimeFieldMap.runtimeFoo.script.source).to.be( + 'emit(doc["foo"].value)' + ); + + const id = response1.body.index_pattern.id; + const response2 = await supertest.post('/api/index_patterns/index_pattern/' + id).send({ + index_pattern: { + runtimeFieldMap: { + runtimeBar: { + type: 'keyword', + script: { + source: 'emit(doc["foo"].value)', + }, + }, + }, + }, + }); + + expect(response2.body.index_pattern.runtimeFieldMap.runtimeBar.type).to.be('keyword'); + expect(response2.body.index_pattern.runtimeFieldMap.runtimeFoo).to.be(undefined); + + const response3 = await supertest.get('/api/index_patterns/index_pattern/' + id); + + expect(response3.body.index_pattern.runtimeFieldMap.runtimeBar.type).to.be('keyword'); + expect(response3.body.index_pattern.runtimeFieldMap.runtimeFoo).to.be(undefined); + }); }); } diff --git a/test/api_integration/apis/index_patterns/integration/index.ts b/test/api_integration/apis/index_patterns/integration/index.ts new file mode 100644 index 0000000000000..6fd5f644ae894 --- /dev/null +++ b/test/api_integration/apis/index_patterns/integration/index.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 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import { FtrProviderContext } from '../../../ftr_provider_context'; + +/** + * Test usage of different index patterns APIs in combination + */ +export default function ({ loadTestFile }: FtrProviderContext) { + describe('integration', () => { + loadTestFile(require.resolve('./integration')); + }); +} diff --git a/test/api_integration/apis/index_patterns/integration/integration.ts b/test/api_integration/apis/index_patterns/integration/integration.ts new file mode 100644 index 0000000000000..22f0755373323 --- /dev/null +++ b/test/api_integration/apis/index_patterns/integration/integration.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 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import expect from '@kbn/expect'; +import _ from 'lodash'; +import { FtrProviderContext } from '../../../ftr_provider_context'; + +/** + * Test usage of different index patterns APIs in combination + */ +export default function ({ getService }: FtrProviderContext) { + const supertest = getService('supertest'); + const esArchiver = getService('esArchiver'); + + describe('integration', () => { + before(async () => { + await esArchiver.load('test/api_integration/fixtures/es_archiver/index_patterns/basic_index'); + }); + + after(async () => { + await esArchiver.unload( + 'test/api_integration/fixtures/es_archiver/index_patterns/basic_index' + ); + }); + + it('create an index pattern, add a runtime field, add a field formatter, then re-create the same index pattern', async () => { + const title = `basic_index*`; + const response1 = await supertest.post('/api/index_patterns/index_pattern').send({ + override: true, + index_pattern: { + title, + }, + }); + const id = response1.body.index_pattern.id; + const response2 = await supertest + .post(`/api/index_patterns/index_pattern/${id}/runtime_field`) + .send({ + name: 'runtimeBar', + runtimeField: { + type: 'long', + script: { + source: "emit(doc['field_name'].value)", + }, + }, + }); + + expect(response2.status).to.be(200); + + const response3 = await supertest + .post(`/api/index_patterns/index_pattern/${response1.body.index_pattern.id}/fields`) + .send({ + fields: { + runtimeBar: { + count: 123, + customLabel: 'test', + }, + }, + }); + + expect(response3.status).to.be(200); + + const response4 = await supertest + .post(`/api/index_patterns/index_pattern/${response1.body.index_pattern.id}/fields`) + .send({ + fields: { + runtimeBar: { + format: { + id: 'duration', + params: { inputFormat: 'milliseconds', outputFormat: 'humanizePrecise' }, + }, + }, + }, + }); + + expect(response4.status).to.be(200); + + const response5 = await supertest.get( + '/api/index_patterns/index_pattern/' + response1.body.index_pattern.id + ); + + expect(response5.status).to.be(200); + + const resultIndexPattern = response5.body.index_pattern; + + const runtimeField = resultIndexPattern.fields.runtimeBar; + expect(runtimeField.name).to.be('runtimeBar'); + expect(runtimeField.runtimeField.type).to.be('long'); + expect(runtimeField.runtimeField.script.source).to.be("emit(doc['field_name'].value)"); + expect(runtimeField.scripted).to.be(false); + + expect(resultIndexPattern.fieldFormats.runtimeBar.id).to.be('duration'); + expect(resultIndexPattern.fieldFormats.runtimeBar.params.inputFormat).to.be('milliseconds'); + expect(resultIndexPattern.fieldFormats.runtimeBar.params.outputFormat).to.be( + 'humanizePrecise' + ); + + expect(resultIndexPattern.fieldAttrs.runtimeBar.count).to.be(123); + expect(resultIndexPattern.fieldAttrs.runtimeBar.customLabel).to.be('test'); + + // check that retrieved object is transient and a clone can be created + const response6 = await supertest.post('/api/index_patterns/index_pattern').send({ + override: true, + index_pattern: resultIndexPattern, + }); + + expect(response6.status).to.be(200); + const recreatedIndexPattern = response6.body.index_pattern; + + expect(_.omit(recreatedIndexPattern, 'version')).to.eql( + _.omit(resultIndexPattern, 'version') + ); + }); + }); +} diff --git a/test/api_integration/apis/index_patterns/runtime_fields_crud/create_runtime_field/errors.ts b/test/api_integration/apis/index_patterns/runtime_fields_crud/create_runtime_field/errors.ts new file mode 100644 index 0000000000000..8ce9e3b36b5c8 --- /dev/null +++ b/test/api_integration/apis/index_patterns/runtime_fields_crud/create_runtime_field/errors.ts @@ -0,0 +1,35 @@ +/* + * 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 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import expect from '@kbn/expect'; +import { FtrProviderContext } from '../../../../ftr_provider_context'; + +export default function ({ getService }: FtrProviderContext) { + const supertest = getService('supertest'); + + describe('errors', () => { + it('returns an error field object is not provided', async () => { + const title = `foo-${Date.now()}-${Math.random()}*`; + const response1 = await supertest.post('/api/index_patterns/index_pattern').send({ + index_pattern: { + title, + }, + }); + const id = response1.body.index_pattern.id; + const response2 = await supertest + .post(`/api/index_patterns/index_pattern/${id}/runtime_field`) + .send({}); + + expect(response2.status).to.be(400); + expect(response2.body.statusCode).to.be(400); + expect(response2.body.message).to.be( + '[request body.name]: expected value of type [string] but got [undefined]' + ); + }); + }); +} diff --git a/test/api_integration/apis/index_patterns/runtime_fields_crud/create_runtime_field/index.ts b/test/api_integration/apis/index_patterns/runtime_fields_crud/create_runtime_field/index.ts new file mode 100644 index 0000000000000..2cb90ca087f49 --- /dev/null +++ b/test/api_integration/apis/index_patterns/runtime_fields_crud/create_runtime_field/index.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 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import { FtrProviderContext } from '../../../../ftr_provider_context'; + +export default function ({ loadTestFile }: FtrProviderContext) { + describe('create_runtime_field', () => { + loadTestFile(require.resolve('./errors')); + loadTestFile(require.resolve('./main')); + }); +} diff --git a/test/api_integration/apis/index_patterns/runtime_fields_crud/create_runtime_field/main.ts b/test/api_integration/apis/index_patterns/runtime_fields_crud/create_runtime_field/main.ts new file mode 100644 index 0000000000000..e262b9d838e97 --- /dev/null +++ b/test/api_integration/apis/index_patterns/runtime_fields_crud/create_runtime_field/main.ts @@ -0,0 +1,95 @@ +/* + * 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 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import expect from '@kbn/expect'; +import { FtrProviderContext } from '../../../../ftr_provider_context'; + +export default function ({ getService }: FtrProviderContext) { + const supertest = getService('supertest'); + const esArchiver = getService('esArchiver'); + + describe('main', () => { + before(async () => { + await esArchiver.load('test/api_integration/fixtures/es_archiver/index_patterns/basic_index'); + }); + + after(async () => { + await esArchiver.unload( + 'test/api_integration/fixtures/es_archiver/index_patterns/basic_index' + ); + }); + + it('can create a new runtime field', async () => { + const title = `basic_index*`; + const response1 = await supertest.post('/api/index_patterns/index_pattern').send({ + override: true, + index_pattern: { + title, + }, + }); + const id = response1.body.index_pattern.id; + const response2 = await supertest + .post(`/api/index_patterns/index_pattern/${id}/runtime_field`) + .send({ + name: 'runtimeBar', + runtimeField: { + type: 'long', + script: { + source: "emit(doc['field_name'].value)", + }, + }, + }); + + expect(response2.status).to.be(200); + expect(response2.body.field.name).to.be('runtimeBar'); + expect(response2.body.field.runtimeField.type).to.be('long'); + expect(response2.body.field.runtimeField.script.source).to.be( + "emit(doc['field_name'].value)" + ); + expect(response2.body.field.scripted).to.be(false); + }); + + it('newly created runtime field is available in the index_pattern object', async () => { + const title = `basic_index`; + const response1 = await supertest.post('/api/index_patterns/index_pattern').send({ + override: true, + index_pattern: { + title, + }, + }); + + await supertest + .post(`/api/index_patterns/index_pattern/${response1.body.index_pattern.id}/runtime_field`) + .send({ + name: 'runtimeBar', + runtimeField: { + type: 'long', + script: { + source: "emit(doc['field_name'].value)", + }, + }, + }); + + const response2 = await supertest.get( + '/api/index_patterns/index_pattern/' + response1.body.index_pattern.id + ); + + expect(response2.status).to.be(200); + + const field = response2.body.index_pattern.fields.runtimeBar; + + expect(field.name).to.be('runtimeBar'); + expect(field.runtimeField.type).to.be('long'); + expect(field.runtimeField.script.source).to.be("emit(doc['field_name'].value)"); + expect(field.scripted).to.be(false); + await supertest.delete( + '/api/index_patterns/index_pattern/' + response1.body.index_pattern.id + ); + }); + }); +} diff --git a/test/api_integration/apis/index_patterns/runtime_fields_crud/delete_runtime_field/errors.ts b/test/api_integration/apis/index_patterns/runtime_fields_crud/delete_runtime_field/errors.ts new file mode 100644 index 0000000000000..b41a630889ff8 --- /dev/null +++ b/test/api_integration/apis/index_patterns/runtime_fields_crud/delete_runtime_field/errors.ts @@ -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 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import expect from '@kbn/expect'; +import { FtrProviderContext } from '../../../../ftr_provider_context'; + +export default function ({ getService }: FtrProviderContext) { + const esArchiver = getService('esArchiver'); + const supertest = getService('supertest'); + + describe('errors', () => { + const basicIndex = 'b*sic_index'; + let indexPattern: any; + + before(async () => { + await esArchiver.load('test/api_integration/fixtures/es_archiver/index_patterns/basic_index'); + + indexPattern = ( + await supertest.post('/api/index_patterns/index_pattern').send({ + index_pattern: { + title: basicIndex, + }, + }) + ).body.index_pattern; + }); + + after(async () => { + 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); + } + }); + + it('returns 404 error on non-existing index_pattern', async () => { + const id = `xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx-${Date.now()}`; + const response = await supertest.delete( + `/api/index_patterns/index_pattern/${id}/runtime_field/foo` + ); + + expect(response.status).to.be(404); + }); + + it('returns 404 error on non-existing runtime field', async () => { + const response1 = await supertest.delete( + `/api/index_patterns/index_pattern/${indexPattern.id}/runtime_field/test` + ); + + expect(response1.status).to.be(404); + }); + + it('returns error when attempting to delete a field which is not a runtime field', async () => { + const response2 = await supertest.delete( + `/api/index_patterns/index_pattern/${indexPattern.id}/runtime_field/foo` + ); + + expect(response2.status).to.be(400); + expect(response2.body.statusCode).to.be(400); + expect(response2.body.message).to.be('Only runtime fields can be deleted.'); + }); + + it('returns error when ID is too long', async () => { + const id = `xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx`; + const response = await supertest.delete( + `/api/index_patterns/index_pattern/${id}/runtime_field/foo` + ); + + expect(response.status).to.be(400); + expect(response.body.message).to.be( + '[request params.id]: value has length [1759] but it must have a maximum length of [1000].' + ); + }); + }); +} diff --git a/test/api_integration/apis/index_patterns/runtime_fields_crud/delete_runtime_field/index.ts b/test/api_integration/apis/index_patterns/runtime_fields_crud/delete_runtime_field/index.ts new file mode 100644 index 0000000000000..a14201e750dda --- /dev/null +++ b/test/api_integration/apis/index_patterns/runtime_fields_crud/delete_runtime_field/index.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 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import { FtrProviderContext } from '../../../../ftr_provider_context'; + +export default function ({ loadTestFile }: FtrProviderContext) { + describe('delete_runtime_field', () => { + loadTestFile(require.resolve('./errors')); + loadTestFile(require.resolve('./main')); + }); +} diff --git a/test/api_integration/apis/index_patterns/runtime_fields_crud/delete_runtime_field/main.ts b/test/api_integration/apis/index_patterns/runtime_fields_crud/delete_runtime_field/main.ts new file mode 100644 index 0000000000000..3c74aa336e440 --- /dev/null +++ b/test/api_integration/apis/index_patterns/runtime_fields_crud/delete_runtime_field/main.ts @@ -0,0 +1,66 @@ +/* + * 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 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import expect from '@kbn/expect'; +import { FtrProviderContext } from '../../../../ftr_provider_context'; + +export default function ({ getService }: FtrProviderContext) { + const supertest = getService('supertest'); + const esArchiver = getService('esArchiver'); + + describe('main', () => { + before(async () => { + await esArchiver.load('test/api_integration/fixtures/es_archiver/index_patterns/basic_index'); + }); + + after(async () => { + await esArchiver.unload( + 'test/api_integration/fixtures/es_archiver/index_patterns/basic_index' + ); + }); + + it('can delete a runtime field', async () => { + const title = `basic_index*`; + const response1 = await supertest.post('/api/index_patterns/index_pattern').send({ + override: true, + index_pattern: { + title, + runtimeFieldMap: { + runtimeBar: { + type: 'long', + script: { + source: "emit(doc['field_name'].value)", + }, + }, + }, + }, + }); + + const response2 = await supertest.get( + '/api/index_patterns/index_pattern/' + response1.body.index_pattern.id + ); + + expect(typeof response2.body.index_pattern.fields.runtimeBar).to.be('object'); + + const response3 = await supertest.delete( + `/api/index_patterns/index_pattern/${response1.body.index_pattern.id}/runtime_field/runtimeBar` + ); + + expect(response3.status).to.be(200); + + const response4 = await supertest.get( + '/api/index_patterns/index_pattern/' + response1.body.index_pattern.id + ); + + expect(typeof response4.body.index_pattern.fields.runtimeBar).to.be('undefined'); + await supertest.delete( + '/api/index_patterns/index_pattern/' + response1.body.index_pattern.id + ); + }); + }); +} diff --git a/test/api_integration/apis/index_patterns/runtime_fields_crud/get_runtime_field/errors.ts b/test/api_integration/apis/index_patterns/runtime_fields_crud/get_runtime_field/errors.ts new file mode 100644 index 0000000000000..3608089e4641a --- /dev/null +++ b/test/api_integration/apis/index_patterns/runtime_fields_crud/get_runtime_field/errors.ts @@ -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 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import expect from '@kbn/expect'; +import { FtrProviderContext } from '../../../../ftr_provider_context'; + +export default function ({ getService }: FtrProviderContext) { + const esArchiver = getService('esArchiver'); + const supertest = getService('supertest'); + + describe('errors', () => { + const basicIndex = '*asic_index'; + let indexPattern: any; + + before(async () => { + await esArchiver.load('test/api_integration/fixtures/es_archiver/index_patterns/basic_index'); + + indexPattern = ( + await supertest.post('/api/index_patterns/index_pattern').send({ + index_pattern: { + title: basicIndex, + }, + }) + ).body.index_pattern; + }); + + after(async () => { + 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); + } + }); + + it('returns 404 error on non-existing index_pattern', async () => { + const id = `xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx-${Date.now()}`; + const response = await supertest.get( + `/api/index_patterns/index_pattern/${id}/runtime_field/foo` + ); + + expect(response.status).to.be(404); + }); + + it('returns 404 error on non-existing runtime field', async () => { + const response1 = await supertest.get( + `/api/index_patterns/index_pattern/${indexPattern.id}/runtime_field/sf` + ); + + expect(response1.status).to.be(404); + }); + + it('returns error when ID is too long', async () => { + const id = `xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx`; + const response = await supertest.get( + `/api/index_patterns/index_pattern/${id}/runtime_field/foo` + ); + + expect(response.status).to.be(400); + expect(response.body.message).to.be( + '[request params.id]: value has length [1759] but it must have a maximum length of [1000].' + ); + }); + + it('returns error when attempting to fetch a field which is not a runtime field', async () => { + const response2 = await supertest.get( + `/api/index_patterns/index_pattern/${indexPattern.id}/runtime_field/foo` + ); + + expect(response2.status).to.be(400); + expect(response2.body.statusCode).to.be(400); + expect(response2.body.message).to.be('Only runtime fields can be retrieved.'); + }); + }); +} diff --git a/test/api_integration/apis/index_patterns/runtime_fields_crud/get_runtime_field/index.ts b/test/api_integration/apis/index_patterns/runtime_fields_crud/get_runtime_field/index.ts new file mode 100644 index 0000000000000..2e48ba64841ee --- /dev/null +++ b/test/api_integration/apis/index_patterns/runtime_fields_crud/get_runtime_field/index.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 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import { FtrProviderContext } from '../../../../ftr_provider_context'; + +export default function ({ loadTestFile }: FtrProviderContext) { + describe('get_runtime_field', () => { + loadTestFile(require.resolve('./errors')); + loadTestFile(require.resolve('./main')); + }); +} diff --git a/test/api_integration/apis/index_patterns/runtime_fields_crud/get_runtime_field/main.ts b/test/api_integration/apis/index_patterns/runtime_fields_crud/get_runtime_field/main.ts new file mode 100644 index 0000000000000..fa0283d69d8e3 --- /dev/null +++ b/test/api_integration/apis/index_patterns/runtime_fields_crud/get_runtime_field/main.ts @@ -0,0 +1,71 @@ +/* + * 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 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import expect from '@kbn/expect'; +import { FtrProviderContext } from '../../../../ftr_provider_context'; + +export default function ({ getService }: FtrProviderContext) { + const supertest = getService('supertest'); + const esArchiver = getService('esArchiver'); + + describe('main', () => { + before(async () => { + await esArchiver.load('test/api_integration/fixtures/es_archiver/index_patterns/basic_index'); + }); + + after(async () => { + await esArchiver.unload( + 'test/api_integration/fixtures/es_archiver/index_patterns/basic_index' + ); + }); + + it('can fetch a runtime field', async () => { + const title = `basic_index*`; + const response1 = await supertest.post('/api/index_patterns/index_pattern').send({ + override: true, + index_pattern: { + title, + runtimeFieldMap: { + runtimeFoo: { + type: 'keyword', + script: { + source: "emit(doc['field_name'].value)", + }, + }, + runtimeBar: { + type: 'keyword', + script: { + source: "emit(doc['field_name'].value)", + }, + }, + }, + }, + }); + + expect(response1.status).to.be(200); + + const response2 = await supertest.get( + '/api/index_patterns/index_pattern/' + + response1.body.index_pattern.id + + '/runtime_field/runtimeFoo' + ); + + expect(response2.status).to.be(200); + expect(typeof response2.body.field).to.be('object'); + expect(response2.body.field.name).to.be('runtimeFoo'); + expect(response2.body.field.type).to.be('string'); + expect(response2.body.field.scripted).to.be(false); + expect(response2.body.field.runtimeField.script.source).to.be( + "emit(doc['field_name'].value)" + ); + await supertest.delete( + '/api/index_patterns/index_pattern/' + response1.body.index_pattern.id + ); + }); + }); +} diff --git a/test/api_integration/apis/index_patterns/runtime_fields_crud/index.ts b/test/api_integration/apis/index_patterns/runtime_fields_crud/index.ts new file mode 100644 index 0000000000000..7a727a3e86755 --- /dev/null +++ b/test/api_integration/apis/index_patterns/runtime_fields_crud/index.ts @@ -0,0 +1,19 @@ +/* + * 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 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import { FtrProviderContext } from '../../../ftr_provider_context'; + +export default function ({ loadTestFile }: FtrProviderContext) { + describe('runtime_fields_crud', () => { + loadTestFile(require.resolve('./create_runtime_field')); + loadTestFile(require.resolve('./get_runtime_field')); + loadTestFile(require.resolve('./delete_runtime_field')); + loadTestFile(require.resolve('./put_runtime_field')); + loadTestFile(require.resolve('./update_runtime_field')); + }); +} diff --git a/test/api_integration/apis/index_patterns/runtime_fields_crud/put_runtime_field/errors.ts b/test/api_integration/apis/index_patterns/runtime_fields_crud/put_runtime_field/errors.ts new file mode 100644 index 0000000000000..9faca08238033 --- /dev/null +++ b/test/api_integration/apis/index_patterns/runtime_fields_crud/put_runtime_field/errors.ts @@ -0,0 +1,69 @@ +/* + * 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 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import expect from '@kbn/expect'; +import { FtrProviderContext } from '../../../../ftr_provider_context'; + +export default function ({ getService }: FtrProviderContext) { + const supertest = getService('supertest'); + const esArchiver = getService('esArchiver'); + + describe('errors', () => { + before(async () => { + await esArchiver.load('test/api_integration/fixtures/es_archiver/index_patterns/basic_index'); + }); + + after(async () => { + await esArchiver.unload( + 'test/api_integration/fixtures/es_archiver/index_patterns/basic_index' + ); + }); + + it('returns 404 error on non-existing index_pattern', async () => { + const id = `xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx-${Date.now()}`; + const response = await supertest + .put(`/api/index_patterns/index_pattern/${id}/runtime_field`) + .send({ + name: 'runtimeBar', + runtimeField: { + type: 'long', + script: { + source: "emit(doc['field_name'].value)", + }, + }, + }); + + expect(response.status).to.be(404); + }); + + it('returns error on non-runtime field update attempt', async () => { + const title = `basic_index`; + const response1 = await supertest.post('/api/index_patterns/index_pattern').send({ + override: true, + index_pattern: { + title, + }, + }); + + const response2 = await supertest + .put(`/api/index_patterns/index_pattern/${response1.body.index_pattern.id}/runtime_field`) + .send({ + name: 'bar', + runtimeField: { + type: 'long', + script: { + source: "emit(doc['field_name'].value)", + }, + }, + }); + + expect(response2.status).to.be(400); + expect(response2.body.message).to.be('Only runtime fields can be updated'); + }); + }); +} diff --git a/test/api_integration/apis/index_patterns/runtime_fields_crud/put_runtime_field/index.ts b/test/api_integration/apis/index_patterns/runtime_fields_crud/put_runtime_field/index.ts new file mode 100644 index 0000000000000..724f18e57f3ef --- /dev/null +++ b/test/api_integration/apis/index_patterns/runtime_fields_crud/put_runtime_field/index.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 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import { FtrProviderContext } from '../../../../ftr_provider_context'; + +export default function ({ loadTestFile }: FtrProviderContext) { + describe('put_runtime_field', () => { + loadTestFile(require.resolve('./errors')); + loadTestFile(require.resolve('./main')); + }); +} diff --git a/test/api_integration/apis/index_patterns/runtime_fields_crud/put_runtime_field/main.ts b/test/api_integration/apis/index_patterns/runtime_fields_crud/put_runtime_field/main.ts new file mode 100644 index 0000000000000..92d8c6fd6d3c2 --- /dev/null +++ b/test/api_integration/apis/index_patterns/runtime_fields_crud/put_runtime_field/main.ts @@ -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 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import expect from '@kbn/expect'; +import { FtrProviderContext } from '../../../../ftr_provider_context'; + +export default function ({ getService }: FtrProviderContext) { + const supertest = getService('supertest'); + const esArchiver = getService('esArchiver'); + + describe('main', () => { + before(async () => { + await esArchiver.load('test/api_integration/fixtures/es_archiver/index_patterns/basic_index'); + }); + + after(async () => { + await esArchiver.unload( + 'test/api_integration/fixtures/es_archiver/index_patterns/basic_index' + ); + }); + + it('can overwrite an existing field', async () => { + const title = `basic_index`; + const response1 = await supertest.post('/api/index_patterns/index_pattern').send({ + override: true, + index_pattern: { + title, + runtimeFieldMap: { + runtimeFoo: { + type: 'keyword', + script: { + source: "doc['field_name'].value", + }, + }, + runtimeBar: { + type: 'keyword', + script: { + source: "doc['field_name'].value", + }, + }, + }, + }, + }); + + const response2 = await supertest + .put(`/api/index_patterns/index_pattern/${response1.body.index_pattern.id}/runtime_field`) + .send({ + name: 'runtimeFoo', + runtimeField: { + type: 'long', + script: { + source: "doc['field_name'].value", + }, + }, + }); + + expect(response2.status).to.be(200); + + const response3 = await supertest.get( + '/api/index_patterns/index_pattern/' + + response1.body.index_pattern.id + + '/runtime_field/runtimeFoo' + ); + + expect(response3.status).to.be(200); + expect(response3.body.field.type).to.be('number'); + + const response4 = await supertest.get( + '/api/index_patterns/index_pattern/' + + response1.body.index_pattern.id + + '/runtime_field/runtimeBar' + ); + + expect(response4.status).to.be(200); + expect(response4.body.field.type).to.be('string'); + }); + + it('can add a new runtime field', async () => { + const title = `basic_index`; + const response1 = await supertest.post('/api/index_patterns/index_pattern').send({ + override: true, + index_pattern: { + title, + runtimeFieldMap: { + runtimeFoo: { + type: 'keyword', + script: { + source: "doc['field_name'].value", + }, + }, + }, + }, + }); + + await supertest + .put(`/api/index_patterns/index_pattern/${response1.body.index_pattern.id}/runtime_field`) + .send({ + name: 'runtimeBar', + runtimeField: { + type: 'long', + script: { + source: "doc['field_name'].value", + }, + }, + }); + + const response2 = await supertest.get( + '/api/index_patterns/index_pattern/' + + response1.body.index_pattern.id + + '/runtime_field/runtimeBar' + ); + + expect(response2.status).to.be(200); + expect(typeof response2.body.field.runtimeField).to.be('object'); + }); + }); +} diff --git a/test/api_integration/apis/index_patterns/runtime_fields_crud/update_runtime_field/errors.ts b/test/api_integration/apis/index_patterns/runtime_fields_crud/update_runtime_field/errors.ts new file mode 100644 index 0000000000000..3980821c0fd09 --- /dev/null +++ b/test/api_integration/apis/index_patterns/runtime_fields_crud/update_runtime_field/errors.ts @@ -0,0 +1,51 @@ +/* + * 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 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import expect from '@kbn/expect'; +import { FtrProviderContext } from '../../../../ftr_provider_context'; + +export default function ({ getService }: FtrProviderContext) { + const supertest = getService('supertest'); + + describe('errors', () => { + it('returns 404 error on non-existing index_pattern', async () => { + const id = `xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx-${Date.now()}`; + const response = await supertest + .post(`/api/index_patterns/index_pattern/${id}/runtime_field/foo`) + .send({ + runtimeField: { + script: { + source: "doc['something_new'].value", + }, + }, + }); + + expect(response.status).to.be(404); + }); + + it('returns error when field name is specified', async () => { + const id = `xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx-${Date.now()}`; + const response = await supertest + .post(`/api/index_patterns/index_pattern/${id}/runtime_field/foo`) + .send({ + name: 'foo', + runtimeField: { + script: { + source: "doc['something_new'].value", + }, + }, + }); + + expect(response.status).to.be(400); + expect(response.body.statusCode).to.be(400); + expect(response.body.message).to.be( + "[request body.name]: a value wasn't expected to be present" + ); + }); + }); +} diff --git a/test/api_integration/apis/index_patterns/runtime_fields_crud/update_runtime_field/index.ts b/test/api_integration/apis/index_patterns/runtime_fields_crud/update_runtime_field/index.ts new file mode 100644 index 0000000000000..f5d556ca9994a --- /dev/null +++ b/test/api_integration/apis/index_patterns/runtime_fields_crud/update_runtime_field/index.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 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import { FtrProviderContext } from '../../../../ftr_provider_context'; + +export default function ({ loadTestFile }: FtrProviderContext) { + describe('update_runtime_field', () => { + loadTestFile(require.resolve('./errors')); + loadTestFile(require.resolve('./main')); + }); +} diff --git a/test/api_integration/apis/index_patterns/runtime_fields_crud/update_runtime_field/main.ts b/test/api_integration/apis/index_patterns/runtime_fields_crud/update_runtime_field/main.ts new file mode 100644 index 0000000000000..6b924570a0e45 --- /dev/null +++ b/test/api_integration/apis/index_patterns/runtime_fields_crud/update_runtime_field/main.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 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import expect from '@kbn/expect'; +import { FtrProviderContext } from '../../../../ftr_provider_context'; + +export default function ({ getService }: FtrProviderContext) { + const supertest = getService('supertest'); + const esArchiver = getService('esArchiver'); + + describe('main', () => { + before(async () => { + await esArchiver.load('test/api_integration/fixtures/es_archiver/index_patterns/basic_index'); + }); + + after(async () => { + await esArchiver.unload( + 'test/api_integration/fixtures/es_archiver/index_patterns/basic_index' + ); + }); + + it('can update an existing field', async () => { + const title = `basic_index`; + const response1 = await supertest.post('/api/index_patterns/index_pattern').send({ + override: true, + index_pattern: { + title, + runtimeFieldMap: { + runtimeFoo: { + type: 'keyword', + script: { + source: "doc['field_name'].value", + }, + }, + runtimeBar: { + type: 'keyword', + script: { + source: "doc['field_name'].value", + }, + }, + }, + }, + }); + + const response2 = await supertest + .post( + `/api/index_patterns/index_pattern/${response1.body.index_pattern.id}/runtime_field/runtimeFoo` + ) + .send({ + runtimeField: { + script: { + source: "doc['something_new'].value", + }, + }, + }); + + expect(response2.status).to.be(200); + + const response3 = await supertest.get( + '/api/index_patterns/index_pattern/' + + response1.body.index_pattern.id + + '/runtime_field/runtimeFoo' + ); + + expect(response3.status).to.be(200); + expect(response3.body.field.type).to.be('string'); + expect(response3.body.field.runtimeField.type).to.be('keyword'); + expect(response3.body.field.runtimeField.script.source).to.be("doc['something_new'].value"); + }); + }); +} 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 1210e7247f72d..663deae1d3476 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 @@ -54,6 +54,7 @@ export default function ({ getService }: FtrProviderContext) { it('newly created scripted field is materialized in the index_pattern object', async () => { const title = `basic_index`; const response1 = await supertest.post('/api/index_patterns/index_pattern').send({ + override: true, index_pattern: { title, }, 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 466af26f6e127..b9ce3e84d5390 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 @@ -27,6 +27,7 @@ export default function ({ getService }: FtrProviderContext) { it('can remove a scripted field', async () => { const title = `basic_index`; const response1 = await supertest.post('/api/index_patterns/index_pattern').send({ + override: true, index_pattern: { title, fields: { 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 64d909480260e..c38c3a01708a7 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 @@ -27,6 +27,7 @@ export default function ({ getService }: FtrProviderContext) { it('can fetch a scripted field', async () => { const title = `basic_index`; const response1 = await supertest.post('/api/index_patterns/index_pattern').send({ + override: true, index_pattern: { title, fields: { 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 96f5924e7c132..16b1958306818 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 @@ -27,6 +27,7 @@ export default function ({ getService }: FtrProviderContext) { it('can overwrite an existing field', async () => { const title = `basic_index`; const response1 = await supertest.post('/api/index_patterns/index_pattern').send({ + override: true, index_pattern: { title, fields: { 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 055b3fe9abe04..4ffc98e0660bc 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 @@ -27,6 +27,7 @@ export default function ({ getService }: FtrProviderContext) { it('can update an existing field', async () => { const title = `basic_index`; const response1 = await supertest.post('/api/index_patterns/index_pattern').send({ + override: true, index_pattern: { title, fields: { From 520d1e8c042526900060a028e417b17766997d31 Mon Sep 17 00:00:00 2001 From: Dario Gieselaar Date: Wed, 9 Jun 2021 15:42:05 +0200 Subject: [PATCH 22/25] [APM] Add link-to/transaction route (#101731) --- .../components/app/transaction_link/index.tsx | 67 +++++++++++++++++++ .../components/routing/apm_route_config.tsx | 7 ++ .../lib/transactions/get_transaction/index.ts | 10 +-- x-pack/plugins/apm/server/routes/traces.ts | 20 +++++- 4 files changed, 98 insertions(+), 6 deletions(-) create mode 100644 x-pack/plugins/apm/public/components/app/transaction_link/index.tsx diff --git a/x-pack/plugins/apm/public/components/app/transaction_link/index.tsx b/x-pack/plugins/apm/public/components/app/transaction_link/index.tsx new file mode 100644 index 0000000000000..c6394f09b0d3c --- /dev/null +++ b/x-pack/plugins/apm/public/components/app/transaction_link/index.tsx @@ -0,0 +1,67 @@ +/* + * 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 { EuiEmptyPrompt } from '@elastic/eui'; +import React from 'react'; +import { Redirect, RouteComponentProps } from 'react-router-dom'; +import { euiStyled } from '../../../../../../../src/plugins/kibana_react/common'; +import { FETCH_STATUS, useFetcher } from '../../../hooks/use_fetcher'; +import { useUrlParams } from '../../../context/url_params_context/use_url_params'; +import { getRedirectToTransactionDetailPageUrl } from '../TraceLink/get_redirect_to_transaction_detail_page_url'; + +const CentralizedContainer = euiStyled.div` + height: 100%; + display: flex; +`; + +export function TransactionLink({ + match, +}: RouteComponentProps<{ transactionId: string }>) { + const { transactionId } = match.params; + const { urlParams } = useUrlParams(); + const { rangeFrom, rangeTo } = urlParams; + + const { data = { transaction: null }, status } = useFetcher( + (callApmApi) => { + if (transactionId) { + return callApmApi({ + endpoint: 'GET /api/apm/transactions/{transactionId}', + params: { + path: { + transactionId, + }, + }, + }); + } + }, + [transactionId] + ); + if (transactionId && status === FETCH_STATUS.SUCCESS) { + if (data.transaction) { + return ( + + ); + } + + return ; + } + + return ( + + Fetching transaction...} + /> + + ); +} diff --git a/x-pack/plugins/apm/public/components/routing/apm_route_config.tsx b/x-pack/plugins/apm/public/components/routing/apm_route_config.tsx index 3d530f4614d82..36580d38e660d 100644 --- a/x-pack/plugins/apm/public/components/routing/apm_route_config.tsx +++ b/x-pack/plugins/apm/public/components/routing/apm_route_config.tsx @@ -20,6 +20,7 @@ import { AnomalyDetection } from '../app/Settings/anomaly_detection'; import { ApmIndices } from '../app/Settings/ApmIndices'; import { CustomizeUI } from '../app/Settings/CustomizeUI'; import { TraceLink } from '../app/TraceLink'; +import { TransactionLink } from '../app/transaction_link'; import { TransactionDetails } from '../app/transaction_details'; import { enableServiceOverview } from '../../../common/ui_settings_keys'; import { redirectTo } from './redirect_to'; @@ -498,6 +499,12 @@ export const apmRouteConfig: APMRouteDefinition[] = [ component: TraceLink, breadcrumb: null, }, + { + exact: true, + path: '/link-to/transaction/:transactionId', + component: TransactionLink, + breadcrumb: null, + }, ]; function RedirectToDefaultServiceRouteView( diff --git a/x-pack/plugins/apm/server/lib/transactions/get_transaction/index.ts b/x-pack/plugins/apm/server/lib/transactions/get_transaction/index.ts index b4323ae7f51e2..6987ef0757734 100644 --- a/x-pack/plugins/apm/server/lib/transactions/get_transaction/index.ts +++ b/x-pack/plugins/apm/server/lib/transactions/get_transaction/index.ts @@ -21,11 +21,11 @@ export function getTransaction({ setup, }: { transactionId: string; - traceId: string; - setup: Setup & SetupTimeRange; + traceId?: string; + setup: Setup | (Setup & SetupTimeRange); }) { return withApmSpan('get_transaction', async () => { - const { start, end, apmEventClient } = setup; + const { apmEventClient } = setup; const resp = await apmEventClient.search({ apm: { @@ -37,8 +37,8 @@ export function getTransaction({ bool: { filter: asMutableArray([ { term: { [TRANSACTION_ID]: transactionId } }, - { term: { [TRACE_ID]: traceId } }, - ...rangeQuery(start, end), + ...(traceId ? [{ term: { [TRACE_ID]: traceId } }] : []), + ...('start' in setup ? rangeQuery(setup.start, setup.end) : []), ]), }, }, diff --git a/x-pack/plugins/apm/server/routes/traces.ts b/x-pack/plugins/apm/server/routes/traces.ts index dd392982b02fd..7fce04644f220 100644 --- a/x-pack/plugins/apm/server/routes/traces.ts +++ b/x-pack/plugins/apm/server/routes/traces.ts @@ -14,6 +14,7 @@ import { environmentRt, kueryRt, rangeRt } from './default_api_types'; import { getSearchAggregatedTransactions } from '../lib/helpers/aggregated_transactions'; import { getRootTransactionByTraceId } from '../lib/transactions/get_transaction_by_trace'; import { createApmServerRouteRepository } from './create_apm_server_route_repository'; +import { getTransaction } from '../lib/transactions/get_transaction'; const tracesRoute = createApmServerRoute({ endpoint: 'GET /api/apm/traces', @@ -70,7 +71,24 @@ const rootTransactionByTraceIdRoute = createApmServerRoute({ }, }); +const transactionByIdRoute = createApmServerRoute({ + endpoint: 'GET /api/apm/transactions/{transactionId}', + params: t.type({ + path: t.type({ + transactionId: t.string, + }), + }), + options: { tags: ['access:apm'] }, + handler: async (resources) => { + const { params } = resources; + const { transactionId } = params.path; + const setup = await setupRequest(resources); + return { transaction: await getTransaction({ transactionId, setup }) }; + }, +}); + export const traceRouteRepository = createApmServerRouteRepository() .add(tracesByIdRoute) .add(tracesRoute) - .add(rootTransactionByTraceIdRoute); + .add(rootTransactionByTraceIdRoute) + .add(transactionByIdRoute); From 58eb0d40e989e00966c651447772f8f3b746c4f9 Mon Sep 17 00:00:00 2001 From: Kyle Pollich Date: Wed, 9 Jun 2021 10:07:29 -0400 Subject: [PATCH 23/25] [Fleet] Fix routing issues with `getPath` and `history.push` (#101658) * Fix getPath usage in Fleet app * Fix pathname in failing test --- .../integrations/sections/epm/screens/detail/index.test.tsx | 4 +--- x-pack/plugins/fleet/public/hooks/use_link.ts | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/x-pack/plugins/fleet/public/applications/integrations/sections/epm/screens/detail/index.test.tsx b/x-pack/plugins/fleet/public/applications/integrations/sections/epm/screens/detail/index.test.tsx index 4063bc6371cbd..3477335321a2c 100644 --- a/x-pack/plugins/fleet/public/applications/integrations/sections/epm/screens/detail/index.test.tsx +++ b/x-pack/plugins/fleet/public/applications/integrations/sections/epm/screens/detail/index.test.tsx @@ -109,9 +109,7 @@ describe('when on integration detail', () => { pagePathGetters.integration_details_custom({ pkgkey: 'nginx-0.3.7' })[1] ); }); - expect(testRenderer.history.location.pathname).toEqual( - '/app/integrations/detail/nginx-0.3.7/overview' - ); + expect(testRenderer.history.location.pathname).toEqual('/detail/nginx-0.3.7/overview'); }); }); diff --git a/x-pack/plugins/fleet/public/hooks/use_link.ts b/x-pack/plugins/fleet/public/hooks/use_link.ts index df6f45af31d56..6917e0f5c3b8e 100644 --- a/x-pack/plugins/fleet/public/hooks/use_link.ts +++ b/x-pack/plugins/fleet/public/hooks/use_link.ts @@ -21,9 +21,7 @@ export const useLink = () => { const core = useStartServices(); return { getPath: (page: StaticPage | DynamicPage, values: DynamicPagePathValues = {}): string => { - const [basePath, path] = getSeparatePaths(page, values); - - return `${basePath}${path}`; + return getSeparatePaths(page, values)[1]; }, getAssetsPath: (path: string) => core.http.basePath.prepend(`/plugins/${PLUGIN_ID}/assets/${path}`), From 97b952b0e1e7decbd5f3bd97641a4b121bcfc95e Mon Sep 17 00:00:00 2001 From: Dima Arnautov Date: Wed, 9 Jun 2021 16:08:08 +0200 Subject: [PATCH 24/25] [ML] Add debounce to the severity control update (#101581) --- .../application/explorer/anomaly_timeline.tsx | 29 ++++++++++++++----- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/x-pack/plugins/ml/public/application/explorer/anomaly_timeline.tsx b/x-pack/plugins/ml/public/application/explorer/anomaly_timeline.tsx index 8375b0a0b1dfc..d20042ddd9443 100644 --- a/x-pack/plugins/ml/public/application/explorer/anomaly_timeline.tsx +++ b/x-pack/plugins/ml/public/application/explorer/anomaly_timeline.tsx @@ -8,20 +8,21 @@ import React, { FC, useCallback, useMemo, useState } from 'react'; import { isEqual } from 'lodash'; import { - EuiPanel, - EuiPopover, - EuiContextMenuPanel, + EuiButtonEmpty, EuiButtonIcon, + EuiContextMenuItem, + EuiContextMenuPanel, EuiFlexGroup, EuiFlexItem, + EuiPanel, + EuiPopover, EuiSelect, - EuiTitle, EuiSpacer, - EuiContextMenuItem, - EuiButtonEmpty, + EuiTitle, } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; +import useDebounce from 'react-use/lib/useDebounce'; import { OVERALL_LABEL, SWIMLANE_TYPE, VIEW_BY_JOB_LABEL } from './explorer_constants'; import { AddSwimlaneToDashboardControl } from './dashboard_controls/add_swimlane_to_dashboard_controls'; import { useMlKibana } from '../contexts/kibana'; @@ -93,6 +94,18 @@ export const AnomalyTimeline: FC = React.memo( viewBySwimlaneData, } = explorerState; + const [severityUpdate, setSeverityUpdate] = useState(swimLaneSeverity); + + useDebounce( + () => { + if (severityUpdate === swimLaneSeverity) return; + + explorerService.setSwimLaneSeverity(severityUpdate!); + }, + 500, + [severityUpdate, swimLaneSeverity] + ); + const annotations = useMemo(() => overallAnnotations.annotationsData, [overallAnnotations]); const menuItems = useMemo(() => { @@ -194,9 +207,9 @@ export const AnomalyTimeline: FC = React.memo( { - explorerService.setSwimLaneSeverity(update); + setSeverityUpdate(update); }, [])} /> From cd8cf46ad1836fbcaf165fc6761400da5840f38c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Fern=C3=A1ndez=20G=C3=B3mez?= Date: Wed, 9 Jun 2021 16:11:15 +0200 Subject: [PATCH 25/25] [Fleet] Tighten policy permissions, take II (#97366) Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> --- .../fleet/common/types/models/agent_policy.ts | 6 +- .../plugins/fleet/common/types/models/epm.ts | 7 + .../fleet/server/services/agent_policy.ts | 59 ++- .../server/services/epm/archive/storage.ts | 8 +- ...kage_policies_to_agent_permissions.test.ts | 341 ++++++++++++++++++ .../package_policies_to_agent_permissions.ts | 152 ++++++++ 6 files changed, 546 insertions(+), 27 deletions(-) create mode 100644 x-pack/plugins/fleet/server/services/package_policies_to_agent_permissions.test.ts create mode 100644 x-pack/plugins/fleet/server/services/package_policies_to_agent_permissions.ts diff --git a/x-pack/plugins/fleet/common/types/models/agent_policy.ts b/x-pack/plugins/fleet/common/types/models/agent_policy.ts index 753100f622556..a9393abcc57ef 100644 --- a/x-pack/plugins/fleet/common/types/models/agent_policy.ts +++ b/x-pack/plugins/fleet/common/types/models/agent_policy.ts @@ -61,9 +61,9 @@ export interface FullAgentPolicyInput { } export interface FullAgentPolicyOutputPermissions { - [role: string]: { - cluster: string[]; - indices: Array<{ + [packagePolicyName: string]: { + cluster?: string[]; + indices?: Array<{ names: string[]; privileges: string[]; }>; diff --git a/x-pack/plugins/fleet/common/types/models/epm.ts b/x-pack/plugins/fleet/common/types/models/epm.ts index 5551453b8975c..0ef9f8b7ace36 100644 --- a/x-pack/plugins/fleet/common/types/models/epm.ts +++ b/x-pack/plugins/fleet/common/types/models/epm.ts @@ -276,6 +276,7 @@ export enum RegistryDataStreamKeys { ingest_pipeline = 'ingest_pipeline', elasticsearch = 'elasticsearch', dataset_is_prefix = 'dataset_is_prefix', + permissions = 'permissions', } export interface RegistryDataStream { @@ -291,6 +292,7 @@ export interface RegistryDataStream { [RegistryDataStreamKeys.ingest_pipeline]?: string; [RegistryDataStreamKeys.elasticsearch]?: RegistryElasticsearch; [RegistryDataStreamKeys.dataset_is_prefix]?: boolean; + [RegistryDataStreamKeys.permissions]?: RegistryDataStreamPermissions; } export interface RegistryElasticsearch { @@ -298,6 +300,11 @@ export interface RegistryElasticsearch { 'index_template.mappings'?: object; } +export interface RegistryDataStreamPermissions { + cluster?: string[]; + indices?: string[]; +} + export type RegistryVarType = 'integer' | 'bool' | 'password' | 'text' | 'yaml' | 'string'; export enum RegistryVarsEntryKeys { name = 'name', diff --git a/x-pack/plugins/fleet/server/services/agent_policy.ts b/x-pack/plugins/fleet/server/services/agent_policy.ts index 62b4578ab87b2..2a6036d99281e 100644 --- a/x-pack/plugins/fleet/server/services/agent_policy.ts +++ b/x-pack/plugins/fleet/server/services/agent_policy.ts @@ -47,6 +47,10 @@ import type { Output, } from '../../common'; import { AgentPolicyNameExistsError, HostedAgentPolicyRestrictionRelatedError } from '../errors'; +import { + storedPackagePoliciesToAgentPermissions, + DEFAULT_PERMISSIONS, +} from '../services/package_policies_to_agent_permissions'; import { getPackageInfo } from './epm/packages'; import { getAgentsByKuery } from './agents'; @@ -745,30 +749,49 @@ class AgentPolicyService { }), }; + const permissions = (await storedPackagePoliciesToAgentPermissions( + soClient, + agentPolicy.package_policies + )) || { _fallback: DEFAULT_PERMISSIONS }; + + permissions._elastic_agent_checks = { + cluster: DEFAULT_PERMISSIONS.cluster, + }; + + // TODO fetch this from the elastic agent package + const monitoringOutput = fullAgentPolicy.agent?.monitoring.use_output; + const monitoringNamespace = fullAgentPolicy.agent?.monitoring.namespace; + if ( + fullAgentPolicy.agent?.monitoring.enabled && + monitoringNamespace && + monitoringOutput && + fullAgentPolicy.outputs[monitoringOutput]?.type === 'elasticsearch' + ) { + const names: string[] = []; + if (fullAgentPolicy.agent.monitoring.logs) { + names.push(`logs-elastic_agent.*-${monitoringNamespace}`); + } + if (fullAgentPolicy.agent.monitoring.metrics) { + names.push(`metrics-elastic_agent.*-${monitoringNamespace}`); + } + + permissions._elastic_agent_checks.indices = [ + { + names, + privileges: ['auto_configure', 'create_doc'], + }, + ]; + } + // Only add permissions if output.type is "elasticsearch" fullAgentPolicy.output_permissions = Object.keys(fullAgentPolicy.outputs).reduce< NonNullable - >((permissions, outputName) => { + >((outputPermissions, outputName) => { const output = fullAgentPolicy.outputs[outputName]; if (output && output.type === 'elasticsearch') { - permissions[outputName] = {}; - permissions[outputName]._fallback = { - cluster: ['monitor'], - indices: [ - { - names: [ - 'logs-*', - 'metrics-*', - 'traces-*', - '.logs-endpoint.diagnostic.collection-*', - 'synthetics-*', - ], - privileges: ['auto_configure', 'create_doc'], - }, - ], - }; + outputPermissions[outputName] = permissions; } - return permissions; + return outputPermissions; }, {}); // only add settings if not in standalone diff --git a/x-pack/plugins/fleet/server/services/epm/archive/storage.ts b/x-pack/plugins/fleet/server/services/epm/archive/storage.ts index 2db6009270a3b..dde6459addcbc 100644 --- a/x-pack/plugins/fleet/server/services/epm/archive/storage.ts +++ b/x-pack/plugins/fleet/server/services/epm/archive/storage.ts @@ -224,24 +224,20 @@ export const getEsPackage = async ( ); const dataStreamManifest = safeLoad(soResDataStreamManifest.attributes.data_utf8); const { - title: dataStreamTitle, - release, ingest_pipeline: ingestPipeline, - type, dataset, streams: manifestStreams, + ...dataStreamManifestProps } = dataStreamManifest; const streams = parseAndVerifyStreams(manifestStreams, dataStreamPath); dataStreams.push({ dataset: dataset || `${pkgName}.${dataStreamPath}`, - title: dataStreamTitle, - release, package: pkgName, ingest_pipeline: ingestPipeline || 'default', path: dataStreamPath, - type, streams, + ...dataStreamManifestProps, }); }) ); diff --git a/x-pack/plugins/fleet/server/services/package_policies_to_agent_permissions.test.ts b/x-pack/plugins/fleet/server/services/package_policies_to_agent_permissions.test.ts new file mode 100644 index 0000000000000..39759a6fc9e9c --- /dev/null +++ b/x-pack/plugins/fleet/server/services/package_policies_to_agent_permissions.test.ts @@ -0,0 +1,341 @@ +/* + * 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. + */ + +jest.mock('./epm/packages'); +import type { SavedObjectsClientContract } from 'kibana/server'; + +import { savedObjectsClientMock } from '../../../../../src/core/server/mocks'; +import type { PackagePolicy, RegistryDataStream } from '../types'; + +import { getPackageInfo } from './epm/packages'; +import { + getDataStreamPermissions, + storedPackagePoliciesToAgentPermissions, +} from './package_policies_to_agent_permissions'; + +const getPackageInfoMock = getPackageInfo as jest.MockedFunction; + +describe('storedPackagePoliciesToAgentPermissions()', () => { + let soClient: jest.Mocked; + beforeEach(() => { + soClient = savedObjectsClientMock.create(); + }); + + it('Returns `undefined` if there are no package policies', async () => { + const permissions = await storedPackagePoliciesToAgentPermissions(soClient, []); + expect(permissions).toBeUndefined(); + }); + + it('Returns the default permissions for string package policies', async () => { + const permissions = await storedPackagePoliciesToAgentPermissions(soClient, ['foo']); + expect(permissions).toMatchObject({ + _fallback: { + cluster: ['monitor'], + indices: [ + { + names: [ + 'logs-*', + 'metrics-*', + 'traces-*', + 'synthetics-*', + '.logs-endpoint.diagnostic.collection-*', + ], + privileges: ['auto_configure', 'create_doc'], + }, + ], + }, + }); + }); + + it('Returns the default permissions if a package policy does not have a package', async () => { + const permissions = await storedPackagePoliciesToAgentPermissions(soClient, [ + { name: 'foo', package: undefined } as PackagePolicy, + ]); + + expect(permissions).toMatchObject({ + foo: { + cluster: ['monitor'], + indices: [ + { + names: [ + 'logs-*', + 'metrics-*', + 'traces-*', + 'synthetics-*', + '.logs-endpoint.diagnostic.collection-*', + ], + privileges: ['auto_configure', 'create_doc'], + }, + ], + }, + }); + }); + + it('Returns the permissions for the enabled inputs', async () => { + getPackageInfoMock.mockResolvedValueOnce({ + name: 'test-package', + version: '0.0.0', + latestVersion: '0.0.0', + release: 'experimental', + format_version: '1.0.0', + title: 'Test Package', + description: '', + icons: [], + owner: { github: '' }, + status: 'not_installed', + assets: { + kibana: { + dashboard: [], + visualization: [], + search: [], + index_pattern: [], + map: [], + lens: [], + security_rule: [], + ml_module: [], + }, + elasticsearch: { + component_template: [], + ingest_pipeline: [], + ilm_policy: [], + transform: [], + index_template: [], + data_stream_ilm_policy: [], + }, + }, + data_streams: [ + { + type: 'logs', + dataset: 'some-logs', + title: '', + release: '', + package: 'test-package', + path: '', + ingest_pipeline: '', + streams: [{ input: 'test-logs', title: 'Test Logs', template_path: '' }], + }, + { + type: 'metrics', + dataset: 'some-metrics', + title: '', + release: '', + package: 'test-package', + path: '', + ingest_pipeline: '', + streams: [{ input: 'test-metrics', title: 'Test Logs', template_path: '' }], + }, + ], + }); + + const packagePolicies: PackagePolicy[] = [ + { + id: '12345', + name: 'test-policy', + namespace: 'test', + enabled: true, + package: { name: 'test-package', version: '0.0.0', title: 'Test Package' }, + inputs: [ + { + type: 'test-logs', + enabled: true, + streams: [ + { + id: 'test-logs', + enabled: true, + data_stream: { type: 'logs', dataset: 'some-logs' }, + }, + ], + }, + { + type: 'test-metrics', + enabled: false, + streams: [ + { + id: 'test-logs', + enabled: false, + data_stream: { type: 'metrics', dataset: 'some-metrics' }, + }, + ], + }, + ], + created_at: '', + updated_at: '', + created_by: '', + updated_by: '', + revision: 1, + policy_id: '', + output_id: '', + }, + ]; + + const permissions = await storedPackagePoliciesToAgentPermissions(soClient, packagePolicies); + expect(permissions).toMatchObject({ + 'test-policy': { + indices: [ + { + names: ['logs-some-logs-test'], + privileges: ['auto_configure', 'create_doc'], + }, + ], + }, + }); + }); + + it('Returns the dataset for the compiled data_streams', async () => { + getPackageInfoMock.mockResolvedValueOnce({ + name: 'test-package', + version: '0.0.0', + latestVersion: '0.0.0', + release: 'experimental', + format_version: '1.0.0', + title: 'Test Package', + description: '', + icons: [], + owner: { github: '' }, + status: 'not_installed', + assets: { + kibana: { + dashboard: [], + visualization: [], + search: [], + index_pattern: [], + map: [], + lens: [], + security_rule: [], + ml_module: [], + }, + elasticsearch: { + component_template: [], + ingest_pipeline: [], + ilm_policy: [], + transform: [], + index_template: [], + data_stream_ilm_policy: [], + }, + }, + data_streams: [ + { + type: 'logs', + dataset: 'some-logs', + title: '', + release: '', + package: 'test-package', + path: '', + ingest_pipeline: '', + streams: [{ input: 'test-logs', title: 'Test Logs', template_path: '' }], + }, + ], + }); + + const packagePolicies: PackagePolicy[] = [ + { + id: '12345', + name: 'test-policy', + namespace: 'test', + enabled: true, + package: { name: 'test-package', version: '0.0.0', title: 'Test Package' }, + inputs: [ + { + type: 'test-logs', + enabled: true, + streams: [ + { + id: 'test-logs', + enabled: true, + data_stream: { type: 'logs', dataset: 'some-logs' }, + compiled_stream: { data_stream: { dataset: 'compiled' } }, + }, + ], + }, + ], + created_at: '', + updated_at: '', + created_by: '', + updated_by: '', + revision: 1, + policy_id: '', + output_id: '', + }, + ]; + + const permissions = await storedPackagePoliciesToAgentPermissions(soClient, packagePolicies); + expect(permissions).toMatchObject({ + 'test-policy': { + indices: [ + { + names: ['logs-compiled-test'], + privileges: ['auto_configure', 'create_doc'], + }, + ], + }, + }); + }); +}); + +describe('getDataStreamPermissions()', () => { + it('returns defaults for a datastream with no permissions', () => { + const dataStream = { type: 'logs', dataset: 'test' } as RegistryDataStream; + const permissions = getDataStreamPermissions(dataStream); + + expect(permissions).toMatchObject({ + names: ['logs-test-*'], + privileges: ['auto_configure', 'create_doc'], + }); + }); + + it('adds the namespace to the index name', () => { + const dataStream = { type: 'logs', dataset: 'test' } as RegistryDataStream; + const permissions = getDataStreamPermissions(dataStream, 'namespace'); + + expect(permissions).toMatchObject({ + names: ['logs-test-namespace'], + privileges: ['auto_configure', 'create_doc'], + }); + }); + + it('appends a wildcard if dataset is prefix', () => { + const dataStream = { + type: 'logs', + dataset: 'test', + dataset_is_prefix: true, + } as RegistryDataStream; + const permissions = getDataStreamPermissions(dataStream, 'namespace'); + + expect(permissions).toMatchObject({ + names: ['logs-test.*-namespace'], + privileges: ['auto_configure', 'create_doc'], + }); + }); + + it('prepends a dot if datastream is hidden', () => { + const dataStream = { + type: 'logs', + dataset: 'test', + hidden: true, + } as RegistryDataStream; + const permissions = getDataStreamPermissions(dataStream, 'namespace'); + + expect(permissions).toMatchObject({ + names: ['.logs-test-namespace'], + privileges: ['auto_configure', 'create_doc'], + }); + }); + + it('uses custom permissions if they are present in the datastream', () => { + const dataStream = { + type: 'logs', + dataset: 'test', + permissions: { indices: ['read', 'write'] }, + } as RegistryDataStream; + const permissions = getDataStreamPermissions(dataStream, 'namespace'); + + expect(permissions).toMatchObject({ + names: ['logs-test-namespace'], + privileges: ['read', 'write'], + }); + }); +}); diff --git a/x-pack/plugins/fleet/server/services/package_policies_to_agent_permissions.ts b/x-pack/plugins/fleet/server/services/package_policies_to_agent_permissions.ts new file mode 100644 index 0000000000000..bd73b88e7c893 --- /dev/null +++ b/x-pack/plugins/fleet/server/services/package_policies_to_agent_permissions.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 type { SavedObjectsClientContract } from 'kibana/server'; + +import type { FullAgentPolicyOutputPermissions, RegistryDataStreamPermissions } from '../../common'; +import { getPackageInfo } from '../../server/services/epm/packages'; + +import type { PackagePolicy } from '../types'; + +export const DEFAULT_PERMISSIONS = { + cluster: ['monitor'], + indices: [ + { + names: [ + 'logs-*', + 'metrics-*', + 'traces-*', + 'synthetics-*', + '.logs-endpoint.diagnostic.collection-*', + ], + privileges: ['auto_configure', 'create_doc'], + }, + ], +}; + +export async function storedPackagePoliciesToAgentPermissions( + soClient: SavedObjectsClientContract, + packagePolicies: string[] | PackagePolicy[] +): Promise { + if (packagePolicies.length === 0) { + return; + } + + // I'm not sure what permissions to return for this case, so let's return the defaults + if (typeof packagePolicies[0] === 'string') { + return { _fallback: DEFAULT_PERMISSIONS }; + } + + const permissionEntries = (packagePolicies as PackagePolicy[]).map>( + async (packagePolicy) => { + if (!packagePolicy.package) { + return [packagePolicy.name, DEFAULT_PERMISSIONS]; + } + + const pkg = await getPackageInfo({ + savedObjectsClient: soClient, + pkgName: packagePolicy.package.name, + pkgVersion: packagePolicy.package.version, + }); + + if (!pkg.data_streams || pkg.data_streams.length === 0) { + return [packagePolicy.name, undefined]; + } + + let dataStreamsForPermissions: DataStreamMeta[]; + + switch (pkg.name) { + case 'endpoint': + // - Endpoint doesn't store the `data_stream` metadata in + // `packagePolicy.inputs`, so we will use _all_ data_streams from the + // package. + dataStreamsForPermissions = pkg.data_streams; + break; + + case 'apm': + // - APM doesn't store the `data_stream` metadata in + // `packagePolicy.inputs`, so we will use _all_ data_streams from + // the package. + dataStreamsForPermissions = pkg.data_streams; + break; + + default: + // - Normal packages store some of the `data_stream` metadata in + // `packagePolicy.inputs[].streams[].data_stream` + // - The rest of the metadata needs to be fetched from the + // `data_stream` object in the package. The link is + // `packagePolicy.inputs[].type == pkg.data_streams.streams[].input` + // - Some packages (custom logs) have a compiled dataset, stored in + // `input.streams.compiled_stream.data_stream.dataset` + dataStreamsForPermissions = packagePolicy.inputs + .filter((i) => i.enabled) + .flatMap((input) => { + if (!input.streams) { + return []; + } + + const dataStreams_: DataStreamMeta[] = []; + + input.streams + .filter((s) => s.enabled) + .forEach((stream) => { + if (!('data_stream' in stream)) { + return; + } + + const ds = { + type: stream.data_stream.type, + dataset: + stream.compiled_stream?.data_stream?.dataset ?? stream.data_stream.dataset, + }; + + dataStreams_.push(ds); + }); + + return dataStreams_; + }); + } + + return [ + packagePolicy.name, + { + indices: dataStreamsForPermissions.map((ds) => + getDataStreamPermissions(ds, packagePolicy.namespace) + ), + }, + ]; + } + ); + + return Object.fromEntries(await Promise.all(permissionEntries)); +} + +interface DataStreamMeta { + type: string; + dataset: string; + dataset_is_prefix?: boolean; + hidden?: boolean; + permissions?: RegistryDataStreamPermissions; +} + +export function getDataStreamPermissions(dataStream: DataStreamMeta, namespace: string = '*') { + let index = `${dataStream.type}-${dataStream.dataset}`; + + if (dataStream.dataset_is_prefix) { + index = `${index}.*`; + } + + if (dataStream.hidden) { + index = `.${index}`; + } + + index += `-${namespace}`; + + return { + names: [index], + privileges: dataStream.permissions?.indices || ['auto_configure', 'create_doc'], + }; +}