risdenk commented on a change in pull request #553: SOLR-9515: Update to Hadoop 3 URL: https://github.com/apache/lucene-solr/pull/553#discussion_r253095650
########## File path: solr/core/src/test/org/apache/solr/cloud/hdfs/HdfsTestUtil.java ########## @@ -62,73 +63,88 @@ public static MiniDFSCluster setupClass(String dir) throws Exception { return setupClass(dir, true, true); } - + public static MiniDFSCluster setupClass(String dir, boolean haTesting) throws Exception { return setupClass(dir, haTesting, true); } - + + /** + * Checks that commons-lang3 FastDateFormat works with configured locale + */ + @SuppressForbidden(reason="Call FastDateFormat.format same way Hadoop calls it") + private static void checkFastDateFormat() { + try { + FastDateFormat.getInstance().format(System.currentTimeMillis()); + } catch (ArrayIndexOutOfBoundsException e) { + LuceneTestCase.assumeNoException("commons-lang3 FastDateFormat doesn't work with " + + Locale.getDefault().toLanguageTag(), e); + } + } + + /** + * Hadoop fails to generate locale agnostic ids - Checks that generated string matches + */ + private static void checkGeneratedIdMatches() { + // This is basically how Namenode generates fsimage ids and checks that the fsimage filename matches + LuceneTestCase.assumeTrue("Check that generated id matches regex", + Pattern.matches("(\\d+)", String.format(Locale.getDefault(),"%019d", 0))); + } + public static MiniDFSCluster setupClass(String dir, boolean safeModeTesting, boolean haTesting) throws Exception { LuceneTestCase.assumeFalse("HDFS tests were disabled by -Dtests.disableHdfs", - Boolean.parseBoolean(System.getProperty("tests.disableHdfs", "false"))); + Boolean.parseBoolean(System.getProperty("tests.disableHdfs", "false"))); + + checkFastDateFormat(); + checkGeneratedIdMatches(); - savedLocale = Locale.getDefault(); - // TODO: we HACK around HADOOP-9643 - Locale.setDefault(Locale.ENGLISH); - if (!HA_TESTING_ENABLED) haTesting = false; - - - // keep netty from using secure random on startup: SOLR-10098 Review comment: Not needed after netty upgrade. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org For additional commands, e-mail: dev-h...@lucene.apache.org