Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use default elser deployment for product documentation #204760

Merged
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,4 @@ export {
isSupportedConnector,
type InferenceConnector,
} from './src/connectors';
export { defaultInferenceEndpoints } from './src/inference_endpoints';
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
* 2.0.
*/

export { waitUntilModelDeployed } from './wait_until_model_deployed';
export { getModelInstallStatus } from './get_model_install_status';
export { installElser } from './install_elser';
/**
* Constants for all default (preconfigured) inference endpoints.
*/
export const defaultInferenceEndpoints = {
ELSER: '.elser-2-elasticsearch',
MULTILINGUAL_E5_SMALL: '.multilingual-e5-small-elasticsearch',
};
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
* 2.0.
*/

import { defaultInferenceEndpoints } from '@kbn/inference-common';

export const productDocInstallStatusSavedObjectTypeName = 'product-doc-install-status';

/**
* The id of the inference endpoint we're creating for our product doc indices.
* Could be replaced with the default elser 2 endpoint once the default endpoint feature is available.
*/
export const internalElserInferenceId = 'kibana-internal-elser2';
export const internalElserInferenceId = defaultInferenceEndpoints.ELSER;
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import {
} from './types';
import { productDocInstallStatusSavedObjectType } from './saved_objects';
import { PackageInstaller } from './services/package_installer';
import { InferenceEndpointManager } from './services/inference_endpoint';
import { ProductDocInstallClient } from './services/doc_install_status';
import { DocumentationManager } from './services/doc_manager';
import { SearchService } from './services/search';
Expand Down Expand Up @@ -79,15 +78,9 @@ export class ProductDocBasePlugin
);
const productDocClient = new ProductDocInstallClient({ soClient });

const endpointManager = new InferenceEndpointManager({
esClient: core.elasticsearch.client.asInternalUser,
logger: this.logger.get('endpoint-manager'),
});

const packageInstaller = new PackageInstaller({
esClient: core.elasticsearch.client.asInternalUser,
productDocClient,
endpointManager,
kibanaVersion: this.context.env.packageInfo.version,
artifactsFolder: Path.join(getDataPath(), 'ai-kb-artifacts'),
artifactRepositoryUrl: this.context.config.get().artifactRepositoryUrl,
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ jest.doMock('./steps', () => {
export const downloadToDiskMock = jest.fn();
export const openZipArchiveMock = jest.fn();
export const loadMappingFileMock = jest.fn();
export const ensureDefaultElserDeployedMock = jest.fn();

jest.doMock('./utils', () => {
const actual = jest.requireActual('./utils');
Expand All @@ -32,5 +33,6 @@ jest.doMock('./utils', () => {
downloadToDisk: downloadToDiskMock,
openZipArchive: openZipArchiveMock,
loadMappingFile: loadMappingFileMock,
ensureDefaultElserDeployed: ensureDefaultElserDeployedMock,
};
});
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
openZipArchiveMock,
validateArtifactArchiveMock,
fetchArtifactVersionsMock,
ensureDefaultElserDeployedMock,
} from './package_installer.test.mocks';

import {
Expand All @@ -24,7 +25,6 @@ import {
import { elasticsearchServiceMock } from '@kbn/core/server/mocks';
import { loggerMock, type MockedLogger } from '@kbn/logging-mocks';
import { installClientMock } from '../doc_install_status/service.mock';
import { inferenceManagerMock } from '../inference_endpoint/service.mock';
import type { ProductInstallState } from '../../../common/install_status';
import { PackageInstaller } from './package_installer';

Expand All @@ -40,21 +40,18 @@ describe('PackageInstaller', () => {
let logger: MockedLogger;
let esClient: ReturnType<typeof elasticsearchServiceMock.createElasticsearchClient>;
let productDocClient: ReturnType<typeof installClientMock.create>;
let endpointManager: ReturnType<typeof inferenceManagerMock.create>;

let packageInstaller: PackageInstaller;

beforeEach(() => {
logger = loggerMock.create();
esClient = elasticsearchServiceMock.createElasticsearchClient();
productDocClient = installClientMock.create();
endpointManager = inferenceManagerMock.create();
packageInstaller = new PackageInstaller({
artifactsFolder,
logger,
esClient,
productDocClient,
endpointManager,
artifactRepositoryUrl,
kibanaVersion,
});
Expand All @@ -68,6 +65,7 @@ describe('PackageInstaller', () => {
openZipArchiveMock.mockReset();
validateArtifactArchiveMock.mockReset();
fetchArtifactVersionsMock.mockReset();
ensureDefaultElserDeployedMock.mockReset();
});

describe('installPackage', () => {
Expand All @@ -87,7 +85,7 @@ describe('PackageInstaller', () => {
productVersion: '8.16',
});
const indexName = getProductDocIndexName('kibana');
expect(endpointManager.ensureInternalElserInstalled).toHaveBeenCalledTimes(1);
expect(ensureDefaultElserDeployedMock).toHaveBeenCalledTimes(1);

expect(downloadToDiskMock).toHaveBeenCalledTimes(1);
expect(downloadToDiskMock).toHaveBeenCalledWith(
Expand Down Expand Up @@ -128,9 +126,7 @@ describe('PackageInstaller', () => {
it('executes the steps in the right order', async () => {
await packageInstaller.installPackage({ productName: 'kibana', productVersion: '8.16' });

expect(callOrder(endpointManager.ensureInternalElserInstalled)).toBeLessThan(
callOrder(downloadToDiskMock)
);
expect(callOrder(ensureDefaultElserDeployedMock)).toBeLessThan(callOrder(downloadToDiskMock));
expect(callOrder(downloadToDiskMock)).toBeLessThan(callOrder(openZipArchiveMock));
expect(callOrder(openZipArchiveMock)).toBeLessThan(callOrder(loadMappingFileMock));
expect(callOrder(loadMappingFileMock)).toBeLessThan(callOrder(createIndexMock));
Expand Down
Loading
Loading