Observability AI Assistant Tests Deployment Agnostic#205194
Conversation
|
Pinging @elastic/obs-ai-assistant (Team:Obs AI Assistant) |
🤖 GitHub commentsExpand to view the GitHub comments
Just comment with:
|
There was a problem hiding this comment.
nit: I suggest not using variables here. It's harder to read and search for. Also, I'm not sure the typescript intellisense for parameters and typed responses works when using variables
| endpoint: `GET ${CONNECTOR_API_URL}`, | |
| endpoint: `GET /internal/observability_ai_assistant/connectors`, |
There was a problem hiding this comment.
If you really want to make it DRY I suggest adding a helper and re-use that instead:
const getConnectors = () =>
observabilityAIAssistantAPIClient.editor({
endpoint: `GET /internal/observability_ai_assistant/connectors`,
});There was a problem hiding this comment.
Agree. Now that I’m moving many of these tests, I won’t use a variable and will ensure they follow a consistent pattern since we currently have a mix.
There was a problem hiding this comment.
Should we have a shared helper for creating the proxy action connector? It's already defined at least 3 times:
There was a problem hiding this comment.
I will keep only one, I will get rid of the duplicate functions.
There was a problem hiding this comment.
Feels good getting rid of the serverless-specific client. Is the plan to get rid of x-pack/test_serverless/api_integration/test_suites/observability/ai_assistant/common/observability_ai_assistant_api_client.ts entirely?
There was a problem hiding this comment.
We can remove it entirely if we get all the tests running in deployment agnostic, unless there is some case where we want a serverless only test because of some serverless only feature. Probably wouldn't hurt to leave it.
...tion/deployment_agnostic/apis/observability/ai_assistant/conversations/conversations.spec.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
This whole file should be safe to move over to deployment agnostic and not exist in stateful tests. I'm assuming you decided not to move it was because of the security roles and access privileges test suite which doesn't exist in serverless, but it soon will: #205210
There was a problem hiding this comment.
Exactly. I only moved the common tests between stateful and serverless. I’ll move the security roles and access privaleges to deployment-agnostic and remove it from stateful and serverless.
There was a problem hiding this comment.
.github/CODEOWNERS
Outdated
There was a problem hiding this comment.
Thanks for pointing that out, @sorenlouv. I checked, and the file is now valid in this branch as well. It might have been a temporary issue or something resolved during recent changes(I did a rebase recently).
sorenlouv
left a comment
There was a problem hiding this comment.
Just one comment about CODEOWNERS file
c1c4339 to
1dc1987
Compare
...tion/deployment_agnostic/apis/observability/ai_assistant/conversations/conversations.spec.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Can't we simply use the existing viewer? Also, what do you expect to happen if unauthorizedUser is used to call an endpoint that viewer is allowed to access?
There was a problem hiding this comment.
Hey @arturoliduena
You might not be able to use the viewer role for unauthorizedUser in this manner for DA tests. It was done for serverless this way, because we force the user to be unauthorized by not passing the cookie header.
However, since the cookie is always included in makeInternalApiRequest, this user will be a viewer with authorization.
There was a problem hiding this comment.
Hey @sorenlouv and @viduni94,
We can simulate an unauthorized user by omitting credentials entirely with a function like makeInternalApiRequestWithoutCredentials:
function makeInternalApiRequest(role: string) {
return async <TEndpoint extends InternalEndpoint<APIEndpoint>>(
options: Options<TEndpoint>
): Promise<SupertestReturnType<TEndpoint>> => {
const headers: Record<string, string> = {
...samlAuth.getInternalRequestHeader(),
...(await samlAuth.getM2MApiCookieCredentialsWithRoleScope(role)),
};
return makeApiRequest({
options,
headers,
});
};
}
function makeInternalApiRequestWithoutCredentials() {
return async <TEndpoint extends InternalEndpoint<APIEndpoint>>(
options: Options<TEndpoint>
): Promise<SupertestReturnType<TEndpoint>> => {
const headers: Record<string, string> = {
...samlAuth.getInternalRequestHeader(),
};
return makeApiRequest({
options,
headers,
});
};
}However, the problem with this approach is that omitting credentials will result in a 401 Unauthorized response instead of a 403 Forbidden. This doesn’t align with the intention of the test, which is to verify whether a user with insufficient permissions can access specific endpoints (DELETE, POST, PUT).
To properly simulate this, the user needs to be authenticated (avoiding 401 Unauthorized) but lack the necessary permissions, resulting in a 403 Forbidden. This is why I think it makes sense to use the viewer role here.
I agree with Søren that adding an additional unauthorizedUser role like this:
unauthorizedUser: observabilityAIAssistantApiClient.makeInternalApiRequest('viewer')is unnecessary. Instead, we can simply use the existing viewer role:
viewer: observabilityAIAssistantApiClient.makeInternalApiRequest('viewer')This keeps the implementation clean and ensures that we’re testing for insufficient permissions correctly. Let me know if you agree
There was a problem hiding this comment.
If I read that correctly, you'll authenticate as the viewer user. That sounds good to me.
There was a problem hiding this comment.
What I meant is not to have a user without credentials, but to have a user with a role that has insufficient privileges to access the AI Assistant APIs.
If the viewer role fits that criteria, I'm good with this.
There was a problem hiding this comment.
It just seems odd to have a user called unauthorizedUser. Because even with just the viewer role there are APIs they are authorised to access.
There was a problem hiding this comment.
fyi: @dgieselaar is extracting the API client in https://github.com/elastic/kibana/pull/204309/files#diff-cb59199a241f60514e9ba52c57b587929f6be6bcedb24c5a138d5ba72184fe85.
I don't think this is a blocker but eventually we should use that implementation so we don't have multiple. Afaict we now have three API clients:
- https://github.com/elastic/kibana/blob/main/x-pack/test/observability_ai_assistant_api_integration/common/observability_ai_assistant_api_client.ts
- https://github.com/elastic/kibana/blob/main/x-pack/test_serverless/api_integration/test_suites/observability/ai_assistant/common/observability_ai_assistant_api_client.ts
There was a problem hiding this comment.
We can be replace skipMKI with failsOnMKI if we want to be more descriptive that we aren't wanting to skip but that its failing so we have to skip.
…s test suite (#205631) Closes #205537 ## Summary The knowledge base migration test suite is missing in serverless. This PR adds it to the serverless test suite. - This has a dependancy to #205194 since we are removing all serverless tests and adding them to DA tests. - If the DA tests PR gets merged first, I'll refactor this PR to add it there. ### Checklist - [ ] [Flaky Test Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was used on any tests changed - [x] The PR description includes the appropriate Release Notes section, and the correct `release_note:*` label is applied per the [guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)
…s test suite (elastic#205631) Closes elastic#205537 ## Summary The knowledge base migration test suite is missing in serverless. This PR adds it to the serverless test suite. - This has a dependancy to elastic#205194 since we are removing all serverless tests and adding them to DA tests. - If the DA tests PR gets merged first, I'll refactor this PR to add it there. ### Checklist - [ ] [Flaky Test Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was used on any tests changed - [x] The PR description includes the appropriate Release Notes section, and the correct `release_note:*` label is applied per the [guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process) (cherry picked from commit e32ff8e)
|
@neptunian, @sorenlouv and @viduni94 Migrated to Deployment-Agnostic:
Pending:
Issue with
|
@arturoliduena Thanks for bringing that question up. From what I've read here, my understanding is we should use the deployment agnostic |
… due to failures, not because skipping is intended behavior
…ses for conversation interception
…lity/ai_assistant/knowledge_base/knowledge_base_migration.spec.ts Co-authored-by: Viduni Wickramarachchi <viduni.ushanka@gmail.com>
4c57434 to
d2028d2
Compare
💛 Build succeeded, but was flaky
Failed CI StepsTest Failures
Metrics [docs]
History
|
|
Starting backport for target branches: 8.x https://github.com/elastic/kibana/actions/runs/12755763835 |
|
Starting backport for target branches: 8.x https://github.com/elastic/kibana/actions/runs/12755763869 |
💔 All backports failed
Manual backportTo create the backport manually run: Questions ?Please refer to the Backport tool documentation |
1 similar comment
💔 All backports failed
Manual backportTo create the backport manually run: Questions ?Please refer to the Backport tool documentation |
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
…206516) # Backport This will backport the following commits from `main` to `8.x`: - [Observability AI Assistant Tests Deployment Agnostic (#205194)](#205194) <!--- Backport version: 8.9.8 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Arturo Lidueña","email":"arturo.liduena@elastic.co"},"sourceCommit":{"committedDate":"2025-01-13T15:03:51Z","message":"Observability AI Assistant Tests Deployment Agnostic (#205194)\n\nCloses #192718\r\n\r\n## Summary\r\n\r\nThis PR add a deployment-agnostic testing environment for Observability\r\nAI Assistant tests by unifying the duplicated tests for stateful and\r\nserverless environments. It create the ObservabilityAIAssistantApiClient\r\nto work seamlessly in both environments, enabling a single test to run\r\nacross stateful, CI, and MKI.\r\n\r\nInitial efforts focus on deduplicating the `conversations.spec.ts` and\r\n`connectors.spec.ts` files, as these already run in all environments.\r\n\r\nMove / dedup the tests that exist in stateful and serverless. They run\r\nin serverless CI but not MKI and add the skipMki tag.\r\n`chat.spec.ts`\r\n`complete.spec.ts`\r\n`elasticsearch.spec.ts`\r\n`public_complete.spec.ts`\r\n`alerts.spec.ts`\r\n`knowledge_base_setup.spec.ts` \r\n`knowledge_base_status.spec.ts` \r\n`knowledge_base.spec.ts` \r\n`summarize.ts` \r\n`knowledge_base_user_instructions.spec.ts`","sha":"ee6c5bde34b984e14889eb136cfa1a9baa9991c0","branchLabelMapping":{"^v9.0.0$":"main","^v8.18.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","v9.0.0","Team:Obs AI Assistant","ci:project-deploy-observability","backport:version","v8.18.0"],"number":205194,"url":"https://github.com/elastic/kibana/pull/205194","mergeCommit":{"message":"Observability AI Assistant Tests Deployment Agnostic (#205194)\n\nCloses #192718\r\n\r\n## Summary\r\n\r\nThis PR add a deployment-agnostic testing environment for Observability\r\nAI Assistant tests by unifying the duplicated tests for stateful and\r\nserverless environments. It create the ObservabilityAIAssistantApiClient\r\nto work seamlessly in both environments, enabling a single test to run\r\nacross stateful, CI, and MKI.\r\n\r\nInitial efforts focus on deduplicating the `conversations.spec.ts` and\r\n`connectors.spec.ts` files, as these already run in all environments.\r\n\r\nMove / dedup the tests that exist in stateful and serverless. They run\r\nin serverless CI but not MKI and add the skipMki tag.\r\n`chat.spec.ts`\r\n`complete.spec.ts`\r\n`elasticsearch.spec.ts`\r\n`public_complete.spec.ts`\r\n`alerts.spec.ts`\r\n`knowledge_base_setup.spec.ts` \r\n`knowledge_base_status.spec.ts` \r\n`knowledge_base.spec.ts` \r\n`summarize.ts` \r\n`knowledge_base_user_instructions.spec.ts`","sha":"ee6c5bde34b984e14889eb136cfa1a9baa9991c0"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","labelRegex":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/205194","number":205194,"mergeCommit":{"message":"Observability AI Assistant Tests Deployment Agnostic (#205194)\n\nCloses #192718\r\n\r\n## Summary\r\n\r\nThis PR add a deployment-agnostic testing environment for Observability\r\nAI Assistant tests by unifying the duplicated tests for stateful and\r\nserverless environments. It create the ObservabilityAIAssistantApiClient\r\nto work seamlessly in both environments, enabling a single test to run\r\nacross stateful, CI, and MKI.\r\n\r\nInitial efforts focus on deduplicating the `conversations.spec.ts` and\r\n`connectors.spec.ts` files, as these already run in all environments.\r\n\r\nMove / dedup the tests that exist in stateful and serverless. They run\r\nin serverless CI but not MKI and add the skipMki tag.\r\n`chat.spec.ts`\r\n`complete.spec.ts`\r\n`elasticsearch.spec.ts`\r\n`public_complete.spec.ts`\r\n`alerts.spec.ts`\r\n`knowledge_base_setup.spec.ts` \r\n`knowledge_base_status.spec.ts` \r\n`knowledge_base.spec.ts` \r\n`summarize.ts` \r\n`knowledge_base_user_instructions.spec.ts`","sha":"ee6c5bde34b984e14889eb136cfa1a9baa9991c0"}},{"branch":"8.x","label":"v8.18.0","labelRegex":"^v8.18.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
…s test suite (elastic#205631) Closes elastic#205537 ## Summary The knowledge base migration test suite is missing in serverless. This PR adds it to the serverless test suite. - This has a dependancy to elastic#205194 since we are removing all serverless tests and adding them to DA tests. - If the DA tests PR gets merged first, I'll refactor this PR to add it there. ### Checklist - [ ] [Flaky Test Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was used on any tests changed - [x] The PR description includes the appropriate Release Notes section, and the correct `release_note:*` label is applied per the [guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)
Closes elastic#192718 ## Summary This PR add a deployment-agnostic testing environment for Observability AI Assistant tests by unifying the duplicated tests for stateful and serverless environments. It create the ObservabilityAIAssistantApiClient to work seamlessly in both environments, enabling a single test to run across stateful, CI, and MKI. Initial efforts focus on deduplicating the `conversations.spec.ts` and `connectors.spec.ts` files, as these already run in all environments. Move / dedup the tests that exist in stateful and serverless. They run in serverless CI but not MKI and add the skipMki tag. `chat.spec.ts` `complete.spec.ts` `elasticsearch.spec.ts` `public_complete.spec.ts` `alerts.spec.ts` `knowledge_base_setup.spec.ts` `knowledge_base_status.spec.ts` `knowledge_base.spec.ts` `summarize.ts` `knowledge_base_user_instructions.spec.ts`


Closes #192718
Summary
This PR add a deployment-agnostic testing environment for Observability AI Assistant tests by unifying the duplicated tests for stateful and serverless environments. It create the ObservabilityAIAssistantApiClient to work seamlessly in both environments, enabling a single test to run across stateful, CI, and MKI.
Initial efforts focus on deduplicating the
conversations.spec.tsandconnectors.spec.tsfiles, as these already run in all environments.Move / dedup the tests that exist in stateful and serverless. They run in serverless CI but not MKI and add the skipMki tag.
chat.spec.tscomplete.spec.tselasticsearch.spec.tspublic_complete.spec.tsalerts.spec.tsknowledge_base_setup.spec.tsknowledge_base_status.spec.tsknowledge_base.spec.tssummarize.tsknowledge_base_user_instructions.spec.tsChecklist
Check the PR satisfies following conditions.
Reviewers should verify this PR satisfies this list as well.
release_note:breakinglabel should be applied in these situations.release_note:*label is applied per the guidelines