From 55d4331a2b46ed24d3fef494d02a9807b8a38ca2 Mon Sep 17 00:00:00 2001 From: Tiago Costa Date: Wed, 20 Jan 2021 13:27:37 +0000 Subject: [PATCH 1/7] skip flaky suite (#88796) --- .../apps/triggers_actions_ui/connectors.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/x-pack/test/functional_with_es_ssl/apps/triggers_actions_ui/connectors.ts b/x-pack/test/functional_with_es_ssl/apps/triggers_actions_ui/connectors.ts index 1eb920a14a5e2..ab2270b4ce70f 100644 --- a/x-pack/test/functional_with_es_ssl/apps/triggers_actions_ui/connectors.ts +++ b/x-pack/test/functional_with_es_ssl/apps/triggers_actions_ui/connectors.ts @@ -17,7 +17,8 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { const comboBox = getService('comboBox'); const supertest = getService('supertest'); - describe('Connectors', function () { + // FLAKY: https://github.com/elastic/kibana/issues/88796 + describe.skip('Connectors', function () { const objectRemover = new ObjectRemover(supertest); before(async () => { From 69182a8628ed832429c629bf57b257e3fe9f23eb Mon Sep 17 00:00:00 2001 From: Tiago Costa Date: Wed, 20 Jan 2021 13:47:08 +0000 Subject: [PATCH 2/7] chore(NA): create new x-pack cigroups and rebalancing them all (#88366) * chore(NA): create new x-pack cigroups and rebalancing them all * chore(NA): better cigroups balancing * chore(NA): push rollup tests back into ciGroup1 * chore(NA): move some functional ml tests from cigroup3 into cigroup13 * chore(NA): move some more tests into ciGroup13 * chore(NA): use a single top level describe at x-pack/test/functional/apps/ml * chore(NA): move settings into ciGroup13 * temporary test for es snapshots env * Revert "temporary test for es snapshots env" This reverts commit 789ebe7b9c1f87a05d1484e822a48420afd29e8f. * docs(NA): add missing documentation on the function tests describe split Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> --- .ci/es-snapshots/Jenkinsfile_verify_es | 2 + .ci/jobs.yml | 2 + test/functional/apps/visualize/index.ts | 2 +- test/scripts/jenkins_xpack_build_kibana.sh | 4 +- vars/kibanaCoverage.groovy | 2 + vars/tasks.groovy | 2 +- .../basic/tests/index.ts | 2 +- .../spaces_only/tests/index.ts | 2 +- .../test/api_integration_basic/apis/index.ts | 2 +- .../exception_operators_data_types/index.ts | 36 ++++-- .../security_and_spaces/tests/index.ts | 61 +++++----- .../tests/index.ts | 2 +- .../apps/api_keys/feature_controls/index.ts | 2 +- .../feature_controls/index.ts | 2 +- .../test/functional/apps/dev_tools/index.ts | 2 +- x-pack/test/functional/apps/graph/index.ts | 2 +- .../functional/apps/grok_debugger/index.js | 2 +- .../functional/apps/index_management/index.ts | 2 +- .../functional/apps/ingest_pipelines/index.ts | 2 +- x-pack/test/functional/apps/ml/index.ts | 107 ++++++++++++------ x-pack/test/functional_cors/tests/index.ts | 2 +- x-pack/test/licensing_plugin/public/index.ts | 2 +- x-pack/test/licensing_plugin/server/index.ts | 2 +- .../test_suites/event_log/index.ts | 2 +- .../licensed_feature_usage/index.ts | 2 +- .../test_suites/platform/index.ts | 2 +- .../test_suites/task_manager/index.ts | 2 +- .../test_suites/task_manager/index.ts | 2 +- .../test_suites/global_search/index.ts | 2 +- .../reporting_without_security/index.ts | 2 +- .../api_integration/tagging_api/apis/index.ts | 2 +- .../tests/login_selector/index.ts | 2 +- .../security_functional/tests/oidc/index.ts | 2 +- .../security_functional/tests/saml/index.ts | 2 +- 34 files changed, 166 insertions(+), 102 deletions(-) diff --git a/.ci/es-snapshots/Jenkinsfile_verify_es b/.ci/es-snapshots/Jenkinsfile_verify_es index 3c38d6279a038..11a39faa9aed0 100644 --- a/.ci/es-snapshots/Jenkinsfile_verify_es +++ b/.ci/es-snapshots/Jenkinsfile_verify_es @@ -56,6 +56,8 @@ kibanaPipeline(timeoutMinutes: 150) { 'xpack-ciGroup9': kibanaPipeline.xpackCiGroupProcess(9), 'xpack-ciGroup10': kibanaPipeline.xpackCiGroupProcess(10), 'xpack-ciGroup11': kibanaPipeline.xpackCiGroupProcess(11), + 'xpack-ciGroup12': kibanaPipeline.xpackCiGroupProcess(12), + 'xpack-ciGroup13': kibanaPipeline.xpackCiGroupProcess(13), ]), ]) } diff --git a/.ci/jobs.yml b/.ci/jobs.yml index f62ec9510d2d4..b05e834f5a459 100644 --- a/.ci/jobs.yml +++ b/.ci/jobs.yml @@ -32,6 +32,8 @@ JOB: - x-pack-ciGroup9 - x-pack-ciGroup10 - x-pack-ciGroup11 + - x-pack-ciGroup12 + - x-pack-ciGroup13 - x-pack-accessibility - x-pack-visualRegression diff --git a/test/functional/apps/visualize/index.ts b/test/functional/apps/visualize/index.ts index ff249d9972525..dddcd82f1d3f8 100644 --- a/test/functional/apps/visualize/index.ts +++ b/test/functional/apps/visualize/index.ts @@ -86,7 +86,7 @@ export default function ({ getService, loadTestFile }: FtrProviderContext) { }); describe('', function () { - this.tags('ciGroup11'); + this.tags('ciGroup4'); loadTestFile(require.resolve('./_line_chart_split_series')); loadTestFile(require.resolve('./_line_chart_split_chart')); diff --git a/test/scripts/jenkins_xpack_build_kibana.sh b/test/scripts/jenkins_xpack_build_kibana.sh index 8bb6effbec89c..a9e603f63bd42 100755 --- a/test/scripts/jenkins_xpack_build_kibana.sh +++ b/test/scripts/jenkins_xpack_build_kibana.sh @@ -23,7 +23,9 @@ node scripts/functional_tests --assert-none-excluded \ --include-tag ciGroup8 \ --include-tag ciGroup9 \ --include-tag ciGroup10 \ - --include-tag ciGroup11 + --include-tag ciGroup11 \ + --include-tag ciGroup12 \ + --include-tag ciGroup13 # Do not build kibana for code coverage run if [[ -z "$CODE_COVERAGE" ]] ; then diff --git a/vars/kibanaCoverage.groovy b/vars/kibanaCoverage.groovy index 019eb8088dbfc..609d8f78aeb96 100644 --- a/vars/kibanaCoverage.groovy +++ b/vars/kibanaCoverage.groovy @@ -247,6 +247,8 @@ def xpackProks() { 'xpack-ciGroup9' : kibanaPipeline.xpackCiGroupProcess(9), 'xpack-ciGroup10': kibanaPipeline.xpackCiGroupProcess(10), 'xpack-ciGroup11': kibanaPipeline.xpackCiGroupProcess(11), + 'xpack-ciGroup12': kibanaPipeline.xpackCiGroupProcess(12), + 'xpack-ciGroup13': kibanaPipeline.xpackCiGroupProcess(13), ] } diff --git a/vars/tasks.groovy b/vars/tasks.groovy index 68a6d4b32618c..3493a95f0bdce 100644 --- a/vars/tasks.groovy +++ b/vars/tasks.groovy @@ -94,7 +94,7 @@ def functionalXpack(Map params = [:]) { kibanaPipeline.buildXpack(10) if (config.ciGroups) { - def ciGroups = 1..11 + def ciGroups = 1..13 tasks(ciGroups.collect { kibanaPipeline.xpackCiGroupProcess(it) }) } diff --git a/x-pack/test/alerting_api_integration/basic/tests/index.ts b/x-pack/test/alerting_api_integration/basic/tests/index.ts index 80152cca07c60..5439379653327 100644 --- a/x-pack/test/alerting_api_integration/basic/tests/index.ts +++ b/x-pack/test/alerting_api_integration/basic/tests/index.ts @@ -12,7 +12,7 @@ export default function alertingApiIntegrationTests({ getService, }: FtrProviderContext) { describe('alerting api integration basic license', function () { - this.tags('ciGroup3'); + this.tags('ciGroup13'); loadTestFile(require.resolve('./actions')); loadTestFile(require.resolve('./alerts')); 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 49227c2d5cdf8..7d2108c5436a1 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 @@ -10,7 +10,7 @@ import { Spaces } from '../scenarios'; // eslint-disable-next-line import/no-default-export export default function alertingApiIntegrationTests({ loadTestFile }: FtrProviderContext) { describe('alerting api integration spaces only', function () { - this.tags('ciGroup9'); + this.tags('ciGroup12'); loadTestFile(require.resolve('./actions')); loadTestFile(require.resolve('./alerting')); diff --git a/x-pack/test/api_integration_basic/apis/index.ts b/x-pack/test/api_integration_basic/apis/index.ts index 66b3a45c12df3..4c797b21c6fe1 100644 --- a/x-pack/test/api_integration_basic/apis/index.ts +++ b/x-pack/test/api_integration_basic/apis/index.ts @@ -8,7 +8,7 @@ import { FtrProviderContext } from '../ftr_provider_context'; export default function ({ loadTestFile }: FtrProviderContext) { describe('apis', function () { - this.tags('ciGroup2'); + this.tags('ciGroup11'); loadTestFile(require.resolve('./ml')); loadTestFile(require.resolve('./transform')); diff --git a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/exception_operators_data_types/index.ts b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/exception_operators_data_types/index.ts index 6b32eb19c83d9..78450ccd70c27 100644 --- a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/exception_operators_data_types/index.ts +++ b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/exception_operators_data_types/index.ts @@ -9,18 +9,30 @@ import { FtrProviderContext } from '../../../common/ftr_provider_context'; // eslint-disable-next-line import/no-default-export export default ({ loadTestFile }: FtrProviderContext): void => { describe('Detection exceptions data types and operators', function () { - this.tags('ciGroup11'); + describe('', function () { + this.tags('ciGroup11'); - loadTestFile(require.resolve('./date')); - loadTestFile(require.resolve('./double')); - loadTestFile(require.resolve('./float')); - loadTestFile(require.resolve('./integer')); - loadTestFile(require.resolve('./ip')); - loadTestFile(require.resolve('./ip_array')); - loadTestFile(require.resolve('./keyword')); - loadTestFile(require.resolve('./keyword_array')); - loadTestFile(require.resolve('./long')); - loadTestFile(require.resolve('./text')); - loadTestFile(require.resolve('./text_array')); + loadTestFile(require.resolve('./date')); + loadTestFile(require.resolve('./double')); + loadTestFile(require.resolve('./float')); + loadTestFile(require.resolve('./integer')); + }); + + describe('', function () { + this.tags('ciGroup12'); + + loadTestFile(require.resolve('./ip')); + loadTestFile(require.resolve('./ip_array')); + loadTestFile(require.resolve('./keyword')); + loadTestFile(require.resolve('./keyword_array')); + loadTestFile(require.resolve('./long')); + }); + + describe('', function () { + this.tags('ciGroup13'); + + loadTestFile(require.resolve('./text')); + loadTestFile(require.resolve('./text_array')); + }); }); }; 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 6eb74af910605..44e033e96c89b 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 @@ -9,33 +9,40 @@ import { FtrProviderContext } from '../../common/ftr_provider_context'; // eslint-disable-next-line import/no-default-export export default ({ loadTestFile }: FtrProviderContext): void => { describe('detection engine api security and spaces enabled', function () { - this.tags('ciGroup11'); + describe('', function () { + this.tags('ciGroup11'); - loadTestFile(require.resolve('./add_actions')); - loadTestFile(require.resolve('./add_prepackaged_rules')); - loadTestFile(require.resolve('./create_rules')); - loadTestFile(require.resolve('./create_rules_bulk')); - loadTestFile(require.resolve('./create_threat_matching')); - loadTestFile(require.resolve('./create_exceptions')); - loadTestFile(require.resolve('./delete_rules')); - loadTestFile(require.resolve('./delete_rules_bulk')); - loadTestFile(require.resolve('./exception_operators_data_types/index')); - loadTestFile(require.resolve('./export_rules')); - loadTestFile(require.resolve('./find_rules')); - loadTestFile(require.resolve('./find_statuses')); - loadTestFile(require.resolve('./generating_signals')); - loadTestFile(require.resolve('./get_prepackaged_rules_status')); - loadTestFile(require.resolve('./import_rules')); - loadTestFile(require.resolve('./read_rules')); - loadTestFile(require.resolve('./update_rules')); - loadTestFile(require.resolve('./update_rules_bulk')); - loadTestFile(require.resolve('./patch_rules_bulk')); - loadTestFile(require.resolve('./patch_rules')); - loadTestFile(require.resolve('./query_signals')); - loadTestFile(require.resolve('./open_close_signals')); - loadTestFile(require.resolve('./get_signals_migration_status')); - loadTestFile(require.resolve('./create_signals_migrations')); - loadTestFile(require.resolve('./finalize_signals_migrations')); - loadTestFile(require.resolve('./delete_signals_migrations')); + loadTestFile(require.resolve('./add_actions')); + loadTestFile(require.resolve('./add_prepackaged_rules')); + loadTestFile(require.resolve('./create_rules')); + loadTestFile(require.resolve('./create_rules_bulk')); + loadTestFile(require.resolve('./create_threat_matching')); + loadTestFile(require.resolve('./create_exceptions')); + loadTestFile(require.resolve('./delete_rules')); + loadTestFile(require.resolve('./delete_rules_bulk')); + loadTestFile(require.resolve('./export_rules')); + loadTestFile(require.resolve('./find_rules')); + loadTestFile(require.resolve('./find_statuses')); + loadTestFile(require.resolve('./generating_signals')); + loadTestFile(require.resolve('./get_prepackaged_rules_status')); + loadTestFile(require.resolve('./import_rules')); + loadTestFile(require.resolve('./read_rules')); + loadTestFile(require.resolve('./update_rules')); + loadTestFile(require.resolve('./update_rules_bulk')); + loadTestFile(require.resolve('./patch_rules_bulk')); + loadTestFile(require.resolve('./patch_rules')); + loadTestFile(require.resolve('./query_signals')); + loadTestFile(require.resolve('./open_close_signals')); + loadTestFile(require.resolve('./get_signals_migration_status')); + loadTestFile(require.resolve('./create_signals_migrations')); + loadTestFile(require.resolve('./finalize_signals_migrations')); + loadTestFile(require.resolve('./delete_signals_migrations')); + }); + + // That split here enable us on using a different ciGroup to run the tests + // listed on ./exception_operators_data_types/index + describe('', function () { + loadTestFile(require.resolve('./exception_operators_data_types/index')); + }); }); }; diff --git a/x-pack/test/encrypted_saved_objects_api_integration/tests/index.ts b/x-pack/test/encrypted_saved_objects_api_integration/tests/index.ts index 4948bee7e6f5e..83c4e5a48b89e 100644 --- a/x-pack/test/encrypted_saved_objects_api_integration/tests/index.ts +++ b/x-pack/test/encrypted_saved_objects_api_integration/tests/index.ts @@ -8,7 +8,7 @@ import { FtrProviderContext } from '../ftr_provider_context'; export default function ({ loadTestFile }: FtrProviderContext) { describe('encryptedSavedObjects', function encryptedSavedObjectsSuite() { - this.tags('ciGroup2'); + this.tags('ciGroup13'); loadTestFile(require.resolve('./encrypted_saved_objects_api')); }); } diff --git a/x-pack/test/functional/apps/api_keys/feature_controls/index.ts b/x-pack/test/functional/apps/api_keys/feature_controls/index.ts index 169b5c7fb0a73..4cd95e5966bb5 100644 --- a/x-pack/test/functional/apps/api_keys/feature_controls/index.ts +++ b/x-pack/test/functional/apps/api_keys/feature_controls/index.ts @@ -8,7 +8,7 @@ import { FtrProviderContext } from '../../../ftr_provider_context'; export default function ({ loadTestFile }: FtrProviderContext) { describe('feature controls', function () { - this.tags(['ciGroup2']); + this.tags(['ciGroup8']); loadTestFile(require.resolve('./api_keys_security')); }); diff --git a/x-pack/test/functional/apps/cross_cluster_replication/feature_controls/index.ts b/x-pack/test/functional/apps/cross_cluster_replication/feature_controls/index.ts index e7be2cb48ce3e..89690829a0d35 100644 --- a/x-pack/test/functional/apps/cross_cluster_replication/feature_controls/index.ts +++ b/x-pack/test/functional/apps/cross_cluster_replication/feature_controls/index.ts @@ -8,7 +8,7 @@ import { FtrProviderContext } from '../../../ftr_provider_context'; export default function ({ loadTestFile }: FtrProviderContext) { describe('feature controls', function () { - this.tags(['ciGroup2']); + this.tags(['ciGroup8']); loadTestFile(require.resolve('./ccr_security')); }); diff --git a/x-pack/test/functional/apps/dev_tools/index.ts b/x-pack/test/functional/apps/dev_tools/index.ts index 767829d4494b7..121d9effc2b6f 100644 --- a/x-pack/test/functional/apps/dev_tools/index.ts +++ b/x-pack/test/functional/apps/dev_tools/index.ts @@ -7,7 +7,7 @@ import { FtrProviderContext } from '../../ftr_provider_context'; export default function ({ loadTestFile }: FtrProviderContext) { describe('console', function () { - this.tags('ciGroup10'); + this.tags('ciGroup13'); loadTestFile(require.resolve('./feature_controls')); loadTestFile(require.resolve('./searchprofiler_editor')); diff --git a/x-pack/test/functional/apps/graph/index.ts b/x-pack/test/functional/apps/graph/index.ts index 4eabb0701d933..00f2295c52728 100644 --- a/x-pack/test/functional/apps/graph/index.ts +++ b/x-pack/test/functional/apps/graph/index.ts @@ -8,7 +8,7 @@ import { FtrProviderContext } from '../../ftr_provider_context'; export default function ({ loadTestFile }: FtrProviderContext) { describe('graph app', function () { - this.tags('ciGroup1'); + this.tags('ciGroup12'); loadTestFile(require.resolve('./feature_controls')); loadTestFile(require.resolve('./graph')); diff --git a/x-pack/test/functional/apps/grok_debugger/index.js b/x-pack/test/functional/apps/grok_debugger/index.js index 75c05f35abd28..948509f650e97 100644 --- a/x-pack/test/functional/apps/grok_debugger/index.js +++ b/x-pack/test/functional/apps/grok_debugger/index.js @@ -6,7 +6,7 @@ export default function ({ loadTestFile }) { describe('logstash', function () { - this.tags('ciGroup2'); + this.tags('ciGroup13'); loadTestFile(require.resolve('./grok_debugger')); }); diff --git a/x-pack/test/functional/apps/index_management/index.ts b/x-pack/test/functional/apps/index_management/index.ts index 97b23cbf82c31..4b585b4d698dd 100644 --- a/x-pack/test/functional/apps/index_management/index.ts +++ b/x-pack/test/functional/apps/index_management/index.ts @@ -8,7 +8,7 @@ import { FtrProviderContext } from '../../ftr_provider_context'; export default ({ loadTestFile }: FtrProviderContext) => { describe('Index Management app', function () { - this.tags('ciGroup3'); + this.tags('ciGroup13'); loadTestFile(require.resolve('./feature_controls')); loadTestFile(require.resolve('./home_page')); }); diff --git a/x-pack/test/functional/apps/ingest_pipelines/index.ts b/x-pack/test/functional/apps/ingest_pipelines/index.ts index 2a4781c5e216d..b02f23245d8ac 100644 --- a/x-pack/test/functional/apps/ingest_pipelines/index.ts +++ b/x-pack/test/functional/apps/ingest_pipelines/index.ts @@ -8,7 +8,7 @@ import { FtrProviderContext } from '../../ftr_provider_context'; export default ({ loadTestFile }: FtrProviderContext) => { describe('Ingest pipelines app', function () { - this.tags('ciGroup3'); + this.tags('ciGroup13'); loadTestFile(require.resolve('./feature_controls')); loadTestFile(require.resolve('./ingest_pipelines')); }); diff --git a/x-pack/test/functional/apps/ml/index.ts b/x-pack/test/functional/apps/ml/index.ts index 29e852f96eea0..7956965be78f6 100644 --- a/x-pack/test/functional/apps/ml/index.ts +++ b/x-pack/test/functional/apps/ml/index.ts @@ -10,44 +10,81 @@ export default function ({ getService, loadTestFile }: FtrProviderContext) { const ml = getService('ml'); describe('machine learning', function () { - this.tags('ciGroup3'); + describe('', function () { + this.tags('ciGroup3'); - before(async () => { - await ml.securityCommon.createMlRoles(); - await ml.securityCommon.createMlUsers(); - }); + before(async () => { + await ml.securityCommon.createMlRoles(); + await ml.securityCommon.createMlUsers(); + }); + + after(async () => { + await ml.securityCommon.cleanMlUsers(); + await ml.securityCommon.cleanMlRoles(); + await ml.testResources.deleteSavedSearches(); + await ml.testResources.deleteDashboards(); + await ml.testResources.deleteIndexPatternByTitle('ft_farequote'); + await ml.testResources.deleteIndexPatternByTitle('ft_ecommerce'); + await ml.testResources.deleteIndexPatternByTitle('ft_categorization'); + await ml.testResources.deleteIndexPatternByTitle('ft_event_rate_gen_trend_nanos'); + await ml.testResources.deleteIndexPatternByTitle('ft_bank_marketing'); + 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 ml.testResources.resetKibanaTimeZone(); + await ml.securityUI.logout(); + }); - after(async () => { - await ml.securityCommon.cleanMlUsers(); - await ml.securityCommon.cleanMlRoles(); - await ml.testResources.deleteSavedSearches(); - await ml.testResources.deleteDashboards(); - await ml.testResources.deleteIndexPatternByTitle('ft_farequote'); - await ml.testResources.deleteIndexPatternByTitle('ft_ecommerce'); - await ml.testResources.deleteIndexPatternByTitle('ft_categorization'); - await ml.testResources.deleteIndexPatternByTitle('ft_event_rate_gen_trend_nanos'); - await ml.testResources.deleteIndexPatternByTitle('ft_bank_marketing'); - 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 ml.testResources.resetKibanaTimeZone(); - await ml.securityUI.logout(); + loadTestFile(require.resolve('./permissions')); + loadTestFile(require.resolve('./pages')); + loadTestFile(require.resolve('./anomaly_detection')); + loadTestFile(require.resolve('./data_visualizer')); + loadTestFile(require.resolve('./data_frame_analytics')); }); - loadTestFile(require.resolve('./feature_controls')); - loadTestFile(require.resolve('./permissions')); - loadTestFile(require.resolve('./pages')); - loadTestFile(require.resolve('./anomaly_detection')); - loadTestFile(require.resolve('./data_visualizer')); - loadTestFile(require.resolve('./data_frame_analytics')); - loadTestFile(require.resolve('./settings')); + describe('', function () { + this.tags('ciGroup13'); + + before(async () => { + await ml.securityCommon.createMlRoles(); + await ml.securityCommon.createMlUsers(); + }); + + after(async () => { + await ml.securityCommon.cleanMlUsers(); + await ml.securityCommon.cleanMlRoles(); + await ml.testResources.deleteSavedSearches(); + await ml.testResources.deleteDashboards(); + await ml.testResources.deleteIndexPatternByTitle('ft_farequote'); + await ml.testResources.deleteIndexPatternByTitle('ft_ecommerce'); + await ml.testResources.deleteIndexPatternByTitle('ft_categorization'); + await ml.testResources.deleteIndexPatternByTitle('ft_event_rate_gen_trend_nanos'); + await ml.testResources.deleteIndexPatternByTitle('ft_bank_marketing'); + 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 ml.testResources.resetKibanaTimeZone(); + await ml.securityUI.logout(); + }); + + loadTestFile(require.resolve('./feature_controls')); + loadTestFile(require.resolve('./settings')); + }); }); } diff --git a/x-pack/test/functional_cors/tests/index.ts b/x-pack/test/functional_cors/tests/index.ts index 7e16e1339b1e7..673cb464c860d 100644 --- a/x-pack/test/functional_cors/tests/index.ts +++ b/x-pack/test/functional_cors/tests/index.ts @@ -8,7 +8,7 @@ import { FtrProviderContext } from '../ftr_provider_context'; export default function ({ loadTestFile }: FtrProviderContext) { describe('Kibana cors', function () { - this.tags('ciGroup2'); + this.tags('ciGroup12'); loadTestFile(require.resolve('./cors')); }); } diff --git a/x-pack/test/licensing_plugin/public/index.ts b/x-pack/test/licensing_plugin/public/index.ts index 268a74c56bd72..e771098ecd36a 100644 --- a/x-pack/test/licensing_plugin/public/index.ts +++ b/x-pack/test/licensing_plugin/public/index.ts @@ -9,7 +9,7 @@ import { FtrProviderContext } from '../services'; // eslint-disable-next-line import/no-default-export export default function ({ loadTestFile }: FtrProviderContext) { describe('Licensing plugin public client', function () { - this.tags('ciGroup2'); + this.tags('ciGroup5'); loadTestFile(require.resolve('./feature_usage')); // MUST BE LAST! CHANGES LICENSE TYPE! loadTestFile(require.resolve('./updates')); diff --git a/x-pack/test/licensing_plugin/server/index.ts b/x-pack/test/licensing_plugin/server/index.ts index dcea6e042443e..a9613e6569703 100644 --- a/x-pack/test/licensing_plugin/server/index.ts +++ b/x-pack/test/licensing_plugin/server/index.ts @@ -9,7 +9,7 @@ import { FtrProviderContext } from '../services'; // eslint-disable-next-line import/no-default-export export default function ({ loadTestFile }: FtrProviderContext) { describe('Licensing plugin server client', function () { - this.tags('ciGroup2'); + this.tags('ciGroup13'); loadTestFile(require.resolve('./info')); loadTestFile(require.resolve('./header')); diff --git a/x-pack/test/plugin_api_integration/test_suites/event_log/index.ts b/x-pack/test/plugin_api_integration/test_suites/event_log/index.ts index c738205361207..4965e1aa7d2dd 100644 --- a/x-pack/test/plugin_api_integration/test_suites/event_log/index.ts +++ b/x-pack/test/plugin_api_integration/test_suites/event_log/index.ts @@ -8,7 +8,7 @@ import { FtrProviderContext } from '../../ftr_provider_context'; export default function ({ loadTestFile }: FtrProviderContext) { describe('event_log', function taskManagerSuite() { - this.tags('ciGroup2'); + this.tags('ciGroup6'); loadTestFile(require.resolve('./public_api_integration')); loadTestFile(require.resolve('./service_api_integration')); }); diff --git a/x-pack/test/plugin_api_integration/test_suites/licensed_feature_usage/index.ts b/x-pack/test/plugin_api_integration/test_suites/licensed_feature_usage/index.ts index 2687c06351d69..23127f4db3d50 100644 --- a/x-pack/test/plugin_api_integration/test_suites/licensed_feature_usage/index.ts +++ b/x-pack/test/plugin_api_integration/test_suites/licensed_feature_usage/index.ts @@ -8,7 +8,7 @@ import { FtrProviderContext } from '../../ftr_provider_context'; export default function ({ loadTestFile }: FtrProviderContext) { describe('Licensed feature usage APIs', function () { - this.tags('ciGroup2'); + this.tags('ciGroup13'); loadTestFile(require.resolve('./feature_usage')); }); } diff --git a/x-pack/test/plugin_api_integration/test_suites/platform/index.ts b/x-pack/test/plugin_api_integration/test_suites/platform/index.ts index 3375e9ca839a5..82308b6168ac1 100644 --- a/x-pack/test/plugin_api_integration/test_suites/platform/index.ts +++ b/x-pack/test/plugin_api_integration/test_suites/platform/index.ts @@ -8,7 +8,7 @@ import { FtrProviderContext } from '../../ftr_provider_context'; export default function ({ loadTestFile }: FtrProviderContext) { describe('platform', function taskManagerSuite() { - this.tags('ciGroup2'); + this.tags('ciGroup13'); loadTestFile(require.resolve('./elasticsearch_client')); }); } diff --git a/x-pack/test/plugin_api_integration/test_suites/task_manager/index.ts b/x-pack/test/plugin_api_integration/test_suites/task_manager/index.ts index c1e7aad8ac36f..69fbb6be3ad59 100644 --- a/x-pack/test/plugin_api_integration/test_suites/task_manager/index.ts +++ b/x-pack/test/plugin_api_integration/test_suites/task_manager/index.ts @@ -8,7 +8,7 @@ import { FtrProviderContext } from '../../ftr_provider_context'; export default function ({ loadTestFile }: FtrProviderContext) { describe('task_manager', function taskManagerSuite() { - this.tags('ciGroup2'); + this.tags('ciGroup12'); loadTestFile(require.resolve('./health_route')); loadTestFile(require.resolve('./task_management')); loadTestFile(require.resolve('./task_management_removed_types')); diff --git a/x-pack/test/plugin_api_perf/test_suites/task_manager/index.ts b/x-pack/test/plugin_api_perf/test_suites/task_manager/index.ts index 648890a2b5431..302ddf071bc3d 100644 --- a/x-pack/test/plugin_api_perf/test_suites/task_manager/index.ts +++ b/x-pack/test/plugin_api_perf/test_suites/task_manager/index.ts @@ -14,7 +14,7 @@ export default function ({ loadTestFile }: { loadTestFile: (file: string) => voi * worth keeping around for future use, rather than being rewritten time and time again. */ describe.skip('task_manager_perf', function taskManagerSuite() { - this.tags('ciGroup2'); + this.tags('ciGroup12'); loadTestFile(require.resolve('./task_manager_perf_integration')); }); } diff --git a/x-pack/test/plugin_functional/test_suites/global_search/index.ts b/x-pack/test/plugin_functional/test_suites/global_search/index.ts index f3557ee8cc8db..f05aebd26cc86 100644 --- a/x-pack/test/plugin_functional/test_suites/global_search/index.ts +++ b/x-pack/test/plugin_functional/test_suites/global_search/index.ts @@ -8,7 +8,7 @@ import { FtrProviderContext } from '../../ftr_provider_context'; export default function ({ loadTestFile }: FtrProviderContext) { describe('GlobalSearch API', function () { - this.tags('ciGroup10'); + this.tags('ciGroup7'); loadTestFile(require.resolve('./global_search_providers')); loadTestFile(require.resolve('./global_search_bar')); }); diff --git a/x-pack/test/reporting_api_integration/reporting_without_security/index.ts b/x-pack/test/reporting_api_integration/reporting_without_security/index.ts index 12b32f0f6c4c6..423fed069ee04 100644 --- a/x-pack/test/reporting_api_integration/reporting_without_security/index.ts +++ b/x-pack/test/reporting_api_integration/reporting_without_security/index.ts @@ -9,7 +9,7 @@ import { FtrProviderContext } from '../ftr_provider_context'; // eslint-disable-next-line import/no-default-export export default function ({ loadTestFile }: FtrProviderContext) { describe('Reporting APIs', function () { - this.tags('ciGroup2'); + this.tags('ciGroup13'); loadTestFile(require.resolve('./job_apis')); loadTestFile(require.resolve('./management')); }); diff --git a/x-pack/test/saved_object_tagging/api_integration/tagging_api/apis/index.ts b/x-pack/test/saved_object_tagging/api_integration/tagging_api/apis/index.ts index fd9720cc453e5..51bfa8d976c92 100644 --- a/x-pack/test/saved_object_tagging/api_integration/tagging_api/apis/index.ts +++ b/x-pack/test/saved_object_tagging/api_integration/tagging_api/apis/index.ts @@ -9,7 +9,7 @@ import { FtrProviderContext } from '../services'; // eslint-disable-next-line import/no-default-export export default function ({ loadTestFile }: FtrProviderContext) { describe('saved objects tagging API', function () { - this.tags('ciGroup10'); + this.tags('ciGroup12'); loadTestFile(require.resolve('./delete')); loadTestFile(require.resolve('./create')); diff --git a/x-pack/test/security_functional/tests/login_selector/index.ts b/x-pack/test/security_functional/tests/login_selector/index.ts index ee25e365d495d..f07a380989e9f 100644 --- a/x-pack/test/security_functional/tests/login_selector/index.ts +++ b/x-pack/test/security_functional/tests/login_selector/index.ts @@ -8,7 +8,7 @@ import { FtrProviderContext } from '../../ftr_provider_context'; export default function ({ loadTestFile }: FtrProviderContext) { describe('security app - login selector', function () { - this.tags('ciGroup4'); + this.tags('ciGroup13'); loadTestFile(require.resolve('./basic_functionality')); loadTestFile(require.resolve('./auth_provider_hint')); diff --git a/x-pack/test/security_functional/tests/oidc/index.ts b/x-pack/test/security_functional/tests/oidc/index.ts index 2b6e433409fb4..9c19f25854afb 100644 --- a/x-pack/test/security_functional/tests/oidc/index.ts +++ b/x-pack/test/security_functional/tests/oidc/index.ts @@ -8,7 +8,7 @@ import { FtrProviderContext } from '../../ftr_provider_context'; export default function ({ loadTestFile }: FtrProviderContext) { describe('security app - OIDC interactions', function () { - this.tags('ciGroup4'); + this.tags('ciGroup13'); loadTestFile(require.resolve('./url_capture')); }); diff --git a/x-pack/test/security_functional/tests/saml/index.ts b/x-pack/test/security_functional/tests/saml/index.ts index 4b3d6a925bf76..cc8a6ce93956c 100644 --- a/x-pack/test/security_functional/tests/saml/index.ts +++ b/x-pack/test/security_functional/tests/saml/index.ts @@ -8,7 +8,7 @@ import { FtrProviderContext } from '../../ftr_provider_context'; export default function ({ loadTestFile }: FtrProviderContext) { describe('security app - SAML interactions', function () { - this.tags('ciGroup4'); + this.tags('ciGroup13'); loadTestFile(require.resolve('./url_capture')); }); From ad8589eb1911eb8918420194cefc85de8173b603 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Fern=C3=A1ndez=20Haro?= Date: Wed, 20 Jan 2021 13:56:40 +0000 Subject: [PATCH 3/7] [Telemetry] Handle Promise Rejection (#88815) --- src/plugins/telemetry/server/fetcher.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/plugins/telemetry/server/fetcher.ts b/src/plugins/telemetry/server/fetcher.ts index f99a769b58d32..9e1499bbb37c0 100644 --- a/src/plugins/telemetry/server/fetcher.ts +++ b/src/plugins/telemetry/server/fetcher.ts @@ -169,6 +169,9 @@ export class FetcherTask { updateTelemetrySavedObject(this.internalRepository!, { reportFailureCount: 0, lastReported: this.lastReported, + }).catch((err) => { + err.message = `Failed to update the telemetry saved object: ${err.message}`; + this.logger.debug(err); }); } @@ -176,6 +179,9 @@ export class FetcherTask { updateTelemetrySavedObject(this.internalRepository!, { reportFailureCount: failureCount + 1, reportFailureVersion: this.currentKibanaVersion, + }).catch((err) => { + err.message = `Failed to update the telemetry saved object: ${err.message}`; + this.logger.debug(err); }); } From ee5f560dd7ebc44b326f9798e24f3d05df8929c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Fern=C3=A1ndez=20Haro?= Date: Wed, 20 Jan 2021 15:30:35 +0000 Subject: [PATCH 4/7] [FTR] Use new ES client instead of legacyEs service (#88720) --- .../apis/home/{index.js => index.ts} | 4 +- .../home/{sample_data.js => sample_data.ts} | 11 ++--- .../apis/{index.js => index.ts} | 4 +- .../apis/kql_telemetry/{index.js => index.ts} | 4 +- .../{kql_telemetry.js => kql_telemetry.ts} | 9 ++-- .../{bulk_create.js => bulk_create.ts} | 13 +++--- .../{bulk_get.js => bulk_get.ts} | 10 ++--- .../{bulk_update.js => bulk_update.ts} | 10 ++--- .../saved_objects/{create.js => create.ts} | 12 +++--- .../saved_objects/{delete.js => delete.ts} | 10 ++--- .../apis/saved_objects/export.ts | 7 +--- .../apis/saved_objects/{find.js => find.ts} | 42 ++++++++++--------- .../apis/saved_objects/{get.js => get.ts} | 10 ++--- .../apis/saved_objects/{index.js => index.ts} | 4 +- ...ort_errors.js => resolve_import_errors.ts} | 3 +- .../saved_objects/{update.js => update.ts} | 10 ++--- .../apis/saved_objects_management/find.ts | 7 +--- .../apis/saved_objects_management/get.ts | 7 +--- .../{ui_counters.js => ui_counters.ts} | 0 ...{telemetry_local.js => telemetry_local.ts} | 25 +++++++---- .../telemetry/telemetry_optin_notice_seen.ts | 27 +++++------- .../apis/ui_counters/{index.js => index.ts} | 4 +- .../{ui_counters.js => ui_counters.ts} | 26 +++++++----- .../apis/ui_metric/{index.js => index.ts} | 4 +- .../ui_metric/{ui_metric.js => ui_metric.ts} | 33 +++++++++------ .../telemetry/telemetry_optin_notice_seen.ts | 27 +++++------- 26 files changed, 165 insertions(+), 158 deletions(-) rename test/api_integration/apis/home/{index.js => index.ts} (77%) rename test/api_integration/apis/home/{sample_data.js => sample_data.ts} (90%) rename test/api_integration/apis/{index.js => index.ts} (90%) rename test/api_integration/apis/kql_telemetry/{index.js => index.ts} (76%) rename test/api_integration/apis/kql_telemetry/{kql_telemetry.js => kql_telemetry.ts} (93%) rename test/api_integration/apis/saved_objects/{bulk_create.js => bulk_create.ts} (93%) rename test/api_integration/apis/saved_objects/{bulk_get.js => bulk_get.ts} (95%) rename test/api_integration/apis/saved_objects/{bulk_update.js => bulk_update.ts} (97%) rename test/api_integration/apis/saved_objects/{create.js => create.ts} (90%) rename test/api_integration/apis/saved_objects/{delete.js => delete.ts} (89%) rename test/api_integration/apis/saved_objects/{find.js => find.ts} (93%) rename test/api_integration/apis/saved_objects/{get.js => get.ts} (93%) rename test/api_integration/apis/saved_objects/{index.js => index.ts} (88%) rename test/api_integration/apis/saved_objects/{resolve_import_errors.js => resolve_import_errors.ts} (98%) rename test/api_integration/apis/saved_objects/{update.js => update.ts} (95%) rename test/api_integration/apis/telemetry/__fixtures__/{ui_counters.js => ui_counters.ts} (100%) rename test/api_integration/apis/telemetry/{telemetry_local.js => telemetry_local.ts} (92%) rename test/api_integration/apis/ui_counters/{index.js => index.ts} (77%) rename test/api_integration/apis/ui_counters/{ui_counters.js => ui_counters.ts} (71%) rename test/api_integration/apis/ui_metric/{index.js => index.ts} (76%) rename test/api_integration/apis/ui_metric/{ui_metric.js => ui_metric.ts} (74%) diff --git a/test/api_integration/apis/home/index.js b/test/api_integration/apis/home/index.ts similarity index 77% rename from test/api_integration/apis/home/index.js rename to test/api_integration/apis/home/index.ts index 51b599cdd0816..95ff370456866 100644 --- a/test/api_integration/apis/home/index.js +++ b/test/api_integration/apis/home/index.ts @@ -6,7 +6,9 @@ * Public License, v 1. */ -export default function ({ loadTestFile }) { +import { FtrProviderContext } from '../../ftr_provider_context'; + +export default function ({ loadTestFile }: FtrProviderContext) { describe('home apis', () => { loadTestFile(require.resolve('./sample_data')); }); diff --git a/test/api_integration/apis/home/sample_data.js b/test/api_integration/apis/home/sample_data.ts similarity index 90% rename from test/api_integration/apis/home/sample_data.js rename to test/api_integration/apis/home/sample_data.ts index bac1ef11f1070..042aff1375267 100644 --- a/test/api_integration/apis/home/sample_data.js +++ b/test/api_integration/apis/home/sample_data.ts @@ -7,10 +7,11 @@ */ import expect from '@kbn/expect'; +import { FtrProviderContext } from '../../ftr_provider_context'; -export default function ({ getService }) { +export default function ({ getService }: FtrProviderContext) { const supertest = getService('supertest'); - const es = getService('legacyEs'); + const es = getService('es'); const MILLISECOND_IN_WEEK = 1000 * 60 * 60 * 24 * 7; @@ -43,7 +44,7 @@ export default function ({ getService }) { }); it('should load elasticsearch index containing sample data with dates relative to current time', async () => { - const resp = await es.search({ + const { body: resp } = await es.search({ index: 'kibana_sample_data_flights', }); @@ -61,7 +62,7 @@ export default function ({ getService }) { .post(`/api/sample_data/flights?now=${nowString}`) .set('kbn-xsrf', 'kibana'); - const resp = await es.search({ + const { body: resp } = await es.search({ index: 'kibana_sample_data_flights', }); @@ -80,7 +81,7 @@ export default function ({ getService }) { }); it('should remove elasticsearch index containing sample data', async () => { - const resp = await es.indices.exists({ + const { body: resp } = await es.indices.exists({ index: 'kibana_sample_data_flights', }); expect(resp).to.be(false); diff --git a/test/api_integration/apis/index.js b/test/api_integration/apis/index.ts similarity index 90% rename from test/api_integration/apis/index.js rename to test/api_integration/apis/index.ts index 25f46feab693a..73629231b5951 100644 --- a/test/api_integration/apis/index.js +++ b/test/api_integration/apis/index.ts @@ -6,7 +6,9 @@ * Public License, v 1. */ -export default function ({ loadTestFile }) { +import { FtrProviderContext } from '../ftr_provider_context'; + +export default function ({ loadTestFile }: FtrProviderContext) { describe('apis', () => { loadTestFile(require.resolve('./core')); loadTestFile(require.resolve('./general')); diff --git a/test/api_integration/apis/kql_telemetry/index.js b/test/api_integration/apis/kql_telemetry/index.ts similarity index 76% rename from test/api_integration/apis/kql_telemetry/index.js rename to test/api_integration/apis/kql_telemetry/index.ts index 18e2fa680c432..afcb96ea8981c 100644 --- a/test/api_integration/apis/kql_telemetry/index.js +++ b/test/api_integration/apis/kql_telemetry/index.ts @@ -6,7 +6,9 @@ * Public License, v 1. */ -export default function ({ loadTestFile }) { +import { FtrProviderContext } from '../../ftr_provider_context'; + +export default function ({ loadTestFile }: FtrProviderContext) { describe('KQL', () => { loadTestFile(require.resolve('./kql_telemetry')); }); diff --git a/test/api_integration/apis/kql_telemetry/kql_telemetry.js b/test/api_integration/apis/kql_telemetry/kql_telemetry.ts similarity index 93% rename from test/api_integration/apis/kql_telemetry/kql_telemetry.js rename to test/api_integration/apis/kql_telemetry/kql_telemetry.ts index 1963b4edebb66..027206b971c45 100644 --- a/test/api_integration/apis/kql_telemetry/kql_telemetry.js +++ b/test/api_integration/apis/kql_telemetry/kql_telemetry.ts @@ -9,11 +9,12 @@ import expect from '@kbn/expect'; import Bluebird from 'bluebird'; import { get } from 'lodash'; +import { FtrProviderContext } from '../../ftr_provider_context'; -export default function ({ getService }) { +export default function ({ getService }: FtrProviderContext) { const supertest = getService('supertest'); const esArchiver = getService('esArchiver'); - const es = getService('legacyEs'); + const es = getService('es'); describe('telemetry API', () => { before(() => esArchiver.load('saved_objects/basic')); @@ -31,7 +32,7 @@ export default function ({ getService }) { index: '.kibana', q: 'type:kql-telemetry', }) - .then((response) => { + .then(({ body: response }) => { const kqlTelemetryDoc = get(response, 'hits.hits[0]._source.kql-telemetry'); expect(kqlTelemetryDoc.optInCount).to.be(1); }); @@ -49,7 +50,7 @@ export default function ({ getService }) { index: '.kibana', q: 'type:kql-telemetry', }) - .then((response) => { + .then(({ body: response }) => { const kqlTelemetryDoc = get(response, 'hits.hits[0]._source.kql-telemetry'); expect(kqlTelemetryDoc.optOutCount).to.be(1); }); diff --git a/test/api_integration/apis/saved_objects/bulk_create.js b/test/api_integration/apis/saved_objects/bulk_create.ts similarity index 93% rename from test/api_integration/apis/saved_objects/bulk_create.js rename to test/api_integration/apis/saved_objects/bulk_create.ts index 2c18df8bc3b19..903332a0a930f 100644 --- a/test/api_integration/apis/saved_objects/bulk_create.js +++ b/test/api_integration/apis/saved_objects/bulk_create.ts @@ -7,10 +7,11 @@ */ import expect from '@kbn/expect'; +import { FtrProviderContext } from '../../ftr_provider_context'; -export default function ({ getService }) { +export default function ({ getService }: FtrProviderContext) { const supertest = getService('supertest'); - const es = getService('legacyEs'); + const es = getService('es'); const esArchiver = getService('esArchiver'); const BULK_REQUESTS = [ @@ -74,11 +75,10 @@ export default function ({ getService }) { it('should not return raw id when object id is unspecified', async () => await supertest .post(`/api/saved_objects/_bulk_create`) - // eslint-disable-next-line no-unused-vars .send(BULK_REQUESTS.map(({ id, ...rest }) => rest)) .expect(200) .then((resp) => { - resp.body.saved_objects.map(({ id }) => + resp.body.saved_objects.map(({ id }: { id: string }) => expect(id).not.match(/visualization|dashboard/) ); })); @@ -88,10 +88,7 @@ export default function ({ getService }) { before( async () => // just in case the kibana server has recreated it - await es.indices.delete({ - index: '.kibana', - ignore: [404], - }) + await es.indices.delete({ index: '.kibana' }, { ignore: [404] }) ); it('should return 200 with individual responses', async () => diff --git a/test/api_integration/apis/saved_objects/bulk_get.js b/test/api_integration/apis/saved_objects/bulk_get.ts similarity index 95% rename from test/api_integration/apis/saved_objects/bulk_get.js rename to test/api_integration/apis/saved_objects/bulk_get.ts index 7870f880b5f74..e552c08a58cf0 100644 --- a/test/api_integration/apis/saved_objects/bulk_get.js +++ b/test/api_integration/apis/saved_objects/bulk_get.ts @@ -7,10 +7,11 @@ */ import expect from '@kbn/expect'; +import { FtrProviderContext } from '../../ftr_provider_context'; -export default function ({ getService }) { +export default function ({ getService }: FtrProviderContext) { const supertest = getService('supertest'); - const es = getService('legacyEs'); + const es = getService('es'); const esArchiver = getService('esArchiver'); const BULK_REQUESTS = [ @@ -98,10 +99,7 @@ export default function ({ getService }) { before( async () => // just in case the kibana server has recreated it - await es.indices.delete({ - index: '.kibana', - ignore: [404], - }) + await es.indices.delete({ index: '.kibana' }, { ignore: [404] }) ); it('should return 200 with individual responses', async () => diff --git a/test/api_integration/apis/saved_objects/bulk_update.js b/test/api_integration/apis/saved_objects/bulk_update.ts similarity index 97% rename from test/api_integration/apis/saved_objects/bulk_update.js rename to test/api_integration/apis/saved_objects/bulk_update.ts index b7e48a467c26a..5a2496b6dde81 100644 --- a/test/api_integration/apis/saved_objects/bulk_update.js +++ b/test/api_integration/apis/saved_objects/bulk_update.ts @@ -8,10 +8,11 @@ import expect from '@kbn/expect'; import _ from 'lodash'; +import { FtrProviderContext } from '../../ftr_provider_context'; -export default function ({ getService }) { +export default function ({ getService }: FtrProviderContext) { const supertest = getService('supertest'); - const es = getService('legacyEs'); + const es = getService('es'); const esArchiver = getService('esArchiver'); describe('bulkUpdate', () => { @@ -234,10 +235,7 @@ export default function ({ getService }) { before( async () => // just in case the kibana server has recreated it - await es.indices.delete({ - index: '.kibana', - ignore: [404], - }) + await es.indices.delete({ index: '.kibana' }, { ignore: [404] }) ); it('should return generic 404', async () => { diff --git a/test/api_integration/apis/saved_objects/create.js b/test/api_integration/apis/saved_objects/create.ts similarity index 90% rename from test/api_integration/apis/saved_objects/create.js rename to test/api_integration/apis/saved_objects/create.ts index 06e3b68121a26..b1cd5a8dfdae4 100644 --- a/test/api_integration/apis/saved_objects/create.js +++ b/test/api_integration/apis/saved_objects/create.ts @@ -7,10 +7,11 @@ */ import expect from '@kbn/expect'; +import { FtrProviderContext } from '../../ftr_provider_context'; -export default function ({ getService }) { +export default function ({ getService }: FtrProviderContext) { const supertest = getService('supertest'); - const es = getService('legacyEs'); + const es = getService('es'); const esArchiver = getService('esArchiver'); describe('create', () => { @@ -58,10 +59,7 @@ export default function ({ getService }) { before( async () => // just in case the kibana server has recreated it - await es.indices.delete({ - index: '.kibana', - ignore: [404], - }) + await es.indices.delete({ index: '.kibana' }, { ignore: [404] }) ); it('should return 200 and create kibana index', async () => { @@ -99,7 +97,7 @@ export default function ({ getService }) { expect(resp.body.migrationVersion).to.be.ok(); }); - expect(await es.indices.exists({ index: '.kibana' })).to.be(true); + expect((await es.indices.exists({ index: '.kibana' })).body).to.be(true); }); }); }); diff --git a/test/api_integration/apis/saved_objects/delete.js b/test/api_integration/apis/saved_objects/delete.ts similarity index 89% rename from test/api_integration/apis/saved_objects/delete.js rename to test/api_integration/apis/saved_objects/delete.ts index f78080dc62b30..9ba51b4b91468 100644 --- a/test/api_integration/apis/saved_objects/delete.js +++ b/test/api_integration/apis/saved_objects/delete.ts @@ -7,10 +7,11 @@ */ import expect from '@kbn/expect'; +import { FtrProviderContext } from '../../ftr_provider_context'; -export default function ({ getService }) { +export default function ({ getService }: FtrProviderContext) { const supertest = getService('supertest'); - const es = getService('legacyEs'); + const es = getService('es'); const esArchiver = getService('esArchiver'); describe('delete', () => { @@ -43,10 +44,7 @@ export default function ({ getService }) { before( async () => // just in case the kibana server has recreated it - await es.indices.delete({ - index: '.kibana', - ignore: [404], - }) + await es.indices.delete({ index: '.kibana' }, { ignore: [404] }) ); it('returns generic 404 when kibana index is missing', async () => diff --git a/test/api_integration/apis/saved_objects/export.ts b/test/api_integration/apis/saved_objects/export.ts index 59847906e6165..a84f3050fdd17 100644 --- a/test/api_integration/apis/saved_objects/export.ts +++ b/test/api_integration/apis/saved_objects/export.ts @@ -14,7 +14,7 @@ function ndjsonToObject(input: string) { } export default function ({ getService }: FtrProviderContext) { const supertest = getService('supertest'); - const es = getService('legacyEs'); + const es = getService('es'); const esArchiver = getService('esArchiver'); describe('export', () => { @@ -524,10 +524,7 @@ export default function ({ getService }: FtrProviderContext) { before( async () => // just in case the kibana server has recreated it - await es.indices.delete({ - index: '.kibana', - ignore: [404], - }) + await es.indices.delete({ index: '.kibana' }, { ignore: [404] }) ); it('should return empty response', async () => { diff --git a/test/api_integration/apis/saved_objects/find.js b/test/api_integration/apis/saved_objects/find.ts similarity index 93% rename from test/api_integration/apis/saved_objects/find.js rename to test/api_integration/apis/saved_objects/find.ts index a6dc1645dfbc9..a3ce70888049c 100644 --- a/test/api_integration/apis/saved_objects/find.js +++ b/test/api_integration/apis/saved_objects/find.ts @@ -7,10 +7,12 @@ */ import expect from '@kbn/expect'; +import { FtrProviderContext } from '../../ftr_provider_context'; +import { SavedObject } from '../../../../src/core/server'; -export default function ({ getService }) { +export default function ({ getService }: FtrProviderContext) { const supertest = getService('supertest'); - const es = getService('legacyEs'); + const es = getService('es'); const esArchiver = getService('esArchiver'); describe('find', () => { @@ -256,7 +258,6 @@ export default function ({ getService }) { ) .expect(400) .then((resp) => { - console.log('body', JSON.stringify(resp.body)); expect(resp.body).to.eql({ error: 'Bad Request', message: 'This type dashboard is not allowed: Bad Request', @@ -271,7 +272,6 @@ export default function ({ getService }) { ) .expect(400) .then((resp) => { - console.log('body', JSON.stringify(resp.body)); expect(resp.body).to.eql({ error: 'Bad Request', message: @@ -297,7 +297,10 @@ export default function ({ getService }) { .expect(200) .then((resp) => { const objects = resp.body.saved_objects; - expect(objects.map((obj) => obj.id)).to.eql(['only-ref-1', 'ref-1-and-ref-2']); + expect(objects.map((obj: SavedObject) => obj.id)).to.eql([ + 'only-ref-1', + 'ref-1-and-ref-2', + ]); }); }); @@ -315,7 +318,7 @@ export default function ({ getService }) { .expect(200) .then((resp) => { const objects = resp.body.saved_objects; - expect(objects.map((obj) => obj.id)).to.eql([ + expect(objects.map((obj: SavedObject) => obj.id)).to.eql([ 'only-ref-1', 'ref-1-and-ref-2', 'only-ref-2', @@ -337,7 +340,7 @@ export default function ({ getService }) { .expect(200) .then((resp) => { const objects = resp.body.saved_objects; - expect(objects.map((obj) => obj.id)).to.eql(['ref-1-and-ref-2']); + expect(objects.map((obj: SavedObject) => obj.id)).to.eql(['ref-1-and-ref-2']); }); }); }); @@ -358,7 +361,9 @@ export default function ({ getService }) { .expect(200) .then((resp) => { const savedObjects = resp.body.saved_objects; - expect(savedObjects.map((so) => so.attributes.title)).to.eql(['my-visualization']); + expect( + savedObjects.map((so: SavedObject<{ title: string }>) => so.attributes.title) + ).to.eql(['my-visualization']); })); it('can search with the prefix search character just after a special one', async () => @@ -372,7 +377,9 @@ export default function ({ getService }) { .expect(200) .then((resp) => { const savedObjects = resp.body.saved_objects; - expect(savedObjects.map((so) => so.attributes.title)).to.eql(['my-visualization']); + expect( + savedObjects.map((so: SavedObject<{ title: string }>) => so.attributes.title) + ).to.eql(['my-visualization']); })); it('can search for objects with asterisk', async () => @@ -386,7 +393,9 @@ export default function ({ getService }) { .expect(200) .then((resp) => { const savedObjects = resp.body.saved_objects; - expect(savedObjects.map((so) => so.attributes.title)).to.eql(['some*visualization']); + expect( + savedObjects.map((so: SavedObject<{ title: string }>) => so.attributes.title) + ).to.eql(['some*visualization']); })); it('can still search tokens by prefix', async () => @@ -400,10 +409,9 @@ export default function ({ getService }) { .expect(200) .then((resp) => { const savedObjects = resp.body.saved_objects; - expect(savedObjects.map((so) => so.attributes.title)).to.eql([ - 'my-visualization', - 'some*visualization', - ]); + expect( + savedObjects.map((so: SavedObject<{ title: string }>) => so.attributes.title) + ).to.eql(['my-visualization', 'some*visualization']); })); }); @@ -411,10 +419,7 @@ export default function ({ getService }) { before( async () => // just in case the kibana server has recreated it - await es.indices.delete({ - index: '.kibana', - ignore: [404], - }) + await es.indices.delete({ index: '.kibana' }, { ignore: [404] }) ); it('should return 200 with empty response', async () => @@ -513,7 +518,6 @@ export default function ({ getService }) { ) .expect(400) .then((resp) => { - console.log('body', JSON.stringify(resp.body)); expect(resp.body).to.eql({ error: 'Bad Request', message: 'This type dashboard is not allowed: Bad Request', diff --git a/test/api_integration/apis/saved_objects/get.js b/test/api_integration/apis/saved_objects/get.ts similarity index 93% rename from test/api_integration/apis/saved_objects/get.js rename to test/api_integration/apis/saved_objects/get.ts index f9c16c41c42f7..7134917122177 100644 --- a/test/api_integration/apis/saved_objects/get.js +++ b/test/api_integration/apis/saved_objects/get.ts @@ -7,10 +7,11 @@ */ import expect from '@kbn/expect'; +import { FtrProviderContext } from '../../ftr_provider_context'; -export default function ({ getService }) { +export default function ({ getService }: FtrProviderContext) { const supertest = getService('supertest'); - const es = getService('legacyEs'); + const es = getService('es'); const esArchiver = getService('esArchiver'); describe('get', () => { @@ -69,10 +70,7 @@ export default function ({ getService }) { before( async () => // just in case the kibana server has recreated it - await es.indices.delete({ - index: '.kibana', - ignore: [404], - }) + await es.indices.delete({ index: '.kibana' }, { ignore: [404] }) ); it('should return basic 404 without mentioning index', async () => diff --git a/test/api_integration/apis/saved_objects/index.js b/test/api_integration/apis/saved_objects/index.ts similarity index 88% rename from test/api_integration/apis/saved_objects/index.js rename to test/api_integration/apis/saved_objects/index.ts index 3feb8be0aa7f0..0e07b3c1ed060 100644 --- a/test/api_integration/apis/saved_objects/index.js +++ b/test/api_integration/apis/saved_objects/index.ts @@ -6,7 +6,9 @@ * Public License, v 1. */ -export default function ({ loadTestFile }) { +import { FtrProviderContext } from '../../ftr_provider_context'; + +export default function ({ loadTestFile }: FtrProviderContext) { describe('saved_objects', () => { loadTestFile(require.resolve('./bulk_create')); loadTestFile(require.resolve('./bulk_get')); diff --git a/test/api_integration/apis/saved_objects/resolve_import_errors.js b/test/api_integration/apis/saved_objects/resolve_import_errors.ts similarity index 98% rename from test/api_integration/apis/saved_objects/resolve_import_errors.js rename to test/api_integration/apis/saved_objects/resolve_import_errors.ts index eafe350e76ae4..5f3929f26aba6 100644 --- a/test/api_integration/apis/saved_objects/resolve_import_errors.js +++ b/test/api_integration/apis/saved_objects/resolve_import_errors.ts @@ -8,8 +8,9 @@ import expect from '@kbn/expect'; import { join } from 'path'; +import { FtrProviderContext } from '../../ftr_provider_context'; -export default function ({ getService }) { +export default function ({ getService }: FtrProviderContext) { const supertest = getService('supertest'); const esArchiver = getService('esArchiver'); diff --git a/test/api_integration/apis/saved_objects/update.js b/test/api_integration/apis/saved_objects/update.ts similarity index 95% rename from test/api_integration/apis/saved_objects/update.js rename to test/api_integration/apis/saved_objects/update.ts index d7c80431e9860..d5346e82ce98c 100644 --- a/test/api_integration/apis/saved_objects/update.js +++ b/test/api_integration/apis/saved_objects/update.ts @@ -7,10 +7,11 @@ */ import expect from '@kbn/expect'; +import { FtrProviderContext } from '../../ftr_provider_context'; -export default function ({ getService }) { +export default function ({ getService }: FtrProviderContext) { const supertest = getService('supertest'); - const es = getService('legacyEs'); + const es = getService('es'); const esArchiver = getService('esArchiver'); describe('update', () => { @@ -120,10 +121,7 @@ export default function ({ getService }) { before( async () => // just in case the kibana server has recreated it - await es.indices.delete({ - index: '.kibana', - ignore: [404], - }) + await es.indices.delete({ index: '.kibana' }, { ignore: [404] }) ); it('should return generic 404', async () => diff --git a/test/api_integration/apis/saved_objects_management/find.ts b/test/api_integration/apis/saved_objects_management/find.ts index 66761e62bda52..d7b486e8ab5cf 100644 --- a/test/api_integration/apis/saved_objects_management/find.ts +++ b/test/api_integration/apis/saved_objects_management/find.ts @@ -11,7 +11,7 @@ import { Response } from 'supertest'; import { FtrProviderContext } from '../../ftr_provider_context'; export default function ({ getService }: FtrProviderContext) { - const es = getService('legacyEs'); + const es = getService('es'); const supertest = getService('supertest'); const esArchiver = getService('esArchiver'); @@ -174,10 +174,7 @@ export default function ({ getService }: FtrProviderContext) { before( async () => // just in case the kibana server has recreated it - await es.indices.delete({ - index: '.kibana', - ignore: [404], - }) + await es.indices.delete({ index: '.kibana' }, { ignore: [404] }) ); it('should return 200 with empty response', async () => diff --git a/test/api_integration/apis/saved_objects_management/get.ts b/test/api_integration/apis/saved_objects_management/get.ts index 456711f06a1d7..bc05d7e392bb9 100644 --- a/test/api_integration/apis/saved_objects_management/get.ts +++ b/test/api_integration/apis/saved_objects_management/get.ts @@ -11,7 +11,7 @@ import { Response } from 'supertest'; import { FtrProviderContext } from '../../ftr_provider_context'; export default function ({ getService }: FtrProviderContext) { - const es = getService('legacyEs'); + const es = getService('es'); const supertest = getService('supertest'); const esArchiver = getService('esArchiver'); @@ -45,10 +45,7 @@ export default function ({ getService }: FtrProviderContext) { before( async () => // just in case the kibana server has recreated it - await es.indices.delete({ - index: '.kibana', - ignore: [404], - }) + await es.indices.delete({ index: '.kibana' }, { ignore: [404] }) ); it('should return 404 for object that no longer exists', async () => diff --git a/test/api_integration/apis/telemetry/__fixtures__/ui_counters.js b/test/api_integration/apis/telemetry/__fixtures__/ui_counters.ts similarity index 100% rename from test/api_integration/apis/telemetry/__fixtures__/ui_counters.js rename to test/api_integration/apis/telemetry/__fixtures__/ui_counters.ts diff --git a/test/api_integration/apis/telemetry/telemetry_local.js b/test/api_integration/apis/telemetry/telemetry_local.ts similarity index 92% rename from test/api_integration/apis/telemetry/telemetry_local.js rename to test/api_integration/apis/telemetry/telemetry_local.ts index beba2e211b04c..25d29a807bdad 100644 --- a/test/api_integration/apis/telemetry/telemetry_local.js +++ b/test/api_integration/apis/telemetry/telemetry_local.ts @@ -9,22 +9,27 @@ import expect from '@kbn/expect'; import _ from 'lodash'; import { basicUiCounters } from './__fixtures__/ui_counters'; +import { FtrProviderContext } from '../../ftr_provider_context'; +import { SavedObject } from '../../../../src/core/server'; /* * Create a single-level array with strings for all the paths to values in the * source object, up to 3 deep. Going deeper than 3 causes a bit too much churn * in the tests. */ -function flatKeys(source) { - const recursivelyFlatKeys = (obj, path = [], depth = 0) => { +function flatKeys(source: Record) { + const recursivelyFlatKeys = (obj: unknown, path: string[] = [], depth = 0): string[] => { return depth < 3 && _.isObject(obj) - ? _.map(obj, (v, k) => recursivelyFlatKeys(v, [...path, k], depth + 1)) - : path.join('.'); + ? Object.entries(obj).reduce( + (acc, [k, v]) => [...acc, ...recursivelyFlatKeys(v, [...path, k], depth + 1)], + [] as string[] + ) + : [path.join('.')]; }; return _.uniq(_.flattenDeep(recursivelyFlatKeys(source))).sort((a, b) => a.localeCompare(b)); } -export default function ({ getService }) { +export default function ({ getService }: FtrProviderContext) { const supertest = getService('supertest'); const es = getService('es'); const esArchiver = getService('esArchiver'); @@ -52,7 +57,7 @@ export default function ({ getService }) { const stats = body[0]; expect(stats.collection).to.be('local'); expect(stats.collectionSource).to.be('local'); - expect(stats.license).to.be.undefined; // OSS cannot get the license + expect(stats.license).to.be(undefined); // OSS cannot get the license expect(stats.stack_stats.kibana.count).to.be.a('number'); expect(stats.stack_stats.kibana.indices).to.be.a('number'); expect(stats.stack_stats.kibana.os.platforms[0].platform).to.be.a('string'); @@ -153,7 +158,7 @@ export default function ({ getService }) { }); describe('application usage limits', () => { - function createSavedObject(viewId) { + function createSavedObject(viewId?: string) { return supertest .post('/api/saved_objects/application_usage_transactional') .send({ @@ -170,7 +175,7 @@ export default function ({ getService }) { } describe('basic behaviour', () => { - let savedObjectIds = []; + let savedObjectIds: string[] = []; before('create application usage entries', async () => { savedObjectIds = await Promise.all([ createSavedObject(), @@ -245,7 +250,9 @@ export default function ({ getService }) { })) ) .expect(200) - .then((resp) => resp.body.saved_objects.forEach(({ id }) => savedObjectIds.push(id))); + .then((resp) => + resp.body.saved_objects.forEach(({ id }: SavedObject) => savedObjectIds.push(id)) + ); }); after('clean them all', async () => { // The SavedObjects API does not allow bulk deleting, and deleting one by one takes ages and the tests timeout diff --git a/test/api_integration/apis/telemetry/telemetry_optin_notice_seen.ts b/test/api_integration/apis/telemetry/telemetry_optin_notice_seen.ts index a3f24ab80389c..dd1aee560af86 100644 --- a/test/api_integration/apis/telemetry/telemetry_optin_notice_seen.ts +++ b/test/api_integration/apis/telemetry/telemetry_optin_notice_seen.ts @@ -7,37 +7,32 @@ */ import expect from '@kbn/expect'; -import { Client, DeleteDocumentParams, GetParams, GetResponse } from 'elasticsearch'; -import { TelemetrySavedObjectAttributes } from 'src/plugins/telemetry/server/telemetry_repository'; import { FtrProviderContext } from '../../ftr_provider_context'; export default function optInTest({ getService }: FtrProviderContext) { - const client: Client = getService('legacyEs'); + const client = getService('es'); const supertest = getService('supertest'); describe('/api/telemetry/v2/userHasSeenNotice API Telemetry User has seen OptIn Notice', () => { it('should update telemetry setting field via PUT', async () => { - try { - await client.delete({ + await client.delete( + { index: '.kibana', id: 'telemetry:telemetry', - } as DeleteDocumentParams); - } catch (err) { - if (err.statusCode !== 404) { - throw err; - } - } + }, + { ignore: [404] } + ); await supertest.put('/api/telemetry/v2/userHasSeenNotice').set('kbn-xsrf', 'xxx').expect(200); const { - _source: { telemetry }, - }: GetResponse<{ - telemetry: TelemetrySavedObjectAttributes; - }> = await client.get({ + body: { + _source: { telemetry }, + }, + } = await client.get({ index: '.kibana', id: 'telemetry:telemetry', - } as GetParams); + }); expect(telemetry.userHasSeenNotice).to.be(true); }); diff --git a/test/api_integration/apis/ui_counters/index.js b/test/api_integration/apis/ui_counters/index.ts similarity index 77% rename from test/api_integration/apis/ui_counters/index.js rename to test/api_integration/apis/ui_counters/index.ts index f01855223264d..7944b38802d93 100644 --- a/test/api_integration/apis/ui_counters/index.js +++ b/test/api_integration/apis/ui_counters/index.ts @@ -6,7 +6,9 @@ * Public License, v 1. */ -export default function ({ loadTestFile }) { +import { FtrProviderContext } from '../../ftr_provider_context'; + +export default function ({ loadTestFile }: FtrProviderContext) { describe('UI Counters', () => { loadTestFile(require.resolve('./ui_counters')); }); diff --git a/test/api_integration/apis/ui_counters/ui_counters.js b/test/api_integration/apis/ui_counters/ui_counters.ts similarity index 71% rename from test/api_integration/apis/ui_counters/ui_counters.js rename to test/api_integration/apis/ui_counters/ui_counters.ts index d84db0275349a..1cf16fe433bf9 100644 --- a/test/api_integration/apis/ui_counters/ui_counters.js +++ b/test/api_integration/apis/ui_counters/ui_counters.ts @@ -7,14 +7,15 @@ */ import expect from '@kbn/expect'; -import { ReportManager, METRIC_TYPE } from '@kbn/analytics'; +import { ReportManager, METRIC_TYPE, UiCounterMetricType } from '@kbn/analytics'; import moment from 'moment'; +import { FtrProviderContext } from '../../ftr_provider_context'; -export default function ({ getService }) { +export default function ({ getService }: FtrProviderContext) { const supertest = getService('supertest'); - const es = getService('legacyEs'); + const es = getService('es'); - const createUiCounterEvent = (eventName, type, count = 1) => ({ + const createUiCounterEvent = (eventName: string, type: UiCounterMetricType, count = 1) => ({ eventName, appName: 'myApp', type, @@ -38,9 +39,9 @@ export default function ({ getService }) { .send({ report }) .expect(200); - const response = await es.search({ index: '.kibana', q: 'type:ui-counter' }); + const { body: response } = await es.search({ index: '.kibana', q: 'type:ui-counter' }); - const ids = response.hits.hits.map(({ _id }) => _id); + const ids = response.hits.hits.map(({ _id }: { _id: string }) => _id); expect(ids.includes(`ui-counter:myApp:${dayDate}:${METRIC_TYPE.COUNT}:my_event`)).to.eql( true ); @@ -64,21 +65,26 @@ export default function ({ getService }) { .expect(200); const { - hits: { hits }, + body: { + hits: { hits }, + }, } = await es.search({ index: '.kibana', q: 'type:ui-counter' }); const countTypeEvent = hits.find( - (hit) => hit._id === `ui-counter:myApp:${dayDate}:${METRIC_TYPE.COUNT}:${uniqueEventName}` + (hit: { _id: string }) => + hit._id === `ui-counter:myApp:${dayDate}:${METRIC_TYPE.COUNT}:${uniqueEventName}` ); expect(countTypeEvent._source['ui-counter'].count).to.eql(1); const clickTypeEvent = hits.find( - (hit) => hit._id === `ui-counter:myApp:${dayDate}:${METRIC_TYPE.CLICK}:${uniqueEventName}` + (hit: { _id: string }) => + hit._id === `ui-counter:myApp:${dayDate}:${METRIC_TYPE.CLICK}:${uniqueEventName}` ); expect(clickTypeEvent._source['ui-counter'].count).to.eql(2); const secondEvent = hits.find( - (hit) => hit._id === `ui-counter:myApp:${dayDate}:${METRIC_TYPE.COUNT}:${uniqueEventName}_2` + (hit: { _id: string }) => + hit._id === `ui-counter:myApp:${dayDate}:${METRIC_TYPE.COUNT}:${uniqueEventName}_2` ); expect(secondEvent._source['ui-counter'].count).to.eql(1); }); diff --git a/test/api_integration/apis/ui_metric/index.js b/test/api_integration/apis/ui_metric/index.ts similarity index 76% rename from test/api_integration/apis/ui_metric/index.js rename to test/api_integration/apis/ui_metric/index.ts index 1cee9c395eb91..2b749f8a01196 100644 --- a/test/api_integration/apis/ui_metric/index.js +++ b/test/api_integration/apis/ui_metric/index.ts @@ -6,7 +6,9 @@ * Public License, v 1. */ -export default function ({ loadTestFile }) { +import { FtrProviderContext } from '../../ftr_provider_context'; + +export default function ({ loadTestFile }: FtrProviderContext) { describe('UI Metric', () => { loadTestFile(require.resolve('./ui_metric')); }); diff --git a/test/api_integration/apis/ui_metric/ui_metric.js b/test/api_integration/apis/ui_metric/ui_metric.ts similarity index 74% rename from test/api_integration/apis/ui_metric/ui_metric.js rename to test/api_integration/apis/ui_metric/ui_metric.ts index 0539bb25b1fd9..d330cb037d1a1 100644 --- a/test/api_integration/apis/ui_metric/ui_metric.js +++ b/test/api_integration/apis/ui_metric/ui_metric.ts @@ -7,20 +7,26 @@ */ import expect from '@kbn/expect'; -import { ReportManager, METRIC_TYPE } from '@kbn/analytics'; +import { ReportManager, METRIC_TYPE, UiCounterMetricType } from '@kbn/analytics'; +import { UserAgentMetric } from '@kbn/analytics/target/types/metrics/user_agent'; +import { FtrProviderContext } from '../../ftr_provider_context'; -export default function ({ getService }) { +export default function ({ getService }: FtrProviderContext) { const supertest = getService('supertest'); - const es = getService('legacyEs'); + const es = getService('es'); - const createStatsMetric = (eventName, type = METRIC_TYPE.CLICK, count = 1) => ({ + const createStatsMetric = ( + eventName: string, + type: UiCounterMetricType = METRIC_TYPE.CLICK, + count = 1 + ) => ({ eventName, appName: 'myApp', type, count, }); - const createUserAgentMetric = (appName) => ({ + const createUserAgentMetric = (appName: string): UserAgentMetric => ({ appName, type: METRIC_TYPE.USER_AGENT, userAgent: @@ -39,8 +45,8 @@ export default function ({ getService }) { .send({ report }) .expect(200); - const response = await es.search({ index: '.kibana', q: 'type:ui-metric' }); - const ids = response.hits.hits.map(({ _id }) => _id); + const { body: response } = await es.search({ index: '.kibana', q: 'type:ui-metric' }); + const ids = response.hits.hits.map(({ _id }: { _id: string }) => _id); expect(ids.includes('ui-metric:myApp:myEvent')).to.eql(true); }); @@ -64,8 +70,8 @@ export default function ({ getService }) { .send({ report }) .expect(200); - const response = await es.search({ index: '.kibana', q: 'type:ui-metric' }); - const ids = response.hits.hits.map(({ _id }) => _id); + const { body: response } = await es.search({ index: '.kibana', q: 'type:ui-metric' }); + const ids = response.hits.hits.map(({ _id }: { _id: string }) => _id); expect(ids.includes('ui-metric:myApp:myEvent')).to.eql(true); expect(ids.includes(`ui-metric:myApp:${uniqueEventName}`)).to.eql(true); expect(ids.includes(`ui-metric:kibana-user_agent:${userAgentMetric.userAgent}`)).to.eql(true); @@ -77,7 +83,6 @@ export default function ({ getService }) { const nano = hrTime[0] * 1000000000 + hrTime[1]; const uniqueEventName = `my_event_${nano}`; const { report } = reportManager.assignReports([ - , createStatsMetric(uniqueEventName, METRIC_TYPE.CLICK, 2), createStatsMetric(uniqueEventName, METRIC_TYPE.LOADED), ]); @@ -89,10 +94,14 @@ export default function ({ getService }) { .expect(200); const { - hits: { hits }, + body: { + hits: { hits }, + }, } = await es.search({ index: '.kibana', q: 'type:ui-metric' }); - const countTypeEvent = hits.find((hit) => hit._id === `ui-metric:myApp:${uniqueEventName}`); + const countTypeEvent = hits.find( + (hit: { _id: string }) => hit._id === `ui-metric:myApp:${uniqueEventName}` + ); expect(countTypeEvent._source['ui-metric'].count).to.eql(3); }); }); diff --git a/x-pack/test/api_integration/apis/telemetry/telemetry_optin_notice_seen.ts b/x-pack/test/api_integration/apis/telemetry/telemetry_optin_notice_seen.ts index 4821eea095d88..6c1a9f0be2461 100644 --- a/x-pack/test/api_integration/apis/telemetry/telemetry_optin_notice_seen.ts +++ b/x-pack/test/api_integration/apis/telemetry/telemetry_optin_notice_seen.ts @@ -5,37 +5,32 @@ */ import expect from '@kbn/expect'; -import { Client, DeleteDocumentParams, GetParams, GetResponse } from 'elasticsearch'; -import { TelemetrySavedObjectAttributes } from '../../../../../src/plugins/telemetry/server/telemetry_repository'; import { FtrProviderContext } from '../../ftr_provider_context'; export default function optInTest({ getService }: FtrProviderContext) { - const client: Client = getService('legacyEs'); + const client = getService('es'); const supertest = getService('supertest'); describe('/api/telemetry/v2/userHasSeenNotice API Telemetry User has seen OptIn Notice', () => { it('should update telemetry setting field via PUT', async () => { - try { - await client.delete({ + await client.delete( + { index: '.kibana', id: 'telemetry:telemetry', - } as DeleteDocumentParams); - } catch (err) { - if (err.statusCode !== 404) { - throw err; - } - } + }, + { ignore: [404] } + ); await supertest.put('/api/telemetry/v2/userHasSeenNotice').set('kbn-xsrf', 'xxx').expect(200); const { - _source: { telemetry }, - }: GetResponse<{ - telemetry: TelemetrySavedObjectAttributes; - }> = await client.get({ + body: { + _source: { telemetry }, + }, + } = await client.get({ index: '.kibana', id: 'telemetry:telemetry', - } as GetParams); + }); expect(telemetry.userHasSeenNotice).to.be(true); }); From c0438ad25ca4f30455a7174eee6ca3201d219adc Mon Sep 17 00:00:00 2001 From: Pierre Gayvallet Date: Wed, 20 Jan 2021 16:40:13 +0100 Subject: [PATCH 5/7] [DX] migrate core xpack plugins to tsproject ref (#88676) * migrate cloud, beatsManagement and savedObjectTagging to TS project ref * migrates globalSearchBar * fix beatsManagement config * fix beatsManagement ts * fix beatsManagement config again * indent. --- .../components/navigation/child_routes.tsx | 2 +- .../beats_management/public/pages/index.ts | 3 +- x-pack/plugins/beats_management/tsconfig.json | 26 ++ x-pack/plugins/cloud/tsconfig.json | 21 ++ .../plugins/global_search_bar/tsconfig.json | 18 ++ .../saved_objects_tagging/tsconfig.json | 25 ++ x-pack/test/tsconfig.json | 8 +- x-pack/tsconfig.json | 225 +++++------------- x-pack/tsconfig.refs.json | 6 +- 9 files changed, 166 insertions(+), 168 deletions(-) create mode 100644 x-pack/plugins/beats_management/tsconfig.json create mode 100644 x-pack/plugins/cloud/tsconfig.json create mode 100644 x-pack/plugins/global_search_bar/tsconfig.json create mode 100644 x-pack/plugins/saved_objects_tagging/tsconfig.json diff --git a/x-pack/plugins/beats_management/public/components/navigation/child_routes.tsx b/x-pack/plugins/beats_management/public/components/navigation/child_routes.tsx index a7e705b00ee84..dd8388f7b7791 100644 --- a/x-pack/plugins/beats_management/public/components/navigation/child_routes.tsx +++ b/x-pack/plugins/beats_management/public/components/navigation/child_routes.tsx @@ -6,7 +6,7 @@ import React, { FC } from 'react'; import { Route, Switch } from 'react-router-dom'; -interface RouteConfig { +export interface RouteConfig { path: string; component: React.ComponentType; routes?: RouteConfig[]; diff --git a/x-pack/plugins/beats_management/public/pages/index.ts b/x-pack/plugins/beats_management/public/pages/index.ts index 418bc4d0ce147..e4b2788cf96e7 100644 --- a/x-pack/plugins/beats_management/public/pages/index.ts +++ b/x-pack/plugins/beats_management/public/pages/index.ts @@ -19,8 +19,9 @@ import { BeatsInitialEnrollmentPage } from './walkthrough/initial/beat'; import { FinishWalkthroughPage } from './walkthrough/initial/finish'; import { InitialWalkthroughPage } from './walkthrough/initial/index'; import { InitialTagPage } from './walkthrough/initial/tag'; +import type { RouteConfig } from '../components/navigation/child_routes'; -export const routeMap = [ +export const routeMap: RouteConfig[] = [ { path: '/tag/create/:tagid?', component: TagCreatePage }, { path: '/tag/edit/:tagid?', component: TagEditPage }, { diff --git a/x-pack/plugins/beats_management/tsconfig.json b/x-pack/plugins/beats_management/tsconfig.json new file mode 100644 index 0000000000000..ad68cc900e638 --- /dev/null +++ b/x-pack/plugins/beats_management/tsconfig.json @@ -0,0 +1,26 @@ +{ + "extends": "../../../tsconfig.base.json", + "compilerOptions": { + "composite": true, + "outDir": "./target/types", + "emitDeclarationOnly": true, + "declaration": true, + "declarationMap": true + }, + "include": [ + "common/**/*", + "public/**/*", + "server/**/*", + "types/**/*", + "scripts/**/*", + "server/index_templates/*.json", + ], + "references": [ + { "path": "../../../src/core/tsconfig.json" }, + { "path": "../../../src/plugins/data/tsconfig.json" }, + { "path": "../../../src/plugins/management/tsconfig.json" }, + { "path": "../licensing/tsconfig.json" }, + { "path": "../features/tsconfig.json" }, + { "path": "../security/tsconfig.json" } + ] +} diff --git a/x-pack/plugins/cloud/tsconfig.json b/x-pack/plugins/cloud/tsconfig.json new file mode 100644 index 0000000000000..46e81aa7fa086 --- /dev/null +++ b/x-pack/plugins/cloud/tsconfig.json @@ -0,0 +1,21 @@ +{ + "extends": "../../../tsconfig.base.json", + "compilerOptions": { + "composite": true, + "outDir": "./target/types", + "emitDeclarationOnly": true, + "declaration": true, + "declarationMap": true, + }, + "include": [ + "common/**/*", + "public/**/*", + "server/**/*", + ], + "references": [ + { "path": "../../../src/core/tsconfig.json" }, + { "path": "../../../src/plugins/usage_collection/tsconfig.json" }, + { "path": "../../../src/plugins/home/tsconfig.json" }, + { "path": "../security/tsconfig.json" }, + ] +} diff --git a/x-pack/plugins/global_search_bar/tsconfig.json b/x-pack/plugins/global_search_bar/tsconfig.json new file mode 100644 index 0000000000000..266eecc35c84b --- /dev/null +++ b/x-pack/plugins/global_search_bar/tsconfig.json @@ -0,0 +1,18 @@ +{ + "extends": "../../../tsconfig.base.json", + "compilerOptions": { + "composite": true, + "outDir": "./target/types", + "emitDeclarationOnly": true, + "declaration": true, + "declarationMap": true + }, + "include": ["common/**/*", "public/**/*", "server/**/*"], + "references": [ + { "path": "../../../src/core/tsconfig.json" }, + { "path": "../../../src/plugins/usage_collection/tsconfig.json" }, + { "path": "../global_search/tsconfig.json" }, + { "path": "../saved_objects_tagging/tsconfig.json" }, + { "path": "../security/tsconfig.json" } + ] +} diff --git a/x-pack/plugins/saved_objects_tagging/tsconfig.json b/x-pack/plugins/saved_objects_tagging/tsconfig.json new file mode 100644 index 0000000000000..d00156ad1277c --- /dev/null +++ b/x-pack/plugins/saved_objects_tagging/tsconfig.json @@ -0,0 +1,25 @@ +{ + "extends": "../../../tsconfig.base.json", + "compilerOptions": { + "composite": true, + "outDir": "./target/types", + "emitDeclarationOnly": true, + "declaration": true, + "declarationMap": true, + }, + "include": [ + "common/**/*", + "public/**/*", + "server/**/*", + ], + "references": [ + { "path": "../../../src/core/tsconfig.json" }, + { "path": "../../../src/plugins/usage_collection/tsconfig.json" }, + { "path": "../../../src/plugins/management/tsconfig.json" }, + { "path": "../../../src/plugins/saved_objects_tagging_oss/tsconfig.json" }, + { "path": "../../../src/plugins/kibana_react/tsconfig.json" }, + { "path": "../../../src/plugins/usage_collection/tsconfig.json" }, + { "path": "../features/tsconfig.json" }, + { "path": "../security/tsconfig.json" }, + ] +} diff --git a/x-pack/test/tsconfig.json b/x-pack/test/tsconfig.json index d977730181e89..cfe328236cd36 100644 --- a/x-pack/test/tsconfig.json +++ b/x-pack/test/tsconfig.json @@ -42,13 +42,17 @@ { "path": "../plugins/global_search_providers/tsconfig.json" }, { "path": "../plugins/features/tsconfig.json" }, { "path": "../plugins/embeddable_enhanced/tsconfig.json" }, - { "path": "../plugins/event_log/tsconfig.json"}, + { "path": "../plugins/event_log/tsconfig.json" }, { "path": "../plugins/licensing/tsconfig.json" }, { "path": "../plugins/task_manager/tsconfig.json" }, { "path": "../plugins/telemetry_collection_xpack/tsconfig.json" }, { "path": "../plugins/ui_actions_enhanced/tsconfig.json" }, { "path": "../plugins/spaces/tsconfig.json" }, { "path": "../plugins/security/tsconfig.json" }, - { "path": "../plugins/encrypted_saved_objects/tsconfig.json" } + { "path": "../plugins/encrypted_saved_objects/tsconfig.json" }, + { "path": "../plugins/beats_management/tsconfig.json" }, + { "path": "../plugins/cloud/tsconfig.json" }, + { "path": "../plugins/saved_objects_tagging/tsconfig.json" }, + { "path": "../plugins/global_search_bar/tsconfig.json" } ] } diff --git a/x-pack/tsconfig.json b/x-pack/tsconfig.json index c68d93903e705..812ead39ba412 100644 --- a/x-pack/tsconfig.json +++ b/x-pack/tsconfig.json @@ -1,11 +1,6 @@ { "extends": "../tsconfig.base.json", - "include": [ - "mocks.ts", - "typings/**/*", - "plugins/**/*", - "tasks/**/*" - ], + "include": ["mocks.ts", "typings/**/*", "plugins/**/*", "tasks/**/*"], "exclude": [ "plugins/apm/e2e/cypress/**/*", "plugins/apm/ftr_e2e/**/*", @@ -31,6 +26,10 @@ "plugins/spaces/**/*", "plugins/security/**/*", "plugins/encrypted_saved_objects/**/*", + "plugins/beats_management/**/*", + "plugins/cloud/**/*", + "plugins/saved_objects_tagging/**/*", + "plugins/global_search_bar/**/*", "test/**/*" ], "compilerOptions": { @@ -38,161 +37,61 @@ "incremental": false }, "references": [ - { - "path": "../src/core/tsconfig.json" - }, - { - "path": "../src/plugins/telemetry_management_section/tsconfig.json" - }, - { - "path": "../src/plugins/management/tsconfig.json" - }, - { - "path": "../src/plugins/bfetch/tsconfig.json" - }, - { - "path": "../src/plugins/charts/tsconfig.json" - }, - { - "path": "../src/plugins/console/tsconfig.json" - }, - { - "path": "../src/plugins/dashboard/tsconfig.json" - }, - { - "path": "../src/plugins/discover/tsconfig.json" - }, - { - "path": "../src/plugins/data/tsconfig.json" - }, - { - "path": "../src/plugins/dev_tools/tsconfig.json" - }, - { - "path": "../src/plugins/embeddable/tsconfig.json" - }, - { - "path": "../src/plugins/es_ui_shared/tsconfig.json" - }, - { - "path": "../src/plugins/expressions/tsconfig.json" - }, - { - "path": "../src/plugins/home/tsconfig.json" - }, - { - "path": "../src/plugins/inspector/tsconfig.json" - }, - { - "path": "../src/plugins/kibana_legacy/tsconfig.json" - }, - { - "path": "../src/plugins/kibana_react/tsconfig.json" - }, - { - "path": "../src/plugins/kibana_usage_collection/tsconfig.json" - }, - { - "path": "../src/plugins/kibana_utils/tsconfig.json" - }, - { - "path": "../src/plugins/navigation/tsconfig.json" - }, - { - "path": "../src/plugins/newsfeed/tsconfig.json" - }, - { - "path": "../src/plugins/saved_objects/tsconfig.json" - }, - { - "path": "../src/plugins/saved_objects_management/tsconfig.json" - }, - { - "path": "../src/plugins/saved_objects_tagging_oss/tsconfig.json" - }, - { - "path": "../src/plugins/presentation_util/tsconfig.json" - }, - { - "path": "../src/plugins/security_oss/tsconfig.json" - }, - { - "path": "../src/plugins/share/tsconfig.json" - }, - { - "path": "../src/plugins/telemetry/tsconfig.json" - }, - { - "path": "../src/plugins/telemetry_collection_manager/tsconfig.json" - }, - { - "path": "../src/plugins/url_forwarding/tsconfig.json" - }, - { - "path": "../src/plugins/ui_actions/tsconfig.json" - }, - { - "path": "../src/plugins/url_forwarding/tsconfig.json" - }, - { - "path": "../src/plugins/usage_collection/tsconfig.json" - }, - { - "path": "./plugins/console_extensions/tsconfig.json" - }, - { - "path": "./plugins/data_enhanced/tsconfig.json" - }, - { - "path": "./plugins/discover_enhanced/tsconfig.json" - }, - { - "path": "./plugins/global_search/tsconfig.json" - }, - { - "path": "./plugins/global_search_providers/tsconfig.json" - }, - { - "path": "./plugins/features/tsconfig.json" - }, - { - "path": "./plugins/graph/tsconfig.json" - }, - { - "path": "./plugins/embeddable_enhanced/tsconfig.json" - }, - { - "path": "./plugins/event_log/tsconfig.json" - }, - { - "path": "./plugins/licensing/tsconfig.json" - }, - { - "path": "./plugins/searchprofiler/tsconfig.json" - }, - { - "path": "./plugins/task_manager/tsconfig.json" - }, - { - "path": "./plugins/telemetry_collection_xpack/tsconfig.json" - }, - { - "path": "./plugins/ui_actions_enhanced/tsconfig.json" - }, - { - "path": "./plugins/vis_type_timeseries_enhanced/tsconfig.json" - }, - { - "path": "./plugins/translations/tsconfig.json" - }, - { - "path": "./plugins/spaces/tsconfig.json" - }, - { - "path": "./plugins/security/tsconfig.json" - }, - { - "path": "./plugins/encrypted_saved_objects/tsconfig.json" - } + { "path": "../src/core/tsconfig.json" }, + { "path": "../src/plugins/telemetry_management_section/tsconfig.json" }, + { "path": "../src/plugins/management/tsconfig.json" }, + { "path": "../src/plugins/bfetch/tsconfig.json" }, + { "path": "../src/plugins/charts/tsconfig.json" }, + { "path": "../src/plugins/console/tsconfig.json" }, + { "path": "../src/plugins/dashboard/tsconfig.json" }, + { "path": "../src/plugins/discover/tsconfig.json" }, + { "path": "../src/plugins/data/tsconfig.json" }, + { "path": "../src/plugins/dev_tools/tsconfig.json" }, + { "path": "../src/plugins/embeddable/tsconfig.json" }, + { "path": "../src/plugins/es_ui_shared/tsconfig.json" }, + { "path": "../src/plugins/expressions/tsconfig.json" }, + { "path": "../src/plugins/home/tsconfig.json" }, + { "path": "../src/plugins/inspector/tsconfig.json" }, + { "path": "../src/plugins/kibana_legacy/tsconfig.json" }, + { "path": "../src/plugins/kibana_react/tsconfig.json" }, + { "path": "../src/plugins/kibana_usage_collection/tsconfig.json" }, + { "path": "../src/plugins/kibana_utils/tsconfig.json" }, + { "path": "../src/plugins/navigation/tsconfig.json" }, + { "path": "../src/plugins/newsfeed/tsconfig.json" }, + { "path": "../src/plugins/saved_objects/tsconfig.json" }, + { "path": "../src/plugins/saved_objects_management/tsconfig.json" }, + { "path": "../src/plugins/saved_objects_tagging_oss/tsconfig.json" }, + { "path": "../src/plugins/presentation_util/tsconfig.json" }, + { "path": "../src/plugins/security_oss/tsconfig.json" }, + { "path": "../src/plugins/share/tsconfig.json" }, + { "path": "../src/plugins/telemetry/tsconfig.json" }, + { "path": "../src/plugins/telemetry_collection_manager/tsconfig.json" }, + { "path": "../src/plugins/url_forwarding/tsconfig.json" }, + { "path": "../src/plugins/ui_actions/tsconfig.json" }, + { "path": "../src/plugins/url_forwarding/tsconfig.json" }, + { "path": "../src/plugins/usage_collection/tsconfig.json" }, + { "path": "./plugins/console_extensions/tsconfig.json" }, + { "path": "./plugins/data_enhanced/tsconfig.json" }, + { "path": "./plugins/discover_enhanced/tsconfig.json" }, + { "path": "./plugins/global_search/tsconfig.json" }, + { "path": "./plugins/global_search_providers/tsconfig.json" }, + { "path": "./plugins/features/tsconfig.json" }, + { "path": "./plugins/graph/tsconfig.json" }, + { "path": "./plugins/embeddable_enhanced/tsconfig.json" }, + { "path": "./plugins/event_log/tsconfig.json" }, + { "path": "./plugins/licensing/tsconfig.json" }, + { "path": "./plugins/searchprofiler/tsconfig.json" }, + { "path": "./plugins/task_manager/tsconfig.json" }, + { "path": "./plugins/telemetry_collection_xpack/tsconfig.json" }, + { "path": "./plugins/ui_actions_enhanced/tsconfig.json" }, + { "path": "./plugins/vis_type_timeseries_enhanced/tsconfig.json" }, + { "path": "./plugins/translations/tsconfig.json" }, + { "path": "./plugins/spaces/tsconfig.json" }, + { "path": "./plugins/security/tsconfig.json" }, + { "path": "./plugins/encrypted_saved_objects/tsconfig.json" }, + { "path": "./plugins/beats_management/tsconfig.json" }, + { "path": "./plugins/cloud/tsconfig.json" }, + { "path": "./plugins/saved_objects_tagging/tsconfig.json" }, + { "path": "./plugins/global_search_bar/tsconfig.json" } ] -} \ No newline at end of file +} diff --git a/x-pack/tsconfig.refs.json b/x-pack/tsconfig.refs.json index a0a9eda0aaf23..edee8e228f769 100644 --- a/x-pack/tsconfig.refs.json +++ b/x-pack/tsconfig.refs.json @@ -20,6 +20,10 @@ { "path": "./plugins/translations/tsconfig.json" }, { "path": "./plugins/spaces/tsconfig.json" }, { "path": "./plugins/security/tsconfig.json" }, - { "path": "./plugins/encrypted_saved_objects/tsconfig.json" } + { "path": "./plugins/encrypted_saved_objects/tsconfig.json" }, + { "path": "./plugins/beats_management/tsconfig.json" }, + { "path": "./plugins/cloud/tsconfig.json" }, + { "path": "./plugins/saved_objects_tagging/tsconfig.json" }, + { "path": "./plugins/global_search_bar/tsconfig.json" } ] } From 7297cc3b1d8f2ac47e3430c5983d696abde009f1 Mon Sep 17 00:00:00 2001 From: Marco Liberati Date: Wed, 20 Jan 2021 16:44:59 +0100 Subject: [PATCH 6/7] [Lens] Add a11y test suite (#88623) * :white_check_mark: Add a11y test suite for Lens + some fixes * :wrench: Removed unused ids * :bug: Fix component duplication via key prop * :white_mark_check: Add more a11y tests * :recycle: Restored back reorder id + fix multi layer duplicate ids * :bug: Fix #88806 Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> --- .../lens/public/drag_drop/providers.tsx | 2 +- .../editor_frame/config_panel/layer_panel.tsx | 9 +- .../public/editor_frame_service/service.tsx | 15 +- x-pack/test/accessibility/apps/lens.ts | 138 ++++++++++++++++++ x-pack/test/accessibility/config.ts | 1 + 5 files changed, 156 insertions(+), 9 deletions(-) create mode 100644 x-pack/test/accessibility/apps/lens.ts diff --git a/x-pack/plugins/lens/public/drag_drop/providers.tsx b/x-pack/plugins/lens/public/drag_drop/providers.tsx index 46247fd981134..5e0fc648454ad 100644 --- a/x-pack/plugins/lens/public/drag_drop/providers.tsx +++ b/x-pack/plugins/lens/public/drag_drop/providers.tsx @@ -171,7 +171,7 @@ export function ReorderProvider({
-

+

{state.keyboardReorderMessage}

diff --git a/x-pack/plugins/lens/public/editor_frame_service/editor_frame/config_panel/layer_panel.tsx b/x-pack/plugins/lens/public/editor_frame_service/editor_frame/config_panel/layer_panel.tsx index 831dfce2efadd..999f75686b1cb 100644 --- a/x-pack/plugins/lens/public/editor_frame_service/editor_frame/config_panel/layer_panel.tsx +++ b/x-pack/plugins/lens/public/editor_frame_service/editor_frame/config_panel/layer_panel.tsx @@ -193,7 +193,7 @@ export function LayerPanel( - {groups.map((group, groupIndex) => { + {groups.map((group) => { const newId = generateId(); const isMissing = !isEmptyLayer && group.required && group.accessors.length === 0; @@ -207,7 +207,7 @@ export function LayerPanel( fullWidth label={

{group.groupLabel}
} labelType="legend" - key={groupIndex} + key={group.groupId} isInvalid={isMissing} error={ isMissing ? ( @@ -222,7 +222,10 @@ export function LayerPanel( } > <> - + {group.accessors.map((accessorConfig) => { const accessor = accessorConfig.columnId; const { dragging } = dragDropContext; diff --git a/x-pack/plugins/lens/public/editor_frame_service/service.tsx b/x-pack/plugins/lens/public/editor_frame_service/service.tsx index d4e9522f3bed1..249d678f56af9 100644 --- a/x-pack/plugins/lens/public/editor_frame_service/service.tsx +++ b/x-pack/plugins/lens/public/editor_frame_service/service.tsx @@ -125,6 +125,12 @@ export class EditorFrameService { collectAsyncDefinitions(this.visualizations), ]); + const unmount = () => { + if (domElement) { + unmountComponentAtNode(domElement); + } + }; + return { mount: async ( element, @@ -141,6 +147,9 @@ export class EditorFrameService { searchSessionId, } ) => { + if (domElement !== element) { + unmount(); + } domElement = element; const firstDatasourceId = Object.keys(resolvedDatasources)[0]; const firstVisualizationId = Object.keys(resolvedVisualizations)[0]; @@ -179,11 +188,7 @@ export class EditorFrameService { domElement ); }, - unmount() { - if (domElement) { - unmountComponentAtNode(domElement); - } - }, + unmount, }; }; diff --git a/x-pack/test/accessibility/apps/lens.ts b/x-pack/test/accessibility/apps/lens.ts new file mode 100644 index 0000000000000..bfd79f070d284 --- /dev/null +++ b/x-pack/test/accessibility/apps/lens.ts @@ -0,0 +1,138 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { FtrProviderContext } from '../ftr_provider_context'; + +export default function ({ getService, getPageObjects }: FtrProviderContext) { + const PageObjects = getPageObjects(['common', 'visualize', 'header', 'home', 'settings', 'lens']); + const a11y = getService('a11y'); + const testSubjects = getService('testSubjects'); + const listingTable = getService('listingTable'); + + describe('Lens', () => { + const lensChartName = 'MyLensChart'; + before(async () => { + await PageObjects.common.navigateToUrl('home', '/tutorial_directory/sampleData', { + useActualUrl: true, + }); + await PageObjects.home.addSampleDataSet('flights'); + }); + + after(async () => { + await PageObjects.common.navigateToApp('visualize'); + await listingTable.searchForItemWithName(lensChartName); + await listingTable.checkListingSelectAllCheckbox(); + await listingTable.clickDeleteSelected(); + await PageObjects.common.clickConfirmOnModal(); + }); + + it('lens', async () => { + await PageObjects.visualize.navigateToNewVisualization(); + await PageObjects.visualize.clickVisType('lens'); + await a11y.testAppSnapshot(); + }); + + it('lens XY chart', async () => { + await PageObjects.visualize.navigateToNewVisualization(); + await PageObjects.visualize.clickVisType('lens'); + + await PageObjects.lens.configureDimension({ + dimension: 'lnsXY_xDimensionPanel > lns-empty-dimension', + operation: 'date_histogram', + field: 'timestamp', + }); + + await PageObjects.lens.configureDimension({ + dimension: 'lnsXY_yDimensionPanel > lns-empty-dimension', + operation: 'avg', + field: 'AvgTicketPrice', + }); + + await a11y.testAppSnapshot(); + }); + + it('lens pie chart', async () => { + await PageObjects.lens.switchToVisualization('pie'); + await a11y.testAppSnapshot(); + }); + + it('lens datatable', async () => { + await PageObjects.lens.switchToVisualization('lnsDatatable'); + await a11y.testAppSnapshot(); + }); + + it('lens metric chart', async () => { + await PageObjects.lens.switchToVisualization('lnsMetric'); + await a11y.testAppSnapshot(); + }); + + it('dimension configuration panel', async () => { + await PageObjects.visualize.navigateToNewVisualization(); + await PageObjects.visualize.clickVisType('lens'); + + await PageObjects.lens.openDimensionEditor('lnsXY_xDimensionPanel > lns-empty-dimension'); + await a11y.testAppSnapshot(); + + await PageObjects.lens.closeDimensionEditor(); + await PageObjects.lens.openDimensionEditor('lnsXY_yDimensionPanel > lns-empty-dimension'); + await a11y.testAppSnapshot(); + + await PageObjects.lens.closeDimensionEditor(); + }); + + it('change chart type', async () => { + await PageObjects.lens.switchToVisualization('line'); + await a11y.testAppSnapshot(); + }); + + it('change chart type via suggestions', async () => { + await PageObjects.lens.configureDimension({ + dimension: 'lnsXY_xDimensionPanel > lns-empty-dimension', + operation: 'date_histogram', + field: 'timestamp', + }); + + await PageObjects.lens.configureDimension({ + dimension: 'lnsXY_yDimensionPanel > lns-empty-dimension', + operation: 'avg', + field: 'AvgTicketPrice', + }); + + await testSubjects.click('lnsSuggestion-barChart > lnsSuggestion'); + await a11y.testAppSnapshot(); + }); + + // Skip until https://github.com/elastic/kibana/issues/88661 gets closed + it.skip('lens XY chart with multiple layers', async () => { + await PageObjects.lens.createLayer(); + + await PageObjects.lens.switchToVisualization('area'); + await PageObjects.lens.configureDimension( + { + dimension: 'lnsXY_xDimensionPanel > lns-empty-dimension', + operation: 'terms', + field: 'DestCityName', + }, + 1 + ); + + await PageObjects.lens.configureDimension( + { + dimension: 'lnsXY_yDimensionPanel > lns-empty-dimension', + operation: 'median', + field: 'FlightTimeMin', + }, + 1 + ); + await a11y.testAppSnapshot(); + }); + + it('saves lens chart', async () => { + await PageObjects.lens.save(lensChartName); + await a11y.testAppSnapshot(); + }); + }); +} diff --git a/x-pack/test/accessibility/config.ts b/x-pack/test/accessibility/config.ts index 070e2c3a61f2b..cf13a009c2821 100644 --- a/x-pack/test/accessibility/config.ts +++ b/x-pack/test/accessibility/config.ts @@ -28,6 +28,7 @@ export default async function ({ readConfigFile }: FtrConfigProviderContext) { require.resolve('./apps/kibana_overview'), require.resolve('./apps/ingest_node_pipelines'), require.resolve('./apps/ml'), + require.resolve('./apps/lens'), ], pageObjects, From 5b315858a3f1c07557c31c37e7f3f0f53e34f971 Mon Sep 17 00:00:00 2001 From: Nathan L Smith Date: Wed, 20 Jan 2021 10:07:13 -0600 Subject: [PATCH 7/7] Instances latency distribution chart (#88546) * Instances latency distribution chart Create an instances row component that does the data fetching for the instances table and the distribution chart. Use the same data for both the chart and the table. Tooltips and selection are disabled on the chart. * import fix * rename ServiceOverviewInstancesRow to ServiceOverviewInstancesChartAndTable * Updates based on feedback * remove stuff * hasdata --- .../components/app/service_overview/index.tsx | 15 ++- ...ice_overview_instances_chart_and_table.tsx | 75 +++++++++++++ .../index.tsx | 74 +++++-------- .../index.tsx | 101 ++++++++++++++++++ 4 files changed, 212 insertions(+), 53 deletions(-) create mode 100644 x-pack/plugins/apm/public/components/app/service_overview/service_overview_instances_chart_and_table.tsx create mode 100644 x-pack/plugins/apm/public/components/shared/charts/instances_latency_distribution_chart/index.tsx diff --git a/x-pack/plugins/apm/public/components/app/service_overview/index.tsx b/x-pack/plugins/apm/public/components/app/service_overview/index.tsx index f7720589359c8..c6cc59876fe35 100644 --- a/x-pack/plugins/apm/public/components/app/service_overview/index.tsx +++ b/x-pack/plugins/apm/public/components/app/service_overview/index.tsx @@ -19,7 +19,7 @@ import { SearchBar } from '../../shared/search_bar'; import { UserExperienceCallout } from '../transaction_overview/user_experience_callout'; import { ServiceOverviewDependenciesTable } from './service_overview_dependencies_table'; import { ServiceOverviewErrorsTable } from './service_overview_errors_table'; -import { ServiceOverviewInstancesTable } from './service_overview_instances_table'; +import { ServiceOverviewInstancesChartAndTable } from './service_overview_instances_chart_and_table'; import { ServiceOverviewThroughputChart } from './service_overview_throughput_chart'; import { ServiceOverviewTransactionsTable } from './service_overview_transactions_table'; import { useShouldUseMobileLayout } from './use_should_use_mobile_layout'; @@ -131,9 +131,16 @@ export function ServiceOverview({ {!isRumAgent && ( - - - + + + )} diff --git a/x-pack/plugins/apm/public/components/app/service_overview/service_overview_instances_chart_and_table.tsx b/x-pack/plugins/apm/public/components/app/service_overview/service_overview_instances_chart_and_table.tsx new file mode 100644 index 0000000000000..f7c2891bb3e65 --- /dev/null +++ b/x-pack/plugins/apm/public/components/app/service_overview/service_overview_instances_chart_and_table.tsx @@ -0,0 +1,75 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { EuiFlexItem, EuiPanel } from '@elastic/eui'; +import React from 'react'; +import { useApmServiceContext } from '../../../context/apm_service/use_apm_service_context'; +import { useUrlParams } from '../../../context/url_params_context/use_url_params'; +import { useFetcher } from '../../../hooks/use_fetcher'; +import { callApmApi } from '../../../services/rest/createCallApmApi'; +import { InstancesLatencyDistributionChart } from '../../shared/charts/instances_latency_distribution_chart'; +import { ServiceOverviewInstancesTable } from './service_overview_instances_table'; + +interface ServiceOverviewInstancesChartAndTableProps { + chartHeight: number; + serviceName: string; +} + +export function ServiceOverviewInstancesChartAndTable({ + chartHeight, + serviceName, +}: ServiceOverviewInstancesChartAndTableProps) { + const { transactionType } = useApmServiceContext(); + + const { + urlParams: { start, end }, + uiFilters, + } = useUrlParams(); + + const { data = [], status } = useFetcher(() => { + if (!start || !end || !transactionType) { + return; + } + + return callApmApi({ + endpoint: + 'GET /api/apm/services/{serviceName}/service_overview_instances', + params: { + path: { + serviceName, + }, + query: { + start, + end, + transactionType, + uiFilters: JSON.stringify(uiFilters), + numBuckets: 20, + }, + }, + }); + }, [start, end, serviceName, transactionType, uiFilters]); + + return ( + <> + + + + + + + + + + ); +} diff --git a/x-pack/plugins/apm/public/components/app/service_overview/service_overview_instances_table/index.tsx b/x-pack/plugins/apm/public/components/app/service_overview/service_overview_instances_table/index.tsx index 1d0e1e50c1489..8d84ad7878ec7 100644 --- a/x-pack/plugins/apm/public/components/app/service_overview/service_overview_instances_table/index.tsx +++ b/x-pack/plugins/apm/public/components/app/service_overview/service_overview_instances_table/index.tsx @@ -4,52 +4,51 @@ * you may not use this file except in compliance with the Elastic License. */ -import { EuiFlexItem } from '@elastic/eui'; -import { EuiInMemoryTable } from '@elastic/eui'; -import { EuiTitle } from '@elastic/eui'; -import { EuiBasicTableColumn } from '@elastic/eui'; -import { EuiFlexGroup } from '@elastic/eui'; +import { + EuiBasicTableColumn, + EuiFlexGroup, + EuiFlexItem, + EuiInMemoryTable, + EuiTitle, +} from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import React from 'react'; import { ValuesType } from 'utility-types'; import { isJavaAgentName } from '../../../../../common/agent_name'; import { UNIDENTIFIED_SERVICE_NODES_LABEL } from '../../../../../common/i18n'; import { SERVICE_NODE_NAME_MISSING } from '../../../../../common/service_nodes'; -import { useApmServiceContext } from '../../../../context/apm_service/use_apm_service_context'; import { asMillisecondDuration, asPercent, asTransactionRate, } from '../../../../../common/utils/formatters'; -import { FETCH_STATUS, useFetcher } from '../../../../hooks/use_fetcher'; -import { useUrlParams } from '../../../../context/url_params_context/use_url_params'; -import { - APIReturnType, - callApmApi, -} from '../../../../services/rest/createCallApmApi'; -import { TruncateWithTooltip } from '../../../shared/truncate_with_tooltip'; -import { TableFetchWrapper } from '../../../shared/table_fetch_wrapper'; -import { SparkPlot } from '../../../shared/charts/spark_plot'; +import { useApmServiceContext } from '../../../../context/apm_service/use_apm_service_context'; +import { FETCH_STATUS } from '../../../../hooks/use_fetcher'; +import { APIReturnType } from '../../../../services/rest/createCallApmApi'; import { px, unit } from '../../../../style/variables'; -import { ServiceOverviewTableContainer } from '../service_overview_table_container'; -import { ServiceNodeMetricOverviewLink } from '../../../shared/Links/apm/ServiceNodeMetricOverviewLink'; +import { SparkPlot } from '../../../shared/charts/spark_plot'; import { MetricOverviewLink } from '../../../shared/Links/apm/MetricOverviewLink'; +import { ServiceNodeMetricOverviewLink } from '../../../shared/Links/apm/ServiceNodeMetricOverviewLink'; +import { TableFetchWrapper } from '../../../shared/table_fetch_wrapper'; +import { TruncateWithTooltip } from '../../../shared/truncate_with_tooltip'; +import { ServiceOverviewTableContainer } from '../service_overview_table_container'; type ServiceInstanceItem = ValuesType< APIReturnType<'GET /api/apm/services/{serviceName}/service_overview_instances'> >; interface Props { + items?: ServiceInstanceItem[]; serviceName: string; + status: FETCH_STATUS; } -export function ServiceOverviewInstancesTable({ serviceName }: Props) { - const { agentName, transactionType } = useApmServiceContext(); - - const { - urlParams: { start, end }, - uiFilters, - } = useUrlParams(); +export function ServiceOverviewInstancesTable({ + items = [], + serviceName, + status, +}: Props) { + const { agentName } = useApmServiceContext(); const columns: Array> = [ { @@ -197,31 +196,8 @@ export function ServiceOverviewInstancesTable({ serviceName }: Props) { }, ]; - const { data = [], status } = useFetcher(() => { - if (!start || !end || !transactionType) { - return; - } - - return callApmApi({ - endpoint: - 'GET /api/apm/services/{serviceName}/service_overview_instances', - params: { - path: { - serviceName, - }, - query: { - start, - end, - transactionType, - uiFilters: JSON.stringify(uiFilters), - numBuckets: 20, - }, - }, - }); - }, [start, end, serviceName, transactionType, uiFilters]); - // need top-level sortable fields for the managed table - const items = data.map((item) => ({ + const tableItems = items.map((item) => ({ ...item, latencyValue: item.latency?.value ?? 0, throughputValue: item.throughput?.value ?? 0, @@ -250,7 +226,7 @@ export function ServiceOverviewInstancesTable({ serviceName }: Props) { > ; + status: FETCH_STATUS; +} + +export function InstancesLatencyDistributionChart({ + height, + items = [], + status, +}: InstancesLatencyDistributionChartProps) { + const hasData = items.length > 0; + + const theme = useTheme(); + const chartTheme = { + ...useChartTheme(), + bubbleSeriesStyle: { + point: { + strokeWidth: 0, + fill: theme.eui.euiColorVis1, + radius: 4, + }, + }, + }; + + const maxLatency = Math.max(...items.map((item) => item.latency?.value ?? 0)); + const latencyFormatter = getDurationFormatter(maxLatency); + + return ( + + +

+ {i18n.translate('xpack.apm.instancesLatencyDistributionChartTitle', { + defaultMessage: 'Instances latency distribution', + })} +

+
+ + + + item.throughput?.value} + xScaleType={ScaleType.Linear} + yAccessors={[(item) => item.latency?.value]} + yScaleType={ScaleType.Linear} + /> + + + + +
+ ); +}