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

[7.17] Accept connecting to ES 8.x #122627

Merged
merged 8 commits into from
Jan 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion packages/kbn-test/src/es/test_es_cluster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ export type EsTestCluster<Options extends CreateTestEsClusterOptions = CreateTes
export interface CreateTestEsClusterOptions {
basePath?: string;
clusterName?: string;
/**
* The ES version to start
*/
version?: string;
/**
* Path to data archive snapshot to run Elasticsearch with.
* To prepare the the snapshot:
Expand Down Expand Up @@ -150,6 +154,7 @@ export function createTestEsCluster<
log,
basePath = Path.resolve(KIBANA_ROOT, '.es'),
esFrom = esTestConfig.getBuildFrom(),
version = esTestConfig.getVersion(),
dataArchive,
nodes = [{ name: 'node-01' }],
esArgs: customEsArgs = [],
Expand All @@ -173,7 +178,7 @@ export function createTestEsCluster<
const esArgs = assignArgs(defaultEsArgs, customEsArgs);

const config = {
version: esTestConfig.getVersion(),
version,
installPath: Path.resolve(basePath, clusterName),
sourcePath: Path.resolve(KIBANA_ROOT, '../elasticsearch'),
password,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

import {
createTestServers,
TestElasticsearchUtils,
TestKibanaUtils,
} from '../../../test_helpers/kbn_server';

describe('esVersionCompatibleWithKibana', () => {
let esServer: TestElasticsearchUtils;
let kibanaServer: TestKibanaUtils;

afterEach(async () => {
if (kibanaServer) {
await kibanaServer.stop();
}
if (esServer) {
await esServer.stop();
}
});

const start = async ({ esArgs = [], version }: { esArgs?: string[]; version?: string } = {}) => {
const { startES, startKibana } = createTestServers({
adjustTimeout: jest.setTimeout,
settings: {
es: {
version,
esArgs,
},
},
});

esServer = await startES();
return { startKibana };
};

it('successfully starts Kibana 7.17.x against Elasticsearch 8.0.0', async () => {
const { startKibana } = await start({ version: '8.0.0' });
const startWithCleanup = async () => {
kibanaServer = await startKibana();
return kibanaServer;
};
await expect(startWithCleanup()).resolves.toBeDefined();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,11 @@ describe('mapNodesVersionCompatibility', () => {
});

it('returns isCompatible=false for an incompatible node without http publish address', async () => {
const nodesInfo = createNodesInfoWithoutHTTP('6.1.1');
const nodesInfo = createNodesInfoWithoutHTTP('7.1.1');
const result = mapNodesVersionCompatibility(nodesInfo, KIBANA_VERSION, false);
expect(result.isCompatible).toBe(false);
expect(result.message).toMatchInlineSnapshot(
`"This version of Kibana (v5.1.0) is incompatible with the following Elasticsearch nodes in your cluster: v6.1.1 @ undefined (ip)"`
`"This version of Kibana (v5.1.0) is incompatible with the following Elasticsearch nodes in your cluster: v7.1.1 @ undefined (ip)"`
);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,38 +8,42 @@

import { esVersionCompatibleWithKibana } from './es_kibana_version_compatability';

describe('plugins/elasticsearch', () => {
describe('lib/is_es_compatible_with_kibana', () => {
describe('returns false', () => {
it('when ES major is greater than Kibana major', () => {
expect(esVersionCompatibleWithKibana('1.0.0', '0.0.0')).toBe(false);
});

it('when ES major is less than Kibana major', () => {
expect(esVersionCompatibleWithKibana('0.0.0', '1.0.0')).toBe(false);
});

it('when majors are equal, but ES minor is less than Kibana minor', () => {
expect(esVersionCompatibleWithKibana('1.0.0', '1.1.0')).toBe(false);
});
});

describe('returns true', () => {
it('when version numbers are the same', () => {
expect(esVersionCompatibleWithKibana('1.1.1', '1.1.1')).toBe(true);
});

it('when majors are equal, and ES minor is greater than Kibana minor', () => {
expect(esVersionCompatibleWithKibana('1.1.0', '1.0.0')).toBe(true);
});

it('when majors and minors are equal, and ES patch is greater than Kibana patch', () => {
expect(esVersionCompatibleWithKibana('1.1.1', '1.1.0')).toBe(true);
});

it('when majors and minors are equal, but ES patch is less than Kibana patch', () => {
expect(esVersionCompatibleWithKibana('1.1.0', '1.1.1')).toBe(true);
});
describe('esVersionCompatibleWithKibana', () => {
describe('returns false', () => {
it('when ES major is greater than Kibana major + 1', () => {
expect(esVersionCompatibleWithKibana('2.0.0', '0.0.0')).toBe(false);
});

it('when ES major is less than Kibana major', () => {
expect(esVersionCompatibleWithKibana('0.0.0', '1.0.0')).toBe(false);
});

it('when majors are equal, but ES minor is less than Kibana minor', () => {
expect(esVersionCompatibleWithKibana('1.0.0', '1.1.0')).toBe(false);
});
});

describe('returns true', () => {
it('when version numbers are the same', () => {
expect(esVersionCompatibleWithKibana('1.1.1', '1.1.1')).toBe(true);
});

it('when majors are equal, and ES minor is greater than Kibana minor', () => {
expect(esVersionCompatibleWithKibana('1.1.0', '1.0.0')).toBe(true);
});

it('when majors and minors are equal, and ES patch is greater than Kibana patch', () => {
expect(esVersionCompatibleWithKibana('1.1.1', '1.1.0')).toBe(true);
});

it('when majors and minors are equal, but ES patch is less than Kibana patch', () => {
expect(esVersionCompatibleWithKibana('1.1.0', '1.1.1')).toBe(true);
});

it('when ES major is Kibana major + 1', () => {
expect(esVersionCompatibleWithKibana('1.0.0', '0.0.0')).toBe(true);
expect(esVersionCompatibleWithKibana('1.0.0', '0.7.0')).toBe(true);
expect(esVersionCompatibleWithKibana('1.9.2', '0.7.12')).toBe(true);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ export function esVersionCompatibleWithKibana(esVersion: string, kibanaVersion:
patch: semver.patch(kibanaVersion),
};

// On 7.17: Accept the next major version of ES.
if (esVersionNumbers.major === kibanaVersionNumbers.major + 1) {
return true;
}

// Reject mismatching major version numbers.
if (esVersionNumbers.major !== kibanaVersionNumbers.major) {
return false;
Expand Down