mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
[test-es-cluster] remove random cluster name (#58762)
* [test-es-cluster] remove random cluster name * make cluster names unique in parallel test groups * specify default customEsArgs * share ci parallel prefix logic to avoid use of wrong env var * remove - postfix from tag, add docs with explaination * fix file name * ci parallel process prefix doesn't need to be exported so don't Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
This commit is contained in:
parent
5cdb0153dc
commit
992e223700
4 changed files with 50 additions and 21 deletions
30
packages/kbn-test/src/ci_parallel_process_prefix.ts
Normal file
30
packages/kbn-test/src/ci_parallel_process_prefix.ts
Normal file
|
@ -0,0 +1,30 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
const job = process.env.JOB ? `job-${process.env.JOB}-` : '';
|
||||
const num = process.env.CI_PARALLEL_PROCESS_NUMBER
|
||||
? `worker-${process.env.CI_PARALLEL_PROCESS_NUMBER}-`
|
||||
: '';
|
||||
|
||||
/**
|
||||
* A prefix string that is unique for each parallel CI process that
|
||||
* is an empty string outside of CI, so it can be safely injected
|
||||
* into strings as a prefix
|
||||
*/
|
||||
export const CI_PARALLEL_PROCESS_PREFIX = `${job}${num}`;
|
|
@ -42,10 +42,11 @@ export async function runElasticsearch({ config, options }) {
|
|||
esFrom: esFrom || config.get('esTestCluster.from'),
|
||||
dataArchive: config.get('esTestCluster.dataArchive'),
|
||||
esArgs,
|
||||
esEnvVars,
|
||||
ssl,
|
||||
});
|
||||
|
||||
await cluster.start(esArgs, esEnvVars);
|
||||
await cluster.start();
|
||||
|
||||
if (isSecurityEnabled) {
|
||||
await setupUsers({
|
||||
|
|
|
@ -18,17 +18,13 @@
|
|||
*/
|
||||
|
||||
import { resolve } from 'path';
|
||||
|
||||
const job = process.env.JOB ? `job-${process.env.JOB}-` : '';
|
||||
const num = process.env.CI_PARALLEL_PROCESS_NUMBER
|
||||
? `worker-${process.env.CI_PARALLEL_PROCESS_NUMBER}-`
|
||||
: '';
|
||||
import { CI_PARALLEL_PROCESS_PREFIX } from './ci_parallel_process_prefix';
|
||||
|
||||
export function makeJunitReportPath(rootDirectory: string, reportName: string) {
|
||||
return resolve(
|
||||
rootDirectory,
|
||||
'target/junit',
|
||||
process.env.JOB || '.',
|
||||
`TEST-${job}${num}${reportName}.xml`
|
||||
`TEST-${CI_PARALLEL_PROCESS_PREFIX}${reportName}.xml`
|
||||
);
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ import { format } from 'url';
|
|||
import { get } from 'lodash';
|
||||
import toPath from 'lodash/internal/toPath';
|
||||
import { Cluster } from '@kbn/es';
|
||||
import { CI_PARALLEL_PROCESS_PREFIX } from '../ci_parallel_process_prefix';
|
||||
import { esTestConfig } from './es_test_config';
|
||||
|
||||
import { KIBANA_ROOT } from '../';
|
||||
|
@ -38,14 +39,22 @@ export function createLegacyEsTestCluster(options = {}) {
|
|||
basePath = resolve(KIBANA_ROOT, '.es'),
|
||||
esFrom = esTestConfig.getBuildFrom(),
|
||||
dataArchive,
|
||||
esArgs,
|
||||
esArgs: customEsArgs = [],
|
||||
esEnvVars,
|
||||
clusterName: customClusterName = 'es-test-cluster',
|
||||
ssl,
|
||||
} = options;
|
||||
|
||||
const randomHash = Math.random()
|
||||
.toString(36)
|
||||
.substring(2);
|
||||
const clusterName = `test-${randomHash}`;
|
||||
const clusterName = `${CI_PARALLEL_PROCESS_PREFIX}${customClusterName}`;
|
||||
|
||||
const esArgs = [
|
||||
`cluster.name=${clusterName}`,
|
||||
`http.port=${port}`,
|
||||
'discovery.type=single-node',
|
||||
`transport.port=${esTestConfig.getTransportPort()}`,
|
||||
...customEsArgs,
|
||||
];
|
||||
|
||||
const config = {
|
||||
version: esTestConfig.getVersion(),
|
||||
installPath: resolve(basePath, clusterName),
|
||||
|
@ -55,7 +64,6 @@ export function createLegacyEsTestCluster(options = {}) {
|
|||
basePath,
|
||||
esArgs,
|
||||
};
|
||||
const transportPort = esTestConfig.getTransportPort();
|
||||
|
||||
const cluster = new Cluster({ log, ssl });
|
||||
|
||||
|
@ -67,7 +75,7 @@ export function createLegacyEsTestCluster(options = {}) {
|
|||
return esFrom === 'snapshot' ? 3 * minute : 6 * minute;
|
||||
}
|
||||
|
||||
async start(esArgs = [], esEnvVars) {
|
||||
async start() {
|
||||
let installPath;
|
||||
|
||||
if (esFrom === 'source') {
|
||||
|
@ -86,13 +94,7 @@ export function createLegacyEsTestCluster(options = {}) {
|
|||
|
||||
await cluster.start(installPath, {
|
||||
password: config.password,
|
||||
esArgs: [
|
||||
`cluster.name=${clusterName}`,
|
||||
`http.port=${port}`,
|
||||
'discovery.type=single-node',
|
||||
`transport.port=${transportPort}`,
|
||||
...esArgs,
|
||||
],
|
||||
esArgs,
|
||||
esEnvVars,
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue