diff --git a/x-pack/plugins/cloud_security_posture/server/create_indices/create_indices.test.ts b/x-pack/plugins/cloud_security_posture/server/create_indices/create_indices.test.ts new file mode 100644 index 0000000000000..c7f500d891c1b --- /dev/null +++ b/x-pack/plugins/cloud_security_posture/server/create_indices/create_indices.test.ts @@ -0,0 +1,111 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import { elasticsearchClientMock } from '@kbn/core-elasticsearch-client-server-mocks'; +import { loggingSystemMock } from '@kbn/core/server/mocks'; +import { createBenchmarkScoreIndex } from './create_indices'; +import { + BENCHMARK_SCORE_INDEX_DEFAULT_NS, + BENCHMARK_SCORE_INDEX_PATTERN, + BENCHMARK_SCORE_INDEX_TEMPLATE_NAME, + CSP_INGEST_TIMESTAMP_PIPELINE, +} from '../../common/constants'; +import { IndicesGetIndexTemplateIndexTemplateItem } from '@elastic/elasticsearch/lib/api/types'; + +const mockEsClient = elasticsearchClientMock.createClusterClient().asScoped().asInternalUser; + +describe('createBenchmarkScoreIndex', () => { + let logger: ReturnType; + + beforeEach(() => { + logger = loggingSystemMock.createLogger(); + jest.resetAllMocks(); + }); + + it('should delete old index template from prev verions first', async () => { + mockEsClient.indices.getIndexTemplate.mockResolvedValueOnce({ + index_templates: [{ name: 'foo' } as IndicesGetIndexTemplateIndexTemplateItem], + }); + // @ts-ignore + await createBenchmarkScoreIndex(mockEsClient, { serverless: { enabled: false } }, logger); + expect(mockEsClient.indices.deleteIndexTemplate).toHaveBeenCalledTimes(1); + expect(mockEsClient.indices.deleteIndexTemplate).toHaveBeenCalledWith({ + name: 'cloud_security_posture.scores', + }); + }); + + it('should create index template with the correct index pattern, index name and default ingest pipeline', async () => { + // @ts-ignore + await createBenchmarkScoreIndex(mockEsClient, { serverless: { enabled: false } }, logger); + expect(mockEsClient.indices.putIndexTemplate).toHaveBeenCalledTimes(1); + expect(mockEsClient.indices.putIndexTemplate).toHaveBeenCalledWith( + expect.objectContaining({ + name: BENCHMARK_SCORE_INDEX_TEMPLATE_NAME, + index_patterns: BENCHMARK_SCORE_INDEX_PATTERN, + template: expect.objectContaining({ + settings: { + index: { + default_pipeline: CSP_INGEST_TIMESTAMP_PIPELINE, + }, + lifecycle: { + name: '', + }, + }, + }), + }) + ); + }); + + it('should create index template the correct index patter, index name and default ingest pipeline but without lifecycle in serverless', async () => { + await createBenchmarkScoreIndex( + mockEsClient, + { serverless: { enabled: true }, enabled: true }, + logger + ); + expect(mockEsClient.indices.putIndexTemplate).toHaveBeenCalledTimes(1); + expect(mockEsClient.indices.putIndexTemplate).toHaveBeenCalledWith( + expect.objectContaining({ + name: BENCHMARK_SCORE_INDEX_TEMPLATE_NAME, + index_patterns: BENCHMARK_SCORE_INDEX_PATTERN, + template: expect.objectContaining({ + settings: expect.not.objectContaining({ + lifecycle: { + name: '', + }, + }), + }), + }) + ); + }); + + it('should create index if does not exist', async () => { + mockEsClient.indices.exists.mockResolvedValueOnce(false); + + await createBenchmarkScoreIndex( + mockEsClient, + { serverless: { enabled: true }, enabled: true }, + logger + ); + expect(mockEsClient.indices.create).toHaveBeenCalledTimes(1); + expect(mockEsClient.indices.create).toHaveBeenCalledWith({ + index: BENCHMARK_SCORE_INDEX_DEFAULT_NS, + }); + expect(mockEsClient.indices.putMapping).toHaveBeenCalledTimes(0); + }); + + it('should updat index mapping if index exists', async () => { + mockEsClient.indices.exists.mockResolvedValueOnce(true); + + await createBenchmarkScoreIndex( + mockEsClient, + { serverless: { enabled: true }, enabled: true }, + logger + ); + expect(mockEsClient.indices.create).toHaveBeenCalledTimes(0); + expect(mockEsClient.indices.putMapping).toHaveBeenCalledTimes(1); + }); +}); diff --git a/x-pack/plugins/cloud_security_posture/server/create_indices/create_indices.ts b/x-pack/plugins/cloud_security_posture/server/create_indices/create_indices.ts index 03e3b0c804dc0..f8a935f361ff6 100644 --- a/x-pack/plugins/cloud_security_posture/server/create_indices/create_indices.ts +++ b/x-pack/plugins/cloud_security_posture/server/create_indices/create_indices.ts @@ -65,7 +65,7 @@ export const initializeCspIndices = async ( } }; -const createBenchmarkScoreIndex = async ( +export const createBenchmarkScoreIndex = async ( esClient: ElasticsearchClient, cloudSecurityPostureConfig: CloudSecurityPostureConfig, logger: Logger diff --git a/x-pack/plugins/fleet/server/integration_tests/fleet_usage_telemetry.test.ts b/x-pack/plugins/fleet/server/integration_tests/fleet_usage_telemetry.test.ts index 046ac5dfe9fad..b841c641c3af4 100644 --- a/x-pack/plugins/fleet/server/integration_tests/fleet_usage_telemetry.test.ts +++ b/x-pack/plugins/fleet/server/integration_tests/fleet_usage_telemetry.test.ts @@ -20,7 +20,8 @@ import { waitForFleetSetup } from './helpers'; const logFilePath = path.join(__dirname, 'logs.log'); -describe('fleet usage telemetry', () => { +// Failing: See https://github.com/elastic/kibana/issues/156245 +describe.skip('fleet usage telemetry', () => { let core: any; let esServer: TestElasticsearchUtils; let kbnServer: TestKibanaUtils; diff --git a/x-pack/plugins/osquery/cypress/tsconfig.json b/x-pack/plugins/osquery/cypress/tsconfig.json index 11f17f033495b..cb468e0fb8893 100644 --- a/x-pack/plugins/osquery/cypress/tsconfig.json +++ b/x-pack/plugins/osquery/cypress/tsconfig.json @@ -19,6 +19,9 @@ "resolveJsonModule": true, }, "kbn_references": [ + { + "path": "../../../test_serverless/tsconfig.json" + }, "@kbn/cypress-config", // cypress projects that are nested inside of other ts project use code // from the parent ts project in ways that can't be automatically deteceted diff --git a/x-pack/plugins/security_solution/scripts/run_cypress/parallel.ts b/x-pack/plugins/security_solution/scripts/run_cypress/parallel.ts index d411cdf8e8abd..dad6bd5b9de29 100644 --- a/x-pack/plugins/security_solution/scripts/run_cypress/parallel.ts +++ b/x-pack/plugins/security_solution/scripts/run_cypress/parallel.ts @@ -263,7 +263,17 @@ ${JSON.stringify(cypressConfigFile, null, 2)} Cypress FTR setup for file: ${filePath}: ---------------------------------------------- -${JSON.stringify(config.getAll(), null, 2)} +${JSON.stringify( + config.getAll(), + (key, v) => { + if (Array.isArray(v) && v.length > 32) { + return v.slice(0, 32).concat('... trimmed after 32 items.'); + } else { + return v; + } + }, + 2 +)} ---------------------------------------------- `); diff --git a/x-pack/plugins/transform/public/app/sections/create_transform/components/step_define/step_define_form.tsx b/x-pack/plugins/transform/public/app/sections/create_transform/components/step_define/step_define_form.tsx index e9326ae195015..246460d11d3ee 100644 --- a/x-pack/plugins/transform/public/app/sections/create_transform/components/step_define/step_define_form.tsx +++ b/x-pack/plugins/transform/public/app/sections/create_transform/components/step_define/step_define_form.tsx @@ -35,7 +35,6 @@ import { import { useStorage } from '@kbn/ml-local-storage'; import { useUrlState } from '@kbn/ml-url-state'; -import { useEnabledFeatures } from '../../../../serverless_context'; import { PivotAggDict } from '../../../../../../common/types/pivot_aggs'; import { PivotGroupByDict } from '../../../../../../common/types/pivot_group_by'; import { TRANSFORM_FUNCTION } from '../../../../../../common/constants'; @@ -113,7 +112,6 @@ export const StepDefineForm: FC = React.memo((props) => { ); const toastNotifications = useToastNotifications(); const stepDefineForm = useStepDefineForm(props); - const { showNodeInfo } = useEnabledFeatures(); const { advancedEditorConfig } = stepDefineForm.advancedPivotEditor.state; const { @@ -355,7 +353,6 @@ export const StepDefineForm: FC = React.memo((props) => { query={undefined} disabled={false} timefilter={timefilter} - hideFrozenDataTierChoice={!showNodeInfo} /> diff --git a/x-pack/test/functional/apps/maps/group2/embeddable/add_to_dashboard.js b/x-pack/test/functional/apps/maps/group2/embeddable/add_to_dashboard.js index fcd3d06115508..dbe4513b1d7ee 100644 --- a/x-pack/test/functional/apps/maps/group2/embeddable/add_to_dashboard.js +++ b/x-pack/test/functional/apps/maps/group2/embeddable/add_to_dashboard.js @@ -21,7 +21,8 @@ export default function ({ getPageObjects, getService }) { const testSubjects = getService('testSubjects'); const security = getService('security'); - describe('maps add-to-dashboard save flow', () => { + // Failing: See https://github.com/elastic/kibana/issues/167320 + describe.skip('maps add-to-dashboard save flow', () => { before(async () => { await security.testUser.setRoles( [ diff --git a/x-pack/test_serverless/api_integration/services/svl_cases/api.ts b/x-pack/test_serverless/api_integration/services/svl_cases/api.ts index 474a92c317e9f..4163fc70291db 100644 --- a/x-pack/test_serverless/api_integration/services/svl_cases/api.ts +++ b/x-pack/test_serverless/api_integration/services/svl_cases/api.ts @@ -14,17 +14,17 @@ import { CasesFindResponse } from '@kbn/cases-plugin/common/types/api'; import { kbnTestConfig, kibanaTestSuperuserServerless } from '@kbn/test'; import { FtrProviderContext } from '../../ftr_provider_context'; +export interface User { + username: string; + password: string; + description?: string; + roles: string[]; +} + export function SvlCasesApiServiceProvider({ getService }: FtrProviderContext) { const kbnServer = getService('kibanaServer'); const supertest = getService('supertest'); - interface User { - username: string; - password: string; - description?: string; - roles: string[]; - } - const superUser: User = { username: 'superuser', password: 'superuser', diff --git a/x-pack/test_serverless/api_integration/services/svl_cases/omit.ts b/x-pack/test_serverless/api_integration/services/svl_cases/omit.ts index 94ce0a479fffc..cb424ed73609c 100644 --- a/x-pack/test_serverless/api_integration/services/svl_cases/omit.ts +++ b/x-pack/test_serverless/api_integration/services/svl_cases/omit.ts @@ -9,15 +9,15 @@ import { Case, Attachment } from '@kbn/cases-plugin/common/types/domain'; import { omit } from 'lodash'; import { FtrProviderContext } from '../../ftr_provider_context'; -export function SvlCasesOmitServiceProvider({}: FtrProviderContext) { - interface CommonSavedObjectAttributes { - id?: string | null; - created_at?: string | null; - updated_at?: string | null; - version?: string | null; - [key: string]: unknown; - } +export interface CommonSavedObjectAttributes { + id?: string | null; + created_at?: string | null; + updated_at?: string | null; + version?: string | null; + [key: string]: unknown; +} +export function SvlCasesOmitServiceProvider({}: FtrProviderContext) { const savedObjectCommonAttributes = ['created_at', 'updated_at', 'version', 'id']; return { diff --git a/x-pack/test_serverless/functional/test_suites/observability/cypress/support/commands.ts b/x-pack/test_serverless/functional/test_suites/observability/cypress/support/commands.ts index 42b6801c6ab5b..38279b0c8d636 100644 --- a/x-pack/test_serverless/functional/test_suites/observability/cypress/support/commands.ts +++ b/x-pack/test_serverless/functional/test_suites/observability/cypress/support/commands.ts @@ -31,8 +31,8 @@ Cypress.Commands.add('loginAsElasticUser', () => { method: 'POST', url: `${kibanaUrlWithoutAuth}/internal/security/login`, body: { - providerType: basicProvider.type, - providerName: basicProvider.name, + providerType: basicProvider?.type, + providerName: basicProvider?.name, currentURL: `${kibanaUrlWithoutAuth}/login`, params: { username, password }, },