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
143 lines
4 KiB
TypeScript
143 lines
4 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 { inspect } from 'util';
|
|
|
|
import { Page } from 'playwright';
|
|
import callsites from 'callsites';
|
|
import { ToolingLog } from '@kbn/tooling-log';
|
|
import { FtrConfigProvider } from '@kbn/test';
|
|
import { FtrProviderContext } from '../services/ftr_context_provider';
|
|
import { Es, KibanaServer, Retry, Auth } from '../services';
|
|
|
|
import { InputDelays } from '../services/input_delays';
|
|
import { KibanaUrl } from '../services/kibana_url';
|
|
|
|
import { JourneyFtrHarness } from './journey_ftr_harness';
|
|
import { makeFtrConfigProvider } from './journey_ftr_config';
|
|
import { JourneyConfig, JourneyConfigOptions } from './journey_config';
|
|
import { KibanaPage } from '../services/page/kibana_page';
|
|
import { ProjectPage } from '../services/page/project_page';
|
|
|
|
export interface BaseStepCtx {
|
|
kibanaPage: KibanaPage | ProjectPage;
|
|
page: Page;
|
|
log: ToolingLog;
|
|
inputDelays: InputDelays;
|
|
kbnUrl: KibanaUrl;
|
|
kibanaServer: KibanaServer;
|
|
es: Es;
|
|
retry: Retry;
|
|
auth: Auth;
|
|
}
|
|
|
|
export type AnyStep = Step<{}>;
|
|
|
|
export interface Step<CtxExt extends object> {
|
|
name: string;
|
|
index: number;
|
|
fn(ctx: BaseStepCtx & CtxExt): Promise<void>;
|
|
}
|
|
|
|
const CONFIG_PROVIDER_CACHE = new WeakMap<Journey<any>, FtrConfigProvider>();
|
|
|
|
export class Journey<CtxExt extends object> {
|
|
static convertToFtrConfigProvider(journey: Journey<any>) {
|
|
const cached = CONFIG_PROVIDER_CACHE.get(journey);
|
|
if (cached) {
|
|
return cached;
|
|
}
|
|
|
|
const provider = makeFtrConfigProvider(journey.config, journey.#steps);
|
|
CONFIG_PROVIDER_CACHE.set(journey, provider);
|
|
return provider;
|
|
}
|
|
|
|
/**
|
|
* Load a journey from a file path
|
|
*/
|
|
static async load(path: string) {
|
|
let m;
|
|
try {
|
|
m = await import(path);
|
|
} catch (error) {
|
|
throw new Error(`Unable to load file: ${path}`);
|
|
}
|
|
|
|
if (!m || !m.journey) {
|
|
throw new Error(`[${path}] is not a journey`);
|
|
}
|
|
|
|
const journey = m.journey;
|
|
if (journey instanceof Journey) {
|
|
return journey;
|
|
}
|
|
|
|
const dbg = inspect(journey);
|
|
throw new Error(`[${path}] does not export a Journey like it should, received ${dbg}`);
|
|
}
|
|
|
|
#steps: Array<Step<CtxExt>> = [];
|
|
|
|
config: JourneyConfig<CtxExt>;
|
|
|
|
/**
|
|
* Create a Journey which should be exported from a file in the
|
|
* x-pack/performance/journeys directory.
|
|
*/
|
|
constructor(opts?: JourneyConfigOptions<CtxExt>) {
|
|
const path = callsites().at(1)?.getFileName();
|
|
|
|
if (!path) {
|
|
throw new Error('unable to determine path of journey config file');
|
|
}
|
|
|
|
this.config = new JourneyConfig(path, opts);
|
|
}
|
|
|
|
/**
|
|
* Define a step of this Journey. Steps are only separated from each other
|
|
* to aid in reading/debugging the journey and reading it's logging output.
|
|
* These services might be helpful:
|
|
*
|
|
* page: methods to interact with a single tab in a browser
|
|
*
|
|
* kbnUrl: get the URL for a Kibana plugin
|
|
*
|
|
* kibanaServer: basic Kibana server client
|
|
*
|
|
* es: basic Elasticsearch client
|
|
*
|
|
* If a journey fails, a failure report will be created with a screenshot
|
|
* at the point of failure as well as a screenshot at the end of every
|
|
* step.
|
|
*/
|
|
step(name: string, fn: (ctx: BaseStepCtx & CtxExt) => Promise<void>) {
|
|
this.#steps.push({
|
|
name,
|
|
index: this.#steps.length,
|
|
fn,
|
|
});
|
|
|
|
return this;
|
|
}
|
|
|
|
/** called by FTR to setup tests */
|
|
protected testProvider({ getService }: FtrProviderContext) {
|
|
new JourneyFtrHarness(
|
|
getService('log'),
|
|
getService('config'),
|
|
getService('esArchiver'),
|
|
getService('kibanaServer'),
|
|
getService('es'),
|
|
getService('retry'),
|
|
getService('auth'),
|
|
this.config
|
|
).initMochaSuite(this.#steps);
|
|
}
|
|
}
|