kibana/x-pack/test/saved_object_api_integration/common/config.ts
Spencer f466ebf1a3
[esArchiver] drop support for --dir, use repo-relative paths instead (#101345)
Co-authored-by: spalger <spalger@users.noreply.github.com>
2021-06-08 17:37:42 -04:00

62 lines
1.9 KiB
TypeScript

/*
* 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; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
import path from 'path';
import { REPO_ROOT } from '@kbn/utils';
import { FtrConfigProviderContext } from '@kbn/test';
import { services } from './services';
interface CreateTestConfigOptions {
license: string;
disabledPlugins?: string[];
}
export function createTestConfig(name: string, options: CreateTestConfigOptions) {
const { license = 'trial', disabledPlugins = [] } = options;
return async ({ readConfigFile }: FtrConfigProviderContext) => {
const config = {
kibana: {
api: await readConfigFile(path.resolve(REPO_ROOT, 'test/api_integration/config.js')),
functional: await readConfigFile(require.resolve('../../../../test/functional/config.js')),
},
xpack: {
api: await readConfigFile(require.resolve('../../api_integration/config.ts')),
},
};
return {
testFiles: [require.resolve(`../${name}/apis/`)],
servers: config.xpack.api.get('servers'),
services,
junit: {
reportName: 'X-Pack Saved Object API Integration Tests -- ' + name,
},
esTestCluster: {
...config.xpack.api.get('esTestCluster'),
license,
serverArgs: [
`xpack.license.self_generated.type=${license}`,
`xpack.security.enabled=${!disabledPlugins.includes('security')}`,
],
},
kbnTestServer: {
...config.xpack.api.get('kbnTestServer'),
serverArgs: [
...config.xpack.api.get('kbnTestServer.serverArgs'),
'--server.xsrf.disableProtection=true',
`--plugin-path=${path.join(__dirname, 'fixtures', 'saved_object_test_plugin')}`,
...disabledPlugins.map((key) => `--xpack.${key}.enabled=false`),
],
},
};
};
}