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

Add a set of "chaos monkey" tests for rehydration. #991

Merged
merged 1 commit into from
Feb 21, 2020

Conversation

rwjblue
Copy link
Member

@rwjblue rwjblue commented Nov 7, 2019

Based on an idea that @krisselden and I had while working on #988 this adds tests that run a number of iterations removing a random node, and confirming that the final rehydrated (e.g. client rendered) HTML is correct.

In order to make these tests actionable the infrastructure added here provides a way to replicate specific iterations upon failure. The way this works is based on QUnit's internal QUnit.config.seed implementation. When a QUnit test suite is ran with the seed query param set (with no value e.g. /tests/index.html?hidepassed&seed), QUnit will choose a random seed and use that seed to choose a randomized test order. Then if a failure occurs with the randomized and seeded test run, you can run the tests again with exactly that seed value by
specifying the seed query param with the failing seed value (e.g. /tests/index.html?hidepassed&seed=THEVALUEHERE). The implementation here piggie backs on that system to use the QUnit's seed value (along with a copied version of their hashing function
and seeded randomizer) in addition to the iteration being ran to always select a "known value" to remove. This means that given the correct seed (and iteration number) we can easily replicate specific failure scenarios without manually having to track it down.

The way you'd do this is:

  1. Run the tests with /tests/index.html?hidepassed&seed until a failure occurs.
  2. Look at the failed tests assertion, grab the rerun URL printed in the failed assertion.
  3. Run the tests again with that set of query params (e.g. /tests/index.html?hidepassed&seed=SEED_HERE&iteration=ITERATION_HERE).

Currently includes the changes from #988, but will rebase once that lands.

@rwjblue rwjblue force-pushed the chaos-monkey branch 3 times, most recently from 69862b3 to 62515c6 Compare November 7, 2019 17:30
@rwjblue
Copy link
Member Author

rwjblue commented Nov 7, 2019

Some ideas that @krisselden just mentioned to me in DM:

  • have the system randomly insert unexpected nodes (at somewhat arbitrary depths)
  • have the system randomly mutate nodeValue of text nodes and comments (including our "special" comments)

@krisselden
Copy link
Contributor

is this still a WIP?

@rwjblue
Copy link
Member Author

rwjblue commented Feb 19, 2020

Thanks for the reminder @krisselden, rebased and updated. Should be good to land once green.

@rwjblue rwjblue marked this pull request as ready for review February 19, 2020 20:34
This adds tests that run a number of iterations removing a random node,
and confirming that the final rehydrated (e.g. client rendered) HTML is
correct.

In order to make these tests actionable the infrastructure added here
provides a way to replicate _specific_ iterations upon failure. The way
this works is based on QUnit's internal `QUnit.config.seed`
implementation. When a `QUnit` test suite is ran with the `seed` query
param set (with no value e.g. `/tests/index.html?hidepassed&seed`),
QUnit will choose a random seed and use that seed to choose a randomized
test order. Then if a failure occurs with the randomized and seeded test
run, you can run the tests again with **exactly** that seed value by
specifying the `seed` query param _with_ the failing seed value (e.g.
`/tests/index.html?hidepassed&seed=THEVALUEHERE`). The implementation
here piggie backs on that system to use the QUnit's seed value (along
with a copied version of their [hashing
function](qunitjs/qunit:src/core/utilities.js@2.9.3#L144-L158)
and [seeded
randomizer](qunitjs/qunit:src/core/processing-queue.js@2.9.3#L134-L154))
in addition to the iteration being ran to always select a "known value"
to remove. This means that given the correct seed (and iteration number)
we can easily replicate **specific** failure scenarios without manually
having to track it down.

The way you'd do this is:

1. Run the tests with `/tests/index.html?hidepassed&seed` until a
   failure occurs.
2. Look at the failed tests assertion, grab the rerun URL printed in the
   failed assertion.
3. Run the tests again with that set of query params (e.g.
   `/tests/index.html?hidepassed&seed=SEED_HERE&iteration=ITERATION_HERE`).
@krisselden krisselden merged commit 1d8b7c7 into glimmerjs:master Feb 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants