mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
* Revert "FTR: add chromium-based Edge browser support (#61684) (#63068)"
This reverts commit e8caa06f19
.
* update lock file
* [Reporting] Improve functional test steps (#63259)
* Start of refactoring
* remove unused fixtuers
* fix the refactoring bugs
* update archive with better dashboard
* important comment
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
* get tests to pass
* get more tests to pass
* reduce branch diffs
* reduce loc change
Co-authored-by: Dzmitry Lemechko <dzmitry.lemechko@elastic.co>
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
This commit is contained in:
parent
e8fcb4920e
commit
7e8f2c317f
15 changed files with 1731 additions and 781 deletions
|
@ -23,6 +23,7 @@ export const DownloadButton = ({ getUrl, job }: Props) => {
|
|||
<EuiButton
|
||||
size="s"
|
||||
data-test-subj="downloadCompletedReportButton"
|
||||
data-test-href={getUrl(job.id)}
|
||||
onClick={() => {
|
||||
downloadReport();
|
||||
}}
|
||||
|
|
Binary file not shown.
File diff suppressed because it is too large
Load diff
Binary file not shown.
|
@ -1,386 +0,0 @@
|
|||
{
|
||||
"type": "index",
|
||||
"value": {
|
||||
"index": ".kibana",
|
||||
"mappings": {
|
||||
"properties": {
|
||||
"config": {
|
||||
"dynamic": "true",
|
||||
"properties": {
|
||||
"buildNum": {
|
||||
"type": "keyword"
|
||||
},
|
||||
"defaultIndex": {
|
||||
"fields": {
|
||||
"keyword": {
|
||||
"ignore_above": 256,
|
||||
"type": "keyword"
|
||||
}
|
||||
},
|
||||
"type": "text"
|
||||
},
|
||||
"xPackMonitoring:showBanner": {
|
||||
"type": "boolean"
|
||||
}
|
||||
}
|
||||
},
|
||||
"dashboard": {
|
||||
"dynamic": "strict",
|
||||
"properties": {
|
||||
"description": {
|
||||
"type": "text"
|
||||
},
|
||||
"hits": {
|
||||
"type": "integer"
|
||||
},
|
||||
"kibanaSavedObjectMeta": {
|
||||
"properties": {
|
||||
"searchSourceJSON": {
|
||||
"type": "text"
|
||||
}
|
||||
}
|
||||
},
|
||||
"optionsJSON": {
|
||||
"type": "text"
|
||||
},
|
||||
"panelsJSON": {
|
||||
"type": "text"
|
||||
},
|
||||
"refreshInterval": {
|
||||
"properties": {
|
||||
"display": {
|
||||
"type": "keyword"
|
||||
},
|
||||
"pause": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"section": {
|
||||
"type": "integer"
|
||||
},
|
||||
"value": {
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
},
|
||||
"timeFrom": {
|
||||
"type": "keyword"
|
||||
},
|
||||
"timeRestore": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"timeTo": {
|
||||
"type": "keyword"
|
||||
},
|
||||
"title": {
|
||||
"type": "text"
|
||||
},
|
||||
"uiStateJSON": {
|
||||
"type": "text"
|
||||
},
|
||||
"version": {
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
},
|
||||
"graph-workspace": {
|
||||
"dynamic": "strict",
|
||||
"properties": {
|
||||
"description": {
|
||||
"type": "text"
|
||||
},
|
||||
"kibanaSavedObjectMeta": {
|
||||
"properties": {
|
||||
"searchSourceJSON": {
|
||||
"type": "text"
|
||||
}
|
||||
}
|
||||
},
|
||||
"numLinks": {
|
||||
"type": "integer"
|
||||
},
|
||||
"numVertices": {
|
||||
"type": "integer"
|
||||
},
|
||||
"title": {
|
||||
"type": "text"
|
||||
},
|
||||
"version": {
|
||||
"type": "integer"
|
||||
},
|
||||
"wsState": {
|
||||
"type": "text"
|
||||
}
|
||||
}
|
||||
},
|
||||
"index-pattern": {
|
||||
"dynamic": "strict",
|
||||
"properties": {
|
||||
"fieldFormatMap": {
|
||||
"type": "text"
|
||||
},
|
||||
"fields": {
|
||||
"type": "text"
|
||||
},
|
||||
"intervalName": {
|
||||
"type": "keyword"
|
||||
},
|
||||
"notExpandable": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"sourceFilters": {
|
||||
"type": "text"
|
||||
},
|
||||
"timeFieldName": {
|
||||
"type": "keyword"
|
||||
},
|
||||
"title": {
|
||||
"type": "text"
|
||||
}
|
||||
}
|
||||
},
|
||||
"search": {
|
||||
"dynamic": "strict",
|
||||
"properties": {
|
||||
"columns": {
|
||||
"type": "keyword"
|
||||
},
|
||||
"description": {
|
||||
"type": "text"
|
||||
},
|
||||
"hits": {
|
||||
"type": "integer"
|
||||
},
|
||||
"kibanaSavedObjectMeta": {
|
||||
"properties": {
|
||||
"searchSourceJSON": {
|
||||
"type": "text"
|
||||
}
|
||||
}
|
||||
},
|
||||
"sort": {
|
||||
"type": "keyword"
|
||||
},
|
||||
"title": {
|
||||
"type": "text"
|
||||
},
|
||||
"version": {
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
},
|
||||
"server": {
|
||||
"dynamic": "strict",
|
||||
"properties": {
|
||||
"uuid": {
|
||||
"type": "keyword"
|
||||
}
|
||||
}
|
||||
},
|
||||
"space": {
|
||||
"properties": {
|
||||
"_reserved": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"color": {
|
||||
"type": "keyword"
|
||||
},
|
||||
"description": {
|
||||
"type": "text"
|
||||
},
|
||||
"initials": {
|
||||
"type": "keyword"
|
||||
},
|
||||
"name": {
|
||||
"fields": {
|
||||
"keyword": {
|
||||
"ignore_above": 2048,
|
||||
"type": "keyword"
|
||||
}
|
||||
},
|
||||
"type": "text"
|
||||
}
|
||||
}
|
||||
},
|
||||
"spaceId": {
|
||||
"type": "keyword"
|
||||
},
|
||||
"timelion-sheet": {
|
||||
"dynamic": "strict",
|
||||
"properties": {
|
||||
"description": {
|
||||
"type": "text"
|
||||
},
|
||||
"hits": {
|
||||
"type": "integer"
|
||||
},
|
||||
"kibanaSavedObjectMeta": {
|
||||
"properties": {
|
||||
"searchSourceJSON": {
|
||||
"type": "text"
|
||||
}
|
||||
}
|
||||
},
|
||||
"timelion_chart_height": {
|
||||
"type": "integer"
|
||||
},
|
||||
"timelion_columns": {
|
||||
"type": "integer"
|
||||
},
|
||||
"timelion_interval": {
|
||||
"type": "keyword"
|
||||
},
|
||||
"timelion_other_interval": {
|
||||
"type": "keyword"
|
||||
},
|
||||
"timelion_rows": {
|
||||
"type": "integer"
|
||||
},
|
||||
"timelion_sheet": {
|
||||
"type": "text"
|
||||
},
|
||||
"title": {
|
||||
"type": "text"
|
||||
},
|
||||
"version": {
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
},
|
||||
"type": {
|
||||
"type": "keyword"
|
||||
},
|
||||
"updated_at": {
|
||||
"type": "date"
|
||||
},
|
||||
"url": {
|
||||
"dynamic": "strict",
|
||||
"properties": {
|
||||
"accessCount": {
|
||||
"type": "long"
|
||||
},
|
||||
"accessDate": {
|
||||
"type": "date"
|
||||
},
|
||||
"createDate": {
|
||||
"type": "date"
|
||||
},
|
||||
"url": {
|
||||
"fields": {
|
||||
"keyword": {
|
||||
"ignore_above": 2048,
|
||||
"type": "keyword"
|
||||
}
|
||||
},
|
||||
"type": "text"
|
||||
}
|
||||
}
|
||||
},
|
||||
"visualization": {
|
||||
"dynamic": "strict",
|
||||
"properties": {
|
||||
"description": {
|
||||
"type": "text"
|
||||
},
|
||||
"kibanaSavedObjectMeta": {
|
||||
"properties": {
|
||||
"searchSourceJSON": {
|
||||
"type": "text"
|
||||
}
|
||||
}
|
||||
},
|
||||
"savedSearchId": {
|
||||
"type": "keyword"
|
||||
},
|
||||
"title": {
|
||||
"type": "text"
|
||||
},
|
||||
"uiStateJSON": {
|
||||
"type": "text"
|
||||
},
|
||||
"version": {
|
||||
"type": "integer"
|
||||
},
|
||||
"visState": {
|
||||
"type": "text"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"settings": {
|
||||
"index": {
|
||||
"number_of_replicas": "1",
|
||||
"number_of_shards": "1"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
"type": "index",
|
||||
"value": {
|
||||
"index": ".reporting-2018.03.11",
|
||||
"mappings": {
|
||||
"properties": {
|
||||
"attempts": {
|
||||
"type": "short"
|
||||
},
|
||||
"completed_at": {
|
||||
"type": "date"
|
||||
},
|
||||
"created_at": {
|
||||
"type": "date"
|
||||
},
|
||||
"created_by": {
|
||||
"type": "keyword"
|
||||
},
|
||||
"jobtype": {
|
||||
"type": "keyword"
|
||||
},
|
||||
"max_attempts": {
|
||||
"type": "short"
|
||||
},
|
||||
"output": {
|
||||
"properties": {
|
||||
"content": {
|
||||
"enabled": false,
|
||||
"type": "object"
|
||||
},
|
||||
"content_type": {
|
||||
"type": "keyword"
|
||||
},
|
||||
"max_size_reached": {
|
||||
"type": "boolean"
|
||||
}
|
||||
}
|
||||
},
|
||||
"payload": {
|
||||
"enabled": false,
|
||||
"type": "object"
|
||||
},
|
||||
"priority": {
|
||||
"type": "byte"
|
||||
},
|
||||
"process_expiration": {
|
||||
"type": "date"
|
||||
},
|
||||
"started_at": {
|
||||
"type": "date"
|
||||
},
|
||||
"status": {
|
||||
"type": "keyword"
|
||||
},
|
||||
"timeout": {
|
||||
"type": "long"
|
||||
}
|
||||
}
|
||||
},
|
||||
"settings": {
|
||||
"index": {
|
||||
"auto_expand_replicas": "0-1",
|
||||
"number_of_replicas": "0",
|
||||
"number_of_shards": "1"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -19,52 +19,10 @@ export function ReportingPageProvider({ getService, getPageObjects }) {
|
|||
const log = getService('log');
|
||||
const config = getService('config');
|
||||
const testSubjects = getService('testSubjects');
|
||||
const esArchiver = getService('esArchiver');
|
||||
const browser = getService('browser');
|
||||
const kibanaServer = getService('kibanaServer');
|
||||
const PageObjects = getPageObjects(['common', 'security', 'settings', 'share', 'timePicker']);
|
||||
const PageObjects = getPageObjects(['common', 'security', 'share', 'timePicker']);
|
||||
|
||||
class ReportingPage {
|
||||
async initTests() {
|
||||
log.debug('ReportingPage:initTests');
|
||||
await PageObjects.settings.navigateTo();
|
||||
await esArchiver.loadIfNeeded('../../functional/es_archives/logstash_functional');
|
||||
await esArchiver.load('reporting/historic');
|
||||
await kibanaServer.uiSettings.replace({
|
||||
defaultIndex: 'logstash-*',
|
||||
});
|
||||
|
||||
await browser.setWindowSize(1600, 850);
|
||||
}
|
||||
|
||||
async getUrlOfTab(tabIndex) {
|
||||
return await retry.try(async () => {
|
||||
log.debug(`reportingPage.getUrlOfTab(${tabIndex}`);
|
||||
const handles = await browser.getAllWindowHandles();
|
||||
log.debug(`Switching to window ${handles[tabIndex]}`);
|
||||
await browser.switchToWindow(handles[tabIndex]);
|
||||
|
||||
const url = await browser.getCurrentUrl();
|
||||
if (!url || url === 'about:blank') {
|
||||
throw new Error('url is blank');
|
||||
}
|
||||
|
||||
await browser.switchToWindow(handles[0]);
|
||||
return url;
|
||||
});
|
||||
}
|
||||
|
||||
async closeTab(tabIndex) {
|
||||
return await retry.try(async () => {
|
||||
log.debug(`reportingPage.closeTab(${tabIndex}`);
|
||||
const handles = await browser.getAllWindowHandles();
|
||||
log.debug(`Switching to window ${handles[tabIndex]}`);
|
||||
await browser.switchToWindow(handles[tabIndex]);
|
||||
await browser.closeCurrentWindow();
|
||||
await browser.switchToWindow(handles[0]);
|
||||
});
|
||||
}
|
||||
|
||||
async forceSharedItemsContainerSize({ width }) {
|
||||
await browser.execute(`
|
||||
var el = document.querySelector('[data-shared-items-container]');
|
||||
|
@ -73,6 +31,20 @@ export function ReportingPageProvider({ getService, getPageObjects }) {
|
|||
`);
|
||||
}
|
||||
|
||||
async getReportURL(timeout) {
|
||||
log.debug('getReportURL');
|
||||
|
||||
const url = await testSubjects.getAttribute(
|
||||
'downloadCompletedReportButton',
|
||||
'data-test-href',
|
||||
timeout
|
||||
);
|
||||
|
||||
log.debug(`getReportURL got url: ${url}`);
|
||||
|
||||
return url;
|
||||
}
|
||||
|
||||
async removeForceSharedItemsContainerSize() {
|
||||
await browser.execute(`
|
||||
var el = document.querySelector('[data-shared-items-container]');
|
||||
|
@ -81,9 +53,8 @@ export function ReportingPageProvider({ getService, getPageObjects }) {
|
|||
`);
|
||||
}
|
||||
|
||||
getRawPdfReportData(url) {
|
||||
log.debug(`getRawPdfReportData for ${url}`);
|
||||
let data = []; // List of Buffer objects
|
||||
getResponse(url) {
|
||||
log.debug(`getResponse for ${url}`);
|
||||
const auth = config.get('servers.elasticsearch.auth');
|
||||
const headers = {
|
||||
Authorization: `Basic ${Buffer.from(auth).toString('base64')}`,
|
||||
|
@ -100,13 +71,7 @@ export function ReportingPageProvider({ getService, getPageObjects }) {
|
|||
headers,
|
||||
},
|
||||
res => {
|
||||
res.on('data', function(chunk) {
|
||||
data.push(chunk);
|
||||
});
|
||||
res.on('end', function() {
|
||||
data = Buffer.concat(data);
|
||||
resolve(data);
|
||||
});
|
||||
resolve(res);
|
||||
}
|
||||
)
|
||||
.on('error', e => {
|
||||
|
@ -115,6 +80,18 @@ export function ReportingPageProvider({ getService, getPageObjects }) {
|
|||
});
|
||||
}
|
||||
|
||||
async getRawPdfReportData(url) {
|
||||
const data = []; // List of Buffer objects
|
||||
log.debug(`getRawPdfReportData for ${url}`);
|
||||
|
||||
return new Promise(async (resolve, reject) => {
|
||||
const response = await this.getResponse(url).catch(reject);
|
||||
|
||||
response.on('data', chunk => data.push(chunk));
|
||||
response.on('end', () => resolve(Buffer.concat(data)));
|
||||
});
|
||||
}
|
||||
|
||||
async openCsvReportingPanel() {
|
||||
log.debug('openCsvReportingPanel');
|
||||
await PageObjects.share.openShareMenuItem('CSV Reports');
|
||||
|
@ -130,10 +107,6 @@ export function ReportingPageProvider({ getService, getPageObjects }) {
|
|||
await PageObjects.share.openShareMenuItem('PNG Reports');
|
||||
}
|
||||
|
||||
async clickDownloadReportButton(timeout) {
|
||||
await testSubjects.click('downloadCompletedReportButton', timeout);
|
||||
}
|
||||
|
||||
async clearToastNotifications() {
|
||||
const toasts = await testSubjects.findAll('toastCloseButton');
|
||||
await Promise.all(toasts.map(async t => await t.click()));
|
||||
|
@ -147,6 +120,20 @@ export function ReportingPageProvider({ getService, getPageObjects }) {
|
|||
return await retry.try(async () => await testSubjects.find('generateReportButton'));
|
||||
}
|
||||
|
||||
async isGenerateReportButtonDisabled() {
|
||||
const generateReportButton = await this.getGenerateReportButton();
|
||||
return await retry.try(async () => {
|
||||
const isDisabled = await generateReportButton.getAttribute('disabled');
|
||||
return isDisabled;
|
||||
});
|
||||
}
|
||||
|
||||
async canReportBeCreated() {
|
||||
await this.clickGenerateReportButton();
|
||||
const success = await this.checkForReportingToasts();
|
||||
return success;
|
||||
}
|
||||
|
||||
async checkUsePrintLayout() {
|
||||
// The print layout checkbox slides in as part of an animation, and tests can
|
||||
// attempt to click it too quickly, leading to flaky tests. The 500ms wait allows
|
||||
|
@ -175,7 +162,9 @@ export function ReportingPageProvider({ getService, getPageObjects }) {
|
|||
|
||||
async setTimepickerInDataRange() {
|
||||
log.debug('Reporting:setTimepickerInDataRange');
|
||||
await PageObjects.timePicker.setDefaultAbsoluteRange();
|
||||
const fromTime = 'Sep 19, 2015 @ 06:31:44.000';
|
||||
const toTime = 'Sep 19, 2015 @ 18:01:44.000';
|
||||
await PageObjects.timePicker.setAbsoluteRange(fromTime, toTime);
|
||||
}
|
||||
|
||||
async setTimepickerInNoDataRange() {
|
||||
|
|
1
x-pack/test/reporting/.gitignore
vendored
Normal file
1
x-pack/test/reporting/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
functional/reports/session/
|
|
@ -9,8 +9,8 @@ Reporting tests have their own top level test folder because:
|
|||
### Running the tests
|
||||
|
||||
There is more information on running x-pack tests here: https://github.com/elastic/kibana/blob/master/x-pack/README.md#running-functional-tests. Similar to running the API tests, you need to specify a reporting configuration file. Reporting currently has two configuration files you can point to:
|
||||
- test/reporting/configs/chromium_api.js
|
||||
- test/reporting/configs/chromium_functional.js
|
||||
- test/reporting/configs/chromium_api.js
|
||||
- test/reporting/configs/chromium_functional.js
|
||||
|
||||
The `api` versions hit the reporting api and ensure report generation completes successfully, but does not verify the output of the reports. This is done in the `functional` test versions, which does a snapshot comparison of the generated URL against a baseline to determine success.
|
||||
|
||||
|
@ -33,10 +33,6 @@ node scripts/functional_tests_server.js --config test/reporting/configs/[test_co
|
|||
node ../scripts/functional_test_runner.js --config test/reporting/configs/[test_config_name_here].js
|
||||
```
|
||||
|
||||
**Prerequisites**
|
||||
The reporting functional tests use [pdf-image](https://www.npmjs.com/package/pdf-image) to convert PDF's pages to png files for image comparisons between generated reports and baseline reports.
|
||||
pdf-image requires the system commands `convert`, `gs`, and `pdfinfo` to function. Those can be set up by running the following.
|
||||
|
||||
```sh
|
||||
//OSX
|
||||
brew install imagemagick ghostscript poppler
|
||||
|
@ -82,16 +78,6 @@ node scripts/functional_tests_server.js --config test/reporting/configs/chromium
|
|||
|
||||
**Note:** Dashboard has some snapshot testing too, in `_dashboard_snapshots.js`. This test watches for a command line flag `--updateBaselines` which automates updating the baselines. Probably worthwhile to do some similar here in the long run.
|
||||
|
||||
### Adding a new BWC test
|
||||
|
||||
We have tests that ensure the latest version of Kibana will continue to generate reports from URLs generated in previous versions, to ensure backward compatibility. These tests are in `api/bwc_generation_urls.js`. It's important to update these every now and then and add new ones, especially if anything in the URL changed in a release.
|
||||
|
||||
To add test coverage for a specific minor release,:
|
||||
1. Checkout previous branch, e.g. `git checkout upstream/6.4`
|
||||
2. Sync your environment via `yarn kbn bootstrap` (Note, if you run into problems you may want to first clean via `yarn kbn clean`)
|
||||
3. Start up kibana and Elasticsearch (`yarn es snapshot --license trial` in one terminal, and `yarn start` in another)
|
||||
4. Load the reporting test data that is used in the tests. Ensure you are in the `x-pack` directory and run:
|
||||
|
||||
```
|
||||
node ../scripts/es_archiver.js --es-url http://elastic:changeme@localhost:9200 load ../../../../test/functional/fixtures/es_archiver/dashboard/current/kibana
|
||||
```
|
||||
|
@ -109,7 +95,7 @@ node ../scripts/es_archiver.js --es-url http://elastic:changeme@localhost:9200 l
|
|||
7. Generate some reporting URLs
|
||||
- Use a mixture of Visualize, Discover (CSV), Dashboard
|
||||
- Can view the current test coverage by checkout out [api/generation_urls.js](https://github.com/elastic/kibana/blob/master/x-pack/test/reporting/api/generation_urls.js). You can use different ones for better test coverage (e.g. different dashboards, different visualizations).
|
||||
- Don’t generate urls from huge dashboards since this is time consuming.
|
||||
- Don’t generate urls from huge dashboards since this is time consuming.
|
||||
- Use dashboards that have time saved with them if you wish to have data included.
|
||||
8. Save these reporting urls.
|
||||
9. Navigate back to the main branch via `git checkout master`. Then create, or work off your branch as usual to add the extra test coverage.
|
||||
|
|
|
@ -1,85 +0,0 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License;
|
||||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
import path from 'path';
|
||||
import fs from 'fs';
|
||||
import { promisify } from 'util';
|
||||
import { PDFImage } from 'pdf-image';
|
||||
import PDFJS from 'pdfjs-dist';
|
||||
import { comparePngs } from '../../../../../test/functional/services/lib/compare_pngs';
|
||||
|
||||
const mkdirAsync = promisify(fs.mkdir);
|
||||
|
||||
export async function checkIfPdfsMatch(actualPdfPath, baselinePdfPath, screenshotsDirectory, log) {
|
||||
log.debug(`checkIfPdfsMatch: ${actualPdfPath} vs ${baselinePdfPath}`);
|
||||
// Copy the pdfs into the screenshot session directory, as that's where the generated pngs will automatically be
|
||||
// stored.
|
||||
const sessionDirectoryPath = path.resolve(screenshotsDirectory, 'session');
|
||||
const failureDirectoryPath = path.resolve(screenshotsDirectory, 'failure');
|
||||
|
||||
await mkdirAsync(sessionDirectoryPath, { recursive: true });
|
||||
await mkdirAsync(failureDirectoryPath, { recursive: true });
|
||||
|
||||
const actualPdfFileName = path.basename(actualPdfPath, '.pdf');
|
||||
const baselinePdfFileName = path.basename(baselinePdfPath, '.pdf');
|
||||
|
||||
const baselineCopyPath = path.resolve(
|
||||
sessionDirectoryPath,
|
||||
`${baselinePdfFileName}_baseline.pdf`
|
||||
);
|
||||
const actualCopyPath = path.resolve(sessionDirectoryPath, `${actualPdfFileName}_actual.pdf`);
|
||||
|
||||
// Don't cause a test failure if the baseline snapshot doesn't exist - we don't have all OS's covered and we
|
||||
// don't want to start causing failures for other devs working on OS's which are lacking snapshots. We have
|
||||
// mac and linux covered which is better than nothing for now.
|
||||
try {
|
||||
log.debug(`writeFileSync: ${baselineCopyPath}`);
|
||||
fs.writeFileSync(baselineCopyPath, fs.readFileSync(baselinePdfPath));
|
||||
} catch (error) {
|
||||
log.error(`No baseline pdf found at ${baselinePdfPath}`);
|
||||
return 0;
|
||||
}
|
||||
log.debug(`writeFileSync: ${actualCopyPath}`);
|
||||
fs.writeFileSync(actualCopyPath, fs.readFileSync(actualPdfPath));
|
||||
|
||||
const convertOptions = {};
|
||||
|
||||
const actualPdfImage = new PDFImage(actualCopyPath, { convertOptions });
|
||||
const expectedPdfImage = new PDFImage(baselineCopyPath, { convertOptions });
|
||||
|
||||
log.debug(`Calculating numberOfPages`);
|
||||
|
||||
const actualDoc = await PDFJS.getDocument(actualCopyPath);
|
||||
const expectedDoc = await PDFJS.getDocument(baselineCopyPath);
|
||||
const actualPages = actualDoc.numPages;
|
||||
const expectedPages = expectedDoc.numPages;
|
||||
|
||||
if (actualPages !== expectedPages) {
|
||||
throw new Error(
|
||||
`Expected ${expectedPages} pages but got ${actualPages} in PDFs expected: "${baselineCopyPath}" actual: "${actualCopyPath}".`
|
||||
);
|
||||
}
|
||||
|
||||
let diffTotal = 0;
|
||||
|
||||
for (let pageNum = 0; pageNum <= expectedPages; ++pageNum) {
|
||||
log.debug(`Converting expected pdf page ${pageNum} to png`);
|
||||
const expectedPagePng = await expectedPdfImage.convertPage(pageNum);
|
||||
log.debug(`Converting actual pdf page ${pageNum} to png`);
|
||||
const actualPagePng = await actualPdfImage.convertPage(pageNum);
|
||||
const diffPngPath = path.resolve(failureDirectoryPath, `${baselinePdfFileName}-${pageNum}.png`);
|
||||
diffTotal += await comparePngs(
|
||||
actualPagePng,
|
||||
expectedPagePng,
|
||||
diffPngPath,
|
||||
sessionDirectoryPath,
|
||||
log
|
||||
);
|
||||
pageNum++;
|
||||
}
|
||||
|
||||
return diffTotal;
|
||||
}
|
|
@ -4,5 +4,4 @@
|
|||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
export { checkIfPdfsMatch } from './compare_pdfs';
|
||||
export { checkIfPngsMatch } from './compare_pngs';
|
||||
|
|
|
@ -5,19 +5,15 @@
|
|||
*/
|
||||
|
||||
import expect from '@kbn/expect';
|
||||
import path from 'path';
|
||||
import fs from 'fs';
|
||||
import { promisify } from 'util';
|
||||
import { checkIfPdfsMatch, checkIfPngsMatch } from './lib';
|
||||
|
||||
const writeFileAsync = promisify(fs.writeFile);
|
||||
const mkdirAsync = promisify(fs.mkdir);
|
||||
|
||||
const REPORTS_FOLDER = path.resolve(__dirname, 'reports');
|
||||
/*
|
||||
* TODO Remove this file and spread the tests to various apps
|
||||
*/
|
||||
|
||||
export default function({ getService, getPageObjects }) {
|
||||
const retry = getService('retry');
|
||||
const config = getService('config');
|
||||
const esArchiver = getService('esArchiver');
|
||||
const browser = getService('browser');
|
||||
const log = getService('log');
|
||||
const PageObjects = getPageObjects([
|
||||
'reporting',
|
||||
'common',
|
||||
|
@ -27,275 +23,141 @@ export default function({ getService, getPageObjects }) {
|
|||
'visualize',
|
||||
'visEditor',
|
||||
]);
|
||||
const log = getService('log');
|
||||
|
||||
// FLAKY: https://github.com/elastic/kibana/issues/45499
|
||||
// FLAKY: https://github.com/elastic/kibana/issues/48721
|
||||
describe.skip('Reporting', () => {
|
||||
before('initialize tests', async () => {
|
||||
await PageObjects.reporting.initTests();
|
||||
});
|
||||
|
||||
const expectDisabledGenerateReportButton = async () => {
|
||||
const generateReportButton = await PageObjects.reporting.getGenerateReportButton();
|
||||
await retry.try(async () => {
|
||||
const isDisabled = await generateReportButton.getAttribute('disabled');
|
||||
expect(isDisabled).to.be('true');
|
||||
});
|
||||
};
|
||||
|
||||
const expectEnabledGenerateReportButton = async () => {
|
||||
const generateReportButton = await PageObjects.reporting.getGenerateReportButton();
|
||||
await retry.try(async () => {
|
||||
const isDisabled = await generateReportButton.getAttribute('disabled');
|
||||
expect(isDisabled).to.be(null);
|
||||
});
|
||||
};
|
||||
|
||||
const expectReportCanBeCreated = async () => {
|
||||
await PageObjects.reporting.clickGenerateReportButton();
|
||||
const success = await PageObjects.reporting.checkForReportingToasts();
|
||||
expect(success).to.be(true);
|
||||
};
|
||||
|
||||
const writeSessionReport = async (name, rawPdf, reportExt = 'pdf') => {
|
||||
const sessionDirectory = path.resolve(REPORTS_FOLDER, 'session');
|
||||
await mkdirAsync(sessionDirectory, { recursive: true });
|
||||
const sessionReportPath = path.resolve(sessionDirectory, `${name}.${reportExt}`);
|
||||
await writeFileAsync(sessionReportPath, rawPdf);
|
||||
return sessionReportPath;
|
||||
};
|
||||
|
||||
const getBaselineReportPath = (fileName, reportExt = 'pdf') => {
|
||||
const baselineFolder = path.resolve(REPORTS_FOLDER, 'baseline');
|
||||
return path.resolve(baselineFolder, `${fileName}.${reportExt}`);
|
||||
};
|
||||
|
||||
describe('Reporting', () => {
|
||||
describe('Dashboard', () => {
|
||||
beforeEach(() => PageObjects.reporting.clearToastNotifications());
|
||||
before('initialize tests', async () => {
|
||||
log.debug('ReportingPage:initTests');
|
||||
await esArchiver.loadIfNeeded('reporting/ecommerce');
|
||||
await esArchiver.loadIfNeeded('reporting/ecommerce_kibana');
|
||||
await browser.setWindowSize(1600, 850);
|
||||
});
|
||||
after('clean up archives', async () => {
|
||||
await esArchiver.unload('reporting/ecommerce');
|
||||
await esArchiver.unload('reporting/ecommerce_kibana');
|
||||
});
|
||||
|
||||
describe('Print PDF button', () => {
|
||||
it('is not available if new', async () => {
|
||||
await PageObjects.common.navigateToApp('dashboard');
|
||||
await PageObjects.dashboard.clickNewDashboard();
|
||||
await PageObjects.reporting.openPdfReportingPanel();
|
||||
await expectDisabledGenerateReportButton();
|
||||
expect(await PageObjects.reporting.isGenerateReportButtonDisabled()).to.be('true');
|
||||
});
|
||||
|
||||
it('becomes available when saved', async () => {
|
||||
await PageObjects.dashboard.saveDashboard('mypdfdash');
|
||||
await PageObjects.dashboard.saveDashboard('My PDF Dashboard');
|
||||
await PageObjects.reporting.openPdfReportingPanel();
|
||||
await expectEnabledGenerateReportButton();
|
||||
expect(await PageObjects.reporting.isGenerateReportButtonDisabled()).to.be(null);
|
||||
});
|
||||
});
|
||||
|
||||
describe.skip('Print Layout', () => {
|
||||
it('matches baseline report', async function() {
|
||||
describe('Print Layout', () => {
|
||||
it('Job completes and generates a download URL', async function() {
|
||||
// Generating and then comparing reports can take longer than the default 60s timeout because the comparePngs
|
||||
// function is taking about 15 seconds per comparison in jenkins.
|
||||
this.timeout(300000);
|
||||
await PageObjects.common.navigateToApp('dashboard');
|
||||
await PageObjects.dashboard.gotoDashboardEditMode('mypdfdash');
|
||||
await PageObjects.reporting.setTimepickerInDataRange();
|
||||
const visualizations = PageObjects.dashboard.getTestVisualizationNames();
|
||||
|
||||
// There is a current issue causing reports with tilemaps to timeout:
|
||||
// https://github.com/elastic/kibana/issues/14136. Once that is resolved, add the tilemap visualization
|
||||
// back in!
|
||||
const tileMapIndex = visualizations.indexOf('Visualization TileMap');
|
||||
visualizations.splice(tileMapIndex, 1);
|
||||
await PageObjects.dashboard.addVisualizations(visualizations);
|
||||
|
||||
await PageObjects.dashboard.saveDashboard('report test');
|
||||
|
||||
await PageObjects.dashboard.loadSavedDashboard('Ecom Dashboard');
|
||||
await PageObjects.reporting.openPdfReportingPanel();
|
||||
await PageObjects.reporting.checkUsePrintLayout();
|
||||
await PageObjects.reporting.clickGenerateReportButton();
|
||||
await PageObjects.reporting.clickDownloadReportButton(60000);
|
||||
PageObjects.reporting.clearToastNotifications();
|
||||
|
||||
const url = await PageObjects.reporting.getUrlOfTab(1);
|
||||
await PageObjects.reporting.closeTab(1);
|
||||
const reportData = await PageObjects.reporting.getRawPdfReportData(url);
|
||||
const reportFileName = 'dashboard_print';
|
||||
const sessionReportPath = await writeSessionReport(reportFileName, reportData);
|
||||
const percentSimilar = await checkIfPdfsMatch(
|
||||
sessionReportPath,
|
||||
getBaselineReportPath(reportFileName),
|
||||
config.get('screenshots.directory'),
|
||||
log
|
||||
);
|
||||
// After expected OS differences, the diff count came to be around 128k
|
||||
expect(percentSimilar).to.be.lessThan(0.05);
|
||||
});
|
||||
|
||||
it('matches same baseline report with margins turned on', async function() {
|
||||
// Generating and then comparing reports can take longer than the default 60s timeout because the comparePngs
|
||||
// function is taking about 15 seconds per comparison in jenkins.
|
||||
this.timeout(360000);
|
||||
|
||||
await PageObjects.dashboard.switchToEditMode();
|
||||
await PageObjects.dashboard.useMargins(true);
|
||||
await PageObjects.dashboard.saveDashboard('report test');
|
||||
await PageObjects.reporting.openPdfReportingPanel();
|
||||
await PageObjects.reporting.checkUsePrintLayout();
|
||||
await PageObjects.reporting.clickGenerateReportButton();
|
||||
await PageObjects.reporting.clickDownloadReportButton(60000);
|
||||
PageObjects.reporting.clearToastNotifications();
|
||||
|
||||
const url = await PageObjects.reporting.getUrlOfTab(1);
|
||||
const reportData = await PageObjects.reporting.getRawPdfReportData(url);
|
||||
|
||||
await PageObjects.reporting.closeTab(1);
|
||||
const reportFileName = 'dashboard_print';
|
||||
const sessionReportPath = await writeSessionReport(reportFileName, reportData);
|
||||
const percentSimilar = await checkIfPdfsMatch(
|
||||
sessionReportPath,
|
||||
getBaselineReportPath(reportFileName),
|
||||
config.get('screenshots.directory'),
|
||||
log
|
||||
);
|
||||
// After expected OS differences, the diff count came to be around 128k
|
||||
expect(percentSimilar).to.be.lessThan(0.05);
|
||||
const url = await PageObjects.reporting.getReportURL(60000);
|
||||
expect(url).to.match(/download/);
|
||||
});
|
||||
});
|
||||
|
||||
// TODO Re-enable the tests after removing Phantom:
|
||||
// https://github.com/elastic/kibana/issues/21485
|
||||
describe.skip('Preserve Layout', () => {
|
||||
it('matches baseline report', async function() {
|
||||
// Generating and then comparing reports can take longer than the default 60s timeout because the comparePngs
|
||||
// function is taking about 15 seconds per comparison in jenkins.
|
||||
this.timeout(360000);
|
||||
|
||||
await PageObjects.reporting.openPdfReportingPanel();
|
||||
await PageObjects.reporting.forceSharedItemsContainerSize({ width: 1405 });
|
||||
await PageObjects.reporting.clickGenerateReportButton();
|
||||
await PageObjects.reporting.removeForceSharedItemsContainerSize();
|
||||
|
||||
await PageObjects.reporting.clickDownloadReportButton(60000);
|
||||
PageObjects.reporting.clearToastNotifications();
|
||||
|
||||
const url = await PageObjects.reporting.getUrlOfTab(1);
|
||||
await PageObjects.reporting.closeTab(1);
|
||||
const reportData = await PageObjects.reporting.getRawPdfReportData(url);
|
||||
|
||||
const reportFileName = 'dashboard_preserve_layout';
|
||||
const sessionReportPath = await writeSessionReport(reportFileName, reportData);
|
||||
|
||||
const percentSimilar = await checkIfPdfsMatch(
|
||||
sessionReportPath,
|
||||
getBaselineReportPath(reportFileName),
|
||||
config.get('screenshots.directory'),
|
||||
log
|
||||
);
|
||||
expect(percentSimilar).to.be.lessThan(0.05);
|
||||
});
|
||||
});
|
||||
|
||||
// FLAKY: https://github.com/elastic/kibana/issues/43131
|
||||
describe.skip('Print PNG button', () => {
|
||||
describe('Print PNG button', () => {
|
||||
it('is not available if new', async () => {
|
||||
await PageObjects.common.navigateToApp('dashboard');
|
||||
await PageObjects.dashboard.clickNewDashboard();
|
||||
await PageObjects.reporting.openPngReportingPanel();
|
||||
await expectDisabledGenerateReportButton();
|
||||
expect(await PageObjects.reporting.isGenerateReportButtonDisabled()).to.be('true');
|
||||
});
|
||||
|
||||
it('becomes available when saved', async () => {
|
||||
await PageObjects.dashboard.saveDashboard('mypngdash');
|
||||
await PageObjects.dashboard.saveDashboard('My PNG Dash');
|
||||
await PageObjects.reporting.openPngReportingPanel();
|
||||
await expectEnabledGenerateReportButton();
|
||||
expect(await PageObjects.reporting.isGenerateReportButtonDisabled()).to.be(null);
|
||||
});
|
||||
});
|
||||
|
||||
// TODO Re-enable the tests after removing Phantom:
|
||||
// https://github.com/elastic/kibana/issues/21485
|
||||
describe.skip('Preserve Layout', () => {
|
||||
it('matches baseline report', async function() {
|
||||
// Generating and then comparing reports can take longer than the default 60s timeout because the comparePngs
|
||||
// function is taking about 15 seconds per comparison in jenkins.
|
||||
this.timeout(360000);
|
||||
|
||||
describe('Preserve Layout', () => {
|
||||
it('Job completes and generates a download URL', async function() {
|
||||
this.timeout(300000);
|
||||
await PageObjects.common.navigateToApp('dashboard');
|
||||
await PageObjects.dashboard.gotoDashboardEditMode('My PNG Dash');
|
||||
await PageObjects.reporting.setTimepickerInDataRange();
|
||||
const visualizations = PageObjects.dashboard.getTestVisualizationNames();
|
||||
|
||||
// There is a current issue causing reports with tilemaps to timeout:
|
||||
// https://github.com/elastic/kibana/issues/14136. Once that is resolved, add the tilemap visualization
|
||||
// back in!
|
||||
const tileMapIndex = visualizations.indexOf('Visualization TileMap');
|
||||
visualizations.splice(tileMapIndex, 1);
|
||||
await PageObjects.dashboard.addVisualizations(visualizations);
|
||||
|
||||
await PageObjects.dashboard.saveDashboard('PNG report test');
|
||||
|
||||
await PageObjects.dashboard.loadSavedDashboard('Ecom Dashboard');
|
||||
await PageObjects.reporting.openPngReportingPanel();
|
||||
await PageObjects.reporting.forceSharedItemsContainerSize({ width: 1405 });
|
||||
await PageObjects.reporting.clickGenerateReportButton();
|
||||
await PageObjects.reporting.removeForceSharedItemsContainerSize();
|
||||
|
||||
await PageObjects.reporting.clickDownloadReportButton(60000);
|
||||
PageObjects.reporting.clearToastNotifications();
|
||||
|
||||
const url = await PageObjects.reporting.getUrlOfTab(1);
|
||||
await PageObjects.reporting.closeTab(1);
|
||||
const reportData = await PageObjects.reporting.getRawPdfReportData(url);
|
||||
|
||||
const reportFileName = 'dashboard_preserve_layout';
|
||||
const sessionReportPath = await writeSessionReport(reportFileName, reportData, 'png');
|
||||
const percentSimilar = await checkIfPngsMatch(
|
||||
sessionReportPath,
|
||||
getBaselineReportPath(reportFileName, 'png'),
|
||||
config.get('screenshots.directory'),
|
||||
log
|
||||
);
|
||||
expect(percentSimilar).to.be.lessThan(0.05);
|
||||
const url = await PageObjects.reporting.getReportURL(60000);
|
||||
expect(url).to.match(/download/);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Discover', () => {
|
||||
// FLAKY: https://github.com/elastic/kibana/issues/31379
|
||||
describe.skip('Generate CSV button', () => {
|
||||
before('initialize tests', async () => {
|
||||
log.debug('ReportingPage:initTests');
|
||||
await esArchiver.loadIfNeeded('reporting/ecommerce');
|
||||
await browser.setWindowSize(1600, 850);
|
||||
});
|
||||
after('clean up archives', async () => {
|
||||
await esArchiver.unload('reporting/ecommerce');
|
||||
});
|
||||
|
||||
describe('Generate CSV button', () => {
|
||||
beforeEach(() => PageObjects.common.navigateToApp('discover'));
|
||||
|
||||
it('is not available if new', async () => {
|
||||
await PageObjects.reporting.openCsvReportingPanel();
|
||||
await expectDisabledGenerateReportButton();
|
||||
expect(await PageObjects.reporting.isGenerateReportButtonDisabled()).to.be('true');
|
||||
});
|
||||
|
||||
it('becomes available when saved', async () => {
|
||||
await PageObjects.discover.saveSearch('my search - expectEnabledGenerateReportButton');
|
||||
await PageObjects.reporting.openCsvReportingPanel();
|
||||
await expectEnabledGenerateReportButton();
|
||||
expect(await PageObjects.reporting.isGenerateReportButtonDisabled()).to.be(null);
|
||||
});
|
||||
|
||||
it('generates a report with data', async () => {
|
||||
await PageObjects.reporting.setTimepickerInDataRange();
|
||||
await PageObjects.discover.saveSearch('my search - with data - expectReportCanBeCreated');
|
||||
await PageObjects.reporting.openCsvReportingPanel();
|
||||
await expectReportCanBeCreated();
|
||||
expect(await PageObjects.reporting.canReportBeCreated()).to.be(true);
|
||||
});
|
||||
|
||||
it('generates a report with no data', async () => {
|
||||
await PageObjects.reporting.setTimepickerInNoDataRange();
|
||||
await PageObjects.discover.saveSearch('my search - no data - expectReportCanBeCreated');
|
||||
await PageObjects.reporting.openCsvReportingPanel();
|
||||
await expectReportCanBeCreated();
|
||||
expect(await PageObjects.reporting.canReportBeCreated()).to.be(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Visualize', () => {
|
||||
before('initialize tests', async () => {
|
||||
log.debug('ReportingPage:initTests');
|
||||
await esArchiver.loadIfNeeded('reporting/ecommerce');
|
||||
await esArchiver.loadIfNeeded('reporting/ecommerce_kibana');
|
||||
await browser.setWindowSize(1600, 850);
|
||||
});
|
||||
after('clean up archives', async () => {
|
||||
await esArchiver.unload('reporting/ecommerce');
|
||||
await esArchiver.unload('reporting/ecommerce_kibana');
|
||||
});
|
||||
|
||||
describe('Print PDF button', () => {
|
||||
it('is not available if new', async () => {
|
||||
await PageObjects.common.navigateToUrl('visualize', 'new');
|
||||
await PageObjects.visualize.clickAreaChart();
|
||||
await PageObjects.visualize.clickNewSearch();
|
||||
await PageObjects.visualize.clickNewSearch('ecommerce');
|
||||
await PageObjects.reporting.openPdfReportingPanel();
|
||||
await expectDisabledGenerateReportButton();
|
||||
expect(await PageObjects.reporting.isGenerateReportButtonDisabled()).to.be('true');
|
||||
});
|
||||
|
||||
it('becomes available when saved', async () => {
|
||||
|
@ -305,34 +167,21 @@ export default function({ getService, getPageObjects }) {
|
|||
await PageObjects.visEditor.clickGo();
|
||||
await PageObjects.visualize.saveVisualization('my viz');
|
||||
await PageObjects.reporting.openPdfReportingPanel();
|
||||
await expectEnabledGenerateReportButton();
|
||||
expect(await PageObjects.reporting.isGenerateReportButtonDisabled()).to.be(null);
|
||||
});
|
||||
|
||||
// TODO Re-enable the tests after removing Phantom:
|
||||
// https://github.com/elastic/kibana/issues/21485
|
||||
it.skip('matches baseline report', async function() {
|
||||
it('Job completes and generates a download URL', async function() {
|
||||
// Generating and then comparing reports can take longer than the default 60s timeout because the comparePngs
|
||||
// function is taking about 15 seconds per comparison in jenkins.
|
||||
this.timeout(180000);
|
||||
|
||||
await PageObjects.common.navigateToApp('dashboard');
|
||||
await PageObjects.dashboard.loadSavedDashboard('Ecom Dashboard');
|
||||
await PageObjects.reporting.openPdfReportingPanel();
|
||||
await PageObjects.reporting.clickGenerateReportButton();
|
||||
await PageObjects.reporting.clickDownloadReportButton(60000);
|
||||
PageObjects.reporting.clearToastNotifications();
|
||||
|
||||
const url = await PageObjects.reporting.getUrlOfTab(1);
|
||||
const reportData = await PageObjects.reporting.getRawPdfReportData(url);
|
||||
|
||||
await PageObjects.reporting.closeTab(1);
|
||||
const reportFileName = 'visualize_print';
|
||||
const sessionReportPath = await writeSessionReport(reportFileName, reportData);
|
||||
const percentSimilar = await checkIfPdfsMatch(
|
||||
sessionReportPath,
|
||||
getBaselineReportPath(reportFileName),
|
||||
config.get('screenshots.directory'),
|
||||
log
|
||||
);
|
||||
expect(percentSimilar).to.be.lessThan(0.05);
|
||||
const url = await PageObjects.reporting.getReportURL(60000);
|
||||
expect(url).to.match(/download/);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Binary file not shown.
Binary file not shown.
Before Width: | Height: | Size: 342 KiB After Width: | Height: | Size: 617 KiB |
Binary file not shown.
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue