import { SavedObjectsClientContract , IUiSettingsClient } from 'src/core/server' ; import { createTestServers , TestOpenSearchUtils , TestOpenSearchDashboardsUtils , TestUtils , } from '../../../../test_helpers/osd_server' ; import { LegacyAPICaller } from '../../../opensearch/' ; import { httpServerMock } from '../../../http/http_server.mocks' ; let servers ; let opensearchServer ; let osd ; let osdServer ; interface AllServices { osdServer : TestOpenSearchDashboardsUtils [ 'osdServer' ] ; savedObjectsClient : SavedObjectsClientContract ; callCluster : LegacyAPICaller ; uiSettings : IUiSettingsClient ; } let services ; export async function startServers ( ) { servers = createTestServers ( { adjustTimeout : ( t ) => jest . setTimeout ( t ) , settings : { osd : { uiSettings : { overrides : { foo : 'bar' , } , } , } , } , } ) ; opensearchServer = await servers . startOpenSearch ( ) ; osd = await servers . startOpenSearchDashboards ( ) ; osdServer = osd . osdServer ; } export function getServices ( ) { if ( services ) { return services ; } const callCluster = opensearchServer . opensearch . getCallCluster ( ) ; const savedObjectsClient = osd . coreStart . savedObjects . getScopedClient ( httpServerMock . createOpenSearchDashboardsRequest ( ) ) ; const uiSettings = osdServer . newPlatform . start . core . uiSettings . asScopedToClient ( savedObjectsClient ) ; services = { osdServer , callCluster , savedObjectsClient , uiSettings , } ; return services ; } export async function stopServers ( ) { services = null ! ; osdServer = null ! ; if ( servers ) { await opensearchServer . stop ( ) ; await osd . stop ( ) ; } }