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

Remove file-type dependency via jimp #137214

Merged
merged 30 commits into from
Aug 24, 2022

Conversation

jeramysoucy
Copy link
Contributor

@jeramysoucy jeramysoucy commented Jul 26, 2022

  • Removes jimp and file-type from dependencies.
  • Updates screenshot and PNG test implementations to use sharp (existing dep), pngjs (existing dep), and pixelmatch to remove dependency on jimp and all of jimp's deps. This also resolves issues with resize quality degradation (particularly color muting) - something jimp is known for.
  • Simplifies access to PNG compare functions by introducing a PngService, removing any redundant implementations and passthrough references.

In the process of updating the dependencies I discovered a couple of issues:

  1. The font spacing in CI screenshots differs significantly from (at least my own) local machines. The new image comparison method appears to be more sensitive than what jimp offered, and without changing the acceptable tolerances, some of the dashboard snapshot tests were failing. After consulting with QA, we determined that that new baselines would be generated from CI's screenshots of the failing tests.

  2. Due to a difference in default resizing options between jimp and sharp, some of the dashboard reporting tests were failing. I tracked this down to an aspect ratio difference, which lead to some further investigation. The tolerance for some of the report tests was set to 9%, which is rather high and allows for false passes for images containing a lot of white/empty space. I experimented with lowering this tolerance and also discovered that the large dashboard layout report image was getting generated with defects when rendered by CI. I will be creating issues for the tests contained in the following files, which all include 9% compare tolerances...

  • x-pack/test/functional/apps/maps/group3/reports/index.ts (Geo/Maps team)
  • x-pack/test/examples/reporting_examples/capture_test.ts (App Services)
  • x-pack/test/functional/apps/dashboard/group3/reporting/screenshots.ts (Presentation)
  • x-pack/test/functional/apps/visualize/reporting.ts (Vis Editors)
  • x-pack/test/plugin_functional/test_suites/resolver/index.ts (Sec Solutions)

Updated jimp to 0.16.1.
Updated light & dark dashboard baseline screenshots to resolve failure due to resize degradation.
@jeramysoucy jeramysoucy changed the title Remove file-type from dependancies Remove file-type from dependencies Jul 26, 2022
…luding file-type.

Eliminates quality degradation from image resizing.
@jeramysoucy jeramysoucy self-assigned this Jul 28, 2022
@jeramysoucy jeramysoucy changed the title Remove file-type from dependencies Remove file-type dependency - update screenshot tests Aug 3, 2022
…r dashboard screenshots to 1% for investigation of remaining screens.
Change of forced container width size in large dashboard layout test.
Adjusted forced container width in large dashboard layout test for troubleshooting.
…ting.

Replaced references to dedundant image service with existing, more adopted reporting service.
Ideally, the PNG functions of the reporting service would be merged with the screenshot service as an image service.
…NG compare testing.

Removed redundant implementations and references.
@jeramysoucy jeramysoucy changed the title Remove file-type dependency - update screenshot tests Remove file-type dependency Aug 11, 2022
@jeramysoucy jeramysoucy changed the title Remove file-type dependency Remove file-type dependency via jimp Aug 11, 2022
@jeramysoucy
Copy link
Contributor Author

@elasticmachine merge upstream

@kibanamachine
Copy link
Contributor

merge conflict between base and head

Copy link
Contributor

@LeeDr LeeDr left a comment

Choose a reason for hiding this comment

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

LGTM - I pulled the PR locally and ran some screenshot tests

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.

kibana-gis changes LGTM
code review

Copy link
Contributor

@jloleysens jloleysens left a comment

Choose a reason for hiding this comment

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

Thanks for this refactor @jeramysoucy ! It's looking really great. LGTM from AppServices

test/functional/services/common/png.ts Show resolved Hide resolved
@jeramysoucy jeramysoucy enabled auto-merge (squash) August 24, 2022 17:15
@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

✅ unchanged

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

cc @jeramysoucy

@jeramysoucy jeramysoucy merged commit de9b7c6 into elastic:main Aug 24, 2022
@kibanamachine
Copy link
Contributor

💔 All backports failed

