@Test public void freeDiskPercentageAfterShardAssignedUnitTest() { RoutingNode rn = new RoutingNode("node1", newNode("node1")); DiskThresholdDecider decider = new DiskThresholdDecider(ImmutableSettings.EMPTY); Map<String, DiskUsage> usages = new HashMap<>(); usages.put("node2", new DiskUsage("node2", 100, 50)); // 50% used usages.put("node3", new DiskUsage("node3", 100, 0)); // 100% used Double after = decider.freeDiskPercentageAfterShardAssigned(new DiskUsage("node2", 100, 30), 11L); assertThat(after, equalTo(19.0)); }
@Test public void averageUsageUnitTest() { RoutingNode rn = new RoutingNode("node1", newNode("node1")); DiskThresholdDecider decider = new DiskThresholdDecider(ImmutableSettings.EMPTY); Map<String, DiskUsage> usages = new HashMap<>(); usages.put("node2", new DiskUsage("node2", 100, 50)); // 50% used usages.put("node3", new DiskUsage("node3", 100, 0)); // 100% used DiskUsage node1Usage = decider.averageUsage(rn, usages); assertThat(node1Usage.getTotalBytes(), equalTo(100L)); assertThat(node1Usage.getFreeBytes(), equalTo(25L)); }