From 336580800592d976aa179ba1e7b2b0e246a1a9cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Ferna=CC=81ndez=20Haro?= Date: Tue, 12 Jan 2021 20:20:14 +0100 Subject: [PATCH 1/7] [Application Usage] Functional test to validate the full list of appIds in the schema --- .../collectors/application_usage/schema.ts | 9 +- src/plugins/telemetry/schema/oss_plugins.json | 288 +++++++++++++++++- x-pack/test/usage_collection/config.ts | 44 +++ .../ftr_provider_context.d.ts | 11 + x-pack/test/usage_collection/page_objects.ts | 6 + .../application_usage_test/kibana.json | 11 + .../application_usage_test/public/index.ts | 11 + .../application_usage_test/public/plugin.ts | 33 ++ x-pack/test/usage_collection/services.ts | 7 + .../test_suites/application_usage/index.ts | 18 ++ 10 files changed, 433 insertions(+), 5 deletions(-) create mode 100644 x-pack/test/usage_collection/config.ts create mode 100644 x-pack/test/usage_collection/ftr_provider_context.d.ts create mode 100644 x-pack/test/usage_collection/page_objects.ts create mode 100644 x-pack/test/usage_collection/plugins/application_usage_test/kibana.json create mode 100644 x-pack/test/usage_collection/plugins/application_usage_test/public/index.ts create mode 100644 x-pack/test/usage_collection/plugins/application_usage_test/public/plugin.ts create mode 100644 x-pack/test/usage_collection/services.ts create mode 100644 x-pack/test/usage_collection/test_suites/application_usage/index.ts diff --git a/src/plugins/kibana_usage_collection/server/collectors/application_usage/schema.ts b/src/plugins/kibana_usage_collection/server/collectors/application_usage/schema.ts index c0e39c2a1d9b3..400e5c7f97969 100644 --- a/src/plugins/kibana_usage_collection/server/collectors/application_usage/schema.ts +++ b/src/plugins/kibana_usage_collection/server/collectors/application_usage/schema.ts @@ -48,8 +48,7 @@ const commonSchema: MakeSchemaFrom = { }, }; -// These keys obtained by searching for `/application\w*\.register\(/` and checking the value of the attr `id`. -// TODO: Find a way to update these keys automatically. +// There is a test in x-pack/test/usage_collection that validates that the keys in here match all the registered apps export const applicationUsageSchema = { // OSS dashboards: commonSchema, @@ -61,10 +60,12 @@ export const applicationUsageSchema = { short_url_redirect: commonSchema, // It's a forward app so we'll likely never report it timelion: commonSchema, visualize: commonSchema, + error: commonSchema, + status: commonSchema, + kibanaOverview: commonSchema, // X-Pack apm: commonSchema, - csm: commonSchema, canvas: commonSchema, dashboard_mode: commonSchema, // It's a forward app so we'll likely never report it enterpriseSearch: commonSchema, @@ -75,6 +76,7 @@ export const applicationUsageSchema = { metrics: commonSchema, infra: commonSchema, // It's a forward app so we'll likely never report it fleet: commonSchema, + ingestManager: commonSchema, lens: commonSchema, maps: commonSchema, ml: commonSchema, @@ -98,4 +100,5 @@ export const applicationUsageSchema = { siem: commonSchema, space_selector: commonSchema, uptime: commonSchema, + ux: commonSchema, }; diff --git a/src/plugins/telemetry/schema/oss_plugins.json b/src/plugins/telemetry/schema/oss_plugins.json index dd3c06a159b81..0403315186969 100644 --- a/src/plugins/telemetry/schema/oss_plugins.json +++ b/src/plugins/telemetry/schema/oss_plugins.json @@ -719,7 +719,7 @@ } } }, - "apm": { + "error": { "properties": { "appId": { "type": "keyword" @@ -790,7 +790,149 @@ } } }, - "csm": { + "status": { + "properties": { + "appId": { + "type": "keyword" + }, + "viewId": { + "type": "keyword" + }, + "clicks_total": { + "type": "long" + }, + "clicks_7_days": { + "type": "long" + }, + "clicks_30_days": { + "type": "long" + }, + "clicks_90_days": { + "type": "long" + }, + "minutes_on_screen_total": { + "type": "float" + }, + "minutes_on_screen_7_days": { + "type": "float" + }, + "minutes_on_screen_30_days": { + "type": "float" + }, + "minutes_on_screen_90_days": { + "type": "float" + }, + "views": { + "type": "array", + "items": { + "properties": { + "appId": { + "type": "keyword" + }, + "viewId": { + "type": "keyword" + }, + "clicks_total": { + "type": "long" + }, + "clicks_7_days": { + "type": "long" + }, + "clicks_30_days": { + "type": "long" + }, + "clicks_90_days": { + "type": "long" + }, + "minutes_on_screen_total": { + "type": "float" + }, + "minutes_on_screen_7_days": { + "type": "float" + }, + "minutes_on_screen_30_days": { + "type": "float" + }, + "minutes_on_screen_90_days": { + "type": "float" + } + } + } + } + } + }, + "kibanaOverview": { + "properties": { + "appId": { + "type": "keyword" + }, + "viewId": { + "type": "keyword" + }, + "clicks_total": { + "type": "long" + }, + "clicks_7_days": { + "type": "long" + }, + "clicks_30_days": { + "type": "long" + }, + "clicks_90_days": { + "type": "long" + }, + "minutes_on_screen_total": { + "type": "float" + }, + "minutes_on_screen_7_days": { + "type": "float" + }, + "minutes_on_screen_30_days": { + "type": "float" + }, + "minutes_on_screen_90_days": { + "type": "float" + }, + "views": { + "type": "array", + "items": { + "properties": { + "appId": { + "type": "keyword" + }, + "viewId": { + "type": "keyword" + }, + "clicks_total": { + "type": "long" + }, + "clicks_7_days": { + "type": "long" + }, + "clicks_30_days": { + "type": "long" + }, + "clicks_90_days": { + "type": "long" + }, + "minutes_on_screen_total": { + "type": "float" + }, + "minutes_on_screen_7_days": { + "type": "float" + }, + "minutes_on_screen_30_days": { + "type": "float" + }, + "minutes_on_screen_90_days": { + "type": "float" + } + } + } + } + } + }, + "apm": { "properties": { "appId": { "type": "keyword" @@ -1571,6 +1713,77 @@ } } }, + "ingestManager": { + "properties": { + "appId": { + "type": "keyword" + }, + "viewId": { + "type": "keyword" + }, + "clicks_total": { + "type": "long" + }, + "clicks_7_days": { + "type": "long" + }, + "clicks_30_days": { + "type": "long" + }, + "clicks_90_days": { + "type": "long" + }, + "minutes_on_screen_total": { + "type": "float" + }, + "minutes_on_screen_7_days": { + "type": "float" + }, + "minutes_on_screen_30_days": { + "type": "float" + }, + "minutes_on_screen_90_days": { + "type": "float" + }, + "views": { + "type": "array", + "items": { + "properties": { + "appId": { + "type": "keyword" + }, + "viewId": { + "type": "keyword" + }, + "clicks_total": { + "type": "long" + }, + "clicks_7_days": { + "type": "long" + }, + "clicks_30_days": { + "type": "long" + }, + "clicks_90_days": { + "type": "long" + }, + "minutes_on_screen_total": { + "type": "float" + }, + "minutes_on_screen_7_days": { + "type": "float" + }, + "minutes_on_screen_30_days": { + "type": "float" + }, + "minutes_on_screen_90_days": { + "type": "float" + } + } + } + } + } + }, "lens": { "properties": { "appId": { @@ -3203,6 +3416,77 @@ } } } + }, + "ux": { + "properties": { + "appId": { + "type": "keyword" + }, + "viewId": { + "type": "keyword" + }, + "clicks_total": { + "type": "long" + }, + "clicks_7_days": { + "type": "long" + }, + "clicks_30_days": { + "type": "long" + }, + "clicks_90_days": { + "type": "long" + }, + "minutes_on_screen_total": { + "type": "float" + }, + "minutes_on_screen_7_days": { + "type": "float" + }, + "minutes_on_screen_30_days": { + "type": "float" + }, + "minutes_on_screen_90_days": { + "type": "float" + }, + "views": { + "type": "array", + "items": { + "properties": { + "appId": { + "type": "keyword" + }, + "viewId": { + "type": "keyword" + }, + "clicks_total": { + "type": "long" + }, + "clicks_7_days": { + "type": "long" + }, + "clicks_30_days": { + "type": "long" + }, + "clicks_90_days": { + "type": "long" + }, + "minutes_on_screen_total": { + "type": "float" + }, + "minutes_on_screen_7_days": { + "type": "float" + }, + "minutes_on_screen_30_days": { + "type": "float" + }, + "minutes_on_screen_90_days": { + "type": "float" + } + } + } + } + } } } }, diff --git a/x-pack/test/usage_collection/config.ts b/x-pack/test/usage_collection/config.ts new file mode 100644 index 0000000000000..27b12a1ff298c --- /dev/null +++ b/x-pack/test/usage_collection/config.ts @@ -0,0 +1,44 @@ +/* + * 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 { resolve } from 'path'; +import fs from 'fs'; +import { FtrConfigProviderContext } from '@kbn/test/types/ftr'; +import { services } from './services'; +import { pageObjects } from './page_objects'; + +// the default export of config files must be a config provider +// that returns an object with the projects config values + +export default async function ({ readConfigFile }: FtrConfigProviderContext) { + const xpackFunctionalConfig = await readConfigFile(require.resolve('../functional/config.js')); + + // Find all folders in ./plugins since we treat all them as plugin folder + const allFiles = fs.readdirSync(resolve(__dirname, 'plugins')); + const plugins = allFiles.filter((file) => + fs.statSync(resolve(__dirname, 'plugins', file)).isDirectory() + ); + + return { + ...xpackFunctionalConfig.getAll(), + // list paths to the files that contain your plugins tests + testFiles: [resolve(__dirname, './test_suites/application_usage')], + + services, + pageObjects, + + kbnTestServer: { + ...xpackFunctionalConfig.get('kbnTestServer'), + serverArgs: [ + ...xpackFunctionalConfig.get('kbnTestServer.serverArgs'), + ...plugins.map((pluginDir) => `--plugin-path=${resolve(__dirname, 'plugins', pluginDir)}`), + ], + }, + + junit: { + reportName: 'X-Pack Usage Collection Functional Tests', + }, + }; +} diff --git a/x-pack/test/usage_collection/ftr_provider_context.d.ts b/x-pack/test/usage_collection/ftr_provider_context.d.ts new file mode 100644 index 0000000000000..271f313d4bda9 --- /dev/null +++ b/x-pack/test/usage_collection/ftr_provider_context.d.ts @@ -0,0 +1,11 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { GenericFtrProviderContext } from '@kbn/test/types/ftr'; +import { services } from './services'; +import { pageObjects } from './page_objects'; + +export type FtrProviderContext = GenericFtrProviderContext; diff --git a/x-pack/test/usage_collection/page_objects.ts b/x-pack/test/usage_collection/page_objects.ts new file mode 100644 index 0000000000000..a216b0f2cd47a --- /dev/null +++ b/x-pack/test/usage_collection/page_objects.ts @@ -0,0 +1,6 @@ +/* + * 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. + */ +export { pageObjects } from '../functional/page_objects'; diff --git a/x-pack/test/usage_collection/plugins/application_usage_test/kibana.json b/x-pack/test/usage_collection/plugins/application_usage_test/kibana.json new file mode 100644 index 0000000000000..7d7c92163437b --- /dev/null +++ b/x-pack/test/usage_collection/plugins/application_usage_test/kibana.json @@ -0,0 +1,11 @@ +{ + "id": "application_usage_test", + "version": "1.0.0", + "kibanaVersion": "kibana", + "configPath": ["xpack", "applicationUsageTest"], + "requiredPlugins": [ + "kibanaUsageCollection" + ], + "server": false, + "ui": true +} diff --git a/x-pack/test/usage_collection/plugins/application_usage_test/public/index.ts b/x-pack/test/usage_collection/plugins/application_usage_test/public/index.ts new file mode 100644 index 0000000000000..83e72770884b1 --- /dev/null +++ b/x-pack/test/usage_collection/plugins/application_usage_test/public/index.ts @@ -0,0 +1,11 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { ApplicationUsageTest } from './plugin'; + +export function plugin() { + return new ApplicationUsageTest(); +} diff --git a/x-pack/test/usage_collection/plugins/application_usage_test/public/plugin.ts b/x-pack/test/usage_collection/plugins/application_usage_test/public/plugin.ts new file mode 100644 index 0000000000000..25f1f976d0bf5 --- /dev/null +++ b/x-pack/test/usage_collection/plugins/application_usage_test/public/plugin.ts @@ -0,0 +1,33 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { Plugin, CoreSetup, CoreStart } from 'kibana/public'; +import { first } from 'rxjs/operators'; +import expect from '@kbn/expect'; +import { applicationUsageSchema } from '../../../../../../src/plugins/kibana_usage_collection/server/collectors/application_usage/schema'; + +export class ApplicationUsageTest implements Plugin { + public setup(core: CoreSetup) {} + + public async start(core: CoreStart) { + if (core.http.anonymousPaths.isAnonymous(window.location.pathname)) { + return; + } + const applications = await core.application.applications$.pipe(first()).toPromise(); + const appIds = [...applications.keys()] + .sort() + // Discard "test" plugins + .filter((appId) => !/test/i.test(appId)); + + try { + // When the lists don't match, the entire page load will fail. + expect(Object.keys(applicationUsageSchema).sort()).to.eql(appIds); + } catch (err) { + err.message = `Application Usage's schema is not up-to-date with the actual registered apps. Please update it at src/plugins/kibana_usage_collection/server/collectors/application_usage/schema.ts.\n${err.message}`; + throw err; + } + } +} diff --git a/x-pack/test/usage_collection/services.ts b/x-pack/test/usage_collection/services.ts new file mode 100644 index 0000000000000..5c807720b2867 --- /dev/null +++ b/x-pack/test/usage_collection/services.ts @@ -0,0 +1,7 @@ +/* + * 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. + */ + +export { services } from '../functional/services'; diff --git a/x-pack/test/usage_collection/test_suites/application_usage/index.ts b/x-pack/test/usage_collection/test_suites/application_usage/index.ts new file mode 100644 index 0000000000000..66a4b0bedbb62 --- /dev/null +++ b/x-pack/test/usage_collection/test_suites/application_usage/index.ts @@ -0,0 +1,18 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { FtrProviderContext } from '../../ftr_provider_context'; + +export default function ({ getPageObjects }: FtrProviderContext) { + describe('Application Usage', function () { + this.tags('ciGroup1'); + const { common } = getPageObjects(['common']); + + it('successfully loads home (the application_usage_test plugin does not fail)', async () => { + await common.navigateToApp('home'); + }); + }); +} From 5f41295befc790564de1acbfccdf2dca2b32b8c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Ferna=CC=81ndez=20Haro?= Date: Wed, 13 Jan 2021 10:32:13 +0100 Subject: [PATCH 2/7] Enable test in the CI --- test/scripts/jenkins_xpack_build_plugins.sh | 1 + x-pack/scripts/functional_tests.js | 1 + 2 files changed, 2 insertions(+) diff --git a/test/scripts/jenkins_xpack_build_plugins.sh b/test/scripts/jenkins_xpack_build_plugins.sh index 37b6398598788..06e8ce8b2fe59 100755 --- a/test/scripts/jenkins_xpack_build_plugins.sh +++ b/test/scripts/jenkins_xpack_build_plugins.sh @@ -12,5 +12,6 @@ node scripts/build_kibana_platform_plugins \ --scan-dir "$XPACK_DIR/test/plugin_api_integration/plugins" \ --scan-dir "$XPACK_DIR/test/plugin_api_perf/plugins" \ --scan-dir "$XPACK_DIR/test/licensing_plugin/plugins" \ + --scan-dir "$XPACK_DIR/test/usage_collection/plugins" \ --workers 12 \ --verbose diff --git a/x-pack/scripts/functional_tests.js b/x-pack/scripts/functional_tests.js index eff3a24a0ff3a..90c75cd62d6cc 100644 --- a/x-pack/scripts/functional_tests.js +++ b/x-pack/scripts/functional_tests.js @@ -73,6 +73,7 @@ const onlyNotInCoverageTests = [ require.resolve('../test/saved_object_tagging/functional/config.ts'), require.resolve('../test/saved_object_tagging/api_integration/security_and_spaces/config.ts'), require.resolve('../test/saved_object_tagging/api_integration/tagging_api/config.ts'), + require.resolve('../test/usage_collection/config.ts'), ]; require('../../src/setup_node_env'); From 28902a75d02f70ff574e71655ba4ebc6167b9003 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Ferna=CC=81ndez=20Haro?= Date: Wed, 13 Jan 2021 18:26:25 +0100 Subject: [PATCH 3/7] No need to filter out 'test' appIds --- .../plugins/application_usage_test/public/plugin.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/x-pack/test/usage_collection/plugins/application_usage_test/public/plugin.ts b/x-pack/test/usage_collection/plugins/application_usage_test/public/plugin.ts index 25f1f976d0bf5..7418904a54799 100644 --- a/x-pack/test/usage_collection/plugins/application_usage_test/public/plugin.ts +++ b/x-pack/test/usage_collection/plugins/application_usage_test/public/plugin.ts @@ -17,10 +17,7 @@ export class ApplicationUsageTest implements Plugin { return; } const applications = await core.application.applications$.pipe(first()).toPromise(); - const appIds = [...applications.keys()] - .sort() - // Discard "test" plugins - .filter((appId) => !/test/i.test(appId)); + const appIds = [...applications.keys()].sort(); try { // When the lists don't match, the entire page load will fail. From 7e0df18b98457cd90e855ed5b1e6bbe910e50f2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Ferna=CC=81ndez=20Haro?= Date: Fri, 15 Jan 2021 15:35:54 +0100 Subject: [PATCH 4/7] Test the apps in the test suite instead of the plugin --- .../plugins/application_usage_test/kibana.json | 6 ++---- .../application_usage_test/public/plugin.ts | 16 ++-------------- .../application_usage_test/public/types.ts | 13 +++++++++++++ .../plugins/application_usage_test/tsconfig.json | 12 ++++++++++++ .../test_suites/application_usage/index.ts | 11 ++++++++--- 5 files changed, 37 insertions(+), 21 deletions(-) create mode 100644 x-pack/test/usage_collection/plugins/application_usage_test/public/types.ts create mode 100644 x-pack/test/usage_collection/plugins/application_usage_test/tsconfig.json diff --git a/x-pack/test/usage_collection/plugins/application_usage_test/kibana.json b/x-pack/test/usage_collection/plugins/application_usage_test/kibana.json index 7d7c92163437b..1bff6cb64be1c 100644 --- a/x-pack/test/usage_collection/plugins/application_usage_test/kibana.json +++ b/x-pack/test/usage_collection/plugins/application_usage_test/kibana.json @@ -1,11 +1,9 @@ { - "id": "application_usage_test", + "id": "applicationUsageTest", "version": "1.0.0", "kibanaVersion": "kibana", "configPath": ["xpack", "applicationUsageTest"], - "requiredPlugins": [ - "kibanaUsageCollection" - ], + "requiredPlugins": [], "server": false, "ui": true } diff --git a/x-pack/test/usage_collection/plugins/application_usage_test/public/plugin.ts b/x-pack/test/usage_collection/plugins/application_usage_test/public/plugin.ts index 7418904a54799..5df673d94da19 100644 --- a/x-pack/test/usage_collection/plugins/application_usage_test/public/plugin.ts +++ b/x-pack/test/usage_collection/plugins/application_usage_test/public/plugin.ts @@ -6,25 +6,13 @@ import { Plugin, CoreSetup, CoreStart } from 'kibana/public'; import { first } from 'rxjs/operators'; -import expect from '@kbn/expect'; -import { applicationUsageSchema } from '../../../../../../src/plugins/kibana_usage_collection/server/collectors/application_usage/schema'; +import './types'; export class ApplicationUsageTest implements Plugin { public setup(core: CoreSetup) {} public async start(core: CoreStart) { - if (core.http.anonymousPaths.isAnonymous(window.location.pathname)) { - return; - } const applications = await core.application.applications$.pipe(first()).toPromise(); - const appIds = [...applications.keys()].sort(); - - try { - // When the lists don't match, the entire page load will fail. - expect(Object.keys(applicationUsageSchema).sort()).to.eql(appIds); - } catch (err) { - err.message = `Application Usage's schema is not up-to-date with the actual registered apps. Please update it at src/plugins/kibana_usage_collection/server/collectors/application_usage/schema.ts.\n${err.message}`; - throw err; - } + window.__applicationIds__ = [...applications.keys()]; } } diff --git a/x-pack/test/usage_collection/plugins/application_usage_test/public/types.ts b/x-pack/test/usage_collection/plugins/application_usage_test/public/types.ts new file mode 100644 index 0000000000000..5282b2fbdeb52 --- /dev/null +++ b/x-pack/test/usage_collection/plugins/application_usage_test/public/types.ts @@ -0,0 +1,13 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +export {}; // Hack to declare this file as a module so TS allows us to extend the Global Window interface + +declare global { + interface Window { + __applicationIds__: string[]; + } +} diff --git a/x-pack/test/usage_collection/plugins/application_usage_test/tsconfig.json b/x-pack/test/usage_collection/plugins/application_usage_test/tsconfig.json new file mode 100644 index 0000000000000..f1bf94a38de8f --- /dev/null +++ b/x-pack/test/usage_collection/plugins/application_usage_test/tsconfig.json @@ -0,0 +1,12 @@ +{ + "extends": "../../../../../tsconfig.base.json", + "compilerOptions": { + "outDir": "./target", + "skipLibCheck": true + }, + "include": [ + "public/**/*.ts", + "public/**/*.tsx", + ], + "exclude": [] +} diff --git a/x-pack/test/usage_collection/test_suites/application_usage/index.ts b/x-pack/test/usage_collection/test_suites/application_usage/index.ts index 66a4b0bedbb62..95358cebc698f 100644 --- a/x-pack/test/usage_collection/test_suites/application_usage/index.ts +++ b/x-pack/test/usage_collection/test_suites/application_usage/index.ts @@ -4,15 +4,20 @@ * you may not use this file except in compliance with the Elastic License. */ +import expect from '@kbn/expect'; import { FtrProviderContext } from '../../ftr_provider_context'; +import { applicationUsageSchema } from '../../../../../src/plugins/kibana_usage_collection/server/collectors/application_usage/schema'; -export default function ({ getPageObjects }: FtrProviderContext) { +export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('Application Usage', function () { this.tags('ciGroup1'); const { common } = getPageObjects(['common']); + const browser = getService('browser'); - it('successfully loads home (the application_usage_test plugin does not fail)', async () => { - await common.navigateToApp('home'); + it('keys in the schema match the registered application IDs', async () => { + await common.navigateToApp('home'); // Navigate to Home to make sure all the appIds are loaded + const appIds = await browser.execute(() => window.__applicationIds__); + expect(Object.keys(applicationUsageSchema).sort()).to.eql(appIds.sort()); }); }); } From 3d4915f85d11b4e7425d2de2921286827484280b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Ferna=CC=81ndez=20Haro?= Date: Fri, 15 Jan 2021 15:39:22 +0100 Subject: [PATCH 5/7] TO BE REVERTED: Extra key in schema to make CI fail --- .../server/collectors/application_usage/schema.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/plugins/kibana_usage_collection/server/collectors/application_usage/schema.ts b/src/plugins/kibana_usage_collection/server/collectors/application_usage/schema.ts index 400e5c7f97969..b76b74f9c48e9 100644 --- a/src/plugins/kibana_usage_collection/server/collectors/application_usage/schema.ts +++ b/src/plugins/kibana_usage_collection/server/collectors/application_usage/schema.ts @@ -50,6 +50,7 @@ const commonSchema: MakeSchemaFrom = { // There is a test in x-pack/test/usage_collection that validates that the keys in here match all the registered apps export const applicationUsageSchema = { + to_delete: commonSchema, // To be deleted (only to make CI fail) // OSS dashboards: commonSchema, dev_tools: commonSchema, From 4ccc4889a2dd7253f0346ab57a915d6796eeee75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Ferna=CC=81ndez=20Haro?= Date: Fri, 15 Jan 2021 15:40:12 +0100 Subject: [PATCH 6/7] Remove extra key for all green --- .../server/collectors/application_usage/schema.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/plugins/kibana_usage_collection/server/collectors/application_usage/schema.ts b/src/plugins/kibana_usage_collection/server/collectors/application_usage/schema.ts index b76b74f9c48e9..400e5c7f97969 100644 --- a/src/plugins/kibana_usage_collection/server/collectors/application_usage/schema.ts +++ b/src/plugins/kibana_usage_collection/server/collectors/application_usage/schema.ts @@ -50,7 +50,6 @@ const commonSchema: MakeSchemaFrom = { // There is a test in x-pack/test/usage_collection that validates that the keys in here match all the registered apps export const applicationUsageSchema = { - to_delete: commonSchema, // To be deleted (only to make CI fail) // OSS dashboards: commonSchema, dev_tools: commonSchema, From 4406deef34ba4aca48fe22db8b7a53cdf8fe1b9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Ferna=CC=81ndez=20Haro?= Date: Tue, 19 Jan 2021 13:25:03 +0100 Subject: [PATCH 7/7] Error message pointing to the location of the schema to fix --- .../test_suites/application_usage/index.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/x-pack/test/usage_collection/test_suites/application_usage/index.ts b/x-pack/test/usage_collection/test_suites/application_usage/index.ts index 95358cebc698f..84a9dccc397cc 100644 --- a/x-pack/test/usage_collection/test_suites/application_usage/index.ts +++ b/x-pack/test/usage_collection/test_suites/application_usage/index.ts @@ -17,7 +17,12 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('keys in the schema match the registered application IDs', async () => { await common.navigateToApp('home'); // Navigate to Home to make sure all the appIds are loaded const appIds = await browser.execute(() => window.__applicationIds__); - expect(Object.keys(applicationUsageSchema).sort()).to.eql(appIds.sort()); + try { + expect(Object.keys(applicationUsageSchema).sort()).to.eql(appIds.sort()); + } catch (err) { + err.message = `Application Usage's schema is not up-to-date with the actual registered apps. Please update it at src/plugins/kibana_usage_collection/server/collectors/application_usage/schema.ts.\n${err.message}`; + throw err; + } }); }); }