From 6bfc1747ba4f6a250448880e8468bc1093fa03f8 Mon Sep 17 00:00:00 2001 From: Brad White Date: Thu, 11 May 2023 16:53:41 -0600 Subject: [PATCH 01/13] Handle path.data in config file and CLI option --- packages/kbn-utils/src/path/index.ts | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/packages/kbn-utils/src/path/index.ts b/packages/kbn-utils/src/path/index.ts index 63ca454dd04fd..b4e35d896d1ee 100644 --- a/packages/kbn-utils/src/path/index.ts +++ b/packages/kbn-utils/src/path/index.ts @@ -10,6 +10,8 @@ import { join } from 'path'; import { accessSync, constants } from 'fs'; import { TypeOf, schema } from '@kbn/config-schema'; import { REPO_ROOT } from '@kbn/repo-info'; +import { getConfigFromFiles } from '@kbn/config'; +import getopts from 'getopts'; const isString = (v: any): v is string => typeof v === 'string'; @@ -25,8 +27,6 @@ const CONFIG_DIRECTORIES = [ '/etc/kibana', ].filter(isString); -const DATA_PATHS = [join(REPO_ROOT, 'data'), '/var/lib/kibana'].filter(isString); - const LOGS_PATHS = [join(REPO_ROOT, 'logs'), '/var/log/kibana'].filter(isString); function findFile(paths: string[]) { @@ -53,6 +53,21 @@ export const getConfigPath = () => findFile(CONFIG_PATHS); */ export const getConfigDirectory = () => findFile(CONFIG_DIRECTORIES); +const configDataPath = getConfigFromFiles([getConfigPath()]).path?.data; +const argv = process.argv.slice(2); +const options = getopts(argv, { + alias: { + pathData: 'path.data', + }, +}); + +const DATA_PATHS = [ + options.pathData && join(REPO_ROOT, options.pathData), + configDataPath && join(REPO_ROOT, configDataPath), + join(REPO_ROOT, 'data'), + '/var/lib/kibana', +].filter(isString); + /** * Get the directory containing runtime data * @internal From a036de618307104f5261d382661aafb618904860 Mon Sep 17 00:00:00 2001 From: Brad White Date: Fri, 12 May 2023 17:41:52 -0600 Subject: [PATCH 02/13] Extract into data path builder func --- packages/kbn-utils/src/path/index.ts | 35 +++++++++++++++------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/packages/kbn-utils/src/path/index.ts b/packages/kbn-utils/src/path/index.ts index b4e35d896d1ee..c5bb28216c8eb 100644 --- a/packages/kbn-utils/src/path/index.ts +++ b/packages/kbn-utils/src/path/index.ts @@ -41,6 +41,24 @@ function findFile(paths: string[]) { return availablePath || paths[0]; } +export const buildDataPaths = (): string[] => { + const configDataPath = getConfigFromFiles([getConfigPath()]).path?.data; + const argv = process.argv.slice(2); + const options = getopts(argv, { + string: ['pathData'], + alias: { + pathData: 'path.data', + }, + }); + + return [ + !!options.pathData && join(REPO_ROOT, options.pathData), + configDataPath && join(REPO_ROOT, configDataPath), + join(REPO_ROOT, 'data'), + '/var/lib/kibana', + ].filter(isString); +}; + /** * Get the path of kibana.yml * @internal @@ -53,26 +71,11 @@ export const getConfigPath = () => findFile(CONFIG_PATHS); */ export const getConfigDirectory = () => findFile(CONFIG_DIRECTORIES); -const configDataPath = getConfigFromFiles([getConfigPath()]).path?.data; -const argv = process.argv.slice(2); -const options = getopts(argv, { - alias: { - pathData: 'path.data', - }, -}); - -const DATA_PATHS = [ - options.pathData && join(REPO_ROOT, options.pathData), - configDataPath && join(REPO_ROOT, configDataPath), - join(REPO_ROOT, 'data'), - '/var/lib/kibana', -].filter(isString); - /** * Get the directory containing runtime data * @internal */ -export const getDataPath = () => findFile(DATA_PATHS); +export const getDataPath = () => findFile(buildDataPaths()); /** * Get the directory containing logs From 316331bcab56dc6f1c0b6c74af49c30a4ed0a0b0 Mon Sep 17 00:00:00 2001 From: Brad White Date: Fri, 12 May 2023 17:42:13 -0600 Subject: [PATCH 03/13] Add tests for argv --- packages/kbn-utils/src/path/index.test.ts | 35 ++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/packages/kbn-utils/src/path/index.test.ts b/packages/kbn-utils/src/path/index.test.ts index 608f3cb2cfeb2..a3b414701e3a0 100644 --- a/packages/kbn-utils/src/path/index.test.ts +++ b/packages/kbn-utils/src/path/index.test.ts @@ -7,7 +7,7 @@ */ import { accessSync, constants } from 'fs'; -import { getConfigPath, getDataPath, getLogsPath, getConfigDirectory } from '.'; +import { getConfigPath, getDataPath, getLogsPath, getConfigDirectory, buildDataPaths } from '.'; import { REPO_ROOT } from '@kbn/repo-info'; expect.addSnapshotSerializer( @@ -46,3 +46,36 @@ describe('Default path finder', () => { expect(() => accessSync(configPath, constants.R_OK)).not.toThrow(); }); }); + +describe('Custom data path finder', () => { + const originalArgv = process.argv; + + beforeEach(() => { + process.argv = originalArgv; + }); + + it('overrides path.data when provided as command line argument', () => { + process.argv = ['--foo', 'bar', '--path.data', '/some/data/path', '--baz', 'xyz']; + + expect(buildDataPaths()).toMatchInlineSnapshot(` + Array [ + /some/data/path, + /data, + "/var/lib/kibana", + ] + `); + }); + + it('ignores the path.data flag when no value is provided', () => { + process.argv = ['--foo', 'bar', '--path.data', '--baz', 'xyz']; + + expect(buildDataPaths()).toMatchInlineSnapshot(` + Array [ + /data, + "/var/lib/kibana", + ] + `); + }); + + // test config file override +}); From 22e75f07d44954aa24661efddb7d0006265fa9f6 Mon Sep 17 00:00:00 2001 From: Brad White Date: Fri, 12 May 2023 18:40:12 -0600 Subject: [PATCH 04/13] Add kibana.yml data path test --- .../src/path/__fixtures__/kibana.yml | 1 + packages/kbn-utils/src/path/index.test.ts | 19 ++++++++++++++++++- packages/kbn-utils/src/path/index.ts | 14 ++++++++------ 3 files changed, 27 insertions(+), 7 deletions(-) create mode 100644 packages/kbn-utils/src/path/__fixtures__/kibana.yml diff --git a/packages/kbn-utils/src/path/__fixtures__/kibana.yml b/packages/kbn-utils/src/path/__fixtures__/kibana.yml new file mode 100644 index 0000000000000..a5a8a9f420fd1 --- /dev/null +++ b/packages/kbn-utils/src/path/__fixtures__/kibana.yml @@ -0,0 +1 @@ +path.data: /path/from/yml \ No newline at end of file diff --git a/packages/kbn-utils/src/path/index.test.ts b/packages/kbn-utils/src/path/index.test.ts index a3b414701e3a0..36d401d5dbda8 100644 --- a/packages/kbn-utils/src/path/index.test.ts +++ b/packages/kbn-utils/src/path/index.test.ts @@ -6,6 +6,7 @@ * Side Public License, v 1. */ +import { join } from 'path'; import { accessSync, constants } from 'fs'; import { getConfigPath, getDataPath, getLogsPath, getConfigDirectory, buildDataPaths } from '.'; import { REPO_ROOT } from '@kbn/repo-info'; @@ -57,6 +58,10 @@ describe('Custom data path finder', () => { it('overrides path.data when provided as command line argument', () => { process.argv = ['--foo', 'bar', '--path.data', '/some/data/path', '--baz', 'xyz']; + /* + * Test buildDataPaths since getDataPath returns the first valid directory and + * custom paths do not exist in environment. Custom directories are built during env init. + */ expect(buildDataPaths()).toMatchInlineSnapshot(` Array [ /some/data/path, @@ -77,5 +82,17 @@ describe('Custom data path finder', () => { `); }); - // test config file override + it('overrides path.when when provided by kibana.yml', () => { + process.env.KBN_PATH_CONF = join(__dirname, '__fixtures__'); + + expect(buildDataPaths()).toMatchInlineSnapshot(` + Array [ + /path/from/yml, + /data, + "/var/lib/kibana", + ] + `); + + delete process.env.KBN_PATH_CONF; + }); }); diff --git a/packages/kbn-utils/src/path/index.ts b/packages/kbn-utils/src/path/index.ts index c5bb28216c8eb..3dec574106470 100644 --- a/packages/kbn-utils/src/path/index.ts +++ b/packages/kbn-utils/src/path/index.ts @@ -15,11 +15,13 @@ import getopts from 'getopts'; const isString = (v: any): v is string => typeof v === 'string'; -const CONFIG_PATHS = [ - process.env.KBN_PATH_CONF && join(process.env.KBN_PATH_CONF, 'kibana.yml'), - join(REPO_ROOT, 'config/kibana.yml'), - '/etc/kibana/kibana.yml', -].filter(isString); +const buildConfigPaths = () => { + return [ + process.env.KBN_PATH_CONF && join(process.env.KBN_PATH_CONF, 'kibana.yml'), + join(REPO_ROOT, 'config/kibana.yml'), + '/etc/kibana/kibana.yml', + ].filter(isString); +}; const CONFIG_DIRECTORIES = [ process.env.KBN_PATH_CONF, @@ -63,7 +65,7 @@ export const buildDataPaths = (): string[] => { * Get the path of kibana.yml * @internal */ -export const getConfigPath = () => findFile(CONFIG_PATHS); +export const getConfigPath = () => findFile(buildConfigPaths()); /** * Get the directory containing configuration files From 048ac2833c58f16018b28a5c2cb8de31d71d9c2b Mon Sep 17 00:00:00 2001 From: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Date: Sat, 13 May 2023 01:17:44 +0000 Subject: [PATCH 05/13] [CI] Auto-commit changed files from 'node scripts/lint_ts_projects --fix' --- packages/kbn-utils/tsconfig.json | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/kbn-utils/tsconfig.json b/packages/kbn-utils/tsconfig.json index 6baa222ef8c37..f6e7fb408bfa2 100644 --- a/packages/kbn-utils/tsconfig.json +++ b/packages/kbn-utils/tsconfig.json @@ -13,6 +13,7 @@ "kbn_references": [ "@kbn/config-schema", "@kbn/repo-info", + "@kbn/config", ], "exclude": [ "target/**/*", From 4841d25a5722e3962c6ed3c28cbc65b258252b08 Mon Sep 17 00:00:00 2001 From: Brad White Date: Wed, 24 May 2023 12:21:47 -0600 Subject: [PATCH 06/13] Use path.resolve. Add tests for relative and absolute paths --- packages/kbn-utils/src/path/index.test.ts | 24 +++++++++++++++++++---- packages/kbn-utils/src/path/index.ts | 6 +++--- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/packages/kbn-utils/src/path/index.test.ts b/packages/kbn-utils/src/path/index.test.ts index 36d401d5dbda8..dea744d728854 100644 --- a/packages/kbn-utils/src/path/index.test.ts +++ b/packages/kbn-utils/src/path/index.test.ts @@ -55,7 +55,7 @@ describe('Custom data path finder', () => { process.argv = originalArgv; }); - it('overrides path.data when provided as command line argument', () => { + it('overrides absolute path.data when provided as command line argument', () => { process.argv = ['--foo', 'bar', '--path.data', '/some/data/path', '--baz', 'xyz']; /* @@ -64,7 +64,23 @@ describe('Custom data path finder', () => { */ expect(buildDataPaths()).toMatchInlineSnapshot(` Array [ - /some/data/path, + "/some/data/path", + /data, + "/var/lib/kibana", + ] + `); + }); + + it('overrides relative path.data when provided as command line argument', () => { + process.argv = ['--foo', 'bar', '--path.data', 'data2', '--baz', 'xyz']; + + /* + * Test buildDataPaths since getDataPath returns the first valid directory and + * custom paths do not exist in environment. Custom directories are built during env init. + */ + expect(buildDataPaths()).toMatchInlineSnapshot(` + Array [ + /data2, /data, "/var/lib/kibana", ] @@ -82,12 +98,12 @@ describe('Custom data path finder', () => { `); }); - it('overrides path.when when provided by kibana.yml', () => { + it('overrides absolute path.data when when provided by kibana.yml', () => { process.env.KBN_PATH_CONF = join(__dirname, '__fixtures__'); expect(buildDataPaths()).toMatchInlineSnapshot(` Array [ - /path/from/yml, + "/path/from/yml", /data, "/var/lib/kibana", ] diff --git a/packages/kbn-utils/src/path/index.ts b/packages/kbn-utils/src/path/index.ts index 3dec574106470..21495464cb310 100644 --- a/packages/kbn-utils/src/path/index.ts +++ b/packages/kbn-utils/src/path/index.ts @@ -6,7 +6,7 @@ * Side Public License, v 1. */ -import { join } from 'path'; +import { join, resolve } from 'path'; import { accessSync, constants } from 'fs'; import { TypeOf, schema } from '@kbn/config-schema'; import { REPO_ROOT } from '@kbn/repo-info'; @@ -54,8 +54,8 @@ export const buildDataPaths = (): string[] => { }); return [ - !!options.pathData && join(REPO_ROOT, options.pathData), - configDataPath && join(REPO_ROOT, configDataPath), + !!options.pathData && resolve(REPO_ROOT, options.pathData), + configDataPath && resolve(REPO_ROOT, configDataPath), join(REPO_ROOT, 'data'), '/var/lib/kibana', ].filter(isString); From 33cc6433b7d4ef7357b3ee07d9b43a421609b4c7 Mon Sep 17 00:00:00 2001 From: Brad White Date: Wed, 24 May 2023 12:28:25 -0600 Subject: [PATCH 07/13] Update docs --- docs/setup/settings.asciidoc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/setup/settings.asciidoc b/docs/setup/settings.asciidoc index 9e7010110568b..003e46d56bc77 100644 --- a/docs/setup/settings.asciidoc +++ b/docs/setup/settings.asciidoc @@ -327,8 +327,9 @@ Specifies the name of the connector that is used to send email notifications. In {ecloud}, the default value is `elastic-cloud-email`. [[path-data]] `path.data`:: -The path where {kib} stores persistent data -not saved in {es}. *Default: `data`* +The path where {kib} stores persistent data not saved in {es}. +Can be a relative or absolute path. +Relative paths are resolved starting from the installation directory. *Default: `data`* `pid.file`:: Specifies the path where {kib} creates the process ID file. From 33ea1aa2d00c76436154b2603e58ad6d41a7d548 Mon Sep 17 00:00:00 2001 From: Brad White Date: Wed, 24 May 2023 16:01:06 -0600 Subject: [PATCH 08/13] Better test descriptions --- packages/kbn-utils/src/path/index.test.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/kbn-utils/src/path/index.test.ts b/packages/kbn-utils/src/path/index.test.ts index dea744d728854..b7e95360f45b8 100644 --- a/packages/kbn-utils/src/path/index.test.ts +++ b/packages/kbn-utils/src/path/index.test.ts @@ -55,7 +55,7 @@ describe('Custom data path finder', () => { process.argv = originalArgv; }); - it('overrides absolute path.data when provided as command line argument', () => { + it('overrides path.data with absolute path when provided as command line argument', () => { process.argv = ['--foo', 'bar', '--path.data', '/some/data/path', '--baz', 'xyz']; /* @@ -71,7 +71,7 @@ describe('Custom data path finder', () => { `); }); - it('overrides relative path.data when provided as command line argument', () => { + it('overrides path.data with relative path when provided as command line argument', () => { process.argv = ['--foo', 'bar', '--path.data', 'data2', '--baz', 'xyz']; /* @@ -98,7 +98,7 @@ describe('Custom data path finder', () => { `); }); - it('overrides absolute path.data when when provided by kibana.yml', () => { + it('overrides path.data with absolute path when when provided by kibana.yml', () => { process.env.KBN_PATH_CONF = join(__dirname, '__fixtures__'); expect(buildDataPaths()).toMatchInlineSnapshot(` From f2391c22a87b0fdd0f0058d2501541b26796da06 Mon Sep 17 00:00:00 2001 From: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Date: Tue, 5 Sep 2023 02:36:48 +0000 Subject: [PATCH 09/13] [CI] Auto-commit changed files from 'node scripts/eslint --no-cache --fix' --- .../timelines/data_providers.cy.ts | 98 ++++++++++--------- 1 file changed, 51 insertions(+), 47 deletions(-) diff --git a/x-pack/test/security_solution_cypress/cypress/e2e/investigations/timelines/data_providers.cy.ts b/x-pack/test/security_solution_cypress/cypress/e2e/investigations/timelines/data_providers.cy.ts index df2d45b0ee4a3..0caaefd1c5e69 100644 --- a/x-pack/test/security_solution_cypress/cypress/e2e/investigations/timelines/data_providers.cy.ts +++ b/x-pack/test/security_solution_cypress/cypress/e2e/investigations/timelines/data_providers.cy.ts @@ -30,61 +30,65 @@ import { HOSTS_URL } from '../../../urls/navigation'; import { cleanKibana, scrollToBottom } from '../../../tasks/common'; // Failing in serverless -describe('timeline data providers', { tags: ['@ess', '@serverless', '@brokenInServerless'] }, () => { - before(() => { - cleanKibana(); - }); +describe( + 'timeline data providers', + { tags: ['@ess', '@serverless', '@brokenInServerless'] }, + () => { + before(() => { + cleanKibana(); + }); - beforeEach(() => { - login(); - visit(HOSTS_URL); - waitForAllHostsToBeLoaded(); - scrollToBottom(); - createNewTimeline(); - addNameAndDescriptionToTimeline(getTimeline()); - populateTimeline(); - }); + beforeEach(() => { + login(); + visit(HOSTS_URL); + waitForAllHostsToBeLoaded(); + scrollToBottom(); + createNewTimeline(); + addNameAndDescriptionToTimeline(getTimeline()); + populateTimeline(); + }); - it('displays the data provider action menu when Enter is pressed', () => { - addDataProvider({ field: 'host.name', operator: 'exists' }); + it('displays the data provider action menu when Enter is pressed', () => { + addDataProvider({ field: 'host.name', operator: 'exists' }); - cy.get(TIMELINE_DATA_PROVIDERS_ACTION_MENU).should('not.exist'); - cy.get(`${TIMELINE_FLYOUT_HEADER} ${TIMELINE_DROPPED_DATA_PROVIDERS}`).focus(); - cy.get(`${TIMELINE_FLYOUT_HEADER} ${TIMELINE_DROPPED_DATA_PROVIDERS}`) - .first() - .parent() - .type('{enter}'); + cy.get(TIMELINE_DATA_PROVIDERS_ACTION_MENU).should('not.exist'); + cy.get(`${TIMELINE_FLYOUT_HEADER} ${TIMELINE_DROPPED_DATA_PROVIDERS}`).focus(); + cy.get(`${TIMELINE_FLYOUT_HEADER} ${TIMELINE_DROPPED_DATA_PROVIDERS}`) + .first() + .parent() + .type('{enter}'); + + cy.get(TIMELINE_DATA_PROVIDERS_ACTION_MENU).should('exist'); + }); - cy.get(TIMELINE_DATA_PROVIDERS_ACTION_MENU).should('exist'); - }); + it.skip( + 'persists timeline when data provider is updated by dragging a field from data grid', + { tags: ['@brokenInServerless'] }, + () => { + updateDataProviderbyDraggingField('host.name', 0); + waitForTimelineChanges(); + cy.reload(); + cy.get(`${GET_TIMELINE_GRID_CELL('host.name')}`) + .first() + .then((hostname) => { + cy.get(TIMELINE_DATA_PROVIDERS_CONTAINER).contains(`host.name: "${hostname.text()}"`); + }); + } + ); - it.skip( - 'persists timeline when data provider is updated by dragging a field from data grid', - { tags: ['@brokenInServerless'] }, - () => { - updateDataProviderbyDraggingField('host.name', 0); + it('persists timeline when a field is added by hover action "Add To Timeline" in data provider ', () => { + addDataProvider({ field: 'host.name', operator: 'exists' }); + waitForTimelineChanges(); + updateDataProviderByFieldHoverAction('host.name', 0); waitForTimelineChanges(); cy.reload(); cy.get(`${GET_TIMELINE_GRID_CELL('host.name')}`) .first() .then((hostname) => { - cy.get(TIMELINE_DATA_PROVIDERS_CONTAINER).contains(`host.name: "${hostname.text()}"`); - }); - } - ); - - it('persists timeline when a field is added by hover action "Add To Timeline" in data provider ', () => { - addDataProvider({ field: 'host.name', operator: 'exists' }); - waitForTimelineChanges(); - updateDataProviderByFieldHoverAction('host.name', 0); - waitForTimelineChanges(); - cy.reload(); - cy.get(`${GET_TIMELINE_GRID_CELL('host.name')}`) - .first() - .then((hostname) => { - cy.get(TIMELINE_DATA_PROVIDERS_CONTAINER).should((dataProviderContainer) => { - expect(dataProviderContainer).to.contain(`host.name: "${hostname.text()}"`); + cy.get(TIMELINE_DATA_PROVIDERS_CONTAINER).should((dataProviderContainer) => { + expect(dataProviderContainer).to.contain(`host.name: "${hostname.text()}"`); + }); }); - }); - }); -}); + }); + } +); From 4d7806d82e3e88019dd75637406a8904420efe42 Mon Sep 17 00:00:00 2001 From: Brad White Date: Mon, 27 Nov 2023 22:02:47 -0700 Subject: [PATCH 10/13] Use resolve for config path --- packages/kbn-utils/src/path/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/kbn-utils/src/path/index.ts b/packages/kbn-utils/src/path/index.ts index 21495464cb310..caeaa9a493f17 100644 --- a/packages/kbn-utils/src/path/index.ts +++ b/packages/kbn-utils/src/path/index.ts @@ -17,7 +17,7 @@ const isString = (v: any): v is string => typeof v === 'string'; const buildConfigPaths = () => { return [ - process.env.KBN_PATH_CONF && join(process.env.KBN_PATH_CONF, 'kibana.yml'), + process.env.KBN_PATH_CONF && resolve(process.env.KBN_PATH_CONF, 'kibana.yml'), join(REPO_ROOT, 'config/kibana.yml'), '/etc/kibana/kibana.yml', ].filter(isString); From 92a2ed1b5c4a302908f46a8d3e118b813365784f Mon Sep 17 00:00:00 2001 From: Brad White Date: Mon, 27 Nov 2023 22:52:21 -0700 Subject: [PATCH 11/13] Add missing test case --- .../src/path/__fixtures__/kibana.yml | 1 - packages/kbn-utils/src/path/index.test.ts | 116 +++++++++++------- 2 files changed, 73 insertions(+), 44 deletions(-) delete mode 100644 packages/kbn-utils/src/path/__fixtures__/kibana.yml diff --git a/packages/kbn-utils/src/path/__fixtures__/kibana.yml b/packages/kbn-utils/src/path/__fixtures__/kibana.yml deleted file mode 100644 index a5a8a9f420fd1..0000000000000 --- a/packages/kbn-utils/src/path/__fixtures__/kibana.yml +++ /dev/null @@ -1 +0,0 @@ -path.data: /path/from/yml \ No newline at end of file diff --git a/packages/kbn-utils/src/path/index.test.ts b/packages/kbn-utils/src/path/index.test.ts index b7e95360f45b8..163dfbef598dc 100644 --- a/packages/kbn-utils/src/path/index.test.ts +++ b/packages/kbn-utils/src/path/index.test.ts @@ -8,6 +8,7 @@ import { join } from 'path'; import { accessSync, constants } from 'fs'; +import { rm, mkdtemp, writeFile } from 'fs/promises'; import { getConfigPath, getDataPath, getLogsPath, getConfigDirectory, buildDataPaths } from '.'; import { REPO_ROOT } from '@kbn/repo-info'; @@ -55,38 +56,6 @@ describe('Custom data path finder', () => { process.argv = originalArgv; }); - it('overrides path.data with absolute path when provided as command line argument', () => { - process.argv = ['--foo', 'bar', '--path.data', '/some/data/path', '--baz', 'xyz']; - - /* - * Test buildDataPaths since getDataPath returns the first valid directory and - * custom paths do not exist in environment. Custom directories are built during env init. - */ - expect(buildDataPaths()).toMatchInlineSnapshot(` - Array [ - "/some/data/path", - /data, - "/var/lib/kibana", - ] - `); - }); - - it('overrides path.data with relative path when provided as command line argument', () => { - process.argv = ['--foo', 'bar', '--path.data', 'data2', '--baz', 'xyz']; - - /* - * Test buildDataPaths since getDataPath returns the first valid directory and - * custom paths do not exist in environment. Custom directories are built during env init. - */ - expect(buildDataPaths()).toMatchInlineSnapshot(` - Array [ - /data2, - /data, - "/var/lib/kibana", - ] - `); - }); - it('ignores the path.data flag when no value is provided', () => { process.argv = ['--foo', 'bar', '--path.data', '--baz', 'xyz']; @@ -98,17 +67,78 @@ describe('Custom data path finder', () => { `); }); - it('overrides path.data with absolute path when when provided by kibana.yml', () => { - process.env.KBN_PATH_CONF = join(__dirname, '__fixtures__'); - - expect(buildDataPaths()).toMatchInlineSnapshot(` - Array [ - "/path/from/yml", - /data, - "/var/lib/kibana", - ] - `); + describe('overrides path.data when provided as command line argument', () => { + it('with absolute path', () => { + process.argv = ['--foo', 'bar', '--path.data', '/some/data/path', '--baz', 'xyz']; + + /* + * Test buildDataPaths since getDataPath returns the first valid directory and + * custom paths do not exist in environment. Custom directories are built during env init. + */ + expect(buildDataPaths()).toMatchInlineSnapshot(` + Array [ + "/some/data/path", + /data, + "/var/lib/kibana", + ] + `); + }); + + it('with relative path', () => { + process.argv = ['--foo', 'bar', '--path.data', 'data2', '--baz', 'xyz']; + + /* + * Test buildDataPaths since getDataPath returns the first valid directory and + * custom paths do not exist in environment. Custom directories are built during env init. + */ + expect(buildDataPaths()).toMatchInlineSnapshot(` + Array [ + /data2, + /data, + "/var/lib/kibana", + ] + `); + }); + }); - delete process.env.KBN_PATH_CONF; + describe('overrides path.data when provided by kibana.yml', () => { + let tempDir: string; + let tempConfigFile: string; + + beforeAll(async () => { + tempDir = await mkdtemp('config-test'); + tempConfigFile = join(tempDir, 'kibana.yml'); + }); + + afterAll(async () => { + await rm(tempDir, { recursive: true }); + delete process.env.KBN_PATH_CONF; + }); + + it('with absolute path', async () => { + process.env.KBN_PATH_CONF = tempDir; + await writeFile(tempConfigFile, `path.data: /path/from/yml`); + + expect(buildDataPaths()).toMatchInlineSnapshot(` + Array [ + "/path/from/yml", + /data, + "/var/lib/kibana", + ] + `); + }); + + it('with relative path', async () => { + process.env.KBN_PATH_CONF = tempDir; + await writeFile(tempConfigFile, `path.data: data2`); + + expect(buildDataPaths()).toMatchInlineSnapshot(` + Array [ + /data2, + /data, + "/var/lib/kibana", + ] + `); + }); }); }); From fa2b9cb015625f515f79a9f140bdc18c2af43610 Mon Sep 17 00:00:00 2001 From: Brad White Date: Tue, 28 Nov 2023 11:48:14 -0700 Subject: [PATCH 12/13] Debug project build --- .buildkite/scripts/steps/serverless/build_and_deploy.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.buildkite/scripts/steps/serverless/build_and_deploy.sh b/.buildkite/scripts/steps/serverless/build_and_deploy.sh index 6c5b72a0b4922..86f864e3d60ce 100644 --- a/.buildkite/scripts/steps/serverless/build_and_deploy.sh +++ b/.buildkite/scripts/steps/serverless/build_and_deploy.sh @@ -1,7 +1,7 @@ #!/bin/bash set -euo pipefail - +set -x source .buildkite/scripts/common/util.sh source .buildkite/scripts/steps/artifacts/docker_image.sh @@ -105,3 +105,5 @@ EOF is_pr_with_label "ci:project-deploy-elasticsearch" && deploy "elasticsearch" is_pr_with_label "ci:project-deploy-observability" && deploy "observability" is_pr_with_label "ci:project-deploy-security" && deploy "security" + +set +x From b1a77c8a07846633eaf1fc3d7e7bc0feb42c1a3e Mon Sep 17 00:00:00 2001 From: Brad White Date: Tue, 28 Nov 2023 14:04:29 -0700 Subject: [PATCH 13/13] Revert "Debug project build" This reverts commit fa2b9cb015625f515f79a9f140bdc18c2af43610. --- .buildkite/scripts/steps/serverless/build_and_deploy.sh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.buildkite/scripts/steps/serverless/build_and_deploy.sh b/.buildkite/scripts/steps/serverless/build_and_deploy.sh index 86f864e3d60ce..6c5b72a0b4922 100644 --- a/.buildkite/scripts/steps/serverless/build_and_deploy.sh +++ b/.buildkite/scripts/steps/serverless/build_and_deploy.sh @@ -1,7 +1,7 @@ #!/bin/bash set -euo pipefail -set -x + source .buildkite/scripts/common/util.sh source .buildkite/scripts/steps/artifacts/docker_image.sh @@ -105,5 +105,3 @@ EOF is_pr_with_label "ci:project-deploy-elasticsearch" && deploy "elasticsearch" is_pr_with_label "ci:project-deploy-observability" && deploy "observability" is_pr_with_label "ci:project-deploy-security" && deploy "security" - -set +x