Skip to content

Commit

Permalink
unskip and update for serverless
Browse files Browse the repository at this point in the history
  • Loading branch information
neptunian committed Dec 18, 2024
1 parent 0b74f62 commit 510b00a
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 510b00a

Please sign in to comment.