mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
Resolves errors preventing ES snapshot promotion (#123649)
This commit is contained in:
parent
6f3a148376
commit
a80acbb871
18 changed files with 42 additions and 19 deletions
|
@ -98,12 +98,3 @@ fi
|
|||
|
||||
export BUILD_TS_REFS_DISABLE=true
|
||||
export DISABLE_BOOTSTRAP_VALIDATION=true
|
||||
|
||||
export TEST_KIBANA_HOST=localhost
|
||||
export TEST_KIBANA_PORT=6101
|
||||
export TEST_KIBANA_URL="http://elastic:changeme@localhost:6101"
|
||||
export TEST_ES_URL="http://elastic:changeme@localhost:6102"
|
||||
export TEST_ES_TRANSPORT_PORT=6301-6309
|
||||
export TEST_CORS_SERVER_PORT=6106
|
||||
export ALERTING_PROXY_PORT=6105
|
||||
export TEST_PROXY_SERVER_PORT=6107
|
||||
|
|
|
@ -69,6 +69,16 @@ const { ES_KEY_PATH, ES_CERT_PATH } = require('@kbn/dev-utils');
|
|||
});
|
||||
}
|
||||
|
||||
if (url.pathname === '/_cluster/health') {
|
||||
return send(
|
||||
200,
|
||||
{
|
||||
status: 'green',
|
||||
},
|
||||
{ 'x-elastic-product': 'Elasticsearch' }
|
||||
);
|
||||
}
|
||||
|
||||
return send(404, {
|
||||
error: {
|
||||
reason: 'not found',
|
||||
|
|
|
@ -53,7 +53,18 @@ exports.NativeRealm = class NativeRealm {
|
|||
});
|
||||
}
|
||||
|
||||
async clusterReady() {
|
||||
return await this._autoRetry({ maxAttempts: 10 }, async () => {
|
||||
const { status } = await this._client.cluster.health();
|
||||
if (status === 'red') {
|
||||
throw new Error(`not ready, cluster health is ${status}`);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
async setPasswords(options) {
|
||||
await this.clusterReady();
|
||||
|
||||
if (!(await this.isSecurityEnabled())) {
|
||||
this._log.info('security is not enabled, unable to set native realm passwords');
|
||||
return;
|
||||
|
@ -97,7 +108,7 @@ exports.NativeRealm = class NativeRealm {
|
|||
}
|
||||
|
||||
async _autoRetry(opts, fn) {
|
||||
const { attempt = 1, maxAttempts = 3 } = opts;
|
||||
const { attempt = 1, maxAttempts = 3, sleep = 1000 } = opts;
|
||||
|
||||
try {
|
||||
return await fn(attempt);
|
||||
|
@ -108,7 +119,7 @@ exports.NativeRealm = class NativeRealm {
|
|||
|
||||
const sec = 1.5 * attempt;
|
||||
this._log.warning(`assuming ES isn't initialized completely, trying again in ${sec} seconds`);
|
||||
await new Promise((resolve) => setTimeout(resolve, sec * 1000));
|
||||
await new Promise((resolve) => setTimeout(resolve, sleep));
|
||||
|
||||
const nextOpts = {
|
||||
...opts,
|
||||
|
|
|
@ -18,6 +18,9 @@ const mockClient = {
|
|||
xpack: {
|
||||
info: jest.fn(),
|
||||
},
|
||||
cluster: {
|
||||
health: jest.fn(),
|
||||
},
|
||||
security: {
|
||||
changePassword: jest.fn(),
|
||||
getUser: jest.fn(),
|
||||
|
@ -49,6 +52,12 @@ function mockXPackInfo(available, enabled) {
|
|||
}));
|
||||
}
|
||||
|
||||
function mockClusterStatus(status) {
|
||||
mockClient.cluster.health.mockImplementation(() => {
|
||||
return status;
|
||||
});
|
||||
}
|
||||
|
||||
describe('isSecurityEnabled', () => {
|
||||
test('returns true if enabled and available', async () => {
|
||||
mockXPackInfo(true, true);
|
||||
|
@ -95,6 +104,7 @@ describe('isSecurityEnabled', () => {
|
|||
describe('setPasswords', () => {
|
||||
it('uses provided passwords', async () => {
|
||||
mockXPackInfo(true, true);
|
||||
mockClusterStatus('green');
|
||||
|
||||
mockClient.security.getUser.mockImplementation(() => ({
|
||||
kibana_system: {
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
import { kibanaPackageJson as pkg } from '@kbn/utils';
|
||||
import Url from 'url';
|
||||
import { adminTestUser } from '../kbn';
|
||||
import { systemIndicesSuperuser } from '../kbn';
|
||||
|
||||
class EsTestConfig {
|
||||
getVersion() {
|
||||
|
@ -51,8 +51,8 @@ class EsTestConfig {
|
|||
};
|
||||
}
|
||||
|
||||
const username = process.env.TEST_ES_USERNAME || adminTestUser.username;
|
||||
const password = process.env.TEST_ES_PASSWORD || adminTestUser.password;
|
||||
const username = process.env.TEST_ES_USERNAME || systemIndicesSuperuser.username;
|
||||
const password = process.env.TEST_ES_PASSWORD || systemIndicesSuperuser.password;
|
||||
|
||||
const port = process.env.TEST_ES_PORT ? parseInt(process.env.TEST_ES_PORT, 10) : 9220;
|
||||
|
||||
|
|
|
@ -48,7 +48,10 @@ const { startES } = kbnTestServer.createTestServers({
|
|||
settings: {
|
||||
es: {
|
||||
license: 'basic',
|
||||
dataArchive: Path.join(__dirname, './archives', '7.7.2_xpack_100k_obj.zip'),
|
||||
dataArchive: Path.resolve(
|
||||
__dirname,
|
||||
'../../integration_tests/archives/7.7.2_xpack_100k_obj.zip'
|
||||
),
|
||||
esArgs: ['http.max_content_length=10Kb'],
|
||||
},
|
||||
},
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -51,8 +51,7 @@ async function fetchDocuments(esClient: ElasticsearchClient, index: string) {
|
|||
|
||||
const assertMigratedDocuments = (arr: any[], target: any[]) => target.every((v) => arr.includes(v));
|
||||
|
||||
// dataArchive not compatible with ES 8.0+
|
||||
describe.skip('migration v2', () => {
|
||||
describe('migration v2', () => {
|
||||
let esServer: kbnTestServer.TestElasticsearchUtils;
|
||||
let root: Root;
|
||||
let startES: () => Promise<kbnTestServer.TestElasticsearchUtils>;
|
||||
|
|
|
@ -20,8 +20,7 @@ async function removeLogFile() {
|
|||
await fs.unlink(logFilePath).catch(() => void 0);
|
||||
}
|
||||
|
||||
// dataArchive not compatible with ES 8.0+
|
||||
describe.skip('migration v2', () => {
|
||||
describe('migration v2', () => {
|
||||
let esServer: kbnTestServer.TestElasticsearchUtils;
|
||||
let root: Root;
|
||||
let startES: () => Promise<kbnTestServer.TestElasticsearchUtils>;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue