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

Typescript-ify screenshot stitcher code in reporting #20061

Conversation

stacey-gammon
Copy link
Contributor

@stacey-gammon stacey-gammon commented Jun 20, 2018

Should be essentially no logic changes, though I called out one place I did modify an API by not sending in information that wasn't used.

To test, set xpack.reporting.capture.browser.type to Chromium and generate some reports.

The test suite doesn't yet cover chromium reports so tests won't catch any issues. Need to fix #19563 first, which was what motivated this PR, to try to make more sense of what is going on.

@stacey-gammon stacey-gammon added :Sharing v7.0.0 v6.4.0 (Deprecated) Feature:Reporting Use Reporting:Screenshot, Reporting:CSV, or Reporting:Framework instead labels Jun 20, 2018
@stacey-gammon stacey-gammon force-pushed the 2018-06-19-typescript-screenshot-stitcher branch from d02a24d to 0068882 Compare June 20, 2018 01:41
@stacey-gammon stacey-gammon changed the title Type-scriptify screenshot stitcher code in reporting Typescript-ify screenshot stitcher code in reporting Jun 20, 2018
*/
export function $combine(
screenshots: Screenshot[],
outputSize: Size,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed this to only take in Size, not Dimension, since the x and y were never used.

* equal to 10, each clip taken, before being zoomed in, should be no bigger than 1 x 1.
* If zoom is 10 and maxDimensionPerClip is 20, then each clip taken before being zoomed in should be no bigger than 2 x 2.
* @param captureScreenshotFn - a function to take a screenshot from the page using the dimensions given. The data
* returned should have dimensions not of the clip passed in, but of the clip passed in multiplied by zoom.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is where the bug is I believe for #19563 - for some reason the captureScreenshotFn is returning data that is too small. We may need to wrap it in a retry, since it seems flaky. Ideally I can figure out why though...

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@stacey-gammon stacey-gammon force-pushed the 2018-06-19-typescript-screenshot-stitcher branch from 68541e0 to 3b2cdec Compare June 20, 2018 13:46
return parseAsObservable(buffer);
},
(screenshot: Screenshot, png: PNG) => {
if (
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is new too, this is to detect earlier the bug in #19563. I simulated an error to verify it is exposed correctly:

screen shot 2018-06-20 at 9 41 50 am

(Note after that screenshot I made slight adjustments to the message).

@stacey-gammon
Copy link
Contributor Author

cc @timroes and @azasypkin - another typescript PR if either of you want to review (not necessary though if you are too busy).

@elasticmachine
Copy link
Contributor

💔 Build Failed

@stacey-gammon
Copy link
Contributor Author

Hmm

13:59:28 [13:59:28] Error: Command failed: /var/lib/jenkins/workspace/elastic+kibana+pull-request+multijob-selenium/kibana/x-pack/node_modules/.bin/tsc --pretty true
13:59:28     at checkExecSyncError (child_process.js:601:13)
13:59:28     at execFileSync (child_process.js:621:13)
13:59:28     at /var/lib/jenkins/workspace/elastic+kibana+pull-request+multijob-selenium/kibana/packages/kbn-plugin-helpers/tasks/build/create_build.js:146:7
13:59:28     at <anonymous>
13:59:28     at process._tickCallback (internal/process/next_tick.js:188:7)
13:59:28 error Command failed with exit code 1.
13:59:28 info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
13:59:28    │ERROR  failure
13:59:28    │ERROR  Error: Command failed: yarn run build
13:59:28    │           at makeError (/var/lib/jenkins/workspace/elastic+kibana+pull-request+multijob-selenium/kibana/packages/kbn-pm/dist/index.js:37840:9)
13:59:28    │           at Promise.all.then.arr (/var/lib/jenkins/workspace/elastic+kibana+pull-request+multijob-selenium/kibana/packages/kbn-pm/dist/index.js:37945:16)
13:59:28    │           at <anonymous>
13:59:28    │           at process._tickCallback (internal/process/next_tick.js:188:7)

Jenkins, test this

@elasticmachine
Copy link
Contributor

💔 Build Failed

@stacey-gammon stacey-gammon force-pushed the 2018-06-19-typescript-screenshot-stitcher branch 2 times, most recently from 205c40a to 2a5840e Compare June 20, 2018 19:10
@elasticmachine
Copy link
Contributor

💔 Build Failed

@elasticmachine
Copy link
Contributor

💔 Build Failed

@stacey-gammon stacey-gammon force-pushed the 2018-06-19-typescript-screenshot-stitcher branch from d6afc41 to bb5b340 Compare June 20, 2018 23:55
@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Copy link
Contributor

@nreese nreese left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm
code review and tested in chrome. Created report using chromium on sample flight data dashboard

@elasticmachine
Copy link
Contributor

💔 Build Failed

@stacey-gammon
Copy link
Contributor Author

failure looks unrelated:
UI Functional Tests.test/functional/apps/visualize/_vega_chart·js.visualize app visualize app vega chart should have some initial vega spec text

jenkins, test this

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@stacey-gammon stacey-gammon merged commit 2c1fcf9 into elastic:master Jun 22, 2018
stacey-gammon added a commit to stacey-gammon/kibana that referenced this pull request Jun 22, 2018
* typescript screenshot stitcher

* Throw an error if the data captured is not of the expected width and height.

* Import babel-core types

* Add babel-core types to x-pack package.json

* Dimensions => Rectangle
Copy link
Member

@azasypkin azasypkin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oooops, I was too slow, just disregard comments I've already left :)


// No types found for this package. May want to investigate an alternative with types.
// @ts-ignore: implicit any for JS file
import $streamToObservable from '@samverschueren/stream-to-observable';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: uggggh, we just should probably write our own analog of https://github.com/Jason3S/rx-stream/blob/master/src/streamToRx.ts at some point.


// Turn the screenshot data into actual PNGs
const pngs$ = Rx.from(screenshots).pipe(
mergeMap(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: it seems mergeMap is deprecated

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please link to that? I don't see any note about deprecation in the docs?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const clips = await $getClips(input.rectangle, input.max)
.pipe(toArray())
.toPromise();
expect(clips.length).toBe(expectedClips.clips.length);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: can't we just replace this:

expect(clips.length).toBe(expectedClips.clips.length);
for (let i = 0; i < clips.length; ++i) {
  expect(clips[i]).toEqual(expectedClips.clips[i]);
}

with that?

expect(clips).toEqual(expectedClips.clips);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those two should be identical.

stacey-gammon added a commit that referenced this pull request Jun 22, 2018
* typescript screenshot stitcher

* Throw an error if the data captured is not of the expected width and height.

* Import babel-core types

* Add babel-core types to x-pack package.json

* Dimensions => Rectangle
@stacey-gammon stacey-gammon deleted the 2018-06-19-typescript-screenshot-stitcher branch July 11, 2018 19:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
(Deprecated) Feature:Reporting Use Reporting:Screenshot, Reporting:CSV, or Reporting:Framework instead v6.4.0 v7.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Chromium: capture png size error
5 participants