Skip to content

Commit

Permalink
Rebased version of #12706 (#12933)
Browse files Browse the repository at this point in the history
* Fix Flaky SettingTests Tests

Signed-off-by: kkewwei <[email protected]>

* add the comment to unit test

Signed-off-by: kkewwei <[email protected]>

---------

Signed-off-by: kkewwei <[email protected]>
Co-authored-by: kkewwei <[email protected]>
(cherry picked from commit 839ee4c)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
github-actions[bot] and kkewwei committed Mar 27, 2024
1 parent 6043865 commit eda9834
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ public void testMemorySize() {
assertEquals(new ByteSizeValue(12), value.get());

assertTrue(settingUpdater.apply(Settings.builder().put("a.byte.size", "20%").build(), Settings.EMPTY));
assertEquals(new ByteSizeValue((int) (JvmInfo.jvmInfo().getMem().getHeapMax().getBytes() * 0.2)), value.get());
assertEquals(new ByteSizeValue((long) (JvmInfo.jvmInfo().getMem().getHeapMax().getBytes() * 0.2)), value.get());
}

public void testMemorySizeWithFallbackValue() {
Expand All @@ -219,10 +219,12 @@ public void testMemorySizeWithFallbackValue() {
assertEquals(memorySizeValue.getBytes(), JvmInfo.jvmInfo().getMem().getHeapMax().getBytes() * 0.2, 1.0);

assertTrue(settingUpdater.apply(Settings.builder().put("a.byte.size", "30%").build(), Settings.EMPTY));
assertEquals(new ByteSizeValue((int) (JvmInfo.jvmInfo().getMem().getHeapMax().getBytes() * 0.3)), value.get());
// If value=getHeapMax()*0.3 is bigger than 2gb, and is bigger than Integer.MAX_VALUE,
// then (long)((int) value) will lose precision.
assertEquals(new ByteSizeValue((long) (JvmInfo.jvmInfo().getMem().getHeapMax().getBytes() * 0.3)), value.get());

assertTrue(settingUpdater.apply(Settings.builder().put("b.byte.size", "40%").build(), Settings.EMPTY));
assertEquals(new ByteSizeValue((int) (JvmInfo.jvmInfo().getMem().getHeapMax().getBytes() * 0.4)), value.get());
assertEquals(new ByteSizeValue((long) (JvmInfo.jvmInfo().getMem().getHeapMax().getBytes() * 0.4)), value.get());
}

public void testSimpleUpdate() {
Expand Down

0 comments on commit eda9834

Please sign in to comment.