Buck tests are flaky on non englisch locale #557
Comments
These looks like locale-specific failures. @bhamiltoncx, what's the best way to test this type of stuff in a locale-aware way? |
According to this comment, it seems like this is a regression, that was already handled once:
And that now in addition to time elapsed, that is handled correctly, at least in this test file, cache hit/missed ratio was added, that is locale specific:
|
Yeah, we need to always pass in a I'll fix it. |
Summary: This method is unused. Worse, it uses the default system locale for formatting numbers, so its tests fail when the system locale uses a decimal comma instead of a decimal point (say, German). This deletes the unused method and its tests. This is a partial fix for #557 . Test Plan: Applied patch to force tests into German: https://gist.github.com/bhamiltoncx/4b6b5785b9d0ba4132e4 Ran `ant java-test -Dtest.class=SizeUnitTest`, confirmed it failed. Applied this fix, re-ran test, confirmed it passed. Reviewed By: Coneko fb-gh-sync-id: 6cba65f
The last of the fixes for this issue are out for review internally. I hope to land them today. |
…matting and parsing Summary: Buck currently formats and parses numbers in various ways, most of which are neither thread-safe nor i18n-safe. This provides a new wrapper `NumberFormatter` for Java's `NumberFormat` class which is both thread-safe and i18n-safe. Instead of using a `ThreadLocal<NumberFormat>` (which leaks memory), I use a `LoadingCache` which manages a `BlockingQueue<NumberFormat>`. When a thread needs to format a number, I call `LoadingCache.get(locale)`, then `blockingQueue.take()` to claim an unused `NumberFormat` for the calling thread. I then format the number and put the `NumberFormat` back on the queue. This is a partial fix for #557 . Test Plan: Unit tests included. `ant java-test -Dtest.class=NumberFormatterTest` and `buck test //test/com/facebook/buck/i18n:i18n`. Reviewed By: sdwilsh fb-gh-sync-id: 3daa33a
Apologies for the delay. The fixes were reviewed last night and are landing now. |
Summary: Previously, `SuperConsoleEventBusListener` and `SimpleConsoleEventBusListener` hard-coded the default locale of the running system. That meant timestamps were formattted like `0.0s` for US English and `0,0s` for German. Unfortunately, the tests had a mix of default locale and hard-coded US English timestamps. The tests all passed in our environment, but failed for people testing Buck in a non-English environment. This fixes the issue by passing a `Locale` down to `SimpleConsoleEventBusListener` / `SuperConsoleEventBusListener` and passing that to a `NumberFormatter` which deals with formatting timestamps appropriately for the locale. To keep this diff small, I didn't delete `SuperConsoleEventBusListenerTest.formatConsoleTimes()`, even though it's unnecessary now. In the next diff, I will delete the test utility method. Partial fix for #557 . Test Plan: New unit test added. `ant java-test -Dtest.class=SuperConsoleEventBusListenerTest`, `ant java-test -Dtest.class=SimpleConsoleEventBusListenerTest`. Applied this patch to repo to hard-code German language as system default in `ant java-test`: https://gist.github.com/bhamiltoncx/4b6b5785b9d0ba4132e4 Ran tests with `ant java-test -Dtest.class=SuperConsoleEventBusListenerTest` and `ant java-test -Dtest.class=SimpleConsoleEventBusListenerTest`, confirmed they both failed. Applied patch, re-ran tests, confirmed they both succeeded. Reviewed By: sdwilsh fb-gh-sync-id: 2339def
Summary: This is the last test which fails in non-US English locales. The only places it's used are from `TestResultSummary` and `TestCaseSummary`. Refactoring `TestResultSummary` to support multiple locales is pretty painful, so I hard-coded that class to US English. Refactoring `TestCaseSummary` isn't as bad, so I'll separately send out a diff to fix that. Temporarily, this diff hard-codes it to US English as well. Partial fix for #557 Test Plan: `ant java-test -Dtest.class=TimeFormatTest` Reviewed By: k21 fb-gh-sync-id: 78752f4
Thanks. Trying again on most recent master (ec75fa1) still some tests are failing here:
Here is the list of failing tests:
Here is more verbose log: |
The |
Thx. |
@bhamiltoncx Thanks for the analysis. I filed new issue to track this failure: #565. Does it work for you? I'm a bit confused. CI is broken, I cannot get test passed on my Linux machine and getting negative reviews because my PR #558 broke some tests. But how should I be able to track down this breakage, when tests are inherently broken on most recent master (ec75fa1) anyway? Or this is something that environment dependent? |
Fixed in: [1]. |
Fixed by: 447e59a |
Summary: This method is unused. Worse, it uses the default system locale for formatting numbers, so its tests fail when the system locale uses a decimal comma instead of a decimal point (say, German). This deletes the unused method and its tests. This is a partial fix for facebook#557 . Test Plan: Applied patch to force tests into German: https://gist.github.com/bhamiltoncx/4b6b5785b9d0ba4132e4 Ran `ant java-test -Dtest.class=SizeUnitTest`, confirmed it failed. Applied this fix, re-ran test, confirmed it passed. Reviewed By: Coneko fb-gh-sync-id: 6cba65f
…matting and parsing Summary: Buck currently formats and parses numbers in various ways, most of which are neither thread-safe nor i18n-safe. This provides a new wrapper `NumberFormatter` for Java's `NumberFormat` class which is both thread-safe and i18n-safe. Instead of using a `ThreadLocal<NumberFormat>` (which leaks memory), I use a `LoadingCache` which manages a `BlockingQueue<NumberFormat>`. When a thread needs to format a number, I call `LoadingCache.get(locale)`, then `blockingQueue.take()` to claim an unused `NumberFormat` for the calling thread. I then format the number and put the `NumberFormat` back on the queue. This is a partial fix for facebook#557 . Test Plan: Unit tests included. `ant java-test -Dtest.class=NumberFormatterTest` and `buck test //test/com/facebook/buck/i18n:i18n`. Reviewed By: sdwilsh fb-gh-sync-id: 3daa33a
Summary: Previously, `SuperConsoleEventBusListener` and `SimpleConsoleEventBusListener` hard-coded the default locale of the running system. That meant timestamps were formattted like `0.0s` for US English and `0,0s` for German. Unfortunately, the tests had a mix of default locale and hard-coded US English timestamps. The tests all passed in our environment, but failed for people testing Buck in a non-English environment. This fixes the issue by passing a `Locale` down to `SimpleConsoleEventBusListener` / `SuperConsoleEventBusListener` and passing that to a `NumberFormatter` which deals with formatting timestamps appropriately for the locale. To keep this diff small, I didn't delete `SuperConsoleEventBusListenerTest.formatConsoleTimes()`, even though it's unnecessary now. In the next diff, I will delete the test utility method. Partial fix for facebook#557 . Test Plan: New unit test added. `ant java-test -Dtest.class=SuperConsoleEventBusListenerTest`, `ant java-test -Dtest.class=SimpleConsoleEventBusListenerTest`. Applied this patch to repo to hard-code German language as system default in `ant java-test`: https://gist.github.com/bhamiltoncx/4b6b5785b9d0ba4132e4 Ran tests with `ant java-test -Dtest.class=SuperConsoleEventBusListenerTest` and `ant java-test -Dtest.class=SimpleConsoleEventBusListenerTest`, confirmed they both failed. Applied patch, re-ran tests, confirmed they both succeeded. Reviewed By: sdwilsh fb-gh-sync-id: 2339def
Summary: This is the last test which fails in non-US English locales. The only places it's used are from `TestResultSummary` and `TestCaseSummary`. Refactoring `TestResultSummary` to support multiple locales is pretty painful, so I hard-coded that class to US English. Refactoring `TestCaseSummary` isn't as bad, so I'll separately send out a diff to fix that. Temporarily, this diff hard-codes it to US English as well. Partial fix for facebook#557 Test Plan: `ant java-test -Dtest.class=TimeFormatTest` Reviewed By: k21 fb-gh-sync-id: 78752f4
Summary: This should be the last of the fixes to ensure our tests can control the locale under which they run. This passes `Locale` down to `TestCaseSummary` and `TestResultFormatter` so they no longer implicitly use the system locale. That allows us to ensure our tests pass when run in a non-English locale. Fixes facebook#557 Test Plan: New test added. ant java-test -Dtest.class=TestResultFormatterTest ant java-test -Dtest.class=TestRunTest Reviewed By: k21 fb-gh-sync-id: 28f2565
Trying to run tests on most recent master 4806fdf on two sane platforms (Linux with Java 7 and Mac OS X with Java 8) I'm seeing number of unit test failures:
The output above is from OS X 10.10.5 with this locale:
The list of failing tests is:
The text was updated successfully, but these errors were encountered: