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

try Stryker (v2) testing, for evaluation, etc. - outdated #16

Draft
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

brodycj
Copy link
Owner

@brodycj brodycj commented Nov 13, 2019

This is an attempt to start using Stryker Mutator for mutation testing of Prettier, as a continuation of prettier#6681.

I am adding Stryker as described in https://stryker-mutator.io/stryker/quickstart but with a few tweaks & updates:

  • switch to testRunner: "command" in stryker.conf.js (and remove @stryker-mutator/jest-runner from devDependencies) - seems to be needed to to avoid excessive surviving mutation test runs, which seems to happen when using testRunner: "jest" in stryker.conf.js
  • set test timeout to 15 minutes in stryker.conf.js
  • only mutate sources in src/common for now
  • add "use strict"; line to stryker.conf.js to make eslint happy
  • add generated Stryker artifacts to .gitignore
  • add stryker entry to package scripts

At this point I was able to start Stryker testing on src/common/*.js on a virtual server in the cloud, with 40 (virtual) CPUs. After about 1.5 hours, Stryker claims ETC in just under 2.5 more hours.

I started with nohup & tee on the command line for increased resilience against any possible network connection issues:

nohup yarn stryker | tee stryker-src-common-progress-log.txt &

Here is the command to watch the progress log if needed after disconnecting:

tail -F stryker-src-common-progress-log.txt

As I said in prettier#6681 (prettier#6681 (comment)), I encountered some issues with running Stryker on combinations such as src/common/*.js, src/language-js/*.js, and src/utils/*.js. I would really love to see some improvements in support for this kind of combination.

I was already able to generate a now outdated report on src/cli (https://chrisbrody.com/prettier-cli-mutation-report/index.html) in prettier#6681. I think it would be much more useful to go through a report on src/common and src/language-js first.

So far I found a few things that could probably be improved on Stryker:

  • show some more information in the progress output such as elapsed testing time (even more informative progress reporting for long-running testing stryker-mutator/stryker-js#1844)
  • resolve issue with using standard testRunner: "jest" setting in stryker.conf.js
  • support testing large numbers of mutations on parallel servers
  • HTML reports could probably use some improvements on larger source trees, such as:
    • show the actual tree in index.html
    • show line numbers for each of the source files
    • seems to dynamically render source mutation report, seems to be a bit sluggish on larger files; static HTML report for each source file would likely be much nicer

Christopher J. Brody added 4 commits November 13, 2019 18:18
using npx:

$ npx stryker init

to initialize testing with Stryker (version 2.3.0)

(with jest runner, on JavaScript code)

with HTML reporter included

and with Yarn package manager selected

as documented in: https://stryker-mutator.io/stryker/quickstart

NOTE that the generated `stryker.conf.js` has a known eslint error
at this point, to be resolved in an upcoming commit
(in the very near future).

Here is a capture of the `stryker init` work from the command line,
for future reference:

$ npx stryker init
? Are you using one of these frameworks? Then select a preset configuration. None/other
? Which test runner do you want to use? If your test runner isn't listed here, you can choose "command" (it uses your `npm test` command, but will come with a big performance penalty) jest
No stryker test framework plugin found that is compatible with jest, downgrading coverageAnalysis to "all"
? What kind of code do you want to mutate? javascript
? [optional] What kind transformations should be applied to your code?
? Which reporter(s) do you want to use? html, clear-text, progress
? Which package manager do you want to use? yarn
Writing & formatting stryker.conf.js...
Installing NPM dependencies...
yarn add @stryker-mutator/jest-runner @stryker-mutator/javascript-mutator @stryker-mutator/html-reporter --dev
yarn add v1.19.1
[1/5] Validating package.json...
[2/5] Resolving packages...
[3/5] Fetching packages...
info fsevents@1.2.9: The platform "linux" is incompatible with this module.
info "fsevents@1.2.9" is an optional dependency and failed compatibility check. Excluding it from installation.
[4/5] Linking dependencies...
warning " > angular-estree-parser@1.1.5" has incorrect peer dependency "@angular/compiler@^6.0.0 || ^7.0.0".
[5/5] Building fresh packages...
success Saved lockfile.
success Saved 6 new dependencies.
info Direct dependencies
├─ @stryker-mutator/html-reporter@2.3.0
├─ @stryker-mutator/javascript-mutator@2.3.0
└─ @stryker-mutator/jest-runner@2.3.0
info All dependencies
├─ @stryker-mutator/html-reporter@2.3.0
├─ @stryker-mutator/javascript-mutator@2.3.0
├─ @stryker-mutator/jest-runner@2.3.0
├─ file-url@3.0.0
├─ lodash.clonedeep@4.5.0
└─ mutation-testing-elements@1.2.0
Done in 5.20s.
Done configuring stryker. Please review `stryker.conf.js`, you might need to configure transpilers or your test runner correctly.
Let's kill some mutants with this command: `stryker run`
Note: Stryker will use `.stryker-temp` as location for temporary files. Be sure to add it to your ignored files in source control.
for now, at least

This seems to be needed to avoid excessive surviving mutation test runs,
which seems to happen when using `testRunner: "jest"`
in stryker.conf.js.
@brodycj brodycj self-assigned this Nov 13, 2019
@brodycj
Copy link
Owner Author

brodycj commented Nov 13, 2019

Some bad news: after about 3 hours the following shows up at the end of stryker-src-common-progress-log.txt:

Mutation testing 72% (ETC 1h, 8m, 58s) 857/1186 tested (152 survived, 59 timed out)
Mutation testing 72% (ETC 1h, 9m, 2s) 857/1186 tested (152 survived, 59 timed out)
Mutation testing 72% (ETC 1h, 9m, 6s) 857/1186 tested (152 survived, 59 timed out)
Mutation testing 72% (ETC 1h, 9m, 9s) 857/1186 tested (152 survived, 59 timed out)
Mutation testing 72% (ETC 1h, 9m, 13s) 857/1186 tested (152 survived, 59 timed out)
Mutation testing 72% (ETC 1h, 9m, 17s) 857/1186 tested (152 survived, 59 timed out)
Mutation testing 72% (ETC 1h, 9m, 21s) 857/1186 tested (152 survived, 59 timed out)
Killed
error Command failed with exit code 137.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

From a quick search this looks like something ran out of memory. I wonder if using something like node --max-old-space-size=40000 may help as discussed in prettier#6681 (comment) & stryker-mutator/stryker-js#1284 (comment).

@brodycj brodycj force-pushed the try-stryker-testing branch from a7ce7ee to 6d597ce Compare November 13, 2019 23:07
@brodycj
Copy link
Owner Author

brodycj commented Nov 13, 2019

Trying now with the following command on a virtual server with 40 (virtual) CPUs and 160 GB memory available:

nohup node --max-old-space-size=100000 `which yarn` stryker | tee stryker-src-common-progress-output.txt &

(with slightly different progress output file name this time)

The --max-old-space-size is probably a bit excessive, for finer tuning if it solves the issue with the Yarn exit code.

P.S. I realized that something like this may be better:

nohup node --max-old-space-size=100000 ./node_modules/.bin/stryker run | tee node-stryker-src-common-progress-output.txt &

I started a Stryker testing run with this in parallel to the other nohup command above in this comment. I will report with some more explanation once I get some results if either or both of these commands gives me a successful Stryker testing run on src/common/*.js.

@brodycj
Copy link
Owner Author

brodycj commented Nov 14, 2019

The HTML mutation report generated by

nohup node --max-old-space-size=100000 `which yarn` stryker

is now posted at: https://chrisbrody.com/prettier-src-common-mutation-report-2019-11-13/

Report generated by nohup node --max-old-space-size=100000 ./node_modules/.bin/stryker run should be available within the next hour.

So using the node command with the --max-old-space-size setting does seems to resolve the issue with the Yarn exit code. I suspect the value I used is excessive, would like to fine tune it (someday).

P.S. I think the one major thing missing test coverage in the language-js processing path is the internal guessEndOfLine function in src/common/end-of-line.js.

@brodycj
Copy link
Owner Author

brodycj commented Nov 14, 2019

One more observation I have is that almost half an hour after the report by this command is finished:

nohup node --max-old-space-size=100000 `which yarn` stryker | tee stryker-src-common-progress-output.txt &

ps -ef continues to show me some Node.js processes still running:

brodybi+  1599  1598  0 Nov13 pts/0    00:00:00 -bash
root     11653     2  0 00:00 ?        00:00:00 [kworker/1:0-rcu_par_gp]
root     11678     2  0 00:00 ?        00:00:00 [kworker/2:0]
root     11698     2  0 00:00 ?        00:00:07 [kworker/38:0-mm_percpu_wq]
brodybi+ 12238     1 33 01:01 pts/0    01:10:55 /home/brodybits/nvs/node/12.13.0/x64/bin/node /home/brodybits/prettier/node_modules/jest-worker/build/child.js
brodybi+ 12353     1 33 01:01 pts/0    01:10:51 /home/brodybits/nvs/node/12.13.0/x64/bin/node /home/brodybits/prettier/node_modules/jest-worker/build/child.js
brodybi+ 12458     1 33 01:01 pts/0    01:10:38 /home/brodybits/nvs/node/12.13.0/x64/bin/node /home/brodybits/prettier/node_modules/jest-worker/build/child.js
root     14199     2  0 Nov13 ?        00:00:00 [kworker/39:1]
brodybi+ 16044     1 34 01:13 pts/0    01:08:40 /home/brodybits/nvs/node/12.13.0/x64/bin/node /home/brodybits/prettier/node_modules/jest-worker/build/child.js
brodybi+ 17177     1 21 Nov13 pts/0    01:04:49 /home/brodybits/nvs/node/12.13.0/x64/bin/node /home/brodybits/prettier/node_modules/jest-worker/build/child.js
brodybi+ 18448     1 30 00:48 pts/0    01:09:20 /home/brodybits/nvs/node/12.13.0/x64/bin/node /home/brodybits/prettier/node_modules/jest-worker/build/child.js
brodybi+ 18506     1 30 00:48 pts/0    01:08:50 /home/brodybits/nvs/node/12.13.0/x64/bin/node /home/brodybits/prettier/node_modules/jest-worker/build/child.js
brodybi+ 18529     1 30 00:48 pts/0    01:09:10 /home/brodybits/nvs/node/12.13.0/x64/bin/node /home/brodybits/prettier/node_modules/jest-worker/build/child.js
brodybi+ 19632     1 30 00:49 pts/0    01:09:10 /home/brodybits/nvs/node/12.13.0/x64/bin/node /home/brodybits/prettier/node_modules/jest-worker/build/child.js
brodybi+ 19933     1 31 00:50 pts/0    01:11:05 /home/brodybits/nvs/node/12.13.0/x64/bin/node /home/brodybits/prettier/node_modules/jest-worker/build/child.js
root     20454     2  0 00:26 ?        00:00:06 [kworker/32:0-mm_percpu_wq]
brodybi+ 23978     1 31 00:54 pts/0    01:09:40 /home/brodybits/nvs/node/12.13.0/x64/bin/node /home/brodybits/prettier/node_modules/jest-worker/build/child.js
brodybi+ 28072     1 15 Nov13 pts/0    00:45:28 /home/brodybits/nvs/node/12.13.0/x64/bin/node /home/brodybits/prettier/node_modules/jest-worker/build/child.js
brodybi+ 28198     1 17 Nov13 pts/0    00:51:40 /home/brodybits/nvs/node/12.13.0/x64/bin/node /home/brodybits/prettier/node_modules/jest-worker/build/child.js
brodybi+ 28208     1 17 Nov13 pts/0    00:50:50 /home/brodybits/nvs/node/12.13.0/x64/bin/node /home/brodybits/prettier/node_modules/jest-worker/build/child.js
brodybi+ 28236     1 18 Nov13 pts/0    00:51:48 /home/brodybits/nvs/node/12.13.0/x64/bin/node /home/brodybits/prettier/node_modules/jest-worker/build/child.js
brodybi+ 28284     1 18 Nov13 pts/0    00:52:19 /home/brodybits/nvs/node/12.13.0/x64/bin/node /home/brodybits/prettier/node_modules/jest-worker/build/child.js
brodybi+ 28350     1 16 Nov13 pts/0    00:46:22 /home/brodybits/nvs/node/12.13.0/x64/bin/node /home/brodybits/prettier/node_modules/jest-worker/build/child.js
brodybi+ 28464     1 17 Nov13 pts/0    00:50:28 /home/brodybits/nvs/node/12.13.0/x64/bin/node /home/brodybits/prettier/node_modules/jest-worker/build/child.js
brodybi+ 28547     1 18 Nov13 pts/0    00:52:26 /home/brodybits/nvs/node/12.13.0/x64/bin/node /home/brodybits/prettier/node_modules/jest-worker/build/child.js
brodybi+ 28554     1 18 Nov13 pts/0    00:52:17 /home/brodybits/nvs/node/12.13.0/x64/bin/node /home/brodybits/prettier/node_modules/jest-worker/build/child.js
brodybi+ 29661     1 25 Nov13 pts/0    01:17:19 /home/brodybits/nvs/node/12.13.0/x64/bin/node /home/brodybits/prettier/node_modules/jest-worker/build/child.js
root     39326     2  0 03:56 ?        00:00:00 [kworker/u80:1-events_power_efficient]
brodybi+ 39443     1 34 01:11 pts/0    01:10:12 /home/brodybits/nvs/node/12.13.0/x64/bin/node /home/brodybits/prettier/node_modules/jest-worker/build/child.js
brodybi+ 39467     1 34 01:11 pts/0    01:10:21 /home/brodybits/nvs/node/12.13.0/x64/bin/node /home/brodybits/prettier/node_modules/jest-worker/build/child.js
brodybi+ 39560     1 34 01:11 pts/0    01:10:25 /home/brodybits/nvs/node/12.13.0/x64/bin/node /home/brodybits/prettier/node_modules/jest-worker/build/child.js
root     39649     2  0 04:06 ?        00:00:00 [kworker/u80:2-events_unbound]
root     39830     2  0 04:11 ?        00:00:00 [kworker/3:0-events]
root     39969     2  0 04:12 ?        00:00:00 [kworker/8:0]
root     40067     2  0 04:19 ?        00:00:00 [kworker/5:2-mm_percpu_wq]
root     40071     2  0 04:19 ?        00:00:00 [kworker/12:2]

I think the best workaround solution if I still want to use the virtual machine would be to simply reboot it. Same workaround as if I have to stop an ongoing Stryker test run on 40 (virtual) CPUs for any reason.

@brodycj
Copy link
Owner Author

brodycj commented Nov 14, 2019

The report generated by nohup node --max-old-space-size=100000 ./node_modules/.bin/stryker run is available here: https://chrisbrody.com/prettier-src-common-mutation-report-2019-11-14/

@brodycj brodycj mentioned this pull request Aug 18, 2020
2 tasks
@brodycj brodycj changed the title [...] try Stryker testing, for evaluation, etc. try Stryker (v2) testing, for evaluation, etc. - outdated Aug 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant