-
Notifications
You must be signed in to change notification settings - Fork 8.5k
[scout] Migrate onboarding deployment-agnostic API tests #259436
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
dmlemeshko
merged 21 commits into
elastic:main
from
dmlemeshko:migrate-onboarding-da-api-tests
Mar 28, 2026
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
7f30ca8
initial migration
dmlemeshko 89c171c
fix tests
dmlemeshko 0fb360f
fix tags
dmlemeshko bd380f7
update migration SKILL
dmlemeshko 0c07b8b
update migration SKILL about saml auth
dmlemeshko fc9ff9e
Changes from node scripts/lint_ts_projects --fix
kibanamachine 0683ab6
TO FIX: Run node 'scripts/yarn_deduplicate && yarn kbn bootstrap' loc…
kibanamachine 8ff237e
Changes from node scripts/regenerate_moon_projects.js --update
kibanamachine 1835445
Merge branch 'main' into migrate-onboarding-da-api-tests
dmlemeshko 9d776b8
fix tsconfig
dmlemeshko 888c51f
Changes from node scripts/lint.js --fix
kibanamachine e9942d7
Merge branch 'main' into migrate-onboarding-da-api-tests
dmlemeshko b3e59a9
merge tsconfigs to use relative imports, update SKILL
dmlemeshko 1aa3fac
TO FIX: Run node 'scripts/yarn_deduplicate && yarn kbn bootstrap' loc…
kibanamachine 28e314e
Changes from node scripts/regenerate_moon_projects.js --update
kibanamachine f3d93b6
Merge branch 'main' into migrate-onboarding-da-api-tests
dmlemeshko e33ad47
Merge branch 'main' into migrate-onboarding-da-api-tests
dmlemeshko f4953cd
chore: revert Scout SKILL doc updates (moved to follow-up PR)
dmlemeshko cce0f4d
code review fixes
dmlemeshko 342c8b4
Merge remote-tracking branch 'upstream/main' into migrate-onboarding-…
dmlemeshko 5908511
Merge branch 'main' into migrate-onboarding-da-api-tests
dmlemeshko File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
...tions/observability/plugins/observability_onboarding/test/scout/api/fixtures/constants.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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; |
11 changes: 11 additions & 0 deletions
11
...solutions/observability/plugins/observability_onboarding/test/scout/api/fixtures/index.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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); |
12 changes: 12 additions & 0 deletions
12
...utions/observability/plugins/observability_onboarding/test/scout/api/playwright.config.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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', | ||
| }); |
194 changes: 194 additions & 0 deletions
194
...ty/plugins/observability_onboarding/test/scout/api/tests/onboarding_flow_progress.spec.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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<string, string>; | ||
| 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<string, { status: string }> }) | ||
| .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<string, { status: string }> }) | ||
| .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<string, { status: string }> }) | ||
| .progress; | ||
| expect(progress['logs-ingest']).toMatchObject({ status: 'complete' }); | ||
|
|
||
| await logsSynthtraceEsClient.clean(); | ||
| }); | ||
| } | ||
| ); | ||
| } | ||
| ); |
41 changes: 41 additions & 0 deletions
41
...observability_onboarding/test/scout/api/tests/onboarding_flow_update_progress_404.spec.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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' | ||
| ); | ||
| }); | ||
| } | ||
| ); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.