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

Continue investigation into capture png size issue #21537

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 16 additions & 24 deletions x-pack/plugins/reporting/server/browsers/chromium/driver/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import moment from 'moment';
import { promisify, delay } from 'bluebird';
import { transformFn } from './transform_fn';
import { ignoreSSLErrorsBehavior } from './ignore_ssl_errors';
import { screenshotStitcher, CapturePngSizeError } from './screenshot_stitcher';
import { screenshotStitcher } from './screenshot_stitcher';

export class HeadlessChromiumDriver {
constructor(client, { maxScreenshotDimension, logger }) {
Expand Down Expand Up @@ -88,30 +88,22 @@ export class HeadlessChromiumDriver {
// https://github.com/elastic/kibana/issues/19563. The reason was never found - it only appeared on ci and
// debug logic right after Page.captureScreenshot to ensure the correct size made the bug disappear.
let retryCount = 0;
const MAX_RETRIES = 3;
while (true) {
try {
return await screenshotStitcher(outputClip, this._zoom, this._maxScreenshotDimension, async screenshotClip => {
const { data } = await Page.captureScreenshot({
clip: {
...screenshotClip,
scale: 1
}
});
this._logger.debug(`Captured screenshot clip ${JSON.stringify(screenshotClip)}`);
return data;
}, this._logger);
} catch (error) {
const isCapturePngSizeError = error instanceof CapturePngSizeError;
if (!isCapturePngSizeError || retryCount === MAX_RETRIES) {
throw error;
} else {
this._logger.error(error.message);
this._logger.error('Trying again...');
retryCount++;
}
}
const MAX_RETRIES = 20;
let returnValue;
while (retryCount < MAX_RETRIES) {
returnValue = await screenshotStitcher(outputClip, this._zoom, this._maxScreenshotDimension, async screenshotClip => {
const { data } = await Page.captureScreenshot({
clip: {
...screenshotClip,
scale: 1
}
});
this._logger.debug(`Captured screenshot clip ${JSON.stringify(screenshotClip)}`);
return data;
}, this._logger);
retryCount++;
}
return returnValue;
}

async _writeData(writePath, base64EncodedData) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export function $combine(
) {
const error = new CapturePngSizeError(png, screenshot.rectangle);
logger.error(error.message);
throw error;
// throw error;
}
return { screenshot, png };
}
Expand All @@ -101,7 +101,9 @@ export function $combine(
logger.debug(`Input png w: ${png.width} and h: ${png.height}`);
logger.debug(`Creating output png with ${JSON.stringify(screenshot.rectangle)}`);
const { rectangle } = screenshot;
png.bitblt(output, 0, 0, rectangle.width, rectangle.height, rectangle.x, rectangle.y);
// if (png.width !== screenshot.rectangle.width || png.height !== screenshot.rectangle.height) {
png.bitblt(output, 0, 0, png.width, png.height, rectangle.x, rectangle.y);
// }
return output;
}, new PNG({ width: outputSize.width, height: outputSize.height }))
);
Expand Down
14 changes: 7 additions & 7 deletions x-pack/scripts/functional_tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@

require('@kbn/plugin-helpers').babelRegister();
require('@kbn/test').runTestsCli([
require.resolve('../test/reporting/configs/chromium_api.js'),
// require.resolve('../test/reporting/configs/chromium_api.js'),
require.resolve('../test/reporting/configs/chromium_functional.js'),
require.resolve('../test/reporting/configs/phantom_api.js'),
require.resolve('../test/reporting/configs/phantom_functional.js'),
require.resolve('../test/functional/config.js'),
require.resolve('../test/api_integration/config.js'),
require.resolve('../test/saml_api_integration/config.js'),
require.resolve('../test/rbac_api_integration/config.js'),
// require.resolve('../test/reporting/configs/phantom_api.js'),
// require.resolve('../test/reporting/configs/phantom_functional.js'),
// require.resolve('../test/functional/config.js'),
// require.resolve('../test/api_integration/config.js'),
// require.resolve('../test/saml_api_integration/config.js'),
// require.resolve('../test/rbac_api_integration/config.js'),
]);
8 changes: 4 additions & 4 deletions x-pack/test/reporting/functional/reporting.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ export default function ({ getService, getPageObjects }) {
});
});

describe('Print Layout', () => {
it.skip('matches baseline report', async function () {
describe.skip('Print 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(180000);
Expand Down Expand Up @@ -117,7 +117,7 @@ export default function ({ getService, getPageObjects }) {
expect(diffCount).to.be.lessThan(128000);
});

it.skip('matches same baseline report with margins turned on', async function () {
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(180000);
Expand Down Expand Up @@ -147,7 +147,7 @@ export default function ({ getService, getPageObjects }) {
});

describe('Preserve Layout', () => {
it.skip('matches baseline report', async function () {
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.
Expand Down