diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 3bd8c2f5e1bbd..962b4b43948fd 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1697,7 +1697,6 @@ x-pack/solutions/observability/plugins/observability/server/lib/esql_extensions /x-pack/solutions/observability/test/serverless/functional/test_suites/dataset_quality @elastic/obs-onboarding-team /x-pack/solutions/observability/plugins/observability/public/pages/landing @elastic/obs-onboarding-team /x-pack/solutions/observability/plugins/observability/test/scout/ui/tests/landing.spec.ts @elastic/obs-onboarding-team -/x-pack/solutions/observability/test/api_integration_deployment_agnostic/apis/onboarding/ @elastic/obs-onboarding-team # Observability-ui /x-pack/solutions/observability/test/serverless/api_integration/configs/index.ts @elastic/observability-ui diff --git a/x-pack/solutions/observability/plugins/observability_onboarding/moon.yml b/x-pack/solutions/observability/plugins/observability_onboarding/moon.yml index 632b1e93934c1..96a6ba941190f 100644 --- a/x-pack/solutions/observability/plugins/observability_onboarding/moon.yml +++ b/x-pack/solutions/observability/plugins/observability_onboarding/moon.yml @@ -52,6 +52,9 @@ dependsOn: - '@kbn/apm-plugin' - '@kbn/react-kibana-mount' - '@kbn/react-query' + - '@kbn/scout-oblt' + - '@kbn/scout-synthtrace' + - '@kbn/synthtrace-client' tags: - plugin - prod @@ -65,6 +68,7 @@ fileGroups: - public/**/*.json - server/**/* - e2e/**/* + - test/scout/**/* - '!target/**/*' tasks: jest: diff --git a/x-pack/solutions/observability/plugins/observability_onboarding/test/scout/README.md b/x-pack/solutions/observability/plugins/observability_onboarding/test/scout/README.md index e5afcee9fe69f..106f0d98cb4d2 100644 --- a/x-pack/solutions/observability/plugins/observability_onboarding/test/scout/README.md +++ b/x-pack/solutions/observability/plugins/observability_onboarding/test/scout/README.md @@ -12,6 +12,18 @@ node scripts/scout.js start-server --arch serverless --domain [search|observabil Then you can run the tests in another terminal: +### API tests (sequential) + +```bash +// ESS +npx playwright test --config x-pack/solutions/observability/plugins/observability_onboarding/test/scout/api/playwright.config.ts --project=local --grep stateful-classic + +// Serverless +npx playwright test --config x-pack/solutions/observability/plugins/observability_onboarding/test/scout/api/playwright.config.ts --project=local --grep serverless-observability_complete +``` + +### UI tests + Some tests are designed to run sequentially: ```bash diff --git a/x-pack/solutions/observability/plugins/observability_onboarding/test/scout/api/fixtures/constants.ts b/x-pack/solutions/observability/plugins/observability_onboarding/test/scout/api/fixtures/constants.ts new file mode 100644 index 0000000000000..d7f49426f70db --- /dev/null +++ b/x-pack/solutions/observability/plugins/observability_onboarding/test/scout/api/fixtures/constants.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 + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +export const ONBOARDING_COMMON_HEADERS = { + 'kbn-xsrf': 'scout', + 'x-elastic-internal-origin': 'kibana', +} as const; diff --git a/x-pack/solutions/observability/plugins/observability_onboarding/test/scout/api/fixtures/index.ts b/x-pack/solutions/observability/plugins/observability_onboarding/test/scout/api/fixtures/index.ts new file mode 100644 index 0000000000000..606978c70c388 --- /dev/null +++ b/x-pack/solutions/observability/plugins/observability_onboarding/test/scout/api/fixtures/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 + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import { apiTest as baseApiTest, mergeTests } from '@kbn/scout-oblt'; +import { synthtraceFixture } from '@kbn/scout-synthtrace'; + +export const apiTest = mergeTests(baseApiTest, synthtraceFixture); diff --git a/x-pack/solutions/observability/plugins/observability_onboarding/test/scout/api/playwright.config.ts b/x-pack/solutions/observability/plugins/observability_onboarding/test/scout/api/playwright.config.ts new file mode 100644 index 0000000000000..4e6053634da5b --- /dev/null +++ b/x-pack/solutions/observability/plugins/observability_onboarding/test/scout/api/playwright.config.ts @@ -0,0 +1,12 @@ +/* + * 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 { createPlaywrightConfig } from '@kbn/scout-oblt'; + +export default createPlaywrightConfig({ + testDir: './tests', +}); diff --git a/x-pack/solutions/observability/plugins/observability_onboarding/test/scout/api/tests/onboarding_flow_progress.spec.ts b/x-pack/solutions/observability/plugins/observability_onboarding/test/scout/api/tests/onboarding_flow_progress.spec.ts new file mode 100644 index 0000000000000..d3550e56446ba --- /dev/null +++ b/x-pack/solutions/observability/plugins/observability_onboarding/test/scout/api/tests/onboarding_flow_progress.spec.ts @@ -0,0 +1,194 @@ +/* + * 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 { log, timerange } from '@kbn/synthtrace-client'; +import { expect } from '@kbn/scout-oblt/api'; +import { tags } from '@kbn/scout-oblt'; +import type { KibanaRole } from '@kbn/scout-oblt'; +import { ONBOARDING_COMMON_HEADERS } from '../fixtures/constants'; +import { apiTest } from '../fixtures'; + +const NO_ACCESS_USER_ROLE: KibanaRole = { + elasticsearch: { + cluster: [], + indices: [], + }, + kibana: [], +}; + +apiTest.describe( + 'Observability onboarding GET flow progress', + { tag: [...tags.stateful.classic, ...tags.serverless.observability.complete] }, + () => { + const datasetName = 'api-tests'; + const namespace = 'default'; + const agentId = 'my-agent-id'; + + /** Cookie session: create flow runs `authc.apiKeys.create`, which fails for API-key-authenticated requests. */ + let adminInteractiveHeaders: Record; + let onboardingId: string; + + apiTest.beforeAll(async ({ apiClient, samlAuth }) => { + const { cookieHeader } = await samlAuth.asInteractiveUser('admin'); + adminInteractiveHeaders = { + ...ONBOARDING_COMMON_HEADERS, + ...cookieHeader, + }; + const createFlowResponse = await apiClient.post('internal/observability_onboarding/flow', { + headers: adminInteractiveHeaders, + responseType: 'json', + }); + expect(createFlowResponse).toHaveStatusCode(200); + onboardingId = (createFlowResponse.body as { onboardingFlow: { id: string } }).onboardingFlow + .id; + }); + + apiTest('returns 404 when onboardingId does not exist', async ({ apiClient }) => { + const response = await apiClient.get( + 'internal/observability_onboarding/flow/test-onboarding-id/progress', + { + headers: adminInteractiveHeaders, + responseType: 'json', + } + ); + expect(response).toHaveStatusCode(404); + expect((response.body as { message?: string }).message).toContain( + 'onboarding session not found' + ); + }); + + apiTest( + 'returns 404 for user without access to the onboarding session', + async ({ apiClient, samlAuth }) => { + const { cookieHeader } = await samlAuth.asInteractiveUser(NO_ACCESS_USER_ROLE); + const response = await apiClient.get( + `internal/observability_onboarding/flow/${onboardingId}/progress`, + { + headers: { + ...ONBOARDING_COMMON_HEADERS, + ...cookieHeader, + }, + responseType: 'json', + } + ); + expect(response).toHaveStatusCode(404); + expect((response.body as { message?: string }).message).toContain( + 'onboarding session not found' + ); + } + ); + + apiTest( + 'logs-ingest progress after ea-status complete', + async ({ apiClient, logsSynthtraceEsClient }) => { + await apiTest.step('post ea-status complete', async () => { + const stepResponse = await apiClient.post( + `internal/observability_onboarding/flow/${onboardingId}/step/ea-status`, + { + headers: adminInteractiveHeaders, + responseType: 'json', + body: { + status: 'complete', + payload: { + agentId, + }, + }, + } + ); + expect(stepResponse).toHaveStatusCode(200); + }); + + await apiTest.step('log-ingest is loading when no logs ingested', async () => { + const response = await apiClient.get( + `internal/observability_onboarding/flow/${onboardingId}/progress`, + { + headers: adminInteractiveHeaders, + responseType: 'json', + } + ); + expect(response).toHaveStatusCode(200); + const progress = (response.body as { progress: Record }) + .progress; + expect(progress['logs-ingest']).toMatchObject({ status: 'loading' }); + }); + + await apiTest.step( + 'log-ingest stays loading when logs use a different agent id', + async () => { + await logsSynthtraceEsClient.index( + timerange('2023-11-20T10:00:00.000Z', '2023-11-20T10:01:00.000Z') + .interval('1m') + .rate(1) + .generator((timestamp) => + log + .create() + .message('This is a log message') + .timestamp(timestamp) + .dataset(datasetName) + .namespace(namespace) + .service('my-service') + .defaults({ + 'agent.id': 'another-agent-id', + 'log.file.path': '/my-service.log', + }) + ) + ); + + const response = await apiClient.get( + `internal/observability_onboarding/flow/${onboardingId}/progress`, + { + headers: adminInteractiveHeaders, + responseType: 'json', + } + ); + expect(response).toHaveStatusCode(200); + const progress = (response.body as { progress: Record }) + .progress; + expect(progress['logs-ingest']).toMatchObject({ status: 'loading' }); + + await logsSynthtraceEsClient.clean(); + } + ); + + await apiTest.step('log-ingest is complete when logs match expected agent id', async () => { + await logsSynthtraceEsClient.index( + timerange('2023-11-20T10:00:00.000Z', '2023-11-20T10:01:00.000Z') + .interval('1m') + .rate(1) + .generator((timestamp) => + log + .create() + .message('This is a log message') + .timestamp(timestamp) + .dataset(datasetName) + .namespace(namespace) + .service('my-service') + .defaults({ + 'agent.id': agentId, + 'log.file.path': '/my-service.log', + }) + ) + ); + + const response = await apiClient.get( + `internal/observability_onboarding/flow/${onboardingId}/progress`, + { + headers: adminInteractiveHeaders, + responseType: 'json', + } + ); + expect(response).toHaveStatusCode(200); + const progress = (response.body as { progress: Record }) + .progress; + expect(progress['logs-ingest']).toMatchObject({ status: 'complete' }); + + await logsSynthtraceEsClient.clean(); + }); + } + ); + } +); diff --git a/x-pack/solutions/observability/plugins/observability_onboarding/test/scout/api/tests/onboarding_flow_update_progress_404.spec.ts b/x-pack/solutions/observability/plugins/observability_onboarding/test/scout/api/tests/onboarding_flow_update_progress_404.spec.ts new file mode 100644 index 0000000000000..8a5453c00fded --- /dev/null +++ b/x-pack/solutions/observability/plugins/observability_onboarding/test/scout/api/tests/onboarding_flow_update_progress_404.spec.ts @@ -0,0 +1,41 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import { expect } from '@kbn/scout-oblt/api'; +import { tags } from '@kbn/scout-oblt'; +import { ONBOARDING_COMMON_HEADERS } from '../fixtures/constants'; +import { apiTest } from '../fixtures'; + +apiTest.describe( + 'Observability onboarding POST flow step — missing session', + { tag: [...tags.stateful.classic, ...tags.serverless.observability.complete] }, + () => { + apiTest('returns 404 when onboardingId does not exist', async ({ apiClient, samlAuth }) => { + const { cookieHeader } = await samlAuth.asInteractiveUser('admin'); + const adminHeaders = { + ...ONBOARDING_COMMON_HEADERS, + ...cookieHeader, + }; + const response = await apiClient.post( + 'internal/observability_onboarding/flow/test-onboarding-id/step/ea-download', + { + headers: { + ...adminHeaders, + }, + responseType: 'json', + body: { + status: 'complete', + }, + } + ); + expect(response).toHaveStatusCode(404); + expect((response.body as { message?: string }).message).toContain( + 'onboarding session not found' + ); + }); + } +); diff --git a/x-pack/solutions/observability/plugins/observability_onboarding/test/scout/api/tests/onboarding_flow_update_progress_updates.spec.ts b/x-pack/solutions/observability/plugins/observability_onboarding/test/scout/api/tests/onboarding_flow_update_progress_updates.spec.ts new file mode 100644 index 0000000000000..c97ddb5e61329 --- /dev/null +++ b/x-pack/solutions/observability/plugins/observability_onboarding/test/scout/api/tests/onboarding_flow_update_progress_updates.spec.ts @@ -0,0 +1,127 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import { expect } from '@kbn/scout-oblt/api'; +import { tags } from '@kbn/scout-oblt'; +import { OBSERVABILITY_ONBOARDING_STATE_SAVED_OBJECT_TYPE } from '../../../../server/saved_objects/observability_onboarding_status'; +import { ONBOARDING_COMMON_HEADERS } from '../fixtures/constants'; +import { apiTest } from '../fixtures'; + +apiTest.describe( + 'Observability onboarding POST flow step — updates saved state', + { tag: [...tags.stateful.classic, ...tags.serverless.observability.complete] }, + () => { + let onboardingId = ''; + + apiTest.afterEach(async ({ kbnClient }) => { + if (onboardingId.length > 0) { + await kbnClient.savedObjects.delete({ + type: OBSERVABILITY_ONBOARDING_STATE_SAVED_OBJECT_TYPE, + id: onboardingId, + }); + onboardingId = ''; + } + }); + + apiTest( + 'updates step progress (status only, then status with decoded message)', + async ({ apiClient, kbnClient, samlAuth }) => { + const { cookieHeader } = await samlAuth.asInteractiveUser('admin'); + const adminHeaders = { + ...ONBOARDING_COMMON_HEADERS, + ...cookieHeader, + }; + + await apiTest.step('updates step status', async () => { + const createFlowResponse = await apiClient.post( + 'internal/observability_onboarding/flow', + { + headers: adminHeaders, + responseType: 'json', + } + ); + expect(createFlowResponse).toHaveStatusCode(200); + onboardingId = (createFlowResponse.body as { onboardingFlow: { id: string } }) + .onboardingFlow.id; + + const initialState = await kbnClient.savedObjects.get({ + type: OBSERVABILITY_ONBOARDING_STATE_SAVED_OBJECT_TYPE, + id: onboardingId, + }); + expect(initialState.attributes.progress).toStrictEqual({}); + + const step = { name: 'ea-download', status: 'complete' }; + const response = await apiClient.post( + `internal/observability_onboarding/flow/${onboardingId}/step/${step.name}`, + { + headers: adminHeaders, + responseType: 'json', + body: { status: step.status }, + } + ); + expect(response).toHaveStatusCode(200); + + const savedState = await kbnClient.savedObjects.get({ + type: OBSERVABILITY_ONBOARDING_STATE_SAVED_OBJECT_TYPE, + id: onboardingId, + }); + expect(savedState.attributes.progress?.[step.name]).toMatchObject({ + status: step.status, + }); + }); + + await apiTest.step('updates step status with base64 message', async () => { + const createFlowResponse = await apiClient.post( + 'internal/observability_onboarding/flow', + { + headers: adminHeaders, + responseType: 'json', + } + ); + expect(createFlowResponse).toHaveStatusCode(200); + onboardingId = (createFlowResponse.body as { onboardingFlow: { id: string } }) + .onboardingFlow.id; + + const initialState = await kbnClient.savedObjects.get({ + type: OBSERVABILITY_ONBOARDING_STATE_SAVED_OBJECT_TYPE, + id: onboardingId, + }); + expect(initialState.attributes.progress).toStrictEqual({}); + + const message = 'Download failed'; + const step = { + name: 'ea-download', + status: 'danger', + message: Buffer.from(message, 'utf8').toString('base64'), + }; + + const response = await apiClient.post( + `internal/observability_onboarding/flow/${onboardingId}/step/${step.name}`, + { + headers: adminHeaders, + responseType: 'json', + body: { + status: step.status, + message: step.message, + }, + } + ); + expect(response).toHaveStatusCode(200); + + const savedState = await kbnClient.savedObjects.get({ + type: OBSERVABILITY_ONBOARDING_STATE_SAVED_OBJECT_TYPE, + id: onboardingId, + }); + expect(savedState.attributes.progress?.[step.name]).toMatchObject({ + status: step.status, + message, + }); + }); + } + ); + } +); diff --git a/x-pack/solutions/observability/plugins/observability_onboarding/test/scout/ui/tsconfig.json b/x-pack/solutions/observability/plugins/observability_onboarding/test/scout/ui/tsconfig.json deleted file mode 100644 index a0d022ca36c12..0000000000000 --- a/x-pack/solutions/observability/plugins/observability_onboarding/test/scout/ui/tsconfig.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "extends": "@kbn/tsconfig-base/tsconfig.json", - "compilerOptions": { - "outDir": "target/types" - }, - "include": [ - "**/*" - ], - "kbn_references": [ - "@kbn/scout-oblt" - ], - "exclude": [ - "target/**/*" - ] -} diff --git a/x-pack/solutions/observability/plugins/observability_onboarding/tsconfig.json b/x-pack/solutions/observability/plugins/observability_onboarding/tsconfig.json index 50b6ea4a5feb7..56806389a18d5 100644 --- a/x-pack/solutions/observability/plugins/observability_onboarding/tsconfig.json +++ b/x-pack/solutions/observability/plugins/observability_onboarding/tsconfig.json @@ -9,7 +9,8 @@ "../../../../../typings/**/*", "public/**/*.json", "server/**/*", - "e2e/**/*" + "e2e/**/*", + "test/scout/**/*" ], "kbn_references": [ "@kbn/core", @@ -46,7 +47,10 @@ "@kbn/ebt-tools", "@kbn/apm-plugin", "@kbn/react-kibana-mount", - "@kbn/react-query" + "@kbn/react-query", + "@kbn/scout-oblt", + "@kbn/scout-synthtrace", + "@kbn/synthtrace-client" ], "exclude": [ "target/**/*" diff --git a/x-pack/solutions/observability/test/api_integration_deployment_agnostic/apis/onboarding/custom_roles/index.ts b/x-pack/solutions/observability/test/api_integration_deployment_agnostic/apis/onboarding/custom_roles/index.ts deleted file mode 100644 index 4f164be4369e1..0000000000000 --- a/x-pack/solutions/observability/test/api_integration_deployment_agnostic/apis/onboarding/custom_roles/index.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -import type { KibanaRoleDescriptors } from '@kbn/ftr-common-functional-services'; - -const noAccessUserRole: KibanaRoleDescriptors = { - elasticsearch: { - indices: [], - }, - kibana: [], -}; - -type CustomRoleNames = 'noAccessUserRole'; - -export const customRoles: Record = { - noAccessUserRole, -}; diff --git a/x-pack/solutions/observability/test/api_integration_deployment_agnostic/apis/onboarding/get_progress.ts b/x-pack/solutions/observability/test/api_integration_deployment_agnostic/apis/onboarding/get_progress.ts deleted file mode 100644 index 2d3b262421c7d..0000000000000 --- a/x-pack/solutions/observability/test/api_integration_deployment_agnostic/apis/onboarding/get_progress.ts +++ /dev/null @@ -1,185 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -import expect from '@kbn/expect'; -import { type LogsSynthtraceEsClient } from '@kbn/synthtrace'; -import { log, timerange } from '@kbn/synthtrace-client'; -import { type DeploymentAgnosticFtrProviderContext } from '../../ftr_provider_context'; -import { type RoleCredentials, type SupertestWithRoleScopeType } from '../../services'; -import { customRoles } from './custom_roles'; - -export default function ({ getService }: DeploymentAgnosticFtrProviderContext) { - const roleScopedSupertest = getService('roleScopedSupertest'); - const customRoleScopedSupertest = getService('customRoleScopedSupertest'); - const saml = getService('samlAuth'); - const synthtrace = getService('synthtrace'); - - let synthtraceLogsEsClient: LogsSynthtraceEsClient; - let adminClient: SupertestWithRoleScopeType; - - describe('Get progress', () => { - const datasetName = 'api-tests'; - const namespace = 'default'; - let onboardingId: string; - - before(async () => { - synthtraceLogsEsClient = await synthtrace.createLogsSynthtraceEsClient(); - adminClient = await roleScopedSupertest.getSupertestWithRoleScope('admin', { - withInternalHeaders: true, - useCookieHeader: true, - }); - - const createFlowResponse = await adminClient.post('/internal/observability_onboarding/flow'); - - onboardingId = createFlowResponse.body.onboardingFlow.id; - }); - - it(`fails with a 404 error when onboardingId doesn't exists`, async () => { - const response = await adminClient.get( - `/internal/observability_onboarding/flow/test-onboarding-id/progress` - ); - - expect(response.status).to.be(404); - expect(response.body.message).to.contain('onboarding session not found'); - }); - - describe('when user lacks required privileges', () => { - let noAccessClient: SupertestWithRoleScopeType; - let roleAuthc: RoleCredentials; - - before(async () => { - await saml.setCustomRole(customRoles.noAccessUserRole); - noAccessClient = await customRoleScopedSupertest.getSupertestWithCustomRoleScope({ - useCookieHeader: true, - withInternalHeaders: true, - }); - roleAuthc = await saml.createM2mApiKeyWithCustomRoleScope(); - }); - - after(async () => { - await saml.invalidateM2mApiKeyWithRoleScope(roleAuthc); - await saml.deleteCustomRole(); - }); - - it('fails with a 404 error', async () => { - const response = await noAccessClient.get( - `/internal/observability_onboarding/flow/${onboardingId}/progress` - ); - - expect(response.status).to.be(404); - expect(response.body.message).to.contain('onboarding session not found'); - }); - }); - - describe('when ea-status is complete', () => { - describe('should not skip logs verification', () => { - const agentId = 'my-agent-id'; - - before(async () => { - await adminClient - .post(`/internal/observability_onboarding/flow/${onboardingId}/step/ea-status`) - .send({ - status: 'complete', - payload: { - agentId, - }, - }); - }); - - describe('when no logs have been ingested', () => { - it('should return log-ingest as loading', async () => { - const response = await adminClient.get( - `/internal/observability_onboarding/flow/${onboardingId}/progress` - ); - - expect(response.status).to.be(200); - - const logsIngestProgress = response.body.progress['logs-ingest']; - expect(logsIngestProgress).to.have.property('status', 'loading'); - }); - }); - - describe('when logs have been ingested', () => { - describe('with a different agentId', () => { - describe('and onboarding type is logFiles', () => { - before(async () => { - await synthtraceLogsEsClient.index([ - timerange('2023-11-20T10:00:00.000Z', '2023-11-20T10:01:00.000Z') - .interval('1m') - .rate(1) - .generator((timestamp) => - log - .create() - .message('This is a log message') - .timestamp(timestamp) - .dataset(datasetName) - .namespace(namespace) - .service('my-service') - .defaults({ - 'agent.id': 'another-agent-id', - 'log.file.path': '/my-service.log', - }) - ), - ]); - }); - - it('should return log-ingest as incomplete', async () => { - const response = await adminClient.get( - `/internal/observability_onboarding/flow/${onboardingId}/progress` - ); - expect(response.status).to.be(200); - const logsIngestProgress = response.body.progress['logs-ingest']; - expect(logsIngestProgress).to.have.property('status', 'loading'); - }); - - after(async () => { - await synthtraceLogsEsClient.clean(); - }); - }); - }); - - describe('with the expected agentId', () => { - describe('and onboarding type is logFiles', () => { - before(async () => { - await synthtraceLogsEsClient.index([ - timerange('2023-11-20T10:00:00.000Z', '2023-11-20T10:01:00.000Z') - .interval('1m') - .rate(1) - .generator((timestamp) => - log - .create() - .message('This is a log message') - .timestamp(timestamp) - .dataset(datasetName) - .namespace(namespace) - .service('my-service') - .defaults({ - 'agent.id': agentId, - 'log.file.path': '/my-service.log', - }) - ), - ]); - }); - it('should return log-ingest as complete', async () => { - const response = await adminClient.get( - `/internal/observability_onboarding/flow/${onboardingId}/progress` - ); - expect(response.status).to.be(200); - const logsIngestProgress = response.body.progress['logs-ingest']; - expect(logsIngestProgress).to.have.property('status', 'complete'); - }); - - after(async () => { - await synthtraceLogsEsClient.clean(); - }); - }); - }); - }); - }); - }); - }); -} diff --git a/x-pack/solutions/observability/test/api_integration_deployment_agnostic/apis/onboarding/index.ts b/x-pack/solutions/observability/test/api_integration_deployment_agnostic/apis/onboarding/index.ts deleted file mode 100644 index d1096f51880da..0000000000000 --- a/x-pack/solutions/observability/test/api_integration_deployment_agnostic/apis/onboarding/index.ts +++ /dev/null @@ -1,15 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -import type { DeploymentAgnosticFtrProviderContext } from '../../ftr_provider_context'; - -export default function ({ loadTestFile }: DeploymentAgnosticFtrProviderContext) { - describe('Onboarding', () => { - loadTestFile(require.resolve('./get_progress')); - loadTestFile(require.resolve('./update_progress')); - }); -} diff --git a/x-pack/solutions/observability/test/api_integration_deployment_agnostic/apis/onboarding/update_progress.ts b/x-pack/solutions/observability/test/api_integration_deployment_agnostic/apis/onboarding/update_progress.ts deleted file mode 100644 index 174aa33fb9993..0000000000000 --- a/x-pack/solutions/observability/test/api_integration_deployment_agnostic/apis/onboarding/update_progress.ts +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -import expect from '@kbn/expect'; -import { OBSERVABILITY_ONBOARDING_STATE_SAVED_OBJECT_TYPE } from '@kbn/observability-onboarding-plugin/server/saved_objects/observability_onboarding_status'; -import { type DeploymentAgnosticFtrProviderContext } from '../../ftr_provider_context'; -import { type SupertestWithRoleScopeType } from '../../services'; - -export default function ({ getService }: DeploymentAgnosticFtrProviderContext) { - const kibanaServer = getService('kibanaServer'); - const roleScopedSupertest = getService('roleScopedSupertest'); - let adminClient: SupertestWithRoleScopeType; - let adminClientWithAPIKey: SupertestWithRoleScopeType; - - describe('Update step progress', () => { - before(async () => { - adminClient = await roleScopedSupertest.getSupertestWithRoleScope('admin', { - withInternalHeaders: true, - useCookieHeader: true, - }); - adminClientWithAPIKey = await roleScopedSupertest.getSupertestWithRoleScope('admin', { - withInternalHeaders: true, - }); - }); - - after(async () => { - await adminClientWithAPIKey.destroy(); - }); - - describe("when onboardingId doesn't exists", () => { - it('fails with a 404 error', async () => { - const response = await adminClient - .post(`/internal/observability_onboarding/flow/test-onboarding-id/step/ea-download`) - .send({ - status: 'complete', - }); - - expect(response.status).to.be(404); - expect(response.body.message).to.contain('onboarding session not found'); - }); - }); - - describe('when onboardingId exists', () => { - let onboardingId: string; - - beforeEach(async () => { - const createFlowResponse = await adminClient.post( - '/internal/observability_onboarding/flow' - ); - - onboardingId = createFlowResponse.body.onboardingFlow.id; - - const savedState = await kibanaServer.savedObjects.get({ - type: OBSERVABILITY_ONBOARDING_STATE_SAVED_OBJECT_TYPE, - id: onboardingId, - }); - - expect(savedState.attributes.progress).eql({}); - }); - - afterEach(async () => { - await kibanaServer.savedObjects.delete({ - type: OBSERVABILITY_ONBOARDING_STATE_SAVED_OBJECT_TYPE, - id: onboardingId, - }); - }); - - it('updates step status', async () => { - const step = { - name: 'ea-download', - status: 'complete', - }; - - const response = await adminClientWithAPIKey - .post(`/internal/observability_onboarding/flow/${onboardingId}/step/${step.name}`) - .send({ - status: step.status, - }); - - expect(response.status).to.be(200); - - const savedState = await kibanaServer.savedObjects.get({ - type: OBSERVABILITY_ONBOARDING_STATE_SAVED_OBJECT_TYPE, - id: onboardingId, - }); - - const stepProgress = savedState.attributes.progress?.[step.name]; - expect(stepProgress).to.have.property('status', step.status); - }); - - it('updates step status with message', async () => { - const message = 'Download failed'; - const step = { - name: 'ea-download', - status: 'danger', - message: Buffer.from(message, 'utf8').toString('base64'), - }; - const response = await adminClientWithAPIKey - .post(`/internal/observability_onboarding/flow/${onboardingId}/step/${step.name}`) - .send({ - status: step.status, - message: step.message, - }); - - expect(response.status).to.be(200); - - const savedState = await kibanaServer.savedObjects.get({ - type: OBSERVABILITY_ONBOARDING_STATE_SAVED_OBJECT_TYPE, - id: onboardingId, - }); - - const stepProgress = savedState.attributes.progress?.[step.name]; - expect(stepProgress).to.have.property('status', step.status); - expect(stepProgress).to.have.property('message', message); - }); - }); - }); -} diff --git a/x-pack/solutions/observability/test/api_integration_deployment_agnostic/configs/serverless/oblt.index.ts b/x-pack/solutions/observability/test/api_integration_deployment_agnostic/configs/serverless/oblt.index.ts index 5b4108362bca7..447398b3f4d9a 100644 --- a/x-pack/solutions/observability/test/api_integration_deployment_agnostic/configs/serverless/oblt.index.ts +++ b/x-pack/solutions/observability/test/api_integration_deployment_agnostic/configs/serverless/oblt.index.ts @@ -17,7 +17,6 @@ export default function ({ loadTestFile }: DeploymentAgnosticFtrProviderContext) loadTestFile(require.resolve('../../apis/alerting')); loadTestFile(require.resolve('../../apis/dataset_quality')); loadTestFile(require.resolve('../../apis/slo')); - loadTestFile(require.resolve('../../apis/onboarding')); loadTestFile(require.resolve('../../apis/incident_management')); }); } diff --git a/x-pack/solutions/observability/test/api_integration_deployment_agnostic/configs/stateful/oblt.index.ts b/x-pack/solutions/observability/test/api_integration_deployment_agnostic/configs/stateful/oblt.index.ts index c695014643630..40f90b2e0cf92 100644 --- a/x-pack/solutions/observability/test/api_integration_deployment_agnostic/configs/stateful/oblt.index.ts +++ b/x-pack/solutions/observability/test/api_integration_deployment_agnostic/configs/stateful/oblt.index.ts @@ -15,7 +15,6 @@ export default function ({ loadTestFile }: DeploymentAgnosticFtrProviderContext) loadTestFile(require.resolve('../../apis/slo')); loadTestFile(require.resolve('../../apis/synthetics')); loadTestFile(require.resolve('../../apis/infra')); - loadTestFile(require.resolve('../../apis/onboarding')); loadTestFile(require.resolve('../../apis/incident_management')); }); } diff --git a/x-pack/solutions/observability/test/moon.yml b/x-pack/solutions/observability/test/moon.yml index fbe01eba6d0ab..0fb404eb8f6f9 100644 --- a/x-pack/solutions/observability/test/moon.yml +++ b/x-pack/solutions/observability/test/moon.yml @@ -68,7 +68,6 @@ dependsOn: - '@kbn/rison' - '@kbn/dataset-quality-plugin' - '@kbn/metrics-data-access-plugin' - - '@kbn/observability-onboarding-plugin' - '@kbn/slo-plugin' - '@kbn/slo-schema' - '@kbn/cases-plugin' diff --git a/x-pack/solutions/observability/test/tsconfig.json b/x-pack/solutions/observability/test/tsconfig.json index e21e90db9401f..41396a19edaf9 100644 --- a/x-pack/solutions/observability/test/tsconfig.json +++ b/x-pack/solutions/observability/test/tsconfig.json @@ -75,7 +75,6 @@ "@kbn/rison", "@kbn/dataset-quality-plugin", "@kbn/metrics-data-access-plugin", - "@kbn/observability-onboarding-plugin", "@kbn/slo-plugin", "@kbn/slo-schema", "@kbn/cases-plugin",