Apache Lucene open-source search software
LUCENE-10531: Add @RequiresGUI test group for GUI tests (#893)
Tomoko Uchidab911d1d47c59
diff --git a/.github/actions/gradle-caches/action.yml b/.github/actions/gradle-caches/action.ymlnew file mode 100644index 00000000000..488e504c2c1--- /dev/null+++ b/.github/actions/gradle-caches/action.yml@@ -0,0 +1,15 @@+name: "Set up caches"+description: "Set up cached resources"++runs:+ using: "composite"+ steps:+ - name: Cache/Restore cached gradle files+ uses: actions/cache@v2+ with:+ path: |+ ~/.gradle/caches+ ~/.gradle/jdks+ key: ${{ runner.os }}-gradle-caches-${{ hashFiles('versions.lock', '**/gradle-wrapper.properties') }}+ restore-keys: |+ ${{ runner.os }}-gradle-caches-diff --git a/.github/workflows/distribution.yml b/.github/workflows/distribution.ymlnew file mode 100644index 00000000000..863ff1dcdb4--- /dev/null+++ b/.github/workflows/distribution.yml@@ -0,0 +1,40 @@+name: Distribution tests++on:+ # Allow manual triggers for testing the action.+ workflow_dispatch:++ pull_request:+ branches:+ - 'main'++ push:+ branches:+ - 'run-scripts-test-nightly'++jobs:+ test:+ name: Run distribution tests++ runs-on: ${{ matrix.os }}+ strategy:+ matrix:+ # we run the distribution tests on all major OSs.+ os: [ubuntu-latest, macos-latest, windows-latest]++ steps:+ - uses: actions/checkout@v2+ - name: Set up JDK+ uses: actions/setup-java@v2+ with:+ distribution: 'temurin'+ java-version: 17+ java-package: jdk+ - name: Prepare caches+ uses: ./.github/actions/gradle-caches++ - name: Initialize gradle settings (${{ matrix.os }})+ run: ./gradlew localSettings++ - name: Run all distribution tests including GUI tests (${{ matrix.os }})+ run: ./gradlew -p lucene/distribution.tests testdiff --git a/.github/workflows/gradle-precommit.yml b/.github/workflows/gradle-precommit.ymlindex 2bc848a0123..ecafe945e09 100644--- a/.github/workflows/gradle-precommit.yml+++ b/.github/workflows/gradle-precommit.yml@@ -33,17 +33,8 @@ jobs:java-version: ${{ matrix.java }}java-package: jdk- - name: Grant execute permission for gradlew- run: chmod +x gradlew-- - uses: actions/cache@v2- with:- path: |- ~/.gradle/caches- key: ${{ runner.os }}-gradle-precommit-${{ hashFiles('versions.lock') }}- restore-keys: |- ${{ runner.os }}-gradle-precommit-- ${{ runner.os }}-gradle-+ - name: Prepare caches+ uses: ./.github/actions/gradle-caches- name: Initialize gradle settingsrun: ./gradlew localSettings --max-workers 2@@ -77,14 +68,8 @@ jobs:java-version: ${{ matrix.java }}java-package: jdk- - uses: actions/cache@v2- with:- path: |- ~/.gradle/caches- key: ${{ runner.os }}-gradle-precommit-${{ hashFiles('versions.lock') }}- restore-keys: |- ${{ runner.os }}-gradle-precommit-- ${{ runner.os }}-gradle-+ - name: Prepare caches+ uses: ./.github/actions/gradle-caches- name: Initialize gradle settingsrun: ./gradlew localSettings --max-workers 2@@ -94,5 +79,3 @@ jobs:- name: Run gradle testsrun: ./gradlew test "-Ptask.times=true" --max-workers 2-- # - uses: gradle/wrapper-validation-action@v1diff --git a/.github/workflows/hunspell.yml b/.github/workflows/hunspell.ymlindex 7f3fce070ff..2dfe9a85ca1 100644--- a/.github/workflows/hunspell.yml+++ b/.github/workflows/hunspell.yml@@ -16,23 +16,19 @@ jobs:steps:- uses: actions/checkout@v2+- name: Set up JDKuses: actions/setup-java@v2with:distribution: 'temurin'java-version: 17java-package: jdk- - name: Grant execute permission for gradlew- run: chmod +x gradlew- - uses: actions/cache@v2- with:- path: |- ~/.gradle/caches- key: ${{ runner.os }}-gradle-solrj-${{ hashFiles('versions.lock') }}- restore-keys: |- ${{ runner.os }}-gradle-solrj-- ${{ runner.os }}-gradle-++ - name: Prepare caches+ uses: ./.github/actions/gradle-caches+- name: Initialize gradle settingsrun: ./gradlew localSettings+- name: Run regular and regression testsrun: ./gradlew -p lucene/analysis/common check testRegressionsdiff --git a/dev-tools/scripts/smokeTestRelease.py b/dev-tools/scripts/smokeTestRelease.pyindex ec64d9d5b4e..8292626796f 100755--- a/dev-tools/scripts/smokeTestRelease.py+++ b/dev-tools/scripts/smokeTestRelease.py@@ -1132,6 +1132,9 @@ def smokeTest(java, baseURL, gitRevision, version, tmpDir, isSigned, local_keys,# coverage.testArgs = '-Dtests.nightly=true %s' % testArgs+ # We also enable GUI tests in smoke tests (LUCENE-10531)+ testArgs = '-Dtests.gui=true %s' % testArgs+if FORCE_CLEAN:if os.path.exists(tmpDir):raise RuntimeError('temp dir %s exists; please remove first' % tmpDir)diff --git a/gradle/testing/randomization.gradle b/gradle/testing/randomization.gradleindex 5f862f087ec..aa5125fe2cb 100644--- a/gradle/testing/randomization.gradle+++ b/gradle/testing/randomization.gradle@@ -90,11 +90,16 @@ allprojects {[propName: 'tests.monster', value: false, description: "Enables or disables @Monster tests."],[propName: 'tests.awaitsfix', value: null, description: "Enables or disables @AwaitsFix tests."],[propName: 'tests.badapples', value: null, description: "Enables or disables @BadApple tests."],+ [propName: 'tests.gui',+ value: { ->+ return rootProject.ext.isCIBuild+ },+ description: "Enables or disables @RequiresGUI tests."],[propName: 'tests.file.encoding',- value: { ->- RandomPicks.randomFrom(new Random(projectSeedLong), ["US-ASCII", "ISO-8859-1", "UTF-8"])- },- description: "Sets the default file.encoding on test JVM.", buildOnly: true],+ value: { ->+ RandomPicks.randomFrom(new Random(projectSeedLong), ["US-ASCII", "ISO-8859-1", "UTF-8"])+ },+ description: "Sets the default file.encoding on test JVM.", buildOnly: true],// Test data file used.[propName: 'tests.linedocsfile', value: 'europarl.lines.txt.gz', description: "Test data file path."],// miscellaneous; some of them very weird.diff --git a/lucene/distribution.tests/src/test/org/apache/lucene/distribution/AbstractLuceneDistributionTest.java b/lucene/distribution.tests/src/test/org/apache/lucene/distribution/AbstractLuceneDistributionTest.javaindex 0a1868f27ec..af1fd91e312 100644--- a/lucene/distribution.tests/src/test/org/apache/lucene/distribution/AbstractLuceneDistributionTest.java+++ b/lucene/distribution.tests/src/test/org/apache/lucene/distribution/AbstractLuceneDistributionTest.java@@ -17,7 +17,12 @@package org.apache.lucene.distribution;import com.carrotsearch.randomizedtesting.RandomizedTest;+import com.carrotsearch.randomizedtesting.annotations.TestGroup;import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope;+import java.lang.annotation.Documented;+import java.lang.annotation.Inherited;+import java.lang.annotation.Retention;+import java.lang.annotation.RetentionPolicy;import java.nio.file.Files;import java.nio.file.Path;import java.nio.file.Paths;@@ -47,6 +52,19 @@ public abstract class AbstractLuceneDistributionTest extends RandomizedTest {/** Resolved and validated {@link #DISTRIBUTION_PROPERTY}. */private static Path distributionPath;+ // --------------------------------------------------------------------+ // Test groups, system properties and other annotations modifying tests+ // --------------------------------------------------------------------++ public static final String SYSPROP_REQUIRES_GUI = "tests.gui";++ /** Annotation for tests that requires GUI (physical or virtual display). */+ @Documented+ @Inherited+ @Retention(RetentionPolicy.RUNTIME)+ @TestGroup(enabled = false, sysProperty = SYSPROP_REQUIRES_GUI)+ public @interface RequiresGUI {}+/** Ensure Lucene classes are not directly visible. */@BeforeClasspublic static void checkLuceneNotInClasspath() {diff --git a/lucene/distribution.tests/src/test/org/apache/lucene/distribution/TestScripts.java b/lucene/distribution.tests/src/test/org/apache/lucene/distribution/TestScripts.javaindex 26565b0cf89..6db60a7202d 100644--- a/lucene/distribution.tests/src/test/org/apache/lucene/distribution/TestScripts.java+++ b/lucene/distribution.tests/src/test/org/apache/lucene/distribution/TestScripts.java@@ -38,6 +38,7 @@ import org.junit.Test;/** Verify that scripts included in the distribution work. */public class TestScripts extends AbstractLuceneDistributionTest {@Test+ @RequiresGUIpublic void testLukeCanBeLaunched() throws Exception {Path distributionPath;if (randomBoolean()) {@@ -69,7 +70,7 @@ public class TestScripts extends AbstractLuceneDistributionTest {execute(launcher,0,- 60,+ 120,(outputBytes) -> {// We know it's UTF-8 because we set file.encoding explicitly.var output = Files.readString(outputBytes, StandardCharsets.UTF_8);