From 1089b482fc9d4b4202ca27e096723d0060446b51 Mon Sep 17 00:00:00 2001 From: Robert Muir Date: Sat, 23 Apr 2022 08:00:33 -0400 Subject: [PATCH] LUCENE-10528: use Xvfb in test to avoid messing up user's desktop (#828) Co-authored-by: Tomoko Uchida --- help/tests.txt | 18 ++++++++++++++++++ .../src/binary-release/bin/luke.sh | 5 +++++ 2 files changed, 23 insertions(+) diff --git a/help/tests.txt b/help/tests.txt index 44e25ec62c3..795f97274ea 100644 --- a/help/tests.txt +++ b/help/tests.txt @@ -128,6 +128,24 @@ specifying the project and test task or a fully qualified task path. Example: gradlew -p lucene/core test -Ptests.verbose=true --tests "TestDemo" +Run GUI tests headlessly with Xvfb (Linux only) +----------------------------------------------- + +GUI test for Luke application launches a window, this might mess up your +monitor depending on the display manager you are using. In that case, +you can install Xvfb (X Virtual Frame Buffer) so that the test runs on the +virtual display and does not open a real window. + +# redhat-type OS +$ sudo yum install Xvfb + +# ubuntu/debian-type OS +$ sudo apt install xvfb + +# arch +$ sudo pacman -S xorg-server-xvfb + + Profiling slow tests -------------------- diff --git a/lucene/distribution/src/binary-release/bin/luke.sh b/lucene/distribution/src/binary-release/bin/luke.sh index 3d920879802..dab1e4ef9be 100644 --- a/lucene/distribution/src/binary-release/bin/luke.sh +++ b/lucene/distribution/src/binary-release/bin/luke.sh @@ -26,6 +26,11 @@ if [ -z "$LAUNCH_CMD" ]; then else # We are integration-testing. Force UTF-8 as the encoding. LAUNCH_OPTS=-Dfile.encoding=UTF-8 + # check if Xvfb is available + if command -v xvfb-run > /dev/null 2>&1; then + LAUNCH_OPTS="$LAUNCH_CMD $LAUNCH_OPTS" + LAUNCH_CMD="xvfb-run" + fi fi "$LAUNCH_CMD" $LAUNCH_OPTS --module-path "$MODULES/modules:$MODULES/modules-thirdparty" --module org.apache.lucene.luke "$@"