Skip to content
This repository was archived by the owner on Aug 8, 2023. It is now read-only.

[node] Added render test suite implementation that recycles the map object#9689

Merged
brunoabinader merged 7 commits into
masterfrom
node-test-render-recycle-map
Aug 31, 2017
Merged

[node] Added render test suite implementation that recycles the map object#9689
brunoabinader merged 7 commits into
masterfrom
node-test-render-recycle-map

Conversation

@brunoabinader
Copy link
Copy Markdown
Contributor

@brunoabinader brunoabinader commented Aug 2, 2017

This PR:

  • Splits test-suite target using npm-run-all's run-s script to run individual scripts in sequence.
  • Adds --recycle-map option to the render test that recycles the map object among test runs.

@brunoabinader brunoabinader added Node.js node-mapbox-gl-native tests labels Aug 2, 2017
@brunoabinader brunoabinader requested a review from kkaefer August 2, 2017 15:42
@brunoabinader
Copy link
Copy Markdown
Contributor Author

brunoabinader commented Aug 2, 2017

* failed background-pattern @2x - ~~~this means we should be able to update the sprite loader pixel ratio e.g. by recreating a sprite loader object inside Style::Impl.~~~
We cannot update the pixel ratio from a map object once it is created - this means we might need to have different instances of the map object for different pixel ratio values.

kkaefer
kkaefer previously requested changes Aug 3, 2017
@@ -0,0 +1,118 @@
'use strict';
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Instead of duplicating this file, can you please add the changes to the original suite_implementation and add a command line argument to toggle between the two variants? It looks like the majority of the code is the same.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Comment thread package.json Outdated
"dependencies": {
"nan": "^2.4.0",
"node-pre-gyp": "^0.6.28",
"nan": "^2.4.0"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nit: Reduce diff size

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Oh, I think yarn automatically sorts packages in alphabetical order when inserting new dependencies.

@brunoabinader brunoabinader force-pushed the node-test-render-recycle-map branch 4 times, most recently from 8e994ec to 2058749 Compare August 4, 2017 10:16
@brunoabinader brunoabinader force-pushed the node-test-render-recycle-map branch from 2058749 to ac43003 Compare August 4, 2017 10:18
@brunoabinader
Copy link
Copy Markdown
Contributor Author

brunoabinader commented Aug 4, 2017

Results are in!

Render test (current) Render test (--recycle-map)
real 1m54.190s 1m0.672s
user 2m12.828s 1m11.892s
sys 0m2.296s 0m1.472s

So far the main obstacles were:

  • Once a Map object is created with a given pixel ratio, it is currently not possible to modify its value. Thus, we need a map of Map objects, one per pixel ratio.
  • Not every render test calls for setStyle - in those cases, left overs in the Style::Impl e.g. added images can cause rendering artifacts on the next test run. Thus, we need to somehow clear the style e.g. by setting an empty JSON as in map.load("{}");. Even though we're eventually loading a new style on each test run, it seems the state cleanup made in Style::Impl::parse is not enough.

Caveats:

  • Because both render tests runs outputs the results to the same HTML file (in render-tests/index.html), only the last render test run is stored as artifact in CircleCI. We might want to either rename the recycling map render test to something else, have two separate HTML files for each run, or select one of the two test runs as base.

What's left:

  • Node v4 does not properly lookup for inherited dependencies e.g. mapbox-gl-styles is a dependency for @mapbox/mapbox-gl-test-suite (included in package.json), but it is not being installed as should (this works fine in Node v6)
  • Crash in style parsing in Node v4 (due to the lack of the core style file above):
* passed background-visibility visible
[Error: Failed to parse style: 0 - Invalid value.]
ERROR (ParseStyle): Failed to parse style: 0 - Invalid value.

@brunoabinader brunoabinader force-pushed the node-test-render-recycle-map branch from ac43003 to e2ce61e Compare August 4, 2017 11:10
@brunoabinader
Copy link
Copy Markdown
Contributor Author

Render tests now pass locally on both macOS and Linux. This indicates the test failures mentioned in #9689 (comment) could be caused by a race condition when fetching data from local resources.

@brunoabinader
Copy link
Copy Markdown
Contributor Author

Last known open bug found by this PR is described in #9868 - which concerns some occasional render test failures in geojson/external-* tests.

Comment thread package.json Outdated
"test": "tape platform/node/test/js/**/*.test.js",
"test-memory": "node --expose-gc platform/node/test/memory.test.js",
"test-suite": "node platform/node/test/render.test.js && node platform/node/test/query.test.js"
"test-suite": "run-s test-render \"test-render -- --recycle-map\" test-query",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This will overwrite the artifacts from the first test-render run with those from the test-render --recycle-map run. Might be confusing/make it hard to debug.

Also, looks like we've roughly doubled the performance of render tests, but are giving that right back by running them twice. Should we parallelize this somehow? For instance we could run one variant in each of the two node 6 builds.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Let's make it so then that tests results run via --recycle-map will be saved in index-recycle-map.html then.

I'm also 👍 in having e.g. node6-debug running tests with --recycle-map while node6-release runs them as usual.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is now done in GL JS side via mapbox/mapbox-gl-js#5195. I'll update this PR accordingly.

@brunoabinader brunoabinader force-pushed the node-test-render-recycle-map branch from 7c4a443 to 648e73c Compare August 28, 2017 15:44
@brunoabinader brunoabinader force-pushed the node-test-render-recycle-map branch from 648e73c to 130c241 Compare August 28, 2017 17:57
@lbud
Copy link
Copy Markdown
Contributor

lbud commented Aug 28, 2017

@brunoabinader I merged #9489 so the icon-anchor ignores can be removed now 👍

@brunoabinader brunoabinader force-pushed the node-test-render-recycle-map branch from 130c241 to c3df47f Compare August 28, 2017 22:20
@brunoabinader
Copy link
Copy Markdown
Contributor Author

Thanks @lbud! PR is updated now.

@brunoabinader brunoabinader force-pushed the node-test-render-recycle-map branch 2 times, most recently from bf23aa9 to ab16876 Compare August 29, 2017 12:11
@brunoabinader brunoabinader force-pushed the node-test-render-recycle-map branch 3 times, most recently from f7969cb to 3bd440a Compare August 30, 2017 13:07
@brunoabinader
Copy link
Copy Markdown
Contributor Author

@kkaefer @jfirebaugh can you please re-review?

@brunoabinader brunoabinader force-pushed the node-test-render-recycle-map branch from 3bd440a to f3b7553 Compare August 30, 2017 13:44
@brunoabinader
Copy link
Copy Markdown
Contributor Author

By the way, though I've added the option to shuffle the render test sequence, I'm going to enable it on CI on a further PR - which also includes implementing --seed.

Copy link
Copy Markdown
Contributor

@jfirebaugh jfirebaugh left a comment

Choose a reason for hiding this comment

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

LGTM other than one question.

Comment thread platform/node/test/ignores.json Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

#9704 is closed -- is this ignore still necessary?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

You're right - this is no longer necessary 👍 removing

@brunoabinader brunoabinader dismissed kkaefer’s stale review August 31, 2017 06:29

Based on a previous change proposal.

@brunoabinader brunoabinader force-pushed the node-test-render-recycle-map branch from f3b7553 to ff6acdc Compare August 31, 2017 06:47
@brunoabinader brunoabinader merged commit 0694d22 into master Aug 31, 2017
@brunoabinader brunoabinader deleted the node-test-render-recycle-map branch August 31, 2017 07:17
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Core The cross-platform C++ core, aka mbgl Node.js node-mapbox-gl-native tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants