You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by to...@apache.org on 2022/05/18 00:26:13 UTC
[lucene] branch main updated: LUCENE-10531: Add @RequiresGUI test group for GUI tests (#893)
This is an automated email from the ASF dual-hosted git repository.
tomoko pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/lucene.git
The following commit(s) were added to refs/heads/main by this push:
new b911d1d47c5 LUCENE-10531: Add @RequiresGUI test group for GUI tests (#893)
b911d1d47c5 is described below
commit b911d1d47c592a51cd3b0c3f59eea6e24455cea3
Author: Tomoko Uchida <to...@gmail.com>
AuthorDate: Wed May 18 09:26:06 2022 +0900
LUCENE-10531: Add @RequiresGUI test group for GUI tests (#893)
Co-authored-by: Dawid Weiss <da...@carrotsearch.com>
---
.github/actions/gradle-caches/action.yml | 15 ++++++++
.github/workflows/distribution.yml | 40 ++++++++++++++++++++++
.github/workflows/gradle-precommit.yml | 25 +++-----------
.github/workflows/hunspell.yml | 16 ++++-----
dev-tools/scripts/smokeTestRelease.py | 3 ++
gradle/testing/randomization.gradle | 13 ++++---
.../AbstractLuceneDistributionTest.java | 18 ++++++++++
.../apache/lucene/distribution/TestScripts.java | 3 +-
8 files changed, 97 insertions(+), 36 deletions(-)
diff --git a/.github/actions/gradle-caches/action.yml b/.github/actions/gradle-caches/action.yml
new file mode 100644
index 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.yml
new file mode 100644
index 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 test
diff --git a/.github/workflows/gradle-precommit.yml b/.github/workflows/gradle-precommit.yml
index 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 settings
run: ./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 settings
run: ./gradlew localSettings --max-workers 2
@@ -94,5 +79,3 @@ jobs:
- name: Run gradle tests
run: ./gradlew test "-Ptask.times=true" --max-workers 2
-
- # - uses: gradle/wrapper-validation-action@v1
diff --git a/.github/workflows/hunspell.yml b/.github/workflows/hunspell.yml
index 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 JDK
uses: actions/setup-java@v2
with:
distribution: 'temurin'
java-version: 17
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-solrj-${{ hashFiles('versions.lock') }}
- restore-keys: |
- ${{ runner.os }}-gradle-solrj-
- ${{ runner.os }}-gradle-
+
+ - name: Prepare caches
+ uses: ./.github/actions/gradle-caches
+
- name: Initialize gradle settings
run: ./gradlew localSettings
+
- name: Run regular and regression tests
run: ./gradlew -p lucene/analysis/common check testRegressions
diff --git a/dev-tools/scripts/smokeTestRelease.py b/dev-tools/scripts/smokeTestRelease.py
index 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.gradle
index 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.java
index 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. */
@BeforeClass
public 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.java
index 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
+ @RequiresGUI
public 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);