Skip to content

Commit

Permalink
[Obs AI Assistant] unskip and update summarize.spec.ts for serverless (
Browse files Browse the repository at this point in the history
…#204790)

Closes #192497

- Unskips summarize.spec.ts. It was originally skipped because
tiny_elser was not available on CI.
- Adds `this.tags(['skipMKI']` due to
#192751

Related: #199134
  • Loading branch information
neptunian authored Dec 18, 2024
1 parent 9b09335 commit 4af2706
Showing 1 changed file with 39 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ import {
LlmProxy,
createLlmProxy,
} from '@kbn/test-suites-xpack/observability_ai_assistant_api_integration/common/create_llm_proxy';
import {
clearKnowledgeBase,
createKnowledgeBaseModel,
deleteInferenceEndpoint,
deleteKnowledgeBaseModel,
TINY_ELSER,
} from '@kbn/test-suites-xpack/observability_ai_assistant_api_integration/tests/knowledge_base/helpers';
import { FtrProviderContext } from '../../../common/ftr_provider_context';
import { invokeChatCompleteWithFunctionRequest } from './helpers';
import {
Expand All @@ -22,12 +29,15 @@ import type { InternalRequestHeader, RoleCredentials } from '../../../../../../.
export default function ApiTest({ getService }: FtrProviderContext) {
const supertest = getService('supertest');
const log = getService('log');
const ml = getService('ml');
const es = getService('es');
const observabilityAIAssistantAPIClient = getService('observabilityAIAssistantAPIClient');
const svlUserManager = getService('svlUserManager');
const svlCommonApi = getService('svlCommonApi');

// Skipped until Elser is available in tests
describe.skip('when calling summarize function', () => {
describe('when calling summarize function', function () {
// TODO: https://github.com/elastic/kibana/issues/192751
this.tags(['skipMKI']);
let roleAuthc: RoleCredentials;
let internalReqHeader: InternalRequestHeader;
let proxy: LlmProxy;
Expand All @@ -36,6 +46,19 @@ export default function ApiTest({ getService }: FtrProviderContext) {
before(async () => {
roleAuthc = await svlUserManager.createM2mApiKeyWithRoleScope('editor');
internalReqHeader = svlCommonApi.getInternalRequestHeader();

await createKnowledgeBaseModel(ml);
await observabilityAIAssistantAPIClient
.slsAdmin({
endpoint: 'POST /internal/observability_ai_assistant/kb/setup',
params: {
query: {
model_id: TINY_ELSER.id,
},
},
})
.expect(200);

proxy = await createLlmProxy(log);
connectorId = await createProxyActionConnector({
supertest,
Expand All @@ -57,10 +80,10 @@ export default function ApiTest({ getService }: FtrProviderContext) {
name: 'summarize',
trigger: MessageRole.User,
arguments: JSON.stringify({
id: 'my-id',
title: 'My Title',
text: 'Hello world',
is_correction: false,
confidence: 1,
confidence: 'high',
public: false,
}),
},
Expand All @@ -72,6 +95,9 @@ export default function ApiTest({ getService }: FtrProviderContext) {
after(async () => {
proxy.close();
await deleteActionConnector({ supertest, connectorId, log, roleAuthc, internalReqHeader });
await deleteKnowledgeBaseModel(ml);
await clearKnowledgeBase(es);
await deleteInferenceEndpoint({ es });
});

it('persists entry in knowledge base', async () => {
Expand All @@ -80,12 +106,20 @@ export default function ApiTest({ getService }: FtrProviderContext) {
params: {
query: {
query: '',
sortBy: 'doc_id',
sortBy: 'title',
sortDirection: 'asc',
},
},
});

const { role, public: isPublic, text, type, user, title } = res.body.entries[0];

expect(role).to.eql('assistant_summarization');
expect(isPublic).to.eql(false);
expect(text).to.eql('Hello world');
expect(type).to.eql('contextual');
expect(user?.name).to.eql('elastic_editor'); // "editor" in stateful
expect(title).to.eql('My Title');
expect(res.body.entries).to.have.length(1);
});
});
Expand Down

0 comments on commit 4af2706

Please sign in to comment.