mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
Currently, if the Cloud plugin is disabled the server will fail to start Fixes #31612 Signed-off-by: Tyler Smalley <tyler.smalley@elastic.co>
This commit is contained in:
parent
aa7427414f
commit
44be79f323
3 changed files with 46 additions and 13 deletions
|
@ -16,26 +16,58 @@ import { registerClusterCheckupRoutes } from './cluster_checkup';
|
|||
const MigrationApis = require('../lib/es_migration_apis');
|
||||
MigrationApis.getUpgradeAssistantStatus = jest.fn();
|
||||
|
||||
function register(plugins = {}) {
|
||||
const server = new Server();
|
||||
server.plugins = {
|
||||
elasticsearch: {
|
||||
getCluster: () => ({ callWithRequest: jest.fn() } as any),
|
||||
} as any,
|
||||
...plugins,
|
||||
} as any;
|
||||
server.config = () => ({ get: () => '' } as any);
|
||||
|
||||
registerClusterCheckupRoutes(server);
|
||||
|
||||
return server;
|
||||
}
|
||||
|
||||
/**
|
||||
* Since these route callbacks are so thin, these serve simply as integration tests
|
||||
* to ensure they're wired up to the lib functions correctly. Business logic is tested
|
||||
* more thoroughly in the es_migration_apis test.
|
||||
*/
|
||||
describe('cluster checkup API', () => {
|
||||
const server = new Server();
|
||||
server.plugins = {
|
||||
elasticsearch: {
|
||||
getCluster: () => ({ callWithRequest: jest.fn() } as any),
|
||||
} as any,
|
||||
cloud: {
|
||||
config: { isCloudEnabled: false },
|
||||
},
|
||||
} as any;
|
||||
server.config = () => ({ get: () => '' } as any);
|
||||
const spy = jest.spyOn(MigrationApis, 'getUpgradeAssistantStatus');
|
||||
|
||||
registerClusterCheckupRoutes(server);
|
||||
afterEach(() => jest.clearAllMocks());
|
||||
|
||||
describe('with cloud enabled', () => {
|
||||
it('is provided to getUpgradeAssistantStatus', async () => {
|
||||
const server = register({
|
||||
cloud: {
|
||||
config: {
|
||||
isCloudEnabled: true,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
MigrationApis.getUpgradeAssistantStatus.mockResolvedValue({
|
||||
cluster: [],
|
||||
indices: [],
|
||||
nodes: [],
|
||||
});
|
||||
await server.inject({
|
||||
method: 'GET',
|
||||
url: '/api/upgrade_assistant/status',
|
||||
});
|
||||
|
||||
expect(spy.mock.calls[0][2]).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('GET /api/upgrade_assistant/reindex/{indexName}.json', () => {
|
||||
const server = register();
|
||||
|
||||
it('returns state', async () => {
|
||||
MigrationApis.getUpgradeAssistantStatus.mockResolvedValue({
|
||||
cluster: [],
|
||||
|
|
|
@ -6,13 +6,14 @@
|
|||
|
||||
import Boom from 'boom';
|
||||
import { Legacy } from 'kibana';
|
||||
import _ from 'lodash';
|
||||
|
||||
import { getUpgradeAssistantStatus } from '../lib/es_migration_apis';
|
||||
import { EsVersionPrecheck } from '../lib/es_version_precheck';
|
||||
|
||||
export function registerClusterCheckupRoutes(server: Legacy.Server) {
|
||||
const { callWithRequest } = server.plugins.elasticsearch.getCluster('admin');
|
||||
const { isCloudEnabled } = server.plugins.cloud.config;
|
||||
const isCloudEnabled = _.get(server.plugins, 'cloud.config.isCloudEnabled', false);
|
||||
|
||||
server.route({
|
||||
path: '/api/upgrade_assistant/status',
|
||||
|
|
2
x-pack/typings/hapi.d.ts
vendored
2
x-pack/typings/hapi.d.ts
vendored
|
@ -11,7 +11,7 @@ import { XPackMainPlugin } from 'x-pack/plugins/xpack_main/xpack_main';
|
|||
|
||||
declare module 'hapi' {
|
||||
interface PluginProperties {
|
||||
cloud: CloudPlugin;
|
||||
cloud?: CloudPlugin;
|
||||
xpack_main: XPackMainPlugin;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue