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

Check message instead of toString for DS_Store test #42742

Closed
wants to merge 1 commit into from

Conversation

rjernst
Copy link
Member

@rjernst rjernst commented May 31, 2019

The plugin service special cases .DS_Store on MacOS, to not think it is
a plugin. The tests for this behavior also check an appropriate error
occurs on non macos systems. On Linux, the test checks the exception
message, but uses toString(), which uses a localized version of the
exception message. This commit changes the test to instead check the
exception message directly, so as not to depend on the locale.

closes #41689

The plugin service special cases .DS_Store on MacOS, to not think it is
a plugin. The tests for this behavior also check an appropriate error
occurs on non macos systems. On Linux, the test checks the exception
message, but uses toString(), which uses a localized version of the
exception message. This commit changes the test to instead check the
exception message directly, so as not to depend on the locale.

closes elastic#41689
@rjernst rjernst added >test Issues or PRs that are addressing/adding tests :Core/Infra/Plugins Plugin API and infrastructure v8.0.0 v7.3.0 labels May 31, 2019
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-core-infra

@jasontedor
Copy link
Member

This does not have any effect. Throwable#getLocalizedMessage defers to Throwable#getMessage for the default implementation, and FileSystemException does not override this. So it means that FileSystemException#getMessage and FileSystemException#getLocalizedMessage will both produce the same result.

@jasontedor
Copy link
Member

I tested this:

centos-7:~/elasticsearch$ git diff
diff --git a/server/src/test/java/org/elasticsearch/plugins/PluginsServiceTests.java b/server/src/test/java/org/elasticsearch/plugins/PluginsServiceTests.java
index b9459b926d3..b853b941955 100644
--- a/server/src/test/java/org/elasticsearch/plugins/PluginsServiceTests.java
+++ b/server/src/test/java/org/elasticsearch/plugins/PluginsServiceTests.java
@@ -171,7 +171,7 @@ public class PluginsServiceTests extends ESTestCase {
             if (Constants.WINDOWS) {
                 assertThat(e.getCause(), instanceOf(NoSuchFileException.class));
             } else {
-                assertThat(e.getCause(), hasToString(containsString("Not a directory")));
+                assertThat(e.getCause().getMessage(), containsString("Not a directory"));
             }
         }
     }
centos-7:~/elasticsearch$ localectl
   System Locale: LANG=zh_CN.utf8
       VC Keymap: us
      X11 Layout: n/a
centos-7:~/elasticsearch$ echo $LANG
zh_CN.UTF-8
centos-7:~/elasticsearch$ JAVA_HOME=/home/vagrant/jdk-12.0.1/ ./gradlew :server:test --tests org.elasticsearch.plugins.PluginsServiceTests --parallel
Starting a Gradle Daemon (subsequent builds will be faster)

> Configure project :plugins:repository-hdfs
Tests for :plugins:repository-hdfs require docker-compose at /usr/local/bin/docker-compose or /usr/bin/docker-compose but none could be found so these will be skipped

> Configure project :x-pack:qa:kerberos-tests
Tests for :x-pack:qa:kerberos-tests require docker-compose at /usr/local/bin/docker-compose or /usr/bin/docker-compose but none could be found so these will be skipped

> Configure project :x-pack:qa:oidc-op-tests
Tests for :x-pack:qa:oidc-op-tests require docker-compose at /usr/local/bin/docker-compose or /usr/bin/docker-compose but none could be found so these will be skipped

> Configure project :x-pack:qa:openldap-tests
Tests for :x-pack:qa:openldap-tests require docker-compose at /usr/local/bin/docker-compose or /usr/bin/docker-compose but none could be found so these will be skipped

> Configure project :x-pack:qa:saml-idp-tests
Tests for :x-pack:qa:saml-idp-tests require docker-compose at /usr/local/bin/docker-compose or /usr/bin/docker-compose but none could be found so these will be skipped

> Configure project :x-pack:qa:third-party:active-directory
Tests for :x-pack:qa:third-party:active-directory require docker-compose at /usr/local/bin/docker-compose or /usr/bin/docker-compose but none could be found so these will be skipped

> Task :printGlobalBuildInfo UP-TO-DATE
=======================================
Elasticsearch Build Hamster says Hello!
  Gradle Version        : 5.4.1
  OS Info               : Linux 3.10.0-957.10.1.el7.x86_64 (amd64)
  JDK Version           : 12 (Oracle Corporation 12.0.1 [OpenJDK 64-Bit Server VM 12.0.1+12])
  JAVA_HOME             : /home/vagrant/jdk-12.0.1
  Random Testing Seed   : E560085EA3537C85
=======================================

> Task :server:compileTestJava
注: /home/vagrant/elasticsearch/server/src/test/java/org/elasticsearch/plugins/PluginsServiceTests.java使用了未经检查或不安全的操作。
注: 有关详细信息, 请使用 -Xlint:unchecked 重新编译。

> Task :server:test


org.elasticsearch.plugins.PluginsServiceTests > testDesktopServicesStoreFiles FAILED
    java.lang.AssertionError: 
    Expected: a string containing "Not a directory"
         but: was "/home/vagrant/elasticsearch/server/build/testrun/test/temp/org.elasticsearch.plugins.PluginsServiceTests_E560085EA3537C85-001/tempDir-008/plugins/.DS_Store/plugin-descriptor.properties: 不是目录"
        at __randomizedtesting.SeedInfo.seed([E560085EA3537C85:B2DEF10F2D306EEF]:0)
        at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:18)
        at org.junit.Assert.assertThat(Assert.java:956)
        at org.junit.Assert.assertThat(Assert.java:923)
        at org.elasticsearch.plugins.PluginsServiceTests.testDesktopServicesStoreFiles(PluginsServiceTests.java:174)
REPRODUCE WITH: ./gradlew :server:test --tests "org.elasticsearch.plugins.PluginsServiceTests.testDesktopServicesStoreFiles" -Dtests.seed=E560085EA3537C85 -Dtests.security.manager=true -Dtests.locale=fr-RE -Dtests.timezone=America/Atikokan -Dcompiler.java=12 -Druntime.java=12

Suite: Test class org.elasticsearch.plugins.PluginsServiceTests
  1> [2019-05-31T10:51:01,798][INFO ][o.e.p.PluginsServiceTests] [testJarHellDuplicateClassWithCore] before test
  1> [2019-05-31T10:51:03,424][INFO ][o.e.p.PluginsServiceTests] [testJarHellDuplicateClassWithCore] after test
  1> [2019-05-31T10:51:03,440][INFO ][o.e.p.PluginsServiceTests] [testAdditionalSettings] before test
  1> [2019-05-31T10:51:03,458][INFO ][o.e.p.PluginsService     ] [testAdditionalSettings] no modules loaded
  1> [2019-05-31T10:51:03,465][INFO ][o.e.p.PluginsService     ] [testAdditionalSettings] loaded plugin [org.elasticsearch.plugins.PluginsServiceTests$AdditionalSettingsPlugin1]
  1> [2019-05-31T10:51:03,466][INFO ][o.e.p.PluginsServiceTests] [testAdditionalSettings] after test
  1> [2019-05-31T10:51:03,470][INFO ][o.e.p.PluginsServiceTests] [testJarHellDuplicateClassAcrossDeps] before test
  1> [2019-05-31T10:51:03,482][INFO ][o.e.p.PluginsServiceTests] [testJarHellDuplicateClassAcrossDeps] after test
  1> [2019-05-31T10:51:03,486][INFO ][o.e.p.PluginsServiceTests] [testSortBundlesCycle] before test
  1> [2019-05-31T10:51:03,489][INFO ][o.e.p.PluginsServiceTests] [testSortBundlesCycle] after test
  1> [2019-05-31T10:51:03,492][INFO ][o.e.p.PluginsServiceTests] [testDesktopServicesStoreFiles] before test
  1> [2019-05-31T10:51:03,499][INFO ][o.e.p.PluginsServiceTests] [testDesktopServicesStoreFiles] after test
  2> REPRODUCE WITH: ./gradlew :server:test --tests "org.elasticsearch.plugins.PluginsServiceTests.testDesktopServicesStoreFiles" -Dtests.seed=E560085EA3537C85 -Dtests.security.manager=true -Dtests.locale=fr-RE -Dtests.timezone=America/Atikokan -Dcompiler.java=12 -Druntime.java=12
  2> java.lang.AssertionError: 
    Expected: a string containing "Not a directory"
         but: was "/home/vagrant/elasticsearch/server/build/testrun/test/temp/org.elasticsearch.plugins.PluginsServiceTests_E560085EA3537C85-001/tempDir-008/plugins/.DS_Store/plugin-descriptor.properties: 不是目录"
        at __randomizedtesting.SeedInfo.seed([E560085EA3537C85:B2DEF10F2D306EEF]:0)
        at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:18)
        at org.junit.Assert.assertThat(Assert.java:956)
        at org.junit.Assert.assertThat(Assert.java:923)
        at org.elasticsearch.plugins.PluginsServiceTests.testDesktopServicesStoreFiles(PluginsServiceTests.java:174)
  1> [2019-05-31T10:51:03,506][INFO ][o.e.p.PluginsServiceTests] [testJarHellTransitiveMap] before test
  1> [2019-05-31T10:51:04,863][INFO ][o.e.p.PluginsServiceTests] [testJarHellTransitiveMap] after test
  1> [2019-05-31T10:51:04,870][INFO ][o.e.p.PluginsServiceTests] [testHiddenFiles] before test
  1> [2019-05-31T10:51:04,875][INFO ][o.e.p.PluginsServiceTests] [testHiddenFiles] after test
  1> [2019-05-31T10:51:04,879][INFO ][o.e.p.PluginsServiceTests] [testExistingPluginMissingDescriptor] before test
  1> [2019-05-31T10:51:04,882][INFO ][o.e.p.PluginsServiceTests] [testExistingPluginMissingDescriptor] after test
  1> [2019-05-31T10:51:04,885][INFO ][o.e.p.PluginsServiceTests] [testFilterPlugins] before test
  1> [2019-05-31T10:51:04,888][INFO ][o.e.p.PluginsService     ] [testFilterPlugins] no modules loaded
  1> [2019-05-31T10:51:04,889][INFO ][o.e.p.PluginsService     ] [testFilterPlugins] loaded plugin [org.elasticsearch.plugins.PluginsServiceTests$AdditionalSettingsPlugin1]
  1> [2019-05-31T10:51:04,889][INFO ][o.e.p.PluginsService     ] [testFilterPlugins] loaded plugin [org.elasticsearch.plugins.PluginsServiceTests$FilterablePlugin]
  1> [2019-05-31T10:51:04,889][INFO ][o.e.p.PluginsServiceTests] [testFilterPlugins] after test
  1> [2019-05-31T10:51:04,892][INFO ][o.e.p.PluginsServiceTests] [testLoadPluginWithMultiplePublicConstructors] before test
  1> [2019-05-31T10:51:04,895][INFO ][o.e.p.PluginsServiceTests] [testLoadPluginWithMultiplePublicConstructors] after test
  1> [2019-05-31T10:51:04,898][INFO ][o.e.p.PluginsServiceTests] [testJarHellDuplicateCodebaseAcrossDeps] before test
  1> [2019-05-31T10:51:04,908][INFO ][o.e.p.PluginsServiceTests] [testJarHellDuplicateCodebaseAcrossDeps] after test
  1> [2019-05-31T10:51:04,911][INFO ][o.e.p.PluginsServiceTests] [testSortBundlesNoDeps] before test
  1> [2019-05-31T10:51:04,914][INFO ][o.e.p.PluginsServiceTests] [testSortBundlesNoDeps] after test
  1> [2019-05-31T10:51:04,917][INFO ][o.e.p.PluginsServiceTests] [testIncompatibleJavaVersion] before test
  1> [2019-05-31T10:51:04,918][INFO ][o.e.p.PluginsServiceTests] [testIncompatibleJavaVersion] after test
  1> [2019-05-31T10:51:04,924][INFO ][o.e.p.PluginsServiceTests] [testSortBundlesCommonDep] before test
  1> [2019-05-31T10:51:04,927][INFO ][o.e.p.PluginsServiceTests] [testSortBundlesCommonDep] after test
  1> [2019-05-31T10:51:04,936][INFO ][o.e.p.PluginsServiceTests] [testAdditionalSettingsClash] before test
  1> [2019-05-31T10:51:04,939][INFO ][o.e.p.PluginsService     ] [testAdditionalSettingsClash] no modules loaded
  1> [2019-05-31T10:51:04,939][INFO ][o.e.p.PluginsService     ] [testAdditionalSettingsClash] loaded plugin [org.elasticsearch.plugins.PluginsServiceTests$AdditionalSettingsPlugin1]
  1> [2019-05-31T10:51:04,939][INFO ][o.e.p.PluginsService     ] [testAdditionalSettingsClash] loaded plugin [org.elasticsearch.plugins.PluginsServiceTests$AdditionalSettingsPlugin2]
  1> [2019-05-31T10:51:04,947][INFO ][o.e.p.PluginsServiceTests] [testAdditionalSettingsClash] after test
  1> [2019-05-31T10:51:04,953][INFO ][o.e.p.PluginsServiceTests] [testExistingMandatoryClasspathPlugin] before test
  1> [2019-05-31T10:51:04,957][INFO ][o.e.p.PluginsService     ] [testExistingMandatoryClasspathPlugin] no modules loaded
  1> [2019-05-31T10:51:04,957][INFO ][o.e.p.PluginsService     ] [testExistingMandatoryClasspathPlugin] loaded plugin [org.elasticsearch.plugins.PluginsServiceTests$FakePlugin]
  1> [2019-05-31T10:51:04,957][INFO ][o.e.p.PluginsServiceTests] [testExistingMandatoryClasspathPlugin] after test
  1> [2019-05-31T10:51:04,961][INFO ][o.e.p.PluginsServiceTests] [testJarHellDuplicateCodebaseWithDep] before test
  1> [2019-05-31T10:51:04,966][INFO ][o.e.p.PluginsServiceTests] [testJarHellDuplicateCodebaseWithDep] after test
  1> [2019-05-31T10:51:04,969][INFO ][o.e.p.PluginsServiceTests] [testSortBundlesSingle] before test
  1> [2019-05-31T10:51:04,971][INFO ][o.e.p.PluginsServiceTests] [testSortBundlesSingle] after test
  1> [2019-05-31T10:51:04,974][INFO ][o.e.p.PluginsServiceTests] [testSortBundlesCycleSelfReference] before test
  1> [2019-05-31T10:51:04,977][INFO ][o.e.p.PluginsServiceTests] [testSortBundlesCycleSelfReference] after test
  1> [2019-05-31T10:51:04,980][INFO ][o.e.p.PluginsServiceTests] [testIncompatibleElasticsearchVersion] before test
  1> [2019-05-31T10:51:04,982][INFO ][o.e.p.PluginsServiceTests] [testIncompatibleElasticsearchVersion] after test
  1> [2019-05-31T10:51:04,984][INFO ][o.e.p.PluginsServiceTests] [testFindPluginDirs] before test
  1> [2019-05-31T10:51:04,994][INFO ][o.e.p.PluginsServiceTests] [testFindPluginDirs] after test
  1> [2019-05-31T10:51:04,997][INFO ][o.e.p.PluginsServiceTests] [testJarHellDuplicateClassWithDep] before test
  1> [2019-05-31T10:51:05,008][INFO ][o.e.p.PluginsServiceTests] [testJarHellDuplicateClassWithDep] after test
  1> [2019-05-31T10:51:05,011][INFO ][o.e.p.PluginsServiceTests] [testExistingMandatoryInstalledPlugin] before test
  1> [2019-05-31T10:51:06,315][INFO ][o.e.p.PluginsService     ] [testExistingMandatoryInstalledPlugin] no modules loaded
  1> [2019-05-31T10:51:06,316][INFO ][o.e.p.PluginsService     ] [testExistingMandatoryInstalledPlugin] loaded plugin [fake]
  1> [2019-05-31T10:51:06,316][INFO ][o.e.p.PluginsServiceTests] [testExistingMandatoryInstalledPlugin] after test
  1> [2019-05-31T10:51:06,320][INFO ][o.e.p.PluginsServiceTests] [testSortBundlesAlreadyOrdered] before test
  1> [2019-05-31T10:51:06,323][INFO ][o.e.p.PluginsServiceTests] [testSortBundlesAlreadyOrdered] after test
  1> [2019-05-31T10:51:06,326][INFO ][o.e.p.PluginsServiceTests] [testLoadPluginWithNoPublicConstructor] before test
  1> [2019-05-31T10:51:06,329][INFO ][o.e.p.PluginsServiceTests] [testLoadPluginWithNoPublicConstructor] after test
  1> [2019-05-31T10:51:06,332][INFO ][o.e.p.PluginsServiceTests] [testLoadPluginWithNoPublicConstructorOfCorrectSignature] before test
  1> [2019-05-31T10:51:06,342][INFO ][o.e.p.PluginsServiceTests] [testLoadPluginWithNoPublicConstructorOfCorrectSignature] after test
  1> [2019-05-31T10:51:06,345][INFO ][o.e.p.PluginsServiceTests] [testSortBundlesMissingDep] before test
  1> [2019-05-31T10:51:06,349][INFO ][o.e.p.PluginsServiceTests] [testSortBundlesMissingDep] after test
  1> [2019-05-31T10:51:06,351][INFO ][o.e.p.PluginsServiceTests] [testNonExtensibleDep] before test
  1> [2019-05-31T10:51:08,872][INFO ][o.e.p.PluginsServiceTests] [testNonExtensibleDep] after test
  1> [2019-05-31T10:51:08,875][INFO ][o.e.p.PluginsServiceTests] [testStartupWithRemovingMarker] before test
  1> [2019-05-31T10:51:08,880][INFO ][o.e.p.PluginsServiceTests] [testStartupWithRemovingMarker] after test
  2> NOTE: leaving temporary files on disk at: /home/vagrant/elasticsearch/server/build/testrun/test/temp/org.elasticsearch.plugins.PluginsServiceTests_E560085EA3537C85-001
  2> NOTE: test params are: codec=Asserting(Lucene80): {}, docValues:{}, maxPointsInLeafNode=959, maxMBSortInHeap=6.699776114976888, sim=Asserting(org.apache.lucene.search.similarities.AssertingSimilarity@2d84a4de), locale=fr-RE, timezone=America/Atikokan
  2> NOTE: Linux 3.10.0-957.10.1.el7.x86_64 amd64/Oracle Corporation 12.0.1 (64-bit)/cpus=4,threads=1,free=525465040,total=536870912
  2> NOTE: All tests run in this JVM: [PluginsServiceTests]

29 tests completed, 1 failed

Tests with failures:
 - org.elasticsearch.plugins.PluginsServiceTests.testDesktopServicesStoreFiles

> Task :server:test FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':server:test'.
> There were failing tests. See the report at: file:///home/vagrant/elasticsearch/server/build/reports/tests/test/index.html

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 28s
31 actionable tasks: 2 executed, 29 up-to-date
centos-7:~/elasticsearch$ 

@rjernst
Copy link
Member Author

rjernst commented May 31, 2019

That is unfortunate (sorry I was testing from my macbook before without thinking).

@rjernst rjernst closed this May 31, 2019
@rjernst rjernst deleted the fix41689 branch June 6, 2019 19:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Core/Infra/Plugins Plugin API and infrastructure >test Issues or PRs that are addressing/adding tests v7.3.0 v8.0.0-alpha1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Test Suit]testDesktopServicesStoreFiles failed
4 participants