LUCENE-10531: Add @RequiresGUI test group for GUI tests (#893)

Co-authored-by: Dawid Weiss <dawid.weiss@carrotsearch.com>
This commit is contained in:
Tomoko Uchida 2022-05-18 09:26:06 +09:00 committed by GitHub
parent e65c0c777b
commit b911d1d47c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 97 additions and 36 deletions

View File

@ -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-

40
.github/workflows/distribution.yml vendored Normal file
View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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)

View File

@ -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.

View File

@ -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() {

View File

@ -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);