Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] AnalysisTests.testParseWordListOutsideConfigDirError #5156

Closed
mch2 opened this issue Nov 8, 2022 · 1 comment · Fixed by #5158
Closed

[BUG] AnalysisTests.testParseWordListOutsideConfigDirError #5156

mch2 opened this issue Nov 8, 2022 · 1 comment · Fixed by #5158
Labels
bug Something isn't working :test Adding or fixing a test untriaged v2.4.0 'Issues and PRs related to version v2.4.0'

Comments

@mch2
Copy link
Member

mch2 commented Nov 8, 2022

Describe the bug
This test consistently fails for me on mac & windows on 2.4 branch.
./gradlew ':server:test' --tests "org.opensearch.index.analysis.AnalysisTests.testParseWordListOutsideConfigDirError"

REPRODUCE WITH: ./gradlew ':server:test' --tests "org.opensearch.index.analysis.AnalysisTests.testParseWordListOutsideConfigDirError" -Dtests.seed=A2F3FFF84D555751 -Dtests.security.manager=true -Dtests.jvm.argline="-XX:TieredStopAtLevel=1 -XX:ReservedCodeCacheSize=64m" -Dtests.locale=el-CY -Dtests.timezone=Asia/Kuwait -Druntime.java=17

org.opensearch.index.analysis.AnalysisTests > testParseWordListOutsideConfigDirError FAILED
    org.junit.ComparisonFailure: expected:<[Line [1]: Invalid ru]le> but was:<[IOException while reading foo.bar_path: file not readab]le>
        at __randomizedtesting.SeedInfo.seed([A2F3FFF84D555751:4F8823E059BDC4B3]:0)
        at org.junit.Assert.assertEquals(Assert.java:117)
        at org.junit.Assert.assertEquals(Assert.java:146)
        at org.opensearch.index.analysis.AnalysisTests.testParseWordListOutsideConfigDirError(AnalysisTests.java:148)


Suite: Test class org.opensearch.index.analysis.AnalysisTests
  1> [2022-11-09T00:31:35,042][INFO ][o.o.i.a.AnalysisTests    ] [testParseWordListOutsideConfigDirError] before test
  1> [2022-11-09T00:31:35,362][ERROR][o.o.i.a.Analysis         ] [testParseWordListOutsideConfigDirError] IOException while reading foo.bar_path: file not readable, from file: /etc/os-release, exception is: java.nio.file.NoSuchFileException: /etc/os-release
  1> [2022-11-09T00:31:35,406][INFO ][o.o.i.a.AnalysisTests    ] [testParseWordListOutsideConfigDirError] after test
  2> REPRODUCE WITH: ./gradlew ':server:test' --tests "org.opensearch.index.analysis.AnalysisTests.testParseWordListOutsideConfigDirError" -Dtests.seed=A2F3FFF84D555751 -Dtests.security.manager=true -Dtests.jvm.argline="-XX:TieredStopAtLevel=1 -XX:ReservedCodeCacheSize=64m" -Dtests.locale=el-CY -Dtests.timezone=Asia/Kuwait -Druntime.java=17
  2> org.junit.ComparisonFailure: expected:<[Line [1]: Invalid ru]le> but was:<[IOException while reading foo.bar_path: file not readab]le>
        at __randomizedtesting.SeedInfo.seed([A2F3FFF84D555751:4F8823E059BDC4B3]:0)
        at org.junit.Assert.assertEquals(Assert.java:117)
        at org.junit.Assert.assertEquals(Assert.java:146)
        at org.opensearch.index.analysis.AnalysisTests.testParseWordListOutsideConfigDirError(AnalysisTests.java:148)
  2> NOTE: leaving temporary files on disk at: /Users/handalm/workspace/OpenSearch/server/build/testrun/test/temp/org.opensearch.index.analysis.AnalysisTests_A2F3FFF84D555751-004
  2> NOTE: test params are: codec=Lucene94, sim=Asserting(RandomSimilarity(queryNorm=true): {}), locale=el-CY, timezone=Asia/Kuwait
  2> NOTE: Mac OS X 12.5 x86_64/Eclipse Adoptium 17.0.5 (64-bit)/cpus=8,threads=1,free=476376576,total=536870912
  2> NOTE: All tests run in this JVM: [AnalysisTests]
WARNING: A terminally deprecated method in java.lang.System has been called
WARNING: System::setSecurityManager has been called by org.gradle.api.internal.tasks.testing.worker.TestWorker (file:/Users/handalm/.gradle/wrapper/dists/gradle-7.5.1-all/1ehga6e77gqps5uk2kc5kf1vc/gradle-7.5.1/lib/plugins/gradle-testing-base-7.5.1.jar)
WARNING: Please consider reporting this to the maintainers of org.gradle.api.internal.tasks.testing.worker.TestWorker
WARNING: System::setSecurityManager will be removed in a future release

related - 877f891

Expected behavior
Test should pass.

@mch2 mch2 added bug Something isn't working untriaged v2.4.0 'Issues and PRs related to version v2.4.0' :test Adding or fixing a test labels Nov 8, 2022
@adnapibar
Copy link
Contributor

Thanks @mch2 - I think the test should create a separate temp directory and create a file in it. Can you try the following on windows ?

public void testParseWordListOutsideConfigDirError() throws IOException {
        Path home = createTempDir();
        Path temp = createTempDir();
        Path dict = temp.resolve("foo.dict");
        try (BufferedWriter writer = Files.newBufferedWriter(dict, StandardCharsets.UTF_8)) {
            writer.write("abcd");
            writer.write('\n');
        }
        Settings nodeSettings = Settings.builder().put("foo.bar_path", dict).put(Environment.PATH_HOME_SETTING.getKey(), home).build();
        Environment env = TestEnvironment.newEnvironment(nodeSettings);
        RuntimeException ex = expectThrows(
            RuntimeException.class,
            () -> Analysis.parseWordList(
                env,
                nodeSettings,
                "foo.bar",
                s -> { throw new RuntimeException("Error while parsing rule = " + s); }
            )
        );
        assertEquals("Line [1]: Invalid rule", ex.getMessage());
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working :test Adding or fixing a test untriaged v2.4.0 'Issues and PRs related to version v2.4.0'
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants