use of org.apache.storm.scheduler.resource.TestUtilsForResourceAwareScheduler.INimbusTest in project storm by apache.
the class TestUser method testResourcePoolUtilization.
@Test
public void testResourcePoolUtilization() {
INimbus iNimbus = new INimbusTest();
Map<String, SupervisorDetails> supMap = genSupervisors(4, 4, 100, 1000);
Double cpuGuarantee = 400.0;
Double memoryGuarantee = 1000.0;
Map<String, Map<String, Number>> resourceUserPool = userResourcePool(userRes("user1", cpuGuarantee, memoryGuarantee));
Config config = createClusterConfig(100, 200, 200, resourceUserPool);
TopologyDetails topo1 = genTopology("topo-1", config, 1, 1, 2, 1, Time.currentTimeSecs() - 24, 9, "user1");
Topologies topologies = new Topologies(topo1);
Cluster cluster = new Cluster(iNimbus, new ResourceMetrics(new StormMetricsRegistry()), supMap, new HashMap<>(), topologies, config);
User user1 = new User("user1", toDouble(resourceUserPool.get("user1")));
WorkerSlot slot = cluster.getAvailableSlots().get(0);
cluster.assign(slot, topo1.getId(), topo1.getExecutors());
Assert.assertEquals("check cpu resource guarantee", cpuGuarantee, user1.getCpuResourceGuaranteed(), 0.001);
Assert.assertEquals("check memory resource guarantee", memoryGuarantee, user1.getMemoryResourceGuaranteed(), 0.001);
Assert.assertEquals("check cpu resource pool utilization", ((100.0 * 3.0) / cpuGuarantee), user1.getCpuResourcePoolUtilization(cluster), 0.001);
Assert.assertEquals("check memory resource pool utilization", ((200.0 + 200.0) * 3.0) / memoryGuarantee, user1.getMemoryResourcePoolUtilization(cluster), 0.001);
}
Aggregations