sporadic "xvfb-run: error: Xvfb failed to start" in make tests causes Travis to mistakenly report "Broken"
This is a minor annoyance, but I'd like to get fixed so Travis doesn't send email when it happens, since as far as I can tell the error is just with the test scripts, not with the MuseScore application.
When make tests, line
https://travis-ci.org/ericfont/MuseScore/jobs/115985176#L4531 reports error for Test #16:
16/45 Test #16: tst_instrumentchange .............***Exception: Other 0.86 sec
Lines https://travis-ci.org/ericfont/MuseScore/jobs/115985176#L4595-L4598 describe the error as:
The following tests FAILED: 16 - tst_instrumentchange (OTHER_FAULT) Errors while running CTest xvfb-run: error: Xvfb failed to start
Now it seems that other projects have had their error on Travis. The problem is due to concurrent tests jobs trying to run simultaneously on framebuffer (I did add "-j2" to make tests...so I take responsiblitlity for that), see:
https://github.com/travis-ci/travis-ci/issues/4387 (Error: "xvfb-run: error: Xvfb failed to start" #4387)
https://github.com/travis-ci/docs-travis-ci-com/pull/311/files (Recommend -a option for xvfb #311)
which says the solution is:
Use `-a` option to `xvfb-run` so that it selects a free display automatically and starts the server. Do not start `xfvb` manually, this will cause problems with concurrent runs of `xfvb-run`.
I'll try to make the relevant changes and submit PR (although since this is a sporatic bug, it will be hard to know if actually is fixed...all I can hope for is that the error doesn't pop up anymore).
Comments
Note, the readme on https://github.com/musescore/MuseScore/tree/master/mtest needs correct the line in "Building the Tests" which currently reads:
to be corrected and read:
since the proper command is "make installdebug" according to:
* https://github.com/musescore/MuseScore/blob/master/Makefile
* https://github.com/musescore/MuseScore/blob/master/Makefile.osx
FYI, what "make debug install" does is first "make debug", then "make install", but since make install first does "make release", that means that means that what gets installed is the *release* build, not the *debug* build!!! Also note that additionally does an unnecessary release build!!!
I'll include this readme correction as a sepearate commit in the PR.
Actually, I'm just realizing that the Makefile.osx doesn't include the a make debug at beginning of make installdebug:
while the linux Makefile does include a make debug at the beginning of make installdebug:
So those two makefiles are inconsistent in that specific aspect. But to make the readme cleaner and cross platform, I'm going to add debug to first line of Makefile.osx for make installdebug:
This way can have consistent readme.
I'll also remove the superflous line in https://github.com/musescore/MuseScore/blob/master/build/travis/job1_Te… which makes debug, since it handled by make installdebug. That will all be in a seperate commit in the PR.
oh...well I'm realzing now that it is better to not include "make debug" inside the "make installdebug" since if on home computer, then it is better to run the compilation "make debug" as non-root user, and then only run the *install* portion as sudo. So I'll keep them seperate...in which case that means I'll update the linux Makefile only...
EDIT 1: But on the other hand, if I'm building on my home account, then that means I simply use
and the installdebug will notice that debug is already built. So now I'm back to saying that the Makefile.osx should be the one that is changed.
EDIT 2: I'm now realizing that the Makefile.mingw adheres to the way Makefile.osx does it...in that it doesn't automatically make debug at beginning:
So I'm at point now where I think I will not change the makefiles for now, unless someone else wants to. I'll just fix the readme to indicate how to build test on home machine using "make debug && sudo make installdebug"
Regarding testing instructions, I added instructions to https://musescore.org/en/developers-handbook/testing on how to manually test in linux terminal, how to manually debug a test inside qtcreator, and how to use Travis-CI to test your own branch. See my revision here: https://musescore.org/en/node/4147/revisions/view/44485/175411
I'm having trouble reproducing the xvfb-run error, even after bumping the test concurrency up to -j23 (see travis build log https://travis-ci.org/ericfont/MuseScore/jobs/116019295). Since this error seems to be very sporadic, it will be hard to verify that a particular code change actually fixes. Any ideas how to force this error? Or should I just submit PR with the changes I *think* will fix it?
I can't even get travis to fail when bump up concurrency to -j45: https://travis-ci.org/ericfont/MuseScore/jobs/116024170
I'm fireing up a vm in qemu, and will try to replicate this bug there by running an infinite loop of running tests and waiting for it to fail!
The tests are not run concurrently as far as I understand, even with j45 :). That will just build them concurrently. They are built, all of them, and then run one by one. A possible problem is that the first failure blocks xvfb-run, so adding -a can't hurt.
Modification of the REAME in mtest is welcome! Thanks!
I'm pretty sure those travis tests are running concurrently when I changed that line: "xvfb-run ctest -j2 --output-on-failure" to -j45, and the travis script will seems to show that it starts all the tests at the same time when I did that: https://travis-ci.org/ericfont/MuseScore/jobs/116024170#L4496-L4543
OK, this j2. I though the one when compiling Musescore.
I'm noticing that line is just performing a *Single* xvfb-run command (but running a bunch of tests for that one xvfb-run). So that makes me think that it is not the concurrency that is casuing the sporadic error. So maybe that sporadic error also occured sometimes with -j1.
Anyway, I'm thinking we should make that "xvfb-run -a ctest -j2 --output-on-failure" and hope that that fixes it. That is what the official directions https://github.com/travis-ci/docs-travis-ci-com/blob/0bc92eabe46348c6fc… tell us...
doing "xvfb-run -a ctest -j2 --output-on-failure" did not break the build (see: https://travis-ci.org/ericfont/MuseScore/jobs/116589138), so I'm submitting a PR with that change. If in the future we get another xvfb-run error, then we will know that this PR didn't fix the problem.
https://github.com/musescore/MuseScore/pull/2459
Fixed in branch master, commit 58c8fbd3f9
fix #102096 add -a to xvfb-run
According to https://github.com/travis-ci/docs-travis-ci-com/commit/0bc92eabe46348c6…
Use -a option to xvfb-run so that it selects a free display automatically and starts the server. Do not start xfvb manually, this will cause problems with concurrent runs of xfvb-run.
Fixed in branch 2.0.3, commit 0efddcce85
fix #102096 add -a to xvfb-run
According to https://github.com/travis-ci/docs-travis-ci-com/commit/0bc92eabe46348c6…
Use -a option to xvfb-run so that it selects a free display automatically and starts the server. Do not start xfvb manually, this will cause problems with concurrent runs of xfvb-run.
Automatically closed -- issue fixed for 2 weeks with no activity.