Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
* Fix Flaky SettingTests Tests

Signed-off-by: kkewwei <kkewwei@163.com>

* add the comment to unit test

Signed-off-by: kkewwei <kkewwei@163.com>

---------

Signed-off-by: kkewwei <kkewwei@163.com>
Co-authored-by: kkewwei <kkewwei@163.com>
  • Loading branch information
2 people authored and harshavamsi committed Apr 29, 2024
1 parent 5dfb127 commit f83a1dc
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 f83a1dc

Please sign in to comment.