From 6cb40499c74bfe6a3e8f8c258201609c279ea715 Mon Sep 17 00:00:00 2001 From: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Date: Sat, 11 Jan 2025 05:18:16 +1100 Subject: [PATCH] [8.x] [Obs AI Assistant] Unskip user instructions test (#205656) (#205897) (#206082) # Backport This will backport the following commits from `main` to `8.x`: - [[Obs AI Assistant] Unskip user instructions test (#205656) (#205897)](https://github.com/elastic/kibana/pull/205897) ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) we don't need title interception for\r\nthese tests\r\n\r\n### Checklist\r\n\r\n- [x] [Flaky Test\r\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was\r\nused on any tests changed\r\n- [x] The PR description includes the appropriate Release Notes section,\r\nand the correct `release_note:*` label is applied per the\r\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)","sha":"37d7a5efb760dc271a4fb26f1eeba0d66e037b07","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"],"title":"[Obs AI Assistant] Unskip user instructions test (#205656)","number":205897,"url":"https://github.com/elastic/kibana/pull/205897","mergeCommit":{"message":"[Obs AI Assistant] Unskip user instructions test (#205656) (#205897)\n\nCloses https://github.com/elastic/kibana/issues/205656\r\n\r\n## Summary\r\n\r\n### Problem\r\nThere seems to be a race condition and state contamination between tests\r\nin the KB user instructions tests.\r\n\r\n### Solution\r\n- Clear knowledge base and conversations after tests\r\n- Remove title interceptor --> we don't need title interception for\r\nthese tests\r\n\r\n### Checklist\r\n\r\n- [x] [Flaky Test\r\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was\r\nused on any tests changed\r\n- [x] The PR description includes the appropriate Release Notes section,\r\nand the correct `release_note:*` label is applied per the\r\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)","sha":"37d7a5efb760dc271a4fb26f1eeba0d66e037b07"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/205897","number":205897,"mergeCommit":{"message":"[Obs AI Assistant] Unskip user instructions test (#205656) (#205897)\n\nCloses https://github.com/elastic/kibana/issues/205656\r\n\r\n## Summary\r\n\r\n### Problem\r\nThere seems to be a race condition and state contamination between tests\r\nin the KB user instructions tests.\r\n\r\n### Solution\r\n- Clear knowledge base and conversations after tests\r\n- Remove title interceptor --> we don't need title interception for\r\nthese tests\r\n\r\n### Checklist\r\n\r\n- [x] [Flaky Test\r\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was\r\nused on any tests changed\r\n- [x] The PR description includes the appropriate Release Notes section,\r\nand the correct `release_note:*` label is applied per the\r\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)","sha":"37d7a5efb760dc271a4fb26f1eeba0d66e037b07"}},{"branch":"8.x","label":"v8.18.0","branchLabelMappingKey":"^v8.18.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> Co-authored-by: Viduni Wickramarachchi --- .../knowledge_base_user_instructions.spec.ts | 14 ++++++-------- .../knowledge_base_user_instructions.spec.ts | 14 ++++++-------- 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/x-pack/test/observability_ai_assistant_api_integration/tests/knowledge_base/knowledge_base_user_instructions.spec.ts b/x-pack/test/observability_ai_assistant_api_integration/tests/knowledge_base/knowledge_base_user_instructions.spec.ts index d5022a052d781..e6f7d728c6e0b 100644 --- a/x-pack/test/observability_ai_assistant_api_integration/tests/knowledge_base/knowledge_base_user_instructions.spec.ts +++ b/x-pack/test/observability_ai_assistant_api_integration/tests/knowledge_base/knowledge_base_user_instructions.spec.ts @@ -233,12 +233,9 @@ export default function ApiTest({ getService }: FtrProviderContext) { }) .expect(200); - const interceptPromises = [ - proxy.interceptConversationTitle('LLM-generated title').completeAfterIntercept(), - proxy - .interceptConversation({ name: 'conversation', response: 'I, the LLM, hear you!' }) - .completeAfterIntercept(), - ]; + const interceptPromise = proxy + .interceptConversation({ name: 'conversation', response: 'I, the LLM, hear you!' }) + .completeAfterIntercept(); const messages: Message[] = [ { @@ -283,8 +280,7 @@ export default function ApiTest({ getService }: FtrProviderContext) { }, }); - // wait for all interceptors to be settled - await Promise.all(interceptPromises); + await interceptPromise; const conversation = res.body; return conversation; @@ -297,6 +293,8 @@ export default function ApiTest({ getService }: FtrProviderContext) { after(async () => { proxy.close(); + await clearKnowledgeBase(es); + await clearConversations(es); await deleteActionConnector({ supertest, connectorId, log }); }); diff --git a/x-pack/test_serverless/api_integration/test_suites/observability/ai_assistant/tests/knowledge_base/knowledge_base_user_instructions.spec.ts b/x-pack/test_serverless/api_integration/test_suites/observability/ai_assistant/tests/knowledge_base/knowledge_base_user_instructions.spec.ts index d2b8f96060527..ddd5c6957c4e2 100644 --- a/x-pack/test_serverless/api_integration/test_suites/observability/ai_assistant/tests/knowledge_base/knowledge_base_user_instructions.spec.ts +++ b/x-pack/test_serverless/api_integration/test_suites/observability/ai_assistant/tests/knowledge_base/knowledge_base_user_instructions.spec.ts @@ -247,12 +247,9 @@ export default function ApiTest({ getService }: FtrProviderContext) { }) .expect(200); - const interceptPromises = [ - proxy.interceptConversationTitle('LLM-generated title').completeAfterIntercept(), - proxy - .interceptConversation({ name: 'conversation', response: 'I, the LLM, hear you!' }) - .completeAfterIntercept(), - ]; + const interceptPromise = proxy + .interceptConversation({ name: 'conversation', response: 'I, the LLM, hear you!' }) + .completeAfterIntercept(); const messages: Message[] = [ { @@ -297,8 +294,7 @@ export default function ApiTest({ getService }: FtrProviderContext) { }, }); - // wait for all interceptors to be settled - await Promise.all(interceptPromises); + await interceptPromise; const conversation = res.body; return conversation; @@ -317,6 +313,8 @@ export default function ApiTest({ getService }: FtrProviderContext) { after(async () => { proxy.close(); + await clearKnowledgeBase(es); + await clearConversations(es); await deleteActionConnector({ supertest: supertestWithoutAuth, connectorId,