Status Branch Result
7.17 Backport failed because of merge conflicts

You might need to backport the following PRs to 7.17:
- Upgrade micromatch from v3.1.10 to v4.0.5 (#139187)
8.3 Backport failed because of merge conflicts

You might need to backport the following PRs to 8.3:
- Upgrade micromatch from v3.1.10 to v4.0.5 (#139187)
8.4 Backport failed because of merge conflicts

Manual backport

To create the backport manually run:

node scripts/backport --pr 137214

Questions ?

Please refer to the Backport tool documentation

jeramysoucy added a commit to jeramysoucy/kibana that referenced this pull request Aug 24, 2022
* Removed file-type from package.json deps.
Updated jimp to 0.16.1.
Updated light & dark dashboard baseline screenshots to resolve failure due to resize degradation.

* Replaced jimp with sharp and pixelmatch. Eliminates several deps, including file-type.
Eliminates quality degradation from image resizing.

* Fixed copy paste error, which lead to pass positives and errors.

* Integrated updateBaselines flag into dashboards report testing.
Fixed sharp resize to fit and not truncate the original image.

* Removed accidental '.only'

* Reverted area chart baseline.

* Removed explicit declaration of sharp from package.json.

* Adjusted dashboard screenshot size in attempt to eliminate layout scaling issues in CI testing.

* Reverted dashboard screenshot size. Lowered tolerance in dashboard PNG reporting tests to force failure and collect CI screenshots.

* Changed session save location for dashboard report images for better CI reporting.

* Fixed small dashboard baseline screenshot with correct aspect ratio.

* Updated 2 basline screenshots from CI. Lowered PNG match tolerance for dashboard screenshots to 1% for investigation of remaining screens.

* Update of dashboard controls light mode baseline.
Change of forced container width size in large dashboard layout test.

* Updated dashboard controls dark mode baseline screenshot.
Adjusted forced container width in large dashboard layout test for troubleshooting.

* Lowering tolerance of PNG compare tests from 9% to 1% for troubleshooting.
Replaced references to dedundant image service with existing, more adopted reporting service.
Ideally, the PNG functions of the reporting service would be merged with the screenshot service as an image service.

* Reverting tolerance of PNG compares to 0.09. Will create GH issues for specific teams to investigate.

* Implemented PngService to provide an accessible single reference to PNG compare testing.
Removed redundant implementations and references.

* Updated service reference and call to png compare function left out of last commit.

* Updated another missed PNG reference.

* Removed superfluous parameter.

* Update after bootstrap

* Updated area chart baseline to match new render with panel filters.

* Reverted limits in dashboard snapshot tests to original values.

* Merge and rebuild.

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
jeramysoucy added a commit to jeramysoucy/kibana that referenced this pull request Aug 24, 2022
* Removed file-type from package.json deps.
Updated jimp to 0.16.1.
Updated light & dark dashboard baseline screenshots to resolve failure due to resize degradation.

* Replaced jimp with sharp and pixelmatch. Eliminates several deps, including file-type.
Eliminates quality degradation from image resizing.

* Fixed copy paste error, which lead to pass positives and errors.

* Integrated updateBaselines flag into dashboards report testing.
Fixed sharp resize to fit and not truncate the original image.

* Removed accidental '.only'

* Reverted area chart baseline.

* Removed explicit declaration of sharp from package.json.

* Adjusted dashboard screenshot size in attempt to eliminate layout scaling issues in CI testing.

* Reverted dashboard screenshot size. Lowered tolerance in dashboard PNG reporting tests to force failure and collect CI screenshots.

* Changed session save location for dashboard report images for better CI reporting.

* Fixed small dashboard baseline screenshot with correct aspect ratio.

* Updated 2 basline screenshots from CI. Lowered PNG match tolerance for dashboard screenshots to 1% for investigation of remaining screens.

* Update of dashboard controls light mode baseline.
Change of forced container width size in large dashboard layout test.

* Updated dashboard controls dark mode baseline screenshot.
Adjusted forced container width in large dashboard layout test for troubleshooting.

* Lowering tolerance of PNG compare tests from 9% to 1% for troubleshooting.
Replaced references to dedundant image service with existing, more adopted reporting service.
Ideally, the PNG functions of the reporting service would be merged with the screenshot service as an image service.

* Reverting tolerance of PNG compares to 0.09. Will create GH issues for specific teams to investigate.

* Implemented PngService to provide an accessible single reference to PNG compare testing.
Removed redundant implementations and references.

* Updated service reference and call to png compare function left out of last commit.

* Updated another missed PNG reference.

* Removed superfluous parameter.

* Update after bootstrap

* Updated area chart baseline to match new render with panel filters.

* Reverted limits in dashboard snapshot tests to original values.

* Merge and rebuild.

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
(cherry picked from commit de9b7c6)

# Conflicts:
#	package.json
#	test/functional/screenshots/baseline/area_chart.png
#	x-pack/test/reporting_functional/reporting_and_timeout/index.ts
#	yarn.lock
jeramysoucy added a commit to jeramysoucy/kibana that referenced this pull request Aug 24, 2022
* Removed file-type from package.json deps.
Updated jimp to 0.16.1.
Updated light & dark dashboard baseline screenshots to resolve failure due to resize degradation.

* Replaced jimp with sharp and pixelmatch. Eliminates several deps, including file-type.
Eliminates quality degradation from image resizing.

* Fixed copy paste error, which lead to pass positives and errors.

* Integrated updateBaselines flag into dashboards report testing.
Fixed sharp resize to fit and not truncate the original image.

* Removed accidental '.only'

* Reverted area chart baseline.

* Removed explicit declaration of sharp from package.json.

* Adjusted dashboard screenshot size in attempt to eliminate layout scaling issues in CI testing.

* Reverted dashboard screenshot size. Lowered tolerance in dashboard PNG reporting tests to force failure and collect CI screenshots.

* Changed session save location for dashboard report images for better CI reporting.

* Fixed small dashboard baseline screenshot with correct aspect ratio.

* Updated 2 basline screenshots from CI. Lowered PNG match tolerance for dashboard screenshots to 1% for investigation of remaining screens.

* Update of dashboard controls light mode baseline.
Change of forced container width size in large dashboard layout test.

* Updated dashboard controls dark mode baseline screenshot.
Adjusted forced container width in large dashboard layout test for troubleshooting.

* Lowering tolerance of PNG compare tests from 9% to 1% for troubleshooting.
Replaced references to dedundant image service with existing, more adopted reporting service.
Ideally, the PNG functions of the reporting service would be merged with the screenshot service as an image service.

* Reverting tolerance of PNG compares to 0.09. Will create GH issues for specific teams to investigate.

* Implemented PngService to provide an accessible single reference to PNG compare testing.
Removed redundant implementations and references.

* Updated service reference and call to png compare function left out of last commit.

* Updated another missed PNG reference.

* Removed superfluous parameter.

* Update after bootstrap

* Updated area chart baseline to match new render with panel filters.

* Reverted limits in dashboard snapshot tests to original values.

* Merge and rebuild.

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
(cherry picked from commit de9b7c6)

# Conflicts:
#	package.json
#	test/functional/screenshots/baseline/area_chart.png
#	test/functional/screenshots/baseline/dashboard_controls_dark.png
#	test/functional/screenshots/baseline/dashboard_controls_light.png
#	test/functional/services/lib/compare_pngs.ts
#	x-pack/test/functional/apps/dashboard/group3/reporting/reports/baseline/small_dashboard_preserve_layout.png
#	x-pack/test/functional/apps/dashboard/reporting/screenshots.ts
#	x-pack/test/functional/apps/maps/group3/reports/index.ts
#	x-pack/test/functional/services/index.ts
#	x-pack/test/reporting_functional/reporting_and_timeout/index.ts
#	x-pack/test/reporting_functional/services/scenarios.ts
#	yarn.lock
@jeramysoucy
Copy link
Contributor Author

💚 All backports created successfully

Status Branch Result
8.4
8.3
7.17

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

@kibanamachine
Copy link
Contributor

Looks like this PR has backport PRs but they still haven't been merged. Please merge them ASAP to keep the branches relatively in sync.

@kibanamachine kibanamachine added the backport missing Added to PRs automatically when the are determined to be missing a backport. label Aug 25, 2022
@kibanamachine
Copy link
Contributor

Looks like this PR has backport PRs but they still haven't been merged. Please merge them ASAP to keep the branches relatively in sync.

jeramysoucy added a commit that referenced this pull request Aug 29, 2022
* Remove file-type dependency via jimp (#137214)

* Removed file-type from package.json deps.
Updated jimp to 0.16.1.
Updated light & dark dashboard baseline screenshots to resolve failure due to resize degradation.

* Replaced jimp with sharp and pixelmatch. Eliminates several deps, including file-type.
Eliminates quality degradation from image resizing.

* Fixed copy paste error, which lead to pass positives and errors.

* Integrated updateBaselines flag into dashboards report testing.
Fixed sharp resize to fit and not truncate the original image.

* Removed accidental '.only'

* Reverted area chart baseline.

* Removed explicit declaration of sharp from package.json.

* Adjusted dashboard screenshot size in attempt to eliminate layout scaling issues in CI testing.

* Reverted dashboard screenshot size. Lowered tolerance in dashboard PNG reporting tests to force failure and collect CI screenshots.

* Changed session save location for dashboard report images for better CI reporting.

* Fixed small dashboard baseline screenshot with correct aspect ratio.

* Updated 2 basline screenshots from CI. Lowered PNG match tolerance for dashboard screenshots to 1% for investigation of remaining screens.

* Update of dashboard controls light mode baseline.
Change of forced container width size in large dashboard layout test.

* Updated dashboard controls dark mode baseline screenshot.
Adjusted forced container width in large dashboard layout test for troubleshooting.

* Lowering tolerance of PNG compare tests from 9% to 1% for troubleshooting.
Replaced references to dedundant image service with existing, more adopted reporting service.
Ideally, the PNG functions of the reporting service would be merged with the screenshot service as an image service.

* Reverting tolerance of PNG compares to 0.09. Will create GH issues for specific teams to investigate.

* Implemented PngService to provide an accessible single reference to PNG compare testing.
Removed redundant implementations and references.

* Updated service reference and call to png compare function left out of last commit.

* Updated another missed PNG reference.

* Removed superfluous parameter.

* Update after bootstrap

* Updated area chart baseline to match new render with panel filters.

* Reverted limits in dashboard snapshot tests to original values.

* Merge and rebuild.

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>

* Update to dashboard screen test area chart baseline.

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
jeramysoucy added a commit that referenced this pull request Aug 29, 2022
* Remove file-type dependency via jimp (#137214)

* Removed file-type from package.json deps.
Updated jimp to 0.16.1.
Updated light & dark dashboard baseline screenshots to resolve failure due to resize degradation.

* Replaced jimp with sharp and pixelmatch. Eliminates several deps, including file-type.
Eliminates quality degradation from image resizing.

* Fixed copy paste error, which lead to pass positives and errors.

* Integrated updateBaselines flag into dashboards report testing.
Fixed sharp resize to fit and not truncate the original image.

* Removed accidental '.only'

* Reverted area chart baseline.

* Removed explicit declaration of sharp from package.json.

* Adjusted dashboard screenshot size in attempt to eliminate layout scaling issues in CI testing.

* Reverted dashboard screenshot size. Lowered tolerance in dashboard PNG reporting tests to force failure and collect CI screenshots.

* Changed session save location for dashboard report images for better CI reporting.

* Fixed small dashboard baseline screenshot with correct aspect ratio.

* Updated 2 basline screenshots from CI. Lowered PNG match tolerance for dashboard screenshots to 1% for investigation of remaining screens.

* Update of dashboard controls light mode baseline.
Change of forced container width size in large dashboard layout test.

* Updated dashboard controls dark mode baseline screenshot.
Adjusted forced container width in large dashboard layout test for troubleshooting.

* Lowering tolerance of PNG compare tests from 9% to 1% for troubleshooting.
Replaced references to dedundant image service with existing, more adopted reporting service.
Ideally, the PNG functions of the reporting service would be merged with the screenshot service as an image service.

* Reverting tolerance of PNG compares to 0.09. Will create GH issues for specific teams to investigate.

* Implemented PngService to provide an accessible single reference to PNG compare testing.
Removed redundant implementations and references.

* Updated service reference and call to png compare function left out of last commit.

* Updated another missed PNG reference.

* Removed superfluous parameter.

* Update after bootstrap

* Updated area chart baseline to match new render with panel filters.

* Reverted limits in dashboard snapshot tests to original values.

* Merge and rebuild.

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
(cherry picked from commit de9b7c6)

# Conflicts:
#	package.json
#	test/functional/screenshots/baseline/area_chart.png
#	test/functional/screenshots/baseline/dashboard_controls_dark.png
#	test/functional/screenshots/baseline/dashboard_controls_light.png
#	test/functional/services/lib/compare_pngs.ts
#	x-pack/test/functional/apps/dashboard/group3/reporting/reports/baseline/small_dashboard_preserve_layout.png
#	x-pack/test/functional/apps/dashboard/reporting/screenshots.ts
#	x-pack/test/functional/apps/maps/group3/reports/index.ts
#	x-pack/test/functional/services/index.ts
#	x-pack/test/reporting_functional/reporting_and_timeout/index.ts
#	x-pack/test/reporting_functional/services/scenarios.ts
#	yarn.lock

* [CI] Auto-commit changed files from 'yarn kbn run build -i @kbn/pm'

* Update to dashboard screenshot functional tests to correct merge errors.

* Removed unintentionally added test.

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
@jeramysoucy jeramysoucy removed the backport missing Added to PRs automatically when the are determined to be missing a backport. label Aug 30, 2022
Mpdreamz pushed a commit to Mpdreamz/kibana that referenced this pull request Sep 6, 2022
* Removed file-type from package.json deps.
Updated jimp to 0.16.1.
Updated light & dark dashboard baseline screenshots to resolve failure due to resize degradation.

* Replaced jimp with sharp and pixelmatch. Eliminates several deps, including file-type.
Eliminates quality degradation from image resizing.

* Fixed copy paste error, which lead to pass positives and errors.

* Integrated updateBaselines flag into dashboards report testing.
Fixed sharp resize to fit and not truncate the original image.

* Removed accidental '.only'

* Reverted area chart baseline.

* Removed explicit declaration of sharp from package.json.

* Adjusted dashboard screenshot size in attempt to eliminate layout scaling issues in CI testing.

* Reverted dashboard screenshot size. Lowered tolerance in dashboard PNG reporting tests to force failure and collect CI screenshots.

* Changed session save location for dashboard report images for better CI reporting.

* Fixed small dashboard baseline screenshot with correct aspect ratio.

* Updated 2 basline screenshots from CI. Lowered PNG match tolerance for dashboard screenshots to 1% for investigation of remaining screens.

* Update of dashboard controls light mode baseline.
Change of forced container width size in large dashboard layout test.

* Updated dashboard controls dark mode baseline screenshot.
Adjusted forced container width in large dashboard layout test for troubleshooting.

* Lowering tolerance of PNG compare tests from 9% to 1% for troubleshooting.
Replaced references to dedundant image service with existing, more adopted reporting service.
Ideally, the PNG functions of the reporting service would be merged with the screenshot service as an image service.

* Reverting tolerance of PNG compares to 0.09. Will create GH issues for specific teams to investigate.

* Implemented PngService to provide an accessible single reference to PNG compare testing.
Removed redundant implementations and references.

* Updated service reference and call to png compare function left out of last commit.

* Updated another missed PNG reference.

* Removed superfluous parameter.

* Update after bootstrap

* Updated area chart baseline to match new render with panel filters.

* Reverted limits in dashboard snapshot tests to original values.

* Merge and rebuild.

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
@jeramysoucy jeramysoucy deleted the remove-file-type-dep branch February 2, 2023 16:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:prev-MAJOR Backport to the previous major branch (7.x) and all later branches still in development release_note:skip Skip the PR/issue when compiling release notes Team:Security Team focused on: Auth, Users, Roles, Spaces, Audit Logging, and more! v7.17.7 v8.4.1 v8.5.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants