mirror of
https://github.com/elastic/kibana.git
synced 2025-06-27 10:40:07 -04:00
## Summary I had to change `waitForRender` since `page.waitForFunction` tries to run a script on page and it is not working due to CSP settings on Cloud. Instead of injecting a script, we use a classical API to find elements/attributes in the DOM. Since `PUT /internal/core/_settings` is merged in 8.11.0, journeys run on Cloud with on-fly labels update is supported starting deployments 8.11.0+. I added error message for 404 code just in case someone runs it on earlier version. `many_fields_discover` journey was update since on Cloud the data view used by scenario is not selected by default. How it works: Create a deployment with QAF and re-configure it for journey run: ``` export EC_DEPLOYMENT_NAME=my-run-8.11 qaf elastic-cloud deployments create --stack-version 8.11.0-SNAPSHOT --environment staging --region gcp-us-central1 qaf elastic-cloud deployments configure-for-performance-journeys ``` Run any journey, e.g. many_fields_discover ``` TEST_CLOUD=1 TEST_ES_URL=https://username:pswd@es_url:443 TEST_KIBANA_URL=https://username:pswd@kibana-ur_url node scripts/functional_test_runner --config x-pack/performance/journeys/many_fields_discover.ts ``` You should see a log about labels being updated: ``` Updating telemetry & APM labels: {"testJobId":"local-a3272047-6724-44d1-9a61-5c79781b06a1","testBuildId":"local-d8edbace-f441-4ba9-ac83-5909be3acf2a","journeyName":"many_fields_discover","ftrConfig":"x-pack/performance/journeys/many_fields_discover.ts"} ``` And then able to find APM logs for the journey in [Ops](https://kibana-ops-e2e-perf.kb.us-central1.gcp.cloud.es.io:9243/app/apm/services?comparisonEnabled=true&environment=ENVIRONMENT_ALL&kuery=labels.testJobId%20%3A%20%22local-d79a878c-cc7a-423b-b884-c9b6b1a8d781%22&latencyAggregationType=avg&offset=1d&rangeFrom=now-24h%2Fh&rangeTo=now&serviceGroup=&transactionType=request) cluster
120 lines
4.5 KiB
TypeScript
120 lines
4.5 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 and the Server Side Public License, v 1; you may not use this file except
|
|
* in compliance with, at your election, the Elastic License 2.0 or the Server
|
|
* Side Public License, v 1.
|
|
*/
|
|
|
|
import Path from 'path';
|
|
|
|
import { v4 as uuidV4 } from 'uuid';
|
|
import { REPO_ROOT } from '@kbn/repo-info';
|
|
import type { FtrConfigProviderContext, FtrConfigProvider } from '@kbn/test';
|
|
import { services } from '../services';
|
|
|
|
import { AnyStep } from './journey';
|
|
import { JourneyConfig } from './journey_config';
|
|
import { JOURNEY_APM_CONFIG } from './journey_apm_config';
|
|
|
|
export function makeFtrConfigProvider(
|
|
config: JourneyConfig<any>,
|
|
steps: AnyStep[]
|
|
): FtrConfigProvider {
|
|
return async ({ readConfigFile }: FtrConfigProviderContext) => {
|
|
const isServerless = !!process.env.TEST_SERVERLESS;
|
|
// Use the same serverless FTR config for all journeys
|
|
const configPath = isServerless
|
|
? 'x-pack/test_serverless/shared/config.base.ts'
|
|
: config.getFtrConfigPath();
|
|
const defaultConfigPath = config.isXpack()
|
|
? 'x-pack/test/functional/config.base.js'
|
|
: 'test/functional/config.base.js';
|
|
const ftrConfigPath = configPath ?? defaultConfigPath;
|
|
const baseConfig = (await readConfigFile(Path.resolve(REPO_ROOT, ftrConfigPath))).getAll();
|
|
|
|
const testBuildId = process.env.BUILDKITE_BUILD_ID ?? `local-${uuidV4()}`;
|
|
const testJobId = process.env.BUILDKITE_JOB_ID ?? `local-${uuidV4()}`;
|
|
const prId = process.env.GITHUB_PR_NUMBER
|
|
? Number.parseInt(process.env.GITHUB_PR_NUMBER, 10)
|
|
: undefined;
|
|
|
|
if (Number.isNaN(prId)) {
|
|
throw new Error('invalid GITHUB_PR_NUMBER environment variable');
|
|
}
|
|
|
|
// Set variable to collect performance events using EBT
|
|
const enableTelemetry = !!process.env.PERFORMANCE_ENABLE_TELEMETRY;
|
|
|
|
const telemetryLabels: Record<string, string | boolean | undefined | number> = {
|
|
branch: process.env.BUILDKITE_BRANCH,
|
|
ciBuildId: process.env.BUILDKITE_BUILD_ID,
|
|
ciBuildJobId: process.env.BUILDKITE_JOB_ID,
|
|
ciBuildNumber: Number(process.env.BUILDKITE_BUILD_NUMBER) || 0,
|
|
gitRev: process.env.BUILDKITE_COMMIT,
|
|
isPr: prId !== undefined,
|
|
...(prId !== undefined ? { prId } : {}),
|
|
ciBuildName: process.env.BUILDKITE_PIPELINE_SLUG,
|
|
journeyName: config.getName(),
|
|
};
|
|
|
|
return {
|
|
...baseConfig,
|
|
|
|
mochaOpts: {
|
|
...baseConfig.mochaOpts,
|
|
bail: true,
|
|
},
|
|
|
|
services,
|
|
pageObjects: {},
|
|
|
|
servicesRequiredForTestAnalysis: ['performance', 'journeyConfig'],
|
|
|
|
junit: {
|
|
reportName: `Journey: ${config.getName()}`,
|
|
metadata: {
|
|
journeyName: config.getName(),
|
|
stepNames: steps.map((s) => s.name),
|
|
},
|
|
},
|
|
|
|
kbnTestServer: {
|
|
...baseConfig.kbnTestServer,
|
|
// delay shutdown to ensure that APM can report the data it collects during test execution
|
|
delayShutdown: process.env.TEST_PERFORMANCE_PHASE === 'TEST' ? 15_000 : 0,
|
|
|
|
serverArgs: [
|
|
...baseConfig.kbnTestServer.serverArgs,
|
|
`--telemetry.optIn=${enableTelemetry && process.env.TEST_PERFORMANCE_PHASE === 'TEST'}`,
|
|
`--telemetry.labels=${JSON.stringify(telemetryLabels)}`,
|
|
'--csp.strict=false',
|
|
'--csp.warnLegacyBrowsers=false',
|
|
'--coreApp.allowDynamicConfigOverrides=true',
|
|
],
|
|
|
|
env: {
|
|
ELASTIC_APM_ACTIVE: JOURNEY_APM_CONFIG.active,
|
|
ELASTIC_APM_CONTEXT_PROPAGATION_ONLY: JOURNEY_APM_CONFIG.contextPropagationOnly,
|
|
ELASTIC_APM_ENVIRONMENT: JOURNEY_APM_CONFIG.environment,
|
|
ELASTIC_APM_TRANSACTION_SAMPLE_RATE: JOURNEY_APM_CONFIG.transactionSampleRate,
|
|
ELASTIC_APM_SERVER_URL: JOURNEY_APM_CONFIG.serverUrl,
|
|
ELASTIC_APM_SECRET_TOKEN: JOURNEY_APM_CONFIG.secretToken,
|
|
ELASTIC_APM_CAPTURE_BODY: JOURNEY_APM_CONFIG.captureBody,
|
|
ELASTIC_APM_CAPTURE_HEADERS: JOURNEY_APM_CONFIG.captureRequestHeaders,
|
|
ELASTIC_APM_LONG_FIELD_MAX_LENGTH: JOURNEY_APM_CONFIG.longFieldMaxLength,
|
|
ELASTIC_APM_GLOBAL_LABELS: Object.entries({
|
|
...config.getExtraApmLabels(),
|
|
testJobId,
|
|
testBuildId,
|
|
journeyName: config.getName(),
|
|
ftrConfig: config.getRepoRelPath(),
|
|
...JOURNEY_APM_CONFIG.globalLabels,
|
|
})
|
|
.flatMap(([key, value]) => (value == null ? [] : `${key}=${value}`))
|
|
.join(','),
|
|
},
|
|
},
|
|
};
|
|
};
|
|
}
|