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

[ftr] fix test users for serverless #161280

Merged
merged 8 commits into from
Jul 10, 2023
14 changes: 10 additions & 4 deletions packages/kbn-ftr-common-functional-services/services/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,15 @@ import { FtrProviderContext } from './ftr_provider_context';

export function EsProvider({ getService }: FtrProviderContext): Client {
const config = getService('config');
const isServerless = !!config.get('serverless');

return createEsClientForFtrConfig(config, {
// Use system indices user so tests can write to system indices
authOverride: systemIndicesSuperuser,
});
return createEsClientForFtrConfig(
config,
isServerless
? {}
: {
// Use system indices user so tests can write to system indices
authOverride: systemIndicesSuperuser,
}
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ export class FunctionalTestRunner {
: this.getStubProviderCollection(coreProviders);

if (realServices) {
if (providers.hasService('es')) {
// Skip ES version validation for serverless project
if (!this.config.get('serverless') && providers.hasService('es')) {
await this.validateEsVersion();
}
await providers.loadAll();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ export const schema = Joi.object()
rootTags: Joi.array().items(Joi.string()),
testFiles: Joi.array().items(Joi.string()),
testRunner: Joi.func(),
serverless: Joi.boolean().default(false),

suiteFiles: Joi.object()
.keys({
Expand Down
9 changes: 5 additions & 4 deletions test/common/services/security/system_indices_user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,12 @@ export async function createSystemIndicesUser(ctx: FtrProviderContext) {
const log = ctx.getService('log');
const config = ctx.getService('config');

const enabled = !config
.get('esTestCluster.serverArgs')
.some((arg: string) => arg === 'xpack.security.enabled=false');
const enabled = !(config.get('esTestCluster.serverArgs') || []).some(
(arg: string) => arg === 'xpack.security.enabled=false'
);
const isServerless = !!config.get('serverless');

if (!enabled) {
if (!enabled || isServerless) {
return;
}

Expand Down
7 changes: 3 additions & 4 deletions test/common/services/security/test_user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,9 @@ export async function createTestUserService(ctx: FtrProviderContext, role: Role,
const config = ctx.getService('config');

const enabled =
!config
.get('esTestCluster.serverArgs')
.some((arg: string) => arg === 'xpack.security.enabled=false') &&
!config.get('security.disableTestUser');
!(config.get('esTestCluster.serverArgs') || []).some(
dmlemeshko marked this conversation as resolved.
Show resolved Hide resolved
(arg: string) => arg === 'xpack.security.enabled=false'
) && !config.get('security.disableTestUser');

if (enabled) {
log.debug('===============creating roles and users===============');
Expand Down
6 changes: 5 additions & 1 deletion x-pack/test_serverless/shared/config.base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ export default async () => {
esTestCluster: {
license: 'trial',
from: 'snapshot',
serverArgs: ['xpack.security.enabled=false'],
},

kbnTestServer: {
Expand Down Expand Up @@ -62,6 +61,11 @@ export default async () => {
],
},

security: { disableTestUser: true },

// Used by FTR to recognize serverless project and change its behavior accordingly
serverless: true,

// overriding default timeouts from packages/kbn-test/src/functional_test_runner/lib/config/schema.ts
// so we can easily adjust them for serverless where needed
timeouts: {
Expand Down