Skip to content

Commit

Permalink
use observabilityAIAssistantAPIClient for status
Browse files Browse the repository at this point in the history
  • Loading branch information
neptunian committed Jul 30, 2024
1 parent 5364e4f commit 01d9821
Showing 1 changed file with 25 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,50 +10,47 @@ import { FtrProviderContext } from '../../common/ftr_provider_context';
import { createKnowledgeBaseModel, deleteKnowledgeBaseModel, TINY_ELSER } from './helpers';

export default function ApiTest({ getService }: FtrProviderContext) {
const supertest = getService('supertest');
const ml = getService('ml');
const KNOWLEDGE_BASE_API_URL = `/internal/observability_ai_assistant/kb`;
const observabilityAIAssistantAPIClient = getService('observabilityAIAssistantAPIClient');

describe(`${KNOWLEDGE_BASE_API_URL}/status`, () => {
describe('/internal/observability_ai_assistant/kb/status', () => {
before(async () => {
await createKnowledgeBaseModel(ml);

await supertest
.post(`${KNOWLEDGE_BASE_API_URL}/setup`)
.set('kbn-xsrf', 'foo')
.expect(200)
.then((response) => {
expect(response.body).to.eql({});
});
await observabilityAIAssistantAPIClient
.editorUser({
endpoint: 'POST /internal/observability_ai_assistant/kb/setup',
})
.expect(200);
});

after(async () => {
await deleteKnowledgeBaseModel(ml);
});

it('returns correct status after knowledge base is setup', async () => {
return await supertest
.get(`${KNOWLEDGE_BASE_API_URL}/status`)
.set('kbn-xsrf', 'foo')
.expect(200)
.then((response) => {
expect(response.body.deployment_state).to.eql('started');
expect(response.body.model_name).to.eql('pt_tiny_elser');
});
const res = await observabilityAIAssistantAPIClient
.editorUser({
endpoint: 'GET /internal/observability_ai_assistant/kb/status',
})
.expect(200);
expect(res.body.deployment_state).to.eql('started');
expect(res.body.model_name).to.eql(TINY_ELSER.id);
});

it('returns correct status after elser is stopped', async () => {
await ml.api.stopTrainedModelDeploymentES(TINY_ELSER.id, true);
return await supertest
.get(`${KNOWLEDGE_BASE_API_URL}/status`)
.set('kbn-xsrf', 'foo')
.expect(200)
.then((response) => {
expect(response.body).to.eql({
ready: false,
model_name: TINY_ELSER.id,
});
});

const res = await observabilityAIAssistantAPIClient
.editorUser({
endpoint: 'GET /internal/observability_ai_assistant/kb/status',
})
.expect(200);

expect(res.body).to.eql({
ready: false,
model_name: TINY_ELSER.id,
});
});
});
}

0 comments on commit 01d9821

Please sign in to comment.