diff --git a/x-pack/test_serverless/api_integration/test_suites/observability/ai_assistant/tests/knowledge_base/knowledge_base.spec.ts b/x-pack/test_serverless/api_integration/test_suites/observability/ai_assistant/tests/knowledge_base/knowledge_base.spec.ts index 20ccce8203ce5..08b4a986d815b 100644 --- a/x-pack/test_serverless/api_integration/test_suites/observability/ai_assistant/tests/knowledge_base/knowledge_base.spec.ts +++ b/x-pack/test_serverless/api_integration/test_suites/observability/ai_assistant/tests/knowledge_base/knowledge_base.spec.ts @@ -21,10 +21,7 @@ export default function ApiTest({ getService }: FtrProviderContext) { const es = getService('es'); const observabilityAIAssistantAPIClient = getService('observabilityAIAssistantAPIClient'); - describe('Knowledge base', function () { - // Fails on MKI: https://github.com/elastic/kibana/issues/205581 - this.tags(['failsOnMKI']); - + describe('Knowledge base', () => { before(async () => { await createKnowledgeBaseModel(ml); diff --git a/x-pack/test_serverless/api_integration/test_suites/observability/ai_assistant/tests/knowledge_base/knowledge_base_setup.spec.ts b/x-pack/test_serverless/api_integration/test_suites/observability/ai_assistant/tests/knowledge_base/knowledge_base_setup.spec.ts index f55bee931fc1f..0ba8f655c8ad1 100644 --- a/x-pack/test_serverless/api_integration/test_suites/observability/ai_assistant/tests/knowledge_base/knowledge_base_setup.spec.ts +++ b/x-pack/test_serverless/api_integration/test_suites/observability/ai_assistant/tests/knowledge_base/knowledge_base_setup.spec.ts @@ -22,13 +22,8 @@ export default function ApiTest({ getService }: FtrProviderContext) { const es = getService('es'); const observabilityAIAssistantAPIClient = getService('observabilityAIAssistantAPIClient'); - describe('/internal/observability_ai_assistant/kb/setup', function () { - before(async () => { - await deleteKnowledgeBaseModel(ml).catch(() => {}); - await deleteInferenceEndpoint({ es }).catch(() => {}); - }); - - it('returns empty object when successful', async () => { + describe('/internal/observability_ai_assistant/kb/setup', () => { + it('returns model info when successful', async () => { await createKnowledgeBaseModel(ml); const res = await observabilityAIAssistantAPIClient .slsAdmin({ @@ -48,7 +43,7 @@ export default function ApiTest({ getService }: FtrProviderContext) { await deleteInferenceEndpoint({ es }); }); - it('returns bad request if model cannot be installed', async () => { + it('returns error message if model is not deployed', async () => { const res = await observabilityAIAssistantAPIClient .slsAdmin({ endpoint: `POST ${KNOWLEDGE_BASE_SETUP_API_URL}`, @@ -64,6 +59,9 @@ export default function ApiTest({ getService }: FtrProviderContext) { expect(res.body.message).to.include.string( 'No known trained model with model_id [pt_tiny_elser]' ); + + // @ts-expect-error + expect(res.body.statusCode).to.be(500); }); describe('security roles and access privileges', () => { diff --git a/x-pack/test_serverless/api_integration/test_suites/observability/ai_assistant/tests/knowledge_base/knowledge_base_status.spec.ts b/x-pack/test_serverless/api_integration/test_suites/observability/ai_assistant/tests/knowledge_base/knowledge_base_status.spec.ts index 11c039a40411b..8d05930a56365 100644 --- a/x-pack/test_serverless/api_integration/test_suites/observability/ai_assistant/tests/knowledge_base/knowledge_base_status.spec.ts +++ b/x-pack/test_serverless/api_integration/test_suites/observability/ai_assistant/tests/knowledge_base/knowledge_base_status.spec.ts @@ -12,9 +12,7 @@ import { TINY_ELSER, deleteKnowledgeBaseModel, } from '@kbn/test-suites-xpack/observability_ai_assistant_api_integration/tests/knowledge_base/helpers'; -import { AI_ASSISTANT_KB_INFERENCE_ID } from '@kbn/observability-ai-assistant-plugin/server/service/inference_endpoint'; import { FtrProviderContext } from '../../common/ftr_provider_context'; -import { KNOWLEDGE_BASE_SETUP_API_URL } from './knowledge_base_setup.spec'; const KNOWLEDGE_BASE_STATUS_API_URL = '/internal/observability_ai_assistant/kb/status'; @@ -23,15 +21,12 @@ export default function ApiTest({ getService }: FtrProviderContext) { const es = getService('es'); const observabilityAIAssistantAPIClient = getService('observabilityAIAssistantAPIClient'); - describe('/internal/observability_ai_assistant/kb/status', function () { - // Fails on MKI: https://github.com/elastic/kibana/issues/205677 - this.tags(['failsOnMKI']); - - before(async () => { + describe('/internal/observability_ai_assistant/kb/status', () => { + beforeEach(async () => { await createKnowledgeBaseModel(ml); await observabilityAIAssistantAPIClient .slsAdmin({ - endpoint: `POST ${KNOWLEDGE_BASE_SETUP_API_URL}`, + endpoint: 'POST /internal/observability_ai_assistant/kb/setup', params: { query: { model_id: TINY_ELSER.id, @@ -41,25 +36,39 @@ export default function ApiTest({ getService }: FtrProviderContext) { .expect(200); }); - after(async () => { - await deleteKnowledgeBaseModel(ml); - await deleteInferenceEndpoint({ es, name: AI_ASSISTANT_KB_INFERENCE_ID }).catch((err) => {}); + afterEach(async () => { + await deleteKnowledgeBaseModel(ml).catch((e) => {}); + await deleteInferenceEndpoint({ es }).catch((e) => {}); }); it('returns correct status after knowledge base is setup', async () => { + const res = await observabilityAIAssistantAPIClient + .slsEditor({ endpoint: `GET ${KNOWLEDGE_BASE_STATUS_API_URL}` }) + .expect(200); + + expect(res.body.ready).to.be(true); + expect(res.body.enabled).to.be(true); + expect(res.body.endpoint?.service_settings?.model_id).to.eql(TINY_ELSER.id); + }); + + it('returns correct status after model is deleted', async () => { + await deleteKnowledgeBaseModel(ml); + const res = await observabilityAIAssistantAPIClient .slsEditor({ endpoint: `GET ${KNOWLEDGE_BASE_STATUS_API_URL}`, }) .expect(200); + expect(res.body.ready).to.be(false); expect(res.body.enabled).to.be(true); - expect(res.body.ready).to.be(true); - expect(res.body.endpoint?.service_settings?.model_id).to.eql(TINY_ELSER.id); + expect(res.body.errorMessage).to.include.string( + 'No known trained model with model_id [pt_tiny_elser]' + ); }); - it('returns correct status after elser is stopped', async () => { - await deleteInferenceEndpoint({ es, name: AI_ASSISTANT_KB_INFERENCE_ID }); + it('returns correct status after inference endpoint is deleted', async () => { + await deleteInferenceEndpoint({ es }); const res = await observabilityAIAssistantAPIClient .slsEditor({ @@ -67,8 +76,11 @@ export default function ApiTest({ getService }: FtrProviderContext) { }) .expect(200); - expect(res.body.enabled).to.be(true); expect(res.body.ready).to.be(false); + expect(res.body.enabled).to.be(true); + expect(res.body.errorMessage).to.include.string( + 'Inference endpoint not found [obs_ai_assistant_kb_inference]' + ); }); describe('security roles and access privileges', () => {