Skip to content
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
9 changes: 0 additions & 9 deletions .buildkite/scripts/common/env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,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
10 changes: 10 additions & 0 deletions packages/kbn-es/src/integration_tests/__fixtures__/es_bin.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
15 changes: 13 additions & 2 deletions packages/kbn-es/src/utils/native_realm.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -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,
Expand Down
10 changes: 10 additions & 0 deletions packages/kbn-es/src/utils/native_realm.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ const mockClient = {
xpack: {
info: jest.fn(),
},
cluster: {
health: jest.fn(),
},
security: {
changePassword: jest.fn(),
getUser: jest.fn(),
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -95,6 +104,7 @@ describe('isSecurityEnabled', () => {
describe('setPasswords', () => {
it('uses provided passwords', async () => {
mockXPackInfo(true, true);
mockClusterStatus('green');

mockClient.security.getUser.mockImplementation(() => ({
kibana_system: {
Expand Down
6 changes: 3 additions & 3 deletions packages/kbn-test/src/es/es_test_config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
},
},
Expand Down
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.
Original file line number Diff line number Diff line change
Expand Up @@ -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>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ describe('migration v2 with corrupt saved object documents', () => {
await new Promise((resolve) => setTimeout(resolve, 10000));
});

it('collects corrupt saved object documents across batches', async () => {
it.skip('collects corrupt saved object documents across batches', async () => {
const { startES } = kbnTestServer.createTestServers({
adjustTimeout: (t: number) => jest.setTimeout(t),
settings: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ describe('migration v2', () => {
await new Promise((resolve) => setTimeout(resolve, 10000));
});

it('migrates the documents to the highest version', async () => {
it.skip('migrates the documents to the highest version', async () => {
const migratedIndex = `.kibana_${pkg.version}_001`;
const { startES } = kbnTestServer.createTestServers({
adjustTimeout: (t: number) => jest.setTimeout(t),
Expand Down