forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SLO] Synthetics based SLO e2e tests (elastic#183637)
## Summary Setting up Elastic/Synthetics based slo e2e tests !! --------- Co-authored-by: kibanamachine <[email protected]>
- Loading branch information
1 parent
743ddd4
commit 8b7fa0d
Showing
21 changed files
with
317 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
steps: | ||
- command: .buildkite/scripts/steps/functional/slo_plugin_e2e.sh | ||
label: 'SLO Plugin @elastic/synthetics Tests' | ||
agents: | ||
queue: n2-4-spot | ||
depends_on: | ||
- build | ||
- quick_checks | ||
timeout_in_minutes: 30 | ||
artifact_paths: | ||
- 'x-pack/plugins/observability_solution/slo/e2e/.journeys/**/*' | ||
retry: | ||
automatic: | ||
- exit_status: '-1' | ||
limit: 3 | ||
- exit_status: '*' | ||
limit: 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -euo pipefail | ||
|
||
source .buildkite/scripts/common/util.sh | ||
|
||
.buildkite/scripts/bootstrap.sh | ||
.buildkite/scripts/download_build_artifacts.sh | ||
|
||
export JOB=kibana-ux-plugin-synthetics | ||
|
||
echo "--- SLO @elastic/synthetics Tests" | ||
|
||
cd "$XPACK_DIR" | ||
|
||
node plugins/observability_solution/slo/scripts/e2e.js --kibana-install-dir "$KIBANA_BUILD_LOCATION" ${GREP:+--grep \"${GREP}\"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
x-pack/plugins/observability_solution/slo/e2e/journeys/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
export * from './slos_overview.journey'; |
50 changes: 50 additions & 0 deletions
50
x-pack/plugins/observability_solution/slo/e2e/journeys/slos_overview.journey.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* 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 { journey, step, before, expect } from '@elastic/synthetics'; | ||
import { RetryService } from '@kbn/ftr-common-functional-services'; | ||
import { SLoDataService } from '../services/slo_data_service'; | ||
import { sloAppPageProvider } from '../page_objects/slo_app'; | ||
|
||
journey(`SLOsOverview`, async ({ page, params }) => { | ||
const sloApp = sloAppPageProvider({ page, kibanaUrl: params.kibanaUrl }); | ||
const dataService = new SLoDataService({ | ||
kibanaUrl: params.kibanaUrl, | ||
elasticsearchUrl: params.elasticsearchUrl, | ||
getService: params.getService, | ||
}); | ||
|
||
const retry: RetryService = params.getService('retry'); | ||
|
||
before(async () => { | ||
await dataService.generateSloData(); | ||
await dataService.addSLO(); | ||
}); | ||
|
||
step('Go to slos overview', async () => { | ||
await sloApp.navigateToOverview(true); | ||
}); | ||
|
||
step('validate data retention tab', async () => { | ||
await retry.tryWithRetries( | ||
'check if slos are displayed', | ||
async () => { | ||
await page.waitForSelector('text="Test Stack SLO"'); | ||
const cards = await page.locator('text="Test Stack SLO"').all(); | ||
expect(cards.length > 5).toBeTruthy(); | ||
}, | ||
{ | ||
retryCount: 50, | ||
retryDelay: 20000, | ||
timeout: 60 * 20000, | ||
}, | ||
async () => { | ||
await page.getByTestId('querySubmitButton').click(); | ||
} | ||
); | ||
}); | ||
}); |
33 changes: 33 additions & 0 deletions
33
x-pack/plugins/observability_solution/slo/e2e/page_objects/slo_app.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* 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 { Page } from '@elastic/synthetics'; | ||
import { loginPageProvider } from '@kbn/synthetics-plugin/e2e/page_objects/login'; | ||
import { utilsPageProvider } from '@kbn/synthetics-plugin/e2e/page_objects/utils'; | ||
import { recordVideo } from '@kbn/synthetics-plugin/e2e/helpers/record_video'; | ||
|
||
export function sloAppPageProvider({ page, kibanaUrl }: { page: Page; kibanaUrl: string }) { | ||
page.setDefaultTimeout(60 * 1000); | ||
recordVideo(page); | ||
|
||
return { | ||
...loginPageProvider({ | ||
page, | ||
username: 'elastic', | ||
password: 'changeme', | ||
}), | ||
...utilsPageProvider({ page }), | ||
|
||
async navigateToOverview(doLogin = false) { | ||
await page.goto(`${kibanaUrl}/app/slo`, { | ||
waitUntil: 'networkidle', | ||
}); | ||
if (doLogin) { | ||
await this.loginToKibana(); | ||
} | ||
}, | ||
}; | ||
} |
94 changes: 94 additions & 0 deletions
94
x-pack/plugins/observability_solution/slo/e2e/services/slo_data_service.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
/* | ||
* 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 { KbnClient } from '@kbn/test'; | ||
import { cli, DEFAULTS } from '@kbn/data-forge'; | ||
|
||
export class SLoDataService { | ||
kibanaUrl: string; | ||
elasticsearchUrl: string; | ||
params: Record<string, any>; | ||
requester: KbnClient['requester']; | ||
|
||
constructor(params: Record<string, any>) { | ||
this.kibanaUrl = params.kibanaUrl; | ||
this.elasticsearchUrl = params.elasticsearchUrl; | ||
this.requester = params.getService('kibanaServer').requester; | ||
this.params = params; | ||
} | ||
|
||
async generateSloData({ | ||
lookback = 'now-1d', | ||
eventsPerCycle = 50, | ||
}: { | ||
lookback?: string; | ||
eventsPerCycle?: number; | ||
} = {}) { | ||
await cli({ | ||
kibanaUrl: this.kibanaUrl, | ||
elasticsearchHost: this.elasticsearchUrl, | ||
lookback: DEFAULTS.LOOKBACK, | ||
eventsPerCycle: DEFAULTS.EVENTS_PER_CYCLE, | ||
payloadSize: DEFAULTS.PAYLOAD_SIZE, | ||
concurrency: DEFAULTS.CONCURRENCY, | ||
indexInterval: 10_000, | ||
dataset: 'fake_stack', | ||
scenario: DEFAULTS.SCENARIO, | ||
elasticsearchUsername: DEFAULTS.ELASTICSEARCH_USERNAME, | ||
elasticsearchPassword: DEFAULTS.ELASTICSEARCH_PASSWORD, | ||
kibanaUsername: DEFAULTS.KIBANA_USERNAME, | ||
kibanaPassword: DEFAULTS.KIBANA_PASSWORD, | ||
installKibanaAssets: true, | ||
eventTemplate: DEFAULTS.EVENT_TEMPLATE, | ||
reduceWeekendTrafficBy: DEFAULTS.REDUCE_WEEKEND_TRAFFIC_BY, | ||
ephemeralProjectIds: DEFAULTS.EPHEMERAL_PROJECT_IDS, | ||
alignEventsToInterval: DEFAULTS.ALIGN_EVENTS_TO_INTERVAL, | ||
scheduleEnd: 'now+10m', | ||
}).then((res) => { | ||
// eslint-disable-next-line no-console | ||
console.log(res); | ||
}); | ||
} | ||
|
||
async addSLO() { | ||
const example = { | ||
name: 'Test Stack SLO', | ||
description: '', | ||
indicator: { | ||
type: 'sli.kql.custom', | ||
params: { | ||
index: 'kbn-data-forge-fake_stack.admin-console-*', | ||
filter: '', | ||
good: 'log.level : "INFO" ', | ||
total: '', | ||
timestampField: '@timestamp', | ||
}, | ||
}, | ||
budgetingMethod: 'occurrences', | ||
timeWindow: { | ||
duration: '30d', | ||
type: 'rolling', | ||
}, | ||
objective: { | ||
target: 0.99, | ||
}, | ||
tags: [], | ||
groupBy: ['user.id'], | ||
}; | ||
try { | ||
const { data } = await this.requester.request({ | ||
description: 'get monitor by id', | ||
path: '/api/observability/slos', | ||
body: example, | ||
method: 'POST', | ||
}); | ||
return data; | ||
} catch (e) { | ||
console.error(e); | ||
} | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
x-pack/plugins/observability_solution/slo/e2e/synthetics_run.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* 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 { FtrConfigProviderContext } from '@kbn/test'; | ||
import { SyntheticsRunner, argv } from '@kbn/synthetics-plugin/e2e'; | ||
|
||
const { headless, grep, bail: pauseOnError } = argv; | ||
|
||
async function runE2ETests({ readConfigFile }: FtrConfigProviderContext) { | ||
const kibanaConfig = await readConfigFile(require.resolve('@kbn/synthetics-plugin/e2e/config')); | ||
return { | ||
...kibanaConfig.getAll(), | ||
testRunner: async ({ getService }: any) => { | ||
const syntheticsRunner = new SyntheticsRunner(getService, { | ||
headless, | ||
match: grep, | ||
pauseOnError, | ||
}); | ||
|
||
await syntheticsRunner.setup(); | ||
|
||
await syntheticsRunner.loadTestFiles(async () => { | ||
require('./journeys'); | ||
}); | ||
|
||
await syntheticsRunner.run(); | ||
}, | ||
}; | ||
} | ||
|
||
// eslint-disable-next-line import/no-default-export | ||
export default runE2ETests; |
18 changes: 18 additions & 0 deletions
18
x-pack/plugins/observability_solution/slo/e2e/tsconfig.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"extends": "../../../../../tsconfig.base.json", | ||
"exclude": ["tmp", "target/**/*"], | ||
"include": ["**/*"], | ||
"compilerOptions": { | ||
"outDir": "target/types", | ||
"types": [ "node"], | ||
"isolatedModules": false, | ||
}, | ||
"kbn_references": [ | ||
{ "path": "../../../../test/tsconfig.json" }, | ||
{ "path": "../../../../../test/tsconfig.json" }, | ||
"@kbn/test", | ||
"@kbn/ftr-common-functional-services", | ||
"@kbn/synthetics-plugin/e2e", | ||
"@kbn/data-forge", | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